From 9086f7474d9c95226cb36edf9e0fceb5883cb2a6 Mon Sep 17 00:00:00 2001 From: Avaer Kazmer Date: Wed, 20 Mar 2019 19:39:38 -0400 Subject: [PATCH] Major node 12 C++ API update --- .../exokit-bindings/browser/include/browser.h | 2 +- deps/exokit-bindings/browser/src/browser.cpp | 80 +- .../canvascontext/include/canvas-context.h | 2 +- .../canvascontext/include/canvas-gradient.h | 2 +- .../canvascontext/include/canvas-pattern.h | 2 +- .../canvascontext/include/image-context.h | 2 +- .../include/imageBitmap-context.h | 2 +- .../canvascontext/include/imageData-context.h | 2 +- .../canvascontext/include/path2d-context.h | 2 +- .../canvascontext/src/canvas-context.cc | 282 ++--- .../canvascontext/src/canvas-gradient.cc | 30 +- .../canvascontext/src/canvas-pattern.cc | 6 +- .../canvascontext/src/image-context.cc | 6 +- .../canvascontext/src/imageBitmap-context.cc | 21 +- .../canvascontext/src/imageData-context.cc | 12 +- .../canvascontext/src/path2d-context.cc | 42 +- deps/exokit-bindings/glfw/src/glfw.cc | 44 +- .../leapmotion/include/leapmotion.h | 4 +- .../leapmotion/src/leapmotion.cc | 6 +- deps/exokit-bindings/util/include/defines.h | 8 + deps/exokit-bindings/util/src/defines.cc | 2 +- .../videocontext/include/Video.h | 4 +- .../videocontext/src/Video.cpp | 16 +- .../webaudiocontext/include/AnalyserNode.h | 2 +- .../webaudiocontext/include/Audio.h | 2 +- .../webaudiocontext/include/AudioBuffer.h | 4 +- .../webaudiocontext/include/AudioContext.h | 2 +- .../include/AudioDestinationNode.h | 2 +- .../webaudiocontext/include/AudioListener.h | 2 +- .../webaudiocontext/include/AudioNode.h | 2 +- .../webaudiocontext/include/AudioParam.h | 2 +- .../webaudiocontext/include/AudioSourceNode.h | 2 +- .../webaudiocontext/include/FakeAudioParam.h | 2 +- .../webaudiocontext/include/GainNode.h | 2 +- .../include/MediaStreamTrack.h | 2 +- .../include/MicrophoneMediaStream.h | 2 +- .../webaudiocontext/include/OscillatorNode.h | 2 +- .../webaudiocontext/include/PannerNode.h | 2 +- .../include/ScriptProcessorNode.h | 4 +- .../include/StereoPannerNode.h | 2 +- .../webaudiocontext/src/AnalyserNode.cpp | 8 +- .../webaudiocontext/src/Audio.cpp | 10 +- .../webaudiocontext/src/AudioBuffer.cpp | 34 +- .../webaudiocontext/src/AudioContext.cpp | 48 +- .../src/AudioDestinationNode.cpp | 6 +- .../webaudiocontext/src/AudioListener.cpp | 20 +- .../webaudiocontext/src/AudioNode.cpp | 20 +- .../webaudiocontext/src/AudioParam.cpp | 36 +- .../webaudiocontext/src/AudioSourceNode.cpp | 12 +- .../webaudiocontext/src/FakeAudioParam.cpp | 16 +- .../webaudiocontext/src/GainNode.cpp | 8 +- .../webaudiocontext/src/MediaStreamTrack.cpp | 8 +- .../src/MicrophoneMediaStream.cpp | 6 +- .../webaudiocontext/src/OscillatorNode.cpp | 8 +- .../webaudiocontext/src/PannerNode.cpp | 36 +- .../src/ScriptProcessorNode.cpp | 24 +- .../webaudiocontext/src/StereoPannerNode.cpp | 8 +- .../exokit-bindings/webglcontext/src/webgl.cc | 1003 +++++++++-------- deps/exokit-bindings/webrtc/include/common.h | 2 + .../webrtc/include/datachannel.h | 2 +- .../webrtc/include/peerconnection.h | 2 +- .../webrtc/include/peerconnectionfactory.h | 2 +- .../webrtc/include/rtcstatsreport.h | 2 +- .../webrtc/include/rtcstatsresponse.h | 2 +- deps/exokit-bindings/webrtc/include/webrtc.h | 2 +- deps/exokit-bindings/webrtc/src/binding.cc | 2 +- .../exokit-bindings/webrtc/src/datachannel.cc | 10 +- .../webrtc/src/peerconnection.cc | 82 +- .../webrtc/src/peerconnectionfactory.cc | 6 +- .../webrtc/src/rtcstatsreport.cc | 9 +- .../webrtc/src/rtcstatsresponse.cc | 7 +- .../windowsystem/src/windowsystem.cc | 74 +- deps/openvr/include/openvr-util.h | 20 +- deps/openvr/src/ivrcompositor.cpp | 2 +- deps/openvr/src/ivrsystem.cpp | 38 +- deps/openvr/src/openvr-bindings.cpp | 26 +- exokit.cpp | 14 +- 77 files changed, 1121 insertions(+), 1111 deletions(-) diff --git a/deps/exokit-bindings/browser/include/browser.h b/deps/exokit-bindings/browser/include/browser.h index 775b14ca0f..a9e0ba424d 100644 --- a/deps/exokit-bindings/browser/include/browser.h +++ b/deps/exokit-bindings/browser/include/browser.h @@ -26,7 +26,7 @@ namespace browser { class Browser : public ObjectWrap { public: - static Handle Initialize(Isolate *isolate); + static Local Initialize(Isolate *isolate); protected: Browser(WebGLRenderingContext *gl, int width, int height); diff --git a/deps/exokit-bindings/browser/src/browser.cpp b/deps/exokit-bindings/browser/src/browser.cpp index 304068a25a..b06417b559 100644 --- a/deps/exokit-bindings/browser/src/browser.cpp +++ b/deps/exokit-bindings/browser/src/browser.cpp @@ -26,7 +26,7 @@ Browser::Browser(WebGLRenderingContext *gl, int width, int height) : gl(gl), win Browser::~Browser() {} -Handle Browser::Initialize(Isolate *isolate) { +Local Browser::Initialize(Isolate *isolate) { uv_async_init(uv_default_loop(), &mainThreadAsync, MainThreadAsync); // uv_sem_init(&constructSem, 0); uv_sem_init(&mainThreadSem, 0); @@ -64,7 +64,7 @@ Handle Browser::Initialize(Isolate *isolate) { Nan::SetMethod(proto, "postMessage", PostMessage); Nan::SetMethod(proto, "destroy", Destroy); - Local ctorFn = ctor->GetFunction(); + Local ctorFn = Nan::GetFunction(ctor).ToLocalChecked(); Nan::SetMethod(ctorFn, "updateAll", UpdateAll); return scope.Escape(ctorFn); @@ -72,15 +72,15 @@ Handle Browser::Initialize(Isolate *isolate) { NAN_METHOD(Browser::New) { if ( - info[0]->IsObject() && info[0]->ToObject()->Get(JS_STR("constructor"))->ToObject()->Get(JS_STR("name"))->StrictEquals(JS_STR("WebGLRenderingContext")) && + info[0]->IsObject() && JS_OBJ(JS_OBJ(info[0])->Get(JS_STR("constructor")))->Get(JS_STR("name"))->StrictEquals(JS_STR("WebGLRenderingContext")) && info[1]->IsNumber() && info[2]->IsNumber() && info[3]->IsString() ) { WebGLRenderingContext *gl = ObjectWrap::Unwrap(Local::Cast(info[0])); - int width = info[1]->Int32Value(); - int height = info[2]->Int32Value(); - String::Utf8Value dataPathValue(Local::Cast(info[3])); + int width = TO_INT32(info[1]); + int height = TO_INT32(info[2]); + Nan::Utf8String dataPathValue(Local::Cast(info[3])); std::string dataPath(*dataPathValue, dataPathValue.length()); if (!embeddedInitialized) { @@ -153,7 +153,7 @@ void Browser::loadImmediate(const std::string &url) { if (!this->onloadstart.IsEmpty()) { Local onloadstart = Nan::New(this->onloadstart); - onloadstart->Call(Nan::Null(), 0, nullptr); + onloadstart->Call(Isolate::GetCurrent()->GetCurrentContext(), Nan::Null(), 0, nullptr); } }); }, @@ -166,7 +166,7 @@ void Browser::loadImmediate(const std::string &url) { JS_STR(url), }; Local onloadend = Nan::New(this->onloadend); - onloadend->Call(Nan::Null(), sizeof(argv)/sizeof(argv[0]), argv); + onloadend->Call(Isolate::GetCurrent()->GetCurrentContext(), Nan::Null(), sizeof(argv)/sizeof(argv[0]), argv); } }); }, @@ -181,7 +181,7 @@ void Browser::loadImmediate(const std::string &url) { JS_STR(errorString), JS_STR(failedUrl), }; - onloaderror->Call(Nan::Null(), sizeof(argv)/sizeof(argv[0]), argv); + onloaderror->Call(Isolate::GetCurrent()->GetCurrentContext(), Nan::Null(), sizeof(argv)/sizeof(argv[0]), argv); } }); }, @@ -196,7 +196,7 @@ void Browser::loadImmediate(const std::string &url) { JS_STR(scriptUrl), JS_INT(startLine), }; - onconsole->Call(Nan::Null(), sizeof(argv)/sizeof(argv[0]), argv); + onconsole->Call(Isolate::GetCurrent()->GetCurrentContext(), Nan::Null(), sizeof(argv)/sizeof(argv[0]), argv); } }); }, @@ -209,7 +209,7 @@ void Browser::loadImmediate(const std::string &url) { Local argv[] = { JS_STR(m), }; - onmessage->Call(Nan::Null(), sizeof(argv)/sizeof(argv[0]), argv); + onmessage->Call(Isolate::GetCurrent()->GetCurrentContext(), Nan::Null(), sizeof(argv)/sizeof(argv[0]), argv); } }); } @@ -234,8 +234,8 @@ NAN_METHOD(Browser::UpdateAll) { NAN_METHOD(Browser::Load) { if (info[0]->IsString()) { Browser *browser = ObjectWrap::Unwrap(info.This()); - String::Utf8Value urlUtf8Value(Local::Cast(info[0])); - std::string url(*urlUtf8Value, urlUtf8Value.length()); + Nan::Utf8String urlUtf8(Local::Cast(info[0])); + std::string url(*urlUtf8, urlUtf8.length()); browser->load(url); } else { @@ -256,7 +256,7 @@ NAN_GETTER(Browser::WidthGetter) { NAN_SETTER(Browser::WidthSetter) { Browser *browser = ObjectWrap::Unwrap(info.This()); if (browser->browser_) { - int width = value->Int32Value(); + int width = TO_INT32(value); QueueOnBrowserThread([browser, width]() -> void { setEmbeddedHeight(browser->browser_, width); @@ -276,8 +276,8 @@ NAN_GETTER(Browser::HeightGetter) { NAN_SETTER(Browser::HeightSetter) { Browser *browser = ObjectWrap::Unwrap(info.This()); if (browser->browser_) { - int height = value->Int32Value(); - + int height = TO_INT32(value); + QueueOnBrowserThread([browser, height]() -> void { setEmbeddedHeight(browser->browser_, height); }); @@ -390,8 +390,8 @@ NAN_METHOD(Browser::SendMouseMove) { if (info[0]->IsNumber() && info[1]->IsNumber()) { Browser *browser = ObjectWrap::Unwrap(info.This()); if (browser->browser_) { - int x = info[0]->Int32Value(); - int y = info[1]->Int32Value(); + int x = TO_INT32(info[0]); + int y = TO_INT32(info[1]); QueueOnBrowserThread([browser, x, y]() -> void { embeddedMouseMove(browser->browser_, x, y); @@ -406,9 +406,9 @@ NAN_METHOD(Browser::SendMouseDown) { if (info[0]->IsNumber() && info[1]->IsNumber() && info[2]->IsNumber()) { Browser *browser = ObjectWrap::Unwrap(info.This()); if (browser->browser_) { - int x = info[0]->Int32Value(); - int y = info[1]->Int32Value(); - int button = info[2]->Int32Value(); + int x = TO_INT32(info[0]); + int y = TO_INT32(info[1]); + int button = TO_INT32(info[2]); QueueOnBrowserThread([browser, x, y, button]() -> void { embeddedMouseDown(browser->browser_, x, y, button); @@ -422,9 +422,9 @@ NAN_METHOD(Browser::SendMouseDown) { NAN_METHOD(Browser::SendMouseUp) { if (info[0]->IsNumber() && info[1]->IsNumber() && info[2]->IsNumber()) { Browser *browser = ObjectWrap::Unwrap(info.This()); - int x = info[0]->Int32Value(); - int y = info[1]->Int32Value(); - int button = info[2]->Int32Value(); + int x = TO_INT32(info[0]); + int y = TO_INT32(info[1]); + int button = TO_INT32(info[2]); QueueOnBrowserThread([browser, x, y, button]() -> void { embeddedMouseUp(browser->browser_, x, y, button); @@ -438,10 +438,10 @@ NAN_METHOD(Browser::SendMouseWheel) { if (info[0]->IsNumber() && info[1]->IsNumber() && info[2]->IsNumber() && info[3]->IsNumber()) { Browser *browser = ObjectWrap::Unwrap(info.This()); if (browser->browser_) { - int x = info[0]->Int32Value(); - int y = info[1]->Int32Value(); - int deltaX = info[2]->Int32Value(); - int deltaY = info[3]->Int32Value(); + int x = TO_INT32(info[0]); + int y = TO_INT32(info[1]); + int deltaX = TO_INT32(info[2]); + int deltaY = TO_INT32(info[3]); QueueOnBrowserThread([browser, x, y, deltaX, deltaY]() -> void { embeddedMouseWheel(browser->browser_, x, y, deltaX, deltaY); @@ -454,13 +454,13 @@ NAN_METHOD(Browser::SendMouseWheel) { int GetKeyModifiers(Local modifiersObj) { int modifiers = 0; - if (modifiersObj->Get(JS_STR("shiftKey"))->BooleanValue()) { + if (TO_BOOL(modifiersObj->Get(JS_STR("shiftKey")))) { modifiers |= (int)EmbeddedKeyModifiers::SHIFT; } - if (modifiersObj->Get(JS_STR("ctrlKey"))->BooleanValue()) { + if (TO_BOOL(modifiersObj->Get(JS_STR("ctrlKey")))) { modifiers |= (int)EmbeddedKeyModifiers::CTRL; } - if (modifiersObj->Get(JS_STR("altKey"))->BooleanValue()) { + if (TO_BOOL(modifiersObj->Get(JS_STR("altKey")))) { modifiers |= (int)EmbeddedKeyModifiers::ALT; } return modifiers; @@ -491,7 +491,7 @@ map keyCodesMap{ }; int MutateKey(int key, Local modifiersObj){ - if (modifiersObj->Get(JS_STR("shiftKey"))->BooleanValue()){ + if (TO_BOOL(modifiersObj->Get(JS_STR("shiftKey")))){ if ( key >= 97 && // a key <= 122 // z @@ -510,7 +510,7 @@ NAN_METHOD(Browser::SendKeyDown) { if (info[0]->IsNumber() && info[1]->IsObject()) { Browser *browser = ObjectWrap::Unwrap(info.This()); if (browser->browser_) { - int key = info[0]->Int32Value(); + int key = TO_INT32(info[0]); Local modifiersObj = Local::Cast(info[1]); int modifiers = GetKeyModifiers(modifiersObj); @@ -530,7 +530,7 @@ NAN_METHOD(Browser::SendKeyUp) { if (info[0]->IsNumber() && info[1]->IsObject()) { Browser *browser = ObjectWrap::Unwrap(info.This()); if (browser->browser_) { - int key = info[0]->Int32Value(); + int key = TO_INT32(info[0]); Local modifiersObj = Local::Cast(info[1]); int modifiers = GetKeyModifiers(modifiersObj); @@ -550,7 +550,7 @@ NAN_METHOD(Browser::SendKeyPress) { if (info[0]->IsNumber() && info[1]->IsObject()) { Browser *browser = ObjectWrap::Unwrap(info.This()); if (browser->browser_) { - int key = info[0]->Uint32Value(); + int key = TO_UINT32(info[0]); Local modifiersObj = Local::Cast(info[1]); int modifiers = GetKeyModifiers(modifiersObj); @@ -570,13 +570,13 @@ NAN_METHOD(Browser::RunJs) { Browser *browser = ObjectWrap::Unwrap(info.This()); if (browser->browser_) { - String::Utf8Value jsStringValue(Local::Cast(info[0])); + Nan::Utf8String jsStringValue(Local::Cast(info[0])); string jsString(*jsStringValue, jsStringValue.length()); - String::Utf8Value scriptUrlValue(Local::Cast(info[1])); + Nan::Utf8String scriptUrlValue(Local::Cast(info[1])); string scriptUrl(*scriptUrlValue, scriptUrlValue.length()); - - int startLine = info[2]->Int32Value(); + + int startLine = TO_INT32(info[2]); QueueOnBrowserThread([browser, jsString, scriptUrl, startLine]() -> void { embeddedRunJs(browser->browser_, jsString, scriptUrl, startLine); @@ -598,7 +598,7 @@ NAN_METHOD(Browser::PostMessage) { Browser *browser = ObjectWrap::Unwrap(info.This()); if (browser->browser_) { - String::Utf8Value messageJsonValue(Local::Cast(info[0])); + Nan::Utf8String messageJsonValue(Local::Cast(info[0])); string messageJson(*messageJsonValue, messageJsonValue.length()); QueueOnBrowserThread([browser, messageJson]() -> void { diff --git a/deps/exokit-bindings/canvascontext/include/canvas-context.h b/deps/exokit-bindings/canvascontext/include/canvas-context.h index b1d32f32ee..080496c3fd 100644 --- a/deps/exokit-bindings/canvascontext/include/canvas-context.h +++ b/deps/exokit-bindings/canvascontext/include/canvas-context.h @@ -46,7 +46,7 @@ enum class Direction { class CanvasRenderingContext2D : public ObjectWrap { public: - static Handle Initialize(Isolate *isolate, Local imageDataCons, Local canvasGradientCons, Local canvasPatternCons); + static Local Initialize(Isolate *isolate, Local imageDataCons, Local canvasGradientCons, Local canvasPatternCons); unsigned int GetWidth(); unsigned int GetHeight(); unsigned int GetNumChannels(); diff --git a/deps/exokit-bindings/canvascontext/include/canvas-gradient.h b/deps/exokit-bindings/canvascontext/include/canvas-gradient.h index af7143b52c..a2ae33dbbe 100644 --- a/deps/exokit-bindings/canvascontext/include/canvas-gradient.h +++ b/deps/exokit-bindings/canvascontext/include/canvas-gradient.h @@ -19,7 +19,7 @@ using namespace node; class CanvasGradient : public ObjectWrap { public: - static Handle Initialize(Isolate *isolate); + static Local Initialize(Isolate *isolate); enum GradientType { LinearType, diff --git a/deps/exokit-bindings/canvascontext/include/canvas-pattern.h b/deps/exokit-bindings/canvascontext/include/canvas-pattern.h index 746f261617..7c6954ab19 100644 --- a/deps/exokit-bindings/canvascontext/include/canvas-pattern.h +++ b/deps/exokit-bindings/canvascontext/include/canvas-pattern.h @@ -12,7 +12,7 @@ using namespace node; class CanvasPattern : public ObjectWrap { public: - static Handle Initialize(Isolate *isolate); + static Local Initialize(Isolate *isolate); sk_sp getShader() const; diff --git a/deps/exokit-bindings/canvascontext/include/image-context.h b/deps/exokit-bindings/canvascontext/include/image-context.h index 4b6d3ad8fb..cdb04b9595 100644 --- a/deps/exokit-bindings/canvascontext/include/image-context.h +++ b/deps/exokit-bindings/canvascontext/include/image-context.h @@ -21,7 +21,7 @@ using namespace node; class Image : public ObjectWrap { public: - static Handle Initialize(Isolate *isolate); + static Local Initialize(Isolate *isolate); unsigned int GetWidth(); unsigned int GetHeight(); unsigned int GetNumChannels(); diff --git a/deps/exokit-bindings/canvascontext/include/imageBitmap-context.h b/deps/exokit-bindings/canvascontext/include/imageBitmap-context.h index 72276bffa8..16f6334845 100644 --- a/deps/exokit-bindings/canvascontext/include/imageBitmap-context.h +++ b/deps/exokit-bindings/canvascontext/include/imageBitmap-context.h @@ -16,7 +16,7 @@ class Image; class ImageBitmap : public ObjectWrap { public: - static Handle Initialize(Isolate *isolate); + static Local Initialize(Isolate *isolate); unsigned int GetWidth(); unsigned int GetHeight(); unsigned int GetNumChannels(); diff --git a/deps/exokit-bindings/canvascontext/include/imageData-context.h b/deps/exokit-bindings/canvascontext/include/imageData-context.h index abdbfa3687..5db4ff4079 100644 --- a/deps/exokit-bindings/canvascontext/include/imageData-context.h +++ b/deps/exokit-bindings/canvascontext/include/imageData-context.h @@ -16,7 +16,7 @@ class CanvasRenderingContext2D; class ImageData : public ObjectWrap { public: - static Handle Initialize(Isolate *isolate); + static Local Initialize(Isolate *isolate); unsigned int GetWidth(); unsigned int GetHeight(); unsigned int GetNumChannels(); diff --git a/deps/exokit-bindings/canvascontext/include/path2d-context.h b/deps/exokit-bindings/canvascontext/include/path2d-context.h index a143086231..749b29ae97 100644 --- a/deps/exokit-bindings/canvascontext/include/path2d-context.h +++ b/deps/exokit-bindings/canvascontext/include/path2d-context.h @@ -16,7 +16,7 @@ using namespace node; class Path2D : public ObjectWrap { public: - static Handle Initialize(Isolate *isolate); + static Local Initialize(Isolate *isolate); void MoveTo(float x, float y); void LineTo(float x, float y); void ClosePath(); diff --git a/deps/exokit-bindings/canvascontext/src/canvas-context.cc b/deps/exokit-bindings/canvascontext/src/canvas-context.cc index 3455be2bf1..d40e10fe5f 100644 --- a/deps/exokit-bindings/canvascontext/src/canvas-context.cc +++ b/deps/exokit-bindings/canvascontext/src/canvas-context.cc @@ -32,15 +32,15 @@ NAN_METHOD(ctxCallWrap) { } bool isImageValue(Local arg) { - if (arg->ToObject()->Get(JS_STR("constructor"))->ToObject()->Get(JS_STR("name"))->StrictEquals(JS_STR("HTMLCanvasElement"))) { - Local otherContextObj = arg->ToObject()->Get(JS_STR("_context")); - return otherContextObj->IsObject() && otherContextObj->ToObject()->Get(JS_STR("constructor"))->ToObject()->Get(JS_STR("name"))->StrictEquals(JS_STR("CanvasRenderingContext2D")); + if (JS_OBJ(JS_OBJ(arg)->Get(JS_STR("constructor")))->Get(JS_STR("name"))->StrictEquals(JS_STR("HTMLCanvasElement"))) { + Local otherContextObj = JS_OBJ(arg)->Get(JS_STR("_context")); + return otherContextObj->IsObject() && JS_OBJ(JS_OBJ(otherContextObj)->Get(JS_STR("constructor")))->Get(JS_STR("name"))->StrictEquals(JS_STR("CanvasRenderingContext2D")); } else { return arg->IsObject() && ( - arg->ToObject()->Get(JS_STR("constructor"))->ToObject()->Get(JS_STR("name"))->StrictEquals(JS_STR("CanvasRenderingContext2D")) || - arg->ToObject()->Get(JS_STR("constructor"))->ToObject()->Get(JS_STR("name"))->StrictEquals(JS_STR("HTMLImageElement")) || - arg->ToObject()->Get(JS_STR("constructor"))->ToObject()->Get(JS_STR("name"))->StrictEquals(JS_STR("ImageData")) || - arg->ToObject()->Get(JS_STR("constructor"))->ToObject()->Get(JS_STR("name"))->StrictEquals(JS_STR("ImageBitmap")) + JS_OBJ(JS_OBJ(arg)->Get(JS_STR("constructor")))->Get(JS_STR("name"))->StrictEquals(JS_STR("CanvasRenderingContext2D")) || + JS_OBJ(JS_OBJ(arg)->Get(JS_STR("constructor")))->Get(JS_STR("name"))->StrictEquals(JS_STR("HTMLImageElement")) || + JS_OBJ(JS_OBJ(arg)->Get(JS_STR("constructor")))->Get(JS_STR("name"))->StrictEquals(JS_STR("ImageData")) || + JS_OBJ(JS_OBJ(arg)->Get(JS_STR("constructor")))->Get(JS_STR("name"))->StrictEquals(JS_STR("ImageBitmap")) ); } } @@ -50,7 +50,7 @@ bool isImageValue(Local arg) { canvas->scale(1.0, -1.0); } */ -Handle CanvasRenderingContext2D::Initialize(Isolate *isolate, Local imageDataCons, Local canvasGradientCons, Local canvasPatternCons) { +Local CanvasRenderingContext2D::Initialize(Isolate *isolate, Local imageDataCons, Local canvasGradientCons, Local canvasPatternCons) { Nan::EscapableHandleScope scope; // constructor @@ -103,7 +103,7 @@ Handle CanvasRenderingContext2D::Initialize(Isolate *isolate, Local ctorFn = ctor->GetFunction(); + Local ctorFn = Nan::GetFunction(ctor).ToLocalChecked(); ctorFn->Set(JS_STR("ImageData"), imageDataCons); ctorFn->Set(JS_STR("CanvasGradient"), canvasGradientCons); ctorFn->Set(JS_STR("CanvasPattern"), canvasPatternCons); @@ -403,7 +403,7 @@ NAN_SETTER(CanvasRenderingContext2D::LineWidthSetter) { if (value->IsNumber()) { CanvasRenderingContext2D *context = ObjectWrap::Unwrap(info.This()); - float lineWidth = value->NumberValue(); + float lineWidth = TO_FLOAT(value); context->strokePaint.setStrokeWidth(lineWidth); context->fillPaint.setStrokeWidth(lineWidth); @@ -422,18 +422,18 @@ NAN_SETTER(CanvasRenderingContext2D::StrokeStyleSetter) { if (value->IsString()) { CanvasRenderingContext2D *context = ObjectWrap::Unwrap(info.This()); - v8::String::Utf8Value text(value); + Nan::Utf8String text(value); std::string strokeStyle(*text, text.length()); canvas::web_color webColor = canvas::web_color::from_string(strokeStyle.c_str()); context->strokePaint.setColor(((uint32_t)webColor.a << (8 * 3)) | ((uint32_t)webColor.r << (8 * 2)) | ((uint32_t)webColor.g << (8 * 1)) | ((uint32_t)webColor.b << (8 * 0))); context->fillPaint.setShader(nullptr); - } else if (value->IsObject() && value->ToObject()->Get(JS_STR("constructor"))->ToObject()->Get(JS_STR("name"))->StrictEquals(JS_STR("CanvasGradient"))) { + } else if (value->IsObject() && JS_OBJ(JS_OBJ(value)->Get(JS_STR("constructor")))->Get(JS_STR("name"))->StrictEquals(JS_STR("CanvasGradient"))) { CanvasRenderingContext2D *context = ObjectWrap::Unwrap(info.This()); CanvasGradient *canvasGradient = ObjectWrap::Unwrap(Local::Cast(value)); context->fillPaint.setShader(canvasGradient->getShader()); - } else if (value->IsObject() && value->ToObject()->Get(JS_STR("constructor"))->ToObject()->Get(JS_STR("name"))->StrictEquals(JS_STR("CanvasPattern"))) { + } else if (value->IsObject() && JS_OBJ(JS_OBJ(value)->Get(JS_STR("constructor")))->Get(JS_STR("name"))->StrictEquals(JS_STR("CanvasPattern"))) { CanvasRenderingContext2D *context = ObjectWrap::Unwrap(info.This()); CanvasPattern *canvasPattern = ObjectWrap::Unwrap(Local::Cast(value)); @@ -453,18 +453,18 @@ NAN_SETTER(CanvasRenderingContext2D::FillStyleSetter) { if (value->IsString()) { CanvasRenderingContext2D *context = ObjectWrap::Unwrap(info.This()); - v8::String::Utf8Value text(value); + Nan::Utf8String text(value); std::string fillStyle(*text, text.length()); canvas::web_color webColor = canvas::web_color::from_string(fillStyle.c_str()); context->fillPaint.setColor(((uint32_t)webColor.a << (8 * 3)) | ((uint32_t)webColor.r << (8 * 2)) | ((uint32_t)webColor.g << (8 * 1)) | ((uint32_t)webColor.b << (8 * 0))); context->fillPaint.setShader(nullptr); - } else if (value->IsObject() && value->ToObject()->Get(JS_STR("constructor"))->ToObject()->Get(JS_STR("name"))->StrictEquals(JS_STR("CanvasGradient"))) { + } else if (value->IsObject() && JS_OBJ(JS_OBJ(value)->Get(JS_STR("constructor")))->Get(JS_STR("name"))->StrictEquals(JS_STR("CanvasGradient"))) { CanvasRenderingContext2D *context = ObjectWrap::Unwrap(info.This()); CanvasGradient *canvasGradient = ObjectWrap::Unwrap(Local::Cast(value)); context->fillPaint.setShader(canvasGradient->getShader()); - } else if (value->IsObject() && value->ToObject()->Get(JS_STR("constructor"))->ToObject()->Get(JS_STR("name"))->StrictEquals(JS_STR("CanvasPattern"))) { + } else if (value->IsObject() && JS_OBJ(JS_OBJ(value)->Get(JS_STR("constructor")))->Get(JS_STR("name"))->StrictEquals(JS_STR("CanvasPattern"))) { CanvasRenderingContext2D *context = ObjectWrap::Unwrap(info.This()); CanvasPattern *canvasPattern = ObjectWrap::Unwrap(Local::Cast(value)); @@ -484,7 +484,7 @@ NAN_SETTER(CanvasRenderingContext2D::FontSetter) { if (value->IsString()) { Local contextObj = info.This(); - v8::String::Utf8Value text(value); + Nan::Utf8String text(value); std::string font(*text, text.length()); canvas::FontDeclaration declaration = canvas::parse_short_font(font); @@ -510,7 +510,7 @@ NAN_SETTER(CanvasRenderingContext2D::FontFamilySetter) { if (value->IsString()) { CanvasRenderingContext2D *context = ObjectWrap::Unwrap(info.This()); - v8::String::Utf8Value text(value); + Nan::Utf8String text(value); std::string fontFamily(*text, text.length()); SkTypeface *typeface = context->strokePaint.getTypeface(); @@ -532,7 +532,7 @@ NAN_SETTER(CanvasRenderingContext2D::FontSizeSetter) { if (value->IsNumber() || value->IsString()) { CanvasRenderingContext2D *context = ObjectWrap::Unwrap(info.This()); - double fontSize = value->NumberValue(); + double fontSize = TO_DOUBLE(value); context->strokePaint.setTextSize(fontSize); context->fillPaint.setTextSize(fontSize); @@ -551,7 +551,7 @@ NAN_SETTER(CanvasRenderingContext2D::FontWeightSetter) { if (value->IsNumber() || value->IsString()) { CanvasRenderingContext2D *context = ObjectWrap::Unwrap(info.This()); - v8::String::Utf8Value text(value); + Nan::Utf8String text(value); std::string fontStyleString(*text, text.length()); unsigned int fontWeight; @@ -560,7 +560,7 @@ NAN_SETTER(CanvasRenderingContext2D::FontWeightSetter) { } else if (fontStyleString == "bold") { fontWeight = 700; } else { - fontWeight = value->IsNumber() ? value->Uint32Value() : 400; + fontWeight = value->IsNumber() ? TO_UINT32(value) : 400; } SkTypeface *typeface = context->strokePaint.getTypeface(); @@ -592,7 +592,7 @@ NAN_SETTER(CanvasRenderingContext2D::LineHeightSetter) { if (value->IsNumber() || value->IsString()) { CanvasRenderingContext2D *context = ObjectWrap::Unwrap(info.This()); - double lineHeight = value->NumberValue(); + double lineHeight = TO_DOUBLE(value); context->lineHeight = lineHeight; } else { @@ -609,7 +609,7 @@ NAN_SETTER(CanvasRenderingContext2D::FontStyleSetter) { if (value->IsString()) { CanvasRenderingContext2D *context = ObjectWrap::Unwrap(info.This()); - v8::String::Utf8Value text(value); + Nan::Utf8String text(value); std::string fontStyleString(*text, text.length()); SkFontStyle::Slant slant; @@ -665,7 +665,7 @@ NAN_SETTER(CanvasRenderingContext2D::TextAlignSetter) { if (value->IsString()) { CanvasRenderingContext2D *context = ObjectWrap::Unwrap(info.This()); - v8::String::Utf8Value text(value); + Nan::Utf8String text(value); std::string textAlignString(*text, text.length()); if (textAlignString == "left") { @@ -710,7 +710,7 @@ NAN_SETTER(CanvasRenderingContext2D::TextBaselineSetter) { if (value->IsString()) { CanvasRenderingContext2D *context = ObjectWrap::Unwrap(info.This()); - v8::String::Utf8Value text(value); + Nan::Utf8String text(value); std::string textBaselineString(*text, text.length()); if (textBaselineString == "top") { @@ -740,7 +740,7 @@ NAN_SETTER(CanvasRenderingContext2D::DirectionSetter) { if (value->IsString()) { CanvasRenderingContext2D *context = ObjectWrap::Unwrap(info.This()); - v8::String::Utf8Value text(value); + Nan::Utf8String text(value); std::string direction(*text, text.length()); if (direction == "ltr") { @@ -759,8 +759,8 @@ NAN_METHOD(CanvasRenderingContext2D::Scale) { // Nan::HandleScope scope; CanvasRenderingContext2D *context = ObjectWrap::Unwrap(info.This()); - double x = info[0]->NumberValue(); - double y = info[1]->NumberValue(); + double x = TO_DOUBLE(info[0]); + double y = TO_DOUBLE(info[1]); context->Scale(x, y); } @@ -768,7 +768,7 @@ NAN_METHOD(CanvasRenderingContext2D::Rotate) { // Nan::HandleScope scope; CanvasRenderingContext2D *context = ObjectWrap::Unwrap(info.This()); - double angle = info[0]->NumberValue(); + double angle = TO_DOUBLE(info[0]); context->Rotate(angle); } @@ -776,8 +776,8 @@ NAN_METHOD(CanvasRenderingContext2D::Translate) { // Nan::HandleScope scope; CanvasRenderingContext2D *context = ObjectWrap::Unwrap(info.This()); - double x = info[0]->NumberValue(); - double y = info[1]->NumberValue(); + double x = TO_DOUBLE(info[0]); + double y = TO_DOUBLE(info[1]); context->Translate(x, y); } @@ -785,12 +785,12 @@ NAN_METHOD(CanvasRenderingContext2D::Transform) { // Nan::HandleScope scope; CanvasRenderingContext2D *context = ObjectWrap::Unwrap(info.This()); - double a = info[0]->NumberValue(); - double b = info[1]->NumberValue(); - double c = info[2]->NumberValue(); - double d = info[3]->NumberValue(); - double e = info[4]->NumberValue(); - double f = info[5]->NumberValue(); + double a = TO_DOUBLE(info[0]); + double b = TO_DOUBLE(info[1]); + double c = TO_DOUBLE(info[2]); + double d = TO_DOUBLE(info[3]); + double e = TO_DOUBLE(info[4]); + double f = TO_DOUBLE(info[5]); context->Transform(a, b, c, d, e, f); } @@ -798,12 +798,12 @@ NAN_METHOD(CanvasRenderingContext2D::SetTransform) { // Nan::HandleScope scope; CanvasRenderingContext2D *context = ObjectWrap::Unwrap(info.This()); - double a = info[0]->NumberValue(); - double b = info[1]->NumberValue(); - double c = info[2]->NumberValue(); - double d = info[3]->NumberValue(); - double e = info[4]->NumberValue(); - double f = info[5]->NumberValue(); + double a = TO_DOUBLE(info[0]); + double b = TO_DOUBLE(info[1]); + double c = TO_DOUBLE(info[2]); + double d = TO_DOUBLE(info[3]); + double e = TO_DOUBLE(info[4]); + double f = TO_DOUBLE(info[5]); context->SetTransform(a, b, c, d, e, f); } @@ -818,7 +818,7 @@ NAN_METHOD(CanvasRenderingContext2D::MeasureText) { // Nan::HandleScope scope; CanvasRenderingContext2D *context = ObjectWrap::Unwrap(info.This()); - v8::String::Utf8Value textUtf8(info[0]); + Nan::Utf8String textUtf8(info[0]); std::string text(*textUtf8, textUtf8.length()); Local result = Object::New(Isolate::GetCurrent()); @@ -854,7 +854,7 @@ NAN_METHOD(CanvasRenderingContext2D::Stroke) { CanvasRenderingContext2D *context = ObjectWrap::Unwrap(info.This()); - if (info[0]->BooleanValue() && info[0]->ToObject()->Get(JS_STR("constructor"))->ToObject()->Get(JS_STR("name"))->StrictEquals(JS_STR("Path2D"))) { + if (TO_BOOL(info[0]) && JS_OBJ(JS_OBJ(info[0])->Get(JS_STR("constructor")))->Get(JS_STR("name"))->StrictEquals(JS_STR("Path2D"))) { Path2D *path2d = ObjectWrap::Unwrap(Local::Cast(info[0])); context->Stroke(*path2d); } else { @@ -867,7 +867,7 @@ NAN_METHOD(CanvasRenderingContext2D::Fill) { CanvasRenderingContext2D *context = ObjectWrap::Unwrap(info.This()); - if (info[0]->BooleanValue() && info[0]->ToObject()->Get(JS_STR("constructor"))->ToObject()->Get(JS_STR("name"))->StrictEquals(JS_STR("Path2D"))) { + if (TO_BOOL(info[0]) && JS_OBJ(JS_OBJ(info[0])->Get(JS_STR("constructor")))->Get(JS_STR("name"))->StrictEquals(JS_STR("Path2D"))) { Path2D *path2d = ObjectWrap::Unwrap(Local::Cast(info[0])); context->Fill(*path2d); } else { @@ -879,8 +879,8 @@ NAN_METHOD(CanvasRenderingContext2D::MoveTo) { // Nan::HandleScope scope; CanvasRenderingContext2D *context = ObjectWrap::Unwrap(info.This()); - double x = info[0]->NumberValue(); - double y = info[1]->NumberValue(); + double x = TO_DOUBLE(info[0]); + double y = TO_DOUBLE(info[1]); context->MoveTo(x, y); } @@ -889,8 +889,8 @@ NAN_METHOD(CanvasRenderingContext2D::LineTo) { // Nan::HandleScope scope; CanvasRenderingContext2D *context = ObjectWrap::Unwrap(info.This()); - double x = info[0]->NumberValue(); - double y = info[1]->NumberValue(); + double x = TO_DOUBLE(info[0]); + double y = TO_DOUBLE(info[1]); context->LineTo(x, y); } @@ -899,12 +899,12 @@ NAN_METHOD(CanvasRenderingContext2D::Arc) { // Nan::HandleScope scope; CanvasRenderingContext2D *context = ObjectWrap::Unwrap(info.This()); - double x = info[0]->NumberValue(); - double y = info[1]->NumberValue(); - double radius = info[2]->NumberValue(); - double startAngle = info[3]->NumberValue(); - double endAngle = info[4]->NumberValue(); - double anticlockwise = info[5]->NumberValue(); + double x = TO_DOUBLE(info[0]); + double y = TO_DOUBLE(info[1]); + double radius = TO_DOUBLE(info[2]); + double startAngle = TO_DOUBLE(info[3]); + double endAngle = TO_DOUBLE(info[4]); + double anticlockwise = TO_DOUBLE(info[5]); context->Arc(x, y, radius, startAngle, endAngle, anticlockwise); } @@ -913,11 +913,11 @@ NAN_METHOD(CanvasRenderingContext2D::ArcTo) { // Nan::HandleScope scope; CanvasRenderingContext2D *context = ObjectWrap::Unwrap(info.This()); - double x1 = info[0]->NumberValue(); - double y1 = info[1]->NumberValue(); - double x2 = info[2]->NumberValue(); - double y2 = info[3]->NumberValue(); - double radius = info[4]->NumberValue(); + double x1 = TO_DOUBLE(info[0]); + double y1 = TO_DOUBLE(info[1]); + double x2 = TO_DOUBLE(info[2]); + double y2 = TO_DOUBLE(info[3]); + double radius = TO_DOUBLE(info[4]); context->ArcTo(x1, y1, x2, y2, radius); } @@ -926,10 +926,10 @@ NAN_METHOD(CanvasRenderingContext2D::QuadraticCurveTo) { // Nan::HandleScope scope; CanvasRenderingContext2D *context = ObjectWrap::Unwrap(info.This()); - double x1 = info[0]->NumberValue(); - double y1 = info[1]->NumberValue(); - double x2 = info[2]->NumberValue(); - double y2 = info[3]->NumberValue(); + double x1 = TO_DOUBLE(info[0]); + double y1 = TO_DOUBLE(info[1]); + double x2 = TO_DOUBLE(info[2]); + double y2 = TO_DOUBLE(info[3]); context->QuadraticCurveTo(x1, y1, x2, y2); } @@ -938,12 +938,12 @@ NAN_METHOD(CanvasRenderingContext2D::BezierCurveTo) { // Nan::HandleScope scope; CanvasRenderingContext2D *context = ObjectWrap::Unwrap(info.This()); - double x1 = info[0]->NumberValue(); - double y1 = info[1]->NumberValue(); - double x2 = info[2]->NumberValue(); - double y2 = info[3]->NumberValue(); - double x = info[4]->NumberValue(); - double y = info[5]->NumberValue(); + double x1 = TO_DOUBLE(info[0]); + double y1 = TO_DOUBLE(info[1]); + double x2 = TO_DOUBLE(info[2]); + double y2 = TO_DOUBLE(info[3]); + double x = TO_DOUBLE(info[4]); + double y = TO_DOUBLE(info[5]); context->BezierCurveTo(x1, y1, x2, y2, x, y); } @@ -952,10 +952,10 @@ NAN_METHOD(CanvasRenderingContext2D::Rect) { // Nan::HandleScope scope; CanvasRenderingContext2D *context = ObjectWrap::Unwrap(info.This()); - double x = info[0]->NumberValue(); - double y = info[1]->NumberValue(); - double w = info[2]->NumberValue(); - double h = info[3]->NumberValue(); + double x = TO_DOUBLE(info[0]); + double y = TO_DOUBLE(info[1]); + double w = TO_DOUBLE(info[2]); + double h = TO_DOUBLE(info[3]); context->Rect(x, y, w, h); @@ -966,10 +966,10 @@ NAN_METHOD(CanvasRenderingContext2D::FillRect) { // Nan::HandleScope scope; CanvasRenderingContext2D *context = ObjectWrap::Unwrap(info.This()); - double x = info[0]->NumberValue(); - double y = info[1]->NumberValue(); - double w = info[2]->NumberValue(); - double h = info[3]->NumberValue(); + double x = TO_DOUBLE(info[0]); + double y = TO_DOUBLE(info[1]); + double w = TO_DOUBLE(info[2]); + double h = TO_DOUBLE(info[3]); context->FillRect(x, y, w, h); @@ -980,10 +980,10 @@ NAN_METHOD(CanvasRenderingContext2D::StrokeRect) { // Nan::HandleScope scope; CanvasRenderingContext2D *context = ObjectWrap::Unwrap(info.This()); - double x = info[0]->NumberValue(); - double y = info[1]->NumberValue(); - double w = info[2]->NumberValue(); - double h = info[3]->NumberValue(); + double x = TO_DOUBLE(info[0]); + double y = TO_DOUBLE(info[1]); + double w = TO_DOUBLE(info[2]); + double h = TO_DOUBLE(info[3]); context->StrokeRect(x, y, w, h); @@ -994,10 +994,10 @@ NAN_METHOD(CanvasRenderingContext2D::ClearRect) { // Nan::HandleScope scope; CanvasRenderingContext2D *context = ObjectWrap::Unwrap(info.This()); - double x = info[0]->NumberValue(); - double y = info[1]->NumberValue(); - double w = info[2]->NumberValue(); - double h = info[3]->NumberValue(); + double x = TO_DOUBLE(info[0]); + double y = TO_DOUBLE(info[1]); + double w = TO_DOUBLE(info[2]); + double h = TO_DOUBLE(info[3]); context->ClearRect(x, y, w, h); @@ -1008,10 +1008,10 @@ NAN_METHOD(CanvasRenderingContext2D::FillText) { // Nan::HandleScope scope; CanvasRenderingContext2D *context = ObjectWrap::Unwrap(info.This()); - v8::String::Utf8Value text(info[0]); + Nan::Utf8String text(info[0]); std::string string(*text, text.length()); - double x = info[1]->NumberValue(); - double y = info[2]->NumberValue(); + double x = TO_DOUBLE(info[1]); + double y = TO_DOUBLE(info[2]); context->FillText(string, x, y); @@ -1022,10 +1022,10 @@ NAN_METHOD(CanvasRenderingContext2D::StrokeText) { // Nan::HandleScope scope; CanvasRenderingContext2D *context = ObjectWrap::Unwrap(info.This()); - v8::String::Utf8Value text(info[0]); + Nan::Utf8String text(info[0]); std::string string(*text, text.length()); - double x = info[1]->NumberValue(); - double y = info[2]->NumberValue(); + double x = TO_DOUBLE(info[1]); + double y = TO_DOUBLE(info[2]); context->StrokeText(string, x, y); @@ -1037,7 +1037,7 @@ NAN_METHOD(CanvasRenderingContext2D::CreateLinearGradient) { Local contextObj = Local::Cast(info.This()); CanvasRenderingContext2D *context = ObjectWrap::Unwrap(contextObj); - Local canvasGradientCons = Local::Cast(contextObj->Get(JS_STR("constructor"))->ToObject()->Get(JS_STR("CanvasGradient"))); + Local canvasGradientCons = Local::Cast(JS_OBJ(contextObj->Get(JS_STR("constructor")))->Get(JS_STR("CanvasGradient"))); Local argv[] = { info[0], info[1], @@ -1056,7 +1056,7 @@ NAN_METHOD(CanvasRenderingContext2D::CreateRadialGradient) { Local contextObj = Local::Cast(info.This()); CanvasRenderingContext2D *context = ObjectWrap::Unwrap(contextObj); - Local canvasGradientCons = Local::Cast(contextObj->Get(JS_STR("constructor"))->ToObject()->Get(JS_STR("CanvasGradient"))); + Local canvasGradientCons = Local::Cast(JS_OBJ(contextObj->Get(JS_STR("constructor")))->Get(JS_STR("CanvasGradient"))); Local argv[] = { info[0], info[1], @@ -1077,7 +1077,7 @@ NAN_METHOD(CanvasRenderingContext2D::CreatePattern) { Local contextObj = Local::Cast(info.This()); CanvasRenderingContext2D *context = ObjectWrap::Unwrap(contextObj); - Local canvasPatternCons = Local::Cast(contextObj->Get(JS_STR("constructor"))->ToObject()->Get(JS_STR("CanvasPattern"))); + Local canvasPatternCons = Local::Cast(JS_OBJ(contextObj->Get(JS_STR("constructor")))->Get(JS_STR("CanvasPattern"))); Local argv[] = { info[0], info[1], @@ -1093,8 +1093,8 @@ NAN_METHOD(CanvasRenderingContext2D::Resize) { // Nan::HandleScope scope; CanvasRenderingContext2D *context = ObjectWrap::Unwrap(info.This()); - unsigned int w = info[0]->Uint32Value(); - unsigned int h = info[1]->Uint32Value(); + unsigned int w = TO_UINT32(info[0]); + unsigned int h = TO_UINT32(info[1]); context->Resize(w, h); } @@ -1107,22 +1107,22 @@ NAN_METHOD(CanvasRenderingContext2D::DrawImage) { if (image) { CanvasRenderingContext2D *context = ObjectWrap::Unwrap(info.This()); - int x = info[1]->Int32Value(); - int y = info[2]->Int32Value(); + int x = TO_INT32(info[1]); + int y = TO_INT32(info[2]); if (info.Length() > 3) { if (info.Length() > 5) { - unsigned int sw = info[3]->Uint32Value(); - unsigned int sh = info[4]->Uint32Value(); - unsigned int dx = info[5]->Uint32Value(); - unsigned int dy = info[6]->Uint32Value(); - unsigned int dw = info[7]->Uint32Value(); - unsigned int dh = info[8]->Uint32Value(); + unsigned int sw = TO_UINT32(info[3]); + unsigned int sh = TO_UINT32(info[4]); + unsigned int dx = TO_UINT32(info[5]); + unsigned int dy = TO_UINT32(info[6]); + unsigned int dw = TO_UINT32(info[7]); + unsigned int dh = TO_UINT32(info[8]); context->DrawImage(image.get(), x, y, sw, sh, dx, dy, dw, dh); } else { - unsigned int dw = info[3]->Uint32Value(); - unsigned int dh = info[4]->Uint32Value(); + unsigned int dw = TO_UINT32(info[3]); + unsigned int dh = TO_UINT32(info[4]); unsigned int sw = image->width(); unsigned int sh = image->height(); @@ -1146,11 +1146,11 @@ NAN_METHOD(CanvasRenderingContext2D::CreateImageData) { // Nan::HandleScope scope; CanvasRenderingContext2D *context = ObjectWrap::Unwrap(Local::Cast(info.This())); - double w = info[0]->NumberValue(); - double h = info[1]->NumberValue(); + double w = TO_DOUBLE(info[0]); + double h = TO_DOUBLE(info[1]); Local imageDataCons = Local::Cast( - Local::Cast(info.This())->Get(JS_STR("constructor"))->ToObject()->Get(JS_STR("ImageData")) + JS_OBJ(Local::Cast(info.This())->Get(JS_STR("constructor")))->Get(JS_STR("ImageData")) ); Local argv[] = { Number::New(Isolate::GetCurrent(), w), @@ -1165,13 +1165,13 @@ NAN_METHOD(CanvasRenderingContext2D::GetImageData) { // Nan::HandleScope scope; CanvasRenderingContext2D *context = ObjectWrap::Unwrap(Local::Cast(info.This())); - int x = info[0]->Int32Value(); - int y = info[1]->Int32Value(); - unsigned int w = info[2]->Uint32Value(); - unsigned int h = info[3]->Uint32Value(); + int x = TO_INT32(info[0]); + int y = TO_INT32(info[1]); + unsigned int w = TO_UINT32(info[2]); + unsigned int h = TO_UINT32(info[3]); Local imageDataCons = Local::Cast( - Local::Cast(info.This())->Get(JS_STR("constructor"))->ToObject()->Get(JS_STR("ImageData")) + JS_OBJ(Local::Cast(info.This())->Get(JS_STR("constructor")))->Get(JS_STR("ImageData")) ); Local argv[] = { Number::New(Isolate::GetCurrent(), w), @@ -1192,14 +1192,14 @@ NAN_METHOD(CanvasRenderingContext2D::PutImageData) { CanvasRenderingContext2D *context = ObjectWrap::Unwrap(Local::Cast(info.This())); ImageData *imageData = ObjectWrap::Unwrap(Local::Cast(info[0])); - int x = info[1]->Int32Value(); - int y = info[2]->Int32Value(); + int x = TO_INT32(info[1]); + int y = TO_INT32(info[2]); if (info.Length() > 3) { - int dirtyX = info[3]->Int32Value(); - int dirtyY = info[4]->Int32Value(); - unsigned int dirtyWidth = info[5]->Uint32Value(); - unsigned int dirtyHeight = info[6]->Uint32Value(); + int dirtyX = TO_INT32(info[3]); + int dirtyY = TO_INT32(info[4]); + unsigned int dirtyWidth = TO_UINT32(info[5]); + unsigned int dirtyHeight = TO_UINT32(info[6]); unsigned int dw = imageData->GetWidth(); unsigned int dh = imageData->GetHeight(); @@ -1235,7 +1235,7 @@ NAN_METHOD(CanvasRenderingContext2D::ToArrayBuffer) { std::string type; if (info[0]->IsString()) { - String::Utf8Value utf8Value(Local::Cast(info[0])); + Nan::Utf8String utf8Value(Local::Cast(info[0])); type = *utf8Value; } SkEncodedImageFormat format; @@ -1250,7 +1250,7 @@ NAN_METHOD(CanvasRenderingContext2D::ToArrayBuffer) { int quality = 90; if (info[1]->IsNumber()) { - double d = std::min(std::max(info[1]->NumberValue(), 0), 1); + double d = std::min(std::max(TO_DOUBLE(info[1]), 0), 1); quality = static_cast(d * 100); } @@ -1300,9 +1300,9 @@ NAN_METHOD(CanvasRenderingContext2D::SetWindowHandle) { NAN_METHOD(CanvasRenderingContext2D::SetTexture) { CanvasRenderingContext2D *ctx = ObjectWrap::Unwrap(info.This()); if (info[0]->IsNumber() && info[1]->IsNumber() && info[2]->IsNumber()) { - GLuint tex = info[0]->Uint32Value(); - int width = info[1]->Int32Value(); - int height = info[2]->Int32Value(); + GLuint tex = TO_UINT32(info[0]); + int width = TO_INT32(info[1]); + int height = TO_INT32(info[2]); ctx->tex = tex; @@ -1327,9 +1327,9 @@ NAN_METHOD(CanvasRenderingContext2D::SetTexture) { } bool CanvasRenderingContext2D::isImageType(Local arg) { - Local constructorName = arg->ToObject()->Get(JS_STR("constructor"))->ToObject()->Get(JS_STR("name")); + Local constructorName = JS_OBJ(JS_OBJ(arg)->Get(JS_STR("constructor")))->Get(JS_STR("name")); - v8::String::Utf8Value utf8Value(constructorName); + Nan::Utf8String utf8Value(constructorName); std::string stringValue(*utf8Value, utf8Value.length()); return @@ -1353,29 +1353,29 @@ sk_sp CanvasRenderingContext2D::getImageFromContext(CanvasRenderingCont } sk_sp CanvasRenderingContext2D::getImage(Local arg) { - if (arg->ToObject()->Get(JS_STR("constructor"))->ToObject()->Get(JS_STR("name"))->StrictEquals(JS_STR("HTMLImageElement"))) { - Image *image = ObjectWrap::Unwrap(Local::Cast(arg->ToObject()->Get(JS_STR("image")))); + if (JS_OBJ(JS_OBJ(arg)->Get(JS_STR("constructor")))->Get(JS_STR("name"))->StrictEquals(JS_STR("HTMLImageElement"))) { + Image *image = ObjectWrap::Unwrap(Local::Cast(JS_OBJ(arg)->Get(JS_STR("image")))); return image->image; - } else if (arg->ToObject()->Get(JS_STR("constructor"))->ToObject()->Get(JS_STR("name"))->StrictEquals(JS_STR("HTMLVideoElement"))) { - auto video = arg->ToObject()->Get(JS_STR("video")); + } else if (JS_OBJ(JS_OBJ(arg)->Get(JS_STR("constructor")))->Get(JS_STR("name"))->StrictEquals(JS_STR("HTMLVideoElement"))) { + auto video = JS_OBJ(arg)->Get(JS_STR("video")); if (video->IsObject()) { - return getImage(video->ToObject()->Get(JS_STR("imageData"))); + return getImage(JS_OBJ(video)->Get(JS_STR("imageData"))); } return nullptr; - } else if (arg->ToObject()->Get(JS_STR("constructor"))->ToObject()->Get(JS_STR("name"))->StrictEquals(JS_STR("ImageData"))) { + } else if (JS_OBJ(JS_OBJ(arg)->Get(JS_STR("constructor")))->Get(JS_STR("name"))->StrictEquals(JS_STR("ImageData"))) { ImageData *imageData = ObjectWrap::Unwrap(Local::Cast(arg)); return SkImage::MakeFromBitmap(imageData->bitmap); - } else if (arg->ToObject()->Get(JS_STR("constructor"))->ToObject()->Get(JS_STR("name"))->StrictEquals(JS_STR("ImageBitmap"))) { + } else if (JS_OBJ(JS_OBJ(arg)->Get(JS_STR("constructor")))->Get(JS_STR("name"))->StrictEquals(JS_STR("ImageBitmap"))) { ImageBitmap *imageBitmap = ObjectWrap::Unwrap(Local::Cast(arg)); return SkImage::MakeFromBitmap(imageBitmap->bitmap); - } else if (arg->ToObject()->Get(JS_STR("constructor"))->ToObject()->Get(JS_STR("name"))->StrictEquals(JS_STR("HTMLCanvasElement"))) { - Local otherContextObj = arg->ToObject()->Get(JS_STR("_context")); - if (otherContextObj->IsObject() && otherContextObj->ToObject()->Get(JS_STR("constructor"))->ToObject()->Get(JS_STR("name"))->StrictEquals(JS_STR("CanvasRenderingContext2D"))) { + } else if (JS_OBJ(JS_OBJ(arg)->Get(JS_STR("constructor")))->Get(JS_STR("name"))->StrictEquals(JS_STR("HTMLCanvasElement"))) { + Local otherContextObj = JS_OBJ(arg)->Get(JS_STR("_context")); + if (otherContextObj->IsObject() && JS_OBJ(JS_OBJ(otherContextObj)->Get(JS_STR("constructor")))->Get(JS_STR("name"))->StrictEquals(JS_STR("CanvasRenderingContext2D"))) { CanvasRenderingContext2D *otherContext = ObjectWrap::Unwrap(Local::Cast(otherContextObj)); return getImageFromContext(otherContext); } else if (otherContextObj->IsObject() && ( - otherContextObj->ToObject()->Get(JS_STR("constructor"))->ToObject()->Get(JS_STR("name"))->StrictEquals(JS_STR("WebGLRenderingContext")) || - otherContextObj->ToObject()->Get(JS_STR("constructor"))->ToObject()->Get(JS_STR("name"))->StrictEquals(JS_STR("WebGL2RenderingContext")) + JS_OBJ(JS_OBJ(otherContextObj)->Get(JS_STR("constructor")))->Get(JS_STR("name"))->StrictEquals(JS_STR("WebGLRenderingContext")) || + JS_OBJ(JS_OBJ(otherContextObj)->Get(JS_STR("constructor")))->Get(JS_STR("name"))->StrictEquals(JS_STR("WebGL2RenderingContext")) )) { WebGLRenderingContext *gl = ObjectWrap::Unwrap(Local::Cast(otherContextObj)); diff --git a/deps/exokit-bindings/canvascontext/src/canvas-gradient.cc b/deps/exokit-bindings/canvascontext/src/canvas-gradient.cc index c90053133b..a12775c0b4 100644 --- a/deps/exokit-bindings/canvascontext/src/canvas-gradient.cc +++ b/deps/exokit-bindings/canvascontext/src/canvas-gradient.cc @@ -4,7 +4,7 @@ using namespace v8; using namespace node; // using namespace std; -Handle CanvasGradient::Initialize(Isolate *isolate) { +Local CanvasGradient::Initialize(Isolate *isolate) { Nan::EscapableHandleScope scope; // constructor @@ -17,7 +17,7 @@ Handle CanvasGradient::Initialize(Isolate *isolate) { Nan::SetMethod(proto, "addColorStop", AddColorStop); - return scope.Escape(ctor->GetFunction()); + return scope.Escape(Nan::GetFunction(ctor).ToLocalChecked()); } CanvasGradient::CanvasGradient(float x0, float y0, float x1, float y1) : type(CanvasGradient::LinearType), x0(x0), y0(y0), x1(x1), y1(y1) {} @@ -49,21 +49,21 @@ NAN_METHOD(CanvasGradient::New) { Nan::HandleScope scope; if (info.Length() == 4 && info[0]->IsNumber() && info[1]->IsNumber() && info[2]->IsNumber() && info[3]->IsNumber()) { - float x0 = info[0]->NumberValue(); - float y0 = info[1]->NumberValue(); - float x1 = info[2]->NumberValue(); - float y1 = info[3]->NumberValue(); + float x0 = TO_FLOAT(info[0]); + float y0 = TO_FLOAT(info[1]); + float x1 = TO_FLOAT(info[2]); + float y1 = TO_FLOAT(info[3]); CanvasGradient *canvasGradient = new CanvasGradient(x0, y0, x1, y1); canvasGradient->Wrap(info.This()); info.GetReturnValue().Set(info.This()); } else if (info.Length() == 6 && info[0]->IsNumber() && info[1]->IsNumber() && info[2]->IsNumber() && info[3]->IsNumber() && info[4]->IsNumber() && info[5]->IsNumber()) { - float x0 = info[0]->NumberValue(); - float y0 = info[1]->NumberValue(); - float r0 = info[2]->NumberValue(); - float x1 = info[3]->NumberValue(); - float y1 = info[4]->NumberValue(); - float r1 = info[5]->NumberValue(); + float x0 = TO_FLOAT(info[0]); + float y0 = TO_FLOAT(info[1]); + float r0 = TO_FLOAT(info[2]); + float x1 = TO_FLOAT(info[3]); + float y1 = TO_FLOAT(info[4]); + float r1 = TO_FLOAT(info[5]); CanvasGradient *canvasGradient = new CanvasGradient(x0, y0, r0, x1, y1, r1); canvasGradient->Wrap(info.This()); @@ -79,9 +79,9 @@ NAN_METHOD(CanvasGradient::AddColorStop) { if (info[0]->IsNumber() && info[1]->IsString()) { CanvasGradient *canvasGradient = ObjectWrap::Unwrap(info.This()); - SkScalar offset = info[0]->NumberValue(); - v8::String::Utf8Value colorUtf8Value(Local::Cast(info[1])); - canvas::web_color webColor = canvas::web_color::from_string(*colorUtf8Value); + SkScalar offset = TO_DOUBLE(info[0]); + Nan::Utf8String colorUtf8(Local::Cast(info[1])); + canvas::web_color webColor = canvas::web_color::from_string(*colorUtf8); canvasGradient->AddColorStop(offset, ((uint32_t)webColor.a << (8 * 3)) | ((uint32_t)webColor.r << (8 * 2)) | ((uint32_t)webColor.g << (8 * 1)) | ((uint32_t)webColor.b << (8 * 0))); } else { diff --git a/deps/exokit-bindings/canvascontext/src/canvas-pattern.cc b/deps/exokit-bindings/canvascontext/src/canvas-pattern.cc index 58a472a4dd..16d96f74b7 100644 --- a/deps/exokit-bindings/canvascontext/src/canvas-pattern.cc +++ b/deps/exokit-bindings/canvascontext/src/canvas-pattern.cc @@ -4,7 +4,7 @@ using namespace v8; using namespace node; // using namespace std; -Handle CanvasPattern::Initialize(Isolate *isolate) { +Local CanvasPattern::Initialize(Isolate *isolate) { Nan::EscapableHandleScope scope; // constructor @@ -15,7 +15,7 @@ Handle CanvasPattern::Initialize(Isolate *isolate) { // prototype // Local proto = ctor->PrototypeTemplate(); - return scope.Escape(ctor->GetFunction()); + return scope.Escape(Nan::GetFunction(ctor).ToLocalChecked()); } CanvasPattern::CanvasPattern(sk_sp shader) : shader(shader) {} @@ -33,7 +33,7 @@ NAN_METHOD(CanvasPattern::New) { if (image) { std::string repetition; if (info[1]->IsString()) { - v8::String::Utf8Value repetitionUtf8Value(info[1]); + Nan::Utf8String repetitionUtf8Value(info[1]); repetition = std::string(*repetitionUtf8Value, repetitionUtf8Value.length()); } diff --git a/deps/exokit-bindings/canvascontext/src/image-context.cc b/deps/exokit-bindings/canvascontext/src/image-context.cc index 94867fe4b6..3182641da4 100644 --- a/deps/exokit-bindings/canvascontext/src/image-context.cc +++ b/deps/exokit-bindings/canvascontext/src/image-context.cc @@ -2,7 +2,7 @@ using namespace v8; -Handle Image::Initialize(Isolate *isolate) { +Local Image::Initialize(Isolate *isolate) { Nan::EscapableHandleScope scope; // constructor @@ -15,7 +15,7 @@ Handle Image::Initialize(Isolate *isolate) { Nan::SetMethod(proto, "load", LoadMethod); - return scope.Escape(ctor->GetFunction()); + return scope.Escape(Nan::GetFunction(ctor).ToLocalChecked()); } unsigned int Image::GetWidth() { @@ -142,7 +142,7 @@ void Image::Load(Local arrayBuffer, size_t byteOffset, size_t byteL Local argv[] = { arg0, }; - cbFn->Call(Nan::Null(), sizeof(argv)/sizeof(argv[0]), argv); + cbFn->Call(Isolate::GetCurrent()->GetCurrentContext(), Nan::Null(), sizeof(argv)/sizeof(argv[0]), argv); } } diff --git a/deps/exokit-bindings/canvascontext/src/imageBitmap-context.cc b/deps/exokit-bindings/canvascontext/src/imageBitmap-context.cc index 4822f97daa..6be4424bc1 100644 --- a/deps/exokit-bindings/canvascontext/src/imageBitmap-context.cc +++ b/deps/exokit-bindings/canvascontext/src/imageBitmap-context.cc @@ -3,7 +3,7 @@ using namespace v8; using namespace node; -Handle ImageBitmap::Initialize(Isolate *isolate) { +Local ImageBitmap::Initialize(Isolate *isolate) { Nan::EscapableHandleScope scope; // constructor @@ -14,8 +14,7 @@ Handle ImageBitmap::Initialize(Isolate *isolate) { // prototype Local proto = ctor->PrototypeTemplate(); - Local ctorFn = ctor->GetFunction(); - + Local ctorFn = Nan::GetFunction(ctor).ToLocalChecked(); return scope.Escape(ctorFn); } @@ -52,12 +51,12 @@ NAN_METHOD(ImageBitmap::New) { Local imageBitmapObj = info.This(); if (info[0]->IsObject() && info[1]->IsNumber() && info[2]->IsNumber() && info[3]->IsNumber() && info[4]->IsNumber() && info[5]->IsBoolean()) { - Image *image = ObjectWrap::Unwrap(info[0]->ToObject()); - int x = info[1]->Int32Value(); - int y = info[2]->Int32Value(); - unsigned int width = info[3]->Uint32Value(); - unsigned int height = info[4]->Uint32Value(); - bool flipY = info[5]->BooleanValue(); + Image *image = ObjectWrap::Unwrap(Local::Cast(info[0])); + int x = TO_INT32(info[1]); + int y = TO_INT32(info[2]); + unsigned int width = TO_UINT32(info[3]); + unsigned int height = TO_UINT32(info[4]); + bool flipY = TO_BOOL(info[5]); SkImageInfo info = SkImageInfo::Make(width, height, SkColorType::kRGBA_8888_SkColorType, SkAlphaType::kPremul_SkAlphaType); unsigned char *address = (unsigned char *)malloc(width * height * 4); @@ -94,8 +93,8 @@ NAN_METHOD(ImageBitmap::New) { } } else { if (info[0]->IsNumber() && info[1]->IsNumber() && info[2]->IsArrayBufferView()) { - unsigned int width = info[0]->Uint32Value(); - unsigned int height = info[1]->Uint32Value(); + unsigned int width = TO_UINT32(info[0]); + unsigned int height = TO_UINT32(info[1]); Local dataValue = Local::Cast(info[2]); char *data = (char *)dataValue->Buffer()->GetContents().Data() + dataValue->ByteOffset(); diff --git a/deps/exokit-bindings/canvascontext/src/imageData-context.cc b/deps/exokit-bindings/canvascontext/src/imageData-context.cc index a4ddb1c36e..00e9c66949 100644 --- a/deps/exokit-bindings/canvascontext/src/imageData-context.cc +++ b/deps/exokit-bindings/canvascontext/src/imageData-context.cc @@ -3,7 +3,7 @@ using namespace v8; using namespace node; -Handle ImageData::Initialize(Isolate *isolate) { +Local ImageData::Initialize(Isolate *isolate) { Nan::EscapableHandleScope scope; // constructor @@ -14,7 +14,7 @@ Handle ImageData::Initialize(Isolate *isolate) { // prototype Local proto = ctor->PrototypeTemplate(); - return scope.Escape(ctor->GetFunction()); + return scope.Escape(Nan::GetFunction(ctor).ToLocalChecked()); } unsigned int ImageData::GetWidth() { @@ -45,8 +45,8 @@ NAN_METHOD(ImageData::New) { ImageData *imageData; if (info[0]->IsArrayBufferView() && info[1]->IsNumber() && info[2]->IsNumber()) { Local array = Local::Cast(info[0]); - unsigned int width = info[1]->Uint32Value(); - unsigned int height = info[2]->Uint32Value(); + unsigned int width = TO_UINT32(info[1]); + unsigned int height = TO_UINT32(info[2]); if (array->ByteLength() >= (width * height * 4)) { Local arrayBuffer = array->Buffer(); @@ -56,8 +56,8 @@ NAN_METHOD(ImageData::New) { return Nan::ThrowError("ImageData: Invalid array length"); } } else if (info[0]->IsNumber() && info[1]->IsNumber()) { - unsigned int width = info[0]->Uint32Value(); - unsigned int height = info[1]->Uint32Value(); + unsigned int width = TO_UINT32(info[0]); + unsigned int height = TO_UINT32(info[1]); imageData = new ImageData(width, height); } else { return Nan::ThrowError("ImageData: Invalid arguments"); diff --git a/deps/exokit-bindings/canvascontext/src/path2d-context.cc b/deps/exokit-bindings/canvascontext/src/path2d-context.cc index 3caee4e000..d71a6e64ab 100644 --- a/deps/exokit-bindings/canvascontext/src/path2d-context.cc +++ b/deps/exokit-bindings/canvascontext/src/path2d-context.cc @@ -4,7 +4,7 @@ using namespace v8; using namespace node; // using namespace std; -Handle Path2D::Initialize(Isolate *isolate) { +Local Path2D::Initialize(Isolate *isolate) { Nan::EscapableHandleScope scope; // constructor @@ -23,7 +23,7 @@ Handle Path2D::Initialize(Isolate *isolate) { Nan::SetMethod(proto,"quadraticCurveTo", QuadraticCurveTo); Nan::SetMethod(proto,"clear", Clear); - return scope.Escape(ctor->GetFunction()); + return scope.Escape(Nan::GetFunction(ctor).ToLocalChecked()); } void Path2D::MoveTo(float x, float y) { @@ -66,8 +66,8 @@ NAN_METHOD(Path2D::MoveTo) { Nan::HandleScope scope; Path2D *path2d = ObjectWrap::Unwrap(info.This()); - double x = info[0]->NumberValue(); - double y = info[1]->NumberValue(); + double x = TO_DOUBLE(info[0]); + double y = TO_DOUBLE(info[1]); path2d->MoveTo(x, y); } @@ -76,8 +76,8 @@ NAN_METHOD(Path2D::LineTo) { Nan::HandleScope scope; Path2D *path2d = ObjectWrap::Unwrap(info.This()); - double x = info[0]->NumberValue(); - double y = info[1]->NumberValue(); + double x = TO_DOUBLE(info[0]); + double y = TO_DOUBLE(info[1]); path2d->LineTo(x, y); } @@ -94,12 +94,12 @@ NAN_METHOD(Path2D::Arc) { Nan::HandleScope scope; Path2D *path2d = ObjectWrap::Unwrap(info.This()); - double x = info[0]->NumberValue(); - double y = info[1]->NumberValue(); - double radius = info[2]->NumberValue(); - double startAngle = info[3]->NumberValue(); - double endAngle = info[4]->NumberValue(); - double anticlockwise = info[5]->NumberValue(); + double x = TO_DOUBLE(info[0]); + double y = TO_DOUBLE(info[1]); + double radius = TO_DOUBLE(info[2]); + double startAngle = TO_DOUBLE(info[3]); + double endAngle = TO_DOUBLE(info[4]); + double anticlockwise = TO_DOUBLE(info[5]); path2d->Arc(x, y, radius, startAngle, endAngle, anticlockwise); } @@ -108,11 +108,11 @@ NAN_METHOD(Path2D::ArcTo) { Nan::HandleScope scope; Path2D *path2d = ObjectWrap::Unwrap(info.This()); - double x1 = info[0]->NumberValue(); - double y1 = info[1]->NumberValue(); - double x2 = info[2]->NumberValue(); - double y2 = info[3]->NumberValue(); - double radius = info[4]->NumberValue(); + double x1 = TO_DOUBLE(info[0]); + double y1 = TO_DOUBLE(info[1]); + double x2 = TO_DOUBLE(info[2]); + double y2 = TO_DOUBLE(info[3]); + double radius = TO_DOUBLE(info[4]); path2d->ArcTo(x1, y1, x2, y2, radius); } @@ -121,10 +121,10 @@ NAN_METHOD(Path2D::QuadraticCurveTo) { Nan::HandleScope scope; Path2D *path2d = ObjectWrap::Unwrap(info.This()); - double cpx = info[0]->NumberValue(); - double cpy = info[1]->NumberValue(); - double x = info[2]->NumberValue(); - double y = info[3]->NumberValue(); + double cpx = TO_DOUBLE(info[0]); + double cpy = TO_DOUBLE(info[1]); + double x = TO_DOUBLE(info[2]); + double y = TO_DOUBLE(info[3]); path2d->QuadraticCurveTo(cpx, cpy, x, y); } diff --git a/deps/exokit-bindings/glfw/src/glfw.cc b/deps/exokit-bindings/glfw/src/glfw.cc index b0b677b3a5..44e7a74b22 100644 --- a/deps/exokit-bindings/glfw/src/glfw.cc +++ b/deps/exokit-bindings/glfw/src/glfw.cc @@ -91,7 +91,7 @@ NAN_METHOD(GetMonitors) { } NAN_METHOD(SetMonitor) { - int index = info[0]->Int32Value(); + int index = TO_INT32(info[0]); int monitor_count; GLFWmonitor **monitors = glfwGetMonitors(&monitor_count); _activeMonitor = monitors[index]; @@ -105,7 +105,7 @@ std::unique_ptr> eventHandler; void NAN_INLINE(CallEmitter(int argc, Local argv[])) { if (eventHandler && !(*eventHandler).IsEmpty()) { Local eventHandlerFn = Nan::New(*eventHandler); - eventHandlerFn->Call(Nan::Null(), argc, argv); + eventHandlerFn->Call(Isolate::GetCurrent()->GetCurrentContext(), Nan::Null(), argc, argv); } } @@ -843,15 +843,15 @@ NAN_METHOD(FramebufferTextureLayer) { NAN_METHOD(BlitFrameBuffer) { Local glObj = Local::Cast(info[0]); - GLuint fbo1 = info[1]->Uint32Value(); - GLuint fbo2 = info[2]->Uint32Value(); - int sw = info[3]->Uint32Value(); - int sh = info[4]->Uint32Value(); - int dw = info[5]->Uint32Value(); - int dh = info[6]->Uint32Value(); - bool color = info[7]->BooleanValue(); - bool depth = info[8]->BooleanValue(); - bool stencil = info[9]->BooleanValue(); + GLuint fbo1 = TO_UINT32(info[1]); + GLuint fbo2 = TO_UINT32(info[2]); + int sw = TO_UINT32(info[3]); + int sh = TO_UINT32(info[4]); + int dw = TO_UINT32(info[5]); + int dh = TO_UINT32(info[6]); + bool color = TO_BOOL(info[7]); + bool depth = TO_BOOL(info[8]); + bool stencil = TO_BOOL(info[9]); glBindFramebuffer(GL_READ_FRAMEBUFFER, fbo1); glBindFramebuffer(GL_DRAW_FRAMEBUFFER, fbo2); @@ -916,7 +916,7 @@ NAN_METHOD(SetCurrentWindowContext) { NAN_METHOD(SetWindowTitle) { NATIVEwindow *window = (NATIVEwindow *)arrayToPointer(Local::Cast(info[0])); - String::Utf8Value str(info[1]->ToString()); + Nan::Utf8String str(Local::Cast(info[1])); glfwSetWindowTitle(window, *str); } @@ -936,12 +936,12 @@ NAN_METHOD(GetWindowSize) { NAN_METHOD(SetWindowSize) { NATIVEwindow *window = (NATIVEwindow *)arrayToPointer(Local::Cast(info[0])); - glfwSetWindowSize(window, info[1]->Uint32Value(), info[2]->Uint32Value()); + glfwSetWindowSize(window, TO_UINT32(info[1]), TO_UINT32(info[2])); } NAN_METHOD(SetWindowPos) { NATIVEwindow *window = (NATIVEwindow *)arrayToPointer(Local::Cast(info[0])); - glfwSetWindowPos(window, info[1]->Uint32Value(),info[2]->Uint32Value()); + glfwSetWindowPos(window, TO_UINT32(info[1]), TO_UINT32(info[2])); } NAN_METHOD(GetWindowPos) { @@ -1163,9 +1163,9 @@ NATIVEwindow *CreateNativeWindow(unsigned int width, unsigned int height, bool v } NAN_METHOD(Create3D) { - unsigned int width = info[0]->Uint32Value(); - unsigned int height = info[1]->Uint32Value(); - bool initialVisible = info[2]->BooleanValue(); + unsigned int width = TO_UINT32(info[0]); + unsigned int height = TO_UINT32(info[1]); + bool initialVisible = TO_BOOL(info[2]); NATIVEwindow *sharedWindow = info[3]->IsArray() ? (NATIVEwindow *)arrayToPointer(Local::Cast(info[3])) : nullptr; WebGLRenderingContext *gl = ObjectWrap::Unwrap(Local::Cast(info[4])); @@ -1244,8 +1244,8 @@ NAN_METHOD(Create3D) { } NAN_METHOD(Create2D) { - unsigned int width = info[0]->Uint32Value(); - unsigned int height = info[1]->Uint32Value(); + unsigned int width = TO_UINT32(info[0]); + unsigned int height = TO_UINT32(info[1]); NATIVEwindow *sharedWindow = info[2]->IsArray() ? (NATIVEwindow *)arrayToPointer(Local::Cast(info[2])) : nullptr; NATIVEwindow *windowHandle = CreateNativeWindow(width, height, false, sharedWindow); @@ -1317,7 +1317,7 @@ NAN_METHOD(GetRefreshRate) { NAN_METHOD(SetCursorMode) { NATIVEwindow *window = (NATIVEwindow *)arrayToPointer(Local::Cast(info[0])); - if (info[1]->BooleanValue()) { + if (TO_BOOL(info[1])) { glfwSetInputMode(window, GLFW_CURSOR, GLFW_CURSOR_NORMAL); } else { glfwSetInputMode(window, GLFW_CURSOR, GLFW_CURSOR_DISABLED); @@ -1336,8 +1336,8 @@ NAN_METHOD(SetCursorMode) { NAN_METHOD(SetCursorPosition) { NATIVEwindow *window = (NATIVEwindow *)arrayToPointer(Local::Cast(info[0])); - int x = info[1]->Int32Value(); - int y = info[2]->Int32Value(); + int x = TO_INT32(info[1]); + int y = TO_INT32(info[2]); glfwSetCursorPos(window, x, y); } diff --git a/deps/exokit-bindings/leapmotion/include/leapmotion.h b/deps/exokit-bindings/leapmotion/include/leapmotion.h index fc31e9a0bf..cc13ca9d85 100644 --- a/deps/exokit-bindings/leapmotion/include/leapmotion.h +++ b/deps/exokit-bindings/leapmotion/include/leapmotion.h @@ -33,7 +33,7 @@ class ListenerImpl : public Leap::Listener { class LMContext : public ObjectWrap { public: - static Handle Initialize(Isolate *isolate); + static Local Initialize(Isolate *isolate); protected: LMContext(); @@ -48,6 +48,6 @@ class LMContext : public ObjectWrap { } -Handle makeLm(); +Local makeLm(); #endif diff --git a/deps/exokit-bindings/leapmotion/src/leapmotion.cc b/deps/exokit-bindings/leapmotion/src/leapmotion.cc index 09835b48be..acd8f49d04 100644 --- a/deps/exokit-bindings/leapmotion/src/leapmotion.cc +++ b/deps/exokit-bindings/leapmotion/src/leapmotion.cc @@ -151,7 +151,7 @@ LMContext::LMContext() { LMContext::~LMContext() {} -Handle LMContext::Initialize(Isolate *isolate) { +Local LMContext::Initialize(Isolate *isolate) { Nan::EscapableHandleScope scope; // constructor @@ -163,7 +163,7 @@ Handle LMContext::Initialize(Isolate *isolate) { Local proto = ctor->PrototypeTemplate(); Nan::SetMethod(proto, "WaitGetPoses", WaitGetPoses); - Local ctorFn = ctor->GetFunction(); + Local ctorFn = Nan::GetFunction(ctor).ToLocalChecked(); return scope.Escape(ctorFn); } @@ -254,7 +254,7 @@ NAN_METHOD(LMContext::WaitGetPoses) { } -Handle makeLm() { +Local makeLm() { Isolate *isolate = Isolate::GetCurrent(); Nan::EscapableHandleScope scope; diff --git a/deps/exokit-bindings/util/include/defines.h b/deps/exokit-bindings/util/include/defines.h index 1b97fc1df5..6472e14aaf 100644 --- a/deps/exokit-bindings/util/include/defines.h +++ b/deps/exokit-bindings/util/include/defines.h @@ -11,6 +11,14 @@ using namespace v8; #define JS_NUM(val) Nan::New(val) #define JS_FLOAT(val) Nan::New(val) #define JS_BOOL(val) Nan::New(val) +#define JS_FN(val) Nan::New(val) +#define JS_OBJ(val) Nan::To(val).ToLocalChecked() + +#define TO_DOUBLE(x) (Nan::To(x).FromJust()) +#define TO_BOOL(x) (Nan::To(x).FromJust()) +#define TO_UINT32(x) (Nan::To(x).FromJust()) +#define TO_INT32(x) (Nan::To(x).FromJust()) +#define TO_FLOAT(x) static_cast((Nan::To(x).FromJust())) template class shared_ptr_release_deleter { diff --git a/deps/exokit-bindings/util/src/defines.cc b/deps/exokit-bindings/util/src/defines.cc index b479d8f2a7..3f2362a724 100644 --- a/deps/exokit-bindings/util/src/defines.cc +++ b/deps/exokit-bindings/util/src/defines.cc @@ -9,6 +9,6 @@ Local pointerToArray(void *ptr) { } void *arrayToPointer(Local array) { - uintptr_t n = ((uintptr_t)array->Get(0)->Uint32Value() << 32) | (uintptr_t)array->Get(1)->Uint32Value(); + uintptr_t n = ((uintptr_t)TO_UINT32(array->Get(0)) << 32) | (uintptr_t)TO_UINT32(array->Get(1)); return (void *)n; } \ No newline at end of file diff --git a/deps/exokit-bindings/videocontext/include/Video.h b/deps/exokit-bindings/videocontext/include/Video.h index 1f80ef4f37..ff94b3cde2 100644 --- a/deps/exokit-bindings/videocontext/include/Video.h +++ b/deps/exokit-bindings/videocontext/include/Video.h @@ -58,7 +58,7 @@ class AppData { class Video : public ObjectWrap { public: - static Handle Initialize(Isolate *isolate); + static Local Initialize(Isolate *isolate); bool Load(uint8_t *bufferValue, size_t bufferLength, string *error = nullptr); void Update(); void Play(); @@ -106,7 +106,7 @@ class VideoCamera; class VideoDevice : public ObjectWrap { public: - static Handle Initialize(Isolate *isolate, Local imageDataCons); + static Local Initialize(Isolate *isolate, Local imageDataCons); protected: static NAN_METHOD(New); diff --git a/deps/exokit-bindings/videocontext/src/Video.cpp b/deps/exokit-bindings/videocontext/src/Video.cpp index 193b6669de..9a45d544eb 100644 --- a/deps/exokit-bindings/videocontext/src/Video.cpp +++ b/deps/exokit-bindings/videocontext/src/Video.cpp @@ -223,7 +223,7 @@ Video::~Video() { videos.erase(std::find(videos.begin(), videos.end(), this)); } -Handle Video::Initialize(Isolate *isolate) { +Local Video::Initialize(Isolate *isolate) { // initialize libav av_register_all(); avcodec_register_all(); @@ -250,7 +250,7 @@ Handle Video::Initialize(Isolate *isolate) { Nan::SetAccessor(proto, JS_STR("currentTime"), CurrentTimeGetter, CurrentTimeSetter); Nan::SetAccessor(proto, JS_STR("duration"), DurationGetter); - Local ctorFn = ctor->GetFunction(); + Local ctorFn = Nan::GetFunction(ctor).ToLocalChecked(); Nan::SetMethod(ctorFn, "updateAll", UpdateAll); Nan::SetMethod(ctorFn, "getDevices", GetDevices); @@ -422,7 +422,7 @@ NAN_SETTER(Video::LoopSetter) { if (value->IsBoolean()) { Video *video = ObjectWrap::Unwrap