Browse Source

Added Canvas::constructor

v1.x
Tj Holowaychuk 14 years ago
parent
commit
644b77c311
  1. 14
      src/Canvas.cc
  2. 1
      src/Canvas.h

14
src/Canvas.cc

@ -30,16 +30,16 @@
void void
Canvas::Initialize(Handle<Object> target) { Canvas::Initialize(Handle<Object> target) {
HandleScope scope; HandleScope scope;
Local<FunctionTemplate> t = FunctionTemplate::New(Canvas::New); constructor = Persistent<FunctionTemplate>::New(FunctionTemplate::New(Canvas::New));
t->InstanceTemplate()->SetInternalFieldCount(1); constructor->InstanceTemplate()->SetInternalFieldCount(1);
t->SetClassName(String::NewSymbol("Canvas")); constructor->SetClassName(String::NewSymbol("Canvas"));
Local<ObjectTemplate> proto = t->PrototypeTemplate(); Local<ObjectTemplate> proto = constructor->PrototypeTemplate();
NODE_SET_PROTOTYPE_METHOD(t, "toBuffer", ToBuffer); NODE_SET_PROTOTYPE_METHOD(constructor, "toBuffer", ToBuffer);
NODE_SET_PROTOTYPE_METHOD(t, "streamPNGSync", StreamPNGSync); NODE_SET_PROTOTYPE_METHOD(constructor, "streamPNGSync", StreamPNGSync);
proto->SetAccessor(String::NewSymbol("width"), GetWidth, SetWidth); proto->SetAccessor(String::NewSymbol("width"), GetWidth, SetWidth);
proto->SetAccessor(String::NewSymbol("height"), GetHeight, SetHeight); proto->SetAccessor(String::NewSymbol("height"), GetHeight, SetHeight);
target->Set(String::NewSymbol("Canvas"), t->GetFunction()); target->Set(String::NewSymbol("Canvas"), constructor->GetFunction());
} }
/* /*

1
src/Canvas.h

@ -65,6 +65,7 @@ class Canvas: public node::ObjectWrap {
inline int stride(){ return cairo_image_surface_get_stride(_surface); } inline int stride(){ return cairo_image_surface_get_stride(_surface); }
Canvas(int width, int height); Canvas(int width, int height);
void resurface(); void resurface();
static Persistent<FunctionTemplate> constructor;
private: private:
~Canvas(); ~Canvas();

Loading…
Cancel
Save