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>
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());
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());
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());
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());
static void SetServers(const FunctionCallbackInfo<Value>& args) {
- Environment* env = Environment::GetCurrent(args.GetIsolate());
+ Environment* env = Environment::GetCurrent(args);
CHECK(args[0]->IsArray());
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));
}
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));
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()),
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 { \
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,
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) \
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)
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());
}
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());
void HandleWrap::Close(const FunctionCallbackInfo<Value>& args) {
- Environment* env = Environment::GetCurrent(args.GetIsolate());
+ Environment* env = Environment::GetCurrent(args);
HandleWrap* wrap = Unwrap<HandleWrap>(args.Holder());
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());
void SetupDomainUse(const FunctionCallbackInfo<Value>& args) {
- Environment* env = Environment::GetCurrent(args.GetIsolate());
+ Environment* env = Environment::GetCurrent(args);
if (env->using_domains())
return;
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());
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(
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;
// 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;
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?
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];
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()) {
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");
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");
static void GetGroups(const FunctionCallbackInfo<Value>& args) {
- Environment* env = Environment::GetCurrent(args.GetIsolate());
+ Environment* env = Environment::GetCurrent(args);
int ngroups = getgroups(0, NULL);
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");
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");
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());
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);
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.");
// 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();
// 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;
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);
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);
}
DebugPortSetter);
// define various internal methods
- NODE_SET_METHOD(process,
- "_startProfilerIdleNotifier",
- StartProfilerIdleNotifier);
- NODE_SET_METHOD(process,
- "_stopProfilerIdleNotifier",
- StopProfilerIdleNotifier);
- NODE_SET_METHOD(process, "_getActiveRequests", GetActiveRequests);
- NODE_SET_METHOD(process, "_getActiveHandles", GetActiveHandles);
- NODE_SET_METHOD(process, "reallyExit", Exit);
- NODE_SET_METHOD(process, "abort", Abort);
- NODE_SET_METHOD(process, "chdir", Chdir);
- NODE_SET_METHOD(process, "cwd", Cwd);
-
- NODE_SET_METHOD(process, "umask", Umask);
+ env->SetMethod(process,
+ "_startProfilerIdleNotifier",
+ StartProfilerIdleNotifier);
+ env->SetMethod(process,
+ "_stopProfilerIdleNotifier",
+ StopProfilerIdleNotifier);
+ env->SetMethod(process, "_getActiveRequests", GetActiveRequests);
+ env->SetMethod(process, "_getActiveHandles", GetActiveHandles);
+ env->SetMethod(process, "reallyExit", Exit);
+ env->SetMethod(process, "abort", Abort);
+ env->SetMethod(process, "chdir", Chdir);
+ env->SetMethod(process, "cwd", Cwd);
+
+ env->SetMethod(process, "umask", Umask);
#if defined(__POSIX__) && !defined(__ANDROID__)
- NODE_SET_METHOD(process, "getuid", GetUid);
- NODE_SET_METHOD(process, "setuid", SetUid);
+ env->SetMethod(process, "getuid", GetUid);
+ env->SetMethod(process, "setuid", SetUid);
- NODE_SET_METHOD(process, "setgid", SetGid);
- NODE_SET_METHOD(process, "getgid", GetGid);
+ env->SetMethod(process, "setgid", SetGid);
+ env->SetMethod(process, "getgid", GetGid);
- NODE_SET_METHOD(process, "getgroups", GetGroups);
- NODE_SET_METHOD(process, "setgroups", SetGroups);
- NODE_SET_METHOD(process, "initgroups", InitGroups);
+ env->SetMethod(process, "getgroups", GetGroups);
+ env->SetMethod(process, "setgroups", SetGroups);
+ env->SetMethod(process, "initgroups", InitGroups);
#endif // __POSIX__ && !defined(__ANDROID__)
- NODE_SET_METHOD(process, "_kill", Kill);
+ env->SetMethod(process, "_kill", Kill);
- NODE_SET_METHOD(process, "_debugProcess", DebugProcess);
- NODE_SET_METHOD(process, "_debugPause", DebugPause);
- NODE_SET_METHOD(process, "_debugEnd", DebugEnd);
+ env->SetMethod(process, "_debugProcess", DebugProcess);
+ env->SetMethod(process, "_debugPause", DebugPause);
+ env->SetMethod(process, "_debugEnd", DebugEnd);
- NODE_SET_METHOD(process, "hrtime", Hrtime);
+ env->SetMethod(process, "hrtime", Hrtime);
- NODE_SET_METHOD(process, "dlopen", DLOpen);
+ env->SetMethod(process, "dlopen", DLOpen);
- NODE_SET_METHOD(process, "uptime", Uptime);
- NODE_SET_METHOD(process, "memoryUsage", MemoryUsage);
+ env->SetMethod(process, "uptime", Uptime);
+ env->SetMethod(process, "memoryUsage", MemoryUsage);
- NODE_SET_METHOD(process, "binding", Binding);
+ env->SetMethod(process, "binding", Binding);
- NODE_SET_METHOD(process, "_setupAsyncListener", SetupAsyncListener);
- NODE_SET_METHOD(process, "_setupNextTick", SetupNextTick);
- NODE_SET_METHOD(process, "_setupDomainUse", SetupDomainUse);
+ env->SetMethod(process, "_setupAsyncListener", SetupAsyncListener);
+ env->SetMethod(process, "_setupNextTick", SetupNextTick);
+ env->SetMethod(process, "_setupDomainUse", SetupDomainUse);
// pre-set _events object for faster emit checks
process->Set(env->events_string(), Object::New(env->isolate()));
// 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);
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.");
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;
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;
}
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)
// 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();
template <encoding encoding>
void StringWrite(const FunctionCallbackInfo<Value>& args) {
- Environment* env = Environment::GetCurrent(args.GetIsolate());
+ Environment* env = Environment::GetCurrent(args);
ARGS_THIS(args.This())
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");
// 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());
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(),
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);
}
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());
}
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);
}
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.");
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");
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);
// 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.");
// args: [options]
static void RunInThisContext(const FunctionCallbackInfo<Value>& args) {
- Isolate* isolate = args.GetIsolate();
-
// Assemble arguments
TryCatch try_catch;
uint64_t timeout = GetTimeoutArg(args, 0);
}
// 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;
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);
}
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",
- SecureContext::SetSessionIdContext);
- NODE_SET_PROTOTYPE_METHOD(t, "setSessionTimeout",
- SecureContext::SetSessionTimeout);
- NODE_SET_PROTOTYPE_METHOD(t, "close", SecureContext::Close);
- NODE_SET_PROTOTYPE_METHOD(t, "loadPKCS12", SecureContext::LoadPKCS12);
- NODE_SET_PROTOTYPE_METHOD(t, "getTicketKeys", SecureContext::GetTicketKeys);
- NODE_SET_PROTOTYPE_METHOD(t, "setTicketKeys", SecureContext::SetTicketKeys);
- NODE_SET_PROTOTYPE_METHOD(t,
- "getCertificate",
- SecureContext::GetCertificate<true>);
- NODE_SET_PROTOTYPE_METHOD(t,
- "getIssuer",
- SecureContext::GetCertificate<false>);
+ env->SetProtoMethod(t, "init", SecureContext::Init);
+ env->SetProtoMethod(t, "setKey", SecureContext::SetKey);
+ env->SetProtoMethod(t, "setCert", SecureContext::SetCert);
+ env->SetProtoMethod(t, "addCACert", SecureContext::AddCACert);
+ env->SetProtoMethod(t, "addCRL", SecureContext::AddCRL);
+ env->SetProtoMethod(t, "addRootCerts", SecureContext::AddRootCerts);
+ env->SetProtoMethod(t, "setCiphers", SecureContext::SetCiphers);
+ env->SetProtoMethod(t, "setECDHCurve", SecureContext::SetECDHCurve);
+ env->SetProtoMethod(t, "setDHParam", SecureContext::SetDHParam);
+ env->SetProtoMethod(t, "setOptions", SecureContext::SetOptions);
+ env->SetProtoMethod(t, "setSessionIdContext",
+ SecureContext::SetSessionIdContext);
+ env->SetProtoMethod(t, "setSessionTimeout",
+ SecureContext::SetSessionTimeout);
+ env->SetProtoMethod(t, "close", SecureContext::Close);
+ env->SetProtoMethod(t, "loadPKCS12", SecureContext::LoadPKCS12);
+ env->SetProtoMethod(t, "getTicketKeys", SecureContext::GetTicketKeys);
+ env->SetProtoMethod(t, "setTicketKeys", SecureContext::SetTicketKeys);
+ env->SetProtoMethod(t, "getCertificate", SecureContext::GetCertificate<true>);
+ env->SetProtoMethod(t, "getIssuer", SecureContext::GetCertificate<false>);
NODE_SET_EXTERNAL(
t->PrototypeTemplate(),
void SecureContext::New(const FunctionCallbackInfo<Value>& args) {
- Environment* env = Environment::GetCurrent(args.GetIsolate());
+ Environment* env = Environment::GetCurrent(args);
new SecureContext(env, args.This());
}
void SecureContext::SetKey(const FunctionCallbackInfo<Value>& args) {
- Environment* env = Environment::GetCurrent(args.GetIsolate());
+ Environment* env = Environment::GetCurrent(args);
SecureContext* sc = Unwrap<SecureContext>(args.Holder());
void SecureContext::SetCert(const FunctionCallbackInfo<Value>& args) {
- Environment* env = Environment::GetCurrent(args.GetIsolate());
+ Environment* env = Environment::GetCurrent(args);
SecureContext* sc = Unwrap<SecureContext>(args.Holder());
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());
void SecureContext::AddCRL(const FunctionCallbackInfo<Value>& args) {
- Environment* env = Environment::GetCurrent(args.GetIsolate());
+ Environment* env = Environment::GetCurrent(args);
SecureContext* sc = Unwrap<SecureContext>(args.Holder());
// 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;
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(
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());
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());
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"),
#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");
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());
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);
}
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;
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))
void CipherBase::SetAAD(const FunctionCallbackInfo<Value>& args) {
- Environment* env = Environment::GetCurrent(args.GetIsolate());
+ Environment* env = Environment::GetCurrent(args);
ASSERT_IS_BUFFER(args[0]);
void CipherBase::Update(const FunctionCallbackInfo<Value>& args) {
- Environment* env = Environment::GetCurrent(args.GetIsolate());
+ Environment* env = Environment::GetCurrent(args);
CipherBase* cipher = Unwrap<CipherBase>(args.Holder());
void CipherBase::Final(const FunctionCallbackInfo<Value>& args) {
- Environment* env = Environment::GetCurrent(args.GetIsolate());
+ Environment* env = Environment::GetCurrent(args);
CipherBase* cipher = Unwrap<CipherBase>(args.Holder());
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());
}
void Hmac::HmacUpdate(const FunctionCallbackInfo<Value>& args) {
- Environment* env = Environment::GetCurrent(args.GetIsolate());
+ Environment* env = Environment::GetCurrent(args);
Hmac* hmac = Unwrap<Hmac>(args.Holder());
void Hmac::HmacDigest(const FunctionCallbackInfo<Value>& args) {
- Environment* env = Environment::GetCurrent(args.GetIsolate());
+ Environment* env = Environment::GetCurrent(args);
Hmac* hmac = Unwrap<Hmac>(args.Holder());
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");
void Hash::HashUpdate(const FunctionCallbackInfo<Value>& args) {
- Environment* env = Environment::GetCurrent(args.GetIsolate());
+ Environment* env = Environment::GetCurrent(args);
Hash* hash = Unwrap<Hash>(args.Holder());
void Hash::HashDigest(const FunctionCallbackInfo<Value>& args) {
- Environment* env = Environment::GetCurrent(args.GetIsolate());
+ Environment* env = Environment::GetCurrent(args);
Hash* hash = Unwrap<Hash>(args.Holder());
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());
}
void Sign::SignUpdate(const FunctionCallbackInfo<Value>& args) {
- Environment* env = Environment::GetCurrent(args.GetIsolate());
+ Environment* env = Environment::GetCurrent(args);
Sign* sign = Unwrap<Sign>(args.Holder());
void Sign::SignFinal(const FunctionCallbackInfo<Value>& args) {
- Environment* env = Environment::GetCurrent(args.GetIsolate());
+ Environment* env = Environment::GetCurrent(args);
Sign* sign = Unwrap<Sign>(args.Holder());
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());
void Verify::New(const FunctionCallbackInfo<Value>& args) {
- Environment* env = Environment::GetCurrent(args.GetIsolate());
+ Environment* env = Environment::GetCurrent(args);
new Verify(env, args.This());
}
void Verify::VerifyUpdate(const FunctionCallbackInfo<Value>& args) {
- Environment* env = Environment::GetCurrent(args.GetIsolate());
+ Environment* env = Environment::GetCurrent(args);
Verify* verify = Unwrap<Verify>(args.Holder());
void Verify::VerifyFinal(const FunctionCallbackInfo<Value>& args) {
- Environment* env = Environment::GetCurrent(args.GetIsolate());
+ Environment* env = Environment::GetCurrent(args);
Verify* verify = Unwrap<Verify>(args.Holder());
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]);
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,
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,
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()) {
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;
void DiffieHellman::GenerateKeys(const FunctionCallbackInfo<Value>& args) {
- Environment* env = Environment::GetCurrent(args.GetIsolate());
+ Environment* env = Environment::GetCurrent(args);
DiffieHellman* diffieHellman = Unwrap<DiffieHellman>(args.Holder());
void DiffieHellman::GetPrime(const FunctionCallbackInfo<Value>& args) {
- Environment* env = Environment::GetCurrent(args.GetIsolate());
+ Environment* env = Environment::GetCurrent(args);
DiffieHellman* diffieHellman = Unwrap<DiffieHellman>(args.Holder());
void DiffieHellman::GetGenerator(const FunctionCallbackInfo<Value>& args) {
- Environment* env = Environment::GetCurrent(args.GetIsolate());
+ Environment* env = Environment::GetCurrent(args);
DiffieHellman* diffieHellman = Unwrap<DiffieHellman>(args.Holder());
void DiffieHellman::GetPublicKey(const FunctionCallbackInfo<Value>& args) {
- Environment* env = Environment::GetCurrent(args.GetIsolate());
+ Environment* env = Environment::GetCurrent(args);
DiffieHellman* diffieHellman = Unwrap<DiffieHellman>(args.Holder());
void DiffieHellman::GetPrivateKey(const FunctionCallbackInfo<Value>& args) {
- Environment* env = Environment::GetCurrent(args.GetIsolate());
+ Environment* env = Environment::GetCurrent(args);
DiffieHellman* diffieHellman = Unwrap<DiffieHellman>(args.Holder());
void DiffieHellman::ComputeSecret(const FunctionCallbackInfo<Value>& args) {
- Environment* env = Environment::GetCurrent(args.GetIsolate());
+ Environment* env = Environment::GetCurrent(args);
DiffieHellman* diffieHellman = Unwrap<DiffieHellman>(args.Holder());
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());
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());
void ECDH::GenerateKeys(const FunctionCallbackInfo<Value>& args) {
- Environment* env = Environment::GetCurrent(args.GetIsolate());
+ Environment* env = Environment::GetCurrent(args);
ECDH* ecdh = Unwrap<ECDH>(args.Holder());
void ECDH::ComputeSecret(const FunctionCallbackInfo<Value>& args) {
- Environment* env = Environment::GetCurrent(args.GetIsolate());
+ Environment* env = Environment::GetCurrent(args);
ASSERT_IS_BUFFER(args[0]);
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);
void ECDH::GetPrivateKey(const FunctionCallbackInfo<Value>& args) {
- Environment* env = Environment::GetCurrent(args.GetIsolate());
+ Environment* env = Environment::GetCurrent(args);
ECDH* ecdh = Unwrap<ECDH>(args.Holder());
void ECDH::SetPrivateKey(const FunctionCallbackInfo<Value>& args) {
- Environment* env = Environment::GetCurrent(args.GetIsolate());
+ Environment* env = Environment::GetCurrent(args);
ECDH* ecdh = Unwrap<ECDH>(args.Holder());
void ECDH::SetPublicKey(const FunctionCallbackInfo<Value>& args) {
- Environment* env = Environment::GetCurrent(args.GetIsolate());
+ Environment* env = Environment::GetCurrent(args);
ECDH* ecdh = Unwrap<ECDH>(args.Holder());
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;
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
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) {
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);
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);
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());
void Certificate::New(const FunctionCallbackInfo<Value>& args) {
- Environment* env = Environment::GetCurrent(args.GetIsolate());
+ Environment* env = Environment::GetCurrent(args);
new Certificate(env, args.This());
}
void Certificate::ExportPublicKey(const FunctionCallbackInfo<Value>& args) {
- Environment* env = Environment::GetCurrent(args.GetIsolate());
+ Environment* env = Environment::GetCurrent(args);
Certificate* certificate = Unwrap<Certificate>(args.Holder());
void Certificate::ExportChallenge(const FunctionCallbackInfo<Value>& args) {
- Environment* env = Environment::GetCurrent(args.GetIsolate());
+ Environment* env = Environment::GetCurrent(args);
Certificate* crt = Unwrap<Certificate>(args.Holder());
#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();
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",
- PublicKeyCipher::Cipher<PublicKeyCipher::kEncrypt,
- EVP_PKEY_encrypt_init,
- EVP_PKEY_encrypt>);
- NODE_SET_METHOD(target,
- "privateDecrypt",
- PublicKeyCipher::Cipher<PublicKeyCipher::kDecrypt,
- EVP_PKEY_decrypt_init,
- EVP_PKEY_decrypt>);
+ 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>);
+ env->SetMethod(target, "privateDecrypt",
+ PublicKeyCipher::Cipher<PublicKeyCipher::kDecrypt,
+ EVP_PKEY_decrypt_init,
+ EVP_PKEY_decrypt>);
}
} // namespace crypto
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);
}
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);
}
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()) {
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()) {
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;
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);
}
if (!NODE_HTTP_CLIENT_REQUEST_ENABLED())
return;
- Environment* env = Environment::GetCurrent(args.GetIsolate());
+ Environment* env = Environment::GetCurrent(args);
HandleScope scope(env->isolate());
/*
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);
}
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);
}
#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); \
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;
}
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");
}
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");
}
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;
}
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)
}
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)
}
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");
}
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)
}
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;
}
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;
}
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;
}
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");
}
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");
}
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;
}
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");
}
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)
// 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]));
// 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");
*
*/
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;
* 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;
* 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;
* 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)
* 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)
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)
}
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)
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);
}
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);
}
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);
// 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());
static void Finish(const FunctionCallbackInfo<Value>& args) {
- Environment* env = Environment::GetCurrent(args.GetIsolate());
+ Environment* env = Environment::GetCurrent(args);
Parser* parser = Unwrap<Parser>(args.Holder());
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());
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());
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"));
#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());
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))) {
static void GetOSType(const FunctionCallbackInfo<Value>& args) {
- Environment* env = Environment::GetCurrent(args.GetIsolate());
+ Environment* env = Environment::GetCurrent(args);
const char* rval;
#ifdef __POSIX__
static void GetOSRelease(const FunctionCallbackInfo<Value>& args) {
- Environment* env = Environment::GetCurrent(args.GetIsolate());
+ Environment* env = Environment::GetCurrent(args);
const char* rval;
#ifdef __POSIX__
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;
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);
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];
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
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());
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());
}
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);
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,
- "startGarbageCollectionTracking",
- StartGarbageCollectionTracking);
- NODE_SET_METHOD(target,
- "stopGarbageCollectionTracking",
- StopGarbageCollectionTracking);
- NODE_SET_METHOD(target, "getHeapStatistics", GetHeapStatistics);
+ Environment* env = Environment::GetCurrent(context);
+ env->SetMethod(target,
+ "startGarbageCollectionTracking",
+ StartGarbageCollectionTracking);
+ env->SetMethod(target,
+ "stopGarbageCollectionTracking",
+ StopGarbageCollectionTracking);
+ env->SetMethod(target, "getHeapStatistics", GetHeapStatistics);
}
} // namespace node
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(),
}
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");
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());
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);
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());
// 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());
}
void PipeWrap::Open(const FunctionCallbackInfo<Value>& args) {
- Environment* env = Environment::GetCurrent(args.GetIsolate());
+ Environment* env = Environment::GetCurrent(args);
PipeWrap* wrap = Unwrap<PipeWrap>(args.Holder());
void PipeWrap::Connect(const FunctionCallbackInfo<Value>& args) {
- Environment* env = Environment::GetCurrent(args.GetIsolate());
+ Environment* env = Environment::GetCurrent(args);
PipeWrap* wrap = Unwrap<PipeWrap>(args.Holder());
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());
// 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());
}
}
static void Spawn(const FunctionCallbackInfo<Value>& args) {
- Environment* env = Environment::GetCurrent(args.GetIsolate());
+ Environment* env = Environment::GetCurrent(args);
ProcessWrap* wrap = Unwrap<ProcessWrap>(args.Holder());
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());
// 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());
}
// 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");
// 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>();
// 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>());
}
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>()));
}
void AllocTruncate(const FunctionCallbackInfo<Value>& args) {
- Environment* env = Environment::GetCurrent(args.GetIsolate());
+ Environment* env = Environment::GetCurrent(args);
Local<Object> obj = args[0].As<Object>();
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));
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);
}
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) {
void StreamWrap::WriteBuffer(const FunctionCallbackInfo<Value>& args) {
- Environment* env = Environment::GetCurrent(args.GetIsolate());
+ Environment* env = Environment::GetCurrent(args);
StreamWrap* wrap = Unwrap<StreamWrap>(args.Holder());
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());
void StreamWrap::Writev(const FunctionCallbackInfo<Value>& args) {
- Environment* env = Environment::GetCurrent(args.GetIsolate());
+ Environment* env = Environment::GetCurrent(args);
StreamWrap* wrap = Unwrap<StreamWrap>(args.Holder());
void StreamWrap::Shutdown(const FunctionCallbackInfo<Value>& args) {
- Environment* env = Environment::GetCurrent(args.GetIsolate());
+ Environment* env = Environment::GetCurrent(args);
StreamWrap* wrap = Unwrap<StreamWrap>(args.Holder());
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);
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());
// 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);
}
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());
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());
void TCPWrap::Connect(const FunctionCallbackInfo<Value>& args) {
- Environment* env = Environment::GetCurrent(args.GetIsolate());
+ Environment* env = Environment::GetCurrent(args);
TCPWrap* wrap = Unwrap<TCPWrap>(args.Holder());
void TCPWrap::Connect6(const FunctionCallbackInfo<Value>& args) {
- Environment* env = Environment::GetCurrent(args.GetIsolate());
+ Environment* env = Environment::GetCurrent(args);
TCPWrap* wrap = Unwrap<TCPWrap>(args.Holder());
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());
// 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());
}
}
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)
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(
void TLSCallbacks::Start(const FunctionCallbackInfo<Value>& args) {
- Environment* env = Environment::GetCurrent(args.GetIsolate());
+ Environment* env = Environment::GetCurrent(args);
TLSCallbacks* wrap = Unwrap<TLSCallbacks>(args.Holder());
void TLSCallbacks::SetVerifyMode(const FunctionCallbackInfo<Value>& args) {
- Environment* env = Environment::GetCurrent(args.GetIsolate());
+ Environment* env = Environment::GetCurrent(args);
TLSCallbacks* wrap = Unwrap<TLSCallbacks>(args.Holder());
#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());
void TLSCallbacks::SetServername(const FunctionCallbackInfo<Value>& args) {
- Environment* env = Environment::GetCurrent(args.GetIsolate());
+ Environment* env = Environment::GetCurrent(args);
TLSCallbacks* wrap = Unwrap<TLSCallbacks>(args.Holder());
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());
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);
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);
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);
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());
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
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"));
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());
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);
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());
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());
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");
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));