diff --git a/src/Canvas.cc b/src/Canvas.cc index 6f12ba6..c14731d 100644 --- a/src/Canvas.cc +++ b/src/Canvas.cc @@ -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); @@ -351,7 +351,7 @@ streamPNG(void *c, const uint8_t *data, unsigned len) { NanNull() , buf , NanNew(len) }; - NanMakeCallback(NanGetCurrentContext(), closure->fn, 3, argv); + NanMakeCallback(NanGetCurrentContext()->Global(), closure->fn, 3, argv); return CAIRO_STATUS_SUCCESS; } @@ -420,13 +420,13 @@ NAN_METHOD(Canvas::StreamPNGSync) { NanReturnValue(try_catch.ReThrow()); } else if (status) { Local argv[1] = { Canvas::Error(status) }; - NanMakeCallback(NanGetCurrentContext(), closure.fn, 1, argv); + NanMakeCallback(NanGetCurrentContext()->Global(), closure.fn, 1, argv); } else { Local argv[3] = { NanNull() , NanNull() - , NanNew(0) }; - NanMakeCallback(NanGetCurrentContext(), closure.fn, 3, argv); + , NanNew(0) }; + NanMakeCallback(NanGetCurrentContext()->Global(), closure.fn, 1, argv); } NanReturnUndefined(); } 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 2bf7f61..9be3f48 100644 --- a/src/CanvasGradient.cc +++ b/src/CanvasGradient.cc @@ -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.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 19902c2..40618dc 100644 --- a/src/CanvasRenderingContext2d.cc +++ b/src/CanvasRenderingContext2d.cc @@ -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)) { @@ -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)) { @@ -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)) { @@ -1166,7 +1166,7 @@ NAN_METHOD(Context2d::IsPointInPath) { , y = args[1]->NumberValue(); 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()); @@ -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()); @@ -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()); @@ -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()); diff --git a/src/FontFace.cc b/src/FontFace.cc index d7d1be6..e739a5a 100644 --- a/src/FontFace.cc +++ b/src/FontFace.cc @@ -6,7 +6,7 @@ #include "FontFace.h" -#include "nan.h" +#include Persistent FontFace::constructor; @@ -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 bb7ba75..ff5751f 100644 --- a/src/Image.cc +++ b/src/Image.cc @@ -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(); 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/JPEGStream.h b/src/JPEGStream.h index e3efcc6..7b508d2 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 @@ -38,7 +38,7 @@ empty_closure_output_buffer(j_compress_ptr cinfo){ , NanNew(buf) , NanNew(dest->bufsize) }; - NanMakeCallback(NanGetCurrentContext(), dest->closure->fn, 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] = { - NanNull() - , NanNew(buf) + NanNew(NanNull()) + , NanNew(buf) , NanNew(remaining) }; - NanMakeCallback(NanGetCurrentContext(), dest->closure->fn, 3, data_argv); + NanMakeCallback(NanGetCurrentContext()->Global(), dest->closure->fn, 3, data_argv); // emit "end" Local end_argv[3] = { - NanNull() - , NanNull() + NanNew(NanNull()) + , NanNew(NanNull()) , NanNew(0) }; - NanMakeCallback(NanGetCurrentContext(), dest->closure->fn, 3, end_argv); + NanMakeCallback(NanGetCurrentContext()->Global(), dest->closure->fn, 3, end_argv); } void diff --git a/src/PixelArray.cc b/src/PixelArray.cc index 2bfe82e..949624d 100644 --- a/src/PixelArray.cc +++ b/src/PixelArray.cc @@ -9,7 +9,7 @@ #include #include -#include "nan.h" +#include Persistent PixelArray::constructor; diff --git a/src/closure.h b/src/closure.h index 96dcb9d..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); - NanAdjustExternalMemory(- (intptr_t) closure->max_len); + NanAdjustExternalMemory(-((intptr_t) closure->max_len)); } }