From 8dbdd009b56507994f97a4ad6e7686d0485af03d Mon Sep 17 00:00:00 2001 From: King Koopa Date: Sun, 16 Mar 2014 13:47:48 +0200 Subject: [PATCH 1/6] Runs on new v8. --- package.json | 2 +- src/Canvas.cc | 70 ++++++++++---------- src/Canvas.h | 2 +- src/CanvasGradient.cc | 8 +-- src/CanvasGradient.h | 2 +- src/CanvasPattern.cc | 4 +- src/CanvasPattern.h | 2 +- src/CanvasRenderingContext2d.cc | 110 ++++++++++++++++---------------- src/FontFace.cc | 8 +-- src/Image.cc | 28 ++++---- src/Image.h | 2 +- src/ImageData.cc | 8 +-- src/JPEGStream.h | 26 ++++---- src/PixelArray.cc | 12 ++-- src/closure.h | 6 +- src/init.cc | 8 +-- 16 files changed, 149 insertions(+), 149 deletions(-) diff --git a/package.json b/package.json index a940eed..10a2961 100644 --- a/package.json +++ b/package.json @@ -14,7 +14,7 @@ "test": "make test" } , "dependencies": { - "nan": "~0.7.0" + "nan": "git://github.com/rvagg/nan.git#cleanup" } , "devDependencies": { "express": "3.0" diff --git a/src/Canvas.cc b/src/Canvas.cc index 306904f..25919dd 100644 --- a/src/Canvas.cc +++ b/src/Canvas.cc @@ -30,8 +30,8 @@ Canvas::Initialize(Handle target) { NanScope(); // Constructor - Local ctor = FunctionTemplate::New(Canvas::New); - NanAssignPersistent(FunctionTemplate, constructor, ctor); + Local ctor = NanNew(Canvas::New); + NanAssignPersistent(constructor, ctor); ctor->InstanceTemplate()->SetInternalFieldCount(1); ctor->SetClassName(NanSymbol("Canvas")); @@ -46,13 +46,13 @@ Canvas::Initialize(Handle target) { proto->SetAccessor(NanSymbol("width"), GetWidth, SetWidth); proto->SetAccessor(NanSymbol("height"), GetHeight, SetHeight); - proto->Set("PNG_NO_FILTERS", Uint32::New(PNG_NO_FILTERS)); - proto->Set("PNG_FILTER_NONE", Uint32::New(PNG_FILTER_NONE)); - proto->Set("PNG_FILTER_SUB", Uint32::New(PNG_FILTER_SUB)); - proto->Set("PNG_FILTER_UP", Uint32::New(PNG_FILTER_UP)); - proto->Set("PNG_FILTER_AVG", Uint32::New(PNG_FILTER_AVG)); - proto->Set("PNG_FILTER_PAETH", Uint32::New(PNG_FILTER_PAETH)); - proto->Set("PNG_ALL_FILTERS", Uint32::New(PNG_ALL_FILTERS)); + NanSetTemplate(proto, "PNG_NO_FILTERS", NanNew(PNG_NO_FILTERS)); + NanSetTemplate(proto, "PNG_FILTER_NONE", NanNew(PNG_FILTER_NONE)); + NanSetTemplate(proto, "PNG_FILTER_SUB", NanNew(PNG_FILTER_SUB)); + NanSetTemplate(proto, "PNG_FILTER_UP", NanNew(PNG_FILTER_UP)); + NanSetTemplate(proto, "PNG_FILTER_AVG", NanNew(PNG_FILTER_AVG)); + NanSetTemplate(proto, "PNG_FILTER_PAETH", NanNew(PNG_FILTER_PAETH)); + NanSetTemplate(proto, "PNG_ALL_FILTERS", NanNew(PNG_ALL_FILTERS)); target->Set(NanSymbol("Canvas"), ctor->GetFunction()); } @@ -67,7 +67,7 @@ NAN_METHOD(Canvas::New) { canvas_type_t type = CANVAS_TYPE_IMAGE; if (args[0]->IsNumber()) width = args[0]->Uint32Value(); if (args[1]->IsNumber()) height = args[1]->Uint32Value(); - if (args[2]->IsString()) type = !strcmp("pdf", *String::AsciiValue(args[2])) + if (args[2]->IsString()) type = !strcmp("pdf", *String::Utf8Value(args[2])) ? CANVAS_TYPE_PDF : CANVAS_TYPE_IMAGE; Canvas *canvas = new Canvas(width, height, type); @@ -82,7 +82,7 @@ NAN_METHOD(Canvas::New) { NAN_GETTER(Canvas::GetType) { NanScope(); Canvas *canvas = ObjectWrap::Unwrap(args.This()); - NanReturnValue(String::New(canvas->isPDF() ? "pdf" : "image")); + NanReturnValue(NanNew(canvas->isPDF() ? "pdf" : "image")); } /* @@ -92,7 +92,7 @@ NAN_GETTER(Canvas::GetType) { NAN_GETTER(Canvas::GetWidth) { NanScope(); Canvas *canvas = ObjectWrap::Unwrap(args.This()); - NanReturnValue(Number::New(canvas->width)); + NanReturnValue(NanNew(canvas->width)); } /* @@ -115,7 +115,7 @@ NAN_SETTER(Canvas::SetWidth) { NAN_GETTER(Canvas::GetHeight) { NanScope(); Canvas *canvas = ObjectWrap::Unwrap(args.This()); - NanReturnValue(Number::New(canvas->height)); + NanReturnValue(NanNew(canvas->height)); } /* @@ -211,7 +211,7 @@ Canvas::EIO_AfterToBuffer(eio_req *req) { } else { Local buf = NanNewBufferHandle((char*)closure->data, closure->len); memcpy(Buffer::Data(buf), closure->data, closure->len); - Local argv[2] = { NanNewLocal(Null()), buf }; + Local argv[2] = { NanNew(NanNull()), buf }; closure->pfn->Call(2, argv); } @@ -246,13 +246,13 @@ NAN_METHOD(Canvas::ToBuffer) { NanReturnValue(buf); } - if (args.Length() > 1 && !(args[1]->StrictEquals(Undefined()) && args[2]->StrictEquals(Undefined()))) { - if (!args[1]->StrictEquals(Undefined())) { + if (args.Length() > 1 && !(args[1]->StrictEquals(NanUndefined()) && args[2]->StrictEquals(NanUndefined()))) { + if (!args[1]->StrictEquals(NanUndefined())) { bool good = true; if (args[1]->IsNumber()) { compression_level = args[1]->Uint32Value(); } else if (args[1]->IsString()) { - if (args[1]->StrictEquals(String::New("0"))) { + if (args[1]->StrictEquals(NanNew("0"))) { compression_level = 0; } else { uint32_t tmp = args[1]->Uint32Value(); @@ -275,7 +275,7 @@ NAN_METHOD(Canvas::ToBuffer) { } } - if (!args[2]->StrictEquals(Undefined())) { + if (!args[2]->StrictEquals(NanUndefined())) { if (args[2]->IsUint32()) { filter = args[2]->Uint32Value(); } else { @@ -348,10 +348,10 @@ streamPNG(void *c, const uint8_t *data, unsigned len) { closure_t *closure = (closure_t *) c; Local buf = NanNewBufferHandle((char *)data, len); Local argv[3] = { - NanNewLocal(Null()) + NanNew(NanNull()) , buf - , Integer::New(len) }; - MakeCallback(Context::GetCurrent()->Global(), closure->fn, 3, argv); + , NanNew(len) }; + NanMakeCallback(NanGetCurrentContext()->Global(), closure->fn, 3, argv); return CAIRO_STATUS_SUCCESS; } @@ -367,13 +367,13 @@ NAN_METHOD(Canvas::StreamPNGSync) { if (!args[0]->IsFunction()) return NanThrowTypeError("callback function required"); - if (args.Length() > 1 && !(args[1]->StrictEquals(Undefined()) && args[2]->StrictEquals(Undefined()))) { - if (!args[1]->StrictEquals(Undefined())) { + if (args.Length() > 1 && !(args[1]->StrictEquals(NanUndefined()) && args[2]->StrictEquals(NanUndefined()))) { + if (!args[1]->StrictEquals(NanUndefined())) { bool good = true; if (args[1]->IsNumber()) { compression_level = args[1]->Uint32Value(); } else if (args[1]->IsString()) { - if (args[1]->StrictEquals(String::New("0"))) { + if (args[1]->StrictEquals(NanNew("0"))) { compression_level = 0; } else { uint32_t tmp = args[1]->Uint32Value(); @@ -396,7 +396,7 @@ NAN_METHOD(Canvas::StreamPNGSync) { } } - if (!args[2]->StrictEquals(Undefined())) { + if (!args[2]->StrictEquals(NanUndefined())) { if (args[2]->IsUint32()) { filter = args[1]->Uint32Value(); } else { @@ -420,13 +420,13 @@ NAN_METHOD(Canvas::StreamPNGSync) { NanReturnValue(try_catch.ReThrow()); } else if (status) { Local argv[1] = { Canvas::Error(status) }; - MakeCallback(Context::GetCurrent()->Global(), closure.fn, 1, argv); + NanMakeCallback(NanGetCurrentContext()->Global(), closure.fn, 1, argv); } else { Local argv[3] = { - NanNewLocal(Null()) - , NanNewLocal(Null()) - , Integer::New(0) }; - MakeCallback(Context::GetCurrent()->Global(), closure.fn, 3, argv); + NanNew(NanNull()) + , NanNew(NanNull()) + , NanNew(0) }; + NanMakeCallback(NanGetCurrentContext()->Global(), closure.fn, 3, argv); } NanReturnUndefined(); } @@ -483,7 +483,7 @@ Canvas::Canvas(int w, int h, canvas_type_t t): ObjectWrap() { } else { _surface = cairo_image_surface_create(CAIRO_FORMAT_ARGB32, w, h); assert(_surface); - V8::AdjustAmountOfExternalAllocatedMemory(4 * w * h); + NanAdjustExternalMemory(4 * w * h); } } @@ -501,7 +501,7 @@ Canvas::~Canvas() { break; case CANVAS_TYPE_IMAGE: cairo_surface_destroy(_surface); - V8::AdjustAmountOfExternalAllocatedMemory(-4 * width * height); + NanAdjustExternalMemory(-4 * width * height); break; } } @@ -522,10 +522,10 @@ Canvas::resurface(Handle canvas) { int old_height = cairo_image_surface_get_height(_surface); cairo_surface_destroy(_surface); _surface = cairo_image_surface_create(CAIRO_FORMAT_ARGB32, width, height); - V8::AdjustAmountOfExternalAllocatedMemory(4 * (width * height - old_width * old_height)); + NanAdjustExternalMemory(4 * (width * height - old_width * old_height)); // Reset context - Handle context = canvas->Get(String::New("context")); + Handle context = canvas->Get(NanNew("context")); if (!context->IsUndefined()) { Context2d *context2d = ObjectWrap::Unwrap(context->ToObject()); cairo_t *prev = context2d->context(); @@ -542,5 +542,5 @@ Canvas::resurface(Handle canvas) { Local Canvas::Error(cairo_status_t status) { - return Exception::Error(String::New(cairo_status_to_string(status))); + return Exception::Error(NanNew(cairo_status_to_string(status))); } diff --git a/src/Canvas.h b/src/Canvas.h index 912d2e2..1dae9b1 100644 --- a/src/Canvas.h +++ b/src/Canvas.h @@ -19,7 +19,7 @@ #include #endif -#include "nan.h" +#include using namespace v8; using namespace node; diff --git a/src/CanvasGradient.cc b/src/CanvasGradient.cc index 802224e..9be3f48 100644 --- a/src/CanvasGradient.cc +++ b/src/CanvasGradient.cc @@ -20,8 +20,8 @@ Gradient::Initialize(Handle target) { NanScope(); // Constructor - Local ctor = FunctionTemplate::New(Gradient::New); - NanAssignPersistent(FunctionTemplate, constructor, ctor); + Local ctor = NanNew(Gradient::New); + NanAssignPersistent(constructor, ctor); ctor->InstanceTemplate()->SetInternalFieldCount(1); ctor->SetClassName(NanSymbol("CanvasGradient")); @@ -60,7 +60,7 @@ NAN_METHOD(Gradient::New) { grad->Wrap(args.This()); NanReturnValue(args.This()); } - + return NanThrowTypeError("invalid arguments"); } @@ -77,7 +77,7 @@ NAN_METHOD(Gradient::AddColorStop) { Gradient *grad = ObjectWrap::Unwrap(args.This()); short ok; - String::AsciiValue str(args[1]); + String::Utf8Value str(args[1]); uint32_t rgba = rgba_from_string(*str, &ok); if (ok) { diff --git a/src/CanvasGradient.h b/src/CanvasGradient.h index 69808e5..49a9c73 100644 --- a/src/CanvasGradient.h +++ b/src/CanvasGradient.h @@ -8,7 +8,7 @@ #ifndef __NODE_GRADIENT_H__ #define __NODE_GRADIENT_H__ -#include "nan.h" +#include #include "Canvas.h" class Gradient: public node::ObjectWrap { diff --git a/src/CanvasPattern.cc b/src/CanvasPattern.cc index 16bb99f..d874bf4 100644 --- a/src/CanvasPattern.cc +++ b/src/CanvasPattern.cc @@ -20,8 +20,8 @@ Pattern::Initialize(Handle target) { NanScope(); // Constructor - Local ctor = FunctionTemplate::New(Pattern::New); - NanAssignPersistent(FunctionTemplate, constructor, ctor); + Local ctor = NanNew(Pattern::New); + NanAssignPersistent(constructor, ctor); ctor->InstanceTemplate()->SetInternalFieldCount(1); ctor->SetClassName(NanSymbol("CanvasPattern")); diff --git a/src/CanvasPattern.h b/src/CanvasPattern.h index 2cc3ecc..fbe9fe3 100644 --- a/src/CanvasPattern.h +++ b/src/CanvasPattern.h @@ -8,7 +8,7 @@ #ifndef __NODE_PATTERN_H__ #define __NODE_PATTERN_H__ -#include "nan.h" +#include #include "Canvas.h" class Pattern: public node::ObjectWrap { diff --git a/src/CanvasRenderingContext2d.cc b/src/CanvasRenderingContext2d.cc index a6c1621..1aeb562 100644 --- a/src/CanvasRenderingContext2d.cc +++ b/src/CanvasRenderingContext2d.cc @@ -81,8 +81,8 @@ Context2d::Initialize(Handle target) { NanScope(); // Constructor - Local ctor = FunctionTemplate::New(Context2d::New); - NanAssignPersistent(FunctionTemplate, constructor, ctor); + Local ctor = NanNew(Context2d::New); + NanAssignPersistent(constructor, ctor); ctor->InstanceTemplate()->SetInternalFieldCount(1); ctor->SetClassName(NanSymbol("CanvasRenderingContext2d")); @@ -694,7 +694,7 @@ NAN_METHOD(Context2d::DrawImage) { NAN_GETTER(Context2d::GetGlobalAlpha) { NanScope(); Context2d *context = ObjectWrap::Unwrap(args.This()); - NanReturnValue(Number::New(context->state->globalAlpha)); + NanReturnValue(NanNew(context->state->globalAlpha)); } /* @@ -764,7 +764,7 @@ NAN_GETTER(Context2d::GetGlobalCompositeOperation) { NAN_SETTER(Context2d::SetPatternQuality) { Context2d *context = ObjectWrap::Unwrap(args.This()); - String::AsciiValue quality(value->ToString()); + String::Utf8Value quality(value->ToString()); if (0 == strcmp("fast", *quality)) { context->state->patternQuality = CAIRO_FILTER_FAST; } else if (0 == strcmp("good", *quality)) { @@ -803,7 +803,7 @@ NAN_GETTER(Context2d::GetPatternQuality) { NAN_SETTER(Context2d::SetGlobalCompositeOperation) { Context2d *context = ObjectWrap::Unwrap(args.This()); cairo_t *ctx = context->context(); - String::AsciiValue type(value->ToString()); + String::Utf8Value type(value->ToString()); if (0 == strcmp("xor", *type)) { cairo_set_operator(ctx, CAIRO_OPERATOR_XOR); } else if (0 == strcmp("source-atop", *type)) { @@ -878,7 +878,7 @@ NAN_SETTER(Context2d::SetGlobalCompositeOperation) { NAN_GETTER(Context2d::GetShadowOffsetX) { NanScope(); Context2d *context = ObjectWrap::Unwrap(args.This()); - NanReturnValue(Number::New(context->state->shadowOffsetX)); + NanReturnValue(NanNew(context->state->shadowOffsetX)); } /* @@ -897,7 +897,7 @@ NAN_SETTER(Context2d::SetShadowOffsetX) { NAN_GETTER(Context2d::GetShadowOffsetY) { NanScope(); Context2d *context = ObjectWrap::Unwrap(args.This()); - NanReturnValue(Number::New(context->state->shadowOffsetY)); + NanReturnValue(NanNew(context->state->shadowOffsetY)); } /* @@ -916,7 +916,7 @@ NAN_SETTER(Context2d::SetShadowOffsetY) { NAN_GETTER(Context2d::GetShadowBlur) { NanScope(); Context2d *context = ObjectWrap::Unwrap(args.This()); - NanReturnValue(Number::New(context->state->shadowBlur)); + NanReturnValue(NanNew(context->state->shadowBlur)); } /* @@ -953,7 +953,7 @@ NAN_GETTER(Context2d::GetAntiAlias) { */ NAN_SETTER(Context2d::SetAntiAlias) { - String::AsciiValue str(value->ToString()); + String::Utf8Value str(value->ToString()); Context2d *context = ObjectWrap::Unwrap(args.This()); cairo_t *ctx = context->context(); cairo_antialias_t a; @@ -994,7 +994,7 @@ NAN_GETTER(Context2d::GetTextDrawingMode) { */ NAN_SETTER(Context2d::SetTextDrawingMode) { - String::AsciiValue str(value->ToString()); + String::Utf8Value str(value->ToString()); Context2d *context = ObjectWrap::Unwrap(args.This()); if (0 == strcmp("path", *str)) { context->state->textDrawingMode = TEXT_DRAW_PATHS; @@ -1026,7 +1026,7 @@ NAN_GETTER(Context2d::GetFilter) { */ NAN_SETTER(Context2d::SetFilter) { - String::AsciiValue str(value->ToString()); + String::Utf8Value str(value->ToString()); Context2d *context = ObjectWrap::Unwrap(args.This()); cairo_filter_t filter; if (0 == strcmp("fast", *str)) { @@ -1050,7 +1050,7 @@ NAN_SETTER(Context2d::SetFilter) { NAN_GETTER(Context2d::GetMiterLimit) { NanScope(); Context2d *context = ObjectWrap::Unwrap(args.This()); - NanReturnValue(Number::New(cairo_get_miter_limit(context->context()))); + NanReturnValue(NanNew(cairo_get_miter_limit(context->context()))); } /* @@ -1072,7 +1072,7 @@ NAN_SETTER(Context2d::SetMiterLimit) { NAN_GETTER(Context2d::GetLineWidth) { NanScope(); Context2d *context = ObjectWrap::Unwrap(args.This()); - NanReturnValue(Number::New(cairo_get_line_width(context->context()))); + NanReturnValue(NanNew(cairo_get_line_width(context->context()))); } /* @@ -1110,7 +1110,7 @@ NAN_GETTER(Context2d::GetLineJoin) { NAN_SETTER(Context2d::SetLineJoin) { Context2d *context = ObjectWrap::Unwrap(args.This()); cairo_t *ctx = context->context(); - String::AsciiValue type(value->ToString()); + String::Utf8Value type(value->ToString()); if (0 == strcmp("round", *type)) { cairo_set_line_join(ctx, CAIRO_LINE_JOIN_ROUND); } else if (0 == strcmp("bevel", *type)) { @@ -1143,7 +1143,7 @@ NAN_GETTER(Context2d::GetLineCap) { NAN_SETTER(Context2d::SetLineCap) { Context2d *context = ObjectWrap::Unwrap(args.This()); cairo_t *ctx = context->context(); - String::AsciiValue type(value->ToString()); + String::Utf8Value type(value->ToString()); if (0 == strcmp("round", *type)) { cairo_set_line_cap(ctx, CAIRO_LINE_CAP_ROUND); } else if (0 == strcmp("square", *type)) { @@ -1164,9 +1164,9 @@ NAN_METHOD(Context2d::IsPointInPath) { cairo_t *ctx = context->context(); double x = args[0]->NumberValue() , y = args[1]->NumberValue(); - NanReturnValue(Boolean::New(cairo_in_fill(ctx, x, y) || cairo_in_stroke(ctx, x, y))); + NanReturnValue(NanNew(cairo_in_fill(ctx, x, y) || cairo_in_stroke(ctx, x, y))); } - NanReturnValue(False()); + NanReturnValue(NanFalse()); } /* @@ -1220,7 +1220,7 @@ NAN_METHOD(Context2d::SetStrokePattern) { NAN_SETTER(Context2d::SetShadowColor) { short ok; - String::AsciiValue str(value->ToString()); + String::Utf8Value str(value->ToString()); uint32_t rgba = rgba_from_string(*str, &ok); if (ok) { Context2d *context = ObjectWrap::Unwrap(args.This()); @@ -1237,7 +1237,7 @@ NAN_GETTER(Context2d::GetShadowColor) { char buf[64]; Context2d *context = ObjectWrap::Unwrap(args.This()); rgba_to_string(context->state->shadow, buf, sizeof(buf)); - NanReturnValue(String::New(buf)); + NanReturnValue(NanNew(buf)); } /* @@ -1248,7 +1248,7 @@ NAN_METHOD(Context2d::SetFillColor) { NanScope(); short ok; if (!args[0]->IsString()) NanReturnUndefined(); - String::AsciiValue str(args[0]); + String::Utf8Value str(args[0]); uint32_t rgba = rgba_from_string(*str, &ok); if (!ok) NanReturnUndefined(); Context2d *context = ObjectWrap::Unwrap(args.This()); @@ -1266,7 +1266,7 @@ NAN_GETTER(Context2d::GetFillColor) { char buf[64]; Context2d *context = ObjectWrap::Unwrap(args.This()); rgba_to_string(context->state->fill, buf, sizeof(buf)); - NanReturnValue(String::New(buf)); + NanReturnValue(NanNew(buf)); } /* @@ -1277,7 +1277,7 @@ NAN_METHOD(Context2d::SetStrokeColor) { NanScope(); short ok; if (!args[0]->IsString()) NanReturnUndefined(); - String::AsciiValue str(args[0]); + String::Utf8Value str(args[0]); uint32_t rgba = rgba_from_string(*str, &ok); if (!ok) NanReturnUndefined(); Context2d *context = ObjectWrap::Unwrap(args.This()); @@ -1295,7 +1295,7 @@ NAN_GETTER(Context2d::GetStrokeColor) { char buf[64]; Context2d *context = ObjectWrap::Unwrap(args.This()); rgba_to_string(context->state->stroke, buf, sizeof(buf)); - NanReturnValue(String::New(buf)); + NanReturnValue(NanNew(buf)); } /* @@ -1763,11 +1763,11 @@ NAN_METHOD(Context2d::SetFont) { || !args[3]->IsString() || !args[4]->IsString()) NanReturnUndefined(); - String::AsciiValue weight(args[0]); - String::AsciiValue style(args[1]); + String::Utf8Value weight(args[0]); + String::Utf8Value style(args[1]); double size = args[2]->NumberValue(); - String::AsciiValue unit(args[3]); - String::AsciiValue family(args[4]); + String::Utf8Value unit(args[3]); + String::Utf8Value family(args[4]); Context2d *context = ObjectWrap::Unwrap(args.This()); @@ -1876,7 +1876,7 @@ NAN_METHOD(Context2d::MeasureText) { cairo_t *ctx = context->context(); String::Utf8Value str(args[0]->ToString()); - Local obj = Object::New(); + Local obj = NanNew(); #if HAVE_PANGO @@ -1917,21 +1917,21 @@ NAN_METHOD(Context2d::MeasureText) { y_offset = 0.0; } - obj->Set(String::New("width"), Number::New(logical_rect.width)); - obj->Set(String::New("actualBoundingBoxLeft"), - Number::New(x_offset - PANGO_LBEARING(logical_rect))); - obj->Set(String::New("actualBoundingBoxRight"), - Number::New(x_offset + PANGO_RBEARING(logical_rect))); - obj->Set(String::New("actualBoundingBoxAscent"), - Number::New(-(y_offset+ink_rect.y))); - obj->Set(String::New("actualBoundingBoxDescent"), - Number::New((PANGO_DESCENT(ink_rect) + y_offset))); - obj->Set(String::New("emHeightAscent"), - Number::New(PANGO_ASCENT(logical_rect) - y_offset)); - obj->Set(String::New("emHeightDescent"), - Number::New(PANGO_DESCENT(logical_rect) + y_offset)); - obj->Set(String::New("alphabeticBaseline"), - Number::New((pango_font_metrics_get_ascent(metrics) / PANGO_SCALE) + obj->Set(NanNew("width"), NanNew(logical_rect.width)); + obj->Set(NanNew("actualBoundingBoxLeft"), + NanNew(x_offset - PANGO_LBEARING(logical_rect))); + obj->Set(NanNew("actualBoundingBoxRight"), + NanNew(x_offset + PANGO_RBEARING(logical_rect))); + obj->Set(NanNew("actualBoundingBoxAscent"), + NanNew(-(y_offset+ink_rect.y))); + obj->Set(NanNew("actualBoundingBoxDescent"), + NanNew((PANGO_DESCENT(ink_rect) + y_offset))); + obj->Set(NanNew("emHeightAscent"), + NanNew(PANGO_ASCENT(logical_rect) - y_offset)); + obj->Set(NanNew("emHeightDescent"), + NanNew(PANGO_DESCENT(logical_rect) + y_offset)); + obj->Set(NanNew("alphabeticBaseline"), + NanNewNumber>((pango_font_metrics_get_ascent(metrics) / PANGO_SCALE) + y_offset)); pango_font_metrics_unref(metrics); @@ -1972,18 +1972,18 @@ NAN_METHOD(Context2d::MeasureText) { y_offset = 0.0; } - obj->Set(String::New("width"), Number::New(te.x_advance)); - obj->Set(String::New("actualBoundingBoxLeft"), - Number::New(x_offset - te.x_bearing)); - obj->Set(String::New("actualBoundingBoxRight"), - Number::New((te.x_bearing + te.width) - x_offset)); - obj->Set(String::New("actualBoundingBoxAscent"), - Number::New(-(te.y_bearing + y_offset))); - obj->Set(String::New("actualBoundingBoxDescent"), - Number::New(te.height + te.y_bearing + y_offset)); - obj->Set(String::New("emHeightAscent"), Number::New(fe.ascent - y_offset)); - obj->Set(String::New("emHeightDescent"), Number::New(fe.descent + y_offset)); - obj->Set(String::New("alphabeticBaseline"), Number::New(y_offset)); + obj->Set(NanNew("width"), NanNew(te.x_advance)); + obj->Set(NanNew("actualBoundingBoxLeft"), + NanNew(x_offset - te.x_bearing)); + obj->Set(NanNew("actualBoundingBoxRight"), + NanNew((te.x_bearing + te.width) - x_offset)); + obj->Set(NanNew("actualBoundingBoxAscent"), + NanNew(-(te.y_bearing + y_offset))); + obj->Set(NanNew("actualBoundingBoxDescent"), + NanNew(te.height + te.y_bearing + y_offset)); + obj->Set(NanNew("emHeightAscent"), NanNew(fe.ascent - y_offset)); + obj->Set(NanNew("emHeightDescent"), NanNew(fe.descent + y_offset)); + obj->Set(NanNew("alphabeticBaseline"), NanNew(y_offset)); #endif diff --git a/src/FontFace.cc b/src/FontFace.cc index af867a8..e739a5a 100644 --- a/src/FontFace.cc +++ b/src/FontFace.cc @@ -6,7 +6,7 @@ #include "FontFace.h" -#include "nan.h" +#include Persistent FontFace::constructor; @@ -30,8 +30,8 @@ FontFace::Initialize(Handle target) { NanScope(); // Constructor - Local ctor = FunctionTemplate::New(FontFace::New); - NanAssignPersistent(FunctionTemplate, constructor, ctor); + Local ctor = NanNew(FontFace::New); + NanAssignPersistent(constructor, ctor); ctor->InstanceTemplate()->SetInternalFieldCount(1); ctor->SetClassName(NanSymbol("FontFace")); @@ -60,7 +60,7 @@ NAN_METHOD(FontFace::New) { return NanThrowError("Wrong argument types passed to FontFace constructor"); } - String::AsciiValue filePath(args[0]); + String::Utf8Value filePath(args[0]); int faceIdx = int(args[1]->NumberValue()); FT_Face ftFace; diff --git a/src/Image.cc b/src/Image.cc index 79ada71..ff5751f 100644 --- a/src/Image.cc +++ b/src/Image.cc @@ -38,8 +38,8 @@ void Image::Initialize(Handle target) { NanScope(); - Local ctor = FunctionTemplate::New(Image::New); - NanAssignPersistent(FunctionTemplate, constructor, ctor); + Local ctor = NanNew(Image::New); + NanAssignPersistent(constructor, ctor); ctor->InstanceTemplate()->SetInternalFieldCount(1); ctor->SetClassName(NanSymbol("Image")); @@ -56,8 +56,8 @@ Image::Initialize(Handle target) { proto->SetAccessor(NanSymbol("onerror"), GetOnerror, SetOnerror); #if CAIRO_VERSION_MINOR >= 10 proto->SetAccessor(NanSymbol("dataMode"), GetDataMode, SetDataMode); - ctor->Set(NanSymbol("MODE_IMAGE"), Number::New(DATA_IMAGE)); - ctor->Set(NanSymbol("MODE_MIME"), Number::New(DATA_MIME)); + ctor->Set(NanSymbol("MODE_IMAGE"), NanNew(DATA_IMAGE)); + ctor->Set(NanSymbol("MODE_MIME"), NanNew(DATA_MIME)); #endif target->Set(NanSymbol("Image"), ctor->GetFunction()); } @@ -81,7 +81,7 @@ NAN_METHOD(Image::New) { NAN_GETTER(Image::GetComplete) { NanScope(); Image *img = ObjectWrap::Unwrap(args.This()); - NanReturnValue(Boolean::New(Image::COMPLETE == img->state)); + NanReturnValue(NanNew(Image::COMPLETE == img->state)); } #if CAIRO_VERSION_MINOR >= 10 @@ -93,7 +93,7 @@ NAN_GETTER(Image::GetComplete) { NAN_GETTER(Image::GetDataMode) { NanScope(); Image *img = ObjectWrap::Unwrap(args.This()); - NanReturnValue(Number::New(img->data_mode)); + NanReturnValue(NanNew(img->data_mode)); } /* @@ -117,7 +117,7 @@ NAN_SETTER(Image::SetDataMode) { NAN_GETTER(Image::GetWidth) { NanScope(); Image *img = ObjectWrap::Unwrap(args.This()); - NanReturnValue(Number::New(img->width)); + NanReturnValue(NanNew(img->width)); } /* * Get height. @@ -126,7 +126,7 @@ NAN_GETTER(Image::GetWidth) { NAN_GETTER(Image::GetHeight) { NanScope(); Image *img = ObjectWrap::Unwrap(args.This()); - NanReturnValue(Number::New(img->height)); + NanReturnValue(NanNew(img->height)); } /* @@ -136,7 +136,7 @@ NAN_GETTER(Image::GetHeight) { NAN_GETTER(Image::GetSource) { NanScope(); Image *img = ObjectWrap::Unwrap(args.This()); - NanReturnValue(String::New(img->filename ? img->filename : "")); + NanReturnValue(NanNew(img->filename ? img->filename : "")); } /* @@ -147,7 +147,7 @@ void Image::clearData() { if (_surface) { cairo_surface_destroy(_surface); - V8::AdjustAmountOfExternalAllocatedMemory(-_data_len); + NanAdjustExternalMemory(-_data_len); _data_len = 0; _surface = NULL; } @@ -175,7 +175,7 @@ NAN_SETTER(Image::SetSource) { // url string if (value->IsString()) { - String::AsciiValue src(value); + String::Utf8Value src(value); if (img->filename) free(img->filename); img->filename = strdup(*src); status = img->load(); @@ -359,7 +359,7 @@ Image::loaded() { width = cairo_image_surface_get_width(_surface); height = cairo_image_surface_get_height(_surface); _data_len = height * cairo_image_surface_get_stride(_surface); - V8::AdjustAmountOfExternalAllocatedMemory(_data_len); + NanAdjustExternalMemory(_data_len); if (onload != NULL) { onload->Call(0, NULL); @@ -807,7 +807,7 @@ Image::decodeJPEGBufferIntoMimeSurface(uint8_t *buf, unsigned len) { void clearMimeData(void *closure) { - V8::AdjustAmountOfExternalAllocatedMemory(-((read_closure_t *)closure)->len); + NanAdjustExternalMemory(-((read_closure_t *)closure)->len); free(((read_closure_t *) closure)->buf); free(closure); } @@ -834,7 +834,7 @@ Image::assignDataAsMime(uint8_t *data, int len, const char *mime_type) { mime_closure->buf = mime_data; mime_closure->len = len; - V8::AdjustAmountOfExternalAllocatedMemory(len); + NanAdjustExternalMemory(len); return cairo_surface_set_mime_data(_surface , mime_type diff --git a/src/Image.h b/src/Image.h index 9890f90..5da5bfd 100644 --- a/src/Image.h +++ b/src/Image.h @@ -8,7 +8,7 @@ #ifndef __NODE_IMAGE_H__ #define __NODE_IMAGE_H__ -#include "nan.h" +#include #include "Canvas.h" #ifdef HAVE_JPEG diff --git a/src/ImageData.cc b/src/ImageData.cc index 0694917..aa1a594 100644 --- a/src/ImageData.cc +++ b/src/ImageData.cc @@ -18,8 +18,8 @@ ImageData::Initialize(Handle target) { NanScope(); // Constructor - Local ctor = FunctionTemplate::New(ImageData::New); - NanAssignPersistent(FunctionTemplate, constructor, ctor); + Local ctor = NanNew(ImageData::New); + NanAssignPersistent(constructor, ctor); ctor->InstanceTemplate()->SetInternalFieldCount(1); ctor->SetClassName(NanSymbol("ImageData")); @@ -55,7 +55,7 @@ NAN_METHOD(ImageData::New) { NAN_GETTER(ImageData::GetWidth) { NanScope(); ImageData *imageData = ObjectWrap::Unwrap(args.This()); - NanReturnValue(Number::New(imageData->pixelArray()->width())); + NanReturnValue(NanNew(imageData->pixelArray()->width())); } /* @@ -65,5 +65,5 @@ NAN_GETTER(ImageData::GetWidth) { NAN_GETTER(ImageData::GetHeight) { NanScope(); ImageData *imageData = ObjectWrap::Unwrap(args.This()); - NanReturnValue(Number::New(imageData->pixelArray()->height())); + NanReturnValue(NanNew(imageData->pixelArray()->height())); } diff --git a/src/JPEGStream.h b/src/JPEGStream.h index 3f21a9c..5d06a86 100644 --- a/src/JPEGStream.h +++ b/src/JPEGStream.h @@ -6,7 +6,7 @@ #ifndef __NODE_JPEG_STREAM_H__ #define __NODE_JPEG_STREAM_H__ -#include "nan.h" +#include #include "Canvas.h" #include #include @@ -34,11 +34,11 @@ empty_closure_output_buffer(j_compress_ptr cinfo){ closure_destination_mgr *dest = (closure_destination_mgr *) cinfo->dest; Local buf = NanNewBufferHandle((char *)dest->buffer, dest->bufsize); Local argv[3] = { - NanNewLocal(Null()) - , NanNewLocal(buf) - , Integer::New(dest->bufsize) + NanNew(NanNull()) + , NanNew(buf) + , NanNew(dest->bufsize) }; - dest->closure->fn->Call(Context::GetCurrent()->Global(), 3, argv); + NanMakeCallback(NanGetCurrentContext()->Global(), dest->closure->fn, 3, argv); cinfo->dest->next_output_byte = dest->buffer; cinfo->dest->free_in_buffer = dest->bufsize; return true; @@ -53,21 +53,21 @@ term_closure_destination(j_compress_ptr cinfo){ Local buf = NanNewBufferHandle((char *)dest->buffer, remaining); Local data_argv[3] = { - NanNewLocal(Null()) - , NanNewLocal(buf) - , Integer::New(remaining) + NanNew(NanNull()) + , NanNew(buf) + , NanNew(remaining) }; - dest->closure->fn->Call(Context::GetCurrent()->Global(), 3, data_argv); + NanMakeCallback(NanGetCurrentContext()->Global(), dest->closure->fn, 3, data_argv); // emit "end" Local end_argv[3] = { - NanNewLocal(Null()) - , NanNewLocal(Null()) - , Integer::New(0) + NanNew(NanNull()) + , NanNew(NanNull()) + , NanNew(0) }; - dest->closure->fn->Call(Context::GetCurrent()->Global(), 3, end_argv); + NanMakeCallback(NanGetCurrentContext()->Global(), dest->closure->fn, 3, end_argv); } void diff --git a/src/PixelArray.cc b/src/PixelArray.cc index 4abc181..949624d 100644 --- a/src/PixelArray.cc +++ b/src/PixelArray.cc @@ -9,7 +9,7 @@ #include #include -#include "nan.h" +#include Persistent PixelArray::constructor; @@ -22,8 +22,8 @@ PixelArray::Initialize(Handle target) { NanScope(); // Constructor - Local ctor = FunctionTemplate::New(PixelArray::New); - NanAssignPersistent(FunctionTemplate, constructor, ctor); + Local ctor = NanNew(PixelArray::New); + NanAssignPersistent(constructor, ctor); ctor->InstanceTemplate()->SetInternalFieldCount(1); ctor->SetClassName(NanSymbol("CanvasPixelArray")); @@ -82,7 +82,7 @@ NAN_METHOD(PixelArray::New) { NAN_GETTER(PixelArray::GetLength) { NanScope(); - NanReturnValue(Number::New(args.This()->GetIndexedPropertiesPixelDataLength())); + NanReturnValue(NanNew(args.This()->GetIndexedPropertiesPixelDataLength())); } /* @@ -142,7 +142,7 @@ uint8_t * PixelArray::alloc() { int len = length(); _data = (uint8_t *) calloc(1, len); - V8::AdjustAmountOfExternalAllocatedMemory(len); + NanAdjustExternalMemory(len); return _data; } @@ -151,6 +151,6 @@ PixelArray::alloc() { */ PixelArray::~PixelArray() { - V8::AdjustAmountOfExternalAllocatedMemory(-length()); + NanAdjustExternalMemory(-length()); free(_data); } diff --git a/src/closure.h b/src/closure.h index 1b3147b..3ac6632 100644 --- a/src/closure.h +++ b/src/closure.h @@ -16,7 +16,7 @@ #define PAGE_SIZE 4096 #endif -#include "nan.h" +#include /* * PNG stream closure. @@ -50,7 +50,7 @@ closure_init(closure_t *closure, Canvas *canvas, unsigned int compression_level, } /* - * Free the given closure's data, + * Free the given closure's data, * and hint V8 at the memory dealloc. */ @@ -58,7 +58,7 @@ void closure_destroy(closure_t *closure) { if (closure->len) { free(closure->data); - V8::AdjustAmountOfExternalAllocatedMemory(- (intptr_t) closure->max_len); + NanAdjustExternalMemory(-((intptr_t) closure->max_len)); } } diff --git a/src/init.cc b/src/init.cc index f7c822d..6628cee 100755 --- a/src/init.cc +++ b/src/init.cc @@ -32,7 +32,7 @@ init (Handle target) { FontFace::Initialize(target); #endif - target->Set(String::New("cairoVersion"), String::New(cairo_version_string())); + target->Set(NanNew("cairoVersion"), NanNew(cairo_version_string())); #ifdef HAVE_JPEG #ifndef JPEG_LIB_VERSION_MAJOR @@ -57,16 +57,16 @@ init (Handle target) { } else { snprintf(jpeg_version, 10, "%d", JPEG_LIB_VERSION_MAJOR); } - target->Set(String::New("jpegVersion"), String::New(jpeg_version)); + target->Set(NanNew("jpegVersion"), NanNew(jpeg_version)); #endif #ifdef HAVE_GIF #ifndef GIF_LIB_VERSION char gif_version[10]; snprintf(gif_version, 10, "%d.%d.%d", GIFLIB_MAJOR, GIFLIB_MINOR, GIFLIB_RELEASE); - target->Set(String::New("gifVersion"), String::New(gif_version)); + target->Set(NanNew("gifVersion"), NanNew(gif_version)); #else - target->Set(String::New("gifVersion"), String::New(GIF_LIB_VERSION)); + target->Set(NanNew("gifVersion"), NanNew(GIF_LIB_VERSION)); #endif #endif } From b0d70c5baaa560363bfbd81486f7b5ab9debb977 Mon Sep 17 00:00:00 2001 From: King Koopa Date: Sun, 16 Mar 2014 17:05:01 +0200 Subject: [PATCH 2/6] Restore Uintiness --- package.json | 2 +- src/Canvas.cc | 18 +++++++++--------- 2 files changed, 10 insertions(+), 10 deletions(-) diff --git a/package.json b/package.json index 10a2961..22d889a 100644 --- a/package.json +++ b/package.json @@ -14,7 +14,7 @@ "test": "make test" } , "dependencies": { - "nan": "git://github.com/rvagg/nan.git#cleanup" + "nan": "git://github.com/rvagg/nan.git#0.9-wip" } , "devDependencies": { "express": "3.0" diff --git a/src/Canvas.cc b/src/Canvas.cc index 25919dd..b879eec 100644 --- a/src/Canvas.cc +++ b/src/Canvas.cc @@ -46,13 +46,13 @@ Canvas::Initialize(Handle target) { proto->SetAccessor(NanSymbol("width"), GetWidth, SetWidth); proto->SetAccessor(NanSymbol("height"), GetHeight, SetHeight); - NanSetTemplate(proto, "PNG_NO_FILTERS", NanNew(PNG_NO_FILTERS)); - NanSetTemplate(proto, "PNG_FILTER_NONE", NanNew(PNG_FILTER_NONE)); - NanSetTemplate(proto, "PNG_FILTER_SUB", NanNew(PNG_FILTER_SUB)); - NanSetTemplate(proto, "PNG_FILTER_UP", NanNew(PNG_FILTER_UP)); - NanSetTemplate(proto, "PNG_FILTER_AVG", NanNew(PNG_FILTER_AVG)); - NanSetTemplate(proto, "PNG_FILTER_PAETH", NanNew(PNG_FILTER_PAETH)); - NanSetTemplate(proto, "PNG_ALL_FILTERS", NanNew(PNG_ALL_FILTERS)); + NanSetTemplate(proto, "PNG_NO_FILTERS", NanNew(PNG_NO_FILTERS)); + NanSetTemplate(proto, "PNG_FILTER_NONE", NanNew(PNG_FILTER_NONE)); + NanSetTemplate(proto, "PNG_FILTER_SUB", NanNew(PNG_FILTER_SUB)); + NanSetTemplate(proto, "PNG_FILTER_UP", NanNew(PNG_FILTER_UP)); + NanSetTemplate(proto, "PNG_FILTER_AVG", NanNew(PNG_FILTER_AVG)); + NanSetTemplate(proto, "PNG_FILTER_PAETH", NanNew(PNG_FILTER_PAETH)); + NanSetTemplate(proto, "PNG_ALL_FILTERS", NanNew(PNG_ALL_FILTERS)); target->Set(NanSymbol("Canvas"), ctor->GetFunction()); } @@ -350,7 +350,7 @@ streamPNG(void *c, const uint8_t *data, unsigned len) { Local argv[3] = { NanNew(NanNull()) , buf - , NanNew(len) }; + , NanNew(len) }; NanMakeCallback(NanGetCurrentContext()->Global(), closure->fn, 3, argv); return CAIRO_STATUS_SUCCESS; } @@ -425,7 +425,7 @@ NAN_METHOD(Canvas::StreamPNGSync) { Local argv[3] = { NanNew(NanNull()) , NanNew(NanNull()) - , NanNew(0) }; + , NanNew(0) }; NanMakeCallback(NanGetCurrentContext()->Global(), closure.fn, 3, argv); } NanReturnUndefined(); From 9b62e5f64ecb53586611725c58977f53779e805c Mon Sep 17 00:00:00 2001 From: Rod Vagg Date: Mon, 5 May 2014 14:40:11 +1000 Subject: [PATCH 3/6] beginning nan@1.0.0 conversion --- package.json | 2 +- src/Canvas.cc | 68 ++++++++++++++-------------- src/CanvasGradient.cc | 4 +- src/CanvasPattern.cc | 4 +- src/CanvasRenderingContext2d.cc | 80 ++++++++++++++++----------------- src/FontFace.cc | 4 +- src/Image.cc | 26 +++++------ src/ImageData.cc | 8 ++-- src/JPEGStream.h | 24 +++++----- src/PixelArray.cc | 10 ++--- src/closure.h | 2 +- src/init.cc | 8 ++-- 12 files changed, 120 insertions(+), 120 deletions(-) diff --git a/package.json b/package.json index a940eed..c131103 100644 --- a/package.json +++ b/package.json @@ -14,7 +14,7 @@ "test": "make test" } , "dependencies": { - "nan": "~0.7.0" + "nan": "~1.0.0" } , "devDependencies": { "express": "3.0" diff --git a/src/Canvas.cc b/src/Canvas.cc index 306904f..6f12ba6 100644 --- a/src/Canvas.cc +++ b/src/Canvas.cc @@ -30,8 +30,8 @@ Canvas::Initialize(Handle target) { NanScope(); // Constructor - Local ctor = FunctionTemplate::New(Canvas::New); - NanAssignPersistent(FunctionTemplate, constructor, ctor); + Local ctor = NanNew(Canvas::New); + NanAssignPersistent(constructor, ctor); ctor->InstanceTemplate()->SetInternalFieldCount(1); ctor->SetClassName(NanSymbol("Canvas")); @@ -46,13 +46,13 @@ Canvas::Initialize(Handle target) { proto->SetAccessor(NanSymbol("width"), GetWidth, SetWidth); proto->SetAccessor(NanSymbol("height"), GetHeight, SetHeight); - proto->Set("PNG_NO_FILTERS", Uint32::New(PNG_NO_FILTERS)); - proto->Set("PNG_FILTER_NONE", Uint32::New(PNG_FILTER_NONE)); - proto->Set("PNG_FILTER_SUB", Uint32::New(PNG_FILTER_SUB)); - proto->Set("PNG_FILTER_UP", Uint32::New(PNG_FILTER_UP)); - proto->Set("PNG_FILTER_AVG", Uint32::New(PNG_FILTER_AVG)); - proto->Set("PNG_FILTER_PAETH", Uint32::New(PNG_FILTER_PAETH)); - proto->Set("PNG_ALL_FILTERS", Uint32::New(PNG_ALL_FILTERS)); + NanSetTemplate(proto, "PNG_NO_FILTERS", NanNew(PNG_NO_FILTERS)); + NanSetTemplate(proto, "PNG_FILTER_NONE", NanNew(PNG_FILTER_NONE)); + NanSetTemplate(proto, "PNG_FILTER_SUB", NanNew(PNG_FILTER_SUB)); + NanSetTemplate(proto, "PNG_FILTER_UP", NanNew(PNG_FILTER_UP)); + NanSetTemplate(proto, "PNG_FILTER_AVG", NanNew(PNG_FILTER_AVG)); + NanSetTemplate(proto, "PNG_FILTER_PAETH", NanNew(PNG_FILTER_PAETH)); + NanSetTemplate(proto, "PNG_ALL_FILTERS", NanNew(PNG_ALL_FILTERS)); target->Set(NanSymbol("Canvas"), ctor->GetFunction()); } @@ -82,7 +82,7 @@ NAN_METHOD(Canvas::New) { NAN_GETTER(Canvas::GetType) { NanScope(); Canvas *canvas = ObjectWrap::Unwrap(args.This()); - NanReturnValue(String::New(canvas->isPDF() ? "pdf" : "image")); + NanReturnValue(NanNew(canvas->isPDF() ? "pdf" : "image")); } /* @@ -92,7 +92,7 @@ NAN_GETTER(Canvas::GetType) { NAN_GETTER(Canvas::GetWidth) { NanScope(); Canvas *canvas = ObjectWrap::Unwrap(args.This()); - NanReturnValue(Number::New(canvas->width)); + NanReturnValue(NanNew(canvas->width)); } /* @@ -115,7 +115,7 @@ NAN_SETTER(Canvas::SetWidth) { NAN_GETTER(Canvas::GetHeight) { NanScope(); Canvas *canvas = ObjectWrap::Unwrap(args.This()); - NanReturnValue(Number::New(canvas->height)); + NanReturnValue(NanNew(canvas->height)); } /* @@ -211,7 +211,7 @@ Canvas::EIO_AfterToBuffer(eio_req *req) { } else { Local buf = NanNewBufferHandle((char*)closure->data, closure->len); memcpy(Buffer::Data(buf), closure->data, closure->len); - Local argv[2] = { NanNewLocal(Null()), buf }; + Local argv[2] = { NanNull(), buf }; closure->pfn->Call(2, argv); } @@ -246,13 +246,13 @@ NAN_METHOD(Canvas::ToBuffer) { NanReturnValue(buf); } - if (args.Length() > 1 && !(args[1]->StrictEquals(Undefined()) && args[2]->StrictEquals(Undefined()))) { - if (!args[1]->StrictEquals(Undefined())) { + if (args.Length() > 1 && !(args[1]->StrictEquals(NanUndefined()) && args[2]->StrictEquals(NanUndefined()))) { + if (!args[1]->StrictEquals(NanUndefined())) { bool good = true; if (args[1]->IsNumber()) { compression_level = args[1]->Uint32Value(); } else if (args[1]->IsString()) { - if (args[1]->StrictEquals(String::New("0"))) { + if (args[1]->StrictEquals(NanNew("0"))) { compression_level = 0; } else { uint32_t tmp = args[1]->Uint32Value(); @@ -275,7 +275,7 @@ NAN_METHOD(Canvas::ToBuffer) { } } - if (!args[2]->StrictEquals(Undefined())) { + if (!args[2]->StrictEquals(NanUndefined())) { if (args[2]->IsUint32()) { filter = args[2]->Uint32Value(); } else { @@ -348,10 +348,10 @@ streamPNG(void *c, const uint8_t *data, unsigned len) { closure_t *closure = (closure_t *) c; Local buf = NanNewBufferHandle((char *)data, len); Local argv[3] = { - NanNewLocal(Null()) + NanNull() , buf - , Integer::New(len) }; - MakeCallback(Context::GetCurrent()->Global(), closure->fn, 3, argv); + , NanNew(len) }; + NanMakeCallback(NanGetCurrentContext(), closure->fn, 3, argv); return CAIRO_STATUS_SUCCESS; } @@ -367,13 +367,13 @@ NAN_METHOD(Canvas::StreamPNGSync) { if (!args[0]->IsFunction()) return NanThrowTypeError("callback function required"); - if (args.Length() > 1 && !(args[1]->StrictEquals(Undefined()) && args[2]->StrictEquals(Undefined()))) { - if (!args[1]->StrictEquals(Undefined())) { + if (args.Length() > 1 && !(args[1]->StrictEquals(NanUndefined()) && args[2]->StrictEquals(NanUndefined()))) { + if (!args[1]->StrictEquals(NanUndefined())) { bool good = true; if (args[1]->IsNumber()) { compression_level = args[1]->Uint32Value(); } else if (args[1]->IsString()) { - if (args[1]->StrictEquals(String::New("0"))) { + if (args[1]->StrictEquals(NanNew("0"))) { compression_level = 0; } else { uint32_t tmp = args[1]->Uint32Value(); @@ -396,7 +396,7 @@ NAN_METHOD(Canvas::StreamPNGSync) { } } - if (!args[2]->StrictEquals(Undefined())) { + if (!args[2]->StrictEquals(NanUndefined())) { if (args[2]->IsUint32()) { filter = args[1]->Uint32Value(); } else { @@ -420,13 +420,13 @@ NAN_METHOD(Canvas::StreamPNGSync) { NanReturnValue(try_catch.ReThrow()); } else if (status) { Local argv[1] = { Canvas::Error(status) }; - MakeCallback(Context::GetCurrent()->Global(), closure.fn, 1, argv); + NanMakeCallback(NanGetCurrentContext(), closure.fn, 1, argv); } else { Local argv[3] = { - NanNewLocal(Null()) - , NanNewLocal(Null()) - , Integer::New(0) }; - MakeCallback(Context::GetCurrent()->Global(), closure.fn, 3, argv); + NanNull() + , NanNull() + , NanNew(0) }; + NanMakeCallback(NanGetCurrentContext(), closure.fn, 3, argv); } NanReturnUndefined(); } @@ -483,7 +483,7 @@ Canvas::Canvas(int w, int h, canvas_type_t t): ObjectWrap() { } else { _surface = cairo_image_surface_create(CAIRO_FORMAT_ARGB32, w, h); assert(_surface); - V8::AdjustAmountOfExternalAllocatedMemory(4 * w * h); + NanAdjustExternalMemory(4 * w * h); } } @@ -501,7 +501,7 @@ Canvas::~Canvas() { break; case CANVAS_TYPE_IMAGE: cairo_surface_destroy(_surface); - V8::AdjustAmountOfExternalAllocatedMemory(-4 * width * height); + NanAdjustExternalMemory(-4 * width * height); break; } } @@ -522,10 +522,10 @@ Canvas::resurface(Handle canvas) { int old_height = cairo_image_surface_get_height(_surface); cairo_surface_destroy(_surface); _surface = cairo_image_surface_create(CAIRO_FORMAT_ARGB32, width, height); - V8::AdjustAmountOfExternalAllocatedMemory(4 * (width * height - old_width * old_height)); + NanAdjustExternalMemory(4 * (width * height - old_width * old_height)); // Reset context - Handle context = canvas->Get(String::New("context")); + Handle context = canvas->Get(NanNew("context")); if (!context->IsUndefined()) { Context2d *context2d = ObjectWrap::Unwrap(context->ToObject()); cairo_t *prev = context2d->context(); @@ -542,5 +542,5 @@ Canvas::resurface(Handle canvas) { Local Canvas::Error(cairo_status_t status) { - return Exception::Error(String::New(cairo_status_to_string(status))); + return Exception::Error(NanNew(cairo_status_to_string(status))); } diff --git a/src/CanvasGradient.cc b/src/CanvasGradient.cc index 802224e..2bf7f61 100644 --- a/src/CanvasGradient.cc +++ b/src/CanvasGradient.cc @@ -20,8 +20,8 @@ Gradient::Initialize(Handle target) { NanScope(); // Constructor - Local ctor = FunctionTemplate::New(Gradient::New); - NanAssignPersistent(FunctionTemplate, constructor, ctor); + Local ctor = NanNew(Gradient::New); + NanAssignPersistent(constructor, ctor); ctor->InstanceTemplate()->SetInternalFieldCount(1); ctor->SetClassName(NanSymbol("CanvasGradient")); diff --git a/src/CanvasPattern.cc b/src/CanvasPattern.cc index 16bb99f..d874bf4 100644 --- a/src/CanvasPattern.cc +++ b/src/CanvasPattern.cc @@ -20,8 +20,8 @@ Pattern::Initialize(Handle target) { NanScope(); // Constructor - Local ctor = FunctionTemplate::New(Pattern::New); - NanAssignPersistent(FunctionTemplate, constructor, ctor); + Local ctor = NanNew(Pattern::New); + NanAssignPersistent(constructor, ctor); ctor->InstanceTemplate()->SetInternalFieldCount(1); ctor->SetClassName(NanSymbol("CanvasPattern")); diff --git a/src/CanvasRenderingContext2d.cc b/src/CanvasRenderingContext2d.cc index a6c1621..19902c2 100644 --- a/src/CanvasRenderingContext2d.cc +++ b/src/CanvasRenderingContext2d.cc @@ -81,8 +81,8 @@ Context2d::Initialize(Handle target) { NanScope(); // Constructor - Local ctor = FunctionTemplate::New(Context2d::New); - NanAssignPersistent(FunctionTemplate, constructor, ctor); + Local ctor = NanNew(Context2d::New); + NanAssignPersistent(constructor, ctor); ctor->InstanceTemplate()->SetInternalFieldCount(1); ctor->SetClassName(NanSymbol("CanvasRenderingContext2d")); @@ -694,7 +694,7 @@ NAN_METHOD(Context2d::DrawImage) { NAN_GETTER(Context2d::GetGlobalAlpha) { NanScope(); Context2d *context = ObjectWrap::Unwrap(args.This()); - NanReturnValue(Number::New(context->state->globalAlpha)); + NanReturnValue(NanNew(context->state->globalAlpha)); } /* @@ -878,7 +878,7 @@ NAN_SETTER(Context2d::SetGlobalCompositeOperation) { NAN_GETTER(Context2d::GetShadowOffsetX) { NanScope(); Context2d *context = ObjectWrap::Unwrap(args.This()); - NanReturnValue(Number::New(context->state->shadowOffsetX)); + NanReturnValue(NanNew(context->state->shadowOffsetX)); } /* @@ -897,7 +897,7 @@ NAN_SETTER(Context2d::SetShadowOffsetX) { NAN_GETTER(Context2d::GetShadowOffsetY) { NanScope(); Context2d *context = ObjectWrap::Unwrap(args.This()); - NanReturnValue(Number::New(context->state->shadowOffsetY)); + NanReturnValue(NanNew(context->state->shadowOffsetY)); } /* @@ -916,7 +916,7 @@ NAN_SETTER(Context2d::SetShadowOffsetY) { NAN_GETTER(Context2d::GetShadowBlur) { NanScope(); Context2d *context = ObjectWrap::Unwrap(args.This()); - NanReturnValue(Number::New(context->state->shadowBlur)); + NanReturnValue(NanNew(context->state->shadowBlur)); } /* @@ -1050,7 +1050,7 @@ NAN_SETTER(Context2d::SetFilter) { NAN_GETTER(Context2d::GetMiterLimit) { NanScope(); Context2d *context = ObjectWrap::Unwrap(args.This()); - NanReturnValue(Number::New(cairo_get_miter_limit(context->context()))); + NanReturnValue(NanNew(cairo_get_miter_limit(context->context()))); } /* @@ -1072,7 +1072,7 @@ NAN_SETTER(Context2d::SetMiterLimit) { NAN_GETTER(Context2d::GetLineWidth) { NanScope(); Context2d *context = ObjectWrap::Unwrap(args.This()); - NanReturnValue(Number::New(cairo_get_line_width(context->context()))); + NanReturnValue(NanNew(cairo_get_line_width(context->context()))); } /* @@ -1164,7 +1164,7 @@ NAN_METHOD(Context2d::IsPointInPath) { cairo_t *ctx = context->context(); double x = args[0]->NumberValue() , y = args[1]->NumberValue(); - NanReturnValue(Boolean::New(cairo_in_fill(ctx, x, y) || cairo_in_stroke(ctx, x, y))); + NanReturnValue(NanNew(cairo_in_fill(ctx, x, y) || cairo_in_stroke(ctx, x, y))); } NanReturnValue(False()); } @@ -1237,7 +1237,7 @@ NAN_GETTER(Context2d::GetShadowColor) { char buf[64]; Context2d *context = ObjectWrap::Unwrap(args.This()); rgba_to_string(context->state->shadow, buf, sizeof(buf)); - NanReturnValue(String::New(buf)); + NanReturnValue(NanNew(buf)); } /* @@ -1266,7 +1266,7 @@ NAN_GETTER(Context2d::GetFillColor) { char buf[64]; Context2d *context = ObjectWrap::Unwrap(args.This()); rgba_to_string(context->state->fill, buf, sizeof(buf)); - NanReturnValue(String::New(buf)); + NanReturnValue(NanNew(buf)); } /* @@ -1295,7 +1295,7 @@ NAN_GETTER(Context2d::GetStrokeColor) { char buf[64]; Context2d *context = ObjectWrap::Unwrap(args.This()); rgba_to_string(context->state->stroke, buf, sizeof(buf)); - NanReturnValue(String::New(buf)); + NanReturnValue(NanNew(buf)); } /* @@ -1876,7 +1876,7 @@ NAN_METHOD(Context2d::MeasureText) { cairo_t *ctx = context->context(); String::Utf8Value str(args[0]->ToString()); - Local obj = Object::New(); + Local obj = NanNew(); #if HAVE_PANGO @@ -1917,21 +1917,21 @@ NAN_METHOD(Context2d::MeasureText) { y_offset = 0.0; } - obj->Set(String::New("width"), Number::New(logical_rect.width)); - obj->Set(String::New("actualBoundingBoxLeft"), - Number::New(x_offset - PANGO_LBEARING(logical_rect))); - obj->Set(String::New("actualBoundingBoxRight"), - Number::New(x_offset + PANGO_RBEARING(logical_rect))); - obj->Set(String::New("actualBoundingBoxAscent"), - Number::New(-(y_offset+ink_rect.y))); - obj->Set(String::New("actualBoundingBoxDescent"), - Number::New((PANGO_DESCENT(ink_rect) + y_offset))); - obj->Set(String::New("emHeightAscent"), - Number::New(PANGO_ASCENT(logical_rect) - y_offset)); - obj->Set(String::New("emHeightDescent"), - Number::New(PANGO_DESCENT(logical_rect) + y_offset)); - obj->Set(String::New("alphabeticBaseline"), - Number::New((pango_font_metrics_get_ascent(metrics) / PANGO_SCALE) + obj->Set(NanNew("width"), NanNew(logical_rect.width)); + obj->Set(NanNew("actualBoundingBoxLeft"), + NanNew(x_offset - PANGO_LBEARING(logical_rect))); + obj->Set(NanNew("actualBoundingBoxRight"), + NanNew(x_offset + PANGO_RBEARING(logical_rect))); + obj->Set(NanNew("actualBoundingBoxAscent"), + NanNew(-(y_offset+ink_rect.y))); + obj->Set(NanNew("actualBoundingBoxDescent"), + NanNew((PANGO_DESCENT(ink_rect) + y_offset))); + obj->Set(NanNew("emHeightAscent"), + NanNew(PANGO_ASCENT(logical_rect) - y_offset)); + obj->Set(NanNew("emHeightDescent"), + NanNew(PANGO_DESCENT(logical_rect) + y_offset)); + obj->Set(NanNew("alphabeticBaseline"), + NanNew((pango_font_metrics_get_ascent(metrics) / PANGO_SCALE) + y_offset)); pango_font_metrics_unref(metrics); @@ -1972,18 +1972,18 @@ NAN_METHOD(Context2d::MeasureText) { y_offset = 0.0; } - obj->Set(String::New("width"), Number::New(te.x_advance)); - obj->Set(String::New("actualBoundingBoxLeft"), - Number::New(x_offset - te.x_bearing)); - obj->Set(String::New("actualBoundingBoxRight"), - Number::New((te.x_bearing + te.width) - x_offset)); - obj->Set(String::New("actualBoundingBoxAscent"), - Number::New(-(te.y_bearing + y_offset))); - obj->Set(String::New("actualBoundingBoxDescent"), - Number::New(te.height + te.y_bearing + y_offset)); - obj->Set(String::New("emHeightAscent"), Number::New(fe.ascent - y_offset)); - obj->Set(String::New("emHeightDescent"), Number::New(fe.descent + y_offset)); - obj->Set(String::New("alphabeticBaseline"), Number::New(y_offset)); + obj->Set(NanNew("width"), NanNew(te.x_advance)); + obj->Set(NanNew("actualBoundingBoxLeft"), + NanNew(x_offset - te.x_bearing)); + obj->Set(NanNew("actualBoundingBoxRight"), + NanNew((te.x_bearing + te.width) - x_offset)); + obj->Set(NanNew("actualBoundingBoxAscent"), + NanNew(-(te.y_bearing + y_offset))); + obj->Set(NanNew("actualBoundingBoxDescent"), + NanNew(te.height + te.y_bearing + y_offset)); + obj->Set(NanNew("emHeightAscent"), NanNew(fe.ascent - y_offset)); + obj->Set(NanNew("emHeightDescent"), NanNew(fe.descent + y_offset)); + obj->Set(NanNew("alphabeticBaseline"), NanNew(y_offset)); #endif diff --git a/src/FontFace.cc b/src/FontFace.cc index af867a8..d7d1be6 100644 --- a/src/FontFace.cc +++ b/src/FontFace.cc @@ -30,8 +30,8 @@ FontFace::Initialize(Handle target) { NanScope(); // Constructor - Local ctor = FunctionTemplate::New(FontFace::New); - NanAssignPersistent(FunctionTemplate, constructor, ctor); + Local ctor = NanNew(FontFace::New); + NanAssignPersistent(constructor, ctor); ctor->InstanceTemplate()->SetInternalFieldCount(1); ctor->SetClassName(NanSymbol("FontFace")); diff --git a/src/Image.cc b/src/Image.cc index 79ada71..bb7ba75 100644 --- a/src/Image.cc +++ b/src/Image.cc @@ -38,8 +38,8 @@ void Image::Initialize(Handle target) { NanScope(); - Local ctor = FunctionTemplate::New(Image::New); - NanAssignPersistent(FunctionTemplate, constructor, ctor); + Local ctor = NanNew(Image::New); + NanAssignPersistent(constructor, ctor); ctor->InstanceTemplate()->SetInternalFieldCount(1); ctor->SetClassName(NanSymbol("Image")); @@ -56,8 +56,8 @@ Image::Initialize(Handle target) { proto->SetAccessor(NanSymbol("onerror"), GetOnerror, SetOnerror); #if CAIRO_VERSION_MINOR >= 10 proto->SetAccessor(NanSymbol("dataMode"), GetDataMode, SetDataMode); - ctor->Set(NanSymbol("MODE_IMAGE"), Number::New(DATA_IMAGE)); - ctor->Set(NanSymbol("MODE_MIME"), Number::New(DATA_MIME)); + ctor->Set(NanSymbol("MODE_IMAGE"), NanNew(DATA_IMAGE)); + ctor->Set(NanSymbol("MODE_MIME"), NanNew(DATA_MIME)); #endif target->Set(NanSymbol("Image"), ctor->GetFunction()); } @@ -81,7 +81,7 @@ NAN_METHOD(Image::New) { NAN_GETTER(Image::GetComplete) { NanScope(); Image *img = ObjectWrap::Unwrap(args.This()); - NanReturnValue(Boolean::New(Image::COMPLETE == img->state)); + NanReturnValue(NanNew(Image::COMPLETE == img->state)); } #if CAIRO_VERSION_MINOR >= 10 @@ -93,7 +93,7 @@ NAN_GETTER(Image::GetComplete) { NAN_GETTER(Image::GetDataMode) { NanScope(); Image *img = ObjectWrap::Unwrap(args.This()); - NanReturnValue(Number::New(img->data_mode)); + NanReturnValue(NanNew(img->data_mode)); } /* @@ -117,7 +117,7 @@ NAN_SETTER(Image::SetDataMode) { NAN_GETTER(Image::GetWidth) { NanScope(); Image *img = ObjectWrap::Unwrap(args.This()); - NanReturnValue(Number::New(img->width)); + NanReturnValue(NanNew(img->width)); } /* * Get height. @@ -126,7 +126,7 @@ NAN_GETTER(Image::GetWidth) { NAN_GETTER(Image::GetHeight) { NanScope(); Image *img = ObjectWrap::Unwrap(args.This()); - NanReturnValue(Number::New(img->height)); + NanReturnValue(NanNew(img->height)); } /* @@ -136,7 +136,7 @@ NAN_GETTER(Image::GetHeight) { NAN_GETTER(Image::GetSource) { NanScope(); Image *img = ObjectWrap::Unwrap(args.This()); - NanReturnValue(String::New(img->filename ? img->filename : "")); + NanReturnValue(NanNew(img->filename ? img->filename : "")); } /* @@ -147,7 +147,7 @@ void Image::clearData() { if (_surface) { cairo_surface_destroy(_surface); - V8::AdjustAmountOfExternalAllocatedMemory(-_data_len); + NanAdjustExternalMemory(-_data_len); _data_len = 0; _surface = NULL; } @@ -359,7 +359,7 @@ Image::loaded() { width = cairo_image_surface_get_width(_surface); height = cairo_image_surface_get_height(_surface); _data_len = height * cairo_image_surface_get_stride(_surface); - V8::AdjustAmountOfExternalAllocatedMemory(_data_len); + NanAdjustExternalMemory(_data_len); if (onload != NULL) { onload->Call(0, NULL); @@ -807,7 +807,7 @@ Image::decodeJPEGBufferIntoMimeSurface(uint8_t *buf, unsigned len) { void clearMimeData(void *closure) { - V8::AdjustAmountOfExternalAllocatedMemory(-((read_closure_t *)closure)->len); + NanAdjustExternalMemory(-((read_closure_t *)closure)->len); free(((read_closure_t *) closure)->buf); free(closure); } @@ -834,7 +834,7 @@ Image::assignDataAsMime(uint8_t *data, int len, const char *mime_type) { mime_closure->buf = mime_data; mime_closure->len = len; - V8::AdjustAmountOfExternalAllocatedMemory(len); + NanAdjustExternalMemory(len); return cairo_surface_set_mime_data(_surface , mime_type diff --git a/src/ImageData.cc b/src/ImageData.cc index 0694917..aa1a594 100644 --- a/src/ImageData.cc +++ b/src/ImageData.cc @@ -18,8 +18,8 @@ ImageData::Initialize(Handle target) { NanScope(); // Constructor - Local ctor = FunctionTemplate::New(ImageData::New); - NanAssignPersistent(FunctionTemplate, constructor, ctor); + Local ctor = NanNew(ImageData::New); + NanAssignPersistent(constructor, ctor); ctor->InstanceTemplate()->SetInternalFieldCount(1); ctor->SetClassName(NanSymbol("ImageData")); @@ -55,7 +55,7 @@ NAN_METHOD(ImageData::New) { NAN_GETTER(ImageData::GetWidth) { NanScope(); ImageData *imageData = ObjectWrap::Unwrap(args.This()); - NanReturnValue(Number::New(imageData->pixelArray()->width())); + NanReturnValue(NanNew(imageData->pixelArray()->width())); } /* @@ -65,5 +65,5 @@ NAN_GETTER(ImageData::GetWidth) { NAN_GETTER(ImageData::GetHeight) { NanScope(); ImageData *imageData = ObjectWrap::Unwrap(args.This()); - NanReturnValue(Number::New(imageData->pixelArray()->height())); + NanReturnValue(NanNew(imageData->pixelArray()->height())); } diff --git a/src/JPEGStream.h b/src/JPEGStream.h index 3f21a9c..e3efcc6 100644 --- a/src/JPEGStream.h +++ b/src/JPEGStream.h @@ -34,11 +34,11 @@ empty_closure_output_buffer(j_compress_ptr cinfo){ closure_destination_mgr *dest = (closure_destination_mgr *) cinfo->dest; Local buf = NanNewBufferHandle((char *)dest->buffer, dest->bufsize); Local argv[3] = { - NanNewLocal(Null()) - , NanNewLocal(buf) - , Integer::New(dest->bufsize) + NanNull() + , NanNew(buf) + , NanNew(dest->bufsize) }; - dest->closure->fn->Call(Context::GetCurrent()->Global(), 3, argv); + NanMakeCallback(NanGetCurrentContext(), dest->closure->fn, 3, argv); cinfo->dest->next_output_byte = dest->buffer; cinfo->dest->free_in_buffer = dest->bufsize; return true; @@ -53,21 +53,21 @@ term_closure_destination(j_compress_ptr cinfo){ Local buf = NanNewBufferHandle((char *)dest->buffer, remaining); Local data_argv[3] = { - NanNewLocal(Null()) - , NanNewLocal(buf) - , Integer::New(remaining) + NanNull() + , NanNew(buf) + , NanNew(remaining) }; - dest->closure->fn->Call(Context::GetCurrent()->Global(), 3, data_argv); + NanMakeCallback(NanGetCurrentContext(), dest->closure->fn, 3, data_argv); // emit "end" Local end_argv[3] = { - NanNewLocal(Null()) - , NanNewLocal(Null()) - , Integer::New(0) + NanNull() + , NanNull() + , NanNew(0) }; - dest->closure->fn->Call(Context::GetCurrent()->Global(), 3, end_argv); + NanMakeCallback(NanGetCurrentContext(), dest->closure->fn, 3, end_argv); } void diff --git a/src/PixelArray.cc b/src/PixelArray.cc index 4abc181..2bfe82e 100644 --- a/src/PixelArray.cc +++ b/src/PixelArray.cc @@ -22,8 +22,8 @@ PixelArray::Initialize(Handle target) { NanScope(); // Constructor - Local ctor = FunctionTemplate::New(PixelArray::New); - NanAssignPersistent(FunctionTemplate, constructor, ctor); + Local ctor = NanNew(PixelArray::New); + NanAssignPersistent(constructor, ctor); ctor->InstanceTemplate()->SetInternalFieldCount(1); ctor->SetClassName(NanSymbol("CanvasPixelArray")); @@ -82,7 +82,7 @@ NAN_METHOD(PixelArray::New) { NAN_GETTER(PixelArray::GetLength) { NanScope(); - NanReturnValue(Number::New(args.This()->GetIndexedPropertiesPixelDataLength())); + NanReturnValue(NanNew(args.This()->GetIndexedPropertiesPixelDataLength())); } /* @@ -142,7 +142,7 @@ uint8_t * PixelArray::alloc() { int len = length(); _data = (uint8_t *) calloc(1, len); - V8::AdjustAmountOfExternalAllocatedMemory(len); + NanAdjustExternalMemory(len); return _data; } @@ -151,6 +151,6 @@ PixelArray::alloc() { */ PixelArray::~PixelArray() { - V8::AdjustAmountOfExternalAllocatedMemory(-length()); + NanAdjustExternalMemory(-length()); free(_data); } diff --git a/src/closure.h b/src/closure.h index 1b3147b..96dcb9d 100644 --- a/src/closure.h +++ b/src/closure.h @@ -58,7 +58,7 @@ void closure_destroy(closure_t *closure) { if (closure->len) { free(closure->data); - V8::AdjustAmountOfExternalAllocatedMemory(- (intptr_t) closure->max_len); + NanAdjustExternalMemory(- (intptr_t) closure->max_len); } } diff --git a/src/init.cc b/src/init.cc index f7c822d..6628cee 100755 --- a/src/init.cc +++ b/src/init.cc @@ -32,7 +32,7 @@ init (Handle target) { FontFace::Initialize(target); #endif - target->Set(String::New("cairoVersion"), String::New(cairo_version_string())); + target->Set(NanNew("cairoVersion"), NanNew(cairo_version_string())); #ifdef HAVE_JPEG #ifndef JPEG_LIB_VERSION_MAJOR @@ -57,16 +57,16 @@ init (Handle target) { } else { snprintf(jpeg_version, 10, "%d", JPEG_LIB_VERSION_MAJOR); } - target->Set(String::New("jpegVersion"), String::New(jpeg_version)); + target->Set(NanNew("jpegVersion"), NanNew(jpeg_version)); #endif #ifdef HAVE_GIF #ifndef GIF_LIB_VERSION char gif_version[10]; snprintf(gif_version, 10, "%d.%d.%d", GIFLIB_MAJOR, GIFLIB_MINOR, GIFLIB_RELEASE); - target->Set(String::New("gifVersion"), String::New(gif_version)); + target->Set(NanNew("gifVersion"), NanNew(gif_version)); #else - target->Set(String::New("gifVersion"), String::New(GIF_LIB_VERSION)); + target->Set(NanNew("gifVersion"), NanNew(GIF_LIB_VERSION)); #endif #endif } From a9645632b9bf7b8cdfdb561eb08fe6aecb8e6be8 Mon Sep 17 00:00:00 2001 From: King Koopa Date: Mon, 5 May 2014 10:48:49 +0300 Subject: [PATCH 4/6] Update NAN --- package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/package.json b/package.json index 22d889a..d888800 100644 --- a/package.json +++ b/package.json @@ -14,7 +14,7 @@ "test": "make test" } , "dependencies": { - "nan": "git://github.com/rvagg/nan.git#0.9-wip" + "nan": "1.0.0" } , "devDependencies": { "express": "3.0" From 4ab32bccb1c34b4a4d03c3662173e80e3c2b5523 Mon Sep 17 00:00:00 2001 From: Rod Vagg Date: Mon, 5 May 2014 18:07:37 +1000 Subject: [PATCH 5/6] NanNew() -> NanNew() --- src/JPEGStream.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/JPEGStream.h b/src/JPEGStream.h index 7b508d2..0f5b5a4 100644 --- a/src/JPEGStream.h +++ b/src/JPEGStream.h @@ -35,7 +35,7 @@ empty_closure_output_buffer(j_compress_ptr cinfo){ Local buf = NanNewBufferHandle((char *)dest->buffer, dest->bufsize); Local argv[3] = { NanNull() - , NanNew(buf) + , NanNew(buf) , NanNew(dest->bufsize) }; NanMakeCallback(NanGetCurrentContext()->Global(), dest->closure->fn, 3, argv); From 8158158abf5d73d21770d137a6e85df960e84f34 Mon Sep 17 00:00:00 2001 From: Rod Vagg Date: Mon, 5 May 2014 18:11:41 +1000 Subject: [PATCH 6/6] NanNew() the NanNull()s --- src/Canvas.cc | 8 ++++---- src/JPEGStream.h | 2 +- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/src/Canvas.cc b/src/Canvas.cc index c14731d..869bbd8 100644 --- a/src/Canvas.cc +++ b/src/Canvas.cc @@ -211,7 +211,7 @@ Canvas::EIO_AfterToBuffer(eio_req *req) { } else { Local buf = NanNewBufferHandle((char*)closure->data, closure->len); memcpy(Buffer::Data(buf), closure->data, closure->len); - Local argv[2] = { NanNull(), buf }; + Local argv[2] = { NanNew(NanNull()), buf }; closure->pfn->Call(2, argv); } @@ -348,7 +348,7 @@ streamPNG(void *c, const uint8_t *data, unsigned len) { closure_t *closure = (closure_t *) c; Local buf = NanNewBufferHandle((char *)data, len); Local argv[3] = { - NanNull() + NanNew(NanNull()) , buf , NanNew(len) }; NanMakeCallback(NanGetCurrentContext()->Global(), closure->fn, 3, argv); @@ -423,8 +423,8 @@ NAN_METHOD(Canvas::StreamPNGSync) { NanMakeCallback(NanGetCurrentContext()->Global(), closure.fn, 1, argv); } else { Local argv[3] = { - NanNull() - , NanNull() + NanNew(NanNull()) + , NanNew(NanNull()) , NanNew(0) }; NanMakeCallback(NanGetCurrentContext()->Global(), closure.fn, 1, argv); } diff --git a/src/JPEGStream.h b/src/JPEGStream.h index 0f5b5a4..5d06a86 100644 --- a/src/JPEGStream.h +++ b/src/JPEGStream.h @@ -34,7 +34,7 @@ empty_closure_output_buffer(j_compress_ptr cinfo){ closure_destination_mgr *dest = (closure_destination_mgr *) cinfo->dest; Local buf = NanNewBufferHandle((char *)dest->buffer, dest->bufsize); Local argv[3] = { - NanNull() + NanNew(NanNull()) , NanNew(buf) , NanNew(dest->bufsize) };