Browse Source

Added PixelArray::constructor

v1.x
Tj Holowaychuk 14 years ago
parent
commit
513f2a1098
  1. 5
      src/Canvas.cc
  2. 2
      src/Canvas.h
  3. 3
      src/CanvasGradient.cc
  4. 2
      src/CanvasGradient.h
  5. 3
      src/CanvasRenderingContext2d.cc
  6. 2
      src/CanvasRenderingContext2d.h
  7. 5
      src/Image.cc
  8. 2
      src/Image.h
  9. 4
      src/ImageData.cc
  10. 2
      src/ImageData.h
  11. 13
      src/PixelArray.cc
  12. 1
      src/PixelArray.h

5
src/Canvas.cc

@ -30,10 +30,13 @@
void
Canvas::Initialize(Handle<Object> target) {
HandleScope scope;
constructor = Persistent<FunctionTemplate>::New(FunctionTemplate::New(Canvas::New));
// Constructor
constructor = Persistent<FunctionTemplate>::New(FunctionTemplate::New(Canvas::New));
constructor->InstanceTemplate()->SetInternalFieldCount(1);
constructor->SetClassName(String::NewSymbol("Canvas"));
// Prototype
Local<ObjectTemplate> proto = constructor->PrototypeTemplate();
NODE_SET_PROTOTYPE_METHOD(constructor, "toBuffer", ToBuffer);
NODE_SET_PROTOTYPE_METHOD(constructor, "streamPNGSync", StreamPNGSync);

2
src/Canvas.h

@ -51,6 +51,7 @@ class Canvas: public node::ObjectWrap {
public:
int width;
int height;
static Persistent<FunctionTemplate> constructor;
static void Initialize(Handle<Object> target);
static Handle<Value> New(const Arguments &args);
static Handle<Value> ToBuffer(const Arguments &args);
@ -65,7 +66,6 @@ class Canvas: public node::ObjectWrap {
inline int stride(){ return cairo_image_surface_get_stride(_surface); }
Canvas(int width, int height);
void resurface();
static Persistent<FunctionTemplate> constructor;
private:
~Canvas();

3
src/CanvasGradient.cc

@ -15,10 +15,13 @@
void
Gradient::Initialize(Handle<Object> target) {
HandleScope scope;
// Constructor
constructor = Persistent<FunctionTemplate>::New(FunctionTemplate::New(Gradient::New));
constructor->InstanceTemplate()->SetInternalFieldCount(1);
constructor->SetClassName(String::NewSymbol("CanvasGradient"));
// Prototype
NODE_SET_PROTOTYPE_METHOD(constructor, "addColorStopRGBA", AddColorStopRGBA);
target->Set(String::NewSymbol("CanvasGradient"), constructor->GetFunction());
}

2
src/CanvasGradient.h

@ -12,13 +12,13 @@
class Gradient: public node::ObjectWrap {
public:
static Persistent<FunctionTemplate> constructor;
static void Initialize(Handle<Object> target);
static Handle<Value> New(const Arguments &args);
static Handle<Value> AddColorStopRGBA(const Arguments &args);
Gradient(double x0, double y0, double x1, double y1);
Gradient(double x0, double y0, double r0, double x1, double y1, double r1);
inline cairo_pattern_t *pattern(){ return _pattern; }
static Persistent<FunctionTemplate> constructor;
private:
~Gradient();

3
src/CanvasRenderingContext2d.cc

@ -58,8 +58,9 @@ enum {
void
Context2d::Initialize(Handle<Object> target) {
HandleScope scope;
// Constructor
constructor = Persistent<FunctionTemplate>::New(FunctionTemplate::New(Context2d::New));
constructor = Persistent<FunctionTemplate>::New(FunctionTemplate::New(Context2d::New));
constructor->InstanceTemplate()->SetInternalFieldCount(1);
constructor->SetClassName(String::NewSymbol("CanvasRenderingContext2d"));

2
src/CanvasRenderingContext2d.h

@ -45,6 +45,7 @@ class Context2d: public node::ObjectWrap {
short stateno;
canvas_state_t *states[CANVAS_MAX_STATES];
canvas_state_t *state;
static Persistent<FunctionTemplate> constructor;
static void Initialize(Handle<Object> target);
static Handle<Value> New(const Arguments &args);
static Handle<Value> DrawImage(const Arguments &args);
@ -119,7 +120,6 @@ class Context2d: public node::ObjectWrap {
void stroke(bool preserve = false);
void save();
void restore();
static Persistent<FunctionTemplate> constructor;
protected:
Context2d(Canvas *canvas);

5
src/Image.cc

@ -17,10 +17,13 @@
void
Image::Initialize(Handle<Object> target) {
HandleScope scope;
constructor = Persistent<FunctionTemplate>::New(FunctionTemplate::New(Image::New));
// Constructor
constructor = Persistent<FunctionTemplate>::New(FunctionTemplate::New(Image::New));
constructor->InstanceTemplate()->SetInternalFieldCount(1);
constructor->SetClassName(String::NewSymbol("Image"));
// Prototype
Local<ObjectTemplate> proto = constructor->PrototypeTemplate();
proto->SetAccessor(String::NewSymbol("src"), GetSrc, SetSrc);
proto->SetAccessor(String::NewSymbol("complete"), GetComplete);

2
src/Image.h

@ -16,6 +16,7 @@ class Image: public node::ObjectWrap {
int width, height;
Persistent<Function> onload;
Persistent<Function> onerror;
static Persistent<FunctionTemplate> constructor;
static void Initialize(Handle<Object> target);
static Handle<Value> New(const Arguments &args);
static Handle<Value> GetSrc(Local<String> prop, const AccessorInfo &info);
@ -36,7 +37,6 @@ class Image: public node::ObjectWrap {
void loaded();
void load();
Image();
static Persistent<FunctionTemplate> constructor;
enum {
DEFAULT

4
src/ImageData.cc

@ -14,7 +14,9 @@
void
ImageData::Initialize(Handle<Object> target) {
HandleScope scope;
constructor = Persistent<FunctionTemplate>::New(FunctionTemplate::New(ImageData::New));
// Constructor
constructor = Persistent<FunctionTemplate>::New(FunctionTemplate::New(ImageData::New));
constructor->InstanceTemplate()->SetInternalFieldCount(1);
constructor->SetClassName(String::NewSymbol("ImageData"));

2
src/ImageData.h

@ -14,7 +14,7 @@
class ImageData: public node::ObjectWrap {
public:
static Persistent<FunctionTemplate> constructor;
static Persistent<FunctionTemplate> constructor;
static void Initialize(Handle<Object> target);
static Handle<Value> New(const Arguments &args);
static Handle<Value> GetWidth(Local<String> prop, const AccessorInfo &info);

13
src/PixelArray.cc

@ -16,13 +16,16 @@
void
PixelArray::Initialize(Handle<Object> target) {
HandleScope scope;
Local<FunctionTemplate> t = FunctionTemplate::New(PixelArray::New);
t->InstanceTemplate()->SetInternalFieldCount(1);
t->SetClassName(String::NewSymbol("CanvasPixelArray"));
Local<ObjectTemplate> proto = t->InstanceTemplate();
// Constructor
constructor = Persistent<FunctionTemplate>::New(FunctionTemplate::New(PixelArray::New));
constructor->InstanceTemplate()->SetInternalFieldCount(1);
constructor->SetClassName(String::NewSymbol("CanvasPixelArray"));
// Prototype
Local<ObjectTemplate> proto = constructor->InstanceTemplate();
proto->SetAccessor(String::NewSymbol("length"), GetLength);
target->Set(String::NewSymbol("CanvasPixelArray"), t->GetFunction());
target->Set(String::NewSymbol("CanvasPixelArray"), constructor->GetFunction());
}
/*

1
src/PixelArray.h

@ -12,6 +12,7 @@
class PixelArray: public node::ObjectWrap {
public:
static Persistent<FunctionTemplate> constructor;
static void Initialize(Handle<Object> target);
static Handle<Value> New(const Arguments &args);
static Handle<Value> GetLength(Local<String> prop, const AccessorInfo &info);

Loading…
Cancel
Save