From 09724b311ee44e6c7998c7a5cb39e739609eba66 Mon Sep 17 00:00:00 2001 From: Ben Noordhuis Date: Mon, 11 Nov 2013 22:02:03 +0100 Subject: src: fix Environment::GetCurrent() usage Create a HandleScope before calling the Environment::GetCurrent() that takes a v8::Isolate* as an argument because it creates a handle with the call to v8::Isolate::CurrentContext(). --- src/async-wrap-inl.h | 4 ++-- src/cares_wrap.cc | 8 ++++---- src/fs_event_wrap.cc | 4 +--- src/node.cc | 23 ++++++++++++++--------- src/node_buffer.cc | 19 +++++++++++++------ src/node_contextify.cc | 4 ++-- src/node_crypto.cc | 16 +++++++++++----- src/node_file.cc | 2 +- src/node_http_parser.cc | 6 +++--- src/node_stat_watcher.cc | 2 +- src/node_zlib.cc | 2 +- src/pipe_wrap.cc | 4 ++-- src/process_wrap.cc | 4 ++-- src/signal_wrap.cc | 2 +- src/smalloc.cc | 3 ++- src/stream_wrap.cc | 8 ++++---- src/tcp_wrap.cc | 10 +++++----- src/timer_wrap.cc | 4 ++-- src/tls_wrap.cc | 2 +- src/tty_wrap.cc | 2 +- src/udp_wrap.cc | 6 +++--- 21 files changed, 76 insertions(+), 59 deletions(-) (limited to 'src') diff --git a/src/async-wrap-inl.h b/src/async-wrap-inl.h index b342cabfe6..1de29583b5 100644 --- a/src/async-wrap-inl.h +++ b/src/async-wrap-inl.h @@ -191,8 +191,8 @@ inline v8::Handle AsyncWrap::MakeCallback( template inline void AsyncWrap::AddAsyncListener( const v8::FunctionCallbackInfo& args) { - Environment* env = Environment::GetCurrent(args.GetIsolate()); v8::HandleScope handle_scope(args.GetIsolate()); + Environment* env = Environment::GetCurrent(args.GetIsolate()); v8::Local handle = args.This(); v8::Local listener = args[0]; @@ -211,8 +211,8 @@ inline void AsyncWrap::AddAsyncListener( template inline void AsyncWrap::RemoveAsyncListener( const v8::FunctionCallbackInfo& args) { - Environment* env = Environment::GetCurrent(args.GetIsolate()); v8::HandleScope handle_scope(args.GetIsolate()); + Environment* env = Environment::GetCurrent(args.GetIsolate()); v8::Local handle = args.This(); v8::Local listener = args[0]; diff --git a/src/cares_wrap.cc b/src/cares_wrap.cc index 7758749d02..8145c595a5 100644 --- a/src/cares_wrap.cc +++ b/src/cares_wrap.cc @@ -776,8 +776,8 @@ class GetHostByNameWrap: public QueryWrap { template static void Query(const FunctionCallbackInfo& args) { - Environment* env = Environment::GetCurrent(args.GetIsolate()); HandleScope handle_scope(args.GetIsolate()); + Environment* env = Environment::GetCurrent(args.GetIsolate()); assert(!args.IsConstructCall()); assert(args[0]->IsObject()); @@ -911,8 +911,8 @@ static void IsIP(const FunctionCallbackInfo& args) { static void GetAddrInfo(const FunctionCallbackInfo& args) { - Environment* env = Environment::GetCurrent(args.GetIsolate()); HandleScope handle_scope(args.GetIsolate()); + Environment* env = Environment::GetCurrent(args.GetIsolate()); assert(args[0]->IsObject()); assert(args[1]->IsString()); @@ -958,8 +958,8 @@ static void GetAddrInfo(const FunctionCallbackInfo& args) { static void GetServers(const FunctionCallbackInfo& args) { - Environment* env = Environment::GetCurrent(args.GetIsolate()); HandleScope handle_scope(args.GetIsolate()); + Environment* env = Environment::GetCurrent(args.GetIsolate()); Local server_array = Array::New(); @@ -988,8 +988,8 @@ static void GetServers(const FunctionCallbackInfo& args) { static void SetServers(const FunctionCallbackInfo& args) { - Environment* env = Environment::GetCurrent(args.GetIsolate()); HandleScope handle_scope(args.GetIsolate()); + Environment* env = Environment::GetCurrent(args.GetIsolate()); assert(args[0]->IsArray()); diff --git a/src/fs_event_wrap.cc b/src/fs_event_wrap.cc index 5dbc278846..8563b40f36 100644 --- a/src/fs_event_wrap.cc +++ b/src/fs_event_wrap.cc @@ -78,9 +78,6 @@ FSEventWrap::~FSEventWrap() { void FSEventWrap::Initialize(Handle target, Handle unused, Handle context) { - Environment* env = Environment::GetCurrent(context); - HandleScope handle_scope(env->isolate()); - Local t = FunctionTemplate::New(New); t->InstanceTemplate()->SetInternalFieldCount(1); t->SetClassName(FIXED_ONE_BYTE_STRING(node_isolate, "FSEvent")); @@ -94,6 +91,7 @@ void FSEventWrap::Initialize(Handle target, void FSEventWrap::New(const FunctionCallbackInfo& args) { assert(args.IsConstructCall()); + HandleScope handle_scope(args.GetIsolate()); Environment* env = Environment::GetCurrent(args.GetIsolate()); new FSEventWrap(env, args.This()); } diff --git a/src/node.cc b/src/node.cc index 3cb6a22a5f..93926cd8bd 100644 --- a/src/node.cc +++ b/src/node.cc @@ -845,8 +845,8 @@ Local WinapiErrnoException(int errorno, void SetupAsyncListener(const FunctionCallbackInfo& args) { - Environment* env = Environment::GetCurrent(args.GetIsolate()); HandleScope handle_scope(args.GetIsolate()); + Environment* env = Environment::GetCurrent(args.GetIsolate()); assert(args[0]->IsObject()); assert(args[1]->IsFunction()); @@ -875,8 +875,8 @@ void SetupAsyncListener(const FunctionCallbackInfo& args) { void SetupNextTick(const FunctionCallbackInfo& args) { - Environment* env = Environment::GetCurrent(args.GetIsolate()); HandleScope handle_scope(args.GetIsolate()); + Environment* env = Environment::GetCurrent(args.GetIsolate()); assert(args[0]->IsObject() && args[1]->IsFunction()); @@ -1648,8 +1648,8 @@ static void Uptime(const FunctionCallbackInfo& args) { void MemoryUsage(const FunctionCallbackInfo& args) { - Environment* env = Environment::GetCurrent(args.GetIsolate()); HandleScope handle_scope(args.GetIsolate()); + Environment* env = Environment::GetCurrent(args.GetIsolate()); size_t rss; int err = uv_resident_set_memory(&rss); @@ -1728,8 +1728,8 @@ 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()); HandleScope handle_scope(args.GetIsolate()); + Environment* env = Environment::GetCurrent(args.GetIsolate()); char symbol[1024], *base, *pos; uv_lib_t lib; int r; @@ -1898,8 +1898,8 @@ void OnMessage(Handle message, Handle error) { static void Binding(const FunctionCallbackInfo& args) { - Environment* env = Environment::GetCurrent(args.GetIsolate()); HandleScope handle_scope(args.GetIsolate()); + Environment* env = Environment::GetCurrent(args.GetIsolate()); Local module = args[0]->ToString(); String::Utf8Value module_v(module); @@ -2181,6 +2181,7 @@ static void DebugEnd(const FunctionCallbackInfo& args); void NeedImmediateCallbackGetter(Local property, const PropertyCallbackInfo& info) { + HandleScope handle_scope(info.GetIsolate()); Environment* env = Environment::GetCurrent(info.GetIsolate()); const uv_check_t* immediate_check_handle = env->immediate_check_handle(); bool active = uv_is_active( @@ -2193,8 +2194,8 @@ static void NeedImmediateCallbackSetter( Local property, Local value, const PropertyCallbackInfo& info) { - Environment* env = Environment::GetCurrent(info.GetIsolate()); HandleScope handle_scope(info.GetIsolate()); + Environment* env = Environment::GetCurrent(info.GetIsolate()); uv_check_t* immediate_check_handle = env->immediate_check_handle(); bool active = uv_is_active( @@ -2241,12 +2242,16 @@ void StopProfilerIdleNotifier(Environment* env) { void StartProfilerIdleNotifier(const FunctionCallbackInfo& args) { - StartProfilerIdleNotifier(Environment::GetCurrent(args.GetIsolate())); + HandleScope handle_scope(args.GetIsolate()); + Environment* env = Environment::GetCurrent(args.GetIsolate()); + StartProfilerIdleNotifier(env); } void StopProfilerIdleNotifier(const FunctionCallbackInfo& args) { - StopProfilerIdleNotifier(Environment::GetCurrent(args.GetIsolate())); + HandleScope handle_scope(args.GetIsolate()); + Environment* env = Environment::GetCurrent(args.GetIsolate()); + StopProfilerIdleNotifier(env); } @@ -2761,6 +2766,7 @@ static void EnableDebug(bool wait_connect) { assert(debugger_running == false); Isolate* isolate = node_isolate; // TODO(bnoordhuis) Multi-isolate support. Isolate::Scope isolate_scope(isolate); + HandleScope handle_scope(isolate); v8::Debug::SetDebugMessageDispatchHandler(DispatchMessagesDebugAgentCallback, false); debugger_running = v8::Debug::EnableAgent("node " NODE_VERSION, @@ -2779,7 +2785,6 @@ static void EnableDebug(bool wait_connect) { return; // Still starting up. Context::Scope context_scope(env->context()); - HandleScope handle_scope(env->isolate()); Local message = Object::New(); message->Set(FIXED_ONE_BYTE_STRING(env->isolate(), "cmd"), FIXED_ONE_BYTE_STRING(env->isolate(), "NODE_DEBUG_ENABLED")); diff --git a/src/node_buffer.cc b/src/node_buffer.cc index 8c5bf3318c..c16129e0ce 100644 --- a/src/node_buffer.cc +++ b/src/node_buffer.cc @@ -127,8 +127,10 @@ Local New(Handle string, enum encoding enc) { Local New(size_t length) { + HandleScope handle_scope(node_isolate); Environment* env = Environment::GetCurrent(node_isolate); - return Buffer::New(env, length); + Local obj = Buffer::New(env, length); + return handle_scope.Close(obj); } @@ -160,8 +162,10 @@ Local New(Environment* env, size_t length) { Local New(const char* data, size_t length) { + HandleScope handle_scope(node_isolate); Environment* env = Environment::GetCurrent(node_isolate); - return Buffer::New(env, data, length); + Local obj = Buffer::New(env, data, length); + return handle_scope.Close(obj); } @@ -199,8 +203,10 @@ Local New(char* data, size_t length, smalloc::FreeCallback callback, void* hint) { + HandleScope handle_scope(node_isolate); Environment* env = Environment::GetCurrent(node_isolate); - return Buffer::New(env, data, length, callback, hint); + Local obj = Buffer::New(env, data, length, callback, hint); + return handle_scope.Close(obj); } @@ -223,8 +229,10 @@ Local New(Environment* env, Local Use(char* data, uint32_t length) { + HandleScope handle_scope(node_isolate); Environment* env = Environment::GetCurrent(node_isolate); - return Buffer::Use(env, data, length); + Local obj = Buffer::Use(env, data, length); + return handle_scope.Close(obj); } @@ -588,8 +596,8 @@ void ByteLength(const FunctionCallbackInfo &args) { // pass Buffer object to load prototype methods void SetupBufferJS(const FunctionCallbackInfo& args) { - Environment* env = Environment::GetCurrent(args.GetIsolate()); HandleScope handle_scope(args.GetIsolate()); + Environment* env = Environment::GetCurrent(args.GetIsolate()); assert(args[0]->IsFunction()); @@ -649,7 +657,6 @@ void Initialize(Handle target, Handle unused, Handle context) { Environment* env = Environment::GetCurrent(context); - HandleScope handle_scope(env->isolate()); target->Set(FIXED_ONE_BYTE_STRING(env->isolate(), "setupBufferJS"), FunctionTemplate::New(SetupBufferJS)->GetFunction()); } diff --git a/src/node_contextify.cc b/src/node_contextify.cc index d1568f8f48..508e329572 100644 --- a/src/node_contextify.cc +++ b/src/node_contextify.cc @@ -218,8 +218,8 @@ class ContextifyContext { static void MakeContext(const FunctionCallbackInfo& args) { - Environment* env = Environment::GetCurrent(args.GetIsolate()); HandleScope handle_scope(args.GetIsolate()); + Environment* env = Environment::GetCurrent(args.GetIsolate()); if (!args[0]->IsObject()) { return ThrowTypeError("sandbox argument must be an object."); @@ -449,8 +449,8 @@ class ContextifyScript : public WeakObject { // args: [options] static void RunInThisContext(const FunctionCallbackInfo& args) { - Environment* env = Environment::GetCurrent(args.GetIsolate()); HandleScope handle_scope(args.GetIsolate()); + Environment* env = Environment::GetCurrent(args.GetIsolate()); // Assemble arguments TryCatch try_catch; diff --git a/src/node_crypto.cc b/src/node_crypto.cc index 28ce89c7d7..952767397c 100644 --- a/src/node_crypto.cc +++ b/src/node_crypto.cc @@ -245,6 +245,7 @@ void SecureContext::Initialize(Environment* env, Handle target) { void SecureContext::New(const FunctionCallbackInfo& args) { + HandleScope handle_scope(args.GetIsolate()); Environment* env = Environment::GetCurrent(args.GetIsolate()); new SecureContext(env, args.This()); } @@ -2105,6 +2106,7 @@ void CipherBase::Initialize(Environment* env, Handle target) { void CipherBase::New(const FunctionCallbackInfo& args) { assert(args.IsConstructCall() == true); + HandleScope handle_scope(args.GetIsolate()); CipherKind kind = args[0]->IsTrue() ? kCipher : kDecipher; Environment* env = Environment::GetCurrent(args.GetIsolate()); new CipherBase(env, args.This(), kind); @@ -2241,8 +2243,8 @@ bool CipherBase::Update(const char* data, void CipherBase::Update(const FunctionCallbackInfo& args) { - Environment* env = Environment::GetCurrent(args.GetIsolate()); HandleScope handle_scope(args.GetIsolate()); + Environment* env = Environment::GetCurrent(args.GetIsolate()); CipherBase* cipher = Unwrap(args.This()); @@ -2310,8 +2312,8 @@ bool CipherBase::Final(unsigned char** out, int *out_len) { void CipherBase::Final(const FunctionCallbackInfo& args) { - Environment* env = Environment::GetCurrent(args.GetIsolate()); HandleScope handle_scope(args.GetIsolate()); + Environment* env = Environment::GetCurrent(args.GetIsolate()); CipherBase* cipher = Unwrap(args.This()); @@ -2348,6 +2350,7 @@ void Hmac::Initialize(Environment* env, v8::Handle target) { void Hmac::New(const FunctionCallbackInfo& args) { + HandleScope handle_scope(args.GetIsolate()); Environment* env = Environment::GetCurrent(args.GetIsolate()); new Hmac(env, args.This()); } @@ -2586,6 +2589,7 @@ void Sign::Initialize(Environment* env, v8::Handle target) { void Sign::New(const FunctionCallbackInfo& args) { + HandleScope handle_scope(args.GetIsolate()); Environment* env = Environment::GetCurrent(args.GetIsolate()); new Sign(env, args.This()); } @@ -2768,6 +2772,7 @@ void Verify::Initialize(Environment* env, v8::Handle target) { void Verify::New(const FunctionCallbackInfo& args) { + HandleScope handle_scope(args.GetIsolate()); Environment* env = Environment::GetCurrent(args.GetIsolate()); new Verify(env, args.This()); } @@ -3449,8 +3454,8 @@ void EIO_PBKDF2After(uv_work_t* work_req, int status) { void PBKDF2(const FunctionCallbackInfo& args) { - Environment* env = Environment::GetCurrent(args.GetIsolate()); HandleScope handle_scope(args.GetIsolate()); + Environment* env = Environment::GetCurrent(args.GetIsolate()); const char* type_error = NULL; char* pass = NULL; @@ -3655,8 +3660,8 @@ void RandomBytesAfter(uv_work_t* work_req, int status) { RandomBytesRequest, work_req_); Environment* env = req->env(); - Context::Scope context_scope(env->context()); HandleScope handle_scope(env->isolate()); + Context::Scope context_scope(env->context()); Local argv[2]; RandomBytesCheck(req, argv); req->MakeCallback(env->ondone_string(), ARRAY_SIZE(argv), argv); @@ -3666,8 +3671,8 @@ void RandomBytesAfter(uv_work_t* work_req, int status) { template void RandomBytes(const FunctionCallbackInfo& args) { - Environment* env = Environment::GetCurrent(args.GetIsolate()); HandleScope handle_scope(args.GetIsolate()); + Environment* env = Environment::GetCurrent(args.GetIsolate()); // maybe allow a buffer to write to? cuts down on object creation // when generating random data in a loop @@ -3776,6 +3781,7 @@ void Certificate::Initialize(Handle target) { void Certificate::New(const FunctionCallbackInfo& args) { + HandleScope handle_scope(args.GetIsolate()); Environment* env = Environment::GetCurrent(args.GetIsolate()); new Certificate(env, args.This()); } diff --git a/src/node_file.cc b/src/node_file.cc index 5650e4cc2d..80f8573d3e 100644 --- a/src/node_file.cc +++ b/src/node_file.cc @@ -731,8 +731,8 @@ 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()); HandleScope handle_scope(args.GetIsolate()); + Environment* env = Environment::GetCurrent(args.GetIsolate()); if (!args[0]->IsInt32()) return ThrowTypeError("First argument must be file descriptor"); diff --git a/src/node_http_parser.cc b/src/node_http_parser.cc index 12957010e5..66c6c7c4cf 100644 --- a/src/node_http_parser.cc +++ b/src/node_http_parser.cc @@ -337,8 +337,8 @@ class Parser : public WeakObject { static void New(const FunctionCallbackInfo& args) { - Environment* env = Environment::GetCurrent(args.GetIsolate()); HandleScope handle_scope(args.GetIsolate()); + Environment* env = Environment::GetCurrent(args.GetIsolate()); http_parser_type type = static_cast(args[0]->Int32Value()); assert(type == HTTP_REQUEST || type == HTTP_RESPONSE); @@ -445,8 +445,8 @@ class Parser : public WeakObject { static void Reinitialize(const FunctionCallbackInfo& args) { - Environment* env = Environment::GetCurrent(args.GetIsolate()); HandleScope handle_scope(args.GetIsolate()); + Environment* env = Environment::GetCurrent(args.GetIsolate()); http_parser_type type = static_cast(args[0]->Int32Value()); @@ -461,8 +461,8 @@ class Parser : public WeakObject { template static void Pause(const FunctionCallbackInfo& args) { - Environment* env = Environment::GetCurrent(args.GetIsolate()); HandleScope handle_scope(args.GetIsolate()); + Environment* env = Environment::GetCurrent(args.GetIsolate()); Parser* parser = Unwrap(args.This()); // Should always be called from the same context. assert(env == parser->env()); diff --git a/src/node_stat_watcher.cc b/src/node_stat_watcher.cc index b5a04c1f94..2f35d550bc 100644 --- a/src/node_stat_watcher.cc +++ b/src/node_stat_watcher.cc @@ -99,8 +99,8 @@ void StatWatcher::Callback(uv_fs_poll_t* handle, void StatWatcher::New(const FunctionCallbackInfo& args) { assert(args.IsConstructCall()); - Environment* env = Environment::GetCurrent(args.GetIsolate()); HandleScope handle_scope(args.GetIsolate()); + Environment* env = Environment::GetCurrent(args.GetIsolate()); new StatWatcher(env, args.This()); } diff --git a/src/node_zlib.cc b/src/node_zlib.cc index 5360b7a077..43bec55a4f 100644 --- a/src/node_zlib.cc +++ b/src/node_zlib.cc @@ -313,8 +313,8 @@ class ZCtx : public WeakObject { } static void New(const FunctionCallbackInfo& args) { - Environment* env = Environment::GetCurrent(args.GetIsolate()); HandleScope handle_scope(args.GetIsolate()); + Environment* env = Environment::GetCurrent(args.GetIsolate()); if (args.Length() < 1 || !args[0]->IsInt32()) { return ThrowTypeError("Bad argument"); diff --git a/src/pipe_wrap.cc b/src/pipe_wrap.cc index a522775743..e5b6836050 100644 --- a/src/pipe_wrap.cc +++ b/src/pipe_wrap.cc @@ -123,8 +123,8 @@ void PipeWrap::New(const FunctionCallbackInfo& args) { // Therefore we assert that we are not trying to call this as a // normal function. assert(args.IsConstructCall()); - Environment* env = Environment::GetCurrent(args.GetIsolate()); HandleScope handle_scope(args.GetIsolate()); + Environment* env = Environment::GetCurrent(args.GetIsolate()); new PipeWrap(env, args.This(), args[0]->IsTrue()); } @@ -266,8 +266,8 @@ void PipeWrap::Open(const FunctionCallbackInfo& args) { void PipeWrap::Connect(const FunctionCallbackInfo& args) { - Environment* env = Environment::GetCurrent(args.GetIsolate()); HandleScope scope(args.GetIsolate()); + Environment* env = Environment::GetCurrent(args.GetIsolate()); PipeWrap* wrap = Unwrap(args.This()); diff --git a/src/process_wrap.cc b/src/process_wrap.cc index 7b8125ceba..83126be6d0 100644 --- a/src/process_wrap.cc +++ b/src/process_wrap.cc @@ -72,8 +72,8 @@ class ProcessWrap : public HandleWrap { // Therefore we assert that we are not trying to call this as a // normal function. assert(args.IsConstructCall()); - Environment* env = Environment::GetCurrent(args.GetIsolate()); HandleScope handle_scope(args.GetIsolate()); + Environment* env = Environment::GetCurrent(args.GetIsolate()); new ProcessWrap(env, args.This()); } @@ -130,8 +130,8 @@ class ProcessWrap : public HandleWrap { } static void Spawn(const FunctionCallbackInfo& args) { - Environment* env = Environment::GetCurrent(args.GetIsolate()); HandleScope handle_scope(args.GetIsolate()); + Environment* env = Environment::GetCurrent(args.GetIsolate()); ProcessWrap* wrap = Unwrap(args.This()); diff --git a/src/signal_wrap.cc b/src/signal_wrap.cc index b38ca38d0c..1eade0bd96 100644 --- a/src/signal_wrap.cc +++ b/src/signal_wrap.cc @@ -66,8 +66,8 @@ class SignalWrap : public HandleWrap { // Therefore we assert that we are not trying to call this as a // normal function. assert(args.IsConstructCall()); - Environment* env = Environment::GetCurrent(args.GetIsolate()); HandleScope handle_scope(args.GetIsolate()); + Environment* env = Environment::GetCurrent(args.GetIsolate()); new SignalWrap(env, args.This()); } diff --git a/src/smalloc.cc b/src/smalloc.cc index 62a57fada9..0e830bb32f 100644 --- a/src/smalloc.cc +++ b/src/smalloc.cc @@ -297,8 +297,8 @@ void AllocDispose(const FunctionCallbackInfo& args) { void AllocDispose(Handle obj) { + HandleScope handle_scope(node_isolate); Environment* env = Environment::GetCurrent(node_isolate); - HandleScope handle_scope(env->isolate()); if (env->using_smalloc_alloc_cb()) { Local ext_v = obj->GetHiddenValue(env->smalloc_p_string()); @@ -360,6 +360,7 @@ void Alloc(Handle obj, enum ExternalArrayType type) { assert(!obj->HasIndexedPropertiesInExternalArrayData()); + HandleScope handle_scope(node_isolate); Environment* env = Environment::GetCurrent(node_isolate); env->set_using_smalloc_alloc_cb(true); diff --git a/src/stream_wrap.cc b/src/stream_wrap.cc index 507819e6cd..69ba23d7c4 100644 --- a/src/stream_wrap.cc +++ b/src/stream_wrap.cc @@ -190,8 +190,8 @@ size_t StreamWrap::WriteBuffer(Handle val, uv_buf_t* buf) { void StreamWrap::WriteBuffer(const FunctionCallbackInfo& args) { - Environment* env = Environment::GetCurrent(args.GetIsolate()); HandleScope handle_scope(args.GetIsolate()); + Environment* env = Environment::GetCurrent(args.GetIsolate()); StreamWrap* wrap = Unwrap(args.This()); @@ -229,8 +229,8 @@ void StreamWrap::WriteBuffer(const FunctionCallbackInfo& args) { template void StreamWrap::WriteStringImpl(const FunctionCallbackInfo& args) { - Environment* env = Environment::GetCurrent(args.GetIsolate()); HandleScope handle_scope(args.GetIsolate()); + Environment* env = Environment::GetCurrent(args.GetIsolate()); int err; StreamWrap* wrap = Unwrap(args.This()); @@ -313,8 +313,8 @@ void StreamWrap::WriteStringImpl(const FunctionCallbackInfo& args) { void StreamWrap::Writev(const FunctionCallbackInfo& args) { - Environment* env = Environment::GetCurrent(args.GetIsolate()); HandleScope handle_scope(args.GetIsolate()); + Environment* env = Environment::GetCurrent(args.GetIsolate()); StreamWrap* wrap = Unwrap(args.This()); @@ -459,8 +459,8 @@ void StreamWrap::AfterWrite(uv_write_t* req, int status) { void StreamWrap::Shutdown(const FunctionCallbackInfo& args) { - Environment* env = Environment::GetCurrent(args.GetIsolate()); HandleScope handle_scope(args.GetIsolate()); + Environment* env = Environment::GetCurrent(args.GetIsolate()); StreamWrap* wrap = Unwrap(args.This()); diff --git a/src/tcp_wrap.cc b/src/tcp_wrap.cc index 85fff070a6..be05a294ea 100644 --- a/src/tcp_wrap.cc +++ b/src/tcp_wrap.cc @@ -133,8 +133,8 @@ void TCPWrap::New(const FunctionCallbackInfo& args) { // Therefore we assert that we are not trying to call this as a // normal function. assert(args.IsConstructCall()); - Environment* env = Environment::GetCurrent(args.GetIsolate()); HandleScope handle_scope(args.GetIsolate()); + Environment* env = Environment::GetCurrent(args.GetIsolate()); TCPWrap* wrap = new TCPWrap(env, args.This()); assert(wrap); } @@ -155,8 +155,8 @@ TCPWrap::~TCPWrap() { void TCPWrap::GetSockName(const FunctionCallbackInfo& args) { - Environment* env = Environment::GetCurrent(args.GetIsolate()); HandleScope handle_scope(args.GetIsolate()); + Environment* env = Environment::GetCurrent(args.GetIsolate()); struct sockaddr_storage address; TCPWrap* wrap = Unwrap(args.This()); @@ -178,8 +178,8 @@ void TCPWrap::GetSockName(const FunctionCallbackInfo& args) { void TCPWrap::GetPeerName(const FunctionCallbackInfo& args) { - Environment* env = Environment::GetCurrent(args.GetIsolate()); HandleScope handle_scope(args.GetIsolate()); + Environment* env = Environment::GetCurrent(args.GetIsolate()); struct sockaddr_storage address; TCPWrap* wrap = Unwrap(args.This()); @@ -356,8 +356,8 @@ void TCPWrap::AfterConnect(uv_connect_t* req, int status) { void TCPWrap::Connect(const FunctionCallbackInfo& args) { - Environment* env = Environment::GetCurrent(args.GetIsolate()); HandleScope handle_scope(args.GetIsolate()); + Environment* env = Environment::GetCurrent(args.GetIsolate()); TCPWrap* wrap = Unwrap(args.This()); @@ -388,8 +388,8 @@ void TCPWrap::Connect(const FunctionCallbackInfo& args) { void TCPWrap::Connect6(const FunctionCallbackInfo& args) { - Environment* env = Environment::GetCurrent(args.GetIsolate()); HandleScope handle_scope(args.GetIsolate()); + Environment* env = Environment::GetCurrent(args.GetIsolate()); TCPWrap* wrap = Unwrap(args.This()); diff --git a/src/timer_wrap.cc b/src/timer_wrap.cc index 393def3d59..01a50f0024 100644 --- a/src/timer_wrap.cc +++ b/src/timer_wrap.cc @@ -77,8 +77,8 @@ class TimerWrap : public HandleWrap { // Therefore we assert that we are not trying to call this as a // normal function. assert(args.IsConstructCall()); - Environment* env = Environment::GetCurrent(args.GetIsolate()); HandleScope handle_scope(args.GetIsolate()); + Environment* env = Environment::GetCurrent(args.GetIsolate()); new TimerWrap(env, args.This()); } @@ -144,8 +144,8 @@ class TimerWrap : public HandleWrap { } static void Now(const FunctionCallbackInfo& args) { - Environment* env = Environment::GetCurrent(args.GetIsolate()); HandleScope handle_scope(args.GetIsolate()); + Environment* env = Environment::GetCurrent(args.GetIsolate()); uv_update_time(env->event_loop()); double now = static_cast(uv_now(env->event_loop())); args.GetReturnValue().Set(now); diff --git a/src/tls_wrap.cc b/src/tls_wrap.cc index a18b6c1da4..2dd8016c59 100644 --- a/src/tls_wrap.cc +++ b/src/tls_wrap.cc @@ -181,8 +181,8 @@ void TLSCallbacks::InitSSL() { void TLSCallbacks::Wrap(const FunctionCallbackInfo& args) { - Environment* env = Environment::GetCurrent(args.GetIsolate()); HandleScope handle_scope(args.GetIsolate()); + Environment* env = Environment::GetCurrent(args.GetIsolate()); if (args.Length() < 1 || !args[0]->IsObject()) return ThrowTypeError("First argument should be a StreamWrap instance"); diff --git a/src/tty_wrap.cc b/src/tty_wrap.cc index 6a0b282377..0f7e390748 100644 --- a/src/tty_wrap.cc +++ b/src/tty_wrap.cc @@ -157,8 +157,8 @@ void TTYWrap::SetRawMode(const FunctionCallbackInfo& args) { void TTYWrap::New(const FunctionCallbackInfo& args) { - Environment* env = Environment::GetCurrent(args.GetIsolate()); HandleScope handle_scope(args.GetIsolate()); + Environment* env = Environment::GetCurrent(args.GetIsolate()); // 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 5a16a55b4e..8424ff080e 100644 --- a/src/udp_wrap.cc +++ b/src/udp_wrap.cc @@ -129,8 +129,8 @@ void UDPWrap::Initialize(Handle target, void UDPWrap::New(const FunctionCallbackInfo& args) { assert(args.IsConstructCall()); - Environment* env = Environment::GetCurrent(args.GetIsolate()); HandleScope handle_scope(args.GetIsolate()); + Environment* env = Environment::GetCurrent(args.GetIsolate()); new UDPWrap(env, args.This()); } @@ -243,8 +243,8 @@ void UDPWrap::DropMembership(const FunctionCallbackInfo& args) { void UDPWrap::DoSend(const FunctionCallbackInfo& args, int family) { - Environment* env = Environment::GetCurrent(args.GetIsolate()); HandleScope handle_scope(args.GetIsolate()); + Environment* env = Environment::GetCurrent(args.GetIsolate()); UDPWrap* wrap = Unwrap(args.This()); @@ -336,8 +336,8 @@ void UDPWrap::RecvStop(const FunctionCallbackInfo& args) { void UDPWrap::GetSockName(const FunctionCallbackInfo& args) { - Environment* env = Environment::GetCurrent(args.GetIsolate()); HandleScope handle_scope(args.GetIsolate()); + Environment* env = Environment::GetCurrent(args.GetIsolate()); struct sockaddr_storage address; UDPWrap* wrap = Unwrap(args.This()); -- cgit v1.2.3