Browse Source

Merge pull request #124 from TooTallNate/0.5.x-compat

0.6.x Compat
v1.x
TJ Holowaychuk 13 years ago
parent
commit
8071ee58a1
  1. 10
      lib/bindings.js
  2. 2
      lib/canvas.js
  3. 2
      lib/context2d.js
  4. 2
      lib/image.js
  5. 2
      lib/pixelarray.js
  6. 6
      src/Canvas.cc
  7. 9
      src/Canvas.h

10
lib/bindings.js

@ -0,0 +1,10 @@
/**
* Compat for changes from node 0.4.x to 0.6.x.
*/
try {
module.exports = require('../build/Release/canvas');
} catch (e) { try {
module.exports = require('../build/default/canvas');
} catch (e) {
throw e;
}}

2
lib/canvas.js

@ -9,7 +9,7 @@
* Module dependencies. * Module dependencies.
*/ */
var canvas = require('../build/default/canvas') var canvas = require('./bindings')
, Canvas = canvas.Canvas , Canvas = canvas.Canvas
, Image = canvas.Image , Image = canvas.Image
, cairoVersion = canvas.cairoVersion , cairoVersion = canvas.cairoVersion

2
lib/context2d.js

@ -9,7 +9,7 @@
* Module dependencies. * Module dependencies.
*/ */
var canvas = require('../build/default/canvas') var canvas = require('./bindings')
, Context2d = canvas.CanvasRenderingContext2d , Context2d = canvas.CanvasRenderingContext2d
, CanvasGradient = canvas.CanvasGradient , CanvasGradient = canvas.CanvasGradient
, ImageData = canvas.ImageData , ImageData = canvas.ImageData

2
lib/image.js

@ -9,7 +9,7 @@
* Module dependencies. * Module dependencies.
*/ */
var Canvas = require('../build/default/canvas') var Canvas = require('./bindings')
, Image = Canvas.Image; , Image = Canvas.Image;
/** /**

2
lib/pixelarray.js

@ -9,7 +9,7 @@
* Module dependencies. * Module dependencies.
*/ */
var Canvas = require('../build/default/canvas') var Canvas = require('./bindings')
, PixelArray = Canvas.CanvasPixelArray; , PixelArray = Canvas.CanvasPixelArray;
/** /**

6
src/Canvas.cc

@ -133,7 +133,11 @@ toBuffer(void *c, const uint8_t *data, unsigned len) {
* EIO toBuffer callback. * EIO toBuffer callback.
*/ */
#if NODE_VERSION_AT_LEAST(0, 5, 4)
void
#else
int int
#endif
Canvas::EIO_ToBuffer(eio_req *req) { Canvas::EIO_ToBuffer(eio_req *req) {
closure_t *closure = (closure_t *) req->data; closure_t *closure = (closure_t *) req->data;
@ -142,7 +146,9 @@ Canvas::EIO_ToBuffer(eio_req *req) {
, toBuffer , toBuffer
, closure); , closure);
#if !NODE_VERSION_AT_LEAST(0, 5, 4)
return 0; return 0;
#endif
} }
/* /*

9
src/Canvas.h

@ -11,6 +11,7 @@
#include <v8.h> #include <v8.h>
#include <node.h> #include <node.h>
#include <node_object_wrap.h> #include <node_object_wrap.h>
#include <node_version.h>
#include <cairo.h> #include <cairo.h>
using namespace v8; using namespace v8;
@ -43,7 +44,13 @@ class Canvas: public node::ObjectWrap {
static void SetHeight(Local<String> prop, Local<Value> val, const AccessorInfo &info); static void SetHeight(Local<String> prop, Local<Value> val, const AccessorInfo &info);
static Handle<Value> StreamPNGSync(const Arguments &args); static Handle<Value> StreamPNGSync(const Arguments &args);
static Local<Value> Error(cairo_status_t status); static Local<Value> Error(cairo_status_t status);
static int EIO_ToBuffer(eio_req *req); static
#if NODE_VERSION_AT_LEAST(0, 5, 4)
void
#else
int
#endif
EIO_ToBuffer(eio_req *req);
static int EIO_AfterToBuffer(eio_req *req); static int EIO_AfterToBuffer(eio_req *req);
inline cairo_surface_t *surface(){ return _surface; } inline cairo_surface_t *surface(){ return _surface; }
inline uint8_t *data(){ return cairo_image_surface_get_data(_surface); } inline uint8_t *data(){ return cairo_image_surface_get_data(_surface); }

Loading…
Cancel
Save