diff --git a/src/cares_wrap.cc b/src/cares_wrap.cc index 2d183395b3..88645c408c 100644 --- a/src/cares_wrap.cc +++ b/src/cares_wrap.cc @@ -840,7 +840,7 @@ class GetHostByNameWrap: public QueryWrap { template static void Query(const FunctionCallbackInfo& args) { - Environment* env = Environment::GetCurrent(args.GetIsolate()); + Environment* env = Environment::GetCurrent(args); CHECK_EQ(false, args.IsConstructCall()); CHECK(args[0]->IsObject()); @@ -1003,7 +1003,7 @@ static void IsIP(const FunctionCallbackInfo& args) { static void GetAddrInfo(const FunctionCallbackInfo& args) { - Environment* env = Environment::GetCurrent(args.GetIsolate()); + Environment* env = Environment::GetCurrent(args); CHECK(args[0]->IsObject()); CHECK(args[1]->IsString()); @@ -1055,7 +1055,7 @@ static void GetAddrInfo(const FunctionCallbackInfo& args) { static void GetNameInfo(const FunctionCallbackInfo& args) { - Environment* env = Environment::GetCurrent(args.GetIsolate()); + Environment* env = Environment::GetCurrent(args); CHECK(args[0]->IsObject()); CHECK(args[1]->IsString()); @@ -1087,7 +1087,7 @@ static void GetNameInfo(const FunctionCallbackInfo& args) { static void GetServers(const FunctionCallbackInfo& args) { - Environment* env = Environment::GetCurrent(args.GetIsolate()); + Environment* env = Environment::GetCurrent(args); Local server_array = Array::New(env->isolate()); @@ -1116,7 +1116,7 @@ static void GetServers(const FunctionCallbackInfo& args) { static void SetServers(const FunctionCallbackInfo& args) { - Environment* env = Environment::GetCurrent(args.GetIsolate()); + Environment* env = Environment::GetCurrent(args); CHECK(args[0]->IsArray()); @@ -1184,7 +1184,7 @@ static void SetServers(const FunctionCallbackInfo& args) { static void StrError(const FunctionCallbackInfo& args) { - Environment* env = Environment::GetCurrent(args.GetIsolate()); + Environment* env = Environment::GetCurrent(args); const char* errmsg = ares_strerror(args[0]->Int32Value()); args.GetReturnValue().Set(OneByteString(env->isolate(), errmsg)); } @@ -1232,24 +1232,24 @@ static void Initialize(Handle target, CaresTimerClose, NULL); - NODE_SET_METHOD(target, "queryA", Query); - NODE_SET_METHOD(target, "queryAaaa", Query); - NODE_SET_METHOD(target, "queryCname", Query); - NODE_SET_METHOD(target, "queryMx", Query); - NODE_SET_METHOD(target, "queryNs", Query); - NODE_SET_METHOD(target, "queryTxt", Query); - NODE_SET_METHOD(target, "querySrv", Query); - NODE_SET_METHOD(target, "queryNaptr", Query); - NODE_SET_METHOD(target, "querySoa", Query); - NODE_SET_METHOD(target, "getHostByAddr", Query); - - NODE_SET_METHOD(target, "getaddrinfo", GetAddrInfo); - NODE_SET_METHOD(target, "getnameinfo", GetNameInfo); - NODE_SET_METHOD(target, "isIP", IsIP); - - NODE_SET_METHOD(target, "strerror", StrError); - NODE_SET_METHOD(target, "getServers", GetServers); - NODE_SET_METHOD(target, "setServers", SetServers); + env->SetMethod(target, "queryA", Query); + env->SetMethod(target, "queryAaaa", Query); + env->SetMethod(target, "queryCname", Query); + env->SetMethod(target, "queryMx", Query); + env->SetMethod(target, "queryNs", Query); + env->SetMethod(target, "queryTxt", Query); + env->SetMethod(target, "querySrv", Query); + env->SetMethod(target, "queryNaptr", Query); + env->SetMethod(target, "querySoa", Query); + env->SetMethod(target, "getHostByAddr", Query); + + env->SetMethod(target, "getaddrinfo", GetAddrInfo); + env->SetMethod(target, "getnameinfo", GetNameInfo); + env->SetMethod(target, "isIP", IsIP); + + env->SetMethod(target, "strerror", StrError); + env->SetMethod(target, "getServers", GetServers); + env->SetMethod(target, "setServers", SetServers); target->Set(FIXED_ONE_BYTE_STRING(env->isolate(), "AF_INET"), Integer::New(env->isolate(), AF_INET)); diff --git a/src/env-inl.h b/src/env-inl.h index e6a3d1c5ec..c0465843d4 100644 --- a/src/env-inl.h +++ b/src/env-inl.h @@ -209,6 +209,18 @@ inline Environment* Environment::GetCurrent(v8::Local context) { context->GetAlignedPointerFromEmbedderData(kContextEmbedderDataIndex)); } +inline Environment* Environment::GetCurrent( + const v8::FunctionCallbackInfo& info) { + ASSERT(info.Data()->IsExternal()); + return static_cast(info.Data().As()->Value()); +} + +inline Environment* Environment::GetCurrent( + const v8::PropertyCallbackInfo& info) { + ASSERT(info.Data()->IsExternal()); + return static_cast(info.Data().As()->Value()); +} + inline Environment::Environment(v8::Local context, uv_loop_t* loop) : isolate_(context->GetIsolate()), @@ -437,6 +449,50 @@ inline void Environment::ThrowUVException(int errorno, UVException(isolate(), errorno, syscall, message, path)); } +inline v8::Local + Environment::NewFunctionTemplate(v8::FunctionCallback callback, + v8::Local signature) { + v8::Local external; + if (external_.IsEmpty()) { + external = v8::External::New(isolate(), this); + external_.Reset(isolate(), external); + } else { + external = StrongPersistentToLocal(external_); + } + return v8::FunctionTemplate::New(isolate(), callback, external, signature); +} + +inline void Environment::SetMethod(v8::Local that, + const char* name, + v8::FunctionCallback callback) { + v8::Local function = + NewFunctionTemplate(callback)->GetFunction(); + v8::Local name_string = v8::String::NewFromUtf8(isolate(), name); + that->Set(name_string, function); + function->SetName(name_string); // NODE_SET_METHOD() compatibility. +} + +inline void Environment::SetProtoMethod(v8::Local that, + const char* name, + v8::FunctionCallback callback) { + v8::Local signature = v8::Signature::New(isolate(), that); + v8::Local function = + NewFunctionTemplate(callback, signature)->GetFunction(); + v8::Local name_string = v8::String::NewFromUtf8(isolate(), name); + that->PrototypeTemplate()->Set(name_string, function); + function->SetName(name_string); // NODE_SET_PROTOTYPE_METHOD() compatibility. +} + +inline void Environment::SetTemplateMethod(v8::Local that, + const char* name, + v8::FunctionCallback callback) { + v8::Local function = + NewFunctionTemplate(callback)->GetFunction(); + v8::Local name_string = v8::String::NewFromUtf8(isolate(), name); + that->Set(name_string, function); + function->SetName(name_string); // NODE_SET_METHOD() compatibility. +} + #define V(PropertyName, StringValue) \ inline \ v8::Local Environment::IsolateData::PropertyName() const { \ diff --git a/src/env.h b/src/env.h index 655e804cb9..d426eb9732 100644 --- a/src/env.h +++ b/src/env.h @@ -380,6 +380,10 @@ class Environment { static inline Environment* GetCurrent(v8::Isolate* isolate); static inline Environment* GetCurrent(v8::Local context); + static inline Environment* GetCurrent( + const v8::FunctionCallbackInfo& info); + static inline Environment* GetCurrent( + const v8::PropertyCallbackInfo& info); // See CreateEnvironment() in src/node.cc. static inline Environment* New(v8::Local context, @@ -451,6 +455,23 @@ class Environment { inline static void ThrowTypeError(v8::Isolate* isolate, const char* errmsg); inline static void ThrowRangeError(v8::Isolate* isolate, const char* errmsg); + inline v8::Local + NewFunctionTemplate(v8::FunctionCallback callback, + v8::Local signature = + v8::Local()); + + // Convenience methods for NewFunctionTemplate(). + inline void SetMethod(v8::Local that, + const char* name, + v8::FunctionCallback callback); + inline void SetProtoMethod(v8::Local that, + const char* name, + v8::FunctionCallback callback); + inline void SetTemplateMethod(v8::Local that, + const char* name, + v8::FunctionCallback callback); + + // Strings are shared across shared contexts. The getters simply proxy to // the per-isolate primitive. #define V(PropertyName, StringValue) \ @@ -509,6 +530,8 @@ class Environment { QUEUE handle_cleanup_queue_; int handle_cleanup_waiting_; + v8::Persistent external_; + #define V(PropertyName, TypeName) \ v8::Persistent PropertyName ## _; ENVIRONMENT_STRONG_PERSISTENT_PROPERTIES(V) diff --git a/src/fs_event_wrap.cc b/src/fs_event_wrap.cc index b054b86a6c..06e5ef44d9 100644 --- a/src/fs_event_wrap.cc +++ b/src/fs_event_wrap.cc @@ -83,12 +83,12 @@ void FSEventWrap::Initialize(Handle target, Handle context) { Environment* env = Environment::GetCurrent(context); - Local t = FunctionTemplate::New(env->isolate(), New); + Local t = env->NewFunctionTemplate(New); t->InstanceTemplate()->SetInternalFieldCount(1); t->SetClassName(env->fsevent_string()); - NODE_SET_PROTOTYPE_METHOD(t, "start", Start); - NODE_SET_PROTOTYPE_METHOD(t, "close", Close); + env->SetProtoMethod(t, "start", Start); + env->SetProtoMethod(t, "close", Close); target->Set(env->fsevent_string(), t->GetFunction()); } @@ -96,13 +96,13 @@ void FSEventWrap::Initialize(Handle target, void FSEventWrap::New(const FunctionCallbackInfo& args) { CHECK(args.IsConstructCall()); - Environment* env = Environment::GetCurrent(args.GetIsolate()); + Environment* env = Environment::GetCurrent(args); new FSEventWrap(env, args.This()); } void FSEventWrap::Start(const FunctionCallbackInfo& args) { - Environment* env = Environment::GetCurrent(args.GetIsolate()); + Environment* env = Environment::GetCurrent(args); FSEventWrap* wrap = Unwrap(args.Holder()); diff --git a/src/handle_wrap.cc b/src/handle_wrap.cc index 403b61ac98..ecca915c43 100644 --- a/src/handle_wrap.cc +++ b/src/handle_wrap.cc @@ -61,7 +61,7 @@ void HandleWrap::Unref(const FunctionCallbackInfo& args) { void HandleWrap::Close(const FunctionCallbackInfo& args) { - Environment* env = Environment::GetCurrent(args.GetIsolate()); + Environment* env = Environment::GetCurrent(args); HandleWrap* wrap = Unwrap(args.Holder()); diff --git a/src/node.cc b/src/node.cc index d85b1e781e..afb5747ade 100644 --- a/src/node.cc +++ b/src/node.cc @@ -918,7 +918,7 @@ Local WinapiErrnoException(Isolate* isolate, void SetupAsyncListener(const FunctionCallbackInfo& args) { - Environment* env = Environment::GetCurrent(args.GetIsolate()); + Environment* env = Environment::GetCurrent(args); CHECK(args[0]->IsObject()); CHECK(args[1]->IsFunction()); @@ -943,7 +943,7 @@ void SetupAsyncListener(const FunctionCallbackInfo& args) { void SetupDomainUse(const FunctionCallbackInfo& args) { - Environment* env = Environment::GetCurrent(args.GetIsolate()); + Environment* env = Environment::GetCurrent(args); if (env->using_domains()) return; @@ -987,7 +987,7 @@ void RunMicrotasks(const FunctionCallbackInfo& args) { void SetupNextTick(const FunctionCallbackInfo& args) { - Environment* env = Environment::GetCurrent(args.GetIsolate()); + Environment* env = Environment::GetCurrent(args); CHECK(args[0]->IsObject()); CHECK(args[1]->IsFunction()); @@ -1002,7 +1002,7 @@ void SetupNextTick(const FunctionCallbackInfo& args) { env->set_tick_callback_function(args[1].As()); - NODE_SET_METHOD(args[2].As(), "runMicrotasks", RunMicrotasks); + env->SetMethod(args[2].As(), "runMicrotasks", RunMicrotasks); // Do a little housekeeping. env->process_object()->Delete( @@ -1554,7 +1554,7 @@ static Local ExecuteString(Environment* env, static void GetActiveRequests(const FunctionCallbackInfo& args) { - Environment* env = Environment::GetCurrent(args.GetIsolate()); + Environment* env = Environment::GetCurrent(args); Local ary = Array::New(args.GetIsolate()); QUEUE* q = NULL; @@ -1574,7 +1574,7 @@ static void GetActiveRequests(const FunctionCallbackInfo& args) { // Non-static, friend of HandleWrap. Could have been a HandleWrap method but // implemented here for consistency with GetActiveRequests(). void GetActiveHandles(const FunctionCallbackInfo& args) { - Environment* env = Environment::GetCurrent(args.GetIsolate()); + Environment* env = Environment::GetCurrent(args); Local ary = Array::New(env->isolate()); QUEUE* q = NULL; @@ -1603,7 +1603,7 @@ static void Abort(const FunctionCallbackInfo& args) { static void Chdir(const FunctionCallbackInfo& args) { - Environment* env = Environment::GetCurrent(args.GetIsolate()); + Environment* env = Environment::GetCurrent(args); if (args.Length() != 1 || !args[0]->IsString()) { // FIXME(bnoordhuis) ThrowTypeError? @@ -1619,7 +1619,7 @@ static void Chdir(const FunctionCallbackInfo& args) { static void Cwd(const FunctionCallbackInfo& args) { - Environment* env = Environment::GetCurrent(args.GetIsolate()); + Environment* env = Environment::GetCurrent(args); #ifdef _WIN32 /* MAX_PATH is in characters, not bytes. Make sure we have enough headroom. */ char buf[MAX_PATH * 4]; @@ -1642,7 +1642,7 @@ static void Cwd(const FunctionCallbackInfo& args) { static void Umask(const FunctionCallbackInfo& args) { - Environment* env = Environment::GetCurrent(args.GetIsolate()); + Environment* env = Environment::GetCurrent(args); uint32_t old; if (args.Length() < 1 || args[0]->IsUndefined()) { @@ -1790,7 +1790,7 @@ static void GetGid(const FunctionCallbackInfo& args) { static void SetGid(const FunctionCallbackInfo& args) { - Environment* env = Environment::GetCurrent(args.GetIsolate()); + Environment* env = Environment::GetCurrent(args); if (!args[0]->IsUint32() && !args[0]->IsString()) { return env->ThrowTypeError("setgid argument must be a number or a string"); @@ -1809,7 +1809,7 @@ static void SetGid(const FunctionCallbackInfo& args) { static void SetUid(const FunctionCallbackInfo& args) { - Environment* env = Environment::GetCurrent(args.GetIsolate()); + Environment* env = Environment::GetCurrent(args); if (!args[0]->IsUint32() && !args[0]->IsString()) { return env->ThrowTypeError("setuid argument must be a number or a string"); @@ -1828,7 +1828,7 @@ static void SetUid(const FunctionCallbackInfo& args) { static void GetGroups(const FunctionCallbackInfo& args) { - Environment* env = Environment::GetCurrent(args.GetIsolate()); + Environment* env = Environment::GetCurrent(args); int ngroups = getgroups(0, NULL); @@ -1866,7 +1866,7 @@ static void GetGroups(const FunctionCallbackInfo& args) { static void SetGroups(const FunctionCallbackInfo& args) { - Environment* env = Environment::GetCurrent(args.GetIsolate()); + Environment* env = Environment::GetCurrent(args); if (!args[0]->IsArray()) { return env->ThrowTypeError("argument 1 must be an array"); @@ -1897,7 +1897,7 @@ static void SetGroups(const FunctionCallbackInfo& args) { static void InitGroups(const FunctionCallbackInfo& args) { - Environment* env = Environment::GetCurrent(args.GetIsolate()); + Environment* env = Environment::GetCurrent(args); if (!args[0]->IsUint32() && !args[0]->IsString()) { return env->ThrowTypeError("argument 1 must be a number or a string"); @@ -1952,7 +1952,7 @@ void Exit(const FunctionCallbackInfo& args) { static void Uptime(const FunctionCallbackInfo& args) { - Environment* env = Environment::GetCurrent(args.GetIsolate()); + Environment* env = Environment::GetCurrent(args); double uptime; uv_update_time(env->event_loop()); @@ -1963,7 +1963,7 @@ static void Uptime(const FunctionCallbackInfo& args) { void MemoryUsage(const FunctionCallbackInfo& args) { - Environment* env = Environment::GetCurrent(args.GetIsolate()); + Environment* env = Environment::GetCurrent(args); size_t rss; int err = uv_resident_set_memory(&rss); @@ -1990,7 +1990,7 @@ void MemoryUsage(const FunctionCallbackInfo& args) { void Kill(const FunctionCallbackInfo& args) { - Environment* env = Environment::GetCurrent(args.GetIsolate()); + Environment* env = Environment::GetCurrent(args); if (args.Length() != 2) { return env->ThrowError("Bad argument."); @@ -2011,7 +2011,7 @@ void Kill(const FunctionCallbackInfo& args) { // and nanoseconds, to avoid any integer overflow possibility. // Pass in an Array from a previous hrtime() call to instead get a time diff. void Hrtime(const FunctionCallbackInfo& args) { - Environment* env = Environment::GetCurrent(args.GetIsolate()); + Environment* env = Environment::GetCurrent(args); uint64_t t = uv_hrtime(); @@ -2066,7 +2066,7 @@ typedef void (UV_DYNAMIC* extInit)(Handle exports); // when two contexts try to load the same shared object. Maybe have a shadow // cache that's a plain C list or hash table that's shared across contexts? void DLOpen(const FunctionCallbackInfo& args) { - Environment* env = Environment::GetCurrent(args.GetIsolate()); + Environment* env = Environment::GetCurrent(args); struct node_module* mp; uv_lib_t lib; @@ -2209,7 +2209,7 @@ void OnMessage(Handle message, Handle error) { static void Binding(const FunctionCallbackInfo& args) { - Environment* env = Environment::GetCurrent(args.GetIsolate()); + Environment* env = Environment::GetCurrent(args); Local module = args[0]->ToString(); node::Utf8Value module_v(module); @@ -2573,13 +2573,13 @@ void StopProfilerIdleNotifier(Environment* env) { void StartProfilerIdleNotifier(const FunctionCallbackInfo& args) { - Environment* env = Environment::GetCurrent(args.GetIsolate()); + Environment* env = Environment::GetCurrent(args); StartProfilerIdleNotifier(env); } void StopProfilerIdleNotifier(const FunctionCallbackInfo& args) { - Environment* env = Environment::GetCurrent(args.GetIsolate()); + Environment* env = Environment::GetCurrent(args); StopProfilerIdleNotifier(env); } @@ -2758,51 +2758,51 @@ void SetupProcessObject(Environment* env, DebugPortSetter); // define various internal methods - NODE_SET_METHOD(process, - "_startProfilerIdleNotifier", - StartProfilerIdleNotifier); - NODE_SET_METHOD(process, - "_stopProfilerIdleNotifier", - StopProfilerIdleNotifier); - NODE_SET_METHOD(process, "_getActiveRequests", GetActiveRequests); - NODE_SET_METHOD(process, "_getActiveHandles", GetActiveHandles); - NODE_SET_METHOD(process, "reallyExit", Exit); - NODE_SET_METHOD(process, "abort", Abort); - NODE_SET_METHOD(process, "chdir", Chdir); - NODE_SET_METHOD(process, "cwd", Cwd); - - NODE_SET_METHOD(process, "umask", Umask); + env->SetMethod(process, + "_startProfilerIdleNotifier", + StartProfilerIdleNotifier); + env->SetMethod(process, + "_stopProfilerIdleNotifier", + StopProfilerIdleNotifier); + env->SetMethod(process, "_getActiveRequests", GetActiveRequests); + env->SetMethod(process, "_getActiveHandles", GetActiveHandles); + env->SetMethod(process, "reallyExit", Exit); + env->SetMethod(process, "abort", Abort); + env->SetMethod(process, "chdir", Chdir); + env->SetMethod(process, "cwd", Cwd); + + env->SetMethod(process, "umask", Umask); #if defined(__POSIX__) && !defined(__ANDROID__) - NODE_SET_METHOD(process, "getuid", GetUid); - NODE_SET_METHOD(process, "setuid", SetUid); + env->SetMethod(process, "getuid", GetUid); + env->SetMethod(process, "setuid", SetUid); - NODE_SET_METHOD(process, "setgid", SetGid); - NODE_SET_METHOD(process, "getgid", GetGid); + env->SetMethod(process, "setgid", SetGid); + env->SetMethod(process, "getgid", GetGid); - NODE_SET_METHOD(process, "getgroups", GetGroups); - NODE_SET_METHOD(process, "setgroups", SetGroups); - NODE_SET_METHOD(process, "initgroups", InitGroups); + env->SetMethod(process, "getgroups", GetGroups); + env->SetMethod(process, "setgroups", SetGroups); + env->SetMethod(process, "initgroups", InitGroups); #endif // __POSIX__ && !defined(__ANDROID__) - NODE_SET_METHOD(process, "_kill", Kill); + env->SetMethod(process, "_kill", Kill); - NODE_SET_METHOD(process, "_debugProcess", DebugProcess); - NODE_SET_METHOD(process, "_debugPause", DebugPause); - NODE_SET_METHOD(process, "_debugEnd", DebugEnd); + env->SetMethod(process, "_debugProcess", DebugProcess); + env->SetMethod(process, "_debugPause", DebugPause); + env->SetMethod(process, "_debugEnd", DebugEnd); - NODE_SET_METHOD(process, "hrtime", Hrtime); + env->SetMethod(process, "hrtime", Hrtime); - NODE_SET_METHOD(process, "dlopen", DLOpen); + env->SetMethod(process, "dlopen", DLOpen); - NODE_SET_METHOD(process, "uptime", Uptime); - NODE_SET_METHOD(process, "memoryUsage", MemoryUsage); + env->SetMethod(process, "uptime", Uptime); + env->SetMethod(process, "memoryUsage", MemoryUsage); - NODE_SET_METHOD(process, "binding", Binding); + env->SetMethod(process, "binding", Binding); - NODE_SET_METHOD(process, "_setupAsyncListener", SetupAsyncListener); - NODE_SET_METHOD(process, "_setupNextTick", SetupNextTick); - NODE_SET_METHOD(process, "_setupDomainUse", SetupDomainUse); + env->SetMethod(process, "_setupAsyncListener", SetupAsyncListener); + env->SetMethod(process, "_setupNextTick", SetupNextTick); + env->SetMethod(process, "_setupDomainUse", SetupDomainUse); // pre-set _events object for faster emit checks process->Set(env->events_string(), Object::New(env->isolate())); @@ -2892,7 +2892,7 @@ void LoadEnvironment(Environment* env) { // thrown during process startup. try_catch.SetVerbose(true); - NODE_SET_METHOD(env->process_object(), "_rawDebug", RawDebug); + env->SetMethod(env->process_object(), "_rawDebug", RawDebug); Local arg = env->process_object(); f->Call(global, 1, &arg); @@ -3194,7 +3194,7 @@ static void RegisterSignalHandler(int signal, void DebugProcess(const FunctionCallbackInfo& args) { - Environment* env = Environment::GetCurrent(args.GetIsolate()); + Environment* env = Environment::GetCurrent(args); if (args.Length() != 1) { return env->ThrowError("Invalid number of arguments."); @@ -3281,8 +3281,8 @@ static int RegisterDebugSignalHandler() { static void DebugProcess(const FunctionCallbackInfo& args) { + Environment* env = Environment::GetCurrent(args); Isolate* isolate = args.GetIsolate(); - Environment* env = Environment::GetCurrent(isolate); DWORD pid; HANDLE process = NULL; HANDLE thread = NULL; @@ -3377,7 +3377,7 @@ static void DebugPause(const FunctionCallbackInfo& args) { static void DebugEnd(const FunctionCallbackInfo& args) { if (debugger_running) { - Environment* env = Environment::GetCurrent(args.GetIsolate()); + Environment* env = Environment::GetCurrent(args); env->debugger_agent()->Stop(); debugger_running = false; } diff --git a/src/node_buffer.cc b/src/node_buffer.cc index 90c0eb5750..4df6217b28 100644 --- a/src/node_buffer.cc +++ b/src/node_buffer.cc @@ -254,7 +254,7 @@ Local Use(Environment* env, char* data, uint32_t length) { template void StringSlice(const FunctionCallbackInfo& args) { - Environment* env = Environment::GetCurrent(args.GetIsolate()); + Environment* env = Environment::GetCurrent(args); ARGS_THIS(args.This()) SLICE_START_END(args[0], args[1], obj_length) @@ -296,7 +296,7 @@ void Base64Slice(const FunctionCallbackInfo& args) { // bytesCopied = buffer.copy(target[, targetStart][, sourceStart][, sourceEnd]); void Copy(const FunctionCallbackInfo &args) { - Environment* env = Environment::GetCurrent(args.GetIsolate()); + Environment* env = Environment::GetCurrent(args); Local target = args[0]->ToObject(); @@ -376,7 +376,7 @@ void Fill(const FunctionCallbackInfo& args) { template void StringWrite(const FunctionCallbackInfo& args) { - Environment* env = Environment::GetCurrent(args.GetIsolate()); + Environment* env = Environment::GetCurrent(args); ARGS_THIS(args.This()) @@ -540,7 +540,7 @@ void WriteDoubleBE(const FunctionCallbackInfo& args) { void ByteLength(const FunctionCallbackInfo &args) { - Environment* env = Environment::GetCurrent(args.GetIsolate()); + Environment* env = Environment::GetCurrent(args); if (!args[0]->IsString()) return env->ThrowTypeError("Argument must be a string"); @@ -588,7 +588,7 @@ void Compare(const FunctionCallbackInfo &args) { // pass Buffer object to load prototype methods void SetupBufferJS(const FunctionCallbackInfo& args) { - Environment* env = Environment::GetCurrent(args.GetIsolate()); + Environment* env = Environment::GetCurrent(args); CHECK(args[0]->IsFunction()); @@ -600,21 +600,21 @@ void SetupBufferJS(const FunctionCallbackInfo& args) { Local proto = proto_v.As(); - NODE_SET_METHOD(proto, "asciiSlice", AsciiSlice); - NODE_SET_METHOD(proto, "base64Slice", Base64Slice); - NODE_SET_METHOD(proto, "binarySlice", BinarySlice); - NODE_SET_METHOD(proto, "hexSlice", HexSlice); - NODE_SET_METHOD(proto, "ucs2Slice", Ucs2Slice); - NODE_SET_METHOD(proto, "utf8Slice", Utf8Slice); + env->SetMethod(proto, "asciiSlice", AsciiSlice); + env->SetMethod(proto, "base64Slice", Base64Slice); + env->SetMethod(proto, "binarySlice", BinarySlice); + env->SetMethod(proto, "hexSlice", HexSlice); + env->SetMethod(proto, "ucs2Slice", Ucs2Slice); + env->SetMethod(proto, "utf8Slice", Utf8Slice); - NODE_SET_METHOD(proto, "asciiWrite", AsciiWrite); - NODE_SET_METHOD(proto, "base64Write", Base64Write); - NODE_SET_METHOD(proto, "binaryWrite", BinaryWrite); - NODE_SET_METHOD(proto, "hexWrite", HexWrite); - NODE_SET_METHOD(proto, "ucs2Write", Ucs2Write); - NODE_SET_METHOD(proto, "utf8Write", Utf8Write); + env->SetMethod(proto, "asciiWrite", AsciiWrite); + env->SetMethod(proto, "base64Write", Base64Write); + env->SetMethod(proto, "binaryWrite", BinaryWrite); + env->SetMethod(proto, "hexWrite", HexWrite); + env->SetMethod(proto, "ucs2Write", Ucs2Write); + env->SetMethod(proto, "utf8Write", Utf8Write); - NODE_SET_METHOD(proto, "copy", Copy); + env->SetMethod(proto, "copy", Copy); // for backwards compatibility proto->ForceSet(env->offset_string(), @@ -626,19 +626,19 @@ void SetupBufferJS(const FunctionCallbackInfo& args) { Local internal = args[1].As(); ASSERT(internal->IsObject()); - NODE_SET_METHOD(internal, "byteLength", ByteLength); - NODE_SET_METHOD(internal, "compare", Compare); - NODE_SET_METHOD(internal, "fill", Fill); + env->SetMethod(internal, "byteLength", ByteLength); + env->SetMethod(internal, "compare", Compare); + env->SetMethod(internal, "fill", Fill); - NODE_SET_METHOD(internal, "readDoubleBE", ReadDoubleBE); - NODE_SET_METHOD(internal, "readDoubleLE", ReadDoubleLE); - NODE_SET_METHOD(internal, "readFloatBE", ReadFloatBE); - NODE_SET_METHOD(internal, "readFloatLE", ReadFloatLE); + env->SetMethod(internal, "readDoubleBE", ReadDoubleBE); + env->SetMethod(internal, "readDoubleLE", ReadDoubleLE); + env->SetMethod(internal, "readFloatBE", ReadFloatBE); + env->SetMethod(internal, "readFloatLE", ReadFloatLE); - NODE_SET_METHOD(internal, "writeDoubleBE", WriteDoubleBE); - NODE_SET_METHOD(internal, "writeDoubleLE", WriteDoubleLE); - NODE_SET_METHOD(internal, "writeFloatBE", WriteFloatBE); - NODE_SET_METHOD(internal, "writeFloatLE", WriteFloatLE); + env->SetMethod(internal, "writeDoubleBE", WriteDoubleBE); + env->SetMethod(internal, "writeDoubleLE", WriteDoubleLE); + env->SetMethod(internal, "writeFloatBE", WriteFloatBE); + env->SetMethod(internal, "writeFloatLE", WriteFloatLE); } @@ -647,8 +647,7 @@ void Initialize(Handle target, Handle context) { Environment* env = Environment::GetCurrent(context); target->Set(FIXED_ONE_BYTE_STRING(env->isolate(), "setupBufferJS"), - FunctionTemplate::New(env->isolate(), SetupBufferJS) - ->GetFunction()); + env->NewFunctionTemplate(SetupBufferJS)->GetFunction()); } diff --git a/src/node_contextify.cc b/src/node_contextify.cc index 89217386ad..ce9d720689 100644 --- a/src/node_contextify.cc +++ b/src/node_contextify.cc @@ -246,9 +246,9 @@ class ContextifyContext { function_template->InstanceTemplate()->SetInternalFieldCount(1); env->set_script_data_constructor_function(function_template->GetFunction()); - NODE_SET_METHOD(target, "runInDebugContext", RunInDebugContext); - NODE_SET_METHOD(target, "makeContext", MakeContext); - NODE_SET_METHOD(target, "isContext", IsContext); + env->SetMethod(target, "runInDebugContext", RunInDebugContext); + env->SetMethod(target, "makeContext", MakeContext); + env->SetMethod(target, "isContext", IsContext); } @@ -265,7 +265,7 @@ class ContextifyContext { static void MakeContext(const FunctionCallbackInfo& args) { - Environment* env = Environment::GetCurrent(args.GetIsolate()); + Environment* env = Environment::GetCurrent(args); if (!args[0]->IsObject()) { return env->ThrowTypeError("sandbox argument must be an object."); @@ -295,7 +295,7 @@ class ContextifyContext { static void IsContext(const FunctionCallbackInfo& args) { - Environment* env = Environment::GetCurrent(args.GetIsolate()); + Environment* env = Environment::GetCurrent(args); if (!args[0]->IsObject()) { env->ThrowTypeError("sandbox must be an object"); @@ -453,14 +453,11 @@ class ContextifyScript : public BaseObject { Local class_name = FIXED_ONE_BYTE_STRING(env->isolate(), "ContextifyScript"); - Local script_tmpl = FunctionTemplate::New(env->isolate(), - New); + Local script_tmpl = env->NewFunctionTemplate(New); script_tmpl->InstanceTemplate()->SetInternalFieldCount(1); script_tmpl->SetClassName(class_name); - NODE_SET_PROTOTYPE_METHOD(script_tmpl, "runInContext", RunInContext); - NODE_SET_PROTOTYPE_METHOD(script_tmpl, - "runInThisContext", - RunInThisContext); + env->SetProtoMethod(script_tmpl, "runInContext", RunInContext); + env->SetProtoMethod(script_tmpl, "runInThisContext", RunInThisContext); target->Set(class_name, script_tmpl->GetFunction()); env->set_script_context_constructor_template(script_tmpl); @@ -469,7 +466,7 @@ class ContextifyScript : public BaseObject { // args: code, [options] static void New(const FunctionCallbackInfo& args) { - Environment* env = Environment::GetCurrent(args.GetIsolate()); + Environment* env = Environment::GetCurrent(args); if (!args.IsConstructCall()) { return env->ThrowError("Must call vm.Script as a constructor."); @@ -511,8 +508,6 @@ class ContextifyScript : public BaseObject { // args: [options] static void RunInThisContext(const FunctionCallbackInfo& args) { - Isolate* isolate = args.GetIsolate(); - // Assemble arguments TryCatch try_catch; uint64_t timeout = GetTimeoutArg(args, 0); @@ -523,13 +518,13 @@ class ContextifyScript : public BaseObject { } // Do the eval within this context - Environment* env = Environment::GetCurrent(isolate); + Environment* env = Environment::GetCurrent(args); EvalMachine(env, timeout, display_errors, args, try_catch); } // args: sandbox, [options] static void RunInContext(const FunctionCallbackInfo& args) { - Environment* env = Environment::GetCurrent(args.GetIsolate()); + Environment* env = Environment::GetCurrent(args); int64_t timeout; bool display_errors; diff --git a/src/node_counters.cc b/src/node_counters.cc index ae2d5a4f81..82bfa07808 100644 --- a/src/node_counters.cc +++ b/src/node_counters.cc @@ -122,8 +122,7 @@ void InitPerfCounters(Environment* env, Handle target) { for (int i = 0; i < ARRAY_SIZE(tab); i++) { Local key = OneByteString(env->isolate(), tab[i].name); - Local val = - FunctionTemplate::New(env->isolate(), tab[i].func)->GetFunction(); + Local val = env->NewFunctionTemplate(tab[i].func)->GetFunction(); target->Set(key, val); } diff --git a/src/node_crypto.cc b/src/node_crypto.cc index 854fc156f4..5d295df7cb 100644 --- a/src/node_crypto.cc +++ b/src/node_crypto.cc @@ -257,35 +257,30 @@ bool EntropySource(unsigned char* buffer, size_t length) { void SecureContext::Initialize(Environment* env, Handle target) { - Local t = FunctionTemplate::New(env->isolate(), - SecureContext::New); + Local t = env->NewFunctionTemplate(SecureContext::New); t->InstanceTemplate()->SetInternalFieldCount(1); t->SetClassName(FIXED_ONE_BYTE_STRING(env->isolate(), "SecureContext")); - NODE_SET_PROTOTYPE_METHOD(t, "init", SecureContext::Init); - NODE_SET_PROTOTYPE_METHOD(t, "setKey", SecureContext::SetKey); - NODE_SET_PROTOTYPE_METHOD(t, "setCert", SecureContext::SetCert); - NODE_SET_PROTOTYPE_METHOD(t, "addCACert", SecureContext::AddCACert); - NODE_SET_PROTOTYPE_METHOD(t, "addCRL", SecureContext::AddCRL); - NODE_SET_PROTOTYPE_METHOD(t, "addRootCerts", SecureContext::AddRootCerts); - NODE_SET_PROTOTYPE_METHOD(t, "setCiphers", SecureContext::SetCiphers); - NODE_SET_PROTOTYPE_METHOD(t, "setECDHCurve", SecureContext::SetECDHCurve); - NODE_SET_PROTOTYPE_METHOD(t, "setDHParam", SecureContext::SetDHParam); - NODE_SET_PROTOTYPE_METHOD(t, "setOptions", SecureContext::SetOptions); - NODE_SET_PROTOTYPE_METHOD(t, "setSessionIdContext", - SecureContext::SetSessionIdContext); - NODE_SET_PROTOTYPE_METHOD(t, "setSessionTimeout", - SecureContext::SetSessionTimeout); - NODE_SET_PROTOTYPE_METHOD(t, "close", SecureContext::Close); - NODE_SET_PROTOTYPE_METHOD(t, "loadPKCS12", SecureContext::LoadPKCS12); - NODE_SET_PROTOTYPE_METHOD(t, "getTicketKeys", SecureContext::GetTicketKeys); - NODE_SET_PROTOTYPE_METHOD(t, "setTicketKeys", SecureContext::SetTicketKeys); - NODE_SET_PROTOTYPE_METHOD(t, - "getCertificate", - SecureContext::GetCertificate); - NODE_SET_PROTOTYPE_METHOD(t, - "getIssuer", - SecureContext::GetCertificate); + env->SetProtoMethod(t, "init", SecureContext::Init); + env->SetProtoMethod(t, "setKey", SecureContext::SetKey); + env->SetProtoMethod(t, "setCert", SecureContext::SetCert); + env->SetProtoMethod(t, "addCACert", SecureContext::AddCACert); + env->SetProtoMethod(t, "addCRL", SecureContext::AddCRL); + env->SetProtoMethod(t, "addRootCerts", SecureContext::AddRootCerts); + env->SetProtoMethod(t, "setCiphers", SecureContext::SetCiphers); + env->SetProtoMethod(t, "setECDHCurve", SecureContext::SetECDHCurve); + env->SetProtoMethod(t, "setDHParam", SecureContext::SetDHParam); + env->SetProtoMethod(t, "setOptions", SecureContext::SetOptions); + env->SetProtoMethod(t, "setSessionIdContext", + SecureContext::SetSessionIdContext); + env->SetProtoMethod(t, "setSessionTimeout", + SecureContext::SetSessionTimeout); + env->SetProtoMethod(t, "close", SecureContext::Close); + env->SetProtoMethod(t, "loadPKCS12", SecureContext::LoadPKCS12); + env->SetProtoMethod(t, "getTicketKeys", SecureContext::GetTicketKeys); + env->SetProtoMethod(t, "setTicketKeys", SecureContext::SetTicketKeys); + env->SetProtoMethod(t, "getCertificate", SecureContext::GetCertificate); + env->SetProtoMethod(t, "getIssuer", SecureContext::GetCertificate); NODE_SET_EXTERNAL( t->PrototypeTemplate(), @@ -299,7 +294,7 @@ void SecureContext::Initialize(Environment* env, Handle target) { void SecureContext::New(const FunctionCallbackInfo& args) { - Environment* env = Environment::GetCurrent(args.GetIsolate()); + Environment* env = Environment::GetCurrent(args); new SecureContext(env, args.This()); } @@ -430,7 +425,7 @@ static X509* LoadX509(Environment* env, Handle v) { void SecureContext::SetKey(const FunctionCallbackInfo& args) { - Environment* env = Environment::GetCurrent(args.GetIsolate()); + Environment* env = Environment::GetCurrent(args); SecureContext* sc = Unwrap(args.Holder()); @@ -575,7 +570,7 @@ int SSL_CTX_use_certificate_chain(SSL_CTX* ctx, void SecureContext::SetCert(const FunctionCallbackInfo& args) { - Environment* env = Environment::GetCurrent(args.GetIsolate()); + Environment* env = Environment::GetCurrent(args); SecureContext* sc = Unwrap(args.Holder()); @@ -606,7 +601,7 @@ void SecureContext::SetCert(const FunctionCallbackInfo& args) { void SecureContext::AddCACert(const FunctionCallbackInfo& args) { bool newCAStore = false; - Environment* env = Environment::GetCurrent(args.GetIsolate()); + Environment* env = Environment::GetCurrent(args); SecureContext* sc = Unwrap(args.Holder()); @@ -635,7 +630,7 @@ void SecureContext::AddCACert(const FunctionCallbackInfo& args) { void SecureContext::AddCRL(const FunctionCallbackInfo& args) { - Environment* env = Environment::GetCurrent(args.GetIsolate()); + Environment* env = Environment::GetCurrent(args); SecureContext* sc = Unwrap(args.Holder()); @@ -835,7 +830,7 @@ void SecureContext::Close(const FunctionCallbackInfo& args) { // Takes .pfx or .p12 and password in string or buffer format void SecureContext::LoadPKCS12(const FunctionCallbackInfo& args) { - Environment* env = Environment::GetCurrent(args.GetIsolate()); + Environment* env = Environment::GetCurrent(args); BIO* in = NULL; PKCS12* p12 = NULL; @@ -974,32 +969,32 @@ template void SSLWrap::AddMethods(Environment* env, Handle t) { HandleScope scope(env->isolate()); - NODE_SET_PROTOTYPE_METHOD(t, "getPeerCertificate", GetPeerCertificate); - NODE_SET_PROTOTYPE_METHOD(t, "getSession", GetSession); - NODE_SET_PROTOTYPE_METHOD(t, "setSession", SetSession); - NODE_SET_PROTOTYPE_METHOD(t, "loadSession", LoadSession); - NODE_SET_PROTOTYPE_METHOD(t, "isSessionReused", IsSessionReused); - NODE_SET_PROTOTYPE_METHOD(t, "isInitFinished", IsInitFinished); - NODE_SET_PROTOTYPE_METHOD(t, "verifyError", VerifyError); - NODE_SET_PROTOTYPE_METHOD(t, "getCurrentCipher", GetCurrentCipher); - NODE_SET_PROTOTYPE_METHOD(t, "endParser", EndParser); - NODE_SET_PROTOTYPE_METHOD(t, "renegotiate", Renegotiate); - NODE_SET_PROTOTYPE_METHOD(t, "shutdown", Shutdown); - NODE_SET_PROTOTYPE_METHOD(t, "getTLSTicket", GetTLSTicket); - NODE_SET_PROTOTYPE_METHOD(t, "newSessionDone", NewSessionDone); - NODE_SET_PROTOTYPE_METHOD(t, "setOCSPResponse", SetOCSPResponse); - NODE_SET_PROTOTYPE_METHOD(t, "requestOCSP", RequestOCSP); + env->SetProtoMethod(t, "getPeerCertificate", GetPeerCertificate); + env->SetProtoMethod(t, "getSession", GetSession); + env->SetProtoMethod(t, "setSession", SetSession); + env->SetProtoMethod(t, "loadSession", LoadSession); + env->SetProtoMethod(t, "isSessionReused", IsSessionReused); + env->SetProtoMethod(t, "isInitFinished", IsInitFinished); + env->SetProtoMethod(t, "verifyError", VerifyError); + env->SetProtoMethod(t, "getCurrentCipher", GetCurrentCipher); + env->SetProtoMethod(t, "endParser", EndParser); + env->SetProtoMethod(t, "renegotiate", Renegotiate); + env->SetProtoMethod(t, "shutdown", Shutdown); + env->SetProtoMethod(t, "getTLSTicket", GetTLSTicket); + env->SetProtoMethod(t, "newSessionDone", NewSessionDone); + env->SetProtoMethod(t, "setOCSPResponse", SetOCSPResponse); + env->SetProtoMethod(t, "requestOCSP", RequestOCSP); #ifdef SSL_set_max_send_fragment - NODE_SET_PROTOTYPE_METHOD(t, "setMaxSendFragment", SetMaxSendFragment); + env->SetProtoMethod(t, "setMaxSendFragment", SetMaxSendFragment); #endif // SSL_set_max_send_fragment #ifdef OPENSSL_NPN_NEGOTIATED - NODE_SET_PROTOTYPE_METHOD(t, "getNegotiatedProtocol", GetNegotiatedProto); + env->SetProtoMethod(t, "getNegotiatedProtocol", GetNegotiatedProto); #endif // OPENSSL_NPN_NEGOTIATED #ifdef OPENSSL_NPN_NEGOTIATED - NODE_SET_PROTOTYPE_METHOD(t, "setNPNProtocols", SetNPNProtocols); + env->SetProtoMethod(t, "setNPNProtocols", SetNPNProtocols); #endif NODE_SET_EXTERNAL( @@ -1377,7 +1372,7 @@ void SSLWrap::GetPeerCertificate( template void SSLWrap::GetSession(const FunctionCallbackInfo& args) { - Environment* env = Environment::GetCurrent(args.GetIsolate()); + Environment* env = Environment::GetCurrent(args); Base* w = Unwrap(args.Holder()); @@ -1398,7 +1393,7 @@ void SSLWrap::GetSession(const FunctionCallbackInfo& args) { template void SSLWrap::SetSession(const FunctionCallbackInfo& args) { - Environment* env = Environment::GetCurrent(args.GetIsolate()); + Environment* env = Environment::GetCurrent(args); Base* w = Unwrap(args.Holder()); @@ -1993,26 +1988,25 @@ void Connection::NewSessionDoneCb() { void Connection::Initialize(Environment* env, Handle target) { - Local t = FunctionTemplate::New(env->isolate(), - Connection::New); + Local t = env->NewFunctionTemplate(Connection::New); t->InstanceTemplate()->SetInternalFieldCount(1); t->SetClassName(FIXED_ONE_BYTE_STRING(env->isolate(), "Connection")); - NODE_SET_PROTOTYPE_METHOD(t, "encIn", Connection::EncIn); - NODE_SET_PROTOTYPE_METHOD(t, "clearOut", Connection::ClearOut); - NODE_SET_PROTOTYPE_METHOD(t, "clearIn", Connection::ClearIn); - NODE_SET_PROTOTYPE_METHOD(t, "encOut", Connection::EncOut); - NODE_SET_PROTOTYPE_METHOD(t, "clearPending", Connection::ClearPending); - NODE_SET_PROTOTYPE_METHOD(t, "encPending", Connection::EncPending); - NODE_SET_PROTOTYPE_METHOD(t, "start", Connection::Start); - NODE_SET_PROTOTYPE_METHOD(t, "close", Connection::Close); + env->SetProtoMethod(t, "encIn", Connection::EncIn); + env->SetProtoMethod(t, "clearOut", Connection::ClearOut); + env->SetProtoMethod(t, "clearIn", Connection::ClearIn); + env->SetProtoMethod(t, "encOut", Connection::EncOut); + env->SetProtoMethod(t, "clearPending", Connection::ClearPending); + env->SetProtoMethod(t, "encPending", Connection::EncPending); + env->SetProtoMethod(t, "start", Connection::Start); + env->SetProtoMethod(t, "close", Connection::Close); SSLWrap::AddMethods(env, t); #ifdef SSL_CTRL_SET_TLSEXT_SERVERNAME_CB - NODE_SET_PROTOTYPE_METHOD(t, "getServername", Connection::GetServername); - NODE_SET_PROTOTYPE_METHOD(t, "setSNICallback", Connection::SetSNICallback); + env->SetProtoMethod(t, "getServername", Connection::GetServername); + env->SetProtoMethod(t, "setSNICallback", Connection::SetSNICallback); #endif target->Set(FIXED_ONE_BYTE_STRING(env->isolate(), "Connection"), @@ -2104,7 +2098,7 @@ int Connection::SelectSNIContextCallback_(SSL *s, int *ad, void* arg) { #endif void Connection::New(const FunctionCallbackInfo& args) { - Environment* env = Environment::GetCurrent(args.GetIsolate()); + Environment* env = Environment::GetCurrent(args); if (args.Length() < 1 || !args[0]->IsObject()) { env->ThrowError("First argument must be a tls module SecureContext"); @@ -2458,18 +2452,18 @@ void Connection::SetSNICallback(const FunctionCallbackInfo& args) { void CipherBase::Initialize(Environment* env, Handle target) { - Local t = FunctionTemplate::New(env->isolate(), New); + Local t = env->NewFunctionTemplate(New); t->InstanceTemplate()->SetInternalFieldCount(1); - NODE_SET_PROTOTYPE_METHOD(t, "init", Init); - NODE_SET_PROTOTYPE_METHOD(t, "initiv", InitIv); - NODE_SET_PROTOTYPE_METHOD(t, "update", Update); - NODE_SET_PROTOTYPE_METHOD(t, "final", Final); - NODE_SET_PROTOTYPE_METHOD(t, "setAutoPadding", SetAutoPadding); - NODE_SET_PROTOTYPE_METHOD(t, "getAuthTag", GetAuthTag); - NODE_SET_PROTOTYPE_METHOD(t, "setAuthTag", SetAuthTag); - NODE_SET_PROTOTYPE_METHOD(t, "setAAD", SetAAD); + env->SetProtoMethod(t, "init", Init); + env->SetProtoMethod(t, "initiv", InitIv); + env->SetProtoMethod(t, "update", Update); + env->SetProtoMethod(t, "final", Final); + env->SetProtoMethod(t, "setAutoPadding", SetAutoPadding); + env->SetProtoMethod(t, "getAuthTag", GetAuthTag); + env->SetProtoMethod(t, "setAuthTag", SetAuthTag); + env->SetProtoMethod(t, "setAAD", SetAAD); target->Set(FIXED_ONE_BYTE_STRING(env->isolate(), "CipherBase"), t->GetFunction()); @@ -2479,7 +2473,7 @@ void CipherBase::Initialize(Environment* env, Handle target) { void CipherBase::New(const FunctionCallbackInfo& args) { CHECK_EQ(args.IsConstructCall(), true); CipherKind kind = args[0]->IsTrue() ? kCipher : kDecipher; - Environment* env = Environment::GetCurrent(args.GetIsolate()); + Environment* env = Environment::GetCurrent(args); new CipherBase(env, args.This(), kind); } @@ -2615,7 +2609,7 @@ bool CipherBase::GetAuthTag(char** out, unsigned int* out_len) const { void CipherBase::GetAuthTag(const FunctionCallbackInfo& args) { - Environment* env = Environment::GetCurrent(args.GetIsolate()); + Environment* env = Environment::GetCurrent(args); CipherBase* cipher = Unwrap(args.Holder()); char* out = NULL; @@ -2642,7 +2636,7 @@ bool CipherBase::SetAuthTag(const char* data, unsigned int len) { void CipherBase::SetAuthTag(const FunctionCallbackInfo& args) { - Environment* env = Environment::GetCurrent(args.GetIsolate()); + Environment* env = Environment::GetCurrent(args); Local buf = args[0].As(); if (!buf->IsObject() || !Buffer::HasInstance(buf)) @@ -2671,7 +2665,7 @@ bool CipherBase::SetAAD(const char* data, unsigned int len) { void CipherBase::SetAAD(const FunctionCallbackInfo& args) { - Environment* env = Environment::GetCurrent(args.GetIsolate()); + Environment* env = Environment::GetCurrent(args); ASSERT_IS_BUFFER(args[0]); @@ -2710,7 +2704,7 @@ bool CipherBase::Update(const char* data, void CipherBase::Update(const FunctionCallbackInfo& args) { - Environment* env = Environment::GetCurrent(args.GetIsolate()); + Environment* env = Environment::GetCurrent(args); CipherBase* cipher = Unwrap(args.Holder()); @@ -2798,7 +2792,7 @@ bool CipherBase::Final(unsigned char** out, int *out_len) { void CipherBase::Final(const FunctionCallbackInfo& args) { - Environment* env = Environment::GetCurrent(args.GetIsolate()); + Environment* env = Environment::GetCurrent(args); CipherBase* cipher = Unwrap(args.Holder()); @@ -2830,20 +2824,20 @@ void CipherBase::Final(const FunctionCallbackInfo& args) { void Hmac::Initialize(Environment* env, v8::Handle target) { - Local t = FunctionTemplate::New(env->isolate(), New); + Local t = env->NewFunctionTemplate(New); t->InstanceTemplate()->SetInternalFieldCount(1); - NODE_SET_PROTOTYPE_METHOD(t, "init", HmacInit); - NODE_SET_PROTOTYPE_METHOD(t, "update", HmacUpdate); - NODE_SET_PROTOTYPE_METHOD(t, "digest", HmacDigest); + env->SetProtoMethod(t, "init", HmacInit); + env->SetProtoMethod(t, "update", HmacUpdate); + env->SetProtoMethod(t, "digest", HmacDigest); target->Set(FIXED_ONE_BYTE_STRING(env->isolate(), "Hmac"), t->GetFunction()); } void Hmac::New(const FunctionCallbackInfo& args) { - Environment* env = Environment::GetCurrent(args.GetIsolate()); + Environment* env = Environment::GetCurrent(args); new Hmac(env, args.This()); } @@ -2892,7 +2886,7 @@ bool Hmac::HmacUpdate(const char* data, int len) { void Hmac::HmacUpdate(const FunctionCallbackInfo& args) { - Environment* env = Environment::GetCurrent(args.GetIsolate()); + Environment* env = Environment::GetCurrent(args); Hmac* hmac = Unwrap(args.Holder()); @@ -2938,7 +2932,7 @@ bool Hmac::HmacDigest(unsigned char** md_value, unsigned int* md_len) { void Hmac::HmacDigest(const FunctionCallbackInfo& args) { - Environment* env = Environment::GetCurrent(args.GetIsolate()); + Environment* env = Environment::GetCurrent(args); Hmac* hmac = Unwrap(args.Holder()); @@ -2966,19 +2960,19 @@ void Hmac::HmacDigest(const FunctionCallbackInfo& args) { void Hash::Initialize(Environment* env, v8::Handle target) { - Local t = FunctionTemplate::New(env->isolate(), New); + Local t = env->NewFunctionTemplate(New); t->InstanceTemplate()->SetInternalFieldCount(1); - NODE_SET_PROTOTYPE_METHOD(t, "update", HashUpdate); - NODE_SET_PROTOTYPE_METHOD(t, "digest", HashDigest); + env->SetProtoMethod(t, "update", HashUpdate); + env->SetProtoMethod(t, "digest", HashDigest); target->Set(FIXED_ONE_BYTE_STRING(env->isolate(), "Hash"), t->GetFunction()); } void Hash::New(const FunctionCallbackInfo& args) { - Environment* env = Environment::GetCurrent(args.GetIsolate()); + Environment* env = Environment::GetCurrent(args); if (args.Length() == 0 || !args[0]->IsString()) { return env->ThrowError("Must give hashtype string as argument"); @@ -3014,7 +3008,7 @@ bool Hash::HashUpdate(const char* data, int len) { void Hash::HashUpdate(const FunctionCallbackInfo& args) { - Environment* env = Environment::GetCurrent(args.GetIsolate()); + Environment* env = Environment::GetCurrent(args); Hash* hash = Unwrap(args.Holder()); @@ -3049,7 +3043,7 @@ void Hash::HashUpdate(const FunctionCallbackInfo& args) { void Hash::HashDigest(const FunctionCallbackInfo& args) { - Environment* env = Environment::GetCurrent(args.GetIsolate()); + Environment* env = Environment::GetCurrent(args); Hash* hash = Unwrap(args.Holder()); @@ -3118,20 +3112,20 @@ void SignBase::CheckThrow(SignBase::Error error) { void Sign::Initialize(Environment* env, v8::Handle target) { - Local t = FunctionTemplate::New(env->isolate(), New); + Local t = env->NewFunctionTemplate(New); t->InstanceTemplate()->SetInternalFieldCount(1); - NODE_SET_PROTOTYPE_METHOD(t, "init", SignInit); - NODE_SET_PROTOTYPE_METHOD(t, "update", SignUpdate); - NODE_SET_PROTOTYPE_METHOD(t, "sign", SignFinal); + env->SetProtoMethod(t, "init", SignInit); + env->SetProtoMethod(t, "update", SignUpdate); + env->SetProtoMethod(t, "sign", SignFinal); target->Set(FIXED_ONE_BYTE_STRING(env->isolate(), "Sign"), t->GetFunction()); } void Sign::New(const FunctionCallbackInfo& args) { - Environment* env = Environment::GetCurrent(args.GetIsolate()); + Environment* env = Environment::GetCurrent(args); new Sign(env, args.This()); } @@ -3173,7 +3167,7 @@ SignBase::Error Sign::SignUpdate(const char* data, int len) { void Sign::SignUpdate(const FunctionCallbackInfo& args) { - Environment* env = Environment::GetCurrent(args.GetIsolate()); + Environment* env = Environment::GetCurrent(args); Sign* sign = Unwrap(args.Holder()); @@ -3249,7 +3243,7 @@ SignBase::Error Sign::SignFinal(const char* key_pem, void Sign::SignFinal(const FunctionCallbackInfo& args) { - Environment* env = Environment::GetCurrent(args.GetIsolate()); + Environment* env = Environment::GetCurrent(args); Sign* sign = Unwrap(args.Holder()); @@ -3294,13 +3288,13 @@ void Sign::SignFinal(const FunctionCallbackInfo& args) { void Verify::Initialize(Environment* env, v8::Handle target) { - Local t = FunctionTemplate::New(env->isolate(), New); + Local t = env->NewFunctionTemplate(New); t->InstanceTemplate()->SetInternalFieldCount(1); - NODE_SET_PROTOTYPE_METHOD(t, "init", VerifyInit); - NODE_SET_PROTOTYPE_METHOD(t, "update", VerifyUpdate); - NODE_SET_PROTOTYPE_METHOD(t, "verify", VerifyFinal); + env->SetProtoMethod(t, "init", VerifyInit); + env->SetProtoMethod(t, "update", VerifyUpdate); + env->SetProtoMethod(t, "verify", VerifyFinal); target->Set(FIXED_ONE_BYTE_STRING(env->isolate(), "Verify"), t->GetFunction()); @@ -3308,7 +3302,7 @@ void Verify::Initialize(Environment* env, v8::Handle target) { void Verify::New(const FunctionCallbackInfo& args) { - Environment* env = Environment::GetCurrent(args.GetIsolate()); + Environment* env = Environment::GetCurrent(args); new Verify(env, args.This()); } @@ -3352,7 +3346,7 @@ SignBase::Error Verify::VerifyUpdate(const char* data, int len) { void Verify::VerifyUpdate(const FunctionCallbackInfo& args) { - Environment* env = Environment::GetCurrent(args.GetIsolate()); + Environment* env = Environment::GetCurrent(args); Verify* verify = Unwrap(args.Holder()); @@ -3459,7 +3453,7 @@ SignBase::Error Verify::VerifyFinal(const char* key_pem, void Verify::VerifyFinal(const FunctionCallbackInfo& args) { - Environment* env = Environment::GetCurrent(args.GetIsolate()); + Environment* env = Environment::GetCurrent(args); Verify* verify = Unwrap(args.Holder()); @@ -3591,7 +3585,7 @@ template void PublicKeyCipher::Cipher(const FunctionCallbackInfo& args) { - Environment* env = Environment::GetCurrent(args.GetIsolate()); + Environment* env = Environment::GetCurrent(args); ASSERT_IS_BUFFER(args[0]); char* kbuf = Buffer::Data(args[0]); @@ -3635,21 +3629,21 @@ void PublicKeyCipher::Cipher(const FunctionCallbackInfo& args) { void DiffieHellman::Initialize(Environment* env, Handle target) { - Local t = FunctionTemplate::New(env->isolate(), New); + Local t = env->NewFunctionTemplate(New); static enum PropertyAttribute attributes = static_cast(v8::ReadOnly | v8::DontDelete); t->InstanceTemplate()->SetInternalFieldCount(1); - NODE_SET_PROTOTYPE_METHOD(t, "generateKeys", GenerateKeys); - NODE_SET_PROTOTYPE_METHOD(t, "computeSecret", ComputeSecret); - NODE_SET_PROTOTYPE_METHOD(t, "getPrime", GetPrime); - NODE_SET_PROTOTYPE_METHOD(t, "getGenerator", GetGenerator); - NODE_SET_PROTOTYPE_METHOD(t, "getPublicKey", GetPublicKey); - NODE_SET_PROTOTYPE_METHOD(t, "getPrivateKey", GetPrivateKey); - NODE_SET_PROTOTYPE_METHOD(t, "setPublicKey", SetPublicKey); - NODE_SET_PROTOTYPE_METHOD(t, "setPrivateKey", SetPrivateKey); + env->SetProtoMethod(t, "generateKeys", GenerateKeys); + env->SetProtoMethod(t, "computeSecret", ComputeSecret); + env->SetProtoMethod(t, "getPrime", GetPrime); + env->SetProtoMethod(t, "getGenerator", GetGenerator); + env->SetProtoMethod(t, "getPublicKey", GetPublicKey); + env->SetProtoMethod(t, "getPrivateKey", GetPrivateKey); + env->SetProtoMethod(t, "setPublicKey", SetPublicKey); + env->SetProtoMethod(t, "setPrivateKey", SetPrivateKey); t->InstanceTemplate()->SetAccessor(env->verify_error_string(), DiffieHellman::VerifyErrorGetter, @@ -3661,16 +3655,15 @@ void DiffieHellman::Initialize(Environment* env, Handle target) { target->Set(FIXED_ONE_BYTE_STRING(env->isolate(), "DiffieHellman"), t->GetFunction()); - Local t2 = FunctionTemplate::New(env->isolate(), - DiffieHellmanGroup); + Local t2 = env->NewFunctionTemplate(DiffieHellmanGroup); t2->InstanceTemplate()->SetInternalFieldCount(1); - NODE_SET_PROTOTYPE_METHOD(t2, "generateKeys", GenerateKeys); - NODE_SET_PROTOTYPE_METHOD(t2, "computeSecret", ComputeSecret); - NODE_SET_PROTOTYPE_METHOD(t2, "getPrime", GetPrime); - NODE_SET_PROTOTYPE_METHOD(t2, "getGenerator", GetGenerator); - NODE_SET_PROTOTYPE_METHOD(t2, "getPublicKey", GetPublicKey); - NODE_SET_PROTOTYPE_METHOD(t2, "getPrivateKey", GetPrivateKey); + env->SetProtoMethod(t2, "generateKeys", GenerateKeys); + env->SetProtoMethod(t2, "computeSecret", ComputeSecret); + env->SetProtoMethod(t2, "getPrime", GetPrime); + env->SetProtoMethod(t2, "getGenerator", GetGenerator); + env->SetProtoMethod(t2, "getPublicKey", GetPublicKey); + env->SetProtoMethod(t2, "getPrivateKey", GetPrivateKey); t2->InstanceTemplate()->SetAccessor(env->verify_error_string(), DiffieHellman::VerifyErrorGetter, @@ -3723,7 +3716,7 @@ bool DiffieHellman::Init(const char* p, int p_len, const char* g, int g_len) { void DiffieHellman::DiffieHellmanGroup( const FunctionCallbackInfo& args) { - Environment* env = Environment::GetCurrent(args.GetIsolate()); + Environment* env = Environment::GetCurrent(args); DiffieHellman* diffieHellman = new DiffieHellman(env, args.This()); if (args.Length() != 1 || !args[0]->IsString()) { @@ -3753,7 +3746,7 @@ void DiffieHellman::DiffieHellmanGroup( void DiffieHellman::New(const FunctionCallbackInfo& args) { - Environment* env = Environment::GetCurrent(args.GetIsolate()); + Environment* env = Environment::GetCurrent(args); DiffieHellman* diffieHellman = new DiffieHellman(env, args.This()); bool initialized = false; @@ -3785,7 +3778,7 @@ void DiffieHellman::New(const FunctionCallbackInfo& args) { void DiffieHellman::GenerateKeys(const FunctionCallbackInfo& args) { - Environment* env = Environment::GetCurrent(args.GetIsolate()); + Environment* env = Environment::GetCurrent(args); DiffieHellman* diffieHellman = Unwrap(args.Holder()); @@ -3808,7 +3801,7 @@ void DiffieHellman::GenerateKeys(const FunctionCallbackInfo& args) { void DiffieHellman::GetPrime(const FunctionCallbackInfo& args) { - Environment* env = Environment::GetCurrent(args.GetIsolate()); + Environment* env = Environment::GetCurrent(args); DiffieHellman* diffieHellman = Unwrap(args.Holder()); @@ -3826,7 +3819,7 @@ void DiffieHellman::GetPrime(const FunctionCallbackInfo& args) { void DiffieHellman::GetGenerator(const FunctionCallbackInfo& args) { - Environment* env = Environment::GetCurrent(args.GetIsolate()); + Environment* env = Environment::GetCurrent(args); DiffieHellman* diffieHellman = Unwrap(args.Holder()); @@ -3844,7 +3837,7 @@ void DiffieHellman::GetGenerator(const FunctionCallbackInfo& args) { void DiffieHellman::GetPublicKey(const FunctionCallbackInfo& args) { - Environment* env = Environment::GetCurrent(args.GetIsolate()); + Environment* env = Environment::GetCurrent(args); DiffieHellman* diffieHellman = Unwrap(args.Holder()); @@ -3867,7 +3860,7 @@ void DiffieHellman::GetPublicKey(const FunctionCallbackInfo& args) { void DiffieHellman::GetPrivateKey(const FunctionCallbackInfo& args) { - Environment* env = Environment::GetCurrent(args.GetIsolate()); + Environment* env = Environment::GetCurrent(args); DiffieHellman* diffieHellman = Unwrap(args.Holder()); @@ -3890,7 +3883,7 @@ void DiffieHellman::GetPrivateKey(const FunctionCallbackInfo& args) { void DiffieHellman::ComputeSecret(const FunctionCallbackInfo& args) { - Environment* env = Environment::GetCurrent(args.GetIsolate()); + Environment* env = Environment::GetCurrent(args); DiffieHellman* diffieHellman = Unwrap(args.Holder()); @@ -4024,16 +4017,16 @@ bool DiffieHellman::VerifyContext() { void ECDH::Initialize(Environment* env, Handle target) { HandleScope scope(env->isolate()); - Local t = FunctionTemplate::New(env->isolate(), New); + Local t = env->NewFunctionTemplate(New); t->InstanceTemplate()->SetInternalFieldCount(1); - NODE_SET_PROTOTYPE_METHOD(t, "generateKeys", GenerateKeys); - NODE_SET_PROTOTYPE_METHOD(t, "computeSecret", ComputeSecret); - NODE_SET_PROTOTYPE_METHOD(t, "getPublicKey", GetPublicKey); - NODE_SET_PROTOTYPE_METHOD(t, "getPrivateKey", GetPrivateKey); - NODE_SET_PROTOTYPE_METHOD(t, "setPublicKey", SetPublicKey); - NODE_SET_PROTOTYPE_METHOD(t, "setPrivateKey", SetPrivateKey); + env->SetProtoMethod(t, "generateKeys", GenerateKeys); + env->SetProtoMethod(t, "computeSecret", ComputeSecret); + env->SetProtoMethod(t, "getPublicKey", GetPublicKey); + env->SetProtoMethod(t, "getPrivateKey", GetPrivateKey); + env->SetProtoMethod(t, "setPublicKey", SetPublicKey); + env->SetProtoMethod(t, "setPrivateKey", SetPrivateKey); target->Set(FIXED_ONE_BYTE_STRING(env->isolate(), "ECDH"), t->GetFunction()); @@ -4041,7 +4034,7 @@ void ECDH::Initialize(Environment* env, Handle target) { void ECDH::New(const FunctionCallbackInfo& args) { - Environment* env = Environment::GetCurrent(args.GetIsolate()); + Environment* env = Environment::GetCurrent(args); // TODO(indutny): Support raw curves? CHECK(args[0]->IsString()); @@ -4060,7 +4053,7 @@ void ECDH::New(const FunctionCallbackInfo& args) { void ECDH::GenerateKeys(const FunctionCallbackInfo& args) { - Environment* env = Environment::GetCurrent(args.GetIsolate()); + Environment* env = Environment::GetCurrent(args); ECDH* ecdh = Unwrap(args.Holder()); @@ -4101,7 +4094,7 @@ EC_POINT* ECDH::BufferToPoint(char* data, size_t len) { void ECDH::ComputeSecret(const FunctionCallbackInfo& args) { - Environment* env = Environment::GetCurrent(args.GetIsolate()); + Environment* env = Environment::GetCurrent(args); ASSERT_IS_BUFFER(args[0]); @@ -4130,7 +4123,7 @@ void ECDH::ComputeSecret(const FunctionCallbackInfo& args) { void ECDH::GetPublicKey(const FunctionCallbackInfo& args) { - Environment* env = Environment::GetCurrent(args.GetIsolate()); + Environment* env = Environment::GetCurrent(args); // Conversion form CHECK_EQ(args.Length(), 1); @@ -4168,7 +4161,7 @@ void ECDH::GetPublicKey(const FunctionCallbackInfo& args) { void ECDH::GetPrivateKey(const FunctionCallbackInfo& args) { - Environment* env = Environment::GetCurrent(args.GetIsolate()); + Environment* env = Environment::GetCurrent(args); ECDH* ecdh = Unwrap(args.Holder()); @@ -4195,7 +4188,7 @@ void ECDH::GetPrivateKey(const FunctionCallbackInfo& args) { void ECDH::SetPrivateKey(const FunctionCallbackInfo& args) { - Environment* env = Environment::GetCurrent(args.GetIsolate()); + Environment* env = Environment::GetCurrent(args); ECDH* ecdh = Unwrap(args.Holder()); @@ -4214,7 +4207,7 @@ void ECDH::SetPrivateKey(const FunctionCallbackInfo& args) { void ECDH::SetPublicKey(const FunctionCallbackInfo& args) { - Environment* env = Environment::GetCurrent(args.GetIsolate()); + Environment* env = Environment::GetCurrent(args); ECDH* ecdh = Unwrap(args.Holder()); @@ -4377,7 +4370,7 @@ void EIO_PBKDF2After(uv_work_t* work_req, int status) { void PBKDF2(const FunctionCallbackInfo& args) { - Environment* env = Environment::GetCurrent(args.GetIsolate()); + Environment* env = Environment::GetCurrent(args); const EVP_MD* digest = NULL; const char* type_error = NULL; @@ -4615,7 +4608,7 @@ void RandomBytesAfter(uv_work_t* work_req, int status) { template void RandomBytes(const FunctionCallbackInfo& args) { - Environment* env = Environment::GetCurrent(args.GetIsolate()); + Environment* env = Environment::GetCurrent(args); // maybe allow a buffer to write to? cuts down on object creation // when generating random data in a loop @@ -4656,7 +4649,7 @@ void RandomBytes(const FunctionCallbackInfo& args) { void GetSSLCiphers(const FunctionCallbackInfo& args) { - Environment* env = Environment::GetCurrent(args.GetIsolate()); + Environment* env = Environment::GetCurrent(args); SSL_CTX* ctx = SSL_CTX_new(TLSv1_server_method()); if (ctx == NULL) { @@ -4711,7 +4704,7 @@ static void array_push_back(const TypeName* md, void GetCiphers(const FunctionCallbackInfo& args) { - Environment* env = Environment::GetCurrent(args.GetIsolate()); + Environment* env = Environment::GetCurrent(args); CipherPushContext ctx(env); EVP_CIPHER_do_all_sorted(array_push_back, &ctx); args.GetReturnValue().Set(ctx.arr); @@ -4719,7 +4712,7 @@ void GetCiphers(const FunctionCallbackInfo& args) { void GetHashes(const FunctionCallbackInfo& args) { - Environment* env = Environment::GetCurrent(args.GetIsolate()); + Environment* env = Environment::GetCurrent(args); CipherPushContext ctx(env); EVP_MD_do_all_sorted(array_push_back, &ctx); args.GetReturnValue().Set(ctx.arr); @@ -4729,13 +4722,13 @@ void GetHashes(const FunctionCallbackInfo& args) { void Certificate::Initialize(Environment* env, Handle target) { HandleScope scope(env->isolate()); - Local t = FunctionTemplate::New(env->isolate(), New); + Local t = env->NewFunctionTemplate(New); t->InstanceTemplate()->SetInternalFieldCount(1); - NODE_SET_PROTOTYPE_METHOD(t, "verifySpkac", VerifySpkac); - NODE_SET_PROTOTYPE_METHOD(t, "exportPublicKey", ExportPublicKey); - NODE_SET_PROTOTYPE_METHOD(t, "exportChallenge", ExportChallenge); + env->SetProtoMethod(t, "verifySpkac", VerifySpkac); + env->SetProtoMethod(t, "exportPublicKey", ExportPublicKey); + env->SetProtoMethod(t, "exportChallenge", ExportChallenge); target->Set(FIXED_ONE_BYTE_STRING(env->isolate(), "Certificate"), t->GetFunction()); @@ -4743,7 +4736,7 @@ void Certificate::Initialize(Environment* env, Handle target) { void Certificate::New(const FunctionCallbackInfo& args) { - Environment* env = Environment::GetCurrent(args.GetIsolate()); + Environment* env = Environment::GetCurrent(args); new Certificate(env, args.This()); } @@ -4839,7 +4832,7 @@ const char* Certificate::ExportPublicKey(const char* data, int len) { void Certificate::ExportPublicKey(const FunctionCallbackInfo& args) { - Environment* env = Environment::GetCurrent(args.GetIsolate()); + Environment* env = Environment::GetCurrent(args); Certificate* certificate = Unwrap(args.Holder()); @@ -4882,7 +4875,7 @@ const char* Certificate::ExportChallenge(const char* data, int len) { void Certificate::ExportChallenge(const FunctionCallbackInfo& args) { - Environment* env = Environment::GetCurrent(args.GetIsolate()); + Environment* env = Environment::GetCurrent(args); Certificate* crt = Unwrap(args.Holder()); @@ -4939,7 +4932,7 @@ void InitCryptoOnce() { #ifndef OPENSSL_NO_ENGINE void SetEngine(const FunctionCallbackInfo& args) { - Environment* env = Environment::GetCurrent(args.GetIsolate()); + Environment* env = Environment::GetCurrent(args); CHECK(args.Length() >= 2 && args[0]->IsString()); unsigned int flags = args[1]->Uint32Value(); @@ -5001,24 +4994,22 @@ void InitCrypto(Handle target, Certificate::Initialize(env, target); #ifndef OPENSSL_NO_ENGINE - NODE_SET_METHOD(target, "setEngine", SetEngine); + env->SetMethod(target, "setEngine", SetEngine); #endif // !OPENSSL_NO_ENGINE - NODE_SET_METHOD(target, "PBKDF2", PBKDF2); - NODE_SET_METHOD(target, "randomBytes", RandomBytes); - NODE_SET_METHOD(target, "pseudoRandomBytes", RandomBytes); - NODE_SET_METHOD(target, "getSSLCiphers", GetSSLCiphers); - NODE_SET_METHOD(target, "getCiphers", GetCiphers); - NODE_SET_METHOD(target, "getHashes", GetHashes); - NODE_SET_METHOD(target, - "publicEncrypt", - PublicKeyCipher::Cipher); - NODE_SET_METHOD(target, - "privateDecrypt", - PublicKeyCipher::Cipher); + env->SetMethod(target, "PBKDF2", PBKDF2); + env->SetMethod(target, "randomBytes", RandomBytes); + env->SetMethod(target, "pseudoRandomBytes", RandomBytes); + env->SetMethod(target, "getSSLCiphers", GetSSLCiphers); + env->SetMethod(target, "getCiphers", GetCiphers); + env->SetMethod(target, "getHashes", GetHashes); + env->SetMethod(target, "publicEncrypt", + PublicKeyCipher::Cipher); + env->SetMethod(target, "privateDecrypt", + PublicKeyCipher::Cipher); } } // namespace crypto diff --git a/src/node_dtrace.cc b/src/node_dtrace.cc index ce31d483b0..2d8d32fc53 100644 --- a/src/node_dtrace.cc +++ b/src/node_dtrace.cc @@ -147,7 +147,7 @@ using v8::Value; void DTRACE_NET_SERVER_CONNECTION(const FunctionCallbackInfo& args) { if (!NODE_NET_SERVER_CONNECTION_ENABLED()) return; - Environment* env = Environment::GetCurrent(args.GetIsolate()); + Environment* env = Environment::GetCurrent(args); SLURP_CONNECTION(args[0], conn); NODE_NET_SERVER_CONNECTION(&conn, conn.remote, conn.port, conn.fd); } @@ -156,7 +156,7 @@ void DTRACE_NET_SERVER_CONNECTION(const FunctionCallbackInfo& args) { void DTRACE_NET_STREAM_END(const FunctionCallbackInfo& args) { if (!NODE_NET_STREAM_END_ENABLED()) return; - Environment* env = Environment::GetCurrent(args.GetIsolate()); + Environment* env = Environment::GetCurrent(args); SLURP_CONNECTION(args[0], conn); NODE_NET_STREAM_END(&conn, conn.remote, conn.port, conn.fd); } @@ -165,7 +165,7 @@ void DTRACE_NET_STREAM_END(const FunctionCallbackInfo& args) { void DTRACE_NET_SOCKET_READ(const FunctionCallbackInfo& args) { if (!NODE_NET_SOCKET_READ_ENABLED()) return; - Environment* env = Environment::GetCurrent(args.GetIsolate()); + Environment* env = Environment::GetCurrent(args); SLURP_CONNECTION(args[0], conn); if (!args[1]->IsNumber()) { @@ -180,7 +180,7 @@ void DTRACE_NET_SOCKET_READ(const FunctionCallbackInfo& args) { void DTRACE_NET_SOCKET_WRITE(const FunctionCallbackInfo& args) { if (!NODE_NET_SOCKET_WRITE_ENABLED()) return; - Environment* env = Environment::GetCurrent(args.GetIsolate()); + Environment* env = Environment::GetCurrent(args); SLURP_CONNECTION(args[0], conn); if (!args[1]->IsNumber()) { @@ -198,7 +198,7 @@ void DTRACE_HTTP_SERVER_REQUEST(const FunctionCallbackInfo& args) { if (!NODE_HTTP_SERVER_REQUEST_ENABLED()) return; - Environment* env = Environment::GetCurrent(args.GetIsolate()); + Environment* env = Environment::GetCurrent(args); HandleScope scope(env->isolate()); Local arg0 = Local::Cast(args[0]); Local headers; @@ -229,7 +229,7 @@ void DTRACE_HTTP_SERVER_REQUEST(const FunctionCallbackInfo& args) { void DTRACE_HTTP_SERVER_RESPONSE(const FunctionCallbackInfo& args) { if (!NODE_HTTP_SERVER_RESPONSE_ENABLED()) return; - Environment* env = Environment::GetCurrent(args.GetIsolate()); + Environment* env = Environment::GetCurrent(args); SLURP_CONNECTION(args[0], conn); NODE_HTTP_SERVER_RESPONSE(&conn, conn.remote, conn.port, conn.fd); } @@ -242,7 +242,7 @@ void DTRACE_HTTP_CLIENT_REQUEST(const FunctionCallbackInfo& args) { if (!NODE_HTTP_CLIENT_REQUEST_ENABLED()) return; - Environment* env = Environment::GetCurrent(args.GetIsolate()); + Environment* env = Environment::GetCurrent(args); HandleScope scope(env->isolate()); /* @@ -278,7 +278,7 @@ void DTRACE_HTTP_CLIENT_REQUEST(const FunctionCallbackInfo& args) { void DTRACE_HTTP_CLIENT_RESPONSE(const FunctionCallbackInfo& args) { if (!NODE_HTTP_CLIENT_RESPONSE_ENABLED()) return; - Environment* env = Environment::GetCurrent(args.GetIsolate()); + Environment* env = Environment::GetCurrent(args); SLURP_CONNECTION_HTTP_CLIENT_RESPONSE(args[0], args[1], conn); NODE_HTTP_CLIENT_RESPONSE(&conn, conn.remote, conn.port, conn.fd); } @@ -319,8 +319,7 @@ void InitDTrace(Environment* env, Handle target) { for (unsigned int i = 0; i < ARRAY_SIZE(tab); i++) { Local key = OneByteString(env->isolate(), tab[i].name); - Local val = FunctionTemplate::New(env->isolate(), tab[i].func) - ->GetFunction(); + Local val = env->NewFunctionTemplate(tab[i].func)->GetFunction(); target->Set(key, val); } diff --git a/src/node_file.cc b/src/node_file.cc index 56d7b35b4b..e0bd47d550 100644 --- a/src/node_file.cc +++ b/src/node_file.cc @@ -256,7 +256,7 @@ struct fs_req_wrap { #define ASYNC_DEST_CALL(func, callback, dest_path, ...) \ - Environment* env = Environment::GetCurrent(args.GetIsolate()); \ + Environment* env = Environment::GetCurrent(args); \ FSReqWrap* req_wrap; \ char* dest_str = (dest_path); \ int dest_len = dest_str == NULL ? 0 : strlen(dest_str); \ @@ -311,7 +311,7 @@ struct fs_req_wrap { static void Close(const FunctionCallbackInfo& args) { - Environment* env = Environment::GetCurrent(args.GetIsolate()); + Environment* env = Environment::GetCurrent(args); if (args.Length() < 1 || !args[0]->IsInt32()) { return THROW_BAD_ARGS; @@ -425,7 +425,7 @@ Local BuildStatsObject(Environment* env, const uv_stat_t* s) { } static void Stat(const FunctionCallbackInfo& args) { - Environment* env = Environment::GetCurrent(args.GetIsolate()); + Environment* env = Environment::GetCurrent(args); if (args.Length() < 1) return TYPE_ERROR("path required"); @@ -444,7 +444,7 @@ static void Stat(const FunctionCallbackInfo& args) { } static void LStat(const FunctionCallbackInfo& args) { - Environment* env = Environment::GetCurrent(args.GetIsolate()); + Environment* env = Environment::GetCurrent(args); if (args.Length() < 1) return TYPE_ERROR("path required"); @@ -463,7 +463,7 @@ static void LStat(const FunctionCallbackInfo& args) { } static void FStat(const FunctionCallbackInfo& args) { - Environment* env = Environment::GetCurrent(args.GetIsolate()); + Environment* env = Environment::GetCurrent(args); if (args.Length() < 1 || !args[0]->IsInt32()) { return THROW_BAD_ARGS; @@ -481,7 +481,7 @@ static void FStat(const FunctionCallbackInfo& args) { } static void Symlink(const FunctionCallbackInfo& args) { - Environment* env = Environment::GetCurrent(args.GetIsolate()); + Environment* env = Environment::GetCurrent(args); int len = args.Length(); if (len < 1) @@ -516,7 +516,7 @@ static void Symlink(const FunctionCallbackInfo& args) { } static void Link(const FunctionCallbackInfo& args) { - Environment* env = Environment::GetCurrent(args.GetIsolate()); + Environment* env = Environment::GetCurrent(args); int len = args.Length(); if (len < 1) @@ -539,7 +539,7 @@ static void Link(const FunctionCallbackInfo& args) { } static void ReadLink(const FunctionCallbackInfo& args) { - Environment* env = Environment::GetCurrent(args.GetIsolate()); + Environment* env = Environment::GetCurrent(args); if (args.Length() < 1) return TYPE_ERROR("path required"); @@ -559,7 +559,7 @@ static void ReadLink(const FunctionCallbackInfo& args) { } static void Rename(const FunctionCallbackInfo& args) { - Environment* env = Environment::GetCurrent(args.GetIsolate()); + Environment* env = Environment::GetCurrent(args); int len = args.Length(); if (len < 1) @@ -582,7 +582,7 @@ static void Rename(const FunctionCallbackInfo& args) { } static void FTruncate(const FunctionCallbackInfo& args) { - Environment* env = Environment::GetCurrent(args.GetIsolate()); + Environment* env = Environment::GetCurrent(args); if (args.Length() < 2 || !args[0]->IsInt32()) { return THROW_BAD_ARGS; @@ -601,7 +601,7 @@ static void FTruncate(const FunctionCallbackInfo& args) { } static void Fdatasync(const FunctionCallbackInfo& args) { - Environment* env = Environment::GetCurrent(args.GetIsolate()); + Environment* env = Environment::GetCurrent(args); if (args.Length() < 1 || !args[0]->IsInt32()) { return THROW_BAD_ARGS; @@ -617,7 +617,7 @@ static void Fdatasync(const FunctionCallbackInfo& args) { } static void Fsync(const FunctionCallbackInfo& args) { - Environment* env = Environment::GetCurrent(args.GetIsolate()); + Environment* env = Environment::GetCurrent(args); if (args.Length() < 1 || !args[0]->IsInt32()) { return THROW_BAD_ARGS; @@ -633,7 +633,7 @@ static void Fsync(const FunctionCallbackInfo& args) { } static void Unlink(const FunctionCallbackInfo& args) { - Environment* env = Environment::GetCurrent(args.GetIsolate()); + Environment* env = Environment::GetCurrent(args); if (args.Length() < 1) return TYPE_ERROR("path required"); @@ -650,7 +650,7 @@ static void Unlink(const FunctionCallbackInfo& args) { } static void RMDir(const FunctionCallbackInfo& args) { - Environment* env = Environment::GetCurrent(args.GetIsolate()); + Environment* env = Environment::GetCurrent(args); if (args.Length() < 1) return TYPE_ERROR("path required"); @@ -667,7 +667,7 @@ static void RMDir(const FunctionCallbackInfo& args) { } static void MKDir(const FunctionCallbackInfo& args) { - Environment* env = Environment::GetCurrent(args.GetIsolate()); + Environment* env = Environment::GetCurrent(args); if (args.Length() < 2 || !args[0]->IsString() || !args[1]->IsInt32()) { return THROW_BAD_ARGS; @@ -684,7 +684,7 @@ static void MKDir(const FunctionCallbackInfo& args) { } static void ReadDir(const FunctionCallbackInfo& args) { - Environment* env = Environment::GetCurrent(args.GetIsolate()); + Environment* env = Environment::GetCurrent(args); if (args.Length() < 1) return TYPE_ERROR("path required"); @@ -721,7 +721,7 @@ static void ReadDir(const FunctionCallbackInfo& args) { } static void Open(const FunctionCallbackInfo& args) { - Environment* env = Environment::GetCurrent(args.GetIsolate()); + Environment* env = Environment::GetCurrent(args); int len = args.Length(); if (len < 1) @@ -760,7 +760,7 @@ static void Open(const FunctionCallbackInfo& args) { // 4 position if integer, position to write at in the file. // if null, write from the current position static void WriteBuffer(const FunctionCallbackInfo& args) { - Environment* env = Environment::GetCurrent(args.GetIsolate()); + Environment* env = Environment::GetCurrent(args); CHECK(args[0]->IsInt32()); CHECK(Buffer::HasInstance(args[1])); @@ -806,7 +806,7 @@ static void WriteBuffer(const FunctionCallbackInfo& args) { // if null, write from the current position // 3 enc encoding of string static void WriteString(const FunctionCallbackInfo& args) { - Environment* env = Environment::GetCurrent(args.GetIsolate()); + Environment* env = Environment::GetCurrent(args); if (!args[0]->IsInt32()) return env->ThrowTypeError("First argument must be file descriptor"); @@ -878,7 +878,7 @@ static void WriteString(const FunctionCallbackInfo& args) { * */ static void Read(const FunctionCallbackInfo& args) { - Environment* env = Environment::GetCurrent(args.GetIsolate()); + Environment* env = Environment::GetCurrent(args); if (args.Length() < 2 || !args[0]->IsInt32()) { return THROW_BAD_ARGS; @@ -931,7 +931,7 @@ static void Read(const FunctionCallbackInfo& args) { * Wrapper for chmod(1) / EIO_CHMOD */ static void Chmod(const FunctionCallbackInfo& args) { - Environment* env = Environment::GetCurrent(args.GetIsolate()); + Environment* env = Environment::GetCurrent(args); if (args.Length() < 2 || !args[0]->IsString() || !args[1]->IsInt32()) { return THROW_BAD_ARGS; @@ -951,7 +951,7 @@ static void Chmod(const FunctionCallbackInfo& args) { * Wrapper for fchmod(1) / EIO_FCHMOD */ static void FChmod(const FunctionCallbackInfo& args) { - Environment* env = Environment::GetCurrent(args.GetIsolate()); + Environment* env = Environment::GetCurrent(args); if (args.Length() < 2 || !args[0]->IsInt32() || !args[1]->IsInt32()) { return THROW_BAD_ARGS; @@ -971,7 +971,7 @@ static void FChmod(const FunctionCallbackInfo& args) { * Wrapper for chown(1) / EIO_CHOWN */ static void Chown(const FunctionCallbackInfo& args) { - Environment* env = Environment::GetCurrent(args.GetIsolate()); + Environment* env = Environment::GetCurrent(args); int len = args.Length(); if (len < 1) @@ -1003,7 +1003,7 @@ static void Chown(const FunctionCallbackInfo& args) { * Wrapper for fchown(1) / EIO_FCHOWN */ static void FChown(const FunctionCallbackInfo& args) { - Environment* env = Environment::GetCurrent(args.GetIsolate()); + Environment* env = Environment::GetCurrent(args); int len = args.Length(); if (len < 1) @@ -1032,7 +1032,7 @@ static void FChown(const FunctionCallbackInfo& args) { static void UTimes(const FunctionCallbackInfo& args) { - Environment* env = Environment::GetCurrent(args.GetIsolate()); + Environment* env = Environment::GetCurrent(args); int len = args.Length(); if (len < 1) @@ -1060,7 +1060,7 @@ static void UTimes(const FunctionCallbackInfo& args) { } static void FUTimes(const FunctionCallbackInfo& args) { - Environment* env = Environment::GetCurrent(args.GetIsolate()); + Environment* env = Environment::GetCurrent(args); int len = args.Length(); if (len < 1) @@ -1091,7 +1091,7 @@ void FSInitialize(const FunctionCallbackInfo& args) { Local stats_constructor = args[0].As(); CHECK(stats_constructor->IsFunction()); - Environment* env = Environment::GetCurrent(args.GetIsolate()); + Environment* env = Environment::GetCurrent(args); env->set_fs_stats_constructor_function(stats_constructor); } @@ -1102,40 +1102,39 @@ void InitFs(Handle target, Environment* env = Environment::GetCurrent(context); // Function which creates a new Stats object. - target->Set( - FIXED_ONE_BYTE_STRING(env->isolate(), "FSInitialize"), - FunctionTemplate::New(env->isolate(), FSInitialize)->GetFunction()); - - NODE_SET_METHOD(target, "close", Close); - NODE_SET_METHOD(target, "open", Open); - NODE_SET_METHOD(target, "read", Read); - NODE_SET_METHOD(target, "fdatasync", Fdatasync); - NODE_SET_METHOD(target, "fsync", Fsync); - NODE_SET_METHOD(target, "rename", Rename); - NODE_SET_METHOD(target, "ftruncate", FTruncate); - NODE_SET_METHOD(target, "rmdir", RMDir); - NODE_SET_METHOD(target, "mkdir", MKDir); - NODE_SET_METHOD(target, "readdir", ReadDir); - NODE_SET_METHOD(target, "stat", Stat); - NODE_SET_METHOD(target, "lstat", LStat); - NODE_SET_METHOD(target, "fstat", FStat); - NODE_SET_METHOD(target, "link", Link); - NODE_SET_METHOD(target, "symlink", Symlink); - NODE_SET_METHOD(target, "readlink", ReadLink); - NODE_SET_METHOD(target, "unlink", Unlink); - NODE_SET_METHOD(target, "writeBuffer", WriteBuffer); - NODE_SET_METHOD(target, "writeString", WriteString); - - NODE_SET_METHOD(target, "chmod", Chmod); - NODE_SET_METHOD(target, "fchmod", FChmod); - // NODE_SET_METHOD(target, "lchmod", LChmod); - - NODE_SET_METHOD(target, "chown", Chown); - NODE_SET_METHOD(target, "fchown", FChown); - // NODE_SET_METHOD(target, "lchown", LChown); - - NODE_SET_METHOD(target, "utimes", UTimes); - NODE_SET_METHOD(target, "futimes", FUTimes); + target->Set(FIXED_ONE_BYTE_STRING(env->isolate(), "FSInitialize"), + env->NewFunctionTemplate(FSInitialize)->GetFunction()); + + env->SetMethod(target, "close", Close); + env->SetMethod(target, "open", Open); + env->SetMethod(target, "read", Read); + env->SetMethod(target, "fdatasync", Fdatasync); + env->SetMethod(target, "fsync", Fsync); + env->SetMethod(target, "rename", Rename); + env->SetMethod(target, "ftruncate", FTruncate); + env->SetMethod(target, "rmdir", RMDir); + env->SetMethod(target, "mkdir", MKDir); + env->SetMethod(target, "readdir", ReadDir); + env->SetMethod(target, "stat", Stat); + env->SetMethod(target, "lstat", LStat); + env->SetMethod(target, "fstat", FStat); + env->SetMethod(target, "link", Link); + env->SetMethod(target, "symlink", Symlink); + env->SetMethod(target, "readlink", ReadLink); + env->SetMethod(target, "unlink", Unlink); + env->SetMethod(target, "writeBuffer", WriteBuffer); + env->SetMethod(target, "writeString", WriteString); + + env->SetMethod(target, "chmod", Chmod); + env->SetMethod(target, "fchmod", FChmod); + // env->SetMethod(target, "lchmod", LChmod); + + env->SetMethod(target, "chown", Chown); + env->SetMethod(target, "fchown", FChown); + // env->SetMethod(target, "lchown", LChown); + + env->SetMethod(target, "utimes", UTimes); + env->SetMethod(target, "futimes", FUTimes); StatWatcher::Initialize(env, target); } diff --git a/src/node_http_parser.cc b/src/node_http_parser.cc index dc25e8c760..eb89829547 100644 --- a/src/node_http_parser.cc +++ b/src/node_http_parser.cc @@ -350,7 +350,7 @@ class Parser : public BaseObject { static void New(const FunctionCallbackInfo& args) { - Environment* env = Environment::GetCurrent(args.GetIsolate()); + Environment* env = Environment::GetCurrent(args); http_parser_type type = static_cast(args[0]->Int32Value()); CHECK(type == HTTP_REQUEST || type == HTTP_RESPONSE); @@ -380,7 +380,7 @@ class Parser : public BaseObject { // var bytesParsed = parser->execute(buffer); static void Execute(const FunctionCallbackInfo& args) { - Environment* env = Environment::GetCurrent(args.GetIsolate()); + Environment* env = Environment::GetCurrent(args); Parser* parser = Unwrap(args.Holder()); CHECK(parser->current_buffer_.IsEmpty()); @@ -434,7 +434,7 @@ class Parser : public BaseObject { static void Finish(const FunctionCallbackInfo& args) { - Environment* env = Environment::GetCurrent(args.GetIsolate()); + Environment* env = Environment::GetCurrent(args); Parser* parser = Unwrap(args.Holder()); @@ -461,7 +461,7 @@ class Parser : public BaseObject { static void Reinitialize(const FunctionCallbackInfo& args) { - Environment* env = Environment::GetCurrent(args.GetIsolate()); + Environment* env = Environment::GetCurrent(args); http_parser_type type = static_cast(args[0]->Int32Value()); @@ -476,7 +476,7 @@ class Parser : public BaseObject { template static void Pause(const FunctionCallbackInfo& args) { - Environment* env = Environment::GetCurrent(args.GetIsolate()); + Environment* env = Environment::GetCurrent(args); Parser* parser = Unwrap(args.Holder()); // Should always be called from the same context. CHECK_EQ(env, parser->env()); @@ -569,8 +569,7 @@ void InitHttpParser(Handle target, Handle context, void* priv) { Environment* env = Environment::GetCurrent(context); - Local t = FunctionTemplate::New(env->isolate(), - Parser::New); + Local t = env->NewFunctionTemplate(Parser::New); t->InstanceTemplate()->SetInternalFieldCount(1); t->SetClassName(FIXED_ONE_BYTE_STRING(env->isolate(), "HTTPParser")); @@ -594,12 +593,12 @@ void InitHttpParser(Handle target, #undef V t->Set(FIXED_ONE_BYTE_STRING(env->isolate(), "methods"), methods); - NODE_SET_PROTOTYPE_METHOD(t, "close", Parser::Close); - NODE_SET_PROTOTYPE_METHOD(t, "execute", Parser::Execute); - NODE_SET_PROTOTYPE_METHOD(t, "finish", Parser::Finish); - NODE_SET_PROTOTYPE_METHOD(t, "reinitialize", Parser::Reinitialize); - NODE_SET_PROTOTYPE_METHOD(t, "pause", Parser::Pause); - NODE_SET_PROTOTYPE_METHOD(t, "resume", Parser::Pause); + env->SetProtoMethod(t, "close", Parser::Close); + env->SetProtoMethod(t, "execute", Parser::Execute); + env->SetProtoMethod(t, "finish", Parser::Finish); + env->SetProtoMethod(t, "reinitialize", Parser::Reinitialize); + env->SetProtoMethod(t, "pause", Parser::Pause); + env->SetProtoMethod(t, "resume", Parser::Pause); target->Set(FIXED_ONE_BYTE_STRING(env->isolate(), "HTTPParser"), t->GetFunction()); diff --git a/src/node_os.cc b/src/node_os.cc index 4d8dc5c31d..53d3d21e56 100644 --- a/src/node_os.cc +++ b/src/node_os.cc @@ -60,14 +60,14 @@ using v8::Value; static void GetEndianness(const FunctionCallbackInfo& args) { - Environment* env = Environment::GetCurrent(args.GetIsolate()); + Environment* env = Environment::GetCurrent(args); const char* rval = IsBigEndian() ? "BE" : "LE"; args.GetReturnValue().Set(OneByteString(env->isolate(), rval)); } static void GetHostname(const FunctionCallbackInfo& args) { - Environment* env = Environment::GetCurrent(args.GetIsolate()); + Environment* env = Environment::GetCurrent(args); char buf[MAXHOSTNAMELEN + 1]; if (gethostname(buf, sizeof(buf))) { @@ -85,7 +85,7 @@ static void GetHostname(const FunctionCallbackInfo& args) { static void GetOSType(const FunctionCallbackInfo& args) { - Environment* env = Environment::GetCurrent(args.GetIsolate()); + Environment* env = Environment::GetCurrent(args); const char* rval; #ifdef __POSIX__ @@ -103,7 +103,7 @@ static void GetOSType(const FunctionCallbackInfo& args) { static void GetOSRelease(const FunctionCallbackInfo& args) { - Environment* env = Environment::GetCurrent(args.GetIsolate()); + Environment* env = Environment::GetCurrent(args); const char* rval; #ifdef __POSIX__ @@ -134,7 +134,7 @@ static void GetOSRelease(const FunctionCallbackInfo& args) { static void GetCPUInfo(const FunctionCallbackInfo& args) { - Environment* env = Environment::GetCurrent(args.GetIsolate()); + Environment* env = Environment::GetCurrent(args); uv_cpu_info_t* cpu_infos; int count, i; @@ -198,7 +198,7 @@ static void GetUptime(const FunctionCallbackInfo& args) { static void GetLoadAvg(const FunctionCallbackInfo& args) { - Environment* env = Environment::GetCurrent(args.GetIsolate()); + Environment* env = Environment::GetCurrent(args); double loadavg[3]; uv_loadavg(loadavg); Local loads = Array::New(env->isolate(), 3); @@ -210,7 +210,7 @@ static void GetLoadAvg(const FunctionCallbackInfo& args) { static void GetInterfaceAddresses(const FunctionCallbackInfo& args) { - Environment* env = Environment::GetCurrent(args.GetIsolate()); + Environment* env = Environment::GetCurrent(args); uv_interface_address_t* interfaces; int count, i; char ip[INET6_ADDRSTRLEN]; @@ -289,16 +289,17 @@ static void GetInterfaceAddresses(const FunctionCallbackInfo& args) { void Initialize(Handle target, Handle unused, Handle context) { - NODE_SET_METHOD(target, "getEndianness", GetEndianness); - NODE_SET_METHOD(target, "getHostname", GetHostname); - NODE_SET_METHOD(target, "getLoadAvg", GetLoadAvg); - NODE_SET_METHOD(target, "getUptime", GetUptime); - NODE_SET_METHOD(target, "getTotalMem", GetTotalMemory); - NODE_SET_METHOD(target, "getFreeMem", GetFreeMemory); - NODE_SET_METHOD(target, "getCPUs", GetCPUInfo); - NODE_SET_METHOD(target, "getOSType", GetOSType); - NODE_SET_METHOD(target, "getOSRelease", GetOSRelease); - NODE_SET_METHOD(target, "getInterfaceAddresses", GetInterfaceAddresses); + Environment* env = Environment::GetCurrent(context); + env->SetMethod(target, "getEndianness", GetEndianness); + env->SetMethod(target, "getHostname", GetHostname); + env->SetMethod(target, "getLoadAvg", GetLoadAvg); + env->SetMethod(target, "getUptime", GetUptime); + env->SetMethod(target, "getTotalMem", GetTotalMemory); + env->SetMethod(target, "getFreeMem", GetFreeMemory); + env->SetMethod(target, "getCPUs", GetCPUInfo); + env->SetMethod(target, "getOSType", GetOSType); + env->SetMethod(target, "getOSRelease", GetOSRelease); + env->SetMethod(target, "getInterfaceAddresses", GetInterfaceAddresses); } } // namespace os diff --git a/src/node_stat_watcher.cc b/src/node_stat_watcher.cc index 3d6c4b189d..8f82bc357e 100644 --- a/src/node_stat_watcher.cc +++ b/src/node_stat_watcher.cc @@ -46,13 +46,12 @@ using v8::Value; void StatWatcher::Initialize(Environment* env, Handle target) { HandleScope scope(env->isolate()); - Local t = FunctionTemplate::New(env->isolate(), - StatWatcher::New); + Local t = env->NewFunctionTemplate(StatWatcher::New); t->InstanceTemplate()->SetInternalFieldCount(1); t->SetClassName(FIXED_ONE_BYTE_STRING(env->isolate(), "StatWatcher")); - NODE_SET_PROTOTYPE_METHOD(t, "start", StatWatcher::Start); - NODE_SET_PROTOTYPE_METHOD(t, "stop", StatWatcher::Stop); + env->SetProtoMethod(t, "start", StatWatcher::Start); + env->SetProtoMethod(t, "stop", StatWatcher::Stop); target->Set(FIXED_ONE_BYTE_STRING(env->isolate(), "StatWatcher"), t->GetFunction()); @@ -99,7 +98,7 @@ void StatWatcher::Callback(uv_fs_poll_t* handle, void StatWatcher::New(const FunctionCallbackInfo& args) { CHECK(args.IsConstructCall()); - Environment* env = Environment::GetCurrent(args.GetIsolate()); + Environment* env = Environment::GetCurrent(args); new StatWatcher(env, args.This()); } diff --git a/src/node_v8.cc b/src/node_v8.cc index 0c7d5f3ebd..d59e661fbd 100644 --- a/src/node_v8.cc +++ b/src/node_v8.cc @@ -173,14 +173,14 @@ void Environment::StopGarbageCollectionTracking() { void StartGarbageCollectionTracking(const FunctionCallbackInfo& args) { CHECK(args[0]->IsFunction() == true); - Environment* env = Environment::GetCurrent(args.GetIsolate()); + Environment* env = Environment::GetCurrent(args); env->StartGarbageCollectionTracking(args[0].As()); } void GetHeapStatistics(const FunctionCallbackInfo& args) { + Environment* env = Environment::GetCurrent(args); Isolate* isolate = args.GetIsolate(); - Environment* env = Environment::GetCurrent(isolate); HeapStatistics s; isolate->GetHeapStatistics(&s); Local info = Object::New(isolate); @@ -200,20 +200,21 @@ void GetHeapStatistics(const FunctionCallbackInfo& args) { void StopGarbageCollectionTracking(const FunctionCallbackInfo& args) { - Environment::GetCurrent(args.GetIsolate())->StopGarbageCollectionTracking(); + Environment::GetCurrent(args)->StopGarbageCollectionTracking(); } void InitializeV8Bindings(Handle target, Handle unused, Handle context) { - NODE_SET_METHOD(target, - "startGarbageCollectionTracking", - StartGarbageCollectionTracking); - NODE_SET_METHOD(target, - "stopGarbageCollectionTracking", - StopGarbageCollectionTracking); - NODE_SET_METHOD(target, "getHeapStatistics", GetHeapStatistics); + Environment* env = Environment::GetCurrent(context); + env->SetMethod(target, + "startGarbageCollectionTracking", + StartGarbageCollectionTracking); + env->SetMethod(target, + "stopGarbageCollectionTracking", + StopGarbageCollectionTracking); + env->SetMethod(target, "getHeapStatistics", GetHeapStatistics); } } // namespace node diff --git a/src/node_zlib.cc b/src/node_zlib.cc index e3165b2b30..22e62d9fb9 100644 --- a/src/node_zlib.cc +++ b/src/node_zlib.cc @@ -219,7 +219,7 @@ class ZCtx : public AsyncWrap { static void AfterSync(ZCtx* ctx, const FunctionCallbackInfo& args) { - Environment* env = Environment::GetCurrent(args.GetIsolate()); + Environment* env = Environment::GetCurrent(args); Local avail_out = Integer::New(env->isolate(), ctx->strm_.avail_out); Local avail_in = Integer::New(env->isolate(), @@ -365,7 +365,7 @@ class ZCtx : public AsyncWrap { } static void New(const FunctionCallbackInfo& args) { - Environment* env = Environment::GetCurrent(args.GetIsolate()); + Environment* env = Environment::GetCurrent(args); if (args.Length() < 1 || !args[0]->IsInt32()) { return env->ThrowTypeError("Bad argument"); @@ -595,16 +595,16 @@ void InitZlib(Handle target, Handle context, void* priv) { Environment* env = Environment::GetCurrent(context); - Local z = FunctionTemplate::New(env->isolate(), ZCtx::New); + Local z = env->NewFunctionTemplate(ZCtx::New); z->InstanceTemplate()->SetInternalFieldCount(1); - NODE_SET_PROTOTYPE_METHOD(z, "write", ZCtx::Write); - NODE_SET_PROTOTYPE_METHOD(z, "writeSync", ZCtx::Write); - NODE_SET_PROTOTYPE_METHOD(z, "init", ZCtx::Init); - NODE_SET_PROTOTYPE_METHOD(z, "close", ZCtx::Close); - NODE_SET_PROTOTYPE_METHOD(z, "params", ZCtx::Params); - NODE_SET_PROTOTYPE_METHOD(z, "reset", ZCtx::Reset); + env->SetProtoMethod(z, "write", ZCtx::Write); + env->SetProtoMethod(z, "writeSync", ZCtx::Write); + env->SetProtoMethod(z, "init", ZCtx::Init); + env->SetProtoMethod(z, "close", ZCtx::Close); + env->SetProtoMethod(z, "params", ZCtx::Params); + env->SetProtoMethod(z, "reset", ZCtx::Reset); z->SetClassName(FIXED_ONE_BYTE_STRING(env->isolate(), "Zlib")); target->Set(FIXED_ONE_BYTE_STRING(env->isolate(), "Zlib"), z->GetFunction()); diff --git a/src/pipe_wrap.cc b/src/pipe_wrap.cc index 7bcc0fb155..65f16d64d0 100644 --- a/src/pipe_wrap.cc +++ b/src/pipe_wrap.cc @@ -75,7 +75,7 @@ void PipeWrap::Initialize(Handle target, Handle context) { Environment* env = Environment::GetCurrent(context); - Local t = FunctionTemplate::New(env->isolate(), New); + Local t = env->NewFunctionTemplate(New); t->SetClassName(FIXED_ONE_BYTE_STRING(env->isolate(), "Pipe")); t->InstanceTemplate()->SetInternalFieldCount(1); @@ -88,33 +88,29 @@ void PipeWrap::Initialize(Handle target, v8::DEFAULT, attributes); - NODE_SET_PROTOTYPE_METHOD(t, "close", HandleWrap::Close); - NODE_SET_PROTOTYPE_METHOD(t, "unref", HandleWrap::Unref); - NODE_SET_PROTOTYPE_METHOD(t, "ref", HandleWrap::Ref); + env->SetProtoMethod(t, "close", HandleWrap::Close); + env->SetProtoMethod(t, "unref", HandleWrap::Unref); + env->SetProtoMethod(t, "ref", HandleWrap::Ref); - NODE_SET_PROTOTYPE_METHOD(t, "setBlocking", StreamWrap::SetBlocking); + env->SetProtoMethod(t, "setBlocking", StreamWrap::SetBlocking); - NODE_SET_PROTOTYPE_METHOD(t, "readStart", StreamWrap::ReadStart); - NODE_SET_PROTOTYPE_METHOD(t, "readStop", StreamWrap::ReadStop); - NODE_SET_PROTOTYPE_METHOD(t, "shutdown", StreamWrap::Shutdown); + env->SetProtoMethod(t, "readStart", StreamWrap::ReadStart); + env->SetProtoMethod(t, "readStop", StreamWrap::ReadStop); + env->SetProtoMethod(t, "shutdown", StreamWrap::Shutdown); - NODE_SET_PROTOTYPE_METHOD(t, "writeBuffer", StreamWrap::WriteBuffer); - NODE_SET_PROTOTYPE_METHOD(t, - "writeAsciiString", - StreamWrap::WriteAsciiString); - NODE_SET_PROTOTYPE_METHOD(t, "writeUtf8String", StreamWrap::WriteUtf8String); - NODE_SET_PROTOTYPE_METHOD(t, "writeUcs2String", StreamWrap::WriteUcs2String); - NODE_SET_PROTOTYPE_METHOD(t, - "writeBinaryString", - StreamWrap::WriteBinaryString); + env->SetProtoMethod(t, "writeBuffer", StreamWrap::WriteBuffer); + env->SetProtoMethod(t, "writeAsciiString", StreamWrap::WriteAsciiString); + env->SetProtoMethod(t, "writeUtf8String", StreamWrap::WriteUtf8String); + env->SetProtoMethod(t, "writeUcs2String", StreamWrap::WriteUcs2String); + env->SetProtoMethod(t, "writeBinaryString", StreamWrap::WriteBinaryString); - NODE_SET_PROTOTYPE_METHOD(t, "bind", Bind); - NODE_SET_PROTOTYPE_METHOD(t, "listen", Listen); - NODE_SET_PROTOTYPE_METHOD(t, "connect", Connect); - NODE_SET_PROTOTYPE_METHOD(t, "open", Open); + env->SetProtoMethod(t, "bind", Bind); + env->SetProtoMethod(t, "listen", Listen); + env->SetProtoMethod(t, "connect", Connect); + env->SetProtoMethod(t, "open", Open); #ifdef _WIN32 - NODE_SET_PROTOTYPE_METHOD(t, "setPendingInstances", SetPendingInstances); + env->SetProtoMethod(t, "setPendingInstances", SetPendingInstances); #endif target->Set(FIXED_ONE_BYTE_STRING(env->isolate(), "Pipe"), t->GetFunction()); @@ -127,7 +123,7 @@ void PipeWrap::New(const FunctionCallbackInfo& args) { // Therefore we assert that we are not trying to call this as a // normal function. CHECK(args.IsConstructCall()); - Environment* env = Environment::GetCurrent(args.GetIsolate()); + Environment* env = Environment::GetCurrent(args); new PipeWrap(env, args.This(), args[0]->IsTrue()); } @@ -247,7 +243,7 @@ void PipeWrap::AfterConnect(uv_connect_t* req, int status) { void PipeWrap::Open(const FunctionCallbackInfo& args) { - Environment* env = Environment::GetCurrent(args.GetIsolate()); + Environment* env = Environment::GetCurrent(args); PipeWrap* wrap = Unwrap(args.Holder()); @@ -261,7 +257,7 @@ void PipeWrap::Open(const FunctionCallbackInfo& args) { void PipeWrap::Connect(const FunctionCallbackInfo& args) { - Environment* env = Environment::GetCurrent(args.GetIsolate()); + Environment* env = Environment::GetCurrent(args); PipeWrap* wrap = Unwrap(args.Holder()); diff --git a/src/process_wrap.cc b/src/process_wrap.cc index 47baf90994..69c696acd0 100644 --- a/src/process_wrap.cc +++ b/src/process_wrap.cc @@ -51,18 +51,17 @@ class ProcessWrap : public HandleWrap { Handle unused, Handle context) { Environment* env = Environment::GetCurrent(context); - Local constructor = FunctionTemplate::New(env->isolate(), - New); + Local constructor = env->NewFunctionTemplate(New); constructor->InstanceTemplate()->SetInternalFieldCount(1); constructor->SetClassName(FIXED_ONE_BYTE_STRING(env->isolate(), "Process")); - NODE_SET_PROTOTYPE_METHOD(constructor, "close", HandleWrap::Close); + env->SetProtoMethod(constructor, "close", HandleWrap::Close); - NODE_SET_PROTOTYPE_METHOD(constructor, "spawn", Spawn); - NODE_SET_PROTOTYPE_METHOD(constructor, "kill", Kill); + env->SetProtoMethod(constructor, "spawn", Spawn); + env->SetProtoMethod(constructor, "kill", Kill); - NODE_SET_PROTOTYPE_METHOD(constructor, "ref", HandleWrap::Ref); - NODE_SET_PROTOTYPE_METHOD(constructor, "unref", HandleWrap::Unref); + env->SetProtoMethod(constructor, "ref", HandleWrap::Ref); + env->SetProtoMethod(constructor, "unref", HandleWrap::Unref); target->Set(FIXED_ONE_BYTE_STRING(env->isolate(), "Process"), constructor->GetFunction()); @@ -74,7 +73,7 @@ class ProcessWrap : public HandleWrap { // Therefore we assert that we are not trying to call this as a // normal function. CHECK(args.IsConstructCall()); - Environment* env = Environment::GetCurrent(args.GetIsolate()); + Environment* env = Environment::GetCurrent(args); new ProcessWrap(env, args.This()); } @@ -130,7 +129,7 @@ class ProcessWrap : public HandleWrap { } static void Spawn(const FunctionCallbackInfo& args) { - Environment* env = Environment::GetCurrent(args.GetIsolate()); + Environment* env = Environment::GetCurrent(args); ProcessWrap* wrap = Unwrap(args.Holder()); diff --git a/src/signal_wrap.cc b/src/signal_wrap.cc index e187f91c7b..1d32f7af0f 100644 --- a/src/signal_wrap.cc +++ b/src/signal_wrap.cc @@ -47,16 +47,15 @@ class SignalWrap : public HandleWrap { Handle unused, Handle context) { Environment* env = Environment::GetCurrent(context); - Local constructor = FunctionTemplate::New(env->isolate(), - New); + Local constructor = env->NewFunctionTemplate(New); constructor->InstanceTemplate()->SetInternalFieldCount(1); constructor->SetClassName(FIXED_ONE_BYTE_STRING(env->isolate(), "Signal")); - NODE_SET_PROTOTYPE_METHOD(constructor, "close", HandleWrap::Close); - NODE_SET_PROTOTYPE_METHOD(constructor, "ref", HandleWrap::Ref); - NODE_SET_PROTOTYPE_METHOD(constructor, "unref", HandleWrap::Unref); - NODE_SET_PROTOTYPE_METHOD(constructor, "start", Start); - NODE_SET_PROTOTYPE_METHOD(constructor, "stop", Stop); + env->SetProtoMethod(constructor, "close", HandleWrap::Close); + env->SetProtoMethod(constructor, "ref", HandleWrap::Ref); + env->SetProtoMethod(constructor, "unref", HandleWrap::Unref); + env->SetProtoMethod(constructor, "start", Start); + env->SetProtoMethod(constructor, "stop", Stop); target->Set(FIXED_ONE_BYTE_STRING(env->isolate(), "Signal"), constructor->GetFunction()); @@ -68,7 +67,7 @@ class SignalWrap : public HandleWrap { // Therefore we assert that we are not trying to call this as a // normal function. CHECK(args.IsConstructCall()); - Environment* env = Environment::GetCurrent(args.GetIsolate()); + Environment* env = Environment::GetCurrent(args); new SignalWrap(env, args.This()); } diff --git a/src/smalloc.cc b/src/smalloc.cc index 9d84b9a15c..9ce5ea4963 100644 --- a/src/smalloc.cc +++ b/src/smalloc.cc @@ -171,7 +171,7 @@ size_t ExternalArraySize(enum ExternalArrayType type) { // copyOnto(source, source_start, dest, dest_start, copy_length) void CopyOnto(const FunctionCallbackInfo& args) { - Environment* env = Environment::GetCurrent(args.GetIsolate()); + Environment* env = Environment::GetCurrent(args); if (!args[0]->IsObject()) return env->ThrowTypeError("source must be an object"); @@ -285,7 +285,7 @@ void SliceOnto(const FunctionCallbackInfo& args) { // for internal use: // alloc(obj, n[, type]); void Alloc(const FunctionCallbackInfo& args) { - Environment* env = Environment::GetCurrent(args.GetIsolate()); + Environment* env = Environment::GetCurrent(args); Local obj = args[0].As(); @@ -348,7 +348,7 @@ void Alloc(Environment* env, // for internal use: dispose(obj); void AllocDispose(const FunctionCallbackInfo& args) { - Environment* env = Environment::GetCurrent(args.GetIsolate()); + Environment* env = Environment::GetCurrent(args); AllocDispose(env, args[0].As()); } @@ -430,7 +430,7 @@ void Alloc(Environment* env, void HasExternalData(const FunctionCallbackInfo& args) { - Environment* env = Environment::GetCurrent(args.GetIsolate()); + Environment* env = Environment::GetCurrent(args); args.GetReturnValue().Set(args[0]->IsObject() && HasExternalData(env, args[0].As())); } @@ -442,7 +442,7 @@ bool HasExternalData(Environment* env, Local obj) { void AllocTruncate(const FunctionCallbackInfo& args) { - Environment* env = Environment::GetCurrent(args.GetIsolate()); + Environment* env = Environment::GetCurrent(args); Local obj = args[0].As(); @@ -532,14 +532,14 @@ void Initialize(Handle exports, Handle context) { Environment* env = Environment::GetCurrent(context); - NODE_SET_METHOD(exports, "copyOnto", CopyOnto); - NODE_SET_METHOD(exports, "sliceOnto", SliceOnto); + env->SetMethod(exports, "copyOnto", CopyOnto); + env->SetMethod(exports, "sliceOnto", SliceOnto); - NODE_SET_METHOD(exports, "alloc", Alloc); - NODE_SET_METHOD(exports, "dispose", AllocDispose); - NODE_SET_METHOD(exports, "truncate", AllocTruncate); + env->SetMethod(exports, "alloc", Alloc); + env->SetMethod(exports, "dispose", AllocDispose); + env->SetMethod(exports, "truncate", AllocTruncate); - NODE_SET_METHOD(exports, "hasExternalData", HasExternalData); + env->SetMethod(exports, "hasExternalData", HasExternalData); exports->Set(FIXED_ONE_BYTE_STRING(env->isolate(), "kMaxLength"), Uint32::NewFromUnsigned(env->isolate(), kMaxLength)); diff --git a/src/spawn_sync.cc b/src/spawn_sync.cc index ea491be175..3cd33ef466 100644 --- a/src/spawn_sync.cc +++ b/src/spawn_sync.cc @@ -356,13 +356,13 @@ void SyncProcessStdioPipe::CloseCallback(uv_handle_t* handle) { void SyncProcessRunner::Initialize(Handle target, Handle unused, Handle context) { - NODE_SET_METHOD(target, "spawn", Spawn); + Environment* env = Environment::GetCurrent(context); + env->SetMethod(target, "spawn", Spawn); } void SyncProcessRunner::Spawn(const FunctionCallbackInfo& args) { - Isolate* isolate = args.GetIsolate(); - SyncProcessRunner p(Environment::GetCurrent(isolate)); + SyncProcessRunner p(Environment::GetCurrent(args)); Local result = p.Run(args[0]); args.GetReturnValue().Set(result); } diff --git a/src/stream_wrap.cc b/src/stream_wrap.cc index a274b0bca3..805f7a3f02 100644 --- a/src/stream_wrap.cc +++ b/src/stream_wrap.cc @@ -70,8 +70,7 @@ StreamWrap::StreamWrap(Environment* env, void StreamWrap::GetFD(Local, const PropertyCallbackInfo& args) { #if !defined(_WIN32) - Environment* env = Environment::GetCurrent(args.GetIsolate()); - HandleScope scope(env->isolate()); + HandleScope scope(args.GetIsolate()); StreamWrap* wrap = Unwrap(args.Holder()); int fd = -1; if (wrap != NULL && wrap->stream() != NULL) { @@ -181,7 +180,7 @@ size_t StreamWrap::WriteBuffer(Handle val, uv_buf_t* buf) { void StreamWrap::WriteBuffer(const FunctionCallbackInfo& args) { - Environment* env = Environment::GetCurrent(args.GetIsolate()); + Environment* env = Environment::GetCurrent(args); StreamWrap* wrap = Unwrap(args.Holder()); @@ -237,7 +236,7 @@ void StreamWrap::WriteBuffer(const FunctionCallbackInfo& args) { template void StreamWrap::WriteStringImpl(const FunctionCallbackInfo& args) { - Environment* env = Environment::GetCurrent(args.GetIsolate()); + Environment* env = Environment::GetCurrent(args); int err; StreamWrap* wrap = Unwrap(args.Holder()); @@ -365,7 +364,7 @@ void StreamWrap::WriteStringImpl(const FunctionCallbackInfo& args) { void StreamWrap::Writev(const FunctionCallbackInfo& args) { - Environment* env = Environment::GetCurrent(args.GetIsolate()); + Environment* env = Environment::GetCurrent(args); StreamWrap* wrap = Unwrap(args.Holder()); @@ -535,7 +534,7 @@ void StreamWrap::AfterWrite(uv_write_t* req, int status) { void StreamWrap::Shutdown(const FunctionCallbackInfo& args) { - Environment* env = Environment::GetCurrent(args.GetIsolate()); + Environment* env = Environment::GetCurrent(args); StreamWrap* wrap = Unwrap(args.Holder()); diff --git a/src/tcp_wrap.cc b/src/tcp_wrap.cc index 128303cb39..1a4939f63c 100644 --- a/src/tcp_wrap.cc +++ b/src/tcp_wrap.cc @@ -71,7 +71,7 @@ void TCPWrap::Initialize(Handle target, Handle context) { Environment* env = Environment::GetCurrent(context); - Local t = FunctionTemplate::New(env->isolate(), New); + Local t = env->NewFunctionTemplate(New); t->SetClassName(FIXED_ONE_BYTE_STRING(env->isolate(), "TCP")); t->InstanceTemplate()->SetInternalFieldCount(1); @@ -96,41 +96,35 @@ void TCPWrap::Initialize(Handle target, Null(env->isolate())); - NODE_SET_PROTOTYPE_METHOD(t, "close", HandleWrap::Close); - - NODE_SET_PROTOTYPE_METHOD(t, "ref", HandleWrap::Ref); - NODE_SET_PROTOTYPE_METHOD(t, "unref", HandleWrap::Unref); - - NODE_SET_PROTOTYPE_METHOD(t, "readStart", StreamWrap::ReadStart); - NODE_SET_PROTOTYPE_METHOD(t, "readStop", StreamWrap::ReadStop); - NODE_SET_PROTOTYPE_METHOD(t, "shutdown", StreamWrap::Shutdown); - - NODE_SET_PROTOTYPE_METHOD(t, "writeBuffer", StreamWrap::WriteBuffer); - NODE_SET_PROTOTYPE_METHOD(t, - "writeAsciiString", - StreamWrap::WriteAsciiString); - NODE_SET_PROTOTYPE_METHOD(t, "writeUtf8String", StreamWrap::WriteUtf8String); - NODE_SET_PROTOTYPE_METHOD(t, "writeUcs2String", StreamWrap::WriteUcs2String); - NODE_SET_PROTOTYPE_METHOD(t, - "writeBinaryString", - StreamWrap::WriteBinaryString); - NODE_SET_PROTOTYPE_METHOD(t, "writev", StreamWrap::Writev); - - NODE_SET_PROTOTYPE_METHOD(t, "open", Open); - NODE_SET_PROTOTYPE_METHOD(t, "bind", Bind); - NODE_SET_PROTOTYPE_METHOD(t, "listen", Listen); - NODE_SET_PROTOTYPE_METHOD(t, "connect", Connect); - NODE_SET_PROTOTYPE_METHOD(t, "bind6", Bind6); - NODE_SET_PROTOTYPE_METHOD(t, "connect6", Connect6); - NODE_SET_PROTOTYPE_METHOD(t, "getsockname", GetSockName); - NODE_SET_PROTOTYPE_METHOD(t, "getpeername", GetPeerName); - NODE_SET_PROTOTYPE_METHOD(t, "setNoDelay", SetNoDelay); - NODE_SET_PROTOTYPE_METHOD(t, "setKeepAlive", SetKeepAlive); + env->SetProtoMethod(t, "close", HandleWrap::Close); + + env->SetProtoMethod(t, "ref", HandleWrap::Ref); + env->SetProtoMethod(t, "unref", HandleWrap::Unref); + + env->SetProtoMethod(t, "readStart", StreamWrap::ReadStart); + env->SetProtoMethod(t, "readStop", StreamWrap::ReadStop); + env->SetProtoMethod(t, "shutdown", StreamWrap::Shutdown); + + env->SetProtoMethod(t, "writeBuffer", StreamWrap::WriteBuffer); + env->SetProtoMethod(t, "writeAsciiString", StreamWrap::WriteAsciiString); + env->SetProtoMethod(t, "writeUtf8String", StreamWrap::WriteUtf8String); + env->SetProtoMethod(t, "writeUcs2String", StreamWrap::WriteUcs2String); + env->SetProtoMethod(t, "writeBinaryString", StreamWrap::WriteBinaryString); + env->SetProtoMethod(t, "writev", StreamWrap::Writev); + + env->SetProtoMethod(t, "open", Open); + env->SetProtoMethod(t, "bind", Bind); + env->SetProtoMethod(t, "listen", Listen); + env->SetProtoMethod(t, "connect", Connect); + env->SetProtoMethod(t, "bind6", Bind6); + env->SetProtoMethod(t, "connect6", Connect6); + env->SetProtoMethod(t, "getsockname", GetSockName); + env->SetProtoMethod(t, "getpeername", GetPeerName); + env->SetProtoMethod(t, "setNoDelay", SetNoDelay); + env->SetProtoMethod(t, "setKeepAlive", SetKeepAlive); #ifdef _WIN32 - NODE_SET_PROTOTYPE_METHOD(t, - "setSimultaneousAccepts", - SetSimultaneousAccepts); + env->SetProtoMethod(t, "setSimultaneousAccepts", SetSimultaneousAccepts); #endif target->Set(FIXED_ONE_BYTE_STRING(env->isolate(), "TCP"), t->GetFunction()); @@ -148,7 +142,7 @@ void TCPWrap::New(const FunctionCallbackInfo& args) { // Therefore we assert that we are not trying to call this as a // normal function. CHECK(args.IsConstructCall()); - Environment* env = Environment::GetCurrent(args.GetIsolate()); + Environment* env = Environment::GetCurrent(args); TCPWrap* wrap = new TCPWrap(env, args.This()); CHECK(wrap); } @@ -172,7 +166,7 @@ TCPWrap::~TCPWrap() { void TCPWrap::GetSockName(const FunctionCallbackInfo& args) { - Environment* env = Environment::GetCurrent(args.GetIsolate()); + Environment* env = Environment::GetCurrent(args); struct sockaddr_storage address; TCPWrap* wrap = Unwrap(args.Holder()); @@ -194,7 +188,7 @@ void TCPWrap::GetSockName(const FunctionCallbackInfo& args) { void TCPWrap::GetPeerName(const FunctionCallbackInfo& args) { - Environment* env = Environment::GetCurrent(args.GetIsolate()); + Environment* env = Environment::GetCurrent(args); struct sockaddr_storage address; TCPWrap* wrap = Unwrap(args.Holder()); @@ -353,7 +347,7 @@ void TCPWrap::AfterConnect(uv_connect_t* req, int status) { void TCPWrap::Connect(const FunctionCallbackInfo& args) { - Environment* env = Environment::GetCurrent(args.GetIsolate()); + Environment* env = Environment::GetCurrent(args); TCPWrap* wrap = Unwrap(args.Holder()); @@ -386,7 +380,7 @@ void TCPWrap::Connect(const FunctionCallbackInfo& args) { void TCPWrap::Connect6(const FunctionCallbackInfo& args) { - Environment* env = Environment::GetCurrent(args.GetIsolate()); + Environment* env = Environment::GetCurrent(args); TCPWrap* wrap = Unwrap(args.Holder()); diff --git a/src/timer_wrap.cc b/src/timer_wrap.cc index f9a2db39fe..0155505532 100644 --- a/src/timer_wrap.cc +++ b/src/timer_wrap.cc @@ -50,24 +50,23 @@ class TimerWrap : public HandleWrap { Handle unused, Handle context) { Environment* env = Environment::GetCurrent(context); - Local constructor = FunctionTemplate::New(env->isolate(), - New); + Local constructor = env->NewFunctionTemplate(New); constructor->InstanceTemplate()->SetInternalFieldCount(1); constructor->SetClassName(FIXED_ONE_BYTE_STRING(env->isolate(), "Timer")); constructor->Set(FIXED_ONE_BYTE_STRING(env->isolate(), "kOnTimeout"), Integer::New(env->isolate(), kOnTimeout)); - NODE_SET_METHOD(constructor, "now", Now); + env->SetTemplateMethod(constructor, "now", Now); - NODE_SET_PROTOTYPE_METHOD(constructor, "close", HandleWrap::Close); - NODE_SET_PROTOTYPE_METHOD(constructor, "ref", HandleWrap::Ref); - NODE_SET_PROTOTYPE_METHOD(constructor, "unref", HandleWrap::Unref); + env->SetProtoMethod(constructor, "close", HandleWrap::Close); + env->SetProtoMethod(constructor, "ref", HandleWrap::Ref); + env->SetProtoMethod(constructor, "unref", HandleWrap::Unref); - NODE_SET_PROTOTYPE_METHOD(constructor, "start", Start); - NODE_SET_PROTOTYPE_METHOD(constructor, "stop", Stop); - NODE_SET_PROTOTYPE_METHOD(constructor, "setRepeat", SetRepeat); - NODE_SET_PROTOTYPE_METHOD(constructor, "getRepeat", GetRepeat); - NODE_SET_PROTOTYPE_METHOD(constructor, "again", Again); + env->SetProtoMethod(constructor, "start", Start); + env->SetProtoMethod(constructor, "stop", Stop); + env->SetProtoMethod(constructor, "setRepeat", SetRepeat); + env->SetProtoMethod(constructor, "getRepeat", GetRepeat); + env->SetProtoMethod(constructor, "again", Again); target->Set(FIXED_ONE_BYTE_STRING(env->isolate(), "Timer"), constructor->GetFunction()); @@ -79,7 +78,7 @@ class TimerWrap : public HandleWrap { // Therefore we assert that we are not trying to call this as a // normal function. CHECK(args.IsConstructCall()); - Environment* env = Environment::GetCurrent(args.GetIsolate()); + Environment* env = Environment::GetCurrent(args); new TimerWrap(env, args.This()); } @@ -145,7 +144,7 @@ class TimerWrap : public HandleWrap { } static void Now(const FunctionCallbackInfo& args) { - Environment* env = Environment::GetCurrent(args.GetIsolate()); + Environment* env = Environment::GetCurrent(args); uv_update_time(env->event_loop()); uint64_t now = uv_now(env->event_loop()); if (now <= 0xfffffff) diff --git a/src/tls_wrap.cc b/src/tls_wrap.cc index d3ad8a5042..bc53100812 100644 --- a/src/tls_wrap.cc +++ b/src/tls_wrap.cc @@ -206,7 +206,7 @@ void TLSCallbacks::InitSSL() { void TLSCallbacks::Wrap(const FunctionCallbackInfo& args) { - Environment* env = Environment::GetCurrent(args.GetIsolate()); + Environment* env = Environment::GetCurrent(args); if (args.Length() < 1 || !args[0]->IsObject()) { return env->ThrowTypeError( @@ -263,7 +263,7 @@ void TLSCallbacks::Receive(const FunctionCallbackInfo& args) { void TLSCallbacks::Start(const FunctionCallbackInfo& args) { - Environment* env = Environment::GetCurrent(args.GetIsolate()); + Environment* env = Environment::GetCurrent(args); TLSCallbacks* wrap = Unwrap(args.Holder()); @@ -680,7 +680,7 @@ int TLSCallbacks::DoShutdown(ShutdownWrap* req_wrap, uv_shutdown_cb cb) { void TLSCallbacks::SetVerifyMode(const FunctionCallbackInfo& args) { - Environment* env = Environment::GetCurrent(args.GetIsolate()); + Environment* env = Environment::GetCurrent(args); TLSCallbacks* wrap = Unwrap(args.Holder()); @@ -734,7 +734,7 @@ void TLSCallbacks::OnClientHelloParseEnd(void* arg) { #ifdef SSL_CTRL_SET_TLSEXT_SERVERNAME_CB void TLSCallbacks::GetServername(const FunctionCallbackInfo& args) { - Environment* env = Environment::GetCurrent(args.GetIsolate()); + Environment* env = Environment::GetCurrent(args); TLSCallbacks* wrap = Unwrap(args.Holder()); @@ -749,7 +749,7 @@ void TLSCallbacks::GetServername(const FunctionCallbackInfo& args) { void TLSCallbacks::SetServername(const FunctionCallbackInfo& args) { - Environment* env = Environment::GetCurrent(args.GetIsolate()); + Environment* env = Environment::GetCurrent(args); TLSCallbacks* wrap = Unwrap(args.Holder()); @@ -811,27 +811,23 @@ void TLSCallbacks::Initialize(Handle target, Handle context) { Environment* env = Environment::GetCurrent(context); - NODE_SET_METHOD(target, "wrap", TLSCallbacks::Wrap); + env->SetMethod(target, "wrap", TLSCallbacks::Wrap); Local t = FunctionTemplate::New(env->isolate()); t->InstanceTemplate()->SetInternalFieldCount(1); t->SetClassName(FIXED_ONE_BYTE_STRING(env->isolate(), "TLSWrap")); - NODE_SET_PROTOTYPE_METHOD(t, "receive", Receive); - NODE_SET_PROTOTYPE_METHOD(t, "start", Start); - NODE_SET_PROTOTYPE_METHOD(t, "setVerifyMode", SetVerifyMode); - NODE_SET_PROTOTYPE_METHOD(t, - "enableSessionCallbacks", - EnableSessionCallbacks); - NODE_SET_PROTOTYPE_METHOD(t, - "enableHelloParser", - EnableHelloParser); + env->SetProtoMethod(t, "receive", Receive); + env->SetProtoMethod(t, "start", Start); + env->SetProtoMethod(t, "setVerifyMode", SetVerifyMode); + env->SetProtoMethod(t, "enableSessionCallbacks", EnableSessionCallbacks); + env->SetProtoMethod(t, "enableHelloParser", EnableHelloParser); SSLWrap::AddMethods(env, t); #ifdef SSL_CTRL_SET_TLSEXT_SERVERNAME_CB - NODE_SET_PROTOTYPE_METHOD(t, "getServername", GetServername); - NODE_SET_PROTOTYPE_METHOD(t, "setServername", SetServername); + env->SetProtoMethod(t, "getServername", GetServername); + env->SetProtoMethod(t, "setServername", SetServername); #endif // SSL_CRT_SET_TLSEXT_SERVERNAME_CB env->set_tls_wrap_constructor_function(t->GetFunction()); diff --git a/src/tty_wrap.cc b/src/tty_wrap.cc index bd9368d3ac..1e5eff3a67 100644 --- a/src/tty_wrap.cc +++ b/src/tty_wrap.cc @@ -52,7 +52,7 @@ void TTYWrap::Initialize(Handle target, Handle context) { Environment* env = Environment::GetCurrent(context); - Local t = FunctionTemplate::New(env->isolate(), New); + Local t = env->NewFunctionTemplate(New); t->SetClassName(FIXED_ONE_BYTE_STRING(env->isolate(), "TTY")); t->InstanceTemplate()->SetInternalFieldCount(1); @@ -65,27 +65,23 @@ void TTYWrap::Initialize(Handle target, v8::DEFAULT, attributes); - NODE_SET_PROTOTYPE_METHOD(t, "close", HandleWrap::Close); - NODE_SET_PROTOTYPE_METHOD(t, "unref", HandleWrap::Unref); + env->SetProtoMethod(t, "close", HandleWrap::Close); + env->SetProtoMethod(t, "unref", HandleWrap::Unref); - NODE_SET_PROTOTYPE_METHOD(t, "readStart", StreamWrap::ReadStart); - NODE_SET_PROTOTYPE_METHOD(t, "readStop", StreamWrap::ReadStop); + env->SetProtoMethod(t, "readStart", StreamWrap::ReadStart); + env->SetProtoMethod(t, "readStop", StreamWrap::ReadStop); - NODE_SET_PROTOTYPE_METHOD(t, "writeBuffer", StreamWrap::WriteBuffer); - NODE_SET_PROTOTYPE_METHOD(t, - "writeAsciiString", - StreamWrap::WriteAsciiString); - NODE_SET_PROTOTYPE_METHOD(t, "writeUtf8String", StreamWrap::WriteUtf8String); - NODE_SET_PROTOTYPE_METHOD(t, "writeUcs2String", StreamWrap::WriteUcs2String); - NODE_SET_PROTOTYPE_METHOD(t, - "writeBinaryString", - StreamWrap::WriteBinaryString); + env->SetProtoMethod(t, "writeBuffer", StreamWrap::WriteBuffer); + env->SetProtoMethod(t, "writeAsciiString", StreamWrap::WriteAsciiString); + env->SetProtoMethod(t, "writeUtf8String", StreamWrap::WriteUtf8String); + env->SetProtoMethod(t, "writeUcs2String", StreamWrap::WriteUcs2String); + env->SetProtoMethod(t, "writeBinaryString", StreamWrap::WriteBinaryString); - NODE_SET_PROTOTYPE_METHOD(t, "getWindowSize", TTYWrap::GetWindowSize); - NODE_SET_PROTOTYPE_METHOD(t, "setRawMode", SetRawMode); + env->SetProtoMethod(t, "getWindowSize", TTYWrap::GetWindowSize); + env->SetProtoMethod(t, "setRawMode", SetRawMode); - NODE_SET_METHOD(target, "isTTY", IsTTY); - NODE_SET_METHOD(target, "guessHandleType", GuessHandleType); + env->SetMethod(target, "isTTY", IsTTY); + env->SetMethod(target, "guessHandleType", GuessHandleType); target->Set(FIXED_ONE_BYTE_STRING(env->isolate(), "TTY"), t->GetFunction()); env->set_tty_constructor_template(t); @@ -98,7 +94,7 @@ uv_tty_t* TTYWrap::UVHandle() { void TTYWrap::GuessHandleType(const FunctionCallbackInfo& args) { - Environment* env = Environment::GetCurrent(args.GetIsolate()); + Environment* env = Environment::GetCurrent(args); int fd = args[0]->Int32Value(); CHECK_GE(fd, 0); @@ -129,7 +125,7 @@ void TTYWrap::IsTTY(const FunctionCallbackInfo& args) { void TTYWrap::GetWindowSize(const FunctionCallbackInfo& args) { - Environment* env = Environment::GetCurrent(args.GetIsolate()); + Environment* env = Environment::GetCurrent(args); TTYWrap* wrap = Unwrap(args.Holder()); CHECK(args[0]->IsArray()); @@ -155,7 +151,7 @@ void TTYWrap::SetRawMode(const FunctionCallbackInfo& args) { void TTYWrap::New(const FunctionCallbackInfo& args) { - Environment* env = Environment::GetCurrent(args.GetIsolate()); + Environment* env = Environment::GetCurrent(args); // This constructor should not be exposed to public javascript. // Therefore we assert that we are not trying to call this as a diff --git a/src/udp_wrap.cc b/src/udp_wrap.cc index 5e2e7e2af1..d41567d25c 100644 --- a/src/udp_wrap.cc +++ b/src/udp_wrap.cc @@ -91,7 +91,7 @@ void UDPWrap::Initialize(Handle target, Handle context) { Environment* env = Environment::GetCurrent(context); - Local t = FunctionTemplate::New(env->isolate(), New); + Local t = env->NewFunctionTemplate(New); t->InstanceTemplate()->SetInternalFieldCount(1); t->SetClassName(FIXED_ONE_BYTE_STRING(env->isolate(), "UDP")); @@ -104,23 +104,23 @@ void UDPWrap::Initialize(Handle target, v8::DEFAULT, attributes); - NODE_SET_PROTOTYPE_METHOD(t, "bind", Bind); - NODE_SET_PROTOTYPE_METHOD(t, "send", Send); - NODE_SET_PROTOTYPE_METHOD(t, "bind6", Bind6); - NODE_SET_PROTOTYPE_METHOD(t, "send6", Send6); - NODE_SET_PROTOTYPE_METHOD(t, "close", Close); - NODE_SET_PROTOTYPE_METHOD(t, "recvStart", RecvStart); - NODE_SET_PROTOTYPE_METHOD(t, "recvStop", RecvStop); - NODE_SET_PROTOTYPE_METHOD(t, "getsockname", GetSockName); - NODE_SET_PROTOTYPE_METHOD(t, "addMembership", AddMembership); - NODE_SET_PROTOTYPE_METHOD(t, "dropMembership", DropMembership); - NODE_SET_PROTOTYPE_METHOD(t, "setMulticastTTL", SetMulticastTTL); - NODE_SET_PROTOTYPE_METHOD(t, "setMulticastLoopback", SetMulticastLoopback); - NODE_SET_PROTOTYPE_METHOD(t, "setBroadcast", SetBroadcast); - NODE_SET_PROTOTYPE_METHOD(t, "setTTL", SetTTL); - - NODE_SET_PROTOTYPE_METHOD(t, "ref", HandleWrap::Ref); - NODE_SET_PROTOTYPE_METHOD(t, "unref", HandleWrap::Unref); + env->SetProtoMethod(t, "bind", Bind); + env->SetProtoMethod(t, "send", Send); + env->SetProtoMethod(t, "bind6", Bind6); + env->SetProtoMethod(t, "send6", Send6); + env->SetProtoMethod(t, "close", Close); + env->SetProtoMethod(t, "recvStart", RecvStart); + env->SetProtoMethod(t, "recvStop", RecvStop); + env->SetProtoMethod(t, "getsockname", GetSockName); + env->SetProtoMethod(t, "addMembership", AddMembership); + env->SetProtoMethod(t, "dropMembership", DropMembership); + env->SetProtoMethod(t, "setMulticastTTL", SetMulticastTTL); + env->SetProtoMethod(t, "setMulticastLoopback", SetMulticastLoopback); + env->SetProtoMethod(t, "setBroadcast", SetBroadcast); + env->SetProtoMethod(t, "setTTL", SetTTL); + + env->SetProtoMethod(t, "ref", HandleWrap::Ref); + env->SetProtoMethod(t, "unref", HandleWrap::Unref); target->Set(FIXED_ONE_BYTE_STRING(env->isolate(), "UDP"), t->GetFunction()); env->set_udp_constructor_function(t->GetFunction()); @@ -129,15 +129,14 @@ void UDPWrap::Initialize(Handle target, void UDPWrap::New(const FunctionCallbackInfo& args) { CHECK(args.IsConstructCall()); - Environment* env = Environment::GetCurrent(args.GetIsolate()); + Environment* env = Environment::GetCurrent(args); new UDPWrap(env, args.This()); } void UDPWrap::GetFD(Local, const PropertyCallbackInfo& args) { #if !defined(_WIN32) - Environment* env = Environment::GetCurrent(args.GetIsolate()); - HandleScope scope(env->isolate()); + HandleScope scope(args.GetIsolate()); UDPWrap* wrap = Unwrap(args.Holder()); int fd = (wrap == NULL) ? -1 : wrap->handle_.io_watcher.fd; args.GetReturnValue().Set(fd); @@ -239,7 +238,7 @@ void UDPWrap::DropMembership(const FunctionCallbackInfo& args) { void UDPWrap::DoSend(const FunctionCallbackInfo& args, int family) { - Environment* env = Environment::GetCurrent(args.GetIsolate()); + Environment* env = Environment::GetCurrent(args); UDPWrap* wrap = Unwrap(args.Holder()); @@ -326,7 +325,7 @@ void UDPWrap::RecvStop(const FunctionCallbackInfo& args) { void UDPWrap::GetSockName(const FunctionCallbackInfo& args) { - Environment* env = Environment::GetCurrent(args.GetIsolate()); + Environment* env = Environment::GetCurrent(args); struct sockaddr_storage address; UDPWrap* wrap = Unwrap(args.Holder()); diff --git a/src/uv.cc b/src/uv.cc index de99b6e66d..d437001bd7 100644 --- a/src/uv.cc +++ b/src/uv.cc @@ -38,7 +38,7 @@ using v8::Value; void ErrName(const FunctionCallbackInfo& args) { - Environment* env = Environment::GetCurrent(args.GetIsolate()); + Environment* env = Environment::GetCurrent(args); int err = args[0]->Int32Value(); if (err >= 0) return env->ThrowError("err >= 0"); @@ -52,7 +52,7 @@ void Initialize(Handle target, Handle context) { Environment* env = Environment::GetCurrent(context); target->Set(FIXED_ONE_BYTE_STRING(env->isolate(), "errname"), - FunctionTemplate::New(env->isolate(), ErrName)->GetFunction()); + env->NewFunctionTemplate(ErrName)->GetFunction()); #define V(name, _) \ target->Set(FIXED_ONE_BYTE_STRING(env->isolate(), "UV_" # name), \ Integer::New(env->isolate(), UV_ ## name));