From 4c7788fd6835546ea885f89ae1998edf0ad593ef Mon Sep 17 00:00:00 2001 From: Tj Holowaychuk Date: Mon, 8 Nov 2010 18:11:56 -0800 Subject: [PATCH 1/3] Use of Local --- src/Canvas.cc | 13 ++++++++----- src/Canvas.h | 2 +- 2 files changed, 9 insertions(+), 6 deletions(-) diff --git a/src/Canvas.cc b/src/Canvas.cc index 6536db6..b87a175 100644 --- a/src/Canvas.cc +++ b/src/Canvas.cc @@ -155,12 +155,12 @@ EIO_AfterToBuffer(eio_req *req) { ev_unref(EV_DEFAULT_UC); if (closure->status) { - Handle argv[1] = { Canvas::Error(closure->status) }; + Local argv[1] = { Canvas::Error(closure->status) }; closure->pfn->Call(Context::GetCurrent()->Global(), 1, argv); } else { Buffer *buf = Buffer::New(closure->len); memcpy(buf->data(), closure->data, closure->len); - Handle argv[2] = { Null(), buf->handle_ }; + Local argv[2] = { Local::New(Null()), Local::New(buf->handle_) }; closure->pfn->Call(Context::GetCurrent()->Global(), 2, argv); } @@ -248,10 +248,13 @@ Canvas::StreamPNGSync(const Arguments &args) { if (try_catch.HasCaught()) { return try_catch.ReThrow(); } else if (status) { - Handle argv[1] = { Canvas::Error(status) }; + Local argv[1] = { Canvas::Error(status) }; closure.fn->Call(Context::GetCurrent()->Global(), 1, argv); } else { - Handle argv[3] = { Null(), Null(), Integer::New(0) }; + Local argv[3] = { + Local::New(Null()) + , Local::New(Null()) + , Integer::New(0) }; closure.fn->Call(Context::GetCurrent()->Global(), 3, argv); } return Undefined(); @@ -289,7 +292,7 @@ Canvas::resurface() { * Construct an Error from the given cairo status. */ -Handle +Local Canvas::Error(cairo_status_t status) { return Exception::Error(String::New(cairo_status_to_string(status))); } diff --git a/src/Canvas.h b/src/Canvas.h index 6902b26..a46ae03 100644 --- a/src/Canvas.h +++ b/src/Canvas.h @@ -58,7 +58,7 @@ class Canvas: public node::ObjectWrap { static void SetWidth(Local prop, Local val, const AccessorInfo &info); static void SetHeight(Local prop, Local val, const AccessorInfo &info); static Handle StreamPNGSync(const Arguments &args); - static Handle Error(cairo_status_t status); + static Local Error(cairo_status_t status); inline cairo_surface_t *getSurface(){ return _surface; } Canvas(int width, int height); void resurface(); From e2df4d491e10cb0116e670f69d1450cd82f4e2a9 Mon Sep 17 00:00:00 2001 From: Tj Holowaychuk Date: Mon, 8 Nov 2010 18:13:22 -0800 Subject: [PATCH 2/3] More locals --- src/Canvas.cc | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/src/Canvas.cc b/src/Canvas.cc index b87a175..77971fd 100644 --- a/src/Canvas.cc +++ b/src/Canvas.cc @@ -215,6 +215,7 @@ Canvas::ToBuffer(const Arguments &args) { static cairo_status_t streamPNG(void *c, const uint8_t *data, unsigned len) { + HandleScope scope; closure_t *closure = (closure_t *) c; Buffer *buf = Buffer::New(len); #if NODE_VERSION_AT_LEAST(0,3,0) @@ -222,7 +223,10 @@ streamPNG(void *c, const uint8_t *data, unsigned len) { #else memcpy(buf->data(), data, len); #endif - Handle argv[3] = { Null(), buf->handle_, Integer::New(len) }; + Local argv[3] = { + Local::New(Null()) + , Local::New(buf->handle_) + , Integer::New(len) }; closure->fn->Call(Context::GetCurrent()->Global(), 3, argv); return CAIRO_STATUS_SUCCESS; } From 5858b47d668a1b3785abca625f4d895e10234dc2 Mon Sep 17 00:00:00 2001 From: Tj Holowaychuk Date: Mon, 8 Nov 2010 18:16:03 -0800 Subject: [PATCH 3/3] locals --- src/Canvas.cc | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/Canvas.cc b/src/Canvas.cc index 77971fd..0c25e66 100644 --- a/src/Canvas.cc +++ b/src/Canvas.cc @@ -217,7 +217,7 @@ static cairo_status_t streamPNG(void *c, const uint8_t *data, unsigned len) { HandleScope scope; closure_t *closure = (closure_t *) c; - Buffer *buf = Buffer::New(len); + Local buf = Buffer::New(len); #if NODE_VERSION_AT_LEAST(0,3,0) memcpy(Buffer::Data(buf->handle_), data, len); #else