From 7ed6fc3d761b84b02e2215d2b9badc42766da15a Mon Sep 17 00:00:00 2001 From: unbornchikken Date: Wed, 26 Aug 2015 21:47:28 +0200 Subject: [PATCH 1/8] in progress --- package.json | 10 +- src/node-proxy.cc | 910 ++++++++++++++++++++++------------------------ 2 files changed, 450 insertions(+), 470 deletions(-) diff --git a/package.json b/package.json index 6378dc8..45ce06b 100644 --- a/package.json +++ b/package.json @@ -6,17 +6,19 @@ "interceptor", "proxy", "overload", - "__noSuchMethod__" + "__noSuchMethod__", + "es6" ], "dependencies": { - "bindings": "1.1.x", - "nan": "^1.7.0" + "bindings": "1", + "nan": "2" }, "contributors": [ "Sam Shull ", "richardms ", "Andreas Botsikas ", - "Kenneth Bentley " + "Kenneth Bentley ", + "Gabor Mezo " ], "licenses": [ { diff --git a/src/node-proxy.cc b/src/node-proxy.cc index b033829..66ab655 100644 --- a/src/node-proxy.cc +++ b/src/node-proxy.cc @@ -62,44 +62,43 @@ NodeProxy::~NodeProxy() { * @throws Error */ NAN_METHOD(NodeProxy::Clone) { - NanScope(); - if (args.Length() < 1) { - NanThrowError("clone requires at least one (1) argument."); + if (info.Length() < 1) { + Nan::ThrowError("clone requires at least one (1) argument."); } - if (args[0]->IsString()) { - NanReturnValue(args[0]->ToObject()->Clone()->ToString()); + if (info[0]->IsString()) { + info.GetReturnValue().Set(info[0]->ToObject()->Clone()->ToString()); - } else if (args[0]->IsBoolean()) { - NanReturnValue(args[0]->ToObject()->Clone()->ToBoolean()); + } else if (info[0]->IsBoolean()) { + info.GetReturnValue().Set(info[0]->ToObject()->Clone()->ToBoolean()); - } else if (args[0]->IsNumber() - || args[0]->IsInt32() - || args[0]->IsUint32()) { - NanReturnValue(args[0]->ToObject()->Clone()->ToNumber()); + } else if (info[0]->IsNumber() + || info[0]->IsInt32() + || info[0]->IsUint32()) { + info.GetReturnValue().Set(info[0]->ToObject()->Clone()->ToNumber()); - } else if (args[0]->IsArray()) { - NanReturnValue(Local::Cast(args[0]->ToObject()->Clone())); + } else if (info[0]->IsArray()) { + info.GetReturnValue().Set(Local::Cast(info[0]->ToObject()->Clone())); - } else if (args[0]->IsDate()) { - NanReturnValue(Local::Cast(args[0]->ToObject()->Clone())); + } else if (info[0]->IsDate()) { + info.GetReturnValue().Set(Local::Cast(info[0]->ToObject()->Clone())); - } else if (args[0]->IsFunction()) { - NanReturnValue(Local::Cast(args[0])->Clone()); + } else if (info[0]->IsFunction()) { + info.GetReturnValue().Set(Local::Cast(info[0])->Clone()); - } else if (args[0]->IsNull()) { - NanReturnNull(); + } else if (info[0]->IsNull()) { + info.GetReturnValue().SetNull(); - } else if (args[0]->IsUndefined()) { - NanReturnUndefined(); + } else if (info[0]->IsUndefined()) { + info.GetReturnValue().SetUndefined(); - } else if (args[0]->IsObject()) { - NanReturnValue(args[0]->ToObject()->Clone()); + } else if (info[0]->IsObject()) { + info.GetReturnValue().Set(info[0]->ToObject()->Clone()); } - NanThrowError("clone cannot determine the type of the argument."); - NanReturnUndefined(); // <-- silence warnings for 0.10.x + Nan::ThrowError("clone cannot determine the type of the argument."); + info.GetReturnValue().SetUndefined(); // <-- silence warnings for 0.10.x } /** @@ -119,25 +118,24 @@ NAN_METHOD(NodeProxy::Clone) { * @throws Error */ NAN_METHOD(NodeProxy::Hidden) { - NanScope(); - if (args.Length() < 2) { - NanThrowError("hidden requires at least two (2) arguments."); + if (info.Length() < 2) { + Nan::ThrowError("hidden requires at least two (2) arguments."); } - Local obj = args[0]->ToObject(); + Local obj = info[0]->ToObject(); - if (args.Length() < 3) { - NanReturnValue(obj->GetHiddenValue( - String::Concat(NanNew("NodeProxy::hidden:"), - args[1]->ToString()))); + if (info.Length() < 3) { + info.GetReturnValue().Set(obj->GetHiddenValue( + String::Concat(Nan::New("NodeProxy::hidden:").ToLocalChecked(), + info[1]->ToString()))); } - NanReturnValue( - NanNew( - obj->SetHiddenValue(String::Concat(NanNew("NodeProxy::hidden:"), - args[1]->ToString()), - args[2]))); + info.GetReturnValue().Set( + Nan::New( + obj->SetHiddenValue(String::Concat(Nan::New("NodeProxy::hidden:").ToLocalChecked(), + info[1]->ToString()), + info[2]))); } /** @@ -149,12 +147,11 @@ NAN_METHOD(NodeProxy::Hidden) { * @throws Error */ NAN_METHOD(NodeProxy::SetPrototype) { - NanScope(); - if (args.Length() < 2) { - NanThrowError("setPrototype requires at least two (2) arguments."); + if (info.Length() < 2) { + Nan::ThrowError("setPrototype requires at least two (2) arguments."); } - NanReturnValue(NanNew(args[0]->ToObject()->SetPrototype(args[1]))); + info.GetReturnValue().Set(Nan::New(info[0]->ToObject()->SetPrototype(info[1]))); } /** @@ -164,21 +161,20 @@ NAN_METHOD(NodeProxy::SetPrototype) { * @returns Boolean */ NAN_METHOD(NodeProxy::IsProxy) { - NanScope(); - if (args.Length() < 1) { - NanThrowError("isProxy requires at least one (1) argument."); + if (info.Length() < 1) { + Nan::ThrowError("isProxy requires at least one (1) argument."); } - Local obj = args[0]->ToObject(); + Local obj = info[0]->ToObject(); if (obj->InternalFieldCount() > 0) { Local temp = obj->GetInternalField(0); - NanReturnValue(NanNew(!temp.IsEmpty() && temp->IsObject())); + info.GetReturnValue().Set(Nan::New(!temp.IsEmpty() && temp->IsObject())); } - NanReturnValue(NanFalse()); + info.GetReturnValue().Set(Nan::False()); } /** @@ -195,41 +191,40 @@ NAN_METHOD(NodeProxy::IsProxy) { * @throws Error, TypeError */ NAN_METHOD(NodeProxy::Create) { - NanScope(); Local proxyHandler; - if (args.Length() < 1) { - NanThrowError("create requires at least one (1) argument."); + if (info.Length() < 1) { + Nan::ThrowError("create requires at least one (1) argument."); } - if (!args[0]->IsObject()) { - NanThrowTypeError( + if (!info[0]->IsObject()) { + Nan::ThrowTypeError( "create requires the first argument to be an Object."); } - proxyHandler = args[0]->ToObject(); + proxyHandler = info[0]->ToObject(); - if (args.Length() > 1 && !args[1]->IsObject()) { - NanThrowTypeError( + if (info.Length() > 1 && !info[1]->IsObject()) { + Nan::ThrowTypeError( "create requires the second argument to be an Object."); } // manage locking states - proxyHandler->SetHiddenValue(NanNew("trapping"), NanTrue()); - proxyHandler->SetHiddenValue(NanNew("extensible"), NanTrue()); - proxyHandler->SetHiddenValue(NanNew("sealed"), NanFalse()); - proxyHandler->SetHiddenValue(NanNew("frozen"), NanFalse()); + proxyHandler->SetHiddenValue(Nan::New("trapping").ToLocalChecked(), Nan::True()); + proxyHandler->SetHiddenValue(Nan::New("extensible").ToLocalChecked(), Nan::True()); + proxyHandler->SetHiddenValue(Nan::New("sealed").ToLocalChecked(), Nan::False()); + proxyHandler->SetHiddenValue(Nan::New("frozen").ToLocalChecked(), Nan::False()); - Local instance = NanNew(ObjectCreator)->NewInstance(); + Local instance = Nan::New(ObjectCreator)->NewInstance(); instance->SetInternalField(0, proxyHandler); - if (args.Length() > 1) { - instance->SetPrototype(args[1]); + if (info.Length() > 1) { + instance->SetPrototype(info[1]); } - NanReturnValue(instance); + info.GetReturnValue().Set(instance); } /** @@ -245,47 +240,46 @@ NAN_METHOD(NodeProxy::Create) { * @throws Error, TypeError */ NAN_METHOD(NodeProxy::CreateFunction) { - NanScope(); - if (args.Length() < 2) { - NanThrowError("createFunction requires at least two (2) arguments."); + if (info.Length() < 2) { + Nan::ThrowError("createFunction requires at least two (2) arguments."); } - if (!args[0]->IsObject()) { - NanThrowTypeError("createFunction requires the first argument to be an Object."); + if (!info[0]->IsObject()) { + Nan::ThrowTypeError("createFunction requires the first argument to be an Object."); } - Local proxyHandler = args[0]->ToObject(); + Local proxyHandler = info[0]->ToObject(); - if (!args[1]->IsFunction()) { - NanThrowTypeError("createFunction requires the second argument to be a Function."); + if (!info[1]->IsFunction()) { + Nan::ThrowTypeError("createFunction requires the second argument to be a Function."); } - if (args.Length() > 2 && !args[2]->IsFunction()) { - NanThrowTypeError("createFunction requires the second argument to be a Function."); + if (info.Length() > 2 && !info[2]->IsFunction()) { + Nan::ThrowTypeError("createFunction requires the second argument to be a Function."); } - proxyHandler->SetHiddenValue(NanNew("callTrap"), args[1]); + proxyHandler->SetHiddenValue(Nan::New("callTrap").ToLocalChecked(), info[1]); Local constructorTrap; - if(args.Length() > 2) { - constructorTrap = args[2]; + if(info.Length() > 2) { + constructorTrap = info[2]; } else { - constructorTrap = NanNew(NanUndefined()); + constructorTrap = Nan::Undefined(); } - proxyHandler->SetHiddenValue(NanNew("constructorTrap"), constructorTrap); + proxyHandler->SetHiddenValue(Nan::New("constructorTrap").ToLocalChecked(), constructorTrap); // manage locking states - proxyHandler->SetHiddenValue(NanNew("trapping"), NanTrue()); - proxyHandler->SetHiddenValue(NanNew("extensible"), NanTrue()); - proxyHandler->SetHiddenValue(NanNew("sealed"), NanFalse()); - proxyHandler->SetHiddenValue(NanNew("frozen"), NanFalse()); + proxyHandler->SetHiddenValue(Nan::New("trapping").ToLocalChecked(), Nan::True()); + proxyHandler->SetHiddenValue(Nan::New("extensible").ToLocalChecked(), Nan::True()); + proxyHandler->SetHiddenValue(Nan::New("sealed").ToLocalChecked(), Nan::False()); + proxyHandler->SetHiddenValue(Nan::New("frozen").ToLocalChecked(), Nan::False()); - Local fn = NanNew(FunctionCreator)->NewInstance(); - fn->SetPrototype(args[1]->ToObject()->GetPrototype()); + Local fn = Nan::New(FunctionCreator)->NewInstance(); + fn->SetPrototype(info[1]->ToObject()->GetPrototype()); fn->SetInternalField(0, proxyHandler); - NanReturnValue(fn); + info.GetReturnValue().Set(fn); } /** @@ -297,19 +291,18 @@ NAN_METHOD(NodeProxy::CreateFunction) { * @throws Error, TypeError */ NAN_METHOD(NodeProxy::Freeze) { - NanScope(); - Local name = args.Callee()->GetName()->ToString(); + Local name = info.Callee()->GetName()->ToString(); - if (args.Length() < 1) { - NanThrowError(String::Concat(name, - NanNew(" requires at least one (1) argument."))); + if (info.Length() < 1) { + Nan::ThrowError(String::Concat(name, + Nan::New(" requires at least one (1) argument.").ToLocalChecked())); } - Local obj = args[0]->ToObject(); + Local obj = info[0]->ToObject(); if (obj->InternalFieldCount() < 1) { - NanThrowTypeError( + Nan::ThrowTypeError( "Locking functions expect first " "argument to be intialized by Proxy"); } @@ -317,7 +310,7 @@ NAN_METHOD(NodeProxy::Freeze) { Local hide = obj->GetInternalField(0); if (hide.IsEmpty() || !hide->IsObject()) { - NanThrowTypeError( + Nan::ThrowTypeError( "Locking functions expect first " "argument to be intialized by Proxy"); } @@ -325,77 +318,77 @@ NAN_METHOD(NodeProxy::Freeze) { Local handler = hide->ToObject(); // if the object already meets the requirements of the function call - if (name->Equals(NanNew("freeze"))) { - if (handler->GetHiddenValue(NanNew("frozen"))->BooleanValue()) { - NanReturnValue(NanTrue()); + if (name->Equals(Nan::New("freeze").ToLocalChecked())) { + if (handler->GetHiddenValue(Nan::New("frozen").ToLocalChecked())->BooleanValue()) { + info.GetReturnValue().Set(Nan::True()); } - } else if (name->Equals(NanNew("seal"))) { - if (handler->GetHiddenValue(NanNew("sealed"))->BooleanValue()) { - NanReturnValue(NanTrue()); + } else if (name->Equals(Nan::New("seal").ToLocalChecked())) { + if (handler->GetHiddenValue(Nan::New("sealed").ToLocalChecked())->BooleanValue()) { + info.GetReturnValue().Set(Nan::True()); } - } else if (name->Equals(NanNew("preventExtensions"))) { - if (handler->GetHiddenValue(NanNew("extensible"))->BooleanValue()) { - NanReturnValue(NanTrue()); + } else if (name->Equals(Nan::New("preventExtensions").ToLocalChecked())) { + if (handler->GetHiddenValue(Nan::New("extensible").ToLocalChecked())->BooleanValue()) { + info.GetReturnValue().Set(Nan::True()); } } // if this object is not trapping, just set the appropriate parameters - if (!handler->GetHiddenValue(NanNew("trapping"))->BooleanValue()) { - if (name->Equals(NanNew("freeze"))) { - handler->SetHiddenValue(NanNew("frozen"), NanTrue()); - handler->SetHiddenValue(NanNew("sealed"), NanTrue()); - handler->SetHiddenValue(NanNew("extensible"), NanFalse()); - NanReturnValue(NanTrue()); - - } else if (name->Equals(NanNew("seal"))) { - handler->SetHiddenValue(NanNew("sealed"), NanTrue()); - handler->SetHiddenValue(NanNew("extensible"), NanFalse()); - NanReturnValue(NanTrue()); - - } else if (name->Equals(NanNew("preventExtensions"))) { - handler->SetHiddenValue(NanNew("extensible"), NanFalse()); - NanReturnValue(NanTrue()); + if (!handler->GetHiddenValue(Nan::New("trapping").ToLocalChecked())->BooleanValue()) { + if (name->Equals(Nan::New("freeze"))) { + handler->SetHiddenValue(Nan::New("frozen").ToLocalChecked(), Nan::True()); + handler->SetHiddenValue(Nan::New("sealed").ToLocalChecked(), Nan::True()); + handler->SetHiddenValue(Nan::New("extensible").ToLocalChecked(), Nan::False()); + info.GetReturnValue().Set(Nan::True()); + + } else if (name->Equals(Nan::New("seal").ToLocalChecked())) { + handler->SetHiddenValue(Nan::New("sealed").ToLocalChecked(), Nan::True()); + handler->SetHiddenValue(Nan::New("extensible").ToLocalChecked(), Nan::False()); + info.GetReturnValue().Set(Nan::True()); + + } else if (name->Equals(Nan::New("preventExtensions").ToLocalChecked())) { + handler->SetHiddenValue(Nan::New("extensible").ToLocalChecked(), Nan::False()); + info.GetReturnValue().Set(Nan::True()); } } // Harmony Proxy handling of fix - Local fix = Local::Cast(handler->Get(NanNew("fix"))); + Local fix = Local::Cast(handler->Get(Nan::New("fix").ToLocalChecked())); #ifdef _WIN32 // On windows you get "error C2466: cannot allocate an array of constant size 0" and we use a pointer Local* argv; #else Local argv[0]; #endif - Local pieces = fix->Call(args[0]->ToObject(), 0, argv); + Local pieces = fix->Call(info[0]->ToObject(), 0, argv); if (pieces.IsEmpty() || !pieces->IsObject()) { - NanThrowTypeError("Cannot lock object."); + Nan::ThrowTypeError("Cannot lock object."); } Local parts = pieces->ToObject(); // set the appropriate parameters - if (name->Equals(NanNew("freeze"))) { - parts->SetHiddenValue(NanNew("frozen"), NanTrue()); - parts->SetHiddenValue(NanNew("sealed"), NanTrue()); - parts->SetHiddenValue(NanNew("extensible"), NanFalse()); + if (name->Equals(Nan::New("freeze"))) { + parts->SetHiddenValue(Nan::New("frozen"), Nan::True()); + parts->SetHiddenValue(Nan::New("sealed"), Nan::True()); + parts->SetHiddenValue(Nan::New("extensible"), Nan::False()); - } else if (name->Equals(NanNew("seal"))) { - parts->SetHiddenValue(NanNew("sealed"), NanTrue()); - parts->SetHiddenValue(NanNew("extensible"), NanFalse()); + } else if (name->Equals(Nan::New("seal"))) { + parts->SetHiddenValue(Nan::New("sealed"), Nan::True()); + parts->SetHiddenValue(Nan::New("extensible"), Nan::False()); - } else if (name->Equals(NanNew("preventExtensions"))) { - parts->SetHiddenValue(NanNew("extensible"), NanFalse()); + } else if (name->Equals(Nan::New("preventExtensions"))) { + parts->SetHiddenValue(Nan::New("extensible"), Nan::False()); } - parts->SetHiddenValue(NanNew("trapping"), NanFalse()); + parts->SetHiddenValue(Nan::New("trapping"), Nan::False()); // overwrite the handler, making handler available for GC obj->SetInternalField(0, parts); - NanReturnValue(NanTrue()); + info.GetReturnValue().Set(Nan::True()); } /** @@ -407,19 +400,18 @@ NAN_METHOD(NodeProxy::Freeze) { * @throws Error, TypeError */ NAN_METHOD(NodeProxy::IsLocked) { - NanScope(); - Local name = args.Callee()->GetName()->ToString(); + Local name = info.Callee()->GetName()->ToString(); - if (args.Length() < 1) { - NanThrowError(String::Concat(name, - NanNew(" requires at least one (1) argument."))); + if (info.Length() < 1) { + Nan::ThrowError(String::Concat(name, + Nan::New(" requires at least one (1) argument."))); } - Local arg = args[0]->ToObject(); + Local arg = info[0]->ToObject(); if (arg->InternalFieldCount() < 1) { - NanThrowTypeError( + Nan::ThrowTypeError( "Locking functions expect first argument " "to be intialized by Proxy"); } @@ -427,27 +419,27 @@ NAN_METHOD(NodeProxy::IsLocked) { Local hide = arg->GetInternalField(0); if (hide.IsEmpty() || !hide->IsObject()) { - NanThrowTypeError( + Nan::ThrowTypeError( "Locking functions expect first argument " "to be intialized by Proxy"); } Local obj = hide->ToObject(); - if (name->Equals(NanNew("isExtensible"))) { - NanReturnValue(obj->GetHiddenValue(NanNew("extensible"))->ToBoolean()); + if (name->Equals(Nan::New("isExtensible"))) { + info.GetReturnValue().Set(obj->GetHiddenValue(Nan::New("extensible"))->ToBoolean()); - } else if (name->Equals(NanNew("isSealed"))) { - NanReturnValue(obj->GetHiddenValue(NanNew("sealed"))->ToBoolean()); + } else if (name->Equals(Nan::New("isSealed"))) { + info.GetReturnValue().Set(obj->GetHiddenValue(Nan::New("sealed"))->ToBoolean()); - } else if (name->Equals(NanNew("isTrapping"))) { - NanReturnValue(obj->GetHiddenValue(NanNew("trapping"))->ToBoolean()); + } else if (name->Equals(Nan::New("isTrapping"))) { + info.GetReturnValue().Set(obj->GetHiddenValue(Nan::New("trapping"))->ToBoolean()); - } else if (name->Equals(NanNew("isFrozen"))) { - NanReturnValue(obj->GetHiddenValue(NanNew("frozen"))->ToBoolean()); + } else if (name->Equals(Nan::New("isFrozen"))) { + info.GetReturnValue().Set(obj->GetHiddenValue(Nan::New("frozen"))->ToBoolean()); } - NanReturnValue(NanFalse()); + info.GetReturnValue().Set(Nan::False()); } /** @@ -460,44 +452,43 @@ NAN_METHOD(NodeProxy::IsLocked) { * @throws Error, TypeError */ NAN_METHOD(NodeProxy::GetOwnPropertyDescriptor) { - NanScope(); - if (args.Length() < 2) { - NanThrowError("getOwnPropertyDescriptor requires " + if (info.Length() < 2) { + Nan::ThrowError("getOwnPropertyDescriptor requires " "at least two (2) arguments."); } - if (!args[1]->IsString() && !args[1]->IsNumber()) { - NanThrowTypeError("getOwnPropertyDescriptor requires " + if (!info[1]->IsString() && !info[1]->IsNumber()) { + Nan::ThrowTypeError("getOwnPropertyDescriptor requires " "the second argument to be a String or a Number."); } - Local obj = args[0]->ToObject(); - Local name = args[1]->ToString(); + Local obj = info[0]->ToObject(); + Local name = info[1]->ToString(); if (obj->InternalFieldCount() < 1) { - NanThrowTypeError("getOwnPropertyDescriptor expects " + Nan::ThrowTypeError("getOwnPropertyDescriptor expects " "first argument to be intialized by Proxy"); } Local temp = obj->GetInternalField(0); if (temp.IsEmpty() || !temp->IsObject()) { - NanThrowTypeError("getOwnPropertyDescriptor expects " + Nan::ThrowTypeError("getOwnPropertyDescriptor expects " "first argument to be intialized by Proxy"); } Local handler = temp->ToObject(); - if (!handler->GetHiddenValue(NanNew("trapping"))->BooleanValue()) { - NanReturnValue(handler->Get(name)); + if (!handler->GetHiddenValue(Nan::New("trapping"))->BooleanValue()) { + info.GetReturnValue().Set(handler->Get(name)); } Local getOwn = Local::Cast( - handler->Get(NanNew("getOwnPropertyDescriptor"))); + handler->Get(Nan::New("getOwnPropertyDescriptor"))); - Local argv[1] = {args[1]}; - NanReturnValue(getOwn->Call(obj, 1, argv)); + Local argv[1] = {info[1]}; + info.GetReturnValue().Set(getOwn->Call(obj, 1, argv)); } /** @@ -511,65 +502,64 @@ NAN_METHOD(NodeProxy::GetOwnPropertyDescriptor) { * @throws Error, TypeError */ NAN_METHOD(NodeProxy::DefineProperty) { - NanScope(); - if (args.Length() < 3) { - NanThrowError("defineProperty requires at least three (3) arguments."); + if (info.Length() < 3) { + Nan::ThrowError("defineProperty requires at least three (3) arguments."); } - if (!args[1]->IsString() && !args[1]->IsNumber()) { - NanThrowTypeError("defineProperty requires the " + if (!info[1]->IsString() && !info[1]->IsNumber()) { + Nan::ThrowTypeError("defineProperty requires the " "second argument to be a String or a Number."); } - if (!args[2]->IsObject()) { - NanThrowTypeError("defineProperty requires the third argument " + if (!info[2]->IsObject()) { + Nan::ThrowTypeError("defineProperty requires the third argument " "to be an Object of the type PropertyDescriptor."); } - Local obj = args[0]->ToObject(); + Local obj = info[0]->ToObject(); if (obj->InternalFieldCount() < 1) { - NanThrowTypeError("defineProperty expects first " + Nan::ThrowTypeError("defineProperty expects first " "argument to be intialized by Proxy"); } Local temp = obj->GetInternalField(0); if (temp.IsEmpty() || !temp->IsObject()) { - NanThrowTypeError("defineProperty expects first argument " + Nan::ThrowTypeError("defineProperty expects first argument " "to be intialized by Proxy"); } - Local name = args[1]->ToString(); + Local name = info[1]->ToString(); Local handler = temp->ToObject(); - if (handler->GetHiddenValue(NanNew("sealed"))->BooleanValue() || - !handler->Has(NanNew("defineProperty"))) { - NanReturnValue(NanFalse()); + if (handler->GetHiddenValue(Nan::New("sealed"))->BooleanValue() || + !handler->Has(Nan::New("defineProperty"))) { + info.GetReturnValue().Set(Nan::False()); } - if (!handler->GetHiddenValue(NanNew("extensible"))->BooleanValue() && + if (!handler->GetHiddenValue(Nan::New("extensible"))->BooleanValue() && !handler->Has(name)) { - NanReturnValue(NanFalse()); + info.GetReturnValue().Set(Nan::False()); } - if (!handler->GetHiddenValue(NanNew("trapping"))->BooleanValue()) { + if (!handler->GetHiddenValue(Nan::New("trapping"))->BooleanValue()) { Local desc = handler->Get(name)->ToObject(); - if (desc->Get(NanNew("configurable"))->BooleanValue()) { - NanReturnValue(NanNew( - handler->Set(name, args[2]->ToObject()))); + if (desc->Get(Nan::New("configurable"))->BooleanValue()) { + info.GetReturnValue().Set(Nan::New( + handler->Set(name, info[2]->ToObject()))); } - NanReturnValue(NanFalse()); + info.GetReturnValue().Set(Nan::False()); } Local def = Local::Cast( - handler->Get(NanNew("defineProperty"))); + handler->Get(Nan::New("defineProperty"))); - Local argv[2] = {args[1], args[2]->ToObject()}; + Local argv[2] = {info[1], info[2]->ToObject()}; - NanReturnValue(def->Call(obj, 2, argv)->ToBoolean()); + info.GetReturnValue().Set(def->Call(obj, 2, argv)->ToBoolean()); } /** @@ -582,40 +572,39 @@ NAN_METHOD(NodeProxy::DefineProperty) { * @throws Error, TypeError */ NAN_METHOD(NodeProxy::DefineProperties) { - NanScope(); - if (args.Length() < 2) { - NanThrowError("defineProperty requires at least three (3) arguments."); + if (info.Length() < 2) { + Nan::ThrowError("defineProperty requires at least three (3) arguments."); } - if (!args[1]->IsObject()) { - NanThrowTypeError("defineProperty requires the third argument " + if (!info[1]->IsObject()) { + Nan::ThrowTypeError("defineProperty requires the third argument " "to be an Object of the type PropertyDescriptor."); } - Local obj = args[0]->ToObject(); + Local obj = info[0]->ToObject(); if (obj->InternalFieldCount() < 1) { - NanThrowTypeError("defineProperty expects first " + Nan::ThrowTypeError("defineProperty expects first " "argument to be intialized by Proxy"); } Local temp = obj->GetInternalField(0); if (!temp.IsEmpty() && temp->IsObject()) { - Local props = args[1]->ToObject(); + Local props = info[1]->ToObject(); Local handler = temp->ToObject(); - if (handler->GetHiddenValue(NanNew("sealed"))->BooleanValue()) { - NanReturnValue(NanFalse()); + if (handler->GetHiddenValue(Nan::New("sealed"))->BooleanValue()) { + info.GetReturnValue().Set(Nan::False()); } bool extensible = handler->GetHiddenValue( - NanNew("extensible"))->BooleanValue(); + Nan::New("extensible"))->BooleanValue(); Local names = props->GetPropertyNames(); uint32_t i = 0, l = names->Length(); - if (!handler->GetHiddenValue(NanNew("trapping"))->BooleanValue()) { + if (!handler->GetHiddenValue(Nan::New("trapping"))->BooleanValue()) { for (;i < l; ++i) { Local name = names->CloneElementAt(i); @@ -624,25 +613,25 @@ NAN_METHOD(NodeProxy::DefineProperties) { ) { Local tempObj = handler->Get(name->ToString())->ToObject(); - if (tempObj->Get(NanNew("configurable"))->BooleanValue()) { + if (tempObj->Get(Nan::New("configurable"))->BooleanValue()) { if (!handler->Set(name->ToString(), props->Get(name->ToString()))) { - NanThrowError( + Nan::ThrowError( String::Concat( - NanNew("Unable to define property: "), + Nan::New("Unable to define property: "), name->ToString())); } } } else { - NanThrowError(String::Concat( - NanNew("Unable to define property: "), + Nan::ThrowError(String::Concat( + Nan::New("Unable to define property: "), name->ToString())); } } - NanReturnValue(NanTrue()); + info.GetReturnValue().Set(Nan::True()); } - Local def = Local::Cast(handler->Get(NanNew("defineProperty"))); + Local def = Local::Cast(handler->Get(Nan::New("defineProperty"))); TryCatch firstTry; for (;i < l; ++i) { @@ -654,13 +643,13 @@ NAN_METHOD(NodeProxy::DefineProperties) { def->Call(obj, 2, argv); if (firstTry.HasCaught()) { - NanReturnValue(firstTry.ReThrow()); + info.GetReturnValue().Set(firstTry.ReThrow()); } } } - NanReturnValue(NanTrue()); + info.GetReturnValue().Set(Nan::True()); } - NanReturnValue(NanFalse()); + info.GetReturnValue().Set(Nan::False()); } /** @@ -668,56 +657,55 @@ NAN_METHOD(NodeProxy::DefineProperties) { * handler of a Proxy created function * Calls the appropriate function attached when the Proxy was created * - * @param ...args + * @param ...info * @returns mixed * @throws Error */ NAN_METHOD(NodeProxy::New) { - NanScope(); - if (args.Callee()->InternalFieldCount() < 1 && args.Data().IsEmpty()) { - NanThrowTypeError("defineProperty expects first " + if (info.Callee()->InternalFieldCount() < 1 && info.Data().IsEmpty()) { + Nan::ThrowTypeError("defineProperty expects first " "argument to be intialized by Proxy"); } - Local info, ret, data = args.Holder()->GetInternalField(0); + Local info, ret, data = info.Holder()->GetInternalField(0); if (data.IsEmpty() || !data->IsObject()) { - NanThrowError("Invalid reference to Proxy#constructor"); + Nan::ThrowError("Invalid reference to Proxy#constructor"); } Local fn; Local obj = data->ToObject(); - if (args.IsConstructCall()) { - info = obj->GetHiddenValue(NanNew("constructorTrap")); + if (info.IsConstructCall()) { + info = obj->GetHiddenValue(Nan::New("constructorTrap")); if (!info.IsEmpty() && info->IsFunction()) { fn = Local::Cast(info); } else { fn = Local::Cast( - obj->GetHiddenValue(NanNew("callTrap"))); + obj->GetHiddenValue(Nan::New("callTrap"))); } } else { - fn = Local::Cast(obj->GetHiddenValue(NanNew("callTrap"))); + fn = Local::Cast(obj->GetHiddenValue(Nan::New("callTrap"))); } - int i = 0, l = args.Length(); + int i = 0, l = info.Length(); Local* argv = new Local[l]; for (; i < l; ++i) { - argv[i] = args[i]; + argv[i] = info[i]; } - ret = fn->Call(args.This(), args.Length(), argv); + ret = fn->Call(info.This(), info.Length(), argv); - if (args.IsConstructCall()) { + if (info.IsConstructCall()) { if (!ret.IsEmpty()) { - NanReturnValue(ret); + info.GetReturnValue().Set(ret); } - NanReturnValue(args.This()); + info.GetReturnValue().Set(info.This()); } - NanReturnValue(ret); + info.GetReturnValue().Set(ret); } /** @@ -727,20 +715,19 @@ NAN_METHOD(NodeProxy::New) { * */ NAN_PROPERTY_GETTER(NodeProxy::GetNamedProperty) { - NanScope(); - if (args.This()->InternalFieldCount() < 1 || args.Data().IsEmpty()) { - NanThrowTypeError("SetNamedProperty intercepted " + if (info.This()->InternalFieldCount() < 1 || info.Data().IsEmpty()) { + Nan::ThrowTypeError("SetNamedProperty intercepted " "by non-Proxy object"); } Local argv1[1] = {property}; - Local data = args.This()->InternalFieldCount() > 0 ? - args.This()->GetInternalField(0) : - args.Data(); + Local data = info.This()->InternalFieldCount() > 0 ? + info.This()->GetInternalField(0) : + info.Data(); if (!data->IsObject()) { - NanReturnUndefined(); + info.GetReturnValue().SetUndefined(); } Local fn; @@ -748,47 +735,47 @@ NAN_PROPERTY_GETTER(NodeProxy::GetNamedProperty) { // if the Proxy isn't trapping, return // the value set on the property descriptor - if (!handler->GetHiddenValue(NanNew("trapping"))->BooleanValue()) { - NanReturnValue(CallPropertyDescriptorGet(handler->Get(property), args.This(), argv1)); + if (!handler->GetHiddenValue(Nan::New("trapping"))->BooleanValue()) { + info.GetReturnValue().Set(CallPropertyDescriptorGet(handler->Get(property), info.This(), argv1)); } - Local get = handler->Get(NanNew("get")); + Local get = handler->Get(Nan::New("get")); if (get->IsFunction()) { fn = Local::Cast(get); - Local argv[2] = {args.This(), property}; + Local argv[2] = {info.This(), property}; - NanReturnValue(fn->Call(handler, 2, argv)); + info.GetReturnValue().Set(fn->Call(handler, 2, argv)); } - Local getPropertyDescriptor = handler->Get(NanNew("getPropertyDescriptor")); + Local getPropertyDescriptor = handler->Get(Nan::New("getPropertyDescriptor")); if (getPropertyDescriptor->IsFunction()) { fn = Local::Cast(getPropertyDescriptor); - NanReturnValue(CallPropertyDescriptorGet(fn->Call(handler, 1, argv1), args.This(), argv1)); + info.GetReturnValue().Set(CallPropertyDescriptorGet(fn->Call(handler, 1, argv1), info.This(), argv1)); } - Local getOwnPropertyDescriptor = handler->Get(NanNew("getOwnPropertyDescriptor")); + Local getOwnPropertyDescriptor = handler->Get(Nan::New("getOwnPropertyDescriptor")); if (getOwnPropertyDescriptor->IsFunction()) { fn = Local::Cast(getOwnPropertyDescriptor); - NanReturnValue(CallPropertyDescriptorGet(fn->Call(handler, 1, argv1), args.This(), argv1)); + info.GetReturnValue().Set(CallPropertyDescriptorGet(fn->Call(handler, 1, argv1), info.This(), argv1)); } - NanReturnUndefined(); // <-- silence warnings for 0.10.x + info.GetReturnValue().SetUndefined(); // <-- silence warnings for 0.10.x } -NAN_INLINE Local NodeProxy::CallPropertyDescriptorGet(Local descriptor, Handle context, Local args[1]) { +NAN_INLINE Local NodeProxy::CallPropertyDescriptorGet(Local descriptor, Handle context, Local info[1]) { if (descriptor->IsObject()) { - Local get = descriptor->ToObject()->Get(NanNew("get")); + Local get = descriptor->ToObject()->Get(Nan::New("get")); if (get->IsFunction()) { Local fn = Local::Cast(get); - return fn->Call(context, 1, args); + return fn->Call(context, 1, info); } - return descriptor->ToObject()->Get(NanNew("value")); + return descriptor->ToObject()->Get(Nan::New("value")); } - return NanNew(NanUndefined()); + return Nan::New(NanUndefined()); } /** @@ -798,108 +785,107 @@ NAN_INLINE Local NodeProxy::CallPropertyDescriptorGet(Local descri * */ NAN_PROPERTY_SETTER(NodeProxy::SetNamedProperty) { - NanScope(); - if (args.This()->InternalFieldCount() < 1 || args.Data().IsEmpty()) { - NanThrowTypeError("SetNamedProperty intercepted " + if (info.This()->InternalFieldCount() < 1 || info.Data().IsEmpty()) { + Nan::ThrowTypeError("SetNamedProperty intercepted " "by non-Proxy object"); } Local argv2[2] = {property, value}; - Local data = args.This()->InternalFieldCount() > 0 ? - args.This()->GetInternalField(0) : - args.Data(); + Local data = info.This()->InternalFieldCount() > 0 ? + info.This()->GetInternalField(0) : + info.Data(); if (!data->IsObject()) { - NanReturnUndefined(); + info.GetReturnValue().SetUndefined(); } Local handler = data->ToObject(); // if the Proxy isn't trapping, return the // value set on the property descriptor - if (!handler->GetHiddenValue(NanNew("trapping"))->BooleanValue()) { - if (handler->GetHiddenValue(NanNew("extensible"))->BooleanValue() || + if (!handler->GetHiddenValue(Nan::New("trapping"))->BooleanValue()) { + if (handler->GetHiddenValue(Nan::New("extensible"))->BooleanValue() || handler->Has(property) ) { Local pd = handler->Get(property); if (!pd->IsObject()) { - NanReturnUndefined(); + info.GetReturnValue().SetUndefined(); } Local pd_obj = pd->ToObject(); if (!pd_obj->GetHiddenValue( - NanNew("writable"))->BooleanValue() + Nan::New("writable"))->BooleanValue() ) { - NanThrowError( + Nan::ThrowError( String::Concat( - NanNew("In accessible property: "), + Nan::New("In accessible property: "), property)); } - Local set = pd_obj->Get(NanNew("set")); + Local set = pd_obj->Get(Nan::New("set")); if (set->IsFunction()) { Local fn = Local::Cast(set); - fn->Call(args.This(), 2, argv2); + fn->Call(info.This(), 2, argv2); - NanReturnValue(value); + info.GetReturnValue().Set(value); } - if (pd_obj->Set(NanNew("value"), value)) { - NanReturnValue(value); + if (pd_obj->Set(Nan::New("value"), value)) { + info.GetReturnValue().Set(value); } - NanReturnUndefined(); + info.GetReturnValue().SetUndefined(); } - NanReturnUndefined(); + info.GetReturnValue().SetUndefined(); } // does the ProxyHandler have a set method? - Local set = handler->Get(NanNew("set")); + Local set = handler->Get(Nan::New("set")); if (set->IsFunction()) { Local set_fn = Local::Cast(set); - Local argv3[3] = {args.This(), property, value}; + Local argv3[3] = {info.This(), property, value}; set_fn->Call(handler, 3, argv3); - NanReturnValue(value); + info.GetReturnValue().Set(value); } - Local getOwnPropertyDescriptor = handler->Get(NanNew("getOwnPropertyDescriptor")); + Local getOwnPropertyDescriptor = handler->Get(Nan::New("getOwnPropertyDescriptor")); if (getOwnPropertyDescriptor->IsFunction()) { Local gopd_fn = Local::Cast(getOwnPropertyDescriptor); Local argv[1] = {property}; - NanReturnValue(CallPropertyDescriptorSet(gopd_fn->Call(handler, 1, argv), args.This(), property, value)); + info.GetReturnValue().Set(CallPropertyDescriptorSet(gopd_fn->Call(handler, 1, argv), info.This(), property, value)); } - Local getPropertyDescriptor = handler->Get(NanNew("getPropertyDescriptor")); + Local getPropertyDescriptor = handler->Get(Nan::New("getPropertyDescriptor")); if (getPropertyDescriptor->IsFunction()) { Local gpd_fn = Local::Cast(getPropertyDescriptor); Local argv[1] = {property}; - NanReturnValue(CallPropertyDescriptorSet(gpd_fn->Call(handler, 1, argv), args.This(), property, value)); + info.GetReturnValue().Set(CallPropertyDescriptorSet(gpd_fn->Call(handler, 1, argv), info.This(), property, value)); } - NanReturnUndefined(); + info.GetReturnValue().SetUndefined(); } NAN_INLINE Local NodeProxy::CallPropertyDescriptorSet(Local descriptor, Handle context, Local name, Local value) { if (descriptor->IsObject()) { Local pd = descriptor->ToObject(); - Local set = pd->Get(NanNew("set")); + Local set = pd->Get(Nan::New("set")); if (set->IsFunction()) { Local fn = Local::Cast(set); - Local args[2] = { name, value }; - return fn->Call(context, 2, args); + Local info[2] = { name, value }; + return fn->Call(context, 2, info); - } else if (pd->Get(NanNew("writable"))->BooleanValue()) { - if (pd->Set(NanNew("value"), value)) { + } else if (pd->Get(Nan::New("writable"))->BooleanValue()) { + if (pd->Set(Nan::New("value"), value)) { return value; } } } - return NanNew(NanUndefined()); + return Nan::New(NanUndefined()); } @@ -910,78 +896,77 @@ NAN_INLINE Local NodeProxy::CallPropertyDescriptorSet(Local descri * */ NAN_PROPERTY_QUERY(NodeProxy::QueryNamedPropertyInteger) { - NanScope(); Local DoesntHavePropertyResponse; - Local HasPropertyResponse = NanNew(None); + Local HasPropertyResponse = Nan::New(None); - if (args.This()->InternalFieldCount() > 0 || !args.Data().IsEmpty()) { - Local data = args.This()->InternalFieldCount() > 0 ? - args.This()->GetInternalField(0) : - args.Data(); + if (info.This()->InternalFieldCount() > 0 || !info.Data().IsEmpty()) { + Local data = info.This()->InternalFieldCount() > 0 ? + info.This()->GetInternalField(0) : + info.Data(); if (!data->IsObject()) { - NanReturnValue(DoesntHavePropertyResponse); + info.GetReturnValue().Set(DoesntHavePropertyResponse); } Local handler = data->ToObject(); // if the Proxy isn't trapping, // return the value set on the property descriptor - if (!handler->GetHiddenValue(NanNew("trapping"))->BooleanValue()) { + if (!handler->GetHiddenValue(Nan::New("trapping"))->BooleanValue()) { if (handler->Has(property)) { Local pd = handler->Get(property); if (pd->IsObject()) { - NanReturnValue(GetPropertyAttributeFromPropertyDescriptor(pd->ToObject())); + info.GetReturnValue().Set(GetPropertyAttributeFromPropertyDescriptor(pd->ToObject())); } - NanReturnValue(HasPropertyResponse); + info.GetReturnValue().Set(HasPropertyResponse); } - NanReturnValue(DoesntHavePropertyResponse); + info.GetReturnValue().Set(DoesntHavePropertyResponse); } Local argv[1] = {property}; - Local hasOwn = handler->Get(NanNew("hasOwn")); + Local hasOwn = handler->Get(Nan::New("hasOwn")); if (hasOwn->IsFunction()) { Local hasOwn_fn = Local::Cast(hasOwn); - NanReturnValue(hasOwn_fn->Call(handler, 1, argv)->BooleanValue() ? + info.GetReturnValue().Set(hasOwn_fn->Call(handler, 1, argv)->BooleanValue() ? HasPropertyResponse : DoesntHavePropertyResponse); } - Local has = handler->Get(NanNew("has")); + Local has = handler->Get(Nan::New("has")); if (has->IsFunction()) { Local has_fn = Local::Cast(has); - NanReturnValue(has_fn->Call(handler, 1, argv)->BooleanValue() ? + info.GetReturnValue().Set(has_fn->Call(handler, 1, argv)->BooleanValue() ? HasPropertyResponse : DoesntHavePropertyResponse); } - Local getOwnPropertyDescriptor = handler->Get(NanNew("getOwnPropertyDescriptor")); + Local getOwnPropertyDescriptor = handler->Get(Nan::New("getOwnPropertyDescriptor")); if (getOwnPropertyDescriptor->IsFunction()) { Local gopd_fn = Local::Cast(getOwnPropertyDescriptor); Local gopd_pd = gopd_fn->Call(handler, 1, argv); if (gopd_pd->IsObject()) { - NanReturnValue(GetPropertyAttributeFromPropertyDescriptor(gopd_pd->ToObject())); + info.GetReturnValue().Set(GetPropertyAttributeFromPropertyDescriptor(gopd_pd->ToObject())); } } - Local getPropertyDescriptor = handler->Get(NanNew("getPropertyDescriptor")); - if (handler->Has(NanNew("getPropertyDescriptor"))) { + Local getPropertyDescriptor = handler->Get(Nan::New("getPropertyDescriptor")); + if (handler->Has(Nan::New("getPropertyDescriptor"))) { Local gpd_fn = Local::Cast(getPropertyDescriptor); Local gpd_pd = gpd_fn->Call(handler, 1, argv); if (gpd_pd->IsObject()) { - NanReturnValue(GetPropertyAttributeFromPropertyDescriptor(gpd_pd->ToObject())); + info.GetReturnValue().Set(GetPropertyAttributeFromPropertyDescriptor(gpd_pd->ToObject())); } else if (gpd_pd->IsUndefined()) { - NanReturnValue(DoesntHavePropertyResponse); + info.GetReturnValue().Set(DoesntHavePropertyResponse); } } } - NanReturnValue(DoesntHavePropertyResponse); + info.GetReturnValue().Set(DoesntHavePropertyResponse); } /** @@ -992,27 +977,26 @@ NAN_PROPERTY_QUERY(NodeProxy::QueryNamedPropertyInteger) { */ Handle NodeProxy::GetPropertyAttributeFromPropertyDescriptor(Local pd) { - NanScope(); uint32_t ret = None; - if (pd->Get(NanNew("configurable"))->IsBoolean() && - !pd->Get(NanNew("configurable"))->BooleanValue()) { + if (pd->Get(Nan::New("configurable"))->IsBoolean() && + !pd->Get(Nan::New("configurable"))->BooleanValue()) { ret &= DontDelete; } - if (pd->Get(NanNew("enumerable"))->IsBoolean() && - !pd->Get(NanNew("enumerable"))->BooleanValue()) { - // return NanNew(DontEnum); + if (pd->Get(Nan::New("enumerable"))->IsBoolean() && + !pd->Get(Nan::New("enumerable"))->BooleanValue()) { + // return Nan::New(DontEnum); ret &= DontEnum; } - if (pd->Get(NanNew("writable"))->IsBoolean() && - !pd->Get(NanNew("writable"))->BooleanValue()) { - // return NanNew(ReadOnly); + if (pd->Get(Nan::New("writable"))->IsBoolean() && + !pd->Get(Nan::New("writable"))->BooleanValue()) { + // return Nan::New(ReadOnly); ret &= ReadOnly; } - return NanNew(ret); + return Nan::New(ret); } /** @@ -1022,46 +1006,45 @@ NodeProxy::GetPropertyAttributeFromPropertyDescriptor(Local pd) { * */ NAN_PROPERTY_DELETER(NodeProxy::DeleteNamedProperty) { - NanScope(); - if (args.This()->InternalFieldCount() > 0 || !args.Data().IsEmpty()) { - Local data = args.This()->InternalFieldCount() > 0 ? - args.This()->GetInternalField(0) : - args.Data(); + if (info.This()->InternalFieldCount() > 0 || !info.Data().IsEmpty()) { + Local data = info.This()->InternalFieldCount() > 0 ? + info.This()->GetInternalField(0) : + info.Data(); if (!data->IsObject()) { - NanReturnValue(NanFalse()); + info.GetReturnValue().Set(Nan::False()); } Local handler = data->ToObject(); // if the Proxy isn't trapping, // return the value set on the property descriptor - if (!handler->GetHiddenValue(NanNew("trapping"))->BooleanValue()) { - if (!handler->GetHiddenValue(NanNew("frozen"))->BooleanValue()) { + if (!handler->GetHiddenValue(Nan::New("trapping"))->BooleanValue()) { + if (!handler->GetHiddenValue(Nan::New("frozen"))->BooleanValue()) { Local pd = handler->Get(property); if (pd->IsObject()) { Local pd_obj = pd->ToObject(); - if (pd_obj->Get(NanNew("configurable"))->IsBoolean() && - pd_obj->Get(NanNew("configurable"))->BooleanValue() + if (pd_obj->Get(Nan::New("configurable"))->IsBoolean() && + pd_obj->Get(Nan::New("configurable"))->BooleanValue() ) { - NanReturnValue(NanNew(handler->Delete(property))); + info.GetReturnValue().Set(Nan::New(handler->Delete(property))); } } } - NanReturnValue(NanFalse()); + info.GetReturnValue().Set(Nan::False()); } - Local delete_ = handler->Get(NanNew("delete")); + Local delete_ = handler->Get(Nan::New("delete")); if (delete_->IsFunction()) { Local fn = Local::Cast(delete_); Local argv[1] = {property}; - NanReturnValue(fn->Call(handler, 1, argv)->ToBoolean()); + info.GetReturnValue().Set(fn->Call(handler, 1, argv)->ToBoolean()); } } - NanReturnValue(NanFalse()); + info.GetReturnValue().Set(Nan::False()); } /** @@ -1071,15 +1054,14 @@ NAN_PROPERTY_DELETER(NodeProxy::DeleteNamedProperty) { * */ NAN_PROPERTY_ENUMERATOR(NodeProxy::EnumerateNamedProperties) { - NanScope(); - if (args.This()->InternalFieldCount() > 0 || !args.Data().IsEmpty()) { - Local data = args.This()->InternalFieldCount() > 0 ? - args.This()->GetInternalField(0) : - args.Data(); + if (info.This()->InternalFieldCount() > 0 || !info.Data().IsEmpty()) { + Local data = info.This()->InternalFieldCount() > 0 ? + info.This()->GetInternalField(0) : + info.Data(); if (!data->IsObject()) { - NanReturnValue(NanNew()); + info.GetReturnValue().Set(Nan::New()); } Local handler = data->ToObject(); @@ -1092,42 +1074,42 @@ NAN_PROPERTY_ENUMERATOR(NodeProxy::EnumerateNamedProperties) { // if the Proxy isn't trapping, // return the value set on the property descriptor - if (!handler->GetHiddenValue(NanNew("trapping"))->BooleanValue()) { - NanReturnValue(handler->GetPropertyNames()); + if (!handler->GetHiddenValue(Nan::New("trapping"))->BooleanValue()) { + info.GetReturnValue().Set(handler->GetPropertyNames()); } - Local enumerate = handler->Get(NanNew("enumerate")); + Local enumerate = handler->Get(Nan::New("enumerate")); if (enumerate->IsFunction()) { Local enumerate_fn = Local::Cast(enumerate); Local names = enumerate_fn->Call(handler, 0, argv); if (names->IsArray()) { - NanReturnValue(Local::Cast(names->ToObject())); + info.GetReturnValue().Set(Local::Cast(names->ToObject())); } } - Local keys = handler->Get(NanNew("keys")); + Local keys = handler->Get(Nan::New("keys")); if (keys->IsFunction()) { Local keys_fn = Local::Cast(enumerate); Local names = keys_fn->Call(handler, 0, argv); if (names->IsArray()) { - NanReturnValue(Local::Cast(names->ToObject())); + info.GetReturnValue().Set(Local::Cast(names->ToObject())); } } - Local getPropertyNames = handler->Get(NanNew("getPropertyNames")); + Local getPropertyNames = handler->Get(Nan::New("getPropertyNames")); if (getPropertyNames->IsFunction()) { Local gpn_fn = Local::Cast(getPropertyNames); Local names = gpn_fn->Call(handler, 0, argv); if (names->IsArray()) { - NanReturnValue(Local::Cast(names->ToObject())); + info.GetReturnValue().Set(Local::Cast(names->ToObject())); } } } - NanReturnValue(NanNew()); + info.GetReturnValue().Set(Nan::New()); } /** @@ -1137,21 +1119,20 @@ NAN_PROPERTY_ENUMERATOR(NodeProxy::EnumerateNamedProperties) { * */ NAN_INDEX_GETTER(NodeProxy::GetIndexedProperty) { - NanScope(); - if (args.This()->InternalFieldCount() < 1 || args.Data().IsEmpty()) { - NanThrowTypeError("SetNamedProperty intercepted " + if (info.This()->InternalFieldCount() < 1 || info.Data().IsEmpty()) { + Nan::ThrowTypeError("SetNamedProperty intercepted " "by non-Proxy object"); } - Local idx = NanNew(index); + Local idx = Nan::New(index); Local argv1[1] = {idx}; - Local data = args.This()->InternalFieldCount() > 0 ? - args.This()->GetInternalField(0) : - args.Data(); + Local data = info.This()->InternalFieldCount() > 0 ? + info.This()->GetInternalField(0) : + info.Data(); if (!data->IsObject()) { - NanReturnUndefined(); + info.GetReturnValue().SetUndefined(); } Local fn; @@ -1159,32 +1140,32 @@ NAN_INDEX_GETTER(NodeProxy::GetIndexedProperty) { // if the Proxy isn't trapping, return // the value set on the index descriptor - if (!handler->GetHiddenValue(NanNew("trapping"))->BooleanValue()) { - NanReturnValue(CallPropertyDescriptorGet(handler->Get(idx), args.This(), argv1)); + if (!handler->GetHiddenValue(Nan::New("trapping"))->BooleanValue()) { + info.GetReturnValue().Set(CallPropertyDescriptorGet(handler->Get(idx), info.This(), argv1)); } - Local get = handler->Get(NanNew("get")); + Local get = handler->Get(Nan::New("get")); if (get->IsFunction()) { fn = Local::Cast(get); - Local argv[2] = {args.This(), idx}; + Local argv[2] = {info.This(), idx}; - NanReturnValue(fn->Call(handler, 2, argv)); + info.GetReturnValue().Set(fn->Call(handler, 2, argv)); } - Local getPropertyDescriptor = handler->Get(NanNew("getPropertyDescriptor")); + Local getPropertyDescriptor = handler->Get(Nan::New("getPropertyDescriptor")); if (getPropertyDescriptor->IsFunction()) { fn = Local::Cast(getPropertyDescriptor); - NanReturnValue(CallPropertyDescriptorGet(fn->Call(handler, 1, argv1), args.This(), argv1)); + info.GetReturnValue().Set(CallPropertyDescriptorGet(fn->Call(handler, 1, argv1), info.This(), argv1)); } - Local getOwnPropertyDescriptor = handler->Get(NanNew("getOwnPropertyDescriptor")); + Local getOwnPropertyDescriptor = handler->Get(Nan::New("getOwnPropertyDescriptor")); if (getOwnPropertyDescriptor->IsFunction()) { fn = Local::Cast(getOwnPropertyDescriptor); - NanReturnValue(CallPropertyDescriptorGet(fn->Call(handler, 1, argv1), args.This(), argv1)); + info.GetReturnValue().Set(CallPropertyDescriptorGet(fn->Call(handler, 1, argv1), info.This(), argv1)); } - NanReturnUndefined(); // <-- silence warnings for 0.10.x + info.GetReturnValue().SetUndefined(); // <-- silence warnings for 0.10.x } /** @@ -1194,89 +1175,88 @@ NAN_INDEX_GETTER(NodeProxy::GetIndexedProperty) { * */ NAN_INDEX_SETTER(NodeProxy::SetIndexedProperty) { - NanScope(); - if (args.This()->InternalFieldCount() < 1 || args.Data().IsEmpty()) { - NanThrowTypeError("SetNamedProperty intercepted " + if (info.This()->InternalFieldCount() < 1 || info.Data().IsEmpty()) { + Nan::ThrowTypeError("SetNamedProperty intercepted " "by non-Proxy object"); } - Local idx = NanNew(index); + Local idx = Nan::New(index); Local argv2[2] = {idx, value}; - Local data = args.This()->InternalFieldCount() > 0 ? - args.This()->GetInternalField(0) : - args.Data(); + Local data = info.This()->InternalFieldCount() > 0 ? + info.This()->GetInternalField(0) : + info.Data(); if (!data->IsObject()) { - NanReturnUndefined(); + info.GetReturnValue().SetUndefined(); } Local handler = data->ToObject(); // if the Proxy isn't trapping, return the // value set on the index descriptor - if (!handler->GetHiddenValue(NanNew("trapping"))->BooleanValue()) { - if (handler->GetHiddenValue(NanNew("extensible"))->BooleanValue() || + if (!handler->GetHiddenValue(Nan::New("trapping"))->BooleanValue()) { + if (handler->GetHiddenValue(Nan::New("extensible"))->BooleanValue() || handler->Has(index) ) { Local pd = handler->Get(index); if (!pd->IsObject()) { - NanReturnUndefined(); + info.GetReturnValue().SetUndefined(); } Local pd_obj = pd->ToObject(); if (!pd_obj->GetHiddenValue( - NanNew("writable"))->BooleanValue() + Nan::New("writable"))->BooleanValue() ) { - NanThrowError( + Nan::ThrowError( String::Concat( - NanNew("In accessible index: "), + Nan::New("In accessible index: "), Local::Cast(idx))); } - Local set = pd_obj->Get(NanNew("set")); + Local set = pd_obj->Get(Nan::New("set")); if (set->IsFunction()) { Local fn = Local::Cast(set); - fn->Call(args.This(), 2, argv2); + fn->Call(info.This(), 2, argv2); - NanReturnValue(value); + info.GetReturnValue().Set(value); } - if (pd_obj->Set(NanNew("value"), value)) { - NanReturnValue(value); + if (pd_obj->Set(Nan::New("value"), value)) { + info.GetReturnValue().Set(value); } - NanReturnUndefined(); + info.GetReturnValue().SetUndefined(); } - NanReturnUndefined(); + info.GetReturnValue().SetUndefined(); } // does the ProxyHandler have a set method? - Local set = handler->Get(NanNew("set")); + Local set = handler->Get(Nan::New("set")); if (set->IsFunction()) { Local set_fn = Local::Cast(set); - Local argv3[3] = {args.This(), idx, value}; + Local argv3[3] = {info.This(), idx, value}; set_fn->Call(handler, 3, argv3); - NanReturnValue(value); + info.GetReturnValue().Set(value); } - Local getOwnPropertyDescriptor = handler->Get(NanNew("getOwnPropertyDescriptor")); + Local getOwnPropertyDescriptor = handler->Get(Nan::New("getOwnPropertyDescriptor")); if (getOwnPropertyDescriptor->IsFunction()) { Local gopd_fn = Local::Cast(getOwnPropertyDescriptor); Local argv[1] = {idx}; - NanReturnValue(CallPropertyDescriptorSet(gopd_fn->Call(handler, 1, argv), args.This(), idx, value)); + info.GetReturnValue().Set(CallPropertyDescriptorSet(gopd_fn->Call(handler, 1, argv), info.This(), idx, value)); } - Local getPropertyDescriptor = handler->Get(NanNew("getPropertyDescriptor")); + Local getPropertyDescriptor = handler->Get(Nan::New("getPropertyDescriptor")); if (getPropertyDescriptor->IsFunction()) { Local gpd_fn = Local::Cast(getPropertyDescriptor); Local argv[1] = {idx}; - NanReturnValue(CallPropertyDescriptorSet(gpd_fn->Call(handler, 1, argv), args.This(), idx, value)); + info.GetReturnValue().Set(CallPropertyDescriptorSet(gpd_fn->Call(handler, 1, argv), info.This(), idx, value)); } - NanReturnUndefined(); + info.GetReturnValue().SetUndefined(); } /** @@ -1286,79 +1266,78 @@ NAN_INDEX_SETTER(NodeProxy::SetIndexedProperty) { * */ NAN_INDEX_QUERY(NodeProxy::QueryIndexedPropertyInteger) { - NanScope(); - Local idx = NanNew(index); + Local idx = Nan::New(index); Local DoesntHavePropertyResponse; - Local HasPropertyResponse = NanNew(None); + Local HasPropertyResponse = Nan::New(None); - if (args.This()->InternalFieldCount() > 0 || !args.Data().IsEmpty()) { - Local data = args.This()->InternalFieldCount() > 0 ? - args.This()->GetInternalField(0) : - args.Data(); + if (info.This()->InternalFieldCount() > 0 || !info.Data().IsEmpty()) { + Local data = info.This()->InternalFieldCount() > 0 ? + info.This()->GetInternalField(0) : + info.Data(); if (!data->IsObject()) { - NanReturnValue(DoesntHavePropertyResponse); + info.GetReturnValue().Set(DoesntHavePropertyResponse); } Local handler = data->ToObject(); // if the Proxy isn't trapping, // return the value set on the property descriptor - if (!handler->GetHiddenValue(NanNew("trapping"))->BooleanValue()) { + if (!handler->GetHiddenValue(Nan::New("trapping"))->BooleanValue()) { if (handler->Has(index)) { Local pd = handler->Get(index); if (pd->IsObject()) { - NanReturnValue(GetPropertyAttributeFromPropertyDescriptor(pd->ToObject())); + info.GetReturnValue().Set(GetPropertyAttributeFromPropertyDescriptor(pd->ToObject())); } - NanReturnValue(HasPropertyResponse); + info.GetReturnValue().Set(HasPropertyResponse); } - NanReturnValue(DoesntHavePropertyResponse); + info.GetReturnValue().Set(DoesntHavePropertyResponse); } Local argv[1] = {idx}; - Local hasOwn = handler->Get(NanNew("hasOwn")); + Local hasOwn = handler->Get(Nan::New("hasOwn")); if (hasOwn->IsFunction()) { Local hasOwn_fn = Local::Cast(hasOwn); - NanReturnValue(hasOwn_fn->Call(handler, 1, argv)->BooleanValue() ? + info.GetReturnValue().Set(hasOwn_fn->Call(handler, 1, argv)->BooleanValue() ? HasPropertyResponse : DoesntHavePropertyResponse); } - Local has = handler->Get(NanNew("has")); + Local has = handler->Get(Nan::New("has")); if (has->IsFunction()) { Local has_fn = Local::Cast(has); - NanReturnValue(has_fn->Call(handler, 1, argv)->BooleanValue() ? + info.GetReturnValue().Set(has_fn->Call(handler, 1, argv)->BooleanValue() ? HasPropertyResponse : DoesntHavePropertyResponse); } - Local getOwnPropertyDescriptor = handler->Get(NanNew("getOwnPropertyDescriptor")); + Local getOwnPropertyDescriptor = handler->Get(Nan::New("getOwnPropertyDescriptor")); if (getOwnPropertyDescriptor->IsFunction()) { Local gopd_fn = Local::Cast(getOwnPropertyDescriptor); Local gopd_pd = gopd_fn->Call(handler, 1, argv); if (gopd_pd->IsObject()) { - NanReturnValue(GetPropertyAttributeFromPropertyDescriptor(gopd_pd->ToObject())); + info.GetReturnValue().Set(GetPropertyAttributeFromPropertyDescriptor(gopd_pd->ToObject())); } } - Local getPropertyDescriptor = handler->Get(NanNew("getPropertyDescriptor")); - if (handler->Has(NanNew("getPropertyDescriptor"))) { + Local getPropertyDescriptor = handler->Get(Nan::New("getPropertyDescriptor")); + if (handler->Has(Nan::New("getPropertyDescriptor"))) { Local gpd_fn = Local::Cast(getPropertyDescriptor); Local gpd_pd = gpd_fn->Call(handler, 1, argv); if (gpd_pd->IsObject()) { - NanReturnValue(GetPropertyAttributeFromPropertyDescriptor(gpd_pd->ToObject())); + info.GetReturnValue().Set(GetPropertyAttributeFromPropertyDescriptor(gpd_pd->ToObject())); } else if (gpd_pd->IsUndefined()) { - NanReturnValue(DoesntHavePropertyResponse); + info.GetReturnValue().Set(DoesntHavePropertyResponse); } } } - NanReturnValue(DoesntHavePropertyResponse); + info.GetReturnValue().Set(DoesntHavePropertyResponse); } /** @@ -1368,47 +1347,46 @@ NAN_INDEX_QUERY(NodeProxy::QueryIndexedPropertyInteger) { * */ NAN_INDEX_DELETER(NodeProxy::DeleteIndexedProperty) { - NanScope(); - if (args.This()->InternalFieldCount() > 0 || !args.Data().IsEmpty()) { - Local data = args.This()->InternalFieldCount() > 0 ? - args.This()->GetInternalField(0) : - args.Data(); + if (info.This()->InternalFieldCount() > 0 || !info.Data().IsEmpty()) { + Local data = info.This()->InternalFieldCount() > 0 ? + info.This()->GetInternalField(0) : + info.Data(); if (!data->IsObject()) { - NanReturnValue(NanFalse()); + info.GetReturnValue().Set(Nan::False()); } - Local idx = NanNew(index); + Local idx = Nan::New(index); Local handler = data->ToObject(); // if the Proxy isn't trapping, // return the value set on the property descriptor - if (!handler->GetHiddenValue(NanNew("trapping"))->BooleanValue()) { - if (!handler->GetHiddenValue(NanNew("frozen"))->BooleanValue()) { + if (!handler->GetHiddenValue(Nan::New("trapping"))->BooleanValue()) { + if (!handler->GetHiddenValue(Nan::New("frozen"))->BooleanValue()) { Local pd = handler->Get(idx); if (pd->IsObject()) { Local pd_obj = pd->ToObject(); - if (pd_obj->Get(NanNew("configurable"))->IsBoolean() && - pd_obj->Get(NanNew("configurable"))->BooleanValue() + if (pd_obj->Get(Nan::New("configurable"))->IsBoolean() && + pd_obj->Get(Nan::New("configurable"))->BooleanValue() ) { - NanReturnValue(NanNew(handler->Delete(index))); + info.GetReturnValue().Set(Nan::New(handler->Delete(index))); } } } - NanReturnValue(NanFalse()); + info.GetReturnValue().Set(Nan::False()); } - Local delete_ = handler->Get(NanNew("delete")); + Local delete_ = handler->Get(Nan::New("delete")); if (delete_->IsFunction()) { Local fn = Local::Cast(delete_); Local argv[1] = {idx}; - NanReturnValue(fn->Call(handler, 1, argv)->ToBoolean()); + info.GetReturnValue().Set(fn->Call(handler, 1, argv)->ToBoolean()); } } - NanReturnValue(NanNew(false)); + info.GetReturnValue().Set(Nan::New(false)); } /** @@ -1418,97 +1396,97 @@ NAN_INDEX_DELETER(NodeProxy::DeleteIndexedProperty) { * */ void NodeProxy::Init(Handle target) { - NanScope(); + Nan::HandleScope scope; // function creation // main functions - Local create = NanNew(Create)->GetFunction(); - Local _create = NanNew("create"); + Local create = Nan::New(Create)->GetFunction(); + Local _create = Nan::New("create"); create->SetName(_create); target->Set(_create, create); - Local createFunction = NanNew(CreateFunction)->GetFunction(); - Local _createFunction = NanNew("createFunction"); + Local createFunction = Nan::New(CreateFunction)->GetFunction(); + Local _createFunction = Nan::New("createFunction"); create->SetName(_createFunction); target->Set(_createFunction, createFunction); // freeze function assignment - Local freeze = NanNew(Freeze)->GetFunction(); - Local _freeze = NanNew("freeze"); + Local freeze = Nan::New(Freeze)->GetFunction(); + Local _freeze = Nan::New("freeze"); freeze->SetName(_freeze); target->Set(_freeze, freeze); - Local seal = NanNew(Freeze)->GetFunction(); - Local _seal = NanNew("seal"); + Local seal = Nan::New(Freeze)->GetFunction(); + Local _seal = Nan::New("seal"); seal->SetName(_seal); target->Set(_seal, seal); - Local prevent = NanNew(Freeze)->GetFunction(); - Local _preventExtensions = NanNew("preventExtensions"); + Local prevent = Nan::New(Freeze)->GetFunction(); + Local _preventExtensions = Nan::New("preventExtensions"); prevent->SetName(_preventExtensions); target->Set(_preventExtensions, prevent); // check function assignment - Local isfrozen = NanNew(IsLocked)->GetFunction(); - Local _isFrozen = NanNew("isFrozen"); + Local isfrozen = Nan::New(IsLocked)->GetFunction(); + Local _isFrozen = Nan::New("isFrozen"); isfrozen->SetName(_isFrozen); target->Set(_isFrozen, isfrozen); - Local issealed = NanNew(IsLocked)->GetFunction(); - Local _isSealed = NanNew("isSealed"); + Local issealed = Nan::New(IsLocked)->GetFunction(); + Local _isSealed = Nan::New("isSealed"); issealed->SetName(_isSealed); target->Set(_isSealed, issealed); - Local isextensible = NanNew(IsLocked)->GetFunction(); - Local _isExtensible = NanNew("isExtensible"); + Local isextensible = Nan::New(IsLocked)->GetFunction(); + Local _isExtensible = Nan::New("isExtensible"); isextensible->SetName(_isExtensible); target->Set(_isExtensible, isextensible); // part of harmony proxies - Local istrapping = NanNew(IsLocked)->GetFunction(); - Local _isTrapping = NanNew("isTrapping"); + Local istrapping = Nan::New(IsLocked)->GetFunction(); + Local _isTrapping = Nan::New("isTrapping"); istrapping->SetName(_isTrapping); target->Set(_isTrapping, istrapping); // ECMAScript 5 - Local getOwnPropertyDescriptor = NanNew(GetOwnPropertyDescriptor)->GetFunction(); - Local _getOwnPropertyDescriptor = NanNew("getOwnPropertyDescriptor"); + Local getOwnPropertyDescriptor = Nan::New(GetOwnPropertyDescriptor)->GetFunction(); + Local _getOwnPropertyDescriptor = Nan::New("getOwnPropertyDescriptor"); getOwnPropertyDescriptor->SetName(_getOwnPropertyDescriptor); target->Set(_getOwnPropertyDescriptor, getOwnPropertyDescriptor); - Local defineProperty = NanNew(DefineProperty)->GetFunction(); - Local _defineProperty = NanNew("defineProperty"); + Local defineProperty = Nan::New(DefineProperty)->GetFunction(); + Local _defineProperty = Nan::New("defineProperty"); defineProperty->SetName(_defineProperty); target->Set(_defineProperty, defineProperty); - Local defineProperties = NanNew(DefineProperties)->GetFunction(); - Local _defineProperties = NanNew("defineProperties"); + Local defineProperties = Nan::New(DefineProperties)->GetFunction(); + Local _defineProperties = Nan::New("defineProperties"); defineProperties->SetName(_defineProperties); target->Set(_defineProperties, defineProperties); // additional functions - Local clone = NanNew(Clone)->GetFunction(); - Local _clone = NanNew("clone"); + Local clone = Nan::New(Clone)->GetFunction(); + Local _clone = Nan::New("clone"); clone->SetName(_clone); target->Set(_clone, clone); - Local hidden = NanNew(Hidden)->GetFunction(); - Local _hidden = NanNew("hidden"); + Local hidden = Nan::New(Hidden)->GetFunction(); + Local _hidden = Nan::New("hidden"); hidden->SetName(_hidden); target->Set(_hidden, hidden); - Local setPrototype = NanNew(SetPrototype)->GetFunction(); - Local _setPrototype = NanNew("setPrototype"); + Local setPrototype = Nan::New(SetPrototype)->GetFunction(); + Local _setPrototype = Nan::New("setPrototype"); setPrototype->SetName(_setPrototype); target->Set(_setPrototype, setPrototype); - Local isProxy_ = NanNew(IsProxy)->GetFunction(); - Local _isProxy = NanNew("isProxy"); + Local isProxy_ = Nan::New(IsProxy)->GetFunction(); + Local _isProxy = Nan::New("isProxy"); hidden->SetName(_isProxy); target->Set(_isProxy, isProxy_); - Local temp = NanNew(); + Local temp = Nan::New(); temp->SetInternalFieldCount(1); @@ -1526,10 +1504,10 @@ void NodeProxy::Init(Handle target) { QueryIndexedPropertyInteger, DeleteIndexedProperty); - Local _objectCreator = NanNew(temp); + Local _objectCreator = Nan::New(temp); NanAssignPersistent(ObjectCreator, _objectCreator); - Local instance = NanNew(); + Local instance = Nan::New(); instance->SetCallAsFunctionHandler(NodeProxy::New); instance->SetInternalFieldCount(1); From 400eb0e5ba23a360adb5dd8ba0bd02d7eff421a7 Mon Sep 17 00:00:00 2001 From: unbornchikken Date: Wed, 26 Aug 2015 22:57:35 +0200 Subject: [PATCH 2/8] almost ok --- src/node-proxy.cc | 308 ++++++++++++++++++++++++---------------------- src/node-proxy.h | 4 +- 2 files changed, 161 insertions(+), 151 deletions(-) diff --git a/src/node-proxy.cc b/src/node-proxy.cc index 66ab655..d90feeb 100644 --- a/src/node-proxy.cc +++ b/src/node-proxy.cc @@ -32,8 +32,8 @@ #include "./node-proxy.h" -Persistent NodeProxy::ObjectCreator; -Persistent NodeProxy::FunctionCreator; +Nan::Persistent NodeProxy::ObjectCreator; +Nan::Persistent NodeProxy::FunctionCreator; /** * @@ -336,7 +336,7 @@ NAN_METHOD(NodeProxy::Freeze) { // if this object is not trapping, just set the appropriate parameters if (!handler->GetHiddenValue(Nan::New("trapping").ToLocalChecked())->BooleanValue()) { - if (name->Equals(Nan::New("freeze"))) { + if (name->Equals(Nan::New("freeze").ToLocalChecked())) { handler->SetHiddenValue(Nan::New("frozen").ToLocalChecked(), Nan::True()); handler->SetHiddenValue(Nan::New("sealed").ToLocalChecked(), Nan::True()); handler->SetHiddenValue(Nan::New("extensible").ToLocalChecked(), Nan::False()); @@ -370,20 +370,20 @@ NAN_METHOD(NodeProxy::Freeze) { Local parts = pieces->ToObject(); // set the appropriate parameters - if (name->Equals(Nan::New("freeze"))) { - parts->SetHiddenValue(Nan::New("frozen"), Nan::True()); - parts->SetHiddenValue(Nan::New("sealed"), Nan::True()); - parts->SetHiddenValue(Nan::New("extensible"), Nan::False()); + if (name->Equals(Nan::New("freeze").ToLocalChecked())) { + parts->SetHiddenValue(Nan::New("frozen").ToLocalChecked(), Nan::True()); + parts->SetHiddenValue(Nan::New("sealed").ToLocalChecked(), Nan::True()); + parts->SetHiddenValue(Nan::New("extensible").ToLocalChecked(), Nan::False()); - } else if (name->Equals(Nan::New("seal"))) { - parts->SetHiddenValue(Nan::New("sealed"), Nan::True()); - parts->SetHiddenValue(Nan::New("extensible"), Nan::False()); + } else if (name->Equals(Nan::New("seal").ToLocalChecked())) { + parts->SetHiddenValue(Nan::New("sealed").ToLocalChecked(), Nan::True()); + parts->SetHiddenValue(Nan::New("extensible").ToLocalChecked(), Nan::False()); - } else if (name->Equals(Nan::New("preventExtensions"))) { - parts->SetHiddenValue(Nan::New("extensible"), Nan::False()); + } else if (name->Equals(Nan::New("preventExtensions").ToLocalChecked())) { + parts->SetHiddenValue(Nan::New("extensible").ToLocalChecked(), Nan::False()); } - parts->SetHiddenValue(Nan::New("trapping"), Nan::False()); + parts->SetHiddenValue(Nan::New("trapping").ToLocalChecked(), Nan::False()); // overwrite the handler, making handler available for GC obj->SetInternalField(0, parts); @@ -405,7 +405,7 @@ NAN_METHOD(NodeProxy::IsLocked) { if (info.Length() < 1) { Nan::ThrowError(String::Concat(name, - Nan::New(" requires at least one (1) argument."))); + Nan::New(" requires at least one (1) argument.").ToLocalChecked())); } Local arg = info[0]->ToObject(); @@ -426,17 +426,17 @@ NAN_METHOD(NodeProxy::IsLocked) { Local obj = hide->ToObject(); - if (name->Equals(Nan::New("isExtensible"))) { - info.GetReturnValue().Set(obj->GetHiddenValue(Nan::New("extensible"))->ToBoolean()); + if (name->Equals(Nan::New("isExtensible").ToLocalChecked())) { + info.GetReturnValue().Set(obj->GetHiddenValue(Nan::New("extensible").ToLocalChecked())->ToBoolean()); - } else if (name->Equals(Nan::New("isSealed"))) { - info.GetReturnValue().Set(obj->GetHiddenValue(Nan::New("sealed"))->ToBoolean()); + } else if (name->Equals(Nan::New("isSealed").ToLocalChecked())) { + info.GetReturnValue().Set(obj->GetHiddenValue(Nan::New("sealed").ToLocalChecked())->ToBoolean()); - } else if (name->Equals(Nan::New("isTrapping"))) { - info.GetReturnValue().Set(obj->GetHiddenValue(Nan::New("trapping"))->ToBoolean()); + } else if (name->Equals(Nan::New("isTrapping").ToLocalChecked())) { + info.GetReturnValue().Set(obj->GetHiddenValue(Nan::New("trapping").ToLocalChecked())->ToBoolean()); - } else if (name->Equals(Nan::New("isFrozen"))) { - info.GetReturnValue().Set(obj->GetHiddenValue(Nan::New("frozen"))->ToBoolean()); + } else if (name->Equals(Nan::New("isFrozen").ToLocalChecked())) { + info.GetReturnValue().Set(obj->GetHiddenValue(Nan::New("frozen").ToLocalChecked())->ToBoolean()); } info.GetReturnValue().Set(Nan::False()); @@ -480,12 +480,12 @@ NAN_METHOD(NodeProxy::GetOwnPropertyDescriptor) { Local handler = temp->ToObject(); - if (!handler->GetHiddenValue(Nan::New("trapping"))->BooleanValue()) { + if (!handler->GetHiddenValue(Nan::New("trapping").ToLocalChecked())->BooleanValue()) { info.GetReturnValue().Set(handler->Get(name)); } Local getOwn = Local::Cast( - handler->Get(Nan::New("getOwnPropertyDescriptor"))); + handler->Get(Nan::New("getOwnPropertyDescriptor").ToLocalChecked())); Local argv[1] = {info[1]}; info.GetReturnValue().Set(getOwn->Call(obj, 1, argv)); @@ -534,20 +534,20 @@ NAN_METHOD(NodeProxy::DefineProperty) { Local name = info[1]->ToString(); Local handler = temp->ToObject(); - if (handler->GetHiddenValue(Nan::New("sealed"))->BooleanValue() || - !handler->Has(Nan::New("defineProperty"))) { + if (handler->GetHiddenValue(Nan::New("sealed").ToLocalChecked())->BooleanValue() || + !handler->Has(Nan::New("defineProperty").ToLocalChecked())) { info.GetReturnValue().Set(Nan::False()); } - if (!handler->GetHiddenValue(Nan::New("extensible"))->BooleanValue() && + if (!handler->GetHiddenValue(Nan::New("extensible").ToLocalChecked())->BooleanValue() && !handler->Has(name)) { info.GetReturnValue().Set(Nan::False()); } - if (!handler->GetHiddenValue(Nan::New("trapping"))->BooleanValue()) { + if (!handler->GetHiddenValue(Nan::New("trapping").ToLocalChecked())->BooleanValue()) { Local desc = handler->Get(name)->ToObject(); - if (desc->Get(Nan::New("configurable"))->BooleanValue()) { + if (desc->Get(Nan::New("configurable").ToLocalChecked())->BooleanValue()) { info.GetReturnValue().Set(Nan::New( handler->Set(name, info[2]->ToObject()))); } @@ -555,7 +555,7 @@ NAN_METHOD(NodeProxy::DefineProperty) { } Local def = Local::Cast( - handler->Get(Nan::New("defineProperty"))); + handler->Get(Nan::New("defineProperty").ToLocalChecked())); Local argv[2] = {info[1], info[2]->ToObject()}; @@ -595,16 +595,16 @@ NAN_METHOD(NodeProxy::DefineProperties) { Local props = info[1]->ToObject(); Local handler = temp->ToObject(); - if (handler->GetHiddenValue(Nan::New("sealed"))->BooleanValue()) { + if (handler->GetHiddenValue(Nan::New("sealed").ToLocalChecked())->BooleanValue()) { info.GetReturnValue().Set(Nan::False()); } bool extensible = handler->GetHiddenValue( - Nan::New("extensible"))->BooleanValue(); + Nan::New("extensible").ToLocalChecked())->BooleanValue(); Local names = props->GetPropertyNames(); uint32_t i = 0, l = names->Length(); - if (!handler->GetHiddenValue(Nan::New("trapping"))->BooleanValue()) { + if (!handler->GetHiddenValue(Nan::New("trapping").ToLocalChecked())->BooleanValue()) { for (;i < l; ++i) { Local name = names->CloneElementAt(i); @@ -613,25 +613,25 @@ NAN_METHOD(NodeProxy::DefineProperties) { ) { Local tempObj = handler->Get(name->ToString())->ToObject(); - if (tempObj->Get(Nan::New("configurable"))->BooleanValue()) { + if (tempObj->Get(Nan::New("configurable").ToLocalChecked())->BooleanValue()) { if (!handler->Set(name->ToString(), props->Get(name->ToString()))) { Nan::ThrowError( String::Concat( - Nan::New("Unable to define property: "), + Nan::New("Unable to define property: ").ToLocalChecked(), name->ToString())); } } } else { Nan::ThrowError(String::Concat( - Nan::New("Unable to define property: "), + Nan::New("Unable to define property: ").ToLocalChecked(), name->ToString())); } } info.GetReturnValue().Set(Nan::True()); } - Local def = Local::Cast(handler->Get(Nan::New("defineProperty"))); + Local def = Local::Cast(handler->Get(Nan::New("defineProperty").ToLocalChecked())); TryCatch firstTry; for (;i < l; ++i) { @@ -668,7 +668,7 @@ NAN_METHOD(NodeProxy::New) { "argument to be intialized by Proxy"); } - Local info, ret, data = info.Holder()->GetInternalField(0); + Local v, ret, data = info.Holder()->GetInternalField(0); if (data.IsEmpty() || !data->IsObject()) { Nan::ThrowError("Invalid reference to Proxy#constructor"); @@ -678,16 +678,16 @@ NAN_METHOD(NodeProxy::New) { Local obj = data->ToObject(); if (info.IsConstructCall()) { - info = obj->GetHiddenValue(Nan::New("constructorTrap")); + v = obj->GetHiddenValue(Nan::New("constructorTrap").ToLocalChecked()); - if (!info.IsEmpty() && info->IsFunction()) { - fn = Local::Cast(info); + if (!v.IsEmpty() && v->IsFunction()) { + fn = Local::Cast(v); } else { fn = Local::Cast( - obj->GetHiddenValue(Nan::New("callTrap"))); + obj->GetHiddenValue(Nan::New("callTrap").ToLocalChecked())); } } else { - fn = Local::Cast(obj->GetHiddenValue(Nan::New("callTrap"))); + fn = Local::Cast(obj->GetHiddenValue(Nan::New("callTrap").ToLocalChecked())); } int i = 0, l = info.Length(); @@ -702,8 +702,10 @@ NAN_METHOD(NodeProxy::New) { if (info.IsConstructCall()) { if (!ret.IsEmpty()) { info.GetReturnValue().Set(ret); + return; } info.GetReturnValue().Set(info.This()); + return; } info.GetReturnValue().Set(ret); } @@ -735,11 +737,11 @@ NAN_PROPERTY_GETTER(NodeProxy::GetNamedProperty) { // if the Proxy isn't trapping, return // the value set on the property descriptor - if (!handler->GetHiddenValue(Nan::New("trapping"))->BooleanValue()) { + if (!handler->GetHiddenValue(Nan::New("trapping").ToLocalChecked())->BooleanValue()) { info.GetReturnValue().Set(CallPropertyDescriptorGet(handler->Get(property), info.This(), argv1)); } - Local get = handler->Get(Nan::New("get")); + Local get = handler->Get(Nan::New("get").ToLocalChecked()); if (get->IsFunction()) { fn = Local::Cast(get); Local argv[2] = {info.This(), property}; @@ -747,14 +749,14 @@ NAN_PROPERTY_GETTER(NodeProxy::GetNamedProperty) { info.GetReturnValue().Set(fn->Call(handler, 2, argv)); } - Local getPropertyDescriptor = handler->Get(Nan::New("getPropertyDescriptor")); + Local getPropertyDescriptor = handler->Get(Nan::New("getPropertyDescriptor").ToLocalChecked()); if (getPropertyDescriptor->IsFunction()) { fn = Local::Cast(getPropertyDescriptor); info.GetReturnValue().Set(CallPropertyDescriptorGet(fn->Call(handler, 1, argv1), info.This(), argv1)); } - Local getOwnPropertyDescriptor = handler->Get(Nan::New("getOwnPropertyDescriptor")); + Local getOwnPropertyDescriptor = handler->Get(Nan::New("getOwnPropertyDescriptor").ToLocalChecked()); if (getOwnPropertyDescriptor->IsFunction()) { fn = Local::Cast(getOwnPropertyDescriptor); @@ -764,18 +766,19 @@ NAN_PROPERTY_GETTER(NodeProxy::GetNamedProperty) { } NAN_INLINE Local NodeProxy::CallPropertyDescriptorGet(Local descriptor, Handle context, Local info[1]) { + Nan::EscapableHandleScope scope; if (descriptor->IsObject()) { - Local get = descriptor->ToObject()->Get(Nan::New("get")); + Local get = descriptor->ToObject()->Get(Nan::New("get").ToLocalChecked()); if (get->IsFunction()) { Local fn = Local::Cast(get); return fn->Call(context, 1, info); } - return descriptor->ToObject()->Get(Nan::New("value")); + return descriptor->ToObject()->Get(Nan::New("value").ToLocalChecked()); } - return Nan::New(NanUndefined()); + return scope.Escape(Nan::Undefined()); } /** @@ -804,8 +807,8 @@ NAN_PROPERTY_SETTER(NodeProxy::SetNamedProperty) { // if the Proxy isn't trapping, return the // value set on the property descriptor - if (!handler->GetHiddenValue(Nan::New("trapping"))->BooleanValue()) { - if (handler->GetHiddenValue(Nan::New("extensible"))->BooleanValue() || + if (!handler->GetHiddenValue(Nan::New("trapping").ToLocalChecked())->BooleanValue()) { + if (handler->GetHiddenValue(Nan::New("extensible").ToLocalChecked())->BooleanValue() || handler->Has(property) ) { Local pd = handler->Get(property); @@ -817,15 +820,15 @@ NAN_PROPERTY_SETTER(NodeProxy::SetNamedProperty) { Local pd_obj = pd->ToObject(); if (!pd_obj->GetHiddenValue( - Nan::New("writable"))->BooleanValue() + Nan::New("writable").ToLocalChecked())->BooleanValue() ) { Nan::ThrowError( String::Concat( - Nan::New("In accessible property: "), + Nan::New("In accessible property: ").ToLocalChecked(), property)); } - Local set = pd_obj->Get(Nan::New("set")); + Local set = pd_obj->Get(Nan::New("set").ToLocalChecked()); if (set->IsFunction()) { Local fn = Local::Cast(set); fn->Call(info.This(), 2, argv2); @@ -833,7 +836,7 @@ NAN_PROPERTY_SETTER(NodeProxy::SetNamedProperty) { info.GetReturnValue().Set(value); } - if (pd_obj->Set(Nan::New("value"), value)) { + if (pd_obj->Set(Nan::New("value").ToLocalChecked(), value)) { info.GetReturnValue().Set(value); } info.GetReturnValue().SetUndefined(); @@ -842,7 +845,7 @@ NAN_PROPERTY_SETTER(NodeProxy::SetNamedProperty) { } // does the ProxyHandler have a set method? - Local set = handler->Get(Nan::New("set")); + Local set = handler->Get(Nan::New("set").ToLocalChecked()); if (set->IsFunction()) { Local set_fn = Local::Cast(set); Local argv3[3] = {info.This(), property, value}; @@ -851,14 +854,14 @@ NAN_PROPERTY_SETTER(NodeProxy::SetNamedProperty) { info.GetReturnValue().Set(value); } - Local getOwnPropertyDescriptor = handler->Get(Nan::New("getOwnPropertyDescriptor")); + Local getOwnPropertyDescriptor = handler->Get(Nan::New("getOwnPropertyDescriptor").ToLocalChecked()); if (getOwnPropertyDescriptor->IsFunction()) { Local gopd_fn = Local::Cast(getOwnPropertyDescriptor); Local argv[1] = {property}; info.GetReturnValue().Set(CallPropertyDescriptorSet(gopd_fn->Call(handler, 1, argv), info.This(), property, value)); } - Local getPropertyDescriptor = handler->Get(Nan::New("getPropertyDescriptor")); + Local getPropertyDescriptor = handler->Get(Nan::New("getPropertyDescriptor").ToLocalChecked()); if (getPropertyDescriptor->IsFunction()) { Local gpd_fn = Local::Cast(getPropertyDescriptor); Local argv[1] = {property}; @@ -869,23 +872,24 @@ NAN_PROPERTY_SETTER(NodeProxy::SetNamedProperty) { } NAN_INLINE Local NodeProxy::CallPropertyDescriptorSet(Local descriptor, Handle context, Local name, Local value) { + Nan::EscapableHandleScope scope; if (descriptor->IsObject()) { Local pd = descriptor->ToObject(); - Local set = pd->Get(Nan::New("set")); + Local set = pd->Get(Nan::New("set").ToLocalChecked()); if (set->IsFunction()) { Local fn = Local::Cast(set); Local info[2] = { name, value }; return fn->Call(context, 2, info); - } else if (pd->Get(Nan::New("writable"))->BooleanValue()) { - if (pd->Set(Nan::New("value"), value)) { + } else if (pd->Get(Nan::New("writable").ToLocalChecked())->BooleanValue()) { + if (pd->Set(Nan::New("value").ToLocalChecked(), value)) { return value; } } } - return Nan::New(NanUndefined()); + return scope.Escape(Nan::Undefined()); } @@ -913,7 +917,7 @@ NAN_PROPERTY_QUERY(NodeProxy::QueryNamedPropertyInteger) { // if the Proxy isn't trapping, // return the value set on the property descriptor - if (!handler->GetHiddenValue(Nan::New("trapping"))->BooleanValue()) { + if (!handler->GetHiddenValue(Nan::New("trapping").ToLocalChecked())->BooleanValue()) { if (handler->Has(property)) { Local pd = handler->Get(property); @@ -927,7 +931,7 @@ NAN_PROPERTY_QUERY(NodeProxy::QueryNamedPropertyInteger) { Local argv[1] = {property}; - Local hasOwn = handler->Get(Nan::New("hasOwn")); + Local hasOwn = handler->Get(Nan::New("hasOwn").ToLocalChecked()); if (hasOwn->IsFunction()) { Local hasOwn_fn = Local::Cast(hasOwn); info.GetReturnValue().Set(hasOwn_fn->Call(handler, 1, argv)->BooleanValue() ? @@ -935,7 +939,7 @@ NAN_PROPERTY_QUERY(NodeProxy::QueryNamedPropertyInteger) { DoesntHavePropertyResponse); } - Local has = handler->Get(Nan::New("has")); + Local has = handler->Get(Nan::New("has").ToLocalChecked()); if (has->IsFunction()) { Local has_fn = Local::Cast(has); info.GetReturnValue().Set(has_fn->Call(handler, 1, argv)->BooleanValue() ? @@ -943,7 +947,7 @@ NAN_PROPERTY_QUERY(NodeProxy::QueryNamedPropertyInteger) { DoesntHavePropertyResponse); } - Local getOwnPropertyDescriptor = handler->Get(Nan::New("getOwnPropertyDescriptor")); + Local getOwnPropertyDescriptor = handler->Get(Nan::New("getOwnPropertyDescriptor").ToLocalChecked()); if (getOwnPropertyDescriptor->IsFunction()) { Local gopd_fn = Local::Cast(getOwnPropertyDescriptor); Local gopd_pd = gopd_fn->Call(handler, 1, argv); @@ -953,8 +957,8 @@ NAN_PROPERTY_QUERY(NodeProxy::QueryNamedPropertyInteger) { } } - Local getPropertyDescriptor = handler->Get(Nan::New("getPropertyDescriptor")); - if (handler->Has(Nan::New("getPropertyDescriptor"))) { + Local getPropertyDescriptor = handler->Get(Nan::New("getPropertyDescriptor").ToLocalChecked()); + if (handler->Has(Nan::New("getPropertyDescriptor").ToLocalChecked())) { Local gpd_fn = Local::Cast(getPropertyDescriptor); Local gpd_pd = gpd_fn->Call(handler, 1, argv); @@ -979,19 +983,19 @@ Handle NodeProxy::GetPropertyAttributeFromPropertyDescriptor(Local pd) { uint32_t ret = None; - if (pd->Get(Nan::New("configurable"))->IsBoolean() && - !pd->Get(Nan::New("configurable"))->BooleanValue()) { + if (pd->Get(Nan::New("configurable").ToLocalChecked())->IsBoolean() && + !pd->Get(Nan::New("configurable").ToLocalChecked())->BooleanValue()) { ret &= DontDelete; } - if (pd->Get(Nan::New("enumerable"))->IsBoolean() && - !pd->Get(Nan::New("enumerable"))->BooleanValue()) { + if (pd->Get(Nan::New("enumerable").ToLocalChecked())->IsBoolean() && + !pd->Get(Nan::New("enumerable").ToLocalChecked())->BooleanValue()) { // return Nan::New(DontEnum); ret &= DontEnum; } - if (pd->Get(Nan::New("writable"))->IsBoolean() && - !pd->Get(Nan::New("writable"))->BooleanValue()) { + if (pd->Get(Nan::New("writable").ToLocalChecked())->IsBoolean() && + !pd->Get(Nan::New("writable").ToLocalChecked())->BooleanValue()) { // return Nan::New(ReadOnly); ret &= ReadOnly; } @@ -1019,15 +1023,15 @@ NAN_PROPERTY_DELETER(NodeProxy::DeleteNamedProperty) { Local handler = data->ToObject(); // if the Proxy isn't trapping, // return the value set on the property descriptor - if (!handler->GetHiddenValue(Nan::New("trapping"))->BooleanValue()) { - if (!handler->GetHiddenValue(Nan::New("frozen"))->BooleanValue()) { + if (!handler->GetHiddenValue(Nan::New("trapping").ToLocalChecked())->BooleanValue()) { + if (!handler->GetHiddenValue(Nan::New("frozen").ToLocalChecked())->BooleanValue()) { Local pd = handler->Get(property); if (pd->IsObject()) { Local pd_obj = pd->ToObject(); - if (pd_obj->Get(Nan::New("configurable"))->IsBoolean() && - pd_obj->Get(Nan::New("configurable"))->BooleanValue() + if (pd_obj->Get(Nan::New("configurable").ToLocalChecked())->IsBoolean() && + pd_obj->Get(Nan::New("configurable").ToLocalChecked())->BooleanValue() ) { info.GetReturnValue().Set(Nan::New(handler->Delete(property))); } @@ -1036,7 +1040,7 @@ NAN_PROPERTY_DELETER(NodeProxy::DeleteNamedProperty) { info.GetReturnValue().Set(Nan::False()); } - Local delete_ = handler->Get(Nan::New("delete")); + Local delete_ = handler->Get(Nan::New("delete").ToLocalChecked()); if (delete_->IsFunction()) { Local fn = Local::Cast(delete_); Local argv[1] = {property}; @@ -1074,11 +1078,11 @@ NAN_PROPERTY_ENUMERATOR(NodeProxy::EnumerateNamedProperties) { // if the Proxy isn't trapping, // return the value set on the property descriptor - if (!handler->GetHiddenValue(Nan::New("trapping"))->BooleanValue()) { + if (!handler->GetHiddenValue(Nan::New("trapping").ToLocalChecked())->BooleanValue()) { info.GetReturnValue().Set(handler->GetPropertyNames()); } - Local enumerate = handler->Get(Nan::New("enumerate")); + Local enumerate = handler->Get(Nan::New("enumerate").ToLocalChecked()); if (enumerate->IsFunction()) { Local enumerate_fn = Local::Cast(enumerate); Local names = enumerate_fn->Call(handler, 0, argv); @@ -1088,7 +1092,7 @@ NAN_PROPERTY_ENUMERATOR(NodeProxy::EnumerateNamedProperties) { } } - Local keys = handler->Get(Nan::New("keys")); + Local keys = handler->Get(Nan::New("keys").ToLocalChecked()); if (keys->IsFunction()) { Local keys_fn = Local::Cast(enumerate); Local names = keys_fn->Call(handler, 0, argv); @@ -1098,7 +1102,7 @@ NAN_PROPERTY_ENUMERATOR(NodeProxy::EnumerateNamedProperties) { } } - Local getPropertyNames = handler->Get(Nan::New("getPropertyNames")); + Local getPropertyNames = handler->Get(Nan::New("getPropertyNames").ToLocalChecked()); if (getPropertyNames->IsFunction()) { Local gpn_fn = Local::Cast(getPropertyNames); Local names = gpn_fn->Call(handler, 0, argv); @@ -1140,11 +1144,11 @@ NAN_INDEX_GETTER(NodeProxy::GetIndexedProperty) { // if the Proxy isn't trapping, return // the value set on the index descriptor - if (!handler->GetHiddenValue(Nan::New("trapping"))->BooleanValue()) { + if (!handler->GetHiddenValue(Nan::New("trapping").ToLocalChecked())->BooleanValue()) { info.GetReturnValue().Set(CallPropertyDescriptorGet(handler->Get(idx), info.This(), argv1)); } - Local get = handler->Get(Nan::New("get")); + Local get = handler->Get(Nan::New("get").ToLocalChecked()); if (get->IsFunction()) { fn = Local::Cast(get); Local argv[2] = {info.This(), idx}; @@ -1152,14 +1156,14 @@ NAN_INDEX_GETTER(NodeProxy::GetIndexedProperty) { info.GetReturnValue().Set(fn->Call(handler, 2, argv)); } - Local getPropertyDescriptor = handler->Get(Nan::New("getPropertyDescriptor")); + Local getPropertyDescriptor = handler->Get(Nan::New("getPropertyDescriptor").ToLocalChecked()); if (getPropertyDescriptor->IsFunction()) { fn = Local::Cast(getPropertyDescriptor); info.GetReturnValue().Set(CallPropertyDescriptorGet(fn->Call(handler, 1, argv1), info.This(), argv1)); } - Local getOwnPropertyDescriptor = handler->Get(Nan::New("getOwnPropertyDescriptor")); + Local getOwnPropertyDescriptor = handler->Get(Nan::New("getOwnPropertyDescriptor").ToLocalChecked()); if (getOwnPropertyDescriptor->IsFunction()) { fn = Local::Cast(getOwnPropertyDescriptor); @@ -1195,8 +1199,8 @@ NAN_INDEX_SETTER(NodeProxy::SetIndexedProperty) { // if the Proxy isn't trapping, return the // value set on the index descriptor - if (!handler->GetHiddenValue(Nan::New("trapping"))->BooleanValue()) { - if (handler->GetHiddenValue(Nan::New("extensible"))->BooleanValue() || + if (!handler->GetHiddenValue(Nan::New("trapping").ToLocalChecked())->BooleanValue()) { + if (handler->GetHiddenValue(Nan::New("extensible").ToLocalChecked())->BooleanValue() || handler->Has(index) ) { Local pd = handler->Get(index); @@ -1208,15 +1212,15 @@ NAN_INDEX_SETTER(NodeProxy::SetIndexedProperty) { Local pd_obj = pd->ToObject(); if (!pd_obj->GetHiddenValue( - Nan::New("writable"))->BooleanValue() + Nan::New("writable").ToLocalChecked())->BooleanValue() ) { Nan::ThrowError( String::Concat( - Nan::New("In accessible index: "), + Nan::New("In accessible index: ").ToLocalChecked(), Local::Cast(idx))); } - Local set = pd_obj->Get(Nan::New("set")); + Local set = pd_obj->Get(Nan::New("set").ToLocalChecked()); if (set->IsFunction()) { Local fn = Local::Cast(set); fn->Call(info.This(), 2, argv2); @@ -1224,7 +1228,7 @@ NAN_INDEX_SETTER(NodeProxy::SetIndexedProperty) { info.GetReturnValue().Set(value); } - if (pd_obj->Set(Nan::New("value"), value)) { + if (pd_obj->Set(Nan::New("value").ToLocalChecked(), value)) { info.GetReturnValue().Set(value); } info.GetReturnValue().SetUndefined(); @@ -1233,7 +1237,7 @@ NAN_INDEX_SETTER(NodeProxy::SetIndexedProperty) { } // does the ProxyHandler have a set method? - Local set = handler->Get(Nan::New("set")); + Local set = handler->Get(Nan::New("set").ToLocalChecked()); if (set->IsFunction()) { Local set_fn = Local::Cast(set); Local argv3[3] = {info.This(), idx, value}; @@ -1242,14 +1246,14 @@ NAN_INDEX_SETTER(NodeProxy::SetIndexedProperty) { info.GetReturnValue().Set(value); } - Local getOwnPropertyDescriptor = handler->Get(Nan::New("getOwnPropertyDescriptor")); + Local getOwnPropertyDescriptor = handler->Get(Nan::New("getOwnPropertyDescriptor").ToLocalChecked()); if (getOwnPropertyDescriptor->IsFunction()) { Local gopd_fn = Local::Cast(getOwnPropertyDescriptor); Local argv[1] = {idx}; info.GetReturnValue().Set(CallPropertyDescriptorSet(gopd_fn->Call(handler, 1, argv), info.This(), idx, value)); } - Local getPropertyDescriptor = handler->Get(Nan::New("getPropertyDescriptor")); + Local getPropertyDescriptor = handler->Get(Nan::New("getPropertyDescriptor").ToLocalChecked()); if (getPropertyDescriptor->IsFunction()) { Local gpd_fn = Local::Cast(getPropertyDescriptor); Local argv[1] = {idx}; @@ -1284,7 +1288,7 @@ NAN_INDEX_QUERY(NodeProxy::QueryIndexedPropertyInteger) { // if the Proxy isn't trapping, // return the value set on the property descriptor - if (!handler->GetHiddenValue(Nan::New("trapping"))->BooleanValue()) { + if (!handler->GetHiddenValue(Nan::New("trapping").ToLocalChecked())->BooleanValue()) { if (handler->Has(index)) { Local pd = handler->Get(index); @@ -1298,7 +1302,7 @@ NAN_INDEX_QUERY(NodeProxy::QueryIndexedPropertyInteger) { Local argv[1] = {idx}; - Local hasOwn = handler->Get(Nan::New("hasOwn")); + Local hasOwn = handler->Get(Nan::New("hasOwn").ToLocalChecked()); if (hasOwn->IsFunction()) { Local hasOwn_fn = Local::Cast(hasOwn); info.GetReturnValue().Set(hasOwn_fn->Call(handler, 1, argv)->BooleanValue() ? @@ -1306,7 +1310,7 @@ NAN_INDEX_QUERY(NodeProxy::QueryIndexedPropertyInteger) { DoesntHavePropertyResponse); } - Local has = handler->Get(Nan::New("has")); + Local has = handler->Get(Nan::New("has").ToLocalChecked()); if (has->IsFunction()) { Local has_fn = Local::Cast(has); info.GetReturnValue().Set(has_fn->Call(handler, 1, argv)->BooleanValue() ? @@ -1314,7 +1318,7 @@ NAN_INDEX_QUERY(NodeProxy::QueryIndexedPropertyInteger) { DoesntHavePropertyResponse); } - Local getOwnPropertyDescriptor = handler->Get(Nan::New("getOwnPropertyDescriptor")); + Local getOwnPropertyDescriptor = handler->Get(Nan::New("getOwnPropertyDescriptor").ToLocalChecked()); if (getOwnPropertyDescriptor->IsFunction()) { Local gopd_fn = Local::Cast(getOwnPropertyDescriptor); Local gopd_pd = gopd_fn->Call(handler, 1, argv); @@ -1324,8 +1328,8 @@ NAN_INDEX_QUERY(NodeProxy::QueryIndexedPropertyInteger) { } } - Local getPropertyDescriptor = handler->Get(Nan::New("getPropertyDescriptor")); - if (handler->Has(Nan::New("getPropertyDescriptor"))) { + Local getPropertyDescriptor = handler->Get(Nan::New("getPropertyDescriptor").ToLocalChecked()); + if (handler->Has(Nan::New("getPropertyDescriptor").ToLocalChecked())) { Local gpd_fn = Local::Cast(getPropertyDescriptor); Local gpd_pd = gpd_fn->Call(handler, 1, argv); @@ -1361,15 +1365,15 @@ NAN_INDEX_DELETER(NodeProxy::DeleteIndexedProperty) { Local handler = data->ToObject(); // if the Proxy isn't trapping, // return the value set on the property descriptor - if (!handler->GetHiddenValue(Nan::New("trapping"))->BooleanValue()) { - if (!handler->GetHiddenValue(Nan::New("frozen"))->BooleanValue()) { + if (!handler->GetHiddenValue(Nan::New("trapping").ToLocalChecked())->BooleanValue()) { + if (!handler->GetHiddenValue(Nan::New("frozen").ToLocalChecked())->BooleanValue()) { Local pd = handler->Get(idx); if (pd->IsObject()) { Local pd_obj = pd->ToObject(); - if (pd_obj->Get(Nan::New("configurable"))->IsBoolean() && - pd_obj->Get(Nan::New("configurable"))->BooleanValue() + if (pd_obj->Get(Nan::New("configurable").ToLocalChecked())->IsBoolean() && + pd_obj->Get(Nan::New("configurable").ToLocalChecked())->BooleanValue() ) { info.GetReturnValue().Set(Nan::New(handler->Delete(index))); } @@ -1378,7 +1382,7 @@ NAN_INDEX_DELETER(NodeProxy::DeleteIndexedProperty) { info.GetReturnValue().Set(Nan::False()); } - Local delete_ = handler->Get(Nan::New("delete")); + Local delete_ = handler->Get(Nan::New("delete").ToLocalChecked()); if (delete_->IsFunction()) { Local fn = Local::Cast(delete_); Local argv[1] = {idx}; @@ -1402,87 +1406,87 @@ void NodeProxy::Init(Handle target) { // main functions Local create = Nan::New(Create)->GetFunction(); - Local _create = Nan::New("create"); + Local _create = Nan::New("create").ToLocalChecked(); create->SetName(_create); target->Set(_create, create); Local createFunction = Nan::New(CreateFunction)->GetFunction(); - Local _createFunction = Nan::New("createFunction"); + Local _createFunction = Nan::New("createFunction").ToLocalChecked(); create->SetName(_createFunction); target->Set(_createFunction, createFunction); // freeze function assignment Local freeze = Nan::New(Freeze)->GetFunction(); - Local _freeze = Nan::New("freeze"); + Local _freeze = Nan::New("freeze").ToLocalChecked(); freeze->SetName(_freeze); target->Set(_freeze, freeze); Local seal = Nan::New(Freeze)->GetFunction(); - Local _seal = Nan::New("seal"); + Local _seal = Nan::New("seal").ToLocalChecked(); seal->SetName(_seal); target->Set(_seal, seal); Local prevent = Nan::New(Freeze)->GetFunction(); - Local _preventExtensions = Nan::New("preventExtensions"); + Local _preventExtensions = Nan::New("preventExtensions").ToLocalChecked(); prevent->SetName(_preventExtensions); target->Set(_preventExtensions, prevent); // check function assignment Local isfrozen = Nan::New(IsLocked)->GetFunction(); - Local _isFrozen = Nan::New("isFrozen"); + Local _isFrozen = Nan::New("isFrozen").ToLocalChecked(); isfrozen->SetName(_isFrozen); target->Set(_isFrozen, isfrozen); Local issealed = Nan::New(IsLocked)->GetFunction(); - Local _isSealed = Nan::New("isSealed"); + Local _isSealed = Nan::New("isSealed").ToLocalChecked(); issealed->SetName(_isSealed); target->Set(_isSealed, issealed); Local isextensible = Nan::New(IsLocked)->GetFunction(); - Local _isExtensible = Nan::New("isExtensible"); + Local _isExtensible = Nan::New("isExtensible").ToLocalChecked(); isextensible->SetName(_isExtensible); target->Set(_isExtensible, isextensible); // part of harmony proxies Local istrapping = Nan::New(IsLocked)->GetFunction(); - Local _isTrapping = Nan::New("isTrapping"); + Local _isTrapping = Nan::New("isTrapping").ToLocalChecked(); istrapping->SetName(_isTrapping); target->Set(_isTrapping, istrapping); // ECMAScript 5 Local getOwnPropertyDescriptor = Nan::New(GetOwnPropertyDescriptor)->GetFunction(); - Local _getOwnPropertyDescriptor = Nan::New("getOwnPropertyDescriptor"); + Local _getOwnPropertyDescriptor = Nan::New("getOwnPropertyDescriptor").ToLocalChecked(); getOwnPropertyDescriptor->SetName(_getOwnPropertyDescriptor); target->Set(_getOwnPropertyDescriptor, getOwnPropertyDescriptor); Local defineProperty = Nan::New(DefineProperty)->GetFunction(); - Local _defineProperty = Nan::New("defineProperty"); + Local _defineProperty = Nan::New("defineProperty").ToLocalChecked(); defineProperty->SetName(_defineProperty); target->Set(_defineProperty, defineProperty); Local defineProperties = Nan::New(DefineProperties)->GetFunction(); - Local _defineProperties = Nan::New("defineProperties"); + Local _defineProperties = Nan::New("defineProperties").ToLocalChecked(); defineProperties->SetName(_defineProperties); target->Set(_defineProperties, defineProperties); // additional functions Local clone = Nan::New(Clone)->GetFunction(); - Local _clone = Nan::New("clone"); + Local _clone = Nan::New("clone").ToLocalChecked(); clone->SetName(_clone); target->Set(_clone, clone); Local hidden = Nan::New(Hidden)->GetFunction(); - Local _hidden = Nan::New("hidden"); + Local _hidden = Nan::New("hidden").ToLocalChecked(); hidden->SetName(_hidden); target->Set(_hidden, hidden); Local setPrototype = Nan::New(SetPrototype)->GetFunction(); - Local _setPrototype = Nan::New("setPrototype"); + Local _setPrototype = Nan::New("setPrototype").ToLocalChecked(); setPrototype->SetName(_setPrototype); target->Set(_setPrototype, setPrototype); Local isProxy_ = Nan::New(IsProxy)->GetFunction(); - Local _isProxy = Nan::New("isProxy"); + Local _isProxy = Nan::New("isProxy").ToLocalChecked(); hidden->SetName(_isProxy); target->Set(_isProxy, isProxy_); @@ -1491,39 +1495,45 @@ void NodeProxy::Init(Handle target) { temp->SetInternalFieldCount(1); // named property handlers - temp->SetNamedPropertyHandler(GetNamedProperty, - SetNamedProperty, - QueryNamedPropertyInteger, - DeleteNamedProperty, - EnumerateNamedProperties); + Nan::SetNamedPropertyHandler( + temp, + GetNamedProperty, + SetNamedProperty, + QueryNamedPropertyInteger, + DeleteNamedProperty, + EnumerateNamedProperties); // indexed property handlers // TODO: properly implement arrays - temp->SetIndexedPropertyHandler(GetIndexedProperty, - SetIndexedProperty, - QueryIndexedPropertyInteger, - DeleteIndexedProperty); - - Local _objectCreator = Nan::New(temp); - NanAssignPersistent(ObjectCreator, _objectCreator); + Nan::SetIndexedPropertyHandler( + temp, + GetIndexedProperty, + SetIndexedProperty, + QueryIndexedPropertyInteger, + DeleteIndexedProperty); + + ObjectCreator.Reset(temp); Local instance = Nan::New(); instance->SetCallAsFunctionHandler(NodeProxy::New); instance->SetInternalFieldCount(1); - instance->SetNamedPropertyHandler(GetNamedProperty, - SetNamedProperty, - QueryNamedPropertyInteger, - DeleteNamedProperty, - EnumerateNamedProperties); - - instance->SetIndexedPropertyHandler(GetIndexedProperty, - SetIndexedProperty, - QueryIndexedPropertyInteger, - DeleteIndexedProperty); - - Local _functionCreator = Local(instance); - NanAssignPersistent(FunctionCreator, _functionCreator); + Nan::SetNamedPropertyHandler( + instance, + GetNamedProperty, + SetNamedProperty, + QueryNamedPropertyInteger, + DeleteNamedProperty, + EnumerateNamedProperties); + + Nan::SetIndexedPropertyHandler( + instance, + GetIndexedProperty, + SetIndexedProperty, + QueryIndexedPropertyInteger, + DeleteIndexedProperty); + + FunctionCreator.Reset(instance); } /** diff --git a/src/node-proxy.h b/src/node-proxy.h index b1ca1b5..638e3fa 100644 --- a/src/node-proxy.h +++ b/src/node-proxy.h @@ -51,8 +51,8 @@ using namespace node; class NodeProxy { public: - static Persistent ObjectCreator; - static Persistent FunctionCreator; + static Nan::Persistent ObjectCreator; + static Nan::Persistent FunctionCreator; static void Init(Handle target); protected: From 321f20175960510d2d9605995f30c19591264b90 Mon Sep 17 00:00:00 2001 From: unbornchikken Date: Sat, 10 Oct 2015 14:03:37 +0200 Subject: [PATCH 3/8] NAN 2.1 - All Tests Passed --- .gitignore | 1 + package.json | 2 +- src/node-proxy.cc | 139 ++++++++++++++++++++++++++++++++++++++++++++-- 3 files changed, 136 insertions(+), 6 deletions(-) diff --git a/.gitignore b/.gitignore index b61ae1f..32819c8 100644 --- a/.gitignore +++ b/.gitignore @@ -1,3 +1,4 @@ +.idea *.node src/build src/.lock-wscript diff --git a/package.json b/package.json index 45ce06b..4a6f129 100644 --- a/package.json +++ b/package.json @@ -11,7 +11,7 @@ ], "dependencies": { "bindings": "1", - "nan": "2" + "nan": "^2.1.0" }, "contributors": [ "Sam Shull ", diff --git a/src/node-proxy.cc b/src/node-proxy.cc index d90feeb..c9c7230 100644 --- a/src/node-proxy.cc +++ b/src/node-proxy.cc @@ -65,40 +65,51 @@ NAN_METHOD(NodeProxy::Clone) { if (info.Length() < 1) { Nan::ThrowError("clone requires at least one (1) argument."); + return; } if (info[0]->IsString()) { info.GetReturnValue().Set(info[0]->ToObject()->Clone()->ToString()); + return; } else if (info[0]->IsBoolean()) { info.GetReturnValue().Set(info[0]->ToObject()->Clone()->ToBoolean()); + return; } else if (info[0]->IsNumber() + || info[0]->IsNumberObject() || info[0]->IsInt32() || info[0]->IsUint32()) { - info.GetReturnValue().Set(info[0]->ToObject()->Clone()->ToNumber()); + info.GetReturnValue().Set(Nan::New(info[0]->NumberValue())); + return; } else if (info[0]->IsArray()) { info.GetReturnValue().Set(Local::Cast(info[0]->ToObject()->Clone())); + return; } else if (info[0]->IsDate()) { info.GetReturnValue().Set(Local::Cast(info[0]->ToObject()->Clone())); + return; } else if (info[0]->IsFunction()) { info.GetReturnValue().Set(Local::Cast(info[0])->Clone()); + return; } else if (info[0]->IsNull()) { info.GetReturnValue().SetNull(); + return; } else if (info[0]->IsUndefined()) { info.GetReturnValue().SetUndefined(); + return; } else if (info[0]->IsObject()) { info.GetReturnValue().Set(info[0]->ToObject()->Clone()); + return; } Nan::ThrowError("clone cannot determine the type of the argument."); - info.GetReturnValue().SetUndefined(); // <-- silence warnings for 0.10.x + return; } /** @@ -121,6 +132,7 @@ NAN_METHOD(NodeProxy::Hidden) { if (info.Length() < 2) { Nan::ThrowError("hidden requires at least two (2) arguments."); + return; } Local obj = info[0]->ToObject(); @@ -128,13 +140,14 @@ NAN_METHOD(NodeProxy::Hidden) { if (info.Length() < 3) { info.GetReturnValue().Set(obj->GetHiddenValue( String::Concat(Nan::New("NodeProxy::hidden:").ToLocalChecked(), - info[1]->ToString()))); + Nan::To(info[1]).ToLocalChecked()))); + return; } info.GetReturnValue().Set( Nan::New( obj->SetHiddenValue(String::Concat(Nan::New("NodeProxy::hidden:").ToLocalChecked(), - info[1]->ToString()), + Nan::To(info[1]).ToLocalChecked()), info[2]))); } @@ -150,6 +163,7 @@ NAN_METHOD(NodeProxy::SetPrototype) { if (info.Length() < 2) { Nan::ThrowError("setPrototype requires at least two (2) arguments."); + return; } info.GetReturnValue().Set(Nan::New(info[0]->ToObject()->SetPrototype(info[1]))); } @@ -164,6 +178,7 @@ NAN_METHOD(NodeProxy::IsProxy) { if (info.Length() < 1) { Nan::ThrowError("isProxy requires at least one (1) argument."); + return; } Local obj = info[0]->ToObject(); @@ -172,6 +187,7 @@ NAN_METHOD(NodeProxy::IsProxy) { Local temp = obj->GetInternalField(0); info.GetReturnValue().Set(Nan::New(!temp.IsEmpty() && temp->IsObject())); + return; } info.GetReturnValue().Set(Nan::False()); @@ -196,11 +212,13 @@ NAN_METHOD(NodeProxy::Create) { if (info.Length() < 1) { Nan::ThrowError("create requires at least one (1) argument."); + return; } if (!info[0]->IsObject()) { Nan::ThrowTypeError( "create requires the first argument to be an Object."); + return; } proxyHandler = info[0]->ToObject(); @@ -208,6 +226,7 @@ NAN_METHOD(NodeProxy::Create) { if (info.Length() > 1 && !info[1]->IsObject()) { Nan::ThrowTypeError( "create requires the second argument to be an Object."); + return; } // manage locking states @@ -243,19 +262,23 @@ NAN_METHOD(NodeProxy::CreateFunction) { if (info.Length() < 2) { Nan::ThrowError("createFunction requires at least two (2) arguments."); + return; } if (!info[0]->IsObject()) { Nan::ThrowTypeError("createFunction requires the first argument to be an Object."); + return; } Local proxyHandler = info[0]->ToObject(); if (!info[1]->IsFunction()) { Nan::ThrowTypeError("createFunction requires the second argument to be a Function."); + return; } if (info.Length() > 2 && !info[2]->IsFunction()) { Nan::ThrowTypeError("createFunction requires the second argument to be a Function."); + return; } proxyHandler->SetHiddenValue(Nan::New("callTrap").ToLocalChecked(), info[1]); @@ -297,6 +320,7 @@ NAN_METHOD(NodeProxy::Freeze) { if (info.Length() < 1) { Nan::ThrowError(String::Concat(name, Nan::New(" requires at least one (1) argument.").ToLocalChecked())); + return; } Local obj = info[0]->ToObject(); @@ -305,6 +329,7 @@ NAN_METHOD(NodeProxy::Freeze) { Nan::ThrowTypeError( "Locking functions expect first " "argument to be intialized by Proxy"); + return; } Local hide = obj->GetInternalField(0); @@ -313,6 +338,7 @@ NAN_METHOD(NodeProxy::Freeze) { Nan::ThrowTypeError( "Locking functions expect first " "argument to be intialized by Proxy"); + return; } Local handler = hide->ToObject(); @@ -321,16 +347,19 @@ NAN_METHOD(NodeProxy::Freeze) { if (name->Equals(Nan::New("freeze").ToLocalChecked())) { if (handler->GetHiddenValue(Nan::New("frozen").ToLocalChecked())->BooleanValue()) { info.GetReturnValue().Set(Nan::True()); + return; } } else if (name->Equals(Nan::New("seal").ToLocalChecked())) { if (handler->GetHiddenValue(Nan::New("sealed").ToLocalChecked())->BooleanValue()) { info.GetReturnValue().Set(Nan::True()); + return; } } else if (name->Equals(Nan::New("preventExtensions").ToLocalChecked())) { if (handler->GetHiddenValue(Nan::New("extensible").ToLocalChecked())->BooleanValue()) { info.GetReturnValue().Set(Nan::True()); + return; } } @@ -341,15 +370,18 @@ NAN_METHOD(NodeProxy::Freeze) { handler->SetHiddenValue(Nan::New("sealed").ToLocalChecked(), Nan::True()); handler->SetHiddenValue(Nan::New("extensible").ToLocalChecked(), Nan::False()); info.GetReturnValue().Set(Nan::True()); + return; } else if (name->Equals(Nan::New("seal").ToLocalChecked())) { handler->SetHiddenValue(Nan::New("sealed").ToLocalChecked(), Nan::True()); handler->SetHiddenValue(Nan::New("extensible").ToLocalChecked(), Nan::False()); info.GetReturnValue().Set(Nan::True()); + return; } else if (name->Equals(Nan::New("preventExtensions").ToLocalChecked())) { handler->SetHiddenValue(Nan::New("extensible").ToLocalChecked(), Nan::False()); info.GetReturnValue().Set(Nan::True()); + return; } } @@ -365,6 +397,7 @@ NAN_METHOD(NodeProxy::Freeze) { if (pieces.IsEmpty() || !pieces->IsObject()) { Nan::ThrowTypeError("Cannot lock object."); + return; } Local parts = pieces->ToObject(); @@ -406,6 +439,7 @@ NAN_METHOD(NodeProxy::IsLocked) { if (info.Length() < 1) { Nan::ThrowError(String::Concat(name, Nan::New(" requires at least one (1) argument.").ToLocalChecked())); + return; } Local arg = info[0]->ToObject(); @@ -414,6 +448,7 @@ NAN_METHOD(NodeProxy::IsLocked) { Nan::ThrowTypeError( "Locking functions expect first argument " "to be intialized by Proxy"); + return; } Local hide = arg->GetInternalField(0); @@ -422,21 +457,26 @@ NAN_METHOD(NodeProxy::IsLocked) { Nan::ThrowTypeError( "Locking functions expect first argument " "to be intialized by Proxy"); + return; } Local obj = hide->ToObject(); if (name->Equals(Nan::New("isExtensible").ToLocalChecked())) { info.GetReturnValue().Set(obj->GetHiddenValue(Nan::New("extensible").ToLocalChecked())->ToBoolean()); + return; } else if (name->Equals(Nan::New("isSealed").ToLocalChecked())) { info.GetReturnValue().Set(obj->GetHiddenValue(Nan::New("sealed").ToLocalChecked())->ToBoolean()); + return; } else if (name->Equals(Nan::New("isTrapping").ToLocalChecked())) { info.GetReturnValue().Set(obj->GetHiddenValue(Nan::New("trapping").ToLocalChecked())->ToBoolean()); + return; } else if (name->Equals(Nan::New("isFrozen").ToLocalChecked())) { info.GetReturnValue().Set(obj->GetHiddenValue(Nan::New("frozen").ToLocalChecked())->ToBoolean()); + return; } info.GetReturnValue().Set(Nan::False()); @@ -456,11 +496,13 @@ NAN_METHOD(NodeProxy::GetOwnPropertyDescriptor) { if (info.Length() < 2) { Nan::ThrowError("getOwnPropertyDescriptor requires " "at least two (2) arguments."); + return; } if (!info[1]->IsString() && !info[1]->IsNumber()) { Nan::ThrowTypeError("getOwnPropertyDescriptor requires " "the second argument to be a String or a Number."); + return; } Local obj = info[0]->ToObject(); @@ -469,6 +511,7 @@ NAN_METHOD(NodeProxy::GetOwnPropertyDescriptor) { if (obj->InternalFieldCount() < 1) { Nan::ThrowTypeError("getOwnPropertyDescriptor expects " "first argument to be intialized by Proxy"); + return; } Local temp = obj->GetInternalField(0); @@ -476,12 +519,14 @@ NAN_METHOD(NodeProxy::GetOwnPropertyDescriptor) { if (temp.IsEmpty() || !temp->IsObject()) { Nan::ThrowTypeError("getOwnPropertyDescriptor expects " "first argument to be intialized by Proxy"); + return; } Local handler = temp->ToObject(); if (!handler->GetHiddenValue(Nan::New("trapping").ToLocalChecked())->BooleanValue()) { info.GetReturnValue().Set(handler->Get(name)); + return; } Local getOwn = Local::Cast( @@ -510,11 +555,13 @@ NAN_METHOD(NodeProxy::DefineProperty) { if (!info[1]->IsString() && !info[1]->IsNumber()) { Nan::ThrowTypeError("defineProperty requires the " "second argument to be a String or a Number."); + return; } if (!info[2]->IsObject()) { Nan::ThrowTypeError("defineProperty requires the third argument " "to be an Object of the type PropertyDescriptor."); + return; } Local obj = info[0]->ToObject(); @@ -522,6 +569,7 @@ NAN_METHOD(NodeProxy::DefineProperty) { if (obj->InternalFieldCount() < 1) { Nan::ThrowTypeError("defineProperty expects first " "argument to be intialized by Proxy"); + return; } Local temp = obj->GetInternalField(0); @@ -529,6 +577,7 @@ NAN_METHOD(NodeProxy::DefineProperty) { if (temp.IsEmpty() || !temp->IsObject()) { Nan::ThrowTypeError("defineProperty expects first argument " "to be intialized by Proxy"); + return; } Local name = info[1]->ToString(); @@ -537,11 +586,13 @@ NAN_METHOD(NodeProxy::DefineProperty) { if (handler->GetHiddenValue(Nan::New("sealed").ToLocalChecked())->BooleanValue() || !handler->Has(Nan::New("defineProperty").ToLocalChecked())) { info.GetReturnValue().Set(Nan::False()); + return; } if (!handler->GetHiddenValue(Nan::New("extensible").ToLocalChecked())->BooleanValue() && !handler->Has(name)) { info.GetReturnValue().Set(Nan::False()); + return; } if (!handler->GetHiddenValue(Nan::New("trapping").ToLocalChecked())->BooleanValue()) { @@ -550,8 +601,10 @@ NAN_METHOD(NodeProxy::DefineProperty) { if (desc->Get(Nan::New("configurable").ToLocalChecked())->BooleanValue()) { info.GetReturnValue().Set(Nan::New( handler->Set(name, info[2]->ToObject()))); + return; } info.GetReturnValue().Set(Nan::False()); + return; } Local def = Local::Cast( @@ -575,11 +628,13 @@ NAN_METHOD(NodeProxy::DefineProperties) { if (info.Length() < 2) { Nan::ThrowError("defineProperty requires at least three (3) arguments."); + return; } if (!info[1]->IsObject()) { Nan::ThrowTypeError("defineProperty requires the third argument " "to be an Object of the type PropertyDescriptor."); + return; } Local obj = info[0]->ToObject(); @@ -587,6 +642,7 @@ NAN_METHOD(NodeProxy::DefineProperties) { if (obj->InternalFieldCount() < 1) { Nan::ThrowTypeError("defineProperty expects first " "argument to be intialized by Proxy"); + return; } Local temp = obj->GetInternalField(0); @@ -597,6 +653,7 @@ NAN_METHOD(NodeProxy::DefineProperties) { if (handler->GetHiddenValue(Nan::New("sealed").ToLocalChecked())->BooleanValue()) { info.GetReturnValue().Set(Nan::False()); + return; } bool extensible = handler->GetHiddenValue( @@ -620,15 +677,18 @@ NAN_METHOD(NodeProxy::DefineProperties) { String::Concat( Nan::New("Unable to define property: ").ToLocalChecked(), name->ToString())); + return; } } } else { Nan::ThrowError(String::Concat( Nan::New("Unable to define property: ").ToLocalChecked(), name->ToString())); + return; } } info.GetReturnValue().Set(Nan::True()); + return; } Local def = Local::Cast(handler->Get(Nan::New("defineProperty").ToLocalChecked())); @@ -644,10 +704,12 @@ NAN_METHOD(NodeProxy::DefineProperties) { if (firstTry.HasCaught()) { info.GetReturnValue().Set(firstTry.ReThrow()); + return; } } } info.GetReturnValue().Set(Nan::True()); + return; } info.GetReturnValue().Set(Nan::False()); } @@ -666,12 +728,14 @@ NAN_METHOD(NodeProxy::New) { if (info.Callee()->InternalFieldCount() < 1 && info.Data().IsEmpty()) { Nan::ThrowTypeError("defineProperty expects first " "argument to be intialized by Proxy"); + return; } Local v, ret, data = info.Holder()->GetInternalField(0); if (data.IsEmpty() || !data->IsObject()) { Nan::ThrowError("Invalid reference to Proxy#constructor"); + return; } Local fn; @@ -721,6 +785,7 @@ NAN_PROPERTY_GETTER(NodeProxy::GetNamedProperty) { if (info.This()->InternalFieldCount() < 1 || info.Data().IsEmpty()) { Nan::ThrowTypeError("SetNamedProperty intercepted " "by non-Proxy object"); + return; } Local argv1[1] = {property}; @@ -730,6 +795,7 @@ NAN_PROPERTY_GETTER(NodeProxy::GetNamedProperty) { if (!data->IsObject()) { info.GetReturnValue().SetUndefined(); + return; } Local fn; @@ -739,6 +805,7 @@ NAN_PROPERTY_GETTER(NodeProxy::GetNamedProperty) { // the value set on the property descriptor if (!handler->GetHiddenValue(Nan::New("trapping").ToLocalChecked())->BooleanValue()) { info.GetReturnValue().Set(CallPropertyDescriptorGet(handler->Get(property), info.This(), argv1)); + return; } Local get = handler->Get(Nan::New("get").ToLocalChecked()); @@ -747,6 +814,7 @@ NAN_PROPERTY_GETTER(NodeProxy::GetNamedProperty) { Local argv[2] = {info.This(), property}; info.GetReturnValue().Set(fn->Call(handler, 2, argv)); + return; } Local getPropertyDescriptor = handler->Get(Nan::New("getPropertyDescriptor").ToLocalChecked()); @@ -754,6 +822,7 @@ NAN_PROPERTY_GETTER(NodeProxy::GetNamedProperty) { fn = Local::Cast(getPropertyDescriptor); info.GetReturnValue().Set(CallPropertyDescriptorGet(fn->Call(handler, 1, argv1), info.This(), argv1)); + return; } Local getOwnPropertyDescriptor = handler->Get(Nan::New("getOwnPropertyDescriptor").ToLocalChecked()); @@ -761,6 +830,7 @@ NAN_PROPERTY_GETTER(NodeProxy::GetNamedProperty) { fn = Local::Cast(getOwnPropertyDescriptor); info.GetReturnValue().Set(CallPropertyDescriptorGet(fn->Call(handler, 1, argv1), info.This(), argv1)); + return; } info.GetReturnValue().SetUndefined(); // <-- silence warnings for 0.10.x } @@ -792,6 +862,7 @@ NAN_PROPERTY_SETTER(NodeProxy::SetNamedProperty) { if (info.This()->InternalFieldCount() < 1 || info.Data().IsEmpty()) { Nan::ThrowTypeError("SetNamedProperty intercepted " "by non-Proxy object"); + return; } Local argv2[2] = {property, value}; @@ -801,6 +872,7 @@ NAN_PROPERTY_SETTER(NodeProxy::SetNamedProperty) { if (!data->IsObject()) { info.GetReturnValue().SetUndefined(); + return; } Local handler = data->ToObject(); @@ -815,6 +887,7 @@ NAN_PROPERTY_SETTER(NodeProxy::SetNamedProperty) { if (!pd->IsObject()) { info.GetReturnValue().SetUndefined(); + return; } Local pd_obj = pd->ToObject(); @@ -826,6 +899,7 @@ NAN_PROPERTY_SETTER(NodeProxy::SetNamedProperty) { String::Concat( Nan::New("In accessible property: ").ToLocalChecked(), property)); + return; } Local set = pd_obj->Get(Nan::New("set").ToLocalChecked()); @@ -834,14 +908,18 @@ NAN_PROPERTY_SETTER(NodeProxy::SetNamedProperty) { fn->Call(info.This(), 2, argv2); info.GetReturnValue().Set(value); + return; } if (pd_obj->Set(Nan::New("value").ToLocalChecked(), value)) { info.GetReturnValue().Set(value); + return; } info.GetReturnValue().SetUndefined(); + return; } info.GetReturnValue().SetUndefined(); + return; } // does the ProxyHandler have a set method? @@ -852,6 +930,7 @@ NAN_PROPERTY_SETTER(NodeProxy::SetNamedProperty) { set_fn->Call(handler, 3, argv3); info.GetReturnValue().Set(value); + return; } Local getOwnPropertyDescriptor = handler->Get(Nan::New("getOwnPropertyDescriptor").ToLocalChecked()); @@ -859,6 +938,7 @@ NAN_PROPERTY_SETTER(NodeProxy::SetNamedProperty) { Local gopd_fn = Local::Cast(getOwnPropertyDescriptor); Local argv[1] = {property}; info.GetReturnValue().Set(CallPropertyDescriptorSet(gopd_fn->Call(handler, 1, argv), info.This(), property, value)); + return; } Local getPropertyDescriptor = handler->Get(Nan::New("getPropertyDescriptor").ToLocalChecked()); @@ -866,6 +946,7 @@ NAN_PROPERTY_SETTER(NodeProxy::SetNamedProperty) { Local gpd_fn = Local::Cast(getPropertyDescriptor); Local argv[1] = {property}; info.GetReturnValue().Set(CallPropertyDescriptorSet(gpd_fn->Call(handler, 1, argv), info.This(), property, value)); + return; } info.GetReturnValue().SetUndefined(); @@ -911,6 +992,7 @@ NAN_PROPERTY_QUERY(NodeProxy::QueryNamedPropertyInteger) { if (!data->IsObject()) { info.GetReturnValue().Set(DoesntHavePropertyResponse); + return; } Local handler = data->ToObject(); @@ -923,10 +1005,13 @@ NAN_PROPERTY_QUERY(NodeProxy::QueryNamedPropertyInteger) { if (pd->IsObject()) { info.GetReturnValue().Set(GetPropertyAttributeFromPropertyDescriptor(pd->ToObject())); + return; } info.GetReturnValue().Set(HasPropertyResponse); + return; } info.GetReturnValue().Set(DoesntHavePropertyResponse); + return; } Local argv[1] = {property}; @@ -937,6 +1022,7 @@ NAN_PROPERTY_QUERY(NodeProxy::QueryNamedPropertyInteger) { info.GetReturnValue().Set(hasOwn_fn->Call(handler, 1, argv)->BooleanValue() ? HasPropertyResponse : DoesntHavePropertyResponse); + return; } Local has = handler->Get(Nan::New("has").ToLocalChecked()); @@ -945,6 +1031,7 @@ NAN_PROPERTY_QUERY(NodeProxy::QueryNamedPropertyInteger) { info.GetReturnValue().Set(has_fn->Call(handler, 1, argv)->BooleanValue() ? HasPropertyResponse : DoesntHavePropertyResponse); + return; } Local getOwnPropertyDescriptor = handler->Get(Nan::New("getOwnPropertyDescriptor").ToLocalChecked()); @@ -954,6 +1041,7 @@ NAN_PROPERTY_QUERY(NodeProxy::QueryNamedPropertyInteger) { if (gopd_pd->IsObject()) { info.GetReturnValue().Set(GetPropertyAttributeFromPropertyDescriptor(gopd_pd->ToObject())); + return; } } @@ -964,8 +1052,10 @@ NAN_PROPERTY_QUERY(NodeProxy::QueryNamedPropertyInteger) { if (gpd_pd->IsObject()) { info.GetReturnValue().Set(GetPropertyAttributeFromPropertyDescriptor(gpd_pd->ToObject())); + return; } else if (gpd_pd->IsUndefined()) { info.GetReturnValue().Set(DoesntHavePropertyResponse); + return; } } } @@ -1018,6 +1108,7 @@ NAN_PROPERTY_DELETER(NodeProxy::DeleteNamedProperty) { if (!data->IsObject()) { info.GetReturnValue().Set(Nan::False()); + return; } Local handler = data->ToObject(); @@ -1034,10 +1125,12 @@ NAN_PROPERTY_DELETER(NodeProxy::DeleteNamedProperty) { pd_obj->Get(Nan::New("configurable").ToLocalChecked())->BooleanValue() ) { info.GetReturnValue().Set(Nan::New(handler->Delete(property))); + return; } } } info.GetReturnValue().Set(Nan::False()); + return; } Local delete_ = handler->Get(Nan::New("delete").ToLocalChecked()); @@ -1045,6 +1138,7 @@ NAN_PROPERTY_DELETER(NodeProxy::DeleteNamedProperty) { Local fn = Local::Cast(delete_); Local argv[1] = {property}; info.GetReturnValue().Set(fn->Call(handler, 1, argv)->ToBoolean()); + return; } } @@ -1066,6 +1160,7 @@ NAN_PROPERTY_ENUMERATOR(NodeProxy::EnumerateNamedProperties) { if (!data->IsObject()) { info.GetReturnValue().Set(Nan::New()); + return; } Local handler = data->ToObject(); @@ -1080,6 +1175,7 @@ NAN_PROPERTY_ENUMERATOR(NodeProxy::EnumerateNamedProperties) { // return the value set on the property descriptor if (!handler->GetHiddenValue(Nan::New("trapping").ToLocalChecked())->BooleanValue()) { info.GetReturnValue().Set(handler->GetPropertyNames()); + return; } Local enumerate = handler->Get(Nan::New("enumerate").ToLocalChecked()); @@ -1089,6 +1185,7 @@ NAN_PROPERTY_ENUMERATOR(NodeProxy::EnumerateNamedProperties) { if (names->IsArray()) { info.GetReturnValue().Set(Local::Cast(names->ToObject())); + return; } } @@ -1099,6 +1196,7 @@ NAN_PROPERTY_ENUMERATOR(NodeProxy::EnumerateNamedProperties) { if (names->IsArray()) { info.GetReturnValue().Set(Local::Cast(names->ToObject())); + return; } } @@ -1109,6 +1207,7 @@ NAN_PROPERTY_ENUMERATOR(NodeProxy::EnumerateNamedProperties) { if (names->IsArray()) { info.GetReturnValue().Set(Local::Cast(names->ToObject())); + return; } } } @@ -1127,6 +1226,7 @@ NAN_INDEX_GETTER(NodeProxy::GetIndexedProperty) { if (info.This()->InternalFieldCount() < 1 || info.Data().IsEmpty()) { Nan::ThrowTypeError("SetNamedProperty intercepted " "by non-Proxy object"); + return; } Local idx = Nan::New(index); @@ -1137,6 +1237,7 @@ NAN_INDEX_GETTER(NodeProxy::GetIndexedProperty) { if (!data->IsObject()) { info.GetReturnValue().SetUndefined(); + return; } Local fn; @@ -1146,6 +1247,7 @@ NAN_INDEX_GETTER(NodeProxy::GetIndexedProperty) { // the value set on the index descriptor if (!handler->GetHiddenValue(Nan::New("trapping").ToLocalChecked())->BooleanValue()) { info.GetReturnValue().Set(CallPropertyDescriptorGet(handler->Get(idx), info.This(), argv1)); + return; } Local get = handler->Get(Nan::New("get").ToLocalChecked()); @@ -1154,6 +1256,7 @@ NAN_INDEX_GETTER(NodeProxy::GetIndexedProperty) { Local argv[2] = {info.This(), idx}; info.GetReturnValue().Set(fn->Call(handler, 2, argv)); + return; } Local getPropertyDescriptor = handler->Get(Nan::New("getPropertyDescriptor").ToLocalChecked()); @@ -1161,6 +1264,7 @@ NAN_INDEX_GETTER(NodeProxy::GetIndexedProperty) { fn = Local::Cast(getPropertyDescriptor); info.GetReturnValue().Set(CallPropertyDescriptorGet(fn->Call(handler, 1, argv1), info.This(), argv1)); + return; } Local getOwnPropertyDescriptor = handler->Get(Nan::New("getOwnPropertyDescriptor").ToLocalChecked()); @@ -1168,6 +1272,7 @@ NAN_INDEX_GETTER(NodeProxy::GetIndexedProperty) { fn = Local::Cast(getOwnPropertyDescriptor); info.GetReturnValue().Set(CallPropertyDescriptorGet(fn->Call(handler, 1, argv1), info.This(), argv1)); + return; } info.GetReturnValue().SetUndefined(); // <-- silence warnings for 0.10.x } @@ -1183,6 +1288,7 @@ NAN_INDEX_SETTER(NodeProxy::SetIndexedProperty) { if (info.This()->InternalFieldCount() < 1 || info.Data().IsEmpty()) { Nan::ThrowTypeError("SetNamedProperty intercepted " "by non-Proxy object"); + return; } Local idx = Nan::New(index); @@ -1193,6 +1299,7 @@ NAN_INDEX_SETTER(NodeProxy::SetIndexedProperty) { if (!data->IsObject()) { info.GetReturnValue().SetUndefined(); + return; } Local handler = data->ToObject(); @@ -1207,6 +1314,7 @@ NAN_INDEX_SETTER(NodeProxy::SetIndexedProperty) { if (!pd->IsObject()) { info.GetReturnValue().SetUndefined(); + return; } Local pd_obj = pd->ToObject(); @@ -1218,6 +1326,7 @@ NAN_INDEX_SETTER(NodeProxy::SetIndexedProperty) { String::Concat( Nan::New("In accessible index: ").ToLocalChecked(), Local::Cast(idx))); + return; } Local set = pd_obj->Get(Nan::New("set").ToLocalChecked()); @@ -1226,14 +1335,18 @@ NAN_INDEX_SETTER(NodeProxy::SetIndexedProperty) { fn->Call(info.This(), 2, argv2); info.GetReturnValue().Set(value); + return; } if (pd_obj->Set(Nan::New("value").ToLocalChecked(), value)) { info.GetReturnValue().Set(value); + return; } info.GetReturnValue().SetUndefined(); + return; } info.GetReturnValue().SetUndefined(); + return; } // does the ProxyHandler have a set method? @@ -1244,6 +1357,7 @@ NAN_INDEX_SETTER(NodeProxy::SetIndexedProperty) { set_fn->Call(handler, 3, argv3); info.GetReturnValue().Set(value); + return; } Local getOwnPropertyDescriptor = handler->Get(Nan::New("getOwnPropertyDescriptor").ToLocalChecked()); @@ -1251,6 +1365,7 @@ NAN_INDEX_SETTER(NodeProxy::SetIndexedProperty) { Local gopd_fn = Local::Cast(getOwnPropertyDescriptor); Local argv[1] = {idx}; info.GetReturnValue().Set(CallPropertyDescriptorSet(gopd_fn->Call(handler, 1, argv), info.This(), idx, value)); + return; } Local getPropertyDescriptor = handler->Get(Nan::New("getPropertyDescriptor").ToLocalChecked()); @@ -1258,6 +1373,7 @@ NAN_INDEX_SETTER(NodeProxy::SetIndexedProperty) { Local gpd_fn = Local::Cast(getPropertyDescriptor); Local argv[1] = {idx}; info.GetReturnValue().Set(CallPropertyDescriptorSet(gpd_fn->Call(handler, 1, argv), info.This(), idx, value)); + return; } info.GetReturnValue().SetUndefined(); @@ -1282,6 +1398,7 @@ NAN_INDEX_QUERY(NodeProxy::QueryIndexedPropertyInteger) { if (!data->IsObject()) { info.GetReturnValue().Set(DoesntHavePropertyResponse); + return; } Local handler = data->ToObject(); @@ -1294,10 +1411,13 @@ NAN_INDEX_QUERY(NodeProxy::QueryIndexedPropertyInteger) { if (pd->IsObject()) { info.GetReturnValue().Set(GetPropertyAttributeFromPropertyDescriptor(pd->ToObject())); + return; } info.GetReturnValue().Set(HasPropertyResponse); + return; } info.GetReturnValue().Set(DoesntHavePropertyResponse); + return; } Local argv[1] = {idx}; @@ -1308,6 +1428,7 @@ NAN_INDEX_QUERY(NodeProxy::QueryIndexedPropertyInteger) { info.GetReturnValue().Set(hasOwn_fn->Call(handler, 1, argv)->BooleanValue() ? HasPropertyResponse : DoesntHavePropertyResponse); + return; } Local has = handler->Get(Nan::New("has").ToLocalChecked()); @@ -1316,6 +1437,7 @@ NAN_INDEX_QUERY(NodeProxy::QueryIndexedPropertyInteger) { info.GetReturnValue().Set(has_fn->Call(handler, 1, argv)->BooleanValue() ? HasPropertyResponse : DoesntHavePropertyResponse); + return; } Local getOwnPropertyDescriptor = handler->Get(Nan::New("getOwnPropertyDescriptor").ToLocalChecked()); @@ -1325,6 +1447,7 @@ NAN_INDEX_QUERY(NodeProxy::QueryIndexedPropertyInteger) { if (gopd_pd->IsObject()) { info.GetReturnValue().Set(GetPropertyAttributeFromPropertyDescriptor(gopd_pd->ToObject())); + return; } } @@ -1335,8 +1458,10 @@ NAN_INDEX_QUERY(NodeProxy::QueryIndexedPropertyInteger) { if (gpd_pd->IsObject()) { info.GetReturnValue().Set(GetPropertyAttributeFromPropertyDescriptor(gpd_pd->ToObject())); + return; } else if (gpd_pd->IsUndefined()) { info.GetReturnValue().Set(DoesntHavePropertyResponse); + return; } } } @@ -1359,6 +1484,7 @@ NAN_INDEX_DELETER(NodeProxy::DeleteIndexedProperty) { if (!data->IsObject()) { info.GetReturnValue().Set(Nan::False()); + return; } Local idx = Nan::New(index); @@ -1376,10 +1502,12 @@ NAN_INDEX_DELETER(NodeProxy::DeleteIndexedProperty) { pd_obj->Get(Nan::New("configurable").ToLocalChecked())->BooleanValue() ) { info.GetReturnValue().Set(Nan::New(handler->Delete(index))); + return; } } } info.GetReturnValue().Set(Nan::False()); + return; } Local delete_ = handler->Get(Nan::New("delete").ToLocalChecked()); @@ -1387,6 +1515,7 @@ NAN_INDEX_DELETER(NodeProxy::DeleteIndexedProperty) { Local fn = Local::Cast(delete_); Local argv[1] = {idx}; info.GetReturnValue().Set(fn->Call(handler, 1, argv)->ToBoolean()); + return; } } @@ -1515,7 +1644,7 @@ void NodeProxy::Init(Handle target) { ObjectCreator.Reset(temp); Local instance = Nan::New(); - instance->SetCallAsFunctionHandler(NodeProxy::New); + Nan::SetCallAsFunctionHandler(instance, NodeProxy::New); instance->SetInternalFieldCount(1); Nan::SetNamedPropertyHandler( From 1750d36ef4ade1400a247553770aa63652e9d9ca Mon Sep 17 00:00:00 2001 From: unbornchikken Date: Sat, 10 Oct 2015 14:13:18 +0200 Subject: [PATCH 4/8] 0.10.x fixes --- src/node-proxy.cc | 4 ++-- src/node-proxy.h | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/src/node-proxy.cc b/src/node-proxy.cc index c9c7230..14e5e53 100644 --- a/src/node-proxy.cc +++ b/src/node-proxy.cc @@ -703,7 +703,7 @@ NAN_METHOD(NodeProxy::DefineProperties) { def->Call(obj, 2, argv); if (firstTry.HasCaught()) { - info.GetReturnValue().Set(firstTry.ReThrow()); + firstTry.ReThrow(); return; } } @@ -1069,7 +1069,7 @@ NAN_PROPERTY_QUERY(NodeProxy::QueryNamedPropertyInteger) { * * */ -Handle +Local NodeProxy::GetPropertyAttributeFromPropertyDescriptor(Local pd) { uint32_t ret = None; diff --git a/src/node-proxy.h b/src/node-proxy.h index 638e3fa..65cf4eb 100644 --- a/src/node-proxy.h +++ b/src/node-proxy.h @@ -58,7 +58,7 @@ class NodeProxy { protected: NodeProxy(); ~NodeProxy(); - static Handle + static Local GetPropertyAttributeFromPropertyDescriptor(Local pd); static Local CorrectPropertyDescriptor(Local pd); static NAN_METHOD(ValidateProxyHandler); From 2fe8c92e7bd08ee52cfd5a68f9de74c701b8bba0 Mon Sep 17 00:00:00 2001 From: unbornchikken Date: Sat, 10 Oct 2015 14:16:34 +0200 Subject: [PATCH 5/8] travis update to test 0.10+ --- .travis.yml | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/.travis.yml b/.travis.yml index d7b5c9c..05d1ae8 100644 --- a/.travis.yml +++ b/.travis.yml @@ -1,6 +1,7 @@ language: "node_js" node_js: - - '0.8' - '0.10' - - '0.11' + - '0.12' + - '4.x' + - 'iojs' script: node test/test.js From 4ac849a35a51b2f4dc10f1cc98a0ddb91074035a Mon Sep 17 00:00:00 2001 From: unbornchikken Date: Sat, 10 Oct 2015 14:21:29 +0200 Subject: [PATCH 6/8] travis C++11 support --- .travis.yml | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/.travis.yml b/.travis.yml index 05d1ae8..8ec64a8 100644 --- a/.travis.yml +++ b/.travis.yml @@ -1,7 +1,16 @@ language: "node_js" +install: +- if [ "$CXX" = "g++" ]; then export CXX="g++-4.8" CC="gcc-4.8"; fi +addons: + apt: + sources: + - ubuntu-toolchain-r-test + packages: + - gcc-4.8 + - g++-4.8 node_js: - '0.10' - '0.12' - - '4.x' + - '4.1' - 'iojs' script: node test/test.js From 4191800e38becea2aa449e816cc4dd39a2e308e3 Mon Sep 17 00:00:00 2001 From: unbornchikken Date: Sat, 10 Oct 2015 14:24:04 +0200 Subject: [PATCH 7/8] more travis hack --- .travis.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.travis.yml b/.travis.yml index 8ec64a8..7d90eab 100644 --- a/.travis.yml +++ b/.travis.yml @@ -13,4 +13,4 @@ node_js: - '0.12' - '4.1' - 'iojs' -script: node test/test.js +script: npm install&&node test/test.js From 80ea4696e7d6d7506c5350037fa4e8afc11cec7a Mon Sep 17 00:00:00 2001 From: unbornchikken Date: Sat, 10 Oct 2015 14:30:31 +0200 Subject: [PATCH 8/8] brand new travis file --- .travis.yml | 42 ++++++++++++++++++++++++++++++------------ 1 file changed, 30 insertions(+), 12 deletions(-) diff --git a/.travis.yml b/.travis.yml index 7d90eab..5ad9fb5 100644 --- a/.travis.yml +++ b/.travis.yml @@ -1,16 +1,34 @@ -language: "node_js" -install: -- if [ "$CXX" = "g++" ]; then export CXX="g++-4.8" CC="gcc-4.8"; fi +os: + - linux + - osx +sudo: false +language: cpp addons: apt: sources: - - ubuntu-toolchain-r-test + - ubuntu-toolchain-r-test packages: - - gcc-4.8 - - g++-4.8 -node_js: - - '0.10' - - '0.12' - - '4.1' - - 'iojs' -script: npm install&&node test/test.js + - g++-4.8 +env: + matrix: + - TRAVIS_NODE_VERSION="0.10" + - TRAVIS_NODE_VERSION="0.12" + - TRAVIS_NODE_VERSION="2" + - TRAVIS_NODE_VERSION="4" + +install: + - rm -rf ~/.nvm && git clone https://github.com/creationix/nvm.git ~/.nvm && (cd ~/.nvm && git checkout `git describe --abbrev=0 --tags`) && source ~/.nvm/nvm.sh && nvm install $TRAVIS_NODE_VERSION + - if [[ $TRAVIS_OS_NAME == "linux" ]]; then export CXX=g++-4.8; fi + - $CXX --version + - PATH="`npm bin`:`npm bin -g`:$PATH" + # Node 0.8 comes with a too obsolete npm + - if [[ "`node --version`" =~ ^v0\.8\. ]]; then npm install -g npm@1.4.28 ; fi + # Install dependencies and build + - npm install + +script: + # Output useful info for debugging + - node --version + - npm --version + # Run tests + - node test/test.js