src: fix v8 compiler warnings in src

This commit changes the code to use the maybe version.

PR-URL: https://github.com/nodejs/node/pull/24246
Reviewed-By: Anna Henningsen <anna@addaleax.net>
Reviewed-By: Refael Ackermann <refack@gmail.com>
This commit is contained in:
Daniel Bevenius 2018-11-08 07:22:13 +01:00
parent 19e5e78e9c
commit 344d33eef1
34 changed files with 414 additions and 213 deletions

View File

@ -1851,7 +1851,7 @@ void AfterGetAddrInfo(uv_getaddrinfo_t* req, int status, struct addrinfo* res) {
continue; continue;
Local<String> s = OneByteString(env->isolate(), ip); Local<String> s = OneByteString(env->isolate(), ip);
results->Set(n, s); results->Set(env->context(), n, s).FromJust();
n++; n++;
} }
}; };
@ -2053,10 +2053,12 @@ void GetServers(const FunctionCallbackInfo<Value>& args) {
CHECK_EQ(err, 0); CHECK_EQ(err, 0);
Local<Array> ret = Array::New(env->isolate(), 2); Local<Array> ret = Array::New(env->isolate(), 2);
ret->Set(0, OneByteString(env->isolate(), ip)); ret->Set(env->context(), 0, OneByteString(env->isolate(), ip)).FromJust();
ret->Set(1, Integer::New(env->isolate(), cur->udp_port)); ret->Set(env->context(),
1,
Integer::New(env->isolate(), cur->udp_port)).FromJust();
server_array->Set(i, ret); server_array->Set(env->context(), i, ret).FromJust();
} }
ares_free_data(servers); ares_free_data(servers);
@ -2179,16 +2181,19 @@ void Initialize(Local<Object> target,
env->SetMethod(target, "strerror", StrError); env->SetMethod(target, "strerror", StrError);
target->Set(FIXED_ONE_BYTE_STRING(env->isolate(), "AF_INET"), target->Set(env->context(), FIXED_ONE_BYTE_STRING(env->isolate(), "AF_INET"),
Integer::New(env->isolate(), AF_INET)); Integer::New(env->isolate(), AF_INET)).FromJust();
target->Set(FIXED_ONE_BYTE_STRING(env->isolate(), "AF_INET6"), target->Set(env->context(), FIXED_ONE_BYTE_STRING(env->isolate(), "AF_INET6"),
Integer::New(env->isolate(), AF_INET6)); Integer::New(env->isolate(), AF_INET6)).FromJust();
target->Set(FIXED_ONE_BYTE_STRING(env->isolate(), "AF_UNSPEC"), target->Set(env->context(), FIXED_ONE_BYTE_STRING(env->isolate(),
Integer::New(env->isolate(), AF_UNSPEC)); "AF_UNSPEC"),
target->Set(FIXED_ONE_BYTE_STRING(env->isolate(), "AI_ADDRCONFIG"), Integer::New(env->isolate(), AF_UNSPEC)).FromJust();
Integer::New(env->isolate(), AI_ADDRCONFIG)); target->Set(env->context(), FIXED_ONE_BYTE_STRING(env->isolate(),
target->Set(FIXED_ONE_BYTE_STRING(env->isolate(), "AI_V4MAPPED"), "AI_ADDRCONFIG"),
Integer::New(env->isolate(), AI_V4MAPPED)); Integer::New(env->isolate(), AI_ADDRCONFIG)).FromJust();
target->Set(env->context(), FIXED_ONE_BYTE_STRING(env->isolate(),
"AI_V4MAPPED"),
Integer::New(env->isolate(), AI_V4MAPPED)).FromJust();
Local<FunctionTemplate> aiw = Local<FunctionTemplate> aiw =
BaseObject::MakeLazilyInitializedJSTemplate(env); BaseObject::MakeLazilyInitializedJSTemplate(env);
@ -2196,7 +2201,9 @@ void Initialize(Local<Object> target,
Local<String> addrInfoWrapString = Local<String> addrInfoWrapString =
FIXED_ONE_BYTE_STRING(env->isolate(), "GetAddrInfoReqWrap"); FIXED_ONE_BYTE_STRING(env->isolate(), "GetAddrInfoReqWrap");
aiw->SetClassName(addrInfoWrapString); aiw->SetClassName(addrInfoWrapString);
target->Set(addrInfoWrapString, aiw->GetFunction(context).ToLocalChecked()); target->Set(env->context(),
addrInfoWrapString,
aiw->GetFunction(context).ToLocalChecked()).FromJust();
Local<FunctionTemplate> niw = Local<FunctionTemplate> niw =
BaseObject::MakeLazilyInitializedJSTemplate(env); BaseObject::MakeLazilyInitializedJSTemplate(env);
@ -2204,7 +2211,9 @@ void Initialize(Local<Object> target,
Local<String> nameInfoWrapString = Local<String> nameInfoWrapString =
FIXED_ONE_BYTE_STRING(env->isolate(), "GetNameInfoReqWrap"); FIXED_ONE_BYTE_STRING(env->isolate(), "GetNameInfoReqWrap");
niw->SetClassName(nameInfoWrapString); niw->SetClassName(nameInfoWrapString);
target->Set(nameInfoWrapString, niw->GetFunction(context).ToLocalChecked()); target->Set(env->context(),
nameInfoWrapString,
niw->GetFunction(context).ToLocalChecked()).FromJust();
Local<FunctionTemplate> qrw = Local<FunctionTemplate> qrw =
BaseObject::MakeLazilyInitializedJSTemplate(env); BaseObject::MakeLazilyInitializedJSTemplate(env);
@ -2212,7 +2221,9 @@ void Initialize(Local<Object> target,
Local<String> queryWrapString = Local<String> queryWrapString =
FIXED_ONE_BYTE_STRING(env->isolate(), "QueryReqWrap"); FIXED_ONE_BYTE_STRING(env->isolate(), "QueryReqWrap");
qrw->SetClassName(queryWrapString); qrw->SetClassName(queryWrapString);
target->Set(queryWrapString, qrw->GetFunction(context).ToLocalChecked()); target->Set(env->context(),
queryWrapString,
qrw->GetFunction(context).ToLocalChecked()).FromJust();
Local<FunctionTemplate> channel_wrap = Local<FunctionTemplate> channel_wrap =
env->NewFunctionTemplate(ChannelWrap::New); env->NewFunctionTemplate(ChannelWrap::New);
@ -2239,8 +2250,8 @@ void Initialize(Local<Object> target,
Local<String> channelWrapString = Local<String> channelWrapString =
FIXED_ONE_BYTE_STRING(env->isolate(), "ChannelWrap"); FIXED_ONE_BYTE_STRING(env->isolate(), "ChannelWrap");
channel_wrap->SetClassName(channelWrapString); channel_wrap->SetClassName(channelWrapString);
target->Set(channelWrapString, target->Set(env->context(), channelWrapString,
channel_wrap->GetFunction(context).ToLocalChecked()); channel_wrap->GetFunction(context).ToLocalChecked()).FromJust();
} }
} // anonymous namespace } // anonymous namespace

View File

@ -755,7 +755,9 @@ void CollectExceptionInfo(Environment* env,
const char* message, const char* message,
const char* path, const char* path,
const char* dest) { const char* dest) {
obj->Set(env->errno_string(), v8::Integer::New(env->isolate(), errorno)); obj->Set(env->context(),
env->errno_string(),
v8::Integer::New(env->isolate(), errorno)).FromJust();
obj->Set(env->context(), env->code_string(), obj->Set(env->context(), env->code_string(),
OneByteString(env->isolate(), err_string)).FromJust(); OneByteString(env->isolate(), err_string)).FromJust();

View File

@ -51,15 +51,19 @@ Local<Value> ErrnoException(Isolate* isolate,
e = Exception::Error(cons); e = Exception::Error(cons);
Local<Object> obj = e.As<Object>(); Local<Object> obj = e.As<Object>();
obj->Set(env->errno_string(), Integer::New(isolate, errorno)); obj->Set(env->context(),
obj->Set(env->code_string(), estring); env->errno_string(),
Integer::New(isolate, errorno)).FromJust();
obj->Set(env->context(), env->code_string(), estring).FromJust();
if (path_string.IsEmpty() == false) { if (path_string.IsEmpty() == false) {
obj->Set(env->path_string(), path_string); obj->Set(env->context(), env->path_string(), path_string).FromJust();
} }
if (syscall != nullptr) { if (syscall != nullptr) {
obj->Set(env->syscall_string(), OneByteString(isolate, syscall)); obj->Set(env->context(),
env->syscall_string(),
OneByteString(isolate, syscall)).FromJust();
} }
return e; return e;
@ -132,13 +136,15 @@ Local<Value> UVException(Isolate* isolate,
Exception::Error(js_msg)->ToObject(isolate->GetCurrentContext()) Exception::Error(js_msg)->ToObject(isolate->GetCurrentContext())
.ToLocalChecked(); .ToLocalChecked();
e->Set(env->errno_string(), Integer::New(isolate, errorno)); e->Set(env->context(),
e->Set(env->code_string(), js_code); env->errno_string(),
e->Set(env->syscall_string(), js_syscall); Integer::New(isolate, errorno)).FromJust();
e->Set(env->context(), env->code_string(), js_code).FromJust();
e->Set(env->context(), env->syscall_string(), js_syscall).FromJust();
if (!js_path.IsEmpty()) if (!js_path.IsEmpty())
e->Set(env->path_string(), js_path); e->Set(env->context(), env->path_string(), js_path).FromJust();
if (!js_dest.IsEmpty()) if (!js_dest.IsEmpty())
e->Set(env->dest_string(), js_dest); e->Set(env->context(), env->dest_string(), js_dest).FromJust();
return e; return e;
} }

View File

@ -119,7 +119,9 @@ void FSEventWrap::Initialize(Local<Object> target,
Local<FunctionTemplate>(), Local<FunctionTemplate>(),
static_cast<PropertyAttribute>(ReadOnly | DontDelete | v8::DontEnum)); static_cast<PropertyAttribute>(ReadOnly | DontDelete | v8::DontEnum));
target->Set(fsevent_string, t->GetFunction(context).ToLocalChecked()); target->Set(env->context(),
fsevent_string,
t->GetFunction(context).ToLocalChecked()).FromJust();
} }

View File

@ -118,7 +118,7 @@ int JSStream::DoWrite(WriteWrap* w,
Local<Object> buf; Local<Object> buf;
for (size_t i = 0; i < count; i++) { for (size_t i = 0; i < count; i++) {
buf = Buffer::Copy(env(), bufs[i].base, bufs[i].len).ToLocalChecked(); buf = Buffer::Copy(env(), bufs[i].base, bufs[i].len).ToLocalChecked();
bufs_arr->Set(i, buf); bufs_arr->Set(env()->context(), i, buf).FromJust();
} }
Local<Value> argv[] = { Local<Value> argv[] = {
@ -210,7 +210,9 @@ void JSStream::Initialize(Local<Object> target,
env->SetProtoMethod(t, "emitEOF", EmitEOF); env->SetProtoMethod(t, "emitEOF", EmitEOF);
StreamBase::AddMethods<JSStream>(env, t); StreamBase::AddMethods<JSStream>(env, t);
target->Set(jsStreamString, t->GetFunction(context).ToLocalChecked()); target->Set(env->context(),
jsStreamString,
t->GetFunction(context).ToLocalChecked()).FromJust();
} }
} // namespace node } // namespace node

View File

@ -837,8 +837,8 @@ void ModuleWrap::Initialize(Local<Object> target,
env->SetProtoMethodNoSideEffect(tpl, "getStaticDependencySpecifiers", env->SetProtoMethodNoSideEffect(tpl, "getStaticDependencySpecifiers",
GetStaticDependencySpecifiers); GetStaticDependencySpecifiers);
target->Set(FIXED_ONE_BYTE_STRING(isolate, "ModuleWrap"), target->Set(env->context(), FIXED_ONE_BYTE_STRING(isolate, "ModuleWrap"),
tpl->GetFunction(context).ToLocalChecked()); tpl->GetFunction(context).ToLocalChecked()).FromJust();
env->SetMethod(target, "resolve", Resolve); env->SetMethod(target, "resolve", Resolve);
env->SetMethod(target, env->SetMethod(target,
"setImportModuleDynamicallyCallback", "setImportModuleDynamicallyCallback",

View File

@ -690,7 +690,8 @@ MaybeLocal<Value> MakeCallback(Isolate* isolate,
int argc, int argc,
Local<Value> argv[], Local<Value> argv[],
async_context asyncContext) { async_context asyncContext) {
Local<Value> callback_v = recv->Get(symbol); Local<Value> callback_v = recv->Get(isolate->GetCurrentContext(),
symbol).ToLocalChecked();
if (callback_v.IsEmpty()) return Local<Value>(); if (callback_v.IsEmpty()) return Local<Value>();
if (!callback_v->IsFunction()) return Local<Value>(); if (!callback_v->IsFunction()) return Local<Value>();
Local<Function> callback = callback_v.As<Function>(); Local<Function> callback = callback_v.As<Function>();
@ -1264,7 +1265,7 @@ static void GetLinkedBinding(const FunctionCallbackInfo<Value>& args) {
Local<Object> exports = Object::New(env->isolate()); Local<Object> exports = Object::New(env->isolate());
Local<String> exports_prop = String::NewFromUtf8(env->isolate(), "exports", Local<String> exports_prop = String::NewFromUtf8(env->isolate(), "exports",
NewStringType::kNormal).ToLocalChecked(); NewStringType::kNormal).ToLocalChecked();
module->Set(exports_prop, exports); module->Set(env->context(), exports_prop, exports).FromJust();
if (mod->nm_context_register_func != nullptr) { if (mod->nm_context_register_func != nullptr) {
mod->nm_context_register_func(exports, mod->nm_context_register_func(exports,
@ -1277,7 +1278,8 @@ static void GetLinkedBinding(const FunctionCallbackInfo<Value>& args) {
return env->ThrowError("Linked module has no declared entry point."); return env->ThrowError("Linked module has no declared entry point.");
} }
auto effective_exports = module->Get(exports_prop); auto effective_exports = module->Get(env->context(),
exports_prop).ToLocalChecked();
args.GetReturnValue().Set(effective_exports); args.GetReturnValue().Set(effective_exports);
} }
@ -1292,10 +1294,16 @@ static Local<Object> GetFeatures(Environment* env) {
Local<Value> debug = False(env->isolate()); Local<Value> debug = False(env->isolate());
#endif // defined(DEBUG) && DEBUG #endif // defined(DEBUG) && DEBUG
obj->Set(FIXED_ONE_BYTE_STRING(env->isolate(), "debug"), debug); obj->Set(env->context(),
obj->Set(FIXED_ONE_BYTE_STRING(env->isolate(), "uv"), True(env->isolate())); FIXED_ONE_BYTE_STRING(env->isolate(), "debug"),
debug).FromJust();
obj->Set(env->context(),
FIXED_ONE_BYTE_STRING(env->isolate(), "uv"),
True(env->isolate())).FromJust();
// TODO(bnoordhuis) ping libuv // TODO(bnoordhuis) ping libuv
obj->Set(FIXED_ONE_BYTE_STRING(env->isolate(), "ipv6"), True(env->isolate())); obj->Set(env->context(),
FIXED_ONE_BYTE_STRING(env->isolate(), "ipv6"),
True(env->isolate())).FromJust();
#ifdef HAVE_OPENSSL #ifdef HAVE_OPENSSL
Local<Boolean> have_openssl = True(env->isolate()); Local<Boolean> have_openssl = True(env->isolate());
@ -1303,10 +1311,18 @@ static Local<Object> GetFeatures(Environment* env) {
Local<Boolean> have_openssl = False(env->isolate()); Local<Boolean> have_openssl = False(env->isolate());
#endif #endif
obj->Set(FIXED_ONE_BYTE_STRING(env->isolate(), "tls_alpn"), have_openssl); obj->Set(env->context(),
obj->Set(FIXED_ONE_BYTE_STRING(env->isolate(), "tls_sni"), have_openssl); FIXED_ONE_BYTE_STRING(env->isolate(), "tls_alpn"),
obj->Set(FIXED_ONE_BYTE_STRING(env->isolate(), "tls_ocsp"), have_openssl); have_openssl).FromJust();
obj->Set(FIXED_ONE_BYTE_STRING(env->isolate(), "tls"), have_openssl); obj->Set(env->context(),
FIXED_ONE_BYTE_STRING(env->isolate(), "tls_sni"),
have_openssl).FromJust();
obj->Set(env->context(),
FIXED_ONE_BYTE_STRING(env->isolate(), "tls_ocsp"),
have_openssl).FromJust();
obj->Set(env->context(),
FIXED_ONE_BYTE_STRING(env->isolate(), "tls"),
have_openssl).FromJust();
return scope.Escape(obj); return scope.Escape(obj);
} }
@ -1468,7 +1484,9 @@ void SetupProcessObject(Environment* env,
NewStringType::kNormal).ToLocalChecked()) NewStringType::kNormal).ToLocalChecked())
.FromJust(); .FromJust();
} }
process->Set(FIXED_ONE_BYTE_STRING(env->isolate(), "argv"), arguments); process->Set(env->context(),
FIXED_ONE_BYTE_STRING(env->isolate(), "argv"),
arguments).FromJust();
// process.execArgv // process.execArgv
Local<Array> exec_arguments = Array::New(env->isolate(), exec_args.size()); Local<Array> exec_arguments = Array::New(env->isolate(), exec_args.size());
@ -1478,8 +1496,9 @@ void SetupProcessObject(Environment* env,
NewStringType::kNormal).ToLocalChecked()) NewStringType::kNormal).ToLocalChecked())
.FromJust(); .FromJust();
} }
process->Set(FIXED_ONE_BYTE_STRING(env->isolate(), "execArgv"), process->Set(env->context(),
exec_arguments); FIXED_ONE_BYTE_STRING(env->isolate(), "execArgv"),
exec_arguments).FromJust();
// create process.env // create process.env
Local<ObjectTemplate> process_env_template = Local<ObjectTemplate> process_env_template =
@ -1494,7 +1513,9 @@ void SetupProcessObject(Environment* env,
Local<Object> process_env = Local<Object> process_env =
process_env_template->NewInstance(env->context()).ToLocalChecked(); process_env_template->NewInstance(env->context()).ToLocalChecked();
process->Set(FIXED_ONE_BYTE_STRING(env->isolate(), "env"), process_env); process->Set(env->context(),
FIXED_ONE_BYTE_STRING(env->isolate(), "env"),
process_env).FromJust();
READONLY_PROPERTY(process, "pid", READONLY_PROPERTY(process, "pid",
Integer::New(env->isolate(), uv_os_getpid())); Integer::New(env->isolate(), uv_os_getpid()));
@ -1539,7 +1560,7 @@ void SetupProcessObject(Environment* env,
preload_modules[i].c_str(), preload_modules[i].c_str(),
NewStringType::kNormal) NewStringType::kNormal)
.ToLocalChecked(); .ToLocalChecked();
array->Set(i, module); array->Set(env->context(), i, module).FromJust();
} }
READONLY_PROPERTY(process, READONLY_PROPERTY(process,
"_preload_modules", "_preload_modules",
@ -1629,8 +1650,9 @@ void SetupProcessObject(Environment* env,
exec_path_value = String::NewFromUtf8(env->isolate(), args[0].c_str(), exec_path_value = String::NewFromUtf8(env->isolate(), args[0].c_str(),
NewStringType::kInternalized).ToLocalChecked(); NewStringType::kInternalized).ToLocalChecked();
} }
process->Set(FIXED_ONE_BYTE_STRING(env->isolate(), "execPath"), process->Set(env->context(),
exec_path_value); FIXED_ONE_BYTE_STRING(env->isolate(), "execPath"),
exec_path_value).FromJust();
delete[] exec_path; delete[] exec_path;
auto debug_port_string = FIXED_ONE_BYTE_STRING(env->isolate(), "debugPort"); auto debug_port_string = FIXED_ONE_BYTE_STRING(env->isolate(), "debugPort");
@ -1783,7 +1805,9 @@ void LoadEnvironment(Environment* env) {
// Expose the global object as a property on itself // Expose the global object as a property on itself
// (Allows you to set stuff on `global` from anywhere in JavaScript.) // (Allows you to set stuff on `global` from anywhere in JavaScript.)
global->Set(FIXED_ONE_BYTE_STRING(env->isolate(), "global"), global); global->Set(env->context(),
FIXED_ONE_BYTE_STRING(env->isolate(), "global"),
global).FromJust();
// Create binding loaders // Create binding loaders
Local<Function> get_binding_fn = Local<Function> get_binding_fn =
@ -2344,8 +2368,9 @@ int EmitExit(Environment* env) {
HandleScope handle_scope(env->isolate()); HandleScope handle_scope(env->isolate());
Context::Scope context_scope(env->context()); Context::Scope context_scope(env->context());
Local<Object> process_object = env->process_object(); Local<Object> process_object = env->process_object();
process_object->Set(FIXED_ONE_BYTE_STRING(env->isolate(), "_exiting"), process_object->Set(env->context(),
True(env->isolate())); FIXED_ONE_BYTE_STRING(env->isolate(), "_exiting"),
True(env->isolate())).FromJust();
Local<String> exit_code = env->exit_code_string(); Local<String> exit_code = env->exit_code_string();
int code = process_object->Get(env->context(), exit_code).ToLocalChecked() int code = process_object->Get(env->context(), exit_code).ToLocalChecked()

View File

@ -1347,15 +1347,33 @@ void DefineConstants(v8::Isolate* isolate, Local<Object> target) {
// Define libuv constants. // Define libuv constants.
NODE_DEFINE_CONSTANT(os_constants, UV_UDP_REUSEADDR); NODE_DEFINE_CONSTANT(os_constants, UV_UDP_REUSEADDR);
os_constants->Set(OneByteString(isolate, "dlopen"), dlopen_constants); os_constants->Set(env->context(),
os_constants->Set(OneByteString(isolate, "errno"), err_constants); OneByteString(isolate, "dlopen"),
os_constants->Set(OneByteString(isolate, "signals"), sig_constants); dlopen_constants).FromJust();
os_constants->Set(OneByteString(isolate, "priority"), priority_constants); os_constants->Set(env->context(),
target->Set(OneByteString(isolate, "os"), os_constants); OneByteString(isolate, "errno"),
target->Set(OneByteString(isolate, "fs"), fs_constants); err_constants).FromJust();
target->Set(OneByteString(isolate, "crypto"), crypto_constants); os_constants->Set(env->context(),
target->Set(OneByteString(isolate, "zlib"), zlib_constants); OneByteString(isolate, "signals"),
target->Set(OneByteString(isolate, "trace"), trace_constants); sig_constants).FromJust();
os_constants->Set(env->context(),
OneByteString(isolate, "priority"),
priority_constants).FromJust();
target->Set(env->context(),
OneByteString(isolate, "os"),
os_constants).FromJust();
target->Set(env->context(),
OneByteString(isolate, "fs"),
fs_constants).FromJust();
target->Set(env->context(),
OneByteString(isolate, "crypto"),
crypto_constants).FromJust();
target->Set(env->context(),
OneByteString(isolate, "zlib"),
zlib_constants).FromJust();
target->Set(env->context(),
OneByteString(isolate, "trace"),
trace_constants).FromJust();
} }
} // namespace node } // namespace node

View File

@ -392,7 +392,7 @@ void ContextifyContext::PropertySetterCallback(
args.GetReturnValue().Set(false); args.GetReturnValue().Set(false);
} }
ctx->sandbox()->Set(property, value); ctx->sandbox()->Set(ctx->context(), property, value).FromJust();
} }
// static // static
@ -606,8 +606,8 @@ void ContextifyScript::Init(Environment* env, Local<Object> target) {
env->SetProtoMethod(script_tmpl, "runInContext", RunInContext); env->SetProtoMethod(script_tmpl, "runInContext", RunInContext);
env->SetProtoMethod(script_tmpl, "runInThisContext", RunInThisContext); env->SetProtoMethod(script_tmpl, "runInThisContext", RunInThisContext);
target->Set(class_name, target->Set(env->context(), class_name,
script_tmpl->GetFunction(env->context()).ToLocalChecked()); script_tmpl->GetFunction(env->context()).ToLocalChecked()).FromJust();
env->set_script_context_constructor_template(script_tmpl); env->set_script_context_constructor_template(script_tmpl);
} }
@ -728,8 +728,9 @@ void ContextifyScript::New(const FunctionCallbackInfo<Value>& args) {
if (compile_options == ScriptCompiler::kConsumeCodeCache) { if (compile_options == ScriptCompiler::kConsumeCodeCache) {
args.This()->Set( args.This()->Set(
env->context(),
env->cached_data_rejected_string(), env->cached_data_rejected_string(),
Boolean::New(isolate, source.GetCachedData()->rejected)); Boolean::New(isolate, source.GetCachedData()->rejected)).FromJust();
} else if (produce_cached_data) { } else if (produce_cached_data) {
const ScriptCompiler::CachedData* cached_data = const ScriptCompiler::CachedData* cached_data =
ScriptCompiler::CreateCodeCache(v8_script.ToLocalChecked()); ScriptCompiler::CreateCodeCache(v8_script.ToLocalChecked());
@ -739,11 +740,14 @@ void ContextifyScript::New(const FunctionCallbackInfo<Value>& args) {
env, env,
reinterpret_cast<const char*>(cached_data->data), reinterpret_cast<const char*>(cached_data->data),
cached_data->length); cached_data->length);
args.This()->Set(env->cached_data_string(), buf.ToLocalChecked()); args.This()->Set(env->context(),
env->cached_data_string(),
buf.ToLocalChecked()).FromJust();
} }
args.This()->Set( args.This()->Set(
env->context(),
env->cached_data_produced_string(), env->cached_data_produced_string(),
Boolean::New(isolate, cached_data_produced)); Boolean::New(isolate, cached_data_produced)).FromJust();
} }
TRACE_EVENT_NESTABLE_ASYNC_END0( TRACE_EVENT_NESTABLE_ASYNC_END0(
TRACING_CATEGORY_NODE2(vm, script), TRACING_CATEGORY_NODE2(vm, script),

View File

@ -379,8 +379,8 @@ void SecureContext::Initialize(Environment* env, Local<Object> target) {
Local<FunctionTemplate>(), Local<FunctionTemplate>(),
static_cast<PropertyAttribute>(ReadOnly | DontDelete)); static_cast<PropertyAttribute>(ReadOnly | DontDelete));
target->Set(secureContextString, target->Set(env->context(), secureContextString,
t->GetFunction(env->context()).ToLocalChecked()); t->GetFunction(env->context()).ToLocalChecked()).FromJust();
env->set_secure_context_constructor_template(t); env->set_secure_context_constructor_template(t);
} }
@ -1276,18 +1276,24 @@ int SecureContext::TicketKeyCallback(SSL* ssl,
Local<Array> arr = ret.As<Array>(); Local<Array> arr = ret.As<Array>();
int r = int r =
arr->Get(kTicketKeyReturnIndex)->Int32Value(env->context()).FromJust(); arr->Get(env->context(),
kTicketKeyReturnIndex).ToLocalChecked()
->Int32Value(env->context()).FromJust();
if (r < 0) if (r < 0)
return r; return r;
Local<Value> hmac = arr->Get(kTicketKeyHMACIndex); Local<Value> hmac = arr->Get(env->context(),
Local<Value> aes = arr->Get(kTicketKeyAESIndex); kTicketKeyHMACIndex).ToLocalChecked();
Local<Value> aes = arr->Get(env->context(),
kTicketKeyAESIndex).ToLocalChecked();
if (Buffer::Length(aes) != kTicketPartSize) if (Buffer::Length(aes) != kTicketPartSize)
return -1; return -1;
if (enc) { if (enc) {
Local<Value> name_val = arr->Get(kTicketKeyNameIndex); Local<Value> name_val = arr->Get(env->context(),
Local<Value> iv_val = arr->Get(kTicketKeyIVIndex); kTicketKeyNameIndex).ToLocalChecked();
Local<Value> iv_val = arr->Get(env->context(),
kTicketKeyIVIndex).ToLocalChecked();
if (Buffer::Length(name_val) != kTicketPartSize || if (Buffer::Length(name_val) != kTicketPartSize ||
Buffer::Length(iv_val) != kTicketPartSize) { Buffer::Length(iv_val) != kTicketPartSize) {
@ -1667,7 +1673,7 @@ static Local<Object> X509ToObject(Environment* env, X509* cert) {
unsigned char* pubserialized = unsigned char* pubserialized =
reinterpret_cast<unsigned char*>(Buffer::Data(pubbuff)); reinterpret_cast<unsigned char*>(Buffer::Data(pubbuff));
i2d_RSA_PUBKEY(rsa.get(), &pubserialized); i2d_RSA_PUBKEY(rsa.get(), &pubserialized);
info->Set(env->pubkey_string(), pubbuff); info->Set(env->context(), env->pubkey_string(), pubbuff).FromJust();
} }
pkey.reset(); pkey.reset();
@ -2422,7 +2428,8 @@ void SSLWrap<Base>::CertCbDone(const FunctionCallbackInfo<Value>& args) {
CHECK(w->is_waiting_cert_cb() && w->cert_cb_running_); CHECK(w->is_waiting_cert_cb() && w->cert_cb_running_);
Local<Object> object = w->object(); Local<Object> object = w->object();
Local<Value> ctx = object->Get(env->sni_context_string()); Local<Value> ctx = object->Get(env->context(),
env->sni_context_string()).ToLocalChecked();
Local<FunctionTemplate> cons = env->secure_context_constructor_template(); Local<FunctionTemplate> cons = env->secure_context_constructor_template();
// Not an object, probably undefined or null // Not an object, probably undefined or null
@ -2586,8 +2593,9 @@ void CipherBase::Initialize(Environment* env, Local<Object> target) {
env->SetProtoMethod(t, "setAuthTag", SetAuthTag); env->SetProtoMethod(t, "setAuthTag", SetAuthTag);
env->SetProtoMethod(t, "setAAD", SetAAD); env->SetProtoMethod(t, "setAAD", SetAAD);
target->Set(FIXED_ONE_BYTE_STRING(env->isolate(), "CipherBase"), target->Set(env->context(),
t->GetFunction(env->context()).ToLocalChecked()); FIXED_ONE_BYTE_STRING(env->isolate(), "CipherBase"),
t->GetFunction(env->context()).ToLocalChecked()).FromJust();
} }
@ -3191,8 +3199,9 @@ void Hmac::Initialize(Environment* env, v8::Local<Object> target) {
env->SetProtoMethod(t, "update", HmacUpdate); env->SetProtoMethod(t, "update", HmacUpdate);
env->SetProtoMethod(t, "digest", HmacDigest); env->SetProtoMethod(t, "digest", HmacDigest);
target->Set(FIXED_ONE_BYTE_STRING(env->isolate(), "Hmac"), target->Set(env->context(),
t->GetFunction(env->context()).ToLocalChecked()); FIXED_ONE_BYTE_STRING(env->isolate(), "Hmac"),
t->GetFunction(env->context()).ToLocalChecked()).FromJust();
} }
@ -3311,8 +3320,9 @@ void Hash::Initialize(Environment* env, v8::Local<Object> target) {
env->SetProtoMethod(t, "update", HashUpdate); env->SetProtoMethod(t, "update", HashUpdate);
env->SetProtoMethod(t, "digest", HashDigest); env->SetProtoMethod(t, "digest", HashDigest);
target->Set(FIXED_ONE_BYTE_STRING(env->isolate(), "Hash"), target->Set(env->context(),
t->GetFunction(env->context()).ToLocalChecked()); FIXED_ONE_BYTE_STRING(env->isolate(), "Hash"),
t->GetFunction(env->context()).ToLocalChecked()).FromJust();
} }
@ -3506,8 +3516,9 @@ void Sign::Initialize(Environment* env, v8::Local<Object> target) {
env->SetProtoMethod(t, "update", SignUpdate); env->SetProtoMethod(t, "update", SignUpdate);
env->SetProtoMethod(t, "sign", SignFinal); env->SetProtoMethod(t, "sign", SignFinal);
target->Set(FIXED_ONE_BYTE_STRING(env->isolate(), "Sign"), target->Set(env->context(),
t->GetFunction(env->context()).ToLocalChecked()); FIXED_ONE_BYTE_STRING(env->isolate(), "Sign"),
t->GetFunction(env->context()).ToLocalChecked()).FromJust();
} }
@ -3737,8 +3748,9 @@ void Verify::Initialize(Environment* env, v8::Local<Object> target) {
env->SetProtoMethod(t, "update", VerifyUpdate); env->SetProtoMethod(t, "update", VerifyUpdate);
env->SetProtoMethod(t, "verify", VerifyFinal); env->SetProtoMethod(t, "verify", VerifyFinal);
target->Set(FIXED_ONE_BYTE_STRING(env->isolate(), "Verify"), target->Set(env->context(),
t->GetFunction(env->context()).ToLocalChecked()); FIXED_ONE_BYTE_STRING(env->isolate(), "Verify"),
t->GetFunction(env->context()).ToLocalChecked()).FromJust();
} }
@ -3974,7 +3986,9 @@ void DiffieHellman::Initialize(Environment* env, Local<Object> target) {
Local<FunctionTemplate>(), Local<FunctionTemplate>(),
attributes); attributes);
target->Set(name, t->GetFunction(env->context()).ToLocalChecked()); target->Set(env->context(),
name,
t->GetFunction(env->context()).ToLocalChecked()).FromJust();
}; };
make(FIXED_ONE_BYTE_STRING(env->isolate(), "DiffieHellman"), New); make(FIXED_ONE_BYTE_STRING(env->isolate(), "DiffieHellman"), New);
@ -4301,8 +4315,9 @@ void ECDH::Initialize(Environment* env, Local<Object> target) {
env->SetProtoMethod(t, "setPublicKey", SetPublicKey); env->SetProtoMethod(t, "setPublicKey", SetPublicKey);
env->SetProtoMethod(t, "setPrivateKey", SetPrivateKey); env->SetProtoMethod(t, "setPrivateKey", SetPrivateKey);
target->Set(FIXED_ONE_BYTE_STRING(env->isolate(), "ECDH"), target->Set(env->context(),
t->GetFunction(env->context()).ToLocalChecked()); FIXED_ONE_BYTE_STRING(env->isolate(), "ECDH"),
t->GetFunction(env->context()).ToLocalChecked()).FromJust();
} }
@ -5309,7 +5324,9 @@ static void array_push_back(const TypeName* md,
const char* to, const char* to,
void* arg) { void* arg) {
CipherPushContext* ctx = static_cast<CipherPushContext*>(arg); CipherPushContext* ctx = static_cast<CipherPushContext*>(arg);
ctx->arr->Set(ctx->arr->Length(), OneByteString(ctx->env()->isolate(), from)); ctx->arr->Set(ctx->env()->context(),
ctx->arr->Length(),
OneByteString(ctx->env()->isolate(), from)).FromJust();
} }

View File

@ -65,7 +65,8 @@ using v8::Value;
"expected object for " #obj " to contain string member " #member); \ "expected object for " #obj " to contain string member " #member); \
} \ } \
node::Utf8Value _##member(env->isolate(), \ node::Utf8Value _##member(env->isolate(), \
obj->Get(OneByteString(env->isolate(), #member))); \ obj->Get(env->context(), \
OneByteString(env->isolate(), #member)).ToLocalChecked()); \
if ((*(const char **)valp = *_##member) == nullptr) \ if ((*(const char **)valp = *_##member) == nullptr) \
*(const char **)valp = "<unknown>"; *(const char **)valp = "<unknown>";
@ -75,7 +76,8 @@ using v8::Value;
env, \ env, \
"expected object for " #obj " to contain integer member " #member); \ "expected object for " #obj " to contain integer member " #member); \
} \ } \
*valp = obj->Get(OneByteString(env->isolate(), #member)) \ *valp = obj->Get(env->context(), \
OneByteString(env->isolate(), #member)).ToLocalChecked() \
->Int32Value(env->context()) \ ->Int32Value(env->context()) \
.FromJust(); .FromJust();
@ -84,7 +86,8 @@ using v8::Value;
return node::THROW_ERR_INVALID_ARG_TYPE(env, \ return node::THROW_ERR_INVALID_ARG_TYPE(env, \
"expected object for " #obj " to contain object member " #member); \ "expected object for " #obj " to contain object member " #member); \
} \ } \
*valp = Local<Object>::Cast(obj->Get(OneByteString(env->isolate(), #member))); *valp = Local<Object>::Cast(obj->Get(env->context(), \
OneByteString(env->isolate(), #member)).ToLocalChecked());
#define SLURP_CONNECTION(arg, conn) \ #define SLURP_CONNECTION(arg, conn) \
if (!(arg)->IsObject()) { \ if (!(arg)->IsObject()) { \
@ -94,7 +97,9 @@ using v8::Value;
node_dtrace_connection_t conn; \ node_dtrace_connection_t conn; \
Local<Object> _##conn = Local<Object>::Cast(arg); \ Local<Object> _##conn = Local<Object>::Cast(arg); \
Local<Value> _handle = \ Local<Value> _handle = \
(_##conn)->Get(FIXED_ONE_BYTE_STRING(env->isolate(), "_handle")); \ (_##conn)->Get(env->context(), \
FIXED_ONE_BYTE_STRING(env->isolate(), "_handle")) \
.ToLocalChecked(); \
if (_handle->IsObject()) { \ if (_handle->IsObject()) { \
SLURP_INT(_handle.As<Object>(), fd, &conn.fd); \ SLURP_INT(_handle.As<Object>(), fd, &conn.fd); \
} else { \ } else { \
@ -173,7 +178,8 @@ void DTRACE_HTTP_SERVER_REQUEST(const FunctionCallbackInfo<Value>& args) {
"expected object for request to contain string member headers"); "expected object for request to contain string member headers");
} }
Local<Value> strfwdfor = headers->Get(env->x_forwarded_string()); Local<Value> strfwdfor = headers->Get(
env->context(), env->x_forwarded_string()).ToLocalChecked();
node::Utf8Value fwdfor(env->isolate(), strfwdfor); node::Utf8Value fwdfor(env->isolate(), strfwdfor);
if (!strfwdfor->IsString() || (req.forwardedFor = *fwdfor) == nullptr) if (!strfwdfor->IsString() || (req.forwardedFor = *fwdfor) == nullptr)
@ -279,7 +285,7 @@ void InitDTrace(Environment* env, Local<Object> target) {
Local<Value> val = env->NewFunctionTemplate(tab[i].func) Local<Value> val = env->NewFunctionTemplate(tab[i].func)
->GetFunction(env->context()) ->GetFunction(env->context())
.ToLocalChecked(); .ToLocalChecked();
target->Set(key, val); target->Set(env->context(), key, val).FromJust();
} }
#ifdef HAVE_ETW #ifdef HAVE_ETW

View File

@ -198,7 +198,8 @@ void ReportException(Environment* env,
} else { } else {
Local<Object> err_obj = er->ToObject(env->context()).ToLocalChecked(); Local<Object> err_obj = er->ToObject(env->context()).ToLocalChecked();
trace_value = err_obj->Get(env->stack_string()); trace_value = err_obj->Get(env->context(),
env->stack_string()).ToLocalChecked();
arrow = arrow =
err_obj->GetPrivate(env->context(), env->arrow_message_private_symbol()) err_obj->GetPrivate(env->context(), env->arrow_message_private_symbol())
.ToLocalChecked(); .ToLocalChecked();
@ -223,8 +224,10 @@ void ReportException(Environment* env,
if (er->IsObject()) { if (er->IsObject()) {
Local<Object> err_obj = er.As<Object>(); Local<Object> err_obj = er.As<Object>();
message = err_obj->Get(env->message_string()); message = err_obj->Get(env->context(),
name = err_obj->Get(FIXED_ONE_BYTE_STRING(env->isolate(), "name")); env->message_string()).ToLocalChecked();
name = err_obj->Get(env->context(),
FIXED_ONE_BYTE_STRING(env->isolate(), "name")).ToLocalChecked();
} }
if (message.IsEmpty() || message->IsUndefined() || name.IsEmpty() || if (message.IsEmpty() || message->IsUndefined() || name.IsEmpty() ||
@ -269,7 +272,8 @@ void DecorateErrorStack(Environment* env, const TryCatch& try_catch) {
if (IsExceptionDecorated(env, err_obj)) return; if (IsExceptionDecorated(env, err_obj)) return;
AppendExceptionLine(env, exception, try_catch.Message(), CONTEXTIFY_ERROR); AppendExceptionLine(env, exception, try_catch.Message(), CONTEXTIFY_ERROR);
Local<Value> stack = err_obj->Get(env->stack_string()); Local<Value> stack = err_obj->Get(env->context(),
env->stack_string()).ToLocalChecked();
MaybeLocal<Value> maybe_value = MaybeLocal<Value> maybe_value =
err_obj->GetPrivate(env->context(), env->arrow_message_private_symbol()); err_obj->GetPrivate(env->context(), env->arrow_message_private_symbol());
@ -288,7 +292,7 @@ void DecorateErrorStack(Environment* env, const TryCatch& try_catch) {
arrow.As<String>(), arrow.As<String>(),
FIXED_ONE_BYTE_STRING(env->isolate(), "\n")), FIXED_ONE_BYTE_STRING(env->isolate(), "\n")),
stack.As<String>()); stack.As<String>());
err_obj->Set(env->stack_string(), decorated_stack); err_obj->Set(env->context(), env->stack_string(), decorated_stack).FromJust();
err_obj->SetPrivate( err_obj->SetPrivate(
env->context(), env->decorated_private_symbol(), True(env->isolate())); env->context(), env->decorated_private_symbol(), True(env->isolate()));
} }
@ -361,7 +365,8 @@ void FatalException(Isolate* isolate,
Local<Object> process_object = env->process_object(); Local<Object> process_object = env->process_object();
Local<String> fatal_exception_string = env->fatal_exception_string(); Local<String> fatal_exception_string = env->fatal_exception_string();
Local<Value> fatal_exception_function = Local<Value> fatal_exception_function =
process_object->Get(fatal_exception_string); process_object->Get(env->context(),
fatal_exception_string).ToLocalChecked();
if (!fatal_exception_function->IsFunction()) { if (!fatal_exception_function->IsFunction()) {
// Failed before the process._fatalException function was added! // Failed before the process._fatalException function was added!

View File

@ -640,8 +640,14 @@ void AfterScanDirWithTypes(uv_fs_t* req) {
} }
Local<Array> result = Array::New(isolate, 2); Local<Array> result = Array::New(isolate, 2);
result->Set(0, Array::New(isolate, name_v.data(), name_v.size())); result->Set(env->context(),
result->Set(1, Array::New(isolate, type_v.data(), type_v.size())); 0,
Array::New(isolate, name_v.data(),
name_v.size())).FromJust();
result->Set(env->context(),
1,
Array::New(isolate, type_v.data(),
type_v.size())).FromJust();
req_wrap->Resolve(result); req_wrap->Resolve(result);
} }
@ -1482,8 +1488,11 @@ static void ReadDir(const FunctionCallbackInfo<Value>& args) {
Local<Array> names = Array::New(isolate, name_v.data(), name_v.size()); Local<Array> names = Array::New(isolate, name_v.data(), name_v.size());
if (with_types) { if (with_types) {
Local<Array> result = Array::New(isolate, 2); Local<Array> result = Array::New(isolate, 2);
result->Set(0, names); result->Set(env->context(), 0, names).FromJust();
result->Set(1, Array::New(isolate, type_v.data(), type_v.size())); result->Set(env->context(),
1,
Array::New(isolate, type_v.data(),
type_v.size())).FromJust();
args.GetReturnValue().Set(result); args.GetReturnValue().Set(result);
} else { } else {
args.GetReturnValue().Set(names); args.GetReturnValue().Set(names);
@ -1667,7 +1676,7 @@ static void WriteBuffers(const FunctionCallbackInfo<Value>& args) {
MaybeStackBuffer<uv_buf_t> iovs(chunks->Length()); MaybeStackBuffer<uv_buf_t> iovs(chunks->Length());
for (uint32_t i = 0; i < iovs.length(); i++) { for (uint32_t i = 0; i < iovs.length(); i++) {
Local<Value> chunk = chunks->Get(i); Local<Value> chunk = chunks->Get(env->context(), i).ToLocalChecked();
CHECK(Buffer::HasInstance(chunk)); CHECK(Buffer::HasInstance(chunk));
iovs[i] = uv_buf_init(Buffer::Data(chunk), Buffer::Length(chunk)); iovs[i] = uv_buf_init(Buffer::Data(chunk), Buffer::Length(chunk));
} }

View File

@ -3057,8 +3057,10 @@ void Initialize(Local<Object> target,
#define V(name) \ #define V(name) \
NODE_DEFINE_CONSTANT(constants, name); \ NODE_DEFINE_CONSTANT(constants, name); \
name_for_error_code->Set(static_cast<int>(name), \ name_for_error_code->Set(env->context(), \
FIXED_ONE_BYTE_STRING(isolate, #name)); static_cast<int>(name), \
FIXED_ONE_BYTE_STRING(isolate, \
#name)).FromJust();
NODE_NGHTTP2_ERROR_CODES(V) NODE_NGHTTP2_ERROR_CODES(V)
#undef V #undef V

View File

@ -265,7 +265,8 @@ class Parser : public AsyncWrap, public StreamListener {
Local<Value> argv[A_MAX]; Local<Value> argv[A_MAX];
Local<Object> obj = object(); Local<Object> obj = object();
Local<Value> cb = obj->Get(kOnHeadersComplete); Local<Value> cb = obj->Get(env()->context(),
kOnHeadersComplete).ToLocalChecked();
if (!cb->IsFunction()) if (!cb->IsFunction())
return 0; return 0;
@ -338,7 +339,7 @@ class Parser : public AsyncWrap, public StreamListener {
EscapableHandleScope scope(env()->isolate()); EscapableHandleScope scope(env()->isolate());
Local<Object> obj = object(); Local<Object> obj = object();
Local<Value> cb = obj->Get(kOnBody); Local<Value> cb = obj->Get(env()->context(), kOnBody).ToLocalChecked();
if (!cb->IsFunction()) if (!cb->IsFunction())
return 0; return 0;
@ -381,7 +382,8 @@ class Parser : public AsyncWrap, public StreamListener {
Flush(); // Flush trailing HTTP headers. Flush(); // Flush trailing HTTP headers.
Local<Object> obj = object(); Local<Object> obj = object();
Local<Value> cb = obj->Get(kOnMessageComplete); Local<Value> cb = obj->Get(env()->context(),
kOnMessageComplete).ToLocalChecked();
if (!cb->IsFunction()) if (!cb->IsFunction())
return 0; return 0;
@ -705,17 +707,23 @@ class Parser : public AsyncWrap, public StreamListener {
Local<Value> e = Exception::Error(env()->parse_error_string()); Local<Value> e = Exception::Error(env()->parse_error_string());
Local<Object> obj = e->ToObject(env()->isolate()->GetCurrentContext()) Local<Object> obj = e->ToObject(env()->isolate()->GetCurrentContext())
.ToLocalChecked(); .ToLocalChecked();
obj->Set(env()->bytes_parsed_string(), nread_obj); obj->Set(env()->context(),
env()->bytes_parsed_string(),
nread_obj).FromJust();
#ifdef NODE_EXPERIMENTAL_HTTP #ifdef NODE_EXPERIMENTAL_HTTP
obj->Set(env()->code_string(), obj->Set(env()->context(),
OneByteString(env()->isolate(), llhttp_errno_name(err))); env()->code_string(),
obj->Set(env()->reason_string(), OneByteString(env()->isolate(),
OneByteString(env()->isolate(), parser_.reason)); llhttp_errno_name(err))).FromJust();
obj->Set(env()->context(),
env()->reason_string(),
OneByteString(env()->isolate(), parser_.reason)).FromJust();
#else /* !NODE_EXPERIMENTAL_HTTP */ #else /* !NODE_EXPERIMENTAL_HTTP */
obj->Set(env()->code_string(), obj->Set(env()->context(),
OneByteString(env()->isolate(), http_errno_name(err))); env()->code_string(),
OneByteString(env()->isolate(),
http_errno_name(err))).FromJust();
#endif /* NODE_EXPERIMENTAL_HTTP */ #endif /* NODE_EXPERIMENTAL_HTTP */
return scope.Escape(e); return scope.Escape(e);
} }
@ -750,7 +758,7 @@ class Parser : public AsyncWrap, public StreamListener {
HandleScope scope(env()->isolate()); HandleScope scope(env()->isolate());
Local<Object> obj = object(); Local<Object> obj = object();
Local<Value> cb = obj->Get(kOnHeaders); Local<Value> cb = obj->Get(env()->context(), kOnHeaders).ToLocalChecked();
if (!cb->IsFunction()) if (!cb->IsFunction())
return; return;
@ -902,10 +910,13 @@ void Initialize(Local<Object> target,
Local<Array> methods = Array::New(env->isolate()); Local<Array> methods = Array::New(env->isolate());
#define V(num, name, string) \ #define V(num, name, string) \
methods->Set(num, FIXED_ONE_BYTE_STRING(env->isolate(), #string)); methods->Set(env->context(), \
num, FIXED_ONE_BYTE_STRING(env->isolate(), #string)).FromJust();
HTTP_METHOD_MAP(V) HTTP_METHOD_MAP(V)
#undef V #undef V
target->Set(FIXED_ONE_BYTE_STRING(env->isolate(), "methods"), methods); target->Set(env->context(),
FIXED_ONE_BYTE_STRING(env->isolate(), "methods"),
methods).FromJust();
t->Inherit(AsyncWrap::GetConstructorTemplate(env)); t->Inherit(AsyncWrap::GetConstructorTemplate(env));
env->SetProtoMethod(t, "close", Parser::Close); env->SetProtoMethod(t, "close", Parser::Close);
@ -919,8 +930,9 @@ void Initialize(Local<Object> target,
env->SetProtoMethod(t, "unconsume", Parser::Unconsume); env->SetProtoMethod(t, "unconsume", Parser::Unconsume);
env->SetProtoMethod(t, "getCurrentBuffer", Parser::GetCurrentBuffer); env->SetProtoMethod(t, "getCurrentBuffer", Parser::GetCurrentBuffer);
target->Set(FIXED_ONE_BYTE_STRING(env->isolate(), "HTTPParser"), target->Set(env->context(),
t->GetFunction(env->context()).ToLocalChecked()); FIXED_ONE_BYTE_STRING(env->isolate(), "HTTPParser"),
t->GetFunction(env->context()).ToLocalChecked()).FromJust();
} }
} // anonymous namespace } // anonymous namespace

View File

@ -267,10 +267,11 @@ static void GetInterfaceAddresses(const FunctionCallbackInfo<Value>& args) {
v8::NewStringType::kNormal).ToLocalChecked(); v8::NewStringType::kNormal).ToLocalChecked();
if (ret->Has(env->context(), name).FromJust()) { if (ret->Has(env->context(), name).FromJust()) {
ifarr = Local<Array>::Cast(ret->Get(name)); ifarr = Local<Array>::Cast(ret->Get(env->context(),
name).ToLocalChecked());
} else { } else {
ifarr = Array::New(env->isolate()); ifarr = Array::New(env->isolate());
ret->Set(name, ifarr); ret->Set(env->context(), name, ifarr).FromJust();
} }
snprintf(mac, snprintf(mac,
@ -297,22 +298,29 @@ static void GetInterfaceAddresses(const FunctionCallbackInfo<Value>& args) {
} }
o = Object::New(env->isolate()); o = Object::New(env->isolate());
o->Set(env->address_string(), OneByteString(env->isolate(), ip)); o->Set(env->context(),
o->Set(env->netmask_string(), OneByteString(env->isolate(), netmask)); env->address_string(),
o->Set(env->family_string(), family); OneByteString(env->isolate(), ip)).FromJust();
o->Set(env->mac_string(), FIXED_ONE_BYTE_STRING(env->isolate(), mac)); o->Set(env->context(),
env->netmask_string(),
OneByteString(env->isolate(), netmask)).FromJust();
o->Set(env->context(),
env->family_string(), family).FromJust();
o->Set(env->context(),
env->mac_string(),
FIXED_ONE_BYTE_STRING(env->isolate(), mac)).FromJust();
if (interfaces[i].address.address4.sin_family == AF_INET6) { if (interfaces[i].address.address4.sin_family == AF_INET6) {
uint32_t scopeid = interfaces[i].address.address6.sin6_scope_id; uint32_t scopeid = interfaces[i].address.address6.sin6_scope_id;
o->Set(env->scopeid_string(), o->Set(env->context(), env->scopeid_string(),
Integer::NewFromUnsigned(env->isolate(), scopeid)); Integer::NewFromUnsigned(env->isolate(), scopeid)).FromJust();
} }
const bool internal = interfaces[i].is_internal; const bool internal = interfaces[i].is_internal;
o->Set(env->internal_string(), o->Set(env->context(), env->internal_string(),
internal ? True(env->isolate()) : False(env->isolate())); internal ? True(env->isolate()) : False(env->isolate())).FromJust();
ifarr->Set(ifarr->Length(), o); ifarr->Set(env->context(), ifarr->Length(), o).FromJust();
} }
uv_free_interface_addresses(interfaces, count); uv_free_interface_addresses(interfaces, count);
@ -397,11 +405,17 @@ static void GetUserInfo(const FunctionCallbackInfo<Value>& args) {
Local<Object> entry = Object::New(env->isolate()); Local<Object> entry = Object::New(env->isolate());
entry->Set(env->uid_string(), uid); entry->Set(env->context(), env->uid_string(), uid).FromJust();
entry->Set(env->gid_string(), gid); entry->Set(env->context(), env->gid_string(), gid).FromJust();
entry->Set(env->username_string(), username.ToLocalChecked()); entry->Set(env->context(),
entry->Set(env->homedir_string(), homedir.ToLocalChecked()); env->username_string(),
entry->Set(env->shell_string(), shell.ToLocalChecked()); username.ToLocalChecked()).FromJust();
entry->Set(env->context(),
env->homedir_string(),
homedir.ToLocalChecked()).FromJust();
entry->Set(env->context(),
env->shell_string(),
shell.ToLocalChecked()).FromJust();
args.GetReturnValue().Set(entry); args.GetReturnValue().Set(entry);
} }
@ -464,8 +478,9 @@ void Initialize(Local<Object> target,
env->SetMethod(target, "getUserInfo", GetUserInfo); env->SetMethod(target, "getUserInfo", GetUserInfo);
env->SetMethod(target, "setPriority", SetPriority); env->SetMethod(target, "setPriority", SetPriority);
env->SetMethod(target, "getPriority", GetPriority); env->SetMethod(target, "getPriority", GetPriority);
target->Set(FIXED_ONE_BYTE_STRING(env->isolate(), "isBigEndian"), target->Set(env->context(),
Boolean::New(env->isolate(), IsBigEndian())); FIXED_ONE_BYTE_STRING(env->isolate(), "isBigEndian"),
Boolean::New(env->isolate(), IsBigEndian())).FromJust();
} }
} // namespace os } // namespace os

View File

@ -488,7 +488,8 @@ void GetGroups(const FunctionCallbackInfo<Value>& args) {
gid_t egid = getegid(); gid_t egid = getegid();
for (int i = 0; i < ngroups; i++) { for (int i = 0; i < ngroups; i++) {
groups_list->Set(i, Integer::New(env->isolate(), groups[i])); groups_list->Set(env->context(),
i, Integer::New(env->isolate(), groups[i])).FromJust();
if (groups[i] == egid) if (groups[i] == egid)
seen_egid = true; seen_egid = true;
} }
@ -496,7 +497,9 @@ void GetGroups(const FunctionCallbackInfo<Value>& args) {
delete[] groups; delete[] groups;
if (seen_egid == false) if (seen_egid == false)
groups_list->Set(ngroups, Integer::New(env->isolate(), egid)); groups_list->Set(env->context(),
ngroups,
Integer::New(env->isolate(), egid)).FromJust();
args.GetReturnValue().Set(groups_list); args.GetReturnValue().Set(groups_list);
} }
@ -513,7 +516,9 @@ void SetGroups(const FunctionCallbackInfo<Value>& args) {
gid_t* groups = new gid_t[size]; gid_t* groups = new gid_t[size];
for (size_t i = 0; i < size; i++) { for (size_t i = 0; i < size; i++) {
gid_t gid = gid_by_name(env->isolate(), groups_list->Get(i)); gid_t gid = gid_by_name(env->isolate(),
groups_list->Get(env->context(),
i).ToLocalChecked());
if (gid == gid_not_found) { if (gid == gid_not_found) {
delete[] groups; delete[] groups;

View File

@ -54,8 +54,8 @@ void StatWatcher::Initialize(Environment* env, Local<Object> target) {
env->SetProtoMethod(t, "start", StatWatcher::Start); env->SetProtoMethod(t, "start", StatWatcher::Start);
target->Set(statWatcherString, target->Set(env->context(), statWatcherString,
t->GetFunction(env->context()).ToLocalChecked()); t->GetFunction(env->context()).ToLocalChecked()).FromJust();
} }

View File

@ -110,8 +110,10 @@ void Initialize(Local<Object> target,
env->SetProtoMethod(category_set, "enable", NodeCategorySet::Enable); env->SetProtoMethod(category_set, "enable", NodeCategorySet::Enable);
env->SetProtoMethod(category_set, "disable", NodeCategorySet::Disable); env->SetProtoMethod(category_set, "disable", NodeCategorySet::Disable);
target->Set(FIXED_ONE_BYTE_STRING(env->isolate(), "CategorySet"), target->Set(env->context(),
category_set->GetFunction(env->context()).ToLocalChecked()); FIXED_ONE_BYTE_STRING(env->isolate(), "CategorySet"),
category_set->GetFunction(env->context()).ToLocalChecked())
.FromJust();
Local<String> isTraceCategoryEnabled = Local<String> isTraceCategoryEnabled =
FIXED_ONE_BYTE_STRING(env->isolate(), "isTraceCategoryEnabled"); FIXED_ONE_BYTE_STRING(env->isolate(), "isTraceCategoryEnabled");

View File

@ -57,6 +57,7 @@ static void GetOwnNonIndexProperties(
} }
static void GetPromiseDetails(const FunctionCallbackInfo<Value>& args) { static void GetPromiseDetails(const FunctionCallbackInfo<Value>& args) {
Environment* env = Environment::GetCurrent(args);
// Return undefined if it's not a Promise. // Return undefined if it's not a Promise.
if (!args[0]->IsPromise()) if (!args[0]->IsPromise())
return; return;
@ -67,14 +68,15 @@ static void GetPromiseDetails(const FunctionCallbackInfo<Value>& args) {
Local<Array> ret = Array::New(isolate, 2); Local<Array> ret = Array::New(isolate, 2);
int state = promise->State(); int state = promise->State();
ret->Set(0, Integer::New(isolate, state)); ret->Set(env->context(), 0, Integer::New(isolate, state)).FromJust();
if (state != Promise::PromiseState::kPending) if (state != Promise::PromiseState::kPending)
ret->Set(1, promise->Result()); ret->Set(env->context(), 1, promise->Result()).FromJust();
args.GetReturnValue().Set(ret); args.GetReturnValue().Set(ret);
} }
static void GetProxyDetails(const FunctionCallbackInfo<Value>& args) { static void GetProxyDetails(const FunctionCallbackInfo<Value>& args) {
Environment* env = Environment::GetCurrent(args);
// Return undefined if it's not a proxy. // Return undefined if it's not a proxy.
if (!args[0]->IsProxy()) if (!args[0]->IsProxy())
return; return;
@ -82,8 +84,8 @@ static void GetProxyDetails(const FunctionCallbackInfo<Value>& args) {
Local<Proxy> proxy = args[0].As<Proxy>(); Local<Proxy> proxy = args[0].As<Proxy>();
Local<Array> ret = Array::New(args.GetIsolate(), 2); Local<Array> ret = Array::New(args.GetIsolate(), 2);
ret->Set(0, proxy->GetTarget()); ret->Set(env->context(), 0, proxy->GetTarget()).FromJust();
ret->Set(1, proxy->GetHandler()); ret->Set(env->context(), 1, proxy->GetHandler()).FromJust();
args.GetReturnValue().Set(ret); args.GetReturnValue().Set(ret);
} }

View File

@ -134,23 +134,27 @@ void Initialize(Local<Object> target,
const size_t heap_statistics_buffer_byte_length = const size_t heap_statistics_buffer_byte_length =
sizeof(*env->heap_statistics_buffer()) * kHeapStatisticsPropertiesCount; sizeof(*env->heap_statistics_buffer()) * kHeapStatisticsPropertiesCount;
target->Set(FIXED_ONE_BYTE_STRING(env->isolate(), target->Set(env->context(),
FIXED_ONE_BYTE_STRING(env->isolate(),
"heapStatisticsArrayBuffer"), "heapStatisticsArrayBuffer"),
ArrayBuffer::New(env->isolate(), ArrayBuffer::New(env->isolate(),
env->heap_statistics_buffer(), env->heap_statistics_buffer(),
heap_statistics_buffer_byte_length)); heap_statistics_buffer_byte_length)).FromJust();
#define V(i, _, name) \ #define V(i, _, name) \
target->Set(FIXED_ONE_BYTE_STRING(env->isolate(), #name), \ target->Set(env->context(), \
Uint32::NewFromUnsigned(env->isolate(), i)); FIXED_ONE_BYTE_STRING(env->isolate(), #name), \
Uint32::NewFromUnsigned(env->isolate(), i)).FromJust();
HEAP_STATISTICS_PROPERTIES(V) HEAP_STATISTICS_PROPERTIES(V)
#undef V #undef V
target->Set(FIXED_ONE_BYTE_STRING(env->isolate(), target->Set(env->context(),
FIXED_ONE_BYTE_STRING(env->isolate(),
"kHeapSpaceStatisticsPropertiesCount"), "kHeapSpaceStatisticsPropertiesCount"),
Uint32::NewFromUnsigned(env->isolate(), Uint32::NewFromUnsigned(env->isolate(),
kHeapSpaceStatisticsPropertiesCount)); kHeapSpaceStatisticsPropertiesCount))
.FromJust();
size_t number_of_heap_spaces = env->isolate()->NumberOfHeapSpaces(); size_t number_of_heap_spaces = env->isolate()->NumberOfHeapSpaces();
@ -165,10 +169,11 @@ void Initialize(Local<Object> target,
s.space_name(), s.space_name(),
NewStringType::kNormal) NewStringType::kNormal)
.ToLocalChecked(); .ToLocalChecked();
heap_spaces->Set(i, heap_space_name); heap_spaces->Set(env->context(), i, heap_space_name).FromJust();
} }
target->Set(FIXED_ONE_BYTE_STRING(env->isolate(), "kHeapSpaces"), target->Set(env->context(),
heap_spaces); FIXED_ONE_BYTE_STRING(env->isolate(), "kHeapSpaces"),
heap_spaces).FromJust();
env->SetMethod(target, env->SetMethod(target,
"updateHeapSpaceStatisticsArrayBuffer", "updateHeapSpaceStatisticsArrayBuffer",
@ -182,15 +187,18 @@ void Initialize(Local<Object> target,
kHeapSpaceStatisticsPropertiesCount * kHeapSpaceStatisticsPropertiesCount *
number_of_heap_spaces; number_of_heap_spaces;
target->Set(FIXED_ONE_BYTE_STRING(env->isolate(), target->Set(env->context(),
FIXED_ONE_BYTE_STRING(env->isolate(),
"heapSpaceStatisticsArrayBuffer"), "heapSpaceStatisticsArrayBuffer"),
ArrayBuffer::New(env->isolate(), ArrayBuffer::New(env->isolate(),
env->heap_space_statistics_buffer(), env->heap_space_statistics_buffer(),
heap_space_statistics_buffer_byte_length)); heap_space_statistics_buffer_byte_length))
.FromJust();
#define V(i, _, name) \ #define V(i, _, name) \
target->Set(FIXED_ONE_BYTE_STRING(env->isolate(), #name), \ target->Set(env->context(), \
Uint32::NewFromUnsigned(env->isolate(), i)); FIXED_ONE_BYTE_STRING(env->isolate(), #name), \
Uint32::NewFromUnsigned(env->isolate(), i)).FromJust();
HEAP_SPACE_STATISTICS_PROPERTIES(V) HEAP_SPACE_STATISTICS_PROPERTIES(V)
#undef V #undef V

View File

@ -490,7 +490,9 @@ void InitWorker(Local<Object> target,
Local<String> workerString = Local<String> workerString =
FIXED_ONE_BYTE_STRING(env->isolate(), "Worker"); FIXED_ONE_BYTE_STRING(env->isolate(), "Worker");
w->SetClassName(workerString); w->SetClassName(workerString);
target->Set(workerString, w->GetFunction(env->context()).ToLocalChecked()); target->Set(env->context(),
workerString,
w->GetFunction(env->context()).ToLocalChecked()).FromJust();
} }
env->SetMethod(target, "getEnvMessagePort", GetEnvMessagePort); env->SetMethod(target, "getEnvMessagePort", GetEnvMessagePort);

View File

@ -896,10 +896,13 @@ void Initialize(Local<Object> target,
Local<String> zlibString = FIXED_ONE_BYTE_STRING(env->isolate(), "Zlib"); Local<String> zlibString = FIXED_ONE_BYTE_STRING(env->isolate(), "Zlib");
z->SetClassName(zlibString); z->SetClassName(zlibString);
target->Set(zlibString, z->GetFunction(env->context()).ToLocalChecked()); target->Set(env->context(),
zlibString,
z->GetFunction(env->context()).ToLocalChecked()).FromJust();
target->Set(FIXED_ONE_BYTE_STRING(env->isolate(), "ZLIB_VERSION"), target->Set(env->context(),
FIXED_ONE_BYTE_STRING(env->isolate(), ZLIB_VERSION)); FIXED_ONE_BYTE_STRING(env->isolate(), "ZLIB_VERSION"),
FIXED_ONE_BYTE_STRING(env->isolate(), ZLIB_VERSION)).FromJust();
} }
} // anonymous namespace } // anonymous namespace

View File

@ -90,7 +90,9 @@ void PipeWrap::Initialize(Local<Object> target,
env->SetProtoMethod(t, "fchmod", Fchmod); env->SetProtoMethod(t, "fchmod", Fchmod);
target->Set(pipeString, t->GetFunction(env->context()).ToLocalChecked()); target->Set(env->context(),
pipeString,
t->GetFunction(env->context()).ToLocalChecked()).FromJust();
env->set_pipe_constructor_template(t); env->set_pipe_constructor_template(t);
// Create FunctionTemplate for PipeConnectWrap. // Create FunctionTemplate for PipeConnectWrap.
@ -99,7 +101,9 @@ void PipeWrap::Initialize(Local<Object> target,
Local<String> wrapString = Local<String> wrapString =
FIXED_ONE_BYTE_STRING(env->isolate(), "PipeConnectWrap"); FIXED_ONE_BYTE_STRING(env->isolate(), "PipeConnectWrap");
cwt->SetClassName(wrapString); cwt->SetClassName(wrapString);
target->Set(wrapString, cwt->GetFunction(env->context()).ToLocalChecked()); target->Set(env->context(),
wrapString,
cwt->GetFunction(env->context()).ToLocalChecked()).FromJust();
// Define constants // Define constants
Local<Object> constants = Object::New(env->isolate()); Local<Object> constants = Object::New(env->isolate());

View File

@ -62,8 +62,9 @@ class ProcessWrap : public HandleWrap {
env->SetProtoMethod(constructor, "spawn", Spawn); env->SetProtoMethod(constructor, "spawn", Spawn);
env->SetProtoMethod(constructor, "kill", Kill); env->SetProtoMethod(constructor, "kill", Kill);
target->Set(processString, target->Set(env->context(),
constructor->GetFunction(context).ToLocalChecked()); processString,
constructor->GetFunction(context).ToLocalChecked()).FromJust();
} }
SET_NO_MEMORY_INFO() SET_NO_MEMORY_INFO()

View File

@ -55,8 +55,9 @@ class SignalWrap : public HandleWrap {
env->SetProtoMethod(constructor, "start", Start); env->SetProtoMethod(constructor, "start", Start);
env->SetProtoMethod(constructor, "stop", Stop); env->SetProtoMethod(constructor, "stop", Stop);
target->Set(signalString, target->Set(env->context(), signalString,
constructor->GetFunction(env->context()).ToLocalChecked()); constructor->GetFunction(env->context()).ToLocalChecked())
.FromJust();
} }
SET_NO_MEMORY_INFO() SET_NO_MEMORY_INFO()

View File

@ -179,7 +179,9 @@ inline int StreamBase::Shutdown(v8::Local<v8::Object> req_wrap_obj) {
const char* msg = Error(); const char* msg = Error();
if (msg != nullptr) { if (msg != nullptr) {
req_wrap_obj->Set(env->error_string(), OneByteString(env->isolate(), msg)); req_wrap_obj->Set(
env->context(),
env->error_string(), OneByteString(env->isolate(), msg)).FromJust();
ClearError(); ClearError();
} }
@ -228,7 +230,9 @@ inline StreamWriteResult StreamBase::Write(
const char* msg = Error(); const char* msg = Error();
if (msg != nullptr) { if (msg != nullptr) {
req_wrap_obj->Set(env->error_string(), OneByteString(env->isolate(), msg)); req_wrap_obj->Set(env->context(),
env->error_string(),
OneByteString(env->isolate(), msg)).FromJust();
ClearError(); ClearError();
} }
@ -434,8 +438,10 @@ inline void StreamReq::Done(int status, const char* error_str) {
AsyncWrap* async_wrap = GetAsyncWrap(); AsyncWrap* async_wrap = GetAsyncWrap();
Environment* env = async_wrap->env(); Environment* env = async_wrap->env();
if (error_str != nullptr) { if (error_str != nullptr) {
async_wrap->object()->Set(env->error_string(), async_wrap->object()->Set(env->context(),
OneByteString(env->isolate(), error_str)); env->error_string(),
OneByteString(env->isolate(), error_str))
.FromJust();
} }
OnDone(status); OnDone(status);

View File

@ -83,7 +83,7 @@ int StreamBase::Writev(const FunctionCallbackInfo<Value>& args) {
if (!all_buffers) { if (!all_buffers) {
// Determine storage size first // Determine storage size first
for (size_t i = 0; i < count; i++) { for (size_t i = 0; i < count; i++) {
Local<Value> chunk = chunks->Get(i * 2); Local<Value> chunk = chunks->Get(env->context(), i * 2).ToLocalChecked();
if (Buffer::HasInstance(chunk)) if (Buffer::HasInstance(chunk))
continue; continue;
@ -92,7 +92,7 @@ int StreamBase::Writev(const FunctionCallbackInfo<Value>& args) {
// String chunk // String chunk
Local<String> string = chunk->ToString(env->context()).ToLocalChecked(); Local<String> string = chunk->ToString(env->context()).ToLocalChecked();
enum encoding encoding = ParseEncoding(env->isolate(), enum encoding encoding = ParseEncoding(env->isolate(),
chunks->Get(i * 2 + 1)); chunks->Get(env->context(), i * 2 + 1).ToLocalChecked());
size_t chunk_size; size_t chunk_size;
if (encoding == UTF8 && string->Length() > 65535 && if (encoding == UTF8 && string->Length() > 65535 &&
!StringBytes::Size(env->isolate(), string, encoding).To(&chunk_size)) !StringBytes::Size(env->isolate(), string, encoding).To(&chunk_size))
@ -107,7 +107,7 @@ int StreamBase::Writev(const FunctionCallbackInfo<Value>& args) {
return UV_ENOBUFS; return UV_ENOBUFS;
} else { } else {
for (size_t i = 0; i < count; i++) { for (size_t i = 0; i < count; i++) {
Local<Value> chunk = chunks->Get(i); Local<Value> chunk = chunks->Get(env->context(), i).ToLocalChecked();
bufs[i].base = Buffer::Data(chunk); bufs[i].base = Buffer::Data(chunk);
bufs[i].len = Buffer::Length(chunk); bufs[i].len = Buffer::Length(chunk);
} }
@ -120,7 +120,7 @@ int StreamBase::Writev(const FunctionCallbackInfo<Value>& args) {
offset = 0; offset = 0;
if (!all_buffers) { if (!all_buffers) {
for (size_t i = 0; i < count; i++) { for (size_t i = 0; i < count; i++) {
Local<Value> chunk = chunks->Get(i * 2); Local<Value> chunk = chunks->Get(env->context(), i * 2).ToLocalChecked();
// Write buffer // Write buffer
if (Buffer::HasInstance(chunk)) { if (Buffer::HasInstance(chunk)) {
@ -136,7 +136,7 @@ int StreamBase::Writev(const FunctionCallbackInfo<Value>& args) {
Local<String> string = chunk->ToString(env->context()).ToLocalChecked(); Local<String> string = chunk->ToString(env->context()).ToLocalChecked();
enum encoding encoding = ParseEncoding(env->isolate(), enum encoding encoding = ParseEncoding(env->isolate(),
chunks->Get(i * 2 + 1)); chunks->Get(env->context(), i * 2 + 1).ToLocalChecked());
str_size = StringBytes::Write(env->isolate(), str_size = StringBytes::Write(env->isolate(),
str_storage, str_storage,
str_size, str_size,
@ -270,7 +270,9 @@ int StreamBase::WriteString(const FunctionCallbackInfo<Value>& args) {
send_handle = reinterpret_cast<uv_stream_t*>(wrap->GetHandle()); send_handle = reinterpret_cast<uv_stream_t*>(wrap->GetHandle());
// Reference LibuvStreamWrap instance to prevent it from being garbage // Reference LibuvStreamWrap instance to prevent it from being garbage
// collected before `AfterWrite` is called. // collected before `AfterWrite` is called.
req_wrap_obj->Set(env->handle_string(), send_handle_obj); req_wrap_obj->Set(env->context(),
env->handle_string(),
send_handle_obj).FromJust();
} }
StreamWriteResult res = Write(&buf, 1, send_handle, req_wrap_obj); StreamWriteResult res = Write(&buf, 1, send_handle, req_wrap_obj);

View File

@ -67,7 +67,9 @@ void LibuvStreamWrap::Initialize(Local<Object> target,
FIXED_ONE_BYTE_STRING(env->isolate(), "ShutdownWrap"); FIXED_ONE_BYTE_STRING(env->isolate(), "ShutdownWrap");
sw->SetClassName(wrapString); sw->SetClassName(wrapString);
sw->Inherit(AsyncWrap::GetConstructorTemplate(env)); sw->Inherit(AsyncWrap::GetConstructorTemplate(env));
target->Set(wrapString, sw->GetFunction(env->context()).ToLocalChecked()); target->Set(env->context(),
wrapString,
sw->GetFunction(env->context()).ToLocalChecked()).FromJust();
env->set_shutdown_wrap_template(sw->InstanceTemplate()); env->set_shutdown_wrap_template(sw->InstanceTemplate());
Local<FunctionTemplate> ww = Local<FunctionTemplate> ww =
@ -77,8 +79,9 @@ void LibuvStreamWrap::Initialize(Local<Object> target,
FIXED_ONE_BYTE_STRING(env->isolate(), "WriteWrap"); FIXED_ONE_BYTE_STRING(env->isolate(), "WriteWrap");
ww->SetClassName(writeWrapString); ww->SetClassName(writeWrapString);
ww->Inherit(AsyncWrap::GetConstructorTemplate(env)); ww->Inherit(AsyncWrap::GetConstructorTemplate(env));
target->Set(writeWrapString, target->Set(env->context(),
ww->GetFunction(env->context()).ToLocalChecked()); writeWrapString,
ww->GetFunction(env->context()).ToLocalChecked()).FromJust();
env->set_write_wrap_template(ww->InstanceTemplate()); env->set_write_wrap_template(ww->InstanceTemplate());
NODE_DEFINE_CONSTANT(target, kReadBytesOrError); NODE_DEFINE_CONSTANT(target, kReadBytesOrError);

View File

@ -107,7 +107,9 @@ void TCPWrap::Initialize(Local<Object> target,
env->SetProtoMethod(t, "setSimultaneousAccepts", SetSimultaneousAccepts); env->SetProtoMethod(t, "setSimultaneousAccepts", SetSimultaneousAccepts);
#endif #endif
target->Set(tcpString, t->GetFunction(env->context()).ToLocalChecked()); target->Set(env->context(),
tcpString,
t->GetFunction(env->context()).ToLocalChecked()).FromJust();
env->set_tcp_constructor_template(t); env->set_tcp_constructor_template(t);
// Create FunctionTemplate for TCPConnectWrap. // Create FunctionTemplate for TCPConnectWrap.
@ -117,7 +119,9 @@ void TCPWrap::Initialize(Local<Object> target,
Local<String> wrapString = Local<String> wrapString =
FIXED_ONE_BYTE_STRING(env->isolate(), "TCPConnectWrap"); FIXED_ONE_BYTE_STRING(env->isolate(), "TCPConnectWrap");
cwt->SetClassName(wrapString); cwt->SetClassName(wrapString);
target->Set(wrapString, cwt->GetFunction(env->context()).ToLocalChecked()); target->Set(env->context(),
wrapString,
cwt->GetFunction(env->context()).ToLocalChecked()).FromJust();
// Define constants // Define constants
Local<Object> constants = Object::New(env->isolate()); Local<Object> constants = Object::New(env->isolate());
@ -349,22 +353,36 @@ Local<Object> AddressToJS(Environment* env,
a6 = reinterpret_cast<const sockaddr_in6*>(addr); a6 = reinterpret_cast<const sockaddr_in6*>(addr);
uv_inet_ntop(AF_INET6, &a6->sin6_addr, ip, sizeof ip); uv_inet_ntop(AF_INET6, &a6->sin6_addr, ip, sizeof ip);
port = ntohs(a6->sin6_port); port = ntohs(a6->sin6_port);
info->Set(env->address_string(), OneByteString(env->isolate(), ip)); info->Set(env->context(),
info->Set(env->family_string(), env->ipv6_string()); env->address_string(),
info->Set(env->port_string(), Integer::New(env->isolate(), port)); OneByteString(env->isolate(), ip)).FromJust();
info->Set(env->context(),
env->family_string(),
env->ipv6_string()).FromJust();
info->Set(env->context(),
env->port_string(),
Integer::New(env->isolate(), port)).FromJust();
break; break;
case AF_INET: case AF_INET:
a4 = reinterpret_cast<const sockaddr_in*>(addr); a4 = reinterpret_cast<const sockaddr_in*>(addr);
uv_inet_ntop(AF_INET, &a4->sin_addr, ip, sizeof ip); uv_inet_ntop(AF_INET, &a4->sin_addr, ip, sizeof ip);
port = ntohs(a4->sin_port); port = ntohs(a4->sin_port);
info->Set(env->address_string(), OneByteString(env->isolate(), ip)); info->Set(env->context(),
info->Set(env->family_string(), env->ipv4_string()); env->address_string(),
info->Set(env->port_string(), Integer::New(env->isolate(), port)); OneByteString(env->isolate(), ip)).FromJust();
info->Set(env->context(),
env->family_string(),
env->ipv4_string()).FromJust();
info->Set(env->context(),
env->port_string(),
Integer::New(env->isolate(), port)).FromJust();
break; break;
default: default:
info->Set(env->address_string(), String::Empty(env->isolate())); info->Set(env->context(),
env->address_string(),
String::Empty(env->isolate())).FromJust();
} }
return scope.Escape(info); return scope.Escape(info);

View File

@ -909,7 +909,9 @@ void TLSWrap::Initialize(Local<Object> target,
env->set_tls_wrap_constructor_function( env->set_tls_wrap_constructor_function(
t->GetFunction(env->context()).ToLocalChecked()); t->GetFunction(env->context()).ToLocalChecked());
target->Set(tlsWrapString, t->GetFunction(env->context()).ToLocalChecked()); target->Set(env->context(),
tlsWrapString,
t->GetFunction(env->context()).ToLocalChecked()).FromJust();
} }
} // namespace node } // namespace node

View File

@ -59,7 +59,9 @@ void TTYWrap::Initialize(Local<Object> target,
env->SetMethodNoSideEffect(target, "isTTY", IsTTY); env->SetMethodNoSideEffect(target, "isTTY", IsTTY);
env->SetMethodNoSideEffect(target, "guessHandleType", GuessHandleType); env->SetMethodNoSideEffect(target, "guessHandleType", GuessHandleType);
target->Set(ttyString, t->GetFunction(env->context()).ToLocalChecked()); target->Set(env->context(),
ttyString,
t->GetFunction(env->context()).ToLocalChecked()).FromJust();
env->set_tty_constructor_template(t); env->set_tty_constructor_template(t);
} }
@ -112,8 +114,8 @@ void TTYWrap::GetWindowSize(const FunctionCallbackInfo<Value>& args) {
if (err == 0) { if (err == 0) {
Local<v8::Array> a = args[0].As<Array>(); Local<v8::Array> a = args[0].As<Array>();
a->Set(0, Integer::New(env->isolate(), width)); a->Set(env->context(), 0, Integer::New(env->isolate(), width)).FromJust();
a->Set(1, Integer::New(env->isolate(), height)); a->Set(env->context(), 1, Integer::New(env->isolate(), height)).FromJust();
} }
args.GetReturnValue().Set(err); args.GetReturnValue().Set(err);

View File

@ -133,7 +133,9 @@ void UDPWrap::Initialize(Local<Object> target,
t->Inherit(HandleWrap::GetConstructorTemplate(env)); t->Inherit(HandleWrap::GetConstructorTemplate(env));
target->Set(udpString, t->GetFunction(env->context()).ToLocalChecked()); target->Set(env->context(),
udpString,
t->GetFunction(env->context()).ToLocalChecked()).FromJust();
env->set_udp_constructor_function( env->set_udp_constructor_function(
t->GetFunction(env->context()).ToLocalChecked()); t->GetFunction(env->context()).ToLocalChecked());
@ -144,8 +146,9 @@ void UDPWrap::Initialize(Local<Object> target,
Local<String> sendWrapString = Local<String> sendWrapString =
FIXED_ONE_BYTE_STRING(env->isolate(), "SendWrap"); FIXED_ONE_BYTE_STRING(env->isolate(), "SendWrap");
swt->SetClassName(sendWrapString); swt->SetClassName(sendWrapString);
target->Set(sendWrapString, target->Set(env->context(),
swt->GetFunction(env->context()).ToLocalChecked()); sendWrapString,
swt->GetFunction(env->context()).ToLocalChecked()).FromJust();
} }
@ -373,7 +376,7 @@ void UDPWrap::DoSend(const FunctionCallbackInfo<Value>& args, int family) {
// construct uv_buf_t array // construct uv_buf_t array
for (size_t i = 0; i < count; i++) { for (size_t i = 0; i < count; i++) {
Local<Value> chunk = chunks->Get(i); Local<Value> chunk = chunks->Get(env->context(), i).ToLocalChecked();
size_t length = Buffer::Length(chunk); size_t length = Buffer::Length(chunk);

View File

@ -63,10 +63,11 @@ void Initialize(Local<Object> target,
Local<Context> context) { Local<Context> context) {
Environment* env = Environment::GetCurrent(context); Environment* env = Environment::GetCurrent(context);
Isolate* isolate = env->isolate(); Isolate* isolate = env->isolate();
target->Set(FIXED_ONE_BYTE_STRING(isolate, "errname"), target->Set(env->context(),
FIXED_ONE_BYTE_STRING(isolate, "errname"),
env->NewFunctionTemplate(ErrName) env->NewFunctionTemplate(ErrName)
->GetFunction(env->context()) ->GetFunction(env->context())
.ToLocalChecked()); .ToLocalChecked()).FromJust();
#define V(name, _) NODE_DEFINE_CONSTANT(target, UV_##name); #define V(name, _) NODE_DEFINE_CONSTANT(target, UV_##name);
UV_ERRNO_MAP(V) UV_ERRNO_MAP(V)
@ -76,8 +77,8 @@ void Initialize(Local<Object> target,
#define V(name, msg) do { \ #define V(name, msg) do { \
Local<Array> arr = Array::New(isolate, 2); \ Local<Array> arr = Array::New(isolate, 2); \
arr->Set(0, OneByteString(isolate, #name)); \ arr->Set(env->context(), 0, OneByteString(isolate, #name)).FromJust(); \
arr->Set(1, OneByteString(isolate, msg)); \ arr->Set(env->context(), 1, OneByteString(isolate, msg)).FromJust(); \
err_map->Set(context, \ err_map->Set(context, \
Integer::New(isolate, UV_##name), \ Integer::New(isolate, UV_##name), \
arr).ToLocalChecked(); \ arr).ToLocalChecked(); \