Browse Source

src: attach env directly to api functions

Attach the per-context execution environment directly to API functions.
Rationale:

 * Gets node one step closer to multi-isolate readiness.

 * Avoids multi-context confusion, e.g. when the caller and callee live
   in different contexts.

 * Avoids expensive calls to pthread_getspecific() on platforms where
   V8 does not know how to use the thread-local storage directly.
   (Linux, the BSDs.)

PR-URL: https://github.com/node-forward/node/pull/18
Reviewed-By: Fedor Indutny <fedor@indutny.com>
archived-io.js-v0.12
Ben Noordhuis 10 years ago
committed by Fedor Indutny
parent
commit
d3c317e08a
  1. 48
      src/cares_wrap.cc
  2. 56
      src/env-inl.h
  3. 23
      src/env.h
  4. 10
      src/fs_event_wrap.cc
  5. 2
      src/handle_wrap.cc
  6. 108
      src/node.cc
  7. 61
      src/node_buffer.cc
  8. 27
      src/node_contextify.cc
  9. 3
      src/node_counters.cc
  10. 329
      src/node_crypto.cc
  11. 19
      src/node_dtrace.cc
  12. 121
      src/node_file.cc
  13. 25
      src/node_http_parser.cc
  14. 35
      src/node_os.cc
  15. 9
      src/node_stat_watcher.cc
  16. 13
      src/node_v8.cc
  17. 18
      src/node_zlib.cc
  18. 46
      src/pipe_wrap.cc
  19. 17
      src/process_wrap.cc
  20. 15
      src/signal_wrap.cc
  21. 22
      src/smalloc.cc
  22. 6
      src/spawn_sync.cc
  23. 11
      src/stream_wrap.cc
  24. 72
      src/tcp_wrap.cc
  25. 25
      src/timer_wrap.cc
  26. 30
      src/tls_wrap.cc
  27. 38
      src/tty_wrap.cc
  28. 45
      src/udp_wrap.cc
  29. 4
      src/uv.cc

48
src/cares_wrap.cc

@ -840,7 +840,7 @@ class GetHostByNameWrap: public QueryWrap {
template <class Wrap>
static void Query(const FunctionCallbackInfo<Value>& 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<Value>& args) {
static void GetAddrInfo(const FunctionCallbackInfo<Value>& 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<Value>& args) {
static void GetNameInfo(const FunctionCallbackInfo<Value>& 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<Value>& args) {
static void GetServers(const FunctionCallbackInfo<Value>& args) {
Environment* env = Environment::GetCurrent(args.GetIsolate());
Environment* env = Environment::GetCurrent(args);
Local<Array> server_array = Array::New(env->isolate());
@ -1116,7 +1116,7 @@ static void GetServers(const FunctionCallbackInfo<Value>& args) {
static void SetServers(const FunctionCallbackInfo<Value>& 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<Value>& args) {
static void StrError(const FunctionCallbackInfo<Value>& 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<Object> target,
CaresTimerClose,
NULL);
NODE_SET_METHOD(target, "queryA", Query<QueryAWrap>);
NODE_SET_METHOD(target, "queryAaaa", Query<QueryAaaaWrap>);
NODE_SET_METHOD(target, "queryCname", Query<QueryCnameWrap>);
NODE_SET_METHOD(target, "queryMx", Query<QueryMxWrap>);
NODE_SET_METHOD(target, "queryNs", Query<QueryNsWrap>);
NODE_SET_METHOD(target, "queryTxt", Query<QueryTxtWrap>);
NODE_SET_METHOD(target, "querySrv", Query<QuerySrvWrap>);
NODE_SET_METHOD(target, "queryNaptr", Query<QueryNaptrWrap>);
NODE_SET_METHOD(target, "querySoa", Query<QuerySoaWrap>);
NODE_SET_METHOD(target, "getHostByAddr", Query<GetHostByAddrWrap>);
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<QueryAWrap>);
env->SetMethod(target, "queryAaaa", Query<QueryAaaaWrap>);
env->SetMethod(target, "queryCname", Query<QueryCnameWrap>);
env->SetMethod(target, "queryMx", Query<QueryMxWrap>);
env->SetMethod(target, "queryNs", Query<QueryNsWrap>);
env->SetMethod(target, "queryTxt", Query<QueryTxtWrap>);
env->SetMethod(target, "querySrv", Query<QuerySrvWrap>);
env->SetMethod(target, "queryNaptr", Query<QueryNaptrWrap>);
env->SetMethod(target, "querySoa", Query<QuerySoaWrap>);
env->SetMethod(target, "getHostByAddr", Query<GetHostByAddrWrap>);
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));

56
src/env-inl.h

@ -209,6 +209,18 @@ inline Environment* Environment::GetCurrent(v8::Local<v8::Context> context) {
context->GetAlignedPointerFromEmbedderData(kContextEmbedderDataIndex));
}
inline Environment* Environment::GetCurrent(
const v8::FunctionCallbackInfo<v8::Value>& info) {
ASSERT(info.Data()->IsExternal());
return static_cast<Environment*>(info.Data().As<v8::External>()->Value());
}
inline Environment* Environment::GetCurrent(
const v8::PropertyCallbackInfo<v8::Value>& info) {
ASSERT(info.Data()->IsExternal());
return static_cast<Environment*>(info.Data().As<v8::External>()->Value());
}
inline Environment::Environment(v8::Local<v8::Context> 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<v8::FunctionTemplate>
Environment::NewFunctionTemplate(v8::FunctionCallback callback,
v8::Local<v8::Signature> signature) {
v8::Local<v8::External> 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<v8::Object> that,
const char* name,
v8::FunctionCallback callback) {
v8::Local<v8::Function> function =
NewFunctionTemplate(callback)->GetFunction();
v8::Local<v8::String> 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<v8::FunctionTemplate> that,
const char* name,
v8::FunctionCallback callback) {
v8::Local<v8::Signature> signature = v8::Signature::New(isolate(), that);
v8::Local<v8::Function> function =
NewFunctionTemplate(callback, signature)->GetFunction();
v8::Local<v8::String> 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<v8::FunctionTemplate> that,
const char* name,
v8::FunctionCallback callback) {
v8::Local<v8::Function> function =
NewFunctionTemplate(callback)->GetFunction();
v8::Local<v8::String> 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<v8::String> Environment::IsolateData::PropertyName() const { \

23
src/env.h

@ -380,6 +380,10 @@ class Environment {
static inline Environment* GetCurrent(v8::Isolate* isolate);
static inline Environment* GetCurrent(v8::Local<v8::Context> context);
static inline Environment* GetCurrent(
const v8::FunctionCallbackInfo<v8::Value>& info);
static inline Environment* GetCurrent(
const v8::PropertyCallbackInfo<v8::Value>& info);
// See CreateEnvironment() in src/node.cc.
static inline Environment* New(v8::Local<v8::Context> 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<v8::FunctionTemplate>
NewFunctionTemplate(v8::FunctionCallback callback,
v8::Local<v8::Signature> signature =
v8::Local<v8::Signature>());
// Convenience methods for NewFunctionTemplate().
inline void SetMethod(v8::Local<v8::Object> that,
const char* name,
v8::FunctionCallback callback);
inline void SetProtoMethod(v8::Local<v8::FunctionTemplate> that,
const char* name,
v8::FunctionCallback callback);
inline void SetTemplateMethod(v8::Local<v8::FunctionTemplate> 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<v8::External> external_;
#define V(PropertyName, TypeName) \
v8::Persistent<TypeName> PropertyName ## _;
ENVIRONMENT_STRONG_PERSISTENT_PROPERTIES(V)

10
src/fs_event_wrap.cc

@ -83,12 +83,12 @@ void FSEventWrap::Initialize(Handle<Object> target,
Handle<Context> context) {
Environment* env = Environment::GetCurrent(context);
Local<FunctionTemplate> t = FunctionTemplate::New(env->isolate(), New);
Local<FunctionTemplate> 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<Object> target,
void FSEventWrap::New(const FunctionCallbackInfo<Value>& 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<Value>& args) {
Environment* env = Environment::GetCurrent(args.GetIsolate());
Environment* env = Environment::GetCurrent(args);
FSEventWrap* wrap = Unwrap<FSEventWrap>(args.Holder());

2
src/handle_wrap.cc

@ -61,7 +61,7 @@ void HandleWrap::Unref(const FunctionCallbackInfo<Value>& args) {
void HandleWrap::Close(const FunctionCallbackInfo<Value>& args) {
Environment* env = Environment::GetCurrent(args.GetIsolate());
Environment* env = Environment::GetCurrent(args);
HandleWrap* wrap = Unwrap<HandleWrap>(args.Holder());

108
src/node.cc

@ -918,7 +918,7 @@ Local<Value> WinapiErrnoException(Isolate* isolate,
void SetupAsyncListener(const FunctionCallbackInfo<Value>& 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<Value>& args) {
void SetupDomainUse(const FunctionCallbackInfo<Value>& 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<Value>& args) {
void SetupNextTick(const FunctionCallbackInfo<Value>& 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<Value>& args) {
env->set_tick_callback_function(args[1].As<Function>());
NODE_SET_METHOD(args[2].As<Object>(), "runMicrotasks", RunMicrotasks);
env->SetMethod(args[2].As<Object>(), "runMicrotasks", RunMicrotasks);
// Do a little housekeeping.
env->process_object()->Delete(
@ -1554,7 +1554,7 @@ static Local<Value> ExecuteString(Environment* env,
static void GetActiveRequests(const FunctionCallbackInfo<Value>& args) {
Environment* env = Environment::GetCurrent(args.GetIsolate());
Environment* env = Environment::GetCurrent(args);
Local<Array> ary = Array::New(args.GetIsolate());
QUEUE* q = NULL;
@ -1574,7 +1574,7 @@ static void GetActiveRequests(const FunctionCallbackInfo<Value>& args) {
// Non-static, friend of HandleWrap. Could have been a HandleWrap method but
// implemented here for consistency with GetActiveRequests().
void GetActiveHandles(const FunctionCallbackInfo<Value>& args) {
Environment* env = Environment::GetCurrent(args.GetIsolate());
Environment* env = Environment::GetCurrent(args);
Local<Array> ary = Array::New(env->isolate());
QUEUE* q = NULL;
@ -1603,7 +1603,7 @@ static void Abort(const FunctionCallbackInfo<Value>& args) {
static void Chdir(const FunctionCallbackInfo<Value>& 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<Value>& args) {
static void Cwd(const FunctionCallbackInfo<Value>& 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<Value>& args) {
static void Umask(const FunctionCallbackInfo<Value>& 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<Value>& args) {
static void SetGid(const FunctionCallbackInfo<Value>& 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<Value>& args) {
static void SetUid(const FunctionCallbackInfo<Value>& 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<Value>& args) {
static void GetGroups(const FunctionCallbackInfo<Value>& 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<Value>& args) {
static void SetGroups(const FunctionCallbackInfo<Value>& 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<Value>& args) {
static void InitGroups(const FunctionCallbackInfo<Value>& 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<Value>& args) {
static void Uptime(const FunctionCallbackInfo<Value>& 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<Value>& args) {
void MemoryUsage(const FunctionCallbackInfo<Value>& 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<Value>& args) {
void Kill(const FunctionCallbackInfo<Value>& 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<Value>& 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<Value>& 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<Object> 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<Value>& 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> message, Handle<Value> error) {
static void Binding(const FunctionCallbackInfo<Value>& args) {
Environment* env = Environment::GetCurrent(args.GetIsolate());
Environment* env = Environment::GetCurrent(args);
Local<String> module = args[0]->ToString();
node::Utf8Value module_v(module);
@ -2573,13 +2573,13 @@ void StopProfilerIdleNotifier(Environment* env) {
void StartProfilerIdleNotifier(const FunctionCallbackInfo<Value>& args) {
Environment* env = Environment::GetCurrent(args.GetIsolate());
Environment* env = Environment::GetCurrent(args);
StartProfilerIdleNotifier(env);
}
void StopProfilerIdleNotifier(const FunctionCallbackInfo<Value>& 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,
env->SetMethod(process,
"_startProfilerIdleNotifier",
StartProfilerIdleNotifier);
NODE_SET_METHOD(process,
env->SetMethod(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);
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);
NODE_SET_METHOD(process, "umask", Umask);
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<Value> arg = env->process_object();
f->Call(global, 1, &arg);
@ -3194,7 +3194,7 @@ static void RegisterSignalHandler(int signal,
void DebugProcess(const FunctionCallbackInfo<Value>& 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<Value>& 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<Value>& args) {
static void DebugEnd(const FunctionCallbackInfo<Value>& args) {
if (debugger_running) {
Environment* env = Environment::GetCurrent(args.GetIsolate());
Environment* env = Environment::GetCurrent(args);
env->debugger_agent()->Stop();
debugger_running = false;
}

61
src/node_buffer.cc

@ -254,7 +254,7 @@ Local<Object> Use(Environment* env, char* data, uint32_t length) {
template <encoding encoding>
void StringSlice(const FunctionCallbackInfo<Value>& 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<Value>& args) {
// bytesCopied = buffer.copy(target[, targetStart][, sourceStart][, sourceEnd]);
void Copy(const FunctionCallbackInfo<Value> &args) {
Environment* env = Environment::GetCurrent(args.GetIsolate());
Environment* env = Environment::GetCurrent(args);
Local<Object> target = args[0]->ToObject();
@ -376,7 +376,7 @@ void Fill(const FunctionCallbackInfo<Value>& args) {
template <encoding encoding>
void StringWrite(const FunctionCallbackInfo<Value>& args) {
Environment* env = Environment::GetCurrent(args.GetIsolate());
Environment* env = Environment::GetCurrent(args);
ARGS_THIS(args.This())
@ -540,7 +540,7 @@ void WriteDoubleBE(const FunctionCallbackInfo<Value>& args) {
void ByteLength(const FunctionCallbackInfo<Value> &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<Value> &args) {
// pass Buffer object to load prototype methods
void SetupBufferJS(const FunctionCallbackInfo<Value>& args) {
Environment* env = Environment::GetCurrent(args.GetIsolate());
Environment* env = Environment::GetCurrent(args);
CHECK(args[0]->IsFunction());
@ -600,21 +600,21 @@ void SetupBufferJS(const FunctionCallbackInfo<Value>& args) {
Local<Object> proto = proto_v.As<Object>();
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<Value>& args) {
Local<Object> internal = args[1].As<Object>();
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<Object> target,
Handle<Context> 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());
}

27
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<Value>& 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<Value>& 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<String> class_name =
FIXED_ONE_BYTE_STRING(env->isolate(), "ContextifyScript");
Local<FunctionTemplate> script_tmpl = FunctionTemplate::New(env->isolate(),
New);
Local<FunctionTemplate> 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<Value>& 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<Value>& 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<Value>& args) {
Environment* env = Environment::GetCurrent(args.GetIsolate());
Environment* env = Environment::GetCurrent(args);
int64_t timeout;
bool display_errors;

3
src/node_counters.cc

@ -122,8 +122,7 @@ void InitPerfCounters(Environment* env, Handle<Object> target) {
for (int i = 0; i < ARRAY_SIZE(tab); i++) {
Local<String> key = OneByteString(env->isolate(), tab[i].name);
Local<Value> val =
FunctionTemplate::New(env->isolate(), tab[i].func)->GetFunction();
Local<Value> val = env->NewFunctionTemplate(tab[i].func)->GetFunction();
target->Set(key, val);
}

329
src/node_crypto.cc

@ -257,35 +257,30 @@ bool EntropySource(unsigned char* buffer, size_t length) {
void SecureContext::Initialize(Environment* env, Handle<Object> target) {
Local<FunctionTemplate> t = FunctionTemplate::New(env->isolate(),
SecureContext::New);
Local<FunctionTemplate> 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",
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);
NODE_SET_PROTOTYPE_METHOD(t, "setSessionTimeout",
env->SetProtoMethod(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<true>);
NODE_SET_PROTOTYPE_METHOD(t,
"getIssuer",
SecureContext::GetCertificate<false>);
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<true>);
env->SetProtoMethod(t, "getIssuer", SecureContext::GetCertificate<false>);
NODE_SET_EXTERNAL(
t->PrototypeTemplate(),
@ -299,7 +294,7 @@ void SecureContext::Initialize(Environment* env, Handle<Object> target) {
void SecureContext::New(const FunctionCallbackInfo<Value>& 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<Value> v) {
void SecureContext::SetKey(const FunctionCallbackInfo<Value>& args) {
Environment* env = Environment::GetCurrent(args.GetIsolate());
Environment* env = Environment::GetCurrent(args);
SecureContext* sc = Unwrap<SecureContext>(args.Holder());
@ -575,7 +570,7 @@ int SSL_CTX_use_certificate_chain(SSL_CTX* ctx,
void SecureContext::SetCert(const FunctionCallbackInfo<Value>& args) {
Environment* env = Environment::GetCurrent(args.GetIsolate());
Environment* env = Environment::GetCurrent(args);
SecureContext* sc = Unwrap<SecureContext>(args.Holder());
@ -606,7 +601,7 @@ void SecureContext::SetCert(const FunctionCallbackInfo<Value>& args) {
void SecureContext::AddCACert(const FunctionCallbackInfo<Value>& args) {
bool newCAStore = false;
Environment* env = Environment::GetCurrent(args.GetIsolate());
Environment* env = Environment::GetCurrent(args);
SecureContext* sc = Unwrap<SecureContext>(args.Holder());
@ -635,7 +630,7 @@ void SecureContext::AddCACert(const FunctionCallbackInfo<Value>& args) {
void SecureContext::AddCRL(const FunctionCallbackInfo<Value>& args) {
Environment* env = Environment::GetCurrent(args.GetIsolate());
Environment* env = Environment::GetCurrent(args);
SecureContext* sc = Unwrap<SecureContext>(args.Holder());
@ -835,7 +830,7 @@ void SecureContext::Close(const FunctionCallbackInfo<Value>& args) {
// Takes .pfx or .p12 and password in string or buffer format
void SecureContext::LoadPKCS12(const FunctionCallbackInfo<Value>& args) {
Environment* env = Environment::GetCurrent(args.GetIsolate());
Environment* env = Environment::GetCurrent(args);
BIO* in = NULL;
PKCS12* p12 = NULL;
@ -974,32 +969,32 @@ template <class Base>
void SSLWrap<Base>::AddMethods(Environment* env, Handle<FunctionTemplate> 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<Base>::GetPeerCertificate(
template <class Base>
void SSLWrap<Base>::GetSession(const FunctionCallbackInfo<Value>& args) {
Environment* env = Environment::GetCurrent(args.GetIsolate());
Environment* env = Environment::GetCurrent(args);
Base* w = Unwrap<Base>(args.Holder());
@ -1398,7 +1393,7 @@ void SSLWrap<Base>::GetSession(const FunctionCallbackInfo<Value>& args) {
template <class Base>
void SSLWrap<Base>::SetSession(const FunctionCallbackInfo<Value>& args) {
Environment* env = Environment::GetCurrent(args.GetIsolate());
Environment* env = Environment::GetCurrent(args);
Base* w = Unwrap<Base>(args.Holder());
@ -1993,26 +1988,25 @@ void Connection::NewSessionDoneCb() {
void Connection::Initialize(Environment* env, Handle<Object> target) {
Local<FunctionTemplate> t = FunctionTemplate::New(env->isolate(),
Connection::New);
Local<FunctionTemplate> 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<Connection>::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<Value>& 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<Value>& args) {
void CipherBase::Initialize(Environment* env, Handle<Object> target) {
Local<FunctionTemplate> t = FunctionTemplate::New(env->isolate(), New);
Local<FunctionTemplate> 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<Object> target) {
void CipherBase::New(const FunctionCallbackInfo<Value>& 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<Value>& args) {
Environment* env = Environment::GetCurrent(args.GetIsolate());
Environment* env = Environment::GetCurrent(args);
CipherBase* cipher = Unwrap<CipherBase>(args.Holder());
char* out = NULL;
@ -2642,7 +2636,7 @@ bool CipherBase::SetAuthTag(const char* data, unsigned int len) {
void CipherBase::SetAuthTag(const FunctionCallbackInfo<Value>& args) {
Environment* env = Environment::GetCurrent(args.GetIsolate());
Environment* env = Environment::GetCurrent(args);
Local<Object> buf = args[0].As<Object>();
if (!buf->IsObject() || !Buffer::HasInstance(buf))
@ -2671,7 +2665,7 @@ bool CipherBase::SetAAD(const char* data, unsigned int len) {
void CipherBase::SetAAD(const FunctionCallbackInfo<Value>& 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<Value>& args) {
Environment* env = Environment::GetCurrent(args.GetIsolate());
Environment* env = Environment::GetCurrent(args);
CipherBase* cipher = Unwrap<CipherBase>(args.Holder());
@ -2798,7 +2792,7 @@ bool CipherBase::Final(unsigned char** out, int *out_len) {
void CipherBase::Final(const FunctionCallbackInfo<Value>& args) {
Environment* env = Environment::GetCurrent(args.GetIsolate());
Environment* env = Environment::GetCurrent(args);
CipherBase* cipher = Unwrap<CipherBase>(args.Holder());
@ -2830,20 +2824,20 @@ void CipherBase::Final(const FunctionCallbackInfo<Value>& args) {
void Hmac::Initialize(Environment* env, v8::Handle<v8::Object> target) {
Local<FunctionTemplate> t = FunctionTemplate::New(env->isolate(), New);
Local<FunctionTemplate> 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<Value>& 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<Value>& args) {
Environment* env = Environment::GetCurrent(args.GetIsolate());
Environment* env = Environment::GetCurrent(args);
Hmac* hmac = Unwrap<Hmac>(args.Holder());
@ -2938,7 +2932,7 @@ bool Hmac::HmacDigest(unsigned char** md_value, unsigned int* md_len) {
void Hmac::HmacDigest(const FunctionCallbackInfo<Value>& args) {
Environment* env = Environment::GetCurrent(args.GetIsolate());
Environment* env = Environment::GetCurrent(args);
Hmac* hmac = Unwrap<Hmac>(args.Holder());
@ -2966,19 +2960,19 @@ void Hmac::HmacDigest(const FunctionCallbackInfo<Value>& args) {
void Hash::Initialize(Environment* env, v8::Handle<v8::Object> target) {
Local<FunctionTemplate> t = FunctionTemplate::New(env->isolate(), New);
Local<FunctionTemplate> 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<Value>& 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<Value>& args) {
Environment* env = Environment::GetCurrent(args.GetIsolate());
Environment* env = Environment::GetCurrent(args);
Hash* hash = Unwrap<Hash>(args.Holder());
@ -3049,7 +3043,7 @@ void Hash::HashUpdate(const FunctionCallbackInfo<Value>& args) {
void Hash::HashDigest(const FunctionCallbackInfo<Value>& args) {
Environment* env = Environment::GetCurrent(args.GetIsolate());
Environment* env = Environment::GetCurrent(args);
Hash* hash = Unwrap<Hash>(args.Holder());
@ -3118,20 +3112,20 @@ void SignBase::CheckThrow(SignBase::Error error) {
void Sign::Initialize(Environment* env, v8::Handle<v8::Object> target) {
Local<FunctionTemplate> t = FunctionTemplate::New(env->isolate(), New);
Local<FunctionTemplate> 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<Value>& 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<Value>& args) {
Environment* env = Environment::GetCurrent(args.GetIsolate());
Environment* env = Environment::GetCurrent(args);
Sign* sign = Unwrap<Sign>(args.Holder());
@ -3249,7 +3243,7 @@ SignBase::Error Sign::SignFinal(const char* key_pem,
void Sign::SignFinal(const FunctionCallbackInfo<Value>& args) {
Environment* env = Environment::GetCurrent(args.GetIsolate());
Environment* env = Environment::GetCurrent(args);
Sign* sign = Unwrap<Sign>(args.Holder());
@ -3294,13 +3288,13 @@ void Sign::SignFinal(const FunctionCallbackInfo<Value>& args) {
void Verify::Initialize(Environment* env, v8::Handle<v8::Object> target) {
Local<FunctionTemplate> t = FunctionTemplate::New(env->isolate(), New);
Local<FunctionTemplate> 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<v8::Object> target) {
void Verify::New(const FunctionCallbackInfo<Value>& 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<Value>& args) {
Environment* env = Environment::GetCurrent(args.GetIsolate());
Environment* env = Environment::GetCurrent(args);
Verify* verify = Unwrap<Verify>(args.Holder());
@ -3459,7 +3453,7 @@ SignBase::Error Verify::VerifyFinal(const char* key_pem,
void Verify::VerifyFinal(const FunctionCallbackInfo<Value>& args) {
Environment* env = Environment::GetCurrent(args.GetIsolate());
Environment* env = Environment::GetCurrent(args);
Verify* verify = Unwrap<Verify>(args.Holder());
@ -3591,7 +3585,7 @@ template <PublicKeyCipher::Operation operation,
PublicKeyCipher::EVP_PKEY_cipher_init_t EVP_PKEY_cipher_init,
PublicKeyCipher::EVP_PKEY_cipher_t EVP_PKEY_cipher>
void PublicKeyCipher::Cipher(const FunctionCallbackInfo<Value>& 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<Value>& args) {
void DiffieHellman::Initialize(Environment* env, Handle<Object> target) {
Local<FunctionTemplate> t = FunctionTemplate::New(env->isolate(), New);
Local<FunctionTemplate> t = env->NewFunctionTemplate(New);
static enum PropertyAttribute attributes =
static_cast<PropertyAttribute>(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<Object> target) {
target->Set(FIXED_ONE_BYTE_STRING(env->isolate(), "DiffieHellman"),
t->GetFunction());
Local<FunctionTemplate> t2 = FunctionTemplate::New(env->isolate(),
DiffieHellmanGroup);
Local<FunctionTemplate> 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<Value>& 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<Value>& 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<Value>& args) {
void DiffieHellman::GenerateKeys(const FunctionCallbackInfo<Value>& args) {
Environment* env = Environment::GetCurrent(args.GetIsolate());
Environment* env = Environment::GetCurrent(args);
DiffieHellman* diffieHellman = Unwrap<DiffieHellman>(args.Holder());
@ -3808,7 +3801,7 @@ void DiffieHellman::GenerateKeys(const FunctionCallbackInfo<Value>& args) {
void DiffieHellman::GetPrime(const FunctionCallbackInfo<Value>& args) {
Environment* env = Environment::GetCurrent(args.GetIsolate());
Environment* env = Environment::GetCurrent(args);
DiffieHellman* diffieHellman = Unwrap<DiffieHellman>(args.Holder());
@ -3826,7 +3819,7 @@ void DiffieHellman::GetPrime(const FunctionCallbackInfo<Value>& args) {
void DiffieHellman::GetGenerator(const FunctionCallbackInfo<Value>& args) {
Environment* env = Environment::GetCurrent(args.GetIsolate());
Environment* env = Environment::GetCurrent(args);
DiffieHellman* diffieHellman = Unwrap<DiffieHellman>(args.Holder());
@ -3844,7 +3837,7 @@ void DiffieHellman::GetGenerator(const FunctionCallbackInfo<Value>& args) {
void DiffieHellman::GetPublicKey(const FunctionCallbackInfo<Value>& args) {
Environment* env = Environment::GetCurrent(args.GetIsolate());
Environment* env = Environment::GetCurrent(args);
DiffieHellman* diffieHellman = Unwrap<DiffieHellman>(args.Holder());
@ -3867,7 +3860,7 @@ void DiffieHellman::GetPublicKey(const FunctionCallbackInfo<Value>& args) {
void DiffieHellman::GetPrivateKey(const FunctionCallbackInfo<Value>& args) {
Environment* env = Environment::GetCurrent(args.GetIsolate());
Environment* env = Environment::GetCurrent(args);
DiffieHellman* diffieHellman = Unwrap<DiffieHellman>(args.Holder());
@ -3890,7 +3883,7 @@ void DiffieHellman::GetPrivateKey(const FunctionCallbackInfo<Value>& args) {
void DiffieHellman::ComputeSecret(const FunctionCallbackInfo<Value>& args) {
Environment* env = Environment::GetCurrent(args.GetIsolate());
Environment* env = Environment::GetCurrent(args);
DiffieHellman* diffieHellman = Unwrap<DiffieHellman>(args.Holder());
@ -4024,16 +4017,16 @@ bool DiffieHellman::VerifyContext() {
void ECDH::Initialize(Environment* env, Handle<Object> target) {
HandleScope scope(env->isolate());
Local<FunctionTemplate> t = FunctionTemplate::New(env->isolate(), New);
Local<FunctionTemplate> 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<Object> target) {
void ECDH::New(const FunctionCallbackInfo<Value>& 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<Value>& args) {
void ECDH::GenerateKeys(const FunctionCallbackInfo<Value>& args) {
Environment* env = Environment::GetCurrent(args.GetIsolate());
Environment* env = Environment::GetCurrent(args);
ECDH* ecdh = Unwrap<ECDH>(args.Holder());
@ -4101,7 +4094,7 @@ EC_POINT* ECDH::BufferToPoint(char* data, size_t len) {
void ECDH::ComputeSecret(const FunctionCallbackInfo<Value>& 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<Value>& args) {
void ECDH::GetPublicKey(const FunctionCallbackInfo<Value>& 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<Value>& args) {
void ECDH::GetPrivateKey(const FunctionCallbackInfo<Value>& args) {
Environment* env = Environment::GetCurrent(args.GetIsolate());
Environment* env = Environment::GetCurrent(args);
ECDH* ecdh = Unwrap<ECDH>(args.Holder());
@ -4195,7 +4188,7 @@ void ECDH::GetPrivateKey(const FunctionCallbackInfo<Value>& args) {
void ECDH::SetPrivateKey(const FunctionCallbackInfo<Value>& args) {
Environment* env = Environment::GetCurrent(args.GetIsolate());
Environment* env = Environment::GetCurrent(args);
ECDH* ecdh = Unwrap<ECDH>(args.Holder());
@ -4214,7 +4207,7 @@ void ECDH::SetPrivateKey(const FunctionCallbackInfo<Value>& args) {
void ECDH::SetPublicKey(const FunctionCallbackInfo<Value>& args) {
Environment* env = Environment::GetCurrent(args.GetIsolate());
Environment* env = Environment::GetCurrent(args);
ECDH* ecdh = Unwrap<ECDH>(args.Holder());
@ -4377,7 +4370,7 @@ void EIO_PBKDF2After(uv_work_t* work_req, int status) {
void PBKDF2(const FunctionCallbackInfo<Value>& 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 <bool pseudoRandom>
void RandomBytes(const FunctionCallbackInfo<Value>& 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<Value>& args) {
void GetSSLCiphers(const FunctionCallbackInfo<Value>& 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<Value>& args) {
Environment* env = Environment::GetCurrent(args.GetIsolate());
Environment* env = Environment::GetCurrent(args);
CipherPushContext ctx(env);
EVP_CIPHER_do_all_sorted(array_push_back<EVP_CIPHER>, &ctx);
args.GetReturnValue().Set(ctx.arr);
@ -4719,7 +4712,7 @@ void GetCiphers(const FunctionCallbackInfo<Value>& args) {
void GetHashes(const FunctionCallbackInfo<Value>& args) {
Environment* env = Environment::GetCurrent(args.GetIsolate());
Environment* env = Environment::GetCurrent(args);
CipherPushContext ctx(env);
EVP_MD_do_all_sorted(array_push_back<EVP_MD>, &ctx);
args.GetReturnValue().Set(ctx.arr);
@ -4729,13 +4722,13 @@ void GetHashes(const FunctionCallbackInfo<Value>& args) {
void Certificate::Initialize(Environment* env, Handle<Object> target) {
HandleScope scope(env->isolate());
Local<FunctionTemplate> t = FunctionTemplate::New(env->isolate(), New);
Local<FunctionTemplate> 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<Object> target) {
void Certificate::New(const FunctionCallbackInfo<Value>& 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<Value>& args) {
Environment* env = Environment::GetCurrent(args.GetIsolate());
Environment* env = Environment::GetCurrent(args);
Certificate* certificate = Unwrap<Certificate>(args.Holder());
@ -4882,7 +4875,7 @@ const char* Certificate::ExportChallenge(const char* data, int len) {
void Certificate::ExportChallenge(const FunctionCallbackInfo<Value>& args) {
Environment* env = Environment::GetCurrent(args.GetIsolate());
Environment* env = Environment::GetCurrent(args);
Certificate* crt = Unwrap<Certificate>(args.Holder());
@ -4939,7 +4932,7 @@ void InitCryptoOnce() {
#ifndef OPENSSL_NO_ENGINE
void SetEngine(const FunctionCallbackInfo<Value>& 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,21 +4994,19 @@ void InitCrypto(Handle<Object> 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<false>);
NODE_SET_METHOD(target, "pseudoRandomBytes", RandomBytes<true>);
NODE_SET_METHOD(target, "getSSLCiphers", GetSSLCiphers);
NODE_SET_METHOD(target, "getCiphers", GetCiphers);
NODE_SET_METHOD(target, "getHashes", GetHashes);
NODE_SET_METHOD(target,
"publicEncrypt",
env->SetMethod(target, "PBKDF2", PBKDF2);
env->SetMethod(target, "randomBytes", RandomBytes<false>);
env->SetMethod(target, "pseudoRandomBytes", RandomBytes<true>);
env->SetMethod(target, "getSSLCiphers", GetSSLCiphers);
env->SetMethod(target, "getCiphers", GetCiphers);
env->SetMethod(target, "getHashes", GetHashes);
env->SetMethod(target, "publicEncrypt",
PublicKeyCipher::Cipher<PublicKeyCipher::kEncrypt,
EVP_PKEY_encrypt_init,
EVP_PKEY_encrypt>);
NODE_SET_METHOD(target,
"privateDecrypt",
env->SetMethod(target, "privateDecrypt",
PublicKeyCipher::Cipher<PublicKeyCipher::kDecrypt,
EVP_PKEY_decrypt_init,
EVP_PKEY_decrypt>);

19
src/node_dtrace.cc

@ -147,7 +147,7 @@ using v8::Value;
void DTRACE_NET_SERVER_CONNECTION(const FunctionCallbackInfo<Value>& 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<Value>& args) {
void DTRACE_NET_STREAM_END(const FunctionCallbackInfo<Value>& 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<Value>& args) {
void DTRACE_NET_SOCKET_READ(const FunctionCallbackInfo<Value>& 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<Value>& args) {
void DTRACE_NET_SOCKET_WRITE(const FunctionCallbackInfo<Value>& 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<Value>& args) {
if (!NODE_HTTP_SERVER_REQUEST_ENABLED())
return;
Environment* env = Environment::GetCurrent(args.GetIsolate());
Environment* env = Environment::GetCurrent(args);
HandleScope scope(env->isolate());
Local<Object> arg0 = Local<Object>::Cast(args[0]);
Local<Object> headers;
@ -229,7 +229,7 @@ void DTRACE_HTTP_SERVER_REQUEST(const FunctionCallbackInfo<Value>& args) {
void DTRACE_HTTP_SERVER_RESPONSE(const FunctionCallbackInfo<Value>& 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<Value>& 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<Value>& args) {
void DTRACE_HTTP_CLIENT_RESPONSE(const FunctionCallbackInfo<Value>& 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<Object> target) {
for (unsigned int i = 0; i < ARRAY_SIZE(tab); i++) {
Local<String> key = OneByteString(env->isolate(), tab[i].name);
Local<Value> val = FunctionTemplate::New(env->isolate(), tab[i].func)
->GetFunction();
Local<Value> val = env->NewFunctionTemplate(tab[i].func)->GetFunction();
target->Set(key, val);
}

121
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<Value>& 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<Value> BuildStatsObject(Environment* env, const uv_stat_t* s) {
}
static void Stat(const FunctionCallbackInfo<Value>& 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<Value>& args) {
}
static void LStat(const FunctionCallbackInfo<Value>& 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<Value>& args) {
}
static void FStat(const FunctionCallbackInfo<Value>& 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<Value>& args) {
}
static void Symlink(const FunctionCallbackInfo<Value>& 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<Value>& args) {
}
static void Link(const FunctionCallbackInfo<Value>& 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<Value>& args) {
}
static void ReadLink(const FunctionCallbackInfo<Value>& 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<Value>& args) {
}
static void Rename(const FunctionCallbackInfo<Value>& 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<Value>& args) {
}
static void FTruncate(const FunctionCallbackInfo<Value>& 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<Value>& args) {
}
static void Fdatasync(const FunctionCallbackInfo<Value>& 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<Value>& args) {
}
static void Fsync(const FunctionCallbackInfo<Value>& 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<Value>& args) {
}
static void Unlink(const FunctionCallbackInfo<Value>& 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<Value>& args) {
}
static void RMDir(const FunctionCallbackInfo<Value>& 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<Value>& args) {
}
static void MKDir(const FunctionCallbackInfo<Value>& 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<Value>& args) {
}
static void ReadDir(const FunctionCallbackInfo<Value>& 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<Value>& args) {
}
static void Open(const FunctionCallbackInfo<Value>& 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<Value>& args) {
// 4 position if integer, position to write at in the file.
// if null, write from the current position
static void WriteBuffer(const FunctionCallbackInfo<Value>& 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<Value>& args) {
// if null, write from the current position
// 3 enc encoding of string
static void WriteString(const FunctionCallbackInfo<Value>& 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<Value>& args) {
*
*/
static void Read(const FunctionCallbackInfo<Value>& 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<Value>& args) {
* Wrapper for chmod(1) / EIO_CHMOD
*/
static void Chmod(const FunctionCallbackInfo<Value>& 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<Value>& args) {
* Wrapper for fchmod(1) / EIO_FCHMOD
*/
static void FChmod(const FunctionCallbackInfo<Value>& 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<Value>& args) {
* Wrapper for chown(1) / EIO_CHOWN
*/
static void Chown(const FunctionCallbackInfo<Value>& 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<Value>& args) {
* Wrapper for fchown(1) / EIO_FCHOWN
*/
static void FChown(const FunctionCallbackInfo<Value>& 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<Value>& args) {
static void UTimes(const FunctionCallbackInfo<Value>& 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<Value>& args) {
}
static void FUTimes(const FunctionCallbackInfo<Value>& 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<Value>& args) {
Local<Function> stats_constructor = args[0].As<Function>();
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<Object> 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);
}

25
src/node_http_parser.cc

@ -350,7 +350,7 @@ class Parser : public BaseObject {
static void New(const FunctionCallbackInfo<Value>& args) {
Environment* env = Environment::GetCurrent(args.GetIsolate());
Environment* env = Environment::GetCurrent(args);
http_parser_type type =
static_cast<http_parser_type>(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<Value>& args) {
Environment* env = Environment::GetCurrent(args.GetIsolate());
Environment* env = Environment::GetCurrent(args);
Parser* parser = Unwrap<Parser>(args.Holder());
CHECK(parser->current_buffer_.IsEmpty());
@ -434,7 +434,7 @@ class Parser : public BaseObject {
static void Finish(const FunctionCallbackInfo<Value>& args) {
Environment* env = Environment::GetCurrent(args.GetIsolate());
Environment* env = Environment::GetCurrent(args);
Parser* parser = Unwrap<Parser>(args.Holder());
@ -461,7 +461,7 @@ class Parser : public BaseObject {
static void Reinitialize(const FunctionCallbackInfo<Value>& args) {
Environment* env = Environment::GetCurrent(args.GetIsolate());
Environment* env = Environment::GetCurrent(args);
http_parser_type type =
static_cast<http_parser_type>(args[0]->Int32Value());
@ -476,7 +476,7 @@ class Parser : public BaseObject {
template <bool should_pause>
static void Pause(const FunctionCallbackInfo<Value>& args) {
Environment* env = Environment::GetCurrent(args.GetIsolate());
Environment* env = Environment::GetCurrent(args);
Parser* parser = Unwrap<Parser>(args.Holder());
// Should always be called from the same context.
CHECK_EQ(env, parser->env());
@ -569,8 +569,7 @@ void InitHttpParser(Handle<Object> target,
Handle<Context> context,
void* priv) {
Environment* env = Environment::GetCurrent(context);
Local<FunctionTemplate> t = FunctionTemplate::New(env->isolate(),
Parser::New);
Local<FunctionTemplate> 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<Object> 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<true>);
NODE_SET_PROTOTYPE_METHOD(t, "resume", Parser::Pause<false>);
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<true>);
env->SetProtoMethod(t, "resume", Parser::Pause<false>);
target->Set(FIXED_ONE_BYTE_STRING(env->isolate(), "HTTPParser"),
t->GetFunction());

35
src/node_os.cc

@ -60,14 +60,14 @@ using v8::Value;
static void GetEndianness(const FunctionCallbackInfo<Value>& 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<Value>& 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<Value>& args) {
static void GetOSType(const FunctionCallbackInfo<Value>& 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<Value>& args) {
static void GetOSRelease(const FunctionCallbackInfo<Value>& 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<Value>& args) {
static void GetCPUInfo(const FunctionCallbackInfo<Value>& 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<Value>& args) {
static void GetLoadAvg(const FunctionCallbackInfo<Value>& args) {
Environment* env = Environment::GetCurrent(args.GetIsolate());
Environment* env = Environment::GetCurrent(args);
double loadavg[3];
uv_loadavg(loadavg);
Local<Array> loads = Array::New(env->isolate(), 3);
@ -210,7 +210,7 @@ static void GetLoadAvg(const FunctionCallbackInfo<Value>& args) {
static void GetInterfaceAddresses(const FunctionCallbackInfo<Value>& 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<Value>& args) {
void Initialize(Handle<Object> target,
Handle<Value> unused,
Handle<Context> 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

9
src/node_stat_watcher.cc

@ -46,13 +46,12 @@ using v8::Value;
void StatWatcher::Initialize(Environment* env, Handle<Object> target) {
HandleScope scope(env->isolate());
Local<FunctionTemplate> t = FunctionTemplate::New(env->isolate(),
StatWatcher::New);
Local<FunctionTemplate> 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<Value>& args) {
CHECK(args.IsConstructCall());
Environment* env = Environment::GetCurrent(args.GetIsolate());
Environment* env = Environment::GetCurrent(args);
new StatWatcher(env, args.This());
}

13
src/node_v8.cc

@ -173,14 +173,14 @@ void Environment::StopGarbageCollectionTracking() {
void StartGarbageCollectionTracking(const FunctionCallbackInfo<Value>& args) {
CHECK(args[0]->IsFunction() == true);
Environment* env = Environment::GetCurrent(args.GetIsolate());
Environment* env = Environment::GetCurrent(args);
env->StartGarbageCollectionTracking(args[0].As<Function>());
}
void GetHeapStatistics(const FunctionCallbackInfo<Value>& args) {
Environment* env = Environment::GetCurrent(args);
Isolate* isolate = args.GetIsolate();
Environment* env = Environment::GetCurrent(isolate);
HeapStatistics s;
isolate->GetHeapStatistics(&s);
Local<Object> info = Object::New(isolate);
@ -200,20 +200,21 @@ void GetHeapStatistics(const FunctionCallbackInfo<Value>& args) {
void StopGarbageCollectionTracking(const FunctionCallbackInfo<Value>& args) {
Environment::GetCurrent(args.GetIsolate())->StopGarbageCollectionTracking();
Environment::GetCurrent(args)->StopGarbageCollectionTracking();
}
void InitializeV8Bindings(Handle<Object> target,
Handle<Value> unused,
Handle<Context> context) {
NODE_SET_METHOD(target,
Environment* env = Environment::GetCurrent(context);
env->SetMethod(target,
"startGarbageCollectionTracking",
StartGarbageCollectionTracking);
NODE_SET_METHOD(target,
env->SetMethod(target,
"stopGarbageCollectionTracking",
StopGarbageCollectionTracking);
NODE_SET_METHOD(target, "getHeapStatistics", GetHeapStatistics);
env->SetMethod(target, "getHeapStatistics", GetHeapStatistics);
}
} // namespace node

18
src/node_zlib.cc

@ -219,7 +219,7 @@ class ZCtx : public AsyncWrap {
static void AfterSync(ZCtx* ctx, const FunctionCallbackInfo<Value>& args) {
Environment* env = Environment::GetCurrent(args.GetIsolate());
Environment* env = Environment::GetCurrent(args);
Local<Integer> avail_out = Integer::New(env->isolate(),
ctx->strm_.avail_out);
Local<Integer> avail_in = Integer::New(env->isolate(),
@ -365,7 +365,7 @@ class ZCtx : public AsyncWrap {
}
static void New(const FunctionCallbackInfo<Value>& 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<Object> target,
Handle<Context> context,
void* priv) {
Environment* env = Environment::GetCurrent(context);
Local<FunctionTemplate> z = FunctionTemplate::New(env->isolate(), ZCtx::New);
Local<FunctionTemplate> z = env->NewFunctionTemplate(ZCtx::New);
z->InstanceTemplate()->SetInternalFieldCount(1);
NODE_SET_PROTOTYPE_METHOD(z, "write", ZCtx::Write<true>);
NODE_SET_PROTOTYPE_METHOD(z, "writeSync", ZCtx::Write<false>);
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<true>);
env->SetProtoMethod(z, "writeSync", ZCtx::Write<false>);
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());

46
src/pipe_wrap.cc

@ -75,7 +75,7 @@ void PipeWrap::Initialize(Handle<Object> target,
Handle<Context> context) {
Environment* env = Environment::GetCurrent(context);
Local<FunctionTemplate> t = FunctionTemplate::New(env->isolate(), New);
Local<FunctionTemplate> 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<Object> 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<Value>& 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<Value>& args) {
Environment* env = Environment::GetCurrent(args.GetIsolate());
Environment* env = Environment::GetCurrent(args);
PipeWrap* wrap = Unwrap<PipeWrap>(args.Holder());
@ -261,7 +257,7 @@ void PipeWrap::Open(const FunctionCallbackInfo<Value>& args) {
void PipeWrap::Connect(const FunctionCallbackInfo<Value>& args) {
Environment* env = Environment::GetCurrent(args.GetIsolate());
Environment* env = Environment::GetCurrent(args);
PipeWrap* wrap = Unwrap<PipeWrap>(args.Holder());

17
src/process_wrap.cc

@ -51,18 +51,17 @@ class ProcessWrap : public HandleWrap {
Handle<Value> unused,
Handle<Context> context) {
Environment* env = Environment::GetCurrent(context);
Local<FunctionTemplate> constructor = FunctionTemplate::New(env->isolate(),
New);
Local<FunctionTemplate> 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<Value>& args) {
Environment* env = Environment::GetCurrent(args.GetIsolate());
Environment* env = Environment::GetCurrent(args);
ProcessWrap* wrap = Unwrap<ProcessWrap>(args.Holder());

15
src/signal_wrap.cc

@ -47,16 +47,15 @@ class SignalWrap : public HandleWrap {
Handle<Value> unused,
Handle<Context> context) {
Environment* env = Environment::GetCurrent(context);
Local<FunctionTemplate> constructor = FunctionTemplate::New(env->isolate(),
New);
Local<FunctionTemplate> 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());
}

22
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<Value>& 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<Value>& args) {
// for internal use:
// alloc(obj, n[, type]);
void Alloc(const FunctionCallbackInfo<Value>& args) {
Environment* env = Environment::GetCurrent(args.GetIsolate());
Environment* env = Environment::GetCurrent(args);
Local<Object> obj = args[0].As<Object>();
@ -348,7 +348,7 @@ void Alloc(Environment* env,
// for internal use: dispose(obj);
void AllocDispose(const FunctionCallbackInfo<Value>& args) {
Environment* env = Environment::GetCurrent(args.GetIsolate());
Environment* env = Environment::GetCurrent(args);
AllocDispose(env, args[0].As<Object>());
}
@ -430,7 +430,7 @@ void Alloc(Environment* env,
void HasExternalData(const FunctionCallbackInfo<Value>& args) {
Environment* env = Environment::GetCurrent(args.GetIsolate());
Environment* env = Environment::GetCurrent(args);
args.GetReturnValue().Set(args[0]->IsObject() &&
HasExternalData(env, args[0].As<Object>()));
}
@ -442,7 +442,7 @@ bool HasExternalData(Environment* env, Local<Object> obj) {
void AllocTruncate(const FunctionCallbackInfo<Value>& args) {
Environment* env = Environment::GetCurrent(args.GetIsolate());
Environment* env = Environment::GetCurrent(args);
Local<Object> obj = args[0].As<Object>();
@ -532,14 +532,14 @@ void Initialize(Handle<Object> exports,
Handle<Context> 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));

6
src/spawn_sync.cc

@ -356,13 +356,13 @@ void SyncProcessStdioPipe::CloseCallback(uv_handle_t* handle) {
void SyncProcessRunner::Initialize(Handle<Object> target,
Handle<Value> unused,
Handle<Context> context) {
NODE_SET_METHOD(target, "spawn", Spawn);
Environment* env = Environment::GetCurrent(context);
env->SetMethod(target, "spawn", Spawn);
}
void SyncProcessRunner::Spawn(const FunctionCallbackInfo<Value>& args) {
Isolate* isolate = args.GetIsolate();
SyncProcessRunner p(Environment::GetCurrent(isolate));
SyncProcessRunner p(Environment::GetCurrent(args));
Local<Value> result = p.Run(args[0]);
args.GetReturnValue().Set(result);
}

11
src/stream_wrap.cc

@ -70,8 +70,7 @@ StreamWrap::StreamWrap(Environment* env,
void StreamWrap::GetFD(Local<String>, const PropertyCallbackInfo<Value>& args) {
#if !defined(_WIN32)
Environment* env = Environment::GetCurrent(args.GetIsolate());
HandleScope scope(env->isolate());
HandleScope scope(args.GetIsolate());
StreamWrap* wrap = Unwrap<StreamWrap>(args.Holder());
int fd = -1;
if (wrap != NULL && wrap->stream() != NULL) {
@ -181,7 +180,7 @@ size_t StreamWrap::WriteBuffer(Handle<Value> val, uv_buf_t* buf) {
void StreamWrap::WriteBuffer(const FunctionCallbackInfo<Value>& args) {
Environment* env = Environment::GetCurrent(args.GetIsolate());
Environment* env = Environment::GetCurrent(args);
StreamWrap* wrap = Unwrap<StreamWrap>(args.Holder());
@ -237,7 +236,7 @@ void StreamWrap::WriteBuffer(const FunctionCallbackInfo<Value>& args) {
template <enum encoding encoding>
void StreamWrap::WriteStringImpl(const FunctionCallbackInfo<Value>& args) {
Environment* env = Environment::GetCurrent(args.GetIsolate());
Environment* env = Environment::GetCurrent(args);
int err;
StreamWrap* wrap = Unwrap<StreamWrap>(args.Holder());
@ -365,7 +364,7 @@ void StreamWrap::WriteStringImpl(const FunctionCallbackInfo<Value>& args) {
void StreamWrap::Writev(const FunctionCallbackInfo<Value>& args) {
Environment* env = Environment::GetCurrent(args.GetIsolate());
Environment* env = Environment::GetCurrent(args);
StreamWrap* wrap = Unwrap<StreamWrap>(args.Holder());
@ -535,7 +534,7 @@ void StreamWrap::AfterWrite(uv_write_t* req, int status) {
void StreamWrap::Shutdown(const FunctionCallbackInfo<Value>& args) {
Environment* env = Environment::GetCurrent(args.GetIsolate());
Environment* env = Environment::GetCurrent(args);
StreamWrap* wrap = Unwrap<StreamWrap>(args.Holder());

72
src/tcp_wrap.cc

@ -71,7 +71,7 @@ void TCPWrap::Initialize(Handle<Object> target,
Handle<Context> context) {
Environment* env = Environment::GetCurrent(context);
Local<FunctionTemplate> t = FunctionTemplate::New(env->isolate(), New);
Local<FunctionTemplate> 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<Object> 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<Value>& 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<Value>& args) {
Environment* env = Environment::GetCurrent(args.GetIsolate());
Environment* env = Environment::GetCurrent(args);
struct sockaddr_storage address;
TCPWrap* wrap = Unwrap<TCPWrap>(args.Holder());
@ -194,7 +188,7 @@ void TCPWrap::GetSockName(const FunctionCallbackInfo<Value>& args) {
void TCPWrap::GetPeerName(const FunctionCallbackInfo<Value>& args) {
Environment* env = Environment::GetCurrent(args.GetIsolate());
Environment* env = Environment::GetCurrent(args);
struct sockaddr_storage address;
TCPWrap* wrap = Unwrap<TCPWrap>(args.Holder());
@ -353,7 +347,7 @@ void TCPWrap::AfterConnect(uv_connect_t* req, int status) {
void TCPWrap::Connect(const FunctionCallbackInfo<Value>& args) {
Environment* env = Environment::GetCurrent(args.GetIsolate());
Environment* env = Environment::GetCurrent(args);
TCPWrap* wrap = Unwrap<TCPWrap>(args.Holder());
@ -386,7 +380,7 @@ void TCPWrap::Connect(const FunctionCallbackInfo<Value>& args) {
void TCPWrap::Connect6(const FunctionCallbackInfo<Value>& args) {
Environment* env = Environment::GetCurrent(args.GetIsolate());
Environment* env = Environment::GetCurrent(args);
TCPWrap* wrap = Unwrap<TCPWrap>(args.Holder());

25
src/timer_wrap.cc

@ -50,24 +50,23 @@ class TimerWrap : public HandleWrap {
Handle<Value> unused,
Handle<Context> context) {
Environment* env = Environment::GetCurrent(context);
Local<FunctionTemplate> constructor = FunctionTemplate::New(env->isolate(),
New);
Local<FunctionTemplate> 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<Value>& 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)

30
src/tls_wrap.cc

@ -206,7 +206,7 @@ void TLSCallbacks::InitSSL() {
void TLSCallbacks::Wrap(const FunctionCallbackInfo<Value>& 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<Value>& args) {
void TLSCallbacks::Start(const FunctionCallbackInfo<Value>& args) {
Environment* env = Environment::GetCurrent(args.GetIsolate());
Environment* env = Environment::GetCurrent(args);
TLSCallbacks* wrap = Unwrap<TLSCallbacks>(args.Holder());
@ -680,7 +680,7 @@ int TLSCallbacks::DoShutdown(ShutdownWrap* req_wrap, uv_shutdown_cb cb) {
void TLSCallbacks::SetVerifyMode(const FunctionCallbackInfo<Value>& args) {
Environment* env = Environment::GetCurrent(args.GetIsolate());
Environment* env = Environment::GetCurrent(args);
TLSCallbacks* wrap = Unwrap<TLSCallbacks>(args.Holder());
@ -734,7 +734,7 @@ void TLSCallbacks::OnClientHelloParseEnd(void* arg) {
#ifdef SSL_CTRL_SET_TLSEXT_SERVERNAME_CB
void TLSCallbacks::GetServername(const FunctionCallbackInfo<Value>& args) {
Environment* env = Environment::GetCurrent(args.GetIsolate());
Environment* env = Environment::GetCurrent(args);
TLSCallbacks* wrap = Unwrap<TLSCallbacks>(args.Holder());
@ -749,7 +749,7 @@ void TLSCallbacks::GetServername(const FunctionCallbackInfo<Value>& args) {
void TLSCallbacks::SetServername(const FunctionCallbackInfo<Value>& args) {
Environment* env = Environment::GetCurrent(args.GetIsolate());
Environment* env = Environment::GetCurrent(args);
TLSCallbacks* wrap = Unwrap<TLSCallbacks>(args.Holder());
@ -811,27 +811,23 @@ void TLSCallbacks::Initialize(Handle<Object> target,
Handle<Context> context) {
Environment* env = Environment::GetCurrent(context);
NODE_SET_METHOD(target, "wrap", TLSCallbacks::Wrap);
env->SetMethod(target, "wrap", TLSCallbacks::Wrap);
Local<FunctionTemplate> 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<TLSCallbacks>::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());

38
src/tty_wrap.cc

@ -52,7 +52,7 @@ void TTYWrap::Initialize(Handle<Object> target,
Handle<Context> context) {
Environment* env = Environment::GetCurrent(context);
Local<FunctionTemplate> t = FunctionTemplate::New(env->isolate(), New);
Local<FunctionTemplate> 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<Object> 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<Value>& 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<Value>& args) {
void TTYWrap::GetWindowSize(const FunctionCallbackInfo<Value>& args) {
Environment* env = Environment::GetCurrent(args.GetIsolate());
Environment* env = Environment::GetCurrent(args);
TTYWrap* wrap = Unwrap<TTYWrap>(args.Holder());
CHECK(args[0]->IsArray());
@ -155,7 +151,7 @@ void TTYWrap::SetRawMode(const FunctionCallbackInfo<Value>& args) {
void TTYWrap::New(const FunctionCallbackInfo<Value>& 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

45
src/udp_wrap.cc

@ -91,7 +91,7 @@ void UDPWrap::Initialize(Handle<Object> target,
Handle<Context> context) {
Environment* env = Environment::GetCurrent(context);
Local<FunctionTemplate> t = FunctionTemplate::New(env->isolate(), New);
Local<FunctionTemplate> 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<Object> 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<Object> target,
void UDPWrap::New(const FunctionCallbackInfo<Value>& args) {
CHECK(args.IsConstructCall());
Environment* env = Environment::GetCurrent(args.GetIsolate());
Environment* env = Environment::GetCurrent(args);
new UDPWrap(env, args.This());
}
void UDPWrap::GetFD(Local<String>, const PropertyCallbackInfo<Value>& args) {
#if !defined(_WIN32)
Environment* env = Environment::GetCurrent(args.GetIsolate());
HandleScope scope(env->isolate());
HandleScope scope(args.GetIsolate());
UDPWrap* wrap = Unwrap<UDPWrap>(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<Value>& args) {
void UDPWrap::DoSend(const FunctionCallbackInfo<Value>& args, int family) {
Environment* env = Environment::GetCurrent(args.GetIsolate());
Environment* env = Environment::GetCurrent(args);
UDPWrap* wrap = Unwrap<UDPWrap>(args.Holder());
@ -326,7 +325,7 @@ void UDPWrap::RecvStop(const FunctionCallbackInfo<Value>& args) {
void UDPWrap::GetSockName(const FunctionCallbackInfo<Value>& args) {
Environment* env = Environment::GetCurrent(args.GetIsolate());
Environment* env = Environment::GetCurrent(args);
struct sockaddr_storage address;
UDPWrap* wrap = Unwrap<UDPWrap>(args.Holder());

4
src/uv.cc

@ -38,7 +38,7 @@ using v8::Value;
void ErrName(const FunctionCallbackInfo<Value>& 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<Object> target,
Handle<Context> 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));

Loading…
Cancel
Save