src: pass Isolate to node::Utf8Value constructor
Initial attempt to remove all uses of Isolate::GetCurrent(). Still exists a few locations, but this works out a heavy usage. PR-URL: https://github.com/iojs/io.js/pull/244 Reviewed-by: Ben Noordhuis <info@bnoordhuis.nl>
This commit is contained in:
parent
d553386623
commit
cbf76c1f2f
@ -884,7 +884,7 @@ static void Query(const FunctionCallbackInfo<Value>& args) {
|
||||
Local<String> string = args[1].As<String>();
|
||||
Wrap* wrap = new Wrap(env, req_wrap_obj);
|
||||
|
||||
node::Utf8Value name(string);
|
||||
node::Utf8Value name(env->isolate(), string);
|
||||
int err = wrap->Send(*name);
|
||||
if (err)
|
||||
delete wrap;
|
||||
@ -1023,7 +1023,7 @@ void AfterGetNameInfo(uv_getnameinfo_t* req,
|
||||
|
||||
|
||||
static void IsIP(const FunctionCallbackInfo<Value>& args) {
|
||||
node::Utf8Value ip(args[0]);
|
||||
node::Utf8Value ip(args.GetIsolate(), args[0]);
|
||||
char address_buffer[sizeof(struct in6_addr)];
|
||||
|
||||
int rc = 0;
|
||||
@ -1043,7 +1043,7 @@ static void GetAddrInfo(const FunctionCallbackInfo<Value>& args) {
|
||||
CHECK(args[1]->IsString());
|
||||
CHECK(args[2]->IsInt32());
|
||||
Local<Object> req_wrap_obj = args[0].As<Object>();
|
||||
node::Utf8Value hostname(args[1]);
|
||||
node::Utf8Value hostname(env->isolate(), args[1]);
|
||||
|
||||
int32_t flags = (args[3]->IsInt32()) ? args[3]->Int32Value() : 0;
|
||||
int family;
|
||||
@ -1092,7 +1092,7 @@ static void GetNameInfo(const FunctionCallbackInfo<Value>& args) {
|
||||
CHECK(args[1]->IsString());
|
||||
CHECK(args[2]->IsUint32());
|
||||
Local<Object> req_wrap_obj = args[0].As<Object>();
|
||||
node::Utf8Value ip(args[1]);
|
||||
node::Utf8Value ip(env->isolate(), args[1]);
|
||||
const unsigned port = args[2]->Uint32Value();
|
||||
struct sockaddr_storage addr;
|
||||
|
||||
@ -1171,7 +1171,7 @@ static void SetServers(const FunctionCallbackInfo<Value>& args) {
|
||||
CHECK(elm->Get(1)->IsString());
|
||||
|
||||
int fam = elm->Get(0)->Int32Value();
|
||||
node::Utf8Value ip(elm->Get(1));
|
||||
node::Utf8Value ip(env->isolate(), elm->Get(1));
|
||||
|
||||
ares_addr_node* cur = &servers[i];
|
||||
|
||||
|
@ -110,7 +110,7 @@ void FSEventWrap::Start(const FunctionCallbackInfo<Value>& args) {
|
||||
return env->ThrowTypeError("Bad arguments");
|
||||
}
|
||||
|
||||
node::Utf8Value path(args[0]);
|
||||
node::Utf8Value path(env->isolate(), args[0]);
|
||||
|
||||
unsigned int flags = 0;
|
||||
if (args[2]->IsTrue())
|
||||
|
46
src/node.cc
46
src/node.cc
@ -1177,7 +1177,7 @@ enum encoding ParseEncoding(Isolate* isolate,
|
||||
if (!encoding_v->IsString())
|
||||
return _default;
|
||||
|
||||
node::Utf8Value encoding(encoding_v);
|
||||
node::Utf8Value encoding(isolate, encoding_v);
|
||||
|
||||
if (strcasecmp(*encoding, "utf8") == 0) {
|
||||
return UTF8;
|
||||
@ -1275,11 +1275,11 @@ void AppendExceptionLine(Environment* env,
|
||||
char arrow[1024];
|
||||
|
||||
// Print (filename):(line number): (message).
|
||||
node::Utf8Value filename(message->GetScriptResourceName());
|
||||
node::Utf8Value filename(env->isolate(), message->GetScriptResourceName());
|
||||
const char* filename_string = *filename;
|
||||
int linenum = message->GetLineNumber();
|
||||
// Print line of source code.
|
||||
node::Utf8Value sourceline(message->GetSourceLine());
|
||||
node::Utf8Value sourceline(env->isolate(), message->GetSourceLine());
|
||||
const char* sourceline_string = *sourceline;
|
||||
|
||||
// Because of how node modules work, all scripts are wrapped with a
|
||||
@ -1378,7 +1378,7 @@ static void ReportException(Environment* env,
|
||||
else
|
||||
trace_value = er->ToObject(env->isolate())->Get(env->stack_string());
|
||||
|
||||
node::Utf8Value trace(trace_value);
|
||||
node::Utf8Value trace(env->isolate(), trace_value);
|
||||
|
||||
// range errors have a trace member set to undefined
|
||||
if (trace.length() > 0 && !trace_value->IsUndefined()) {
|
||||
@ -1401,11 +1401,11 @@ static void ReportException(Environment* env,
|
||||
name.IsEmpty() ||
|
||||
name->IsUndefined()) {
|
||||
// Not an error object. Just print as-is.
|
||||
node::Utf8Value message(er);
|
||||
node::Utf8Value message(env->isolate(), er);
|
||||
fprintf(stderr, "%s\n", *message);
|
||||
} else {
|
||||
node::Utf8Value name_string(name);
|
||||
node::Utf8Value message_string(message);
|
||||
node::Utf8Value name_string(env->isolate(), name);
|
||||
node::Utf8Value message_string(env->isolate(), message);
|
||||
fprintf(stderr, "%s: %s\n", *name_string, *message_string);
|
||||
}
|
||||
}
|
||||
@ -1503,7 +1503,7 @@ static void Chdir(const FunctionCallbackInfo<Value>& args) {
|
||||
return env->ThrowError("Bad argument.");
|
||||
}
|
||||
|
||||
node::Utf8Value path(args[0]);
|
||||
node::Utf8Value path(args.GetIsolate(), args[0]);
|
||||
int err = uv_chdir(*path);
|
||||
if (err) {
|
||||
return env->ThrowUVException(err, "uv_chdir");
|
||||
@ -1549,7 +1549,7 @@ static void Umask(const FunctionCallbackInfo<Value>& args) {
|
||||
oct = args[0]->Uint32Value();
|
||||
} else {
|
||||
oct = 0;
|
||||
node::Utf8Value str(args[0]);
|
||||
node::Utf8Value str(env->isolate(), args[0]);
|
||||
|
||||
// Parse the octal string.
|
||||
for (size_t i = 0; i < str.length(); i++) {
|
||||
@ -1656,7 +1656,8 @@ static uid_t uid_by_name(Handle<Value> value) {
|
||||
if (value->IsUint32()) {
|
||||
return static_cast<uid_t>(value->Uint32Value());
|
||||
} else {
|
||||
node::Utf8Value name(value);
|
||||
// TODO(trevnorris): Fix to not use GetCurrent().
|
||||
node::Utf8Value name(Isolate::GetCurrent(), value);
|
||||
return uid_by_name(*name);
|
||||
}
|
||||
}
|
||||
@ -1666,7 +1667,8 @@ static gid_t gid_by_name(Handle<Value> value) {
|
||||
if (value->IsUint32()) {
|
||||
return static_cast<gid_t>(value->Uint32Value());
|
||||
} else {
|
||||
node::Utf8Value name(value);
|
||||
// TODO(trevnorris): Fix to not use GetCurrent().
|
||||
node::Utf8Value name(Isolate::GetCurrent(), value);
|
||||
return gid_by_name(*name);
|
||||
}
|
||||
}
|
||||
@ -1802,7 +1804,7 @@ static void InitGroups(const FunctionCallbackInfo<Value>& args) {
|
||||
return env->ThrowTypeError("argument 2 must be a number or a string");
|
||||
}
|
||||
|
||||
node::Utf8Value arg0(args[0]);
|
||||
node::Utf8Value arg0(env->isolate(), args[0]);
|
||||
gid_t extra_group;
|
||||
bool must_free;
|
||||
char* user;
|
||||
@ -1989,7 +1991,7 @@ void DLOpen(const FunctionCallbackInfo<Value>& args) {
|
||||
}
|
||||
|
||||
Local<Object> module = args[0]->ToObject(env->isolate()); // Cast
|
||||
node::Utf8Value filename(args[1]); // Cast
|
||||
node::Utf8Value filename(env->isolate(), args[1]); // Cast
|
||||
const bool is_dlopen_error = uv_dlopen(*filename, &lib);
|
||||
|
||||
// Objects containing v14 or later modules will have registered themselves
|
||||
@ -2124,7 +2126,7 @@ static void Binding(const FunctionCallbackInfo<Value>& args) {
|
||||
Environment* env = Environment::GetCurrent(args);
|
||||
|
||||
Local<String> module = args[0]->ToString(env->isolate());
|
||||
node::Utf8Value module_v(module);
|
||||
node::Utf8Value module_v(env->isolate(), module);
|
||||
|
||||
Local<Object> cache = env->binding_cache_object();
|
||||
Local<Object> exports;
|
||||
@ -2184,7 +2186,7 @@ static void LinkedBinding(const FunctionCallbackInfo<Value>& args) {
|
||||
if (exports_v->IsObject())
|
||||
return args.GetReturnValue().Set(exports_v.As<Object>());
|
||||
|
||||
node::Utf8Value module_v(module);
|
||||
node::Utf8Value module_v(env->isolate(), module);
|
||||
node_module* mod = get_linked_module(*module_v);
|
||||
|
||||
if (mod == nullptr) {
|
||||
@ -2229,7 +2231,7 @@ static void ProcessTitleSetter(Local<String> property,
|
||||
const PropertyCallbackInfo<void>& info) {
|
||||
Environment* env = Environment::GetCurrent(info.GetIsolate());
|
||||
HandleScope scope(env->isolate());
|
||||
node::Utf8Value title(value);
|
||||
node::Utf8Value title(env->isolate(), value);
|
||||
// TODO(piscisaureus): protect with a lock
|
||||
uv_set_process_title(*title);
|
||||
}
|
||||
@ -2240,7 +2242,7 @@ static void EnvGetter(Local<String> property,
|
||||
Environment* env = Environment::GetCurrent(info.GetIsolate());
|
||||
HandleScope scope(env->isolate());
|
||||
#ifdef __POSIX__
|
||||
node::Utf8Value key(property);
|
||||
node::Utf8Value key(env->isolate(), property);
|
||||
const char* val = getenv(*key);
|
||||
if (val) {
|
||||
return info.GetReturnValue().Set(String::NewFromUtf8(env->isolate(), val));
|
||||
@ -2273,8 +2275,8 @@ static void EnvSetter(Local<String> property,
|
||||
Environment* env = Environment::GetCurrent(info.GetIsolate());
|
||||
HandleScope scope(env->isolate());
|
||||
#ifdef __POSIX__
|
||||
node::Utf8Value key(property);
|
||||
node::Utf8Value val(value);
|
||||
node::Utf8Value key(env->isolate(), property);
|
||||
node::Utf8Value val(env->isolate(), value);
|
||||
setenv(*key, *val, 1);
|
||||
#else // _WIN32
|
||||
String::Value key(property);
|
||||
@ -2296,7 +2298,7 @@ static void EnvQuery(Local<String> property,
|
||||
HandleScope scope(env->isolate());
|
||||
int32_t rc = -1; // Not found unless proven otherwise.
|
||||
#ifdef __POSIX__
|
||||
node::Utf8Value key(property);
|
||||
node::Utf8Value key(env->isolate(), property);
|
||||
if (getenv(*key))
|
||||
rc = 0;
|
||||
#else // _WIN32
|
||||
@ -2324,7 +2326,7 @@ static void EnvDeleter(Local<String> property,
|
||||
HandleScope scope(env->isolate());
|
||||
bool rc = true;
|
||||
#ifdef __POSIX__
|
||||
node::Utf8Value key(property);
|
||||
node::Utf8Value key(env->isolate(), property);
|
||||
rc = getenv(*key) != nullptr;
|
||||
if (rc)
|
||||
unsetenv(*key);
|
||||
@ -2783,7 +2785,7 @@ static void SignalExit(int signo) {
|
||||
static void RawDebug(const FunctionCallbackInfo<Value>& args) {
|
||||
CHECK(args.Length() == 1 && args[0]->IsString() &&
|
||||
"must be called with a single string");
|
||||
node::Utf8Value message(args[0]);
|
||||
node::Utf8Value message(args.GetIsolate(), args[0]);
|
||||
fprintf(stderr, "%s\n", *message);
|
||||
fflush(stderr);
|
||||
}
|
||||
|
@ -386,7 +386,7 @@ void Fill(const FunctionCallbackInfo<Value>& args) {
|
||||
return;
|
||||
}
|
||||
|
||||
node::Utf8Value str(args[1]);
|
||||
node::Utf8Value str(args.GetIsolate(), args[1]);
|
||||
size_t str_length = str.length();
|
||||
size_t in_there = str_length;
|
||||
char* ptr = obj_data + start + str_length;
|
||||
|
@ -307,7 +307,7 @@ void SecureContext::Init(const FunctionCallbackInfo<Value>& args) {
|
||||
OPENSSL_CONST SSL_METHOD *method = SSLv23_method();
|
||||
|
||||
if (args.Length() == 1 && args[0]->IsString()) {
|
||||
const node::Utf8Value sslmethod(args[0]);
|
||||
const node::Utf8Value sslmethod(env->isolate(), args[0]);
|
||||
|
||||
if (strcmp(*sslmethod, "SSLv2_method") == 0) {
|
||||
#ifndef OPENSSL_NO_SSL2
|
||||
@ -400,7 +400,7 @@ static BIO* LoadBIO(Environment* env, Handle<Value> v) {
|
||||
int r = -1;
|
||||
|
||||
if (v->IsString()) {
|
||||
const node::Utf8Value s(v);
|
||||
const node::Utf8Value s(env->isolate(), v);
|
||||
r = BIO_write(bio, *s, s.length());
|
||||
} else if (Buffer::HasInstance(v)) {
|
||||
char* buffer_data = Buffer::Data(v);
|
||||
@ -454,7 +454,7 @@ void SecureContext::SetKey(const FunctionCallbackInfo<Value>& args) {
|
||||
if (!bio)
|
||||
return;
|
||||
|
||||
node::Utf8Value passphrase(args[1]);
|
||||
node::Utf8Value passphrase(env->isolate(), args[1]);
|
||||
|
||||
EVP_PKEY* key = PEM_read_bio_PrivateKey(bio,
|
||||
nullptr,
|
||||
@ -719,7 +719,7 @@ void SecureContext::SetCiphers(const FunctionCallbackInfo<Value>& args) {
|
||||
return sc->env()->ThrowTypeError("Bad parameter");
|
||||
}
|
||||
|
||||
const node::Utf8Value ciphers(args[0]);
|
||||
const node::Utf8Value ciphers(args.GetIsolate(), args[0]);
|
||||
SSL_CTX_set_cipher_list(sc->ctx_, *ciphers);
|
||||
}
|
||||
|
||||
@ -731,7 +731,7 @@ void SecureContext::SetECDHCurve(const FunctionCallbackInfo<Value>& args) {
|
||||
if (args.Length() != 1 || !args[0]->IsString())
|
||||
return env->ThrowTypeError("First argument should be a string");
|
||||
|
||||
node::Utf8Value curve(args[0]);
|
||||
node::Utf8Value curve(env->isolate(), args[0]);
|
||||
|
||||
int nid = OBJ_sn2nid(*curve);
|
||||
|
||||
@ -798,7 +798,7 @@ void SecureContext::SetSessionIdContext(
|
||||
return sc->env()->ThrowTypeError("Bad parameter");
|
||||
}
|
||||
|
||||
const node::Utf8Value sessionIdContext(args[0]);
|
||||
const node::Utf8Value sessionIdContext(args.GetIsolate(), args[0]);
|
||||
const unsigned char* sid_ctx =
|
||||
reinterpret_cast<const unsigned char*>(*sessionIdContext);
|
||||
unsigned int sid_ctx_len = sessionIdContext.length();
|
||||
@ -2190,7 +2190,7 @@ void Connection::New(const FunctionCallbackInfo<Value>& args) {
|
||||
if (is_server) {
|
||||
SSL_CTX_set_tlsext_servername_callback(sc->ctx_, SelectSNIContextCallback_);
|
||||
} else if (args[2]->IsString()) {
|
||||
const node::Utf8Value servername(args[2]);
|
||||
const node::Utf8Value servername(env->isolate(), args[2]);
|
||||
SSL_set_tlsext_host_name(conn->ssl_, *servername);
|
||||
}
|
||||
#endif
|
||||
@ -2591,7 +2591,7 @@ void CipherBase::Init(const FunctionCallbackInfo<Value>& args) {
|
||||
return cipher->env()->ThrowError("Must give cipher-type, key");
|
||||
}
|
||||
|
||||
const node::Utf8Value cipher_type(args[0]);
|
||||
const node::Utf8Value cipher_type(args.GetIsolate(), args[0]);
|
||||
const char* key_buf = Buffer::Data(args[1]);
|
||||
ssize_t key_buf_len = Buffer::Length(args[1]);
|
||||
cipher->Init(*cipher_type, key_buf, key_buf_len);
|
||||
@ -2645,7 +2645,7 @@ void CipherBase::InitIv(const FunctionCallbackInfo<Value>& args) {
|
||||
ASSERT_IS_BUFFER(args[1]);
|
||||
ASSERT_IS_BUFFER(args[2]);
|
||||
|
||||
const node::Utf8Value cipher_type(args[0]);
|
||||
const node::Utf8Value cipher_type(env->isolate(), args[0]);
|
||||
ssize_t key_len = Buffer::Length(args[1]);
|
||||
const char* key_buf = Buffer::Data(args[1]);
|
||||
ssize_t iv_len = Buffer::Length(args[2]);
|
||||
@ -2936,7 +2936,7 @@ void Hmac::HmacInit(const FunctionCallbackInfo<Value>& args) {
|
||||
|
||||
ASSERT_IS_BUFFER(args[1]);
|
||||
|
||||
const node::Utf8Value hash_type(args[0]);
|
||||
const node::Utf8Value hash_type(env->isolate(), args[0]);
|
||||
const char* buffer_data = Buffer::Data(args[1]);
|
||||
size_t buffer_length = Buffer::Length(args[1]);
|
||||
hmac->HmacInit(*hash_type, buffer_data, buffer_length);
|
||||
@ -3046,7 +3046,7 @@ void Hash::New(const FunctionCallbackInfo<Value>& args) {
|
||||
return env->ThrowError("Must give hashtype string as argument");
|
||||
}
|
||||
|
||||
const node::Utf8Value hash_type(args[0]);
|
||||
const node::Utf8Value hash_type(env->isolate(), args[0]);
|
||||
|
||||
Hash* hash = new Hash(env, args.This());
|
||||
if (!hash->HashInit(*hash_type)) {
|
||||
@ -3222,7 +3222,7 @@ void Sign::SignInit(const FunctionCallbackInfo<Value>& args) {
|
||||
return sign->env()->ThrowError("Must give signtype string as argument");
|
||||
}
|
||||
|
||||
const node::Utf8Value sign_type(args[0]);
|
||||
const node::Utf8Value sign_type(args.GetIsolate(), args[0]);
|
||||
sign->CheckThrow(sign->SignInit(*sign_type));
|
||||
}
|
||||
|
||||
@ -3328,7 +3328,7 @@ void Sign::SignFinal(const FunctionCallbackInfo<Value>& args) {
|
||||
BUFFER);
|
||||
}
|
||||
|
||||
node::Utf8Value passphrase(args[2]);
|
||||
node::Utf8Value passphrase(env->isolate(), args[2]);
|
||||
|
||||
ASSERT_IS_BUFFER(args[0]);
|
||||
size_t buf_len = Buffer::Length(args[0]);
|
||||
@ -3401,7 +3401,7 @@ void Verify::VerifyInit(const FunctionCallbackInfo<Value>& args) {
|
||||
return verify->env()->ThrowError("Must give verifytype string as argument");
|
||||
}
|
||||
|
||||
const node::Utf8Value verify_type(args[0]);
|
||||
const node::Utf8Value verify_type(args.GetIsolate(), args[0]);
|
||||
verify->CheckThrow(verify->VerifyInit(*verify_type));
|
||||
}
|
||||
|
||||
@ -3800,7 +3800,7 @@ void DiffieHellman::DiffieHellmanGroup(
|
||||
|
||||
bool initialized = false;
|
||||
|
||||
const node::Utf8Value group_name(args[0]);
|
||||
const node::Utf8Value group_name(env->isolate(), args[0]);
|
||||
for (unsigned int i = 0; i < ARRAY_SIZE(modp_groups); ++i) {
|
||||
const modp_group* it = modp_groups + i;
|
||||
|
||||
@ -4113,7 +4113,7 @@ void ECDH::New(const FunctionCallbackInfo<Value>& args) {
|
||||
|
||||
// TODO(indutny): Support raw curves?
|
||||
CHECK(args[0]->IsString());
|
||||
node::Utf8Value curve(args[0]);
|
||||
node::Utf8Value curve(env->isolate(), args[0]);
|
||||
|
||||
int nid = OBJ_sn2nid(*curve);
|
||||
if (nid == NID_undef)
|
||||
@ -4513,7 +4513,7 @@ void PBKDF2(const FunctionCallbackInfo<Value>& args) {
|
||||
}
|
||||
|
||||
if (args[4]->IsString()) {
|
||||
node::Utf8Value digest_name(args[4]);
|
||||
node::Utf8Value digest_name(env->isolate(), args[4]);
|
||||
digest = EVP_get_digestbyname(*digest_name);
|
||||
if (digest == nullptr) {
|
||||
type_error = "Bad digest name";
|
||||
@ -5014,7 +5014,7 @@ void SetEngine(const FunctionCallbackInfo<Value>& args) {
|
||||
ClearErrorOnReturn clear_error_on_return;
|
||||
(void) &clear_error_on_return; // Silence compiler warning.
|
||||
|
||||
const node::Utf8Value engine_id(args[0]);
|
||||
const node::Utf8Value engine_id(env->isolate(), args[0]);
|
||||
ENGINE* engine = ENGINE_by_id(*engine_id);
|
||||
|
||||
// Engine not found, try loading dynamically
|
||||
|
@ -76,8 +76,8 @@ using v8::Value;
|
||||
return env->ThrowError( \
|
||||
"expected object for " #obj " to contain string member " #member); \
|
||||
} \
|
||||
node::Utf8Value _##member(obj->Get(OneByteString(env->isolate(), \
|
||||
#member))); \
|
||||
node::Utf8Value _##member(env->isolate(), \
|
||||
obj->Get(OneByteString(env->isolate(), #member))); \
|
||||
if ((*(const char **)valp = *_##member) == nullptr) \
|
||||
*(const char **)valp = "<unknown>";
|
||||
|
||||
@ -215,7 +215,7 @@ void DTRACE_HTTP_SERVER_REQUEST(const FunctionCallbackInfo<Value>& args) {
|
||||
}
|
||||
|
||||
Local<Value> strfwdfor = headers->Get(env->x_forwarded_string());
|
||||
node::Utf8Value fwdfor(strfwdfor);
|
||||
node::Utf8Value fwdfor(env->isolate(), strfwdfor);
|
||||
|
||||
if (!strfwdfor->IsString() || (req.forwardedFor = *fwdfor) == nullptr)
|
||||
req.forwardedFor = const_cast<char*>("");
|
||||
|
@ -329,7 +329,7 @@ static void Access(const FunctionCallbackInfo<Value>& args) {
|
||||
if (!args[1]->IsInt32())
|
||||
return TYPE_ERROR("mode must be an integer");
|
||||
|
||||
node::Utf8Value path(args[0]);
|
||||
node::Utf8Value path(env->isolate(), args[0]);
|
||||
int mode = static_cast<int>(args[1]->Int32Value());
|
||||
|
||||
if (args[2]->IsObject()) {
|
||||
@ -462,7 +462,7 @@ static void Stat(const FunctionCallbackInfo<Value>& args) {
|
||||
if (!args[0]->IsString())
|
||||
return TYPE_ERROR("path must be a string");
|
||||
|
||||
node::Utf8Value path(args[0]);
|
||||
node::Utf8Value path(env->isolate(), args[0]);
|
||||
|
||||
if (args[1]->IsObject()) {
|
||||
ASYNC_CALL(stat, args[1], *path)
|
||||
@ -481,7 +481,7 @@ static void LStat(const FunctionCallbackInfo<Value>& args) {
|
||||
if (!args[0]->IsString())
|
||||
return TYPE_ERROR("path must be a string");
|
||||
|
||||
node::Utf8Value path(args[0]);
|
||||
node::Utf8Value path(env->isolate(), args[0]);
|
||||
|
||||
if (args[1]->IsObject()) {
|
||||
ASYNC_CALL(lstat, args[1], *path)
|
||||
@ -523,12 +523,12 @@ static void Symlink(const FunctionCallbackInfo<Value>& args) {
|
||||
if (!args[1]->IsString())
|
||||
return TYPE_ERROR("src path must be a string");
|
||||
|
||||
node::Utf8Value dest(args[0]);
|
||||
node::Utf8Value path(args[1]);
|
||||
node::Utf8Value dest(env->isolate(), args[0]);
|
||||
node::Utf8Value path(env->isolate(), args[1]);
|
||||
int flags = 0;
|
||||
|
||||
if (args[2]->IsString()) {
|
||||
node::Utf8Value mode(args[2]);
|
||||
node::Utf8Value mode(env->isolate(), args[2]);
|
||||
if (strcmp(*mode, "dir") == 0) {
|
||||
flags |= UV_FS_SYMLINK_DIR;
|
||||
} else if (strcmp(*mode, "junction") == 0) {
|
||||
@ -558,8 +558,8 @@ static void Link(const FunctionCallbackInfo<Value>& args) {
|
||||
if (!args[1]->IsString())
|
||||
return TYPE_ERROR("src path must be a string");
|
||||
|
||||
node::Utf8Value orig_path(args[0]);
|
||||
node::Utf8Value new_path(args[1]);
|
||||
node::Utf8Value orig_path(env->isolate(), args[0]);
|
||||
node::Utf8Value new_path(env->isolate(), args[1]);
|
||||
|
||||
if (args[2]->IsObject()) {
|
||||
ASYNC_DEST_CALL(link, args[2], *new_path, *orig_path, *new_path)
|
||||
@ -576,7 +576,7 @@ static void ReadLink(const FunctionCallbackInfo<Value>& args) {
|
||||
if (!args[0]->IsString())
|
||||
return TYPE_ERROR("path must be a string");
|
||||
|
||||
node::Utf8Value path(args[0]);
|
||||
node::Utf8Value path(env->isolate(), args[0]);
|
||||
|
||||
if (args[1]->IsObject()) {
|
||||
ASYNC_CALL(readlink, args[1], *path)
|
||||
@ -601,8 +601,8 @@ static void Rename(const FunctionCallbackInfo<Value>& args) {
|
||||
if (!args[1]->IsString())
|
||||
return TYPE_ERROR("new path must be a string");
|
||||
|
||||
node::Utf8Value old_path(args[0]);
|
||||
node::Utf8Value new_path(args[1]);
|
||||
node::Utf8Value old_path(env->isolate(), args[0]);
|
||||
node::Utf8Value new_path(env->isolate(), args[1]);
|
||||
|
||||
if (args[2]->IsObject()) {
|
||||
ASYNC_DEST_CALL(rename, args[2], *new_path, *old_path, *new_path)
|
||||
@ -670,7 +670,7 @@ static void Unlink(const FunctionCallbackInfo<Value>& args) {
|
||||
if (!args[0]->IsString())
|
||||
return TYPE_ERROR("path must be a string");
|
||||
|
||||
node::Utf8Value path(args[0]);
|
||||
node::Utf8Value path(env->isolate(), args[0]);
|
||||
|
||||
if (args[1]->IsObject()) {
|
||||
ASYNC_CALL(unlink, args[1], *path)
|
||||
@ -687,7 +687,7 @@ static void RMDir(const FunctionCallbackInfo<Value>& args) {
|
||||
if (!args[0]->IsString())
|
||||
return TYPE_ERROR("path must be a string");
|
||||
|
||||
node::Utf8Value path(args[0]);
|
||||
node::Utf8Value path(env->isolate(), args[0]);
|
||||
|
||||
if (args[1]->IsObject()) {
|
||||
ASYNC_CALL(rmdir, args[1], *path)
|
||||
@ -703,7 +703,7 @@ static void MKDir(const FunctionCallbackInfo<Value>& args) {
|
||||
return THROW_BAD_ARGS;
|
||||
}
|
||||
|
||||
node::Utf8Value path(args[0]);
|
||||
node::Utf8Value path(env->isolate(), args[0]);
|
||||
int mode = static_cast<int>(args[1]->Int32Value());
|
||||
|
||||
if (args[2]->IsObject()) {
|
||||
@ -721,7 +721,7 @@ static void ReadDir(const FunctionCallbackInfo<Value>& args) {
|
||||
if (!args[0]->IsString())
|
||||
return TYPE_ERROR("path must be a string");
|
||||
|
||||
node::Utf8Value path(args[0]);
|
||||
node::Utf8Value path(env->isolate(), args[0]);
|
||||
|
||||
if (args[1]->IsObject()) {
|
||||
ASYNC_CALL(scandir, args[1], *path, 0 /*flags*/)
|
||||
@ -767,7 +767,7 @@ static void Open(const FunctionCallbackInfo<Value>& args) {
|
||||
if (!args[2]->IsInt32())
|
||||
return TYPE_ERROR("mode must be an int");
|
||||
|
||||
node::Utf8Value path(args[0]);
|
||||
node::Utf8Value path(env->isolate(), args[0]);
|
||||
int flags = args[1]->Int32Value();
|
||||
int mode = static_cast<int>(args[2]->Int32Value());
|
||||
|
||||
@ -966,7 +966,7 @@ static void Chmod(const FunctionCallbackInfo<Value>& args) {
|
||||
if (args.Length() < 2 || !args[0]->IsString() || !args[1]->IsInt32()) {
|
||||
return THROW_BAD_ARGS;
|
||||
}
|
||||
node::Utf8Value path(args[0]);
|
||||
node::Utf8Value path(env->isolate(), args[0]);
|
||||
int mode = static_cast<int>(args[1]->Int32Value());
|
||||
|
||||
if (args[2]->IsObject()) {
|
||||
@ -1017,7 +1017,7 @@ static void Chown(const FunctionCallbackInfo<Value>& args) {
|
||||
if (!args[2]->IsUint32())
|
||||
return TYPE_ERROR("gid must be an unsigned int");
|
||||
|
||||
node::Utf8Value path(args[0]);
|
||||
node::Utf8Value path(env->isolate(), args[0]);
|
||||
uv_uid_t uid = static_cast<uv_uid_t>(args[1]->Uint32Value());
|
||||
uv_gid_t gid = static_cast<uv_gid_t>(args[2]->Uint32Value());
|
||||
|
||||
@ -1078,7 +1078,7 @@ static void UTimes(const FunctionCallbackInfo<Value>& args) {
|
||||
if (!args[2]->IsNumber())
|
||||
return TYPE_ERROR("mtime must be a number");
|
||||
|
||||
const node::Utf8Value path(args[0]);
|
||||
const node::Utf8Value path(env->isolate(), args[0]);
|
||||
const double atime = static_cast<double>(args[1]->NumberValue());
|
||||
const double mtime = static_cast<double>(args[2]->NumberValue());
|
||||
|
||||
|
@ -107,7 +107,7 @@ void StatWatcher::Start(const FunctionCallbackInfo<Value>& args) {
|
||||
CHECK_EQ(args.Length(), 3);
|
||||
|
||||
StatWatcher* wrap = Unwrap<StatWatcher>(args.Holder());
|
||||
node::Utf8Value path(args[0]);
|
||||
node::Utf8Value path(args.GetIsolate(), args[0]);
|
||||
const bool persistent = args[1]->BooleanValue();
|
||||
const uint32_t interval = args[2]->Uint32Value();
|
||||
|
||||
|
@ -177,7 +177,7 @@ PipeWrap::PipeWrap(Environment* env,
|
||||
|
||||
void PipeWrap::Bind(const FunctionCallbackInfo<Value>& args) {
|
||||
PipeWrap* wrap = Unwrap<PipeWrap>(args.Holder());
|
||||
node::Utf8Value name(args[0]);
|
||||
node::Utf8Value name(args.GetIsolate(), args[0]);
|
||||
int err = uv_pipe_bind(&wrap->handle_, *name);
|
||||
args.GetReturnValue().Set(err);
|
||||
}
|
||||
@ -300,7 +300,7 @@ void PipeWrap::Connect(const FunctionCallbackInfo<Value>& args) {
|
||||
CHECK(args[1]->IsString());
|
||||
|
||||
Local<Object> req_wrap_obj = args[0].As<Object>();
|
||||
node::Utf8Value name(args[1]);
|
||||
node::Utf8Value name(env->isolate(), args[1]);
|
||||
|
||||
PipeConnectWrap* req_wrap = new PipeConnectWrap(env, req_wrap_obj);
|
||||
uv_pipe_connect(&req_wrap->req_,
|
||||
|
@ -167,7 +167,8 @@ class ProcessWrap : public HandleWrap {
|
||||
|
||||
// options.file
|
||||
Local<Value> file_v = js_options->Get(env->file_string());
|
||||
node::Utf8Value file(file_v->IsString() ? file_v : Local<Value>());
|
||||
node::Utf8Value file(env->isolate(),
|
||||
file_v->IsString() ? file_v : Local<Value>());
|
||||
if (file.length() > 0) {
|
||||
options.file = *file;
|
||||
} else {
|
||||
@ -182,7 +183,7 @@ class ProcessWrap : public HandleWrap {
|
||||
// Heap allocate to detect errors. +1 is for nullptr.
|
||||
options.args = new char*[argc + 1];
|
||||
for (int i = 0; i < argc; i++) {
|
||||
node::Utf8Value arg(js_argv->Get(i));
|
||||
node::Utf8Value arg(env->isolate(), js_argv->Get(i));
|
||||
options.args[i] = strdup(*arg);
|
||||
}
|
||||
options.args[argc] = nullptr;
|
||||
@ -190,7 +191,8 @@ class ProcessWrap : public HandleWrap {
|
||||
|
||||
// options.cwd
|
||||
Local<Value> cwd_v = js_options->Get(env->cwd_string());
|
||||
node::Utf8Value cwd(cwd_v->IsString() ? cwd_v : Local<Value>());
|
||||
node::Utf8Value cwd(env->isolate(),
|
||||
cwd_v->IsString() ? cwd_v : Local<Value>());
|
||||
if (cwd.length() > 0) {
|
||||
options.cwd = *cwd;
|
||||
}
|
||||
@ -198,11 +200,11 @@ class ProcessWrap : public HandleWrap {
|
||||
// options.env
|
||||
Local<Value> env_v = js_options->Get(env->env_pairs_string());
|
||||
if (!env_v.IsEmpty() && env_v->IsArray()) {
|
||||
Local<Array> env = Local<Array>::Cast(env_v);
|
||||
int envc = env->Length();
|
||||
Local<Array> env_opt = Local<Array>::Cast(env_v);
|
||||
int envc = env_opt->Length();
|
||||
options.env = new char*[envc + 1]; // Heap allocated to detect errors.
|
||||
for (int i = 0; i < envc; i++) {
|
||||
node::Utf8Value pair(env->Get(i));
|
||||
node::Utf8Value pair(env->isolate(), env_opt->Get(i));
|
||||
options.env[i] = strdup(*pair);
|
||||
}
|
||||
options.env[envc] = nullptr;
|
||||
|
@ -279,7 +279,7 @@ void TCPWrap::Open(const FunctionCallbackInfo<Value>& args) {
|
||||
|
||||
void TCPWrap::Bind(const FunctionCallbackInfo<Value>& args) {
|
||||
TCPWrap* wrap = Unwrap<TCPWrap>(args.Holder());
|
||||
node::Utf8Value ip_address(args[0]);
|
||||
node::Utf8Value ip_address(args.GetIsolate(), args[0]);
|
||||
int port = args[1]->Int32Value();
|
||||
sockaddr_in addr;
|
||||
int err = uv_ip4_addr(*ip_address, port, &addr);
|
||||
@ -294,7 +294,7 @@ void TCPWrap::Bind(const FunctionCallbackInfo<Value>& args) {
|
||||
|
||||
void TCPWrap::Bind6(const FunctionCallbackInfo<Value>& args) {
|
||||
TCPWrap* wrap = Unwrap<TCPWrap>(args.Holder());
|
||||
node::Utf8Value ip6_address(args[0]);
|
||||
node::Utf8Value ip6_address(args.GetIsolate(), args[0]);
|
||||
int port = args[1]->Int32Value();
|
||||
sockaddr_in6 addr;
|
||||
int err = uv_ip6_addr(*ip6_address, port, &addr);
|
||||
@ -391,7 +391,7 @@ void TCPWrap::Connect(const FunctionCallbackInfo<Value>& args) {
|
||||
CHECK(args[2]->Uint32Value());
|
||||
|
||||
Local<Object> req_wrap_obj = args[0].As<Object>();
|
||||
node::Utf8Value ip_address(args[1]);
|
||||
node::Utf8Value ip_address(env->isolate(), args[1]);
|
||||
int port = args[2]->Uint32Value();
|
||||
|
||||
sockaddr_in addr;
|
||||
@ -422,7 +422,7 @@ void TCPWrap::Connect6(const FunctionCallbackInfo<Value>& args) {
|
||||
CHECK(args[2]->Uint32Value());
|
||||
|
||||
Local<Object> req_wrap_obj = args[0].As<Object>();
|
||||
node::Utf8Value ip_address(args[1]);
|
||||
node::Utf8Value ip_address(env->isolate(), args[1]);
|
||||
int port = args[2]->Int32Value();
|
||||
|
||||
sockaddr_in6 addr;
|
||||
|
@ -748,7 +748,7 @@ void TLSCallbacks::SetServername(const FunctionCallbackInfo<Value>& args) {
|
||||
return;
|
||||
|
||||
#ifdef SSL_CTRL_SET_TLSEXT_SERVERNAME_CB
|
||||
node::Utf8Value servername(args[0].As<String>());
|
||||
node::Utf8Value servername(env->isolate(), args[0].As<String>());
|
||||
SSL_set_tlsext_host_name(wrap->ssl_, *servername);
|
||||
#endif // SSL_CTRL_SET_TLSEXT_SERVERNAME_CB
|
||||
}
|
||||
|
@ -170,7 +170,7 @@ void UDPWrap::DoBind(const FunctionCallbackInfo<Value>& args, int family) {
|
||||
// bind(ip, port, flags)
|
||||
CHECK_EQ(args.Length(), 3);
|
||||
|
||||
node::Utf8Value address(args[0]);
|
||||
node::Utf8Value address(args.GetIsolate(), args[0]);
|
||||
const int port = args[1]->Uint32Value();
|
||||
const int flags = args[2]->Uint32Value();
|
||||
char addr[sizeof(sockaddr_in6)];
|
||||
@ -231,8 +231,8 @@ void UDPWrap::SetMembership(const FunctionCallbackInfo<Value>& args,
|
||||
|
||||
CHECK_EQ(args.Length(), 2);
|
||||
|
||||
node::Utf8Value address(args[0]);
|
||||
node::Utf8Value iface(args[1]);
|
||||
node::Utf8Value address(args.GetIsolate(), args[0]);
|
||||
node::Utf8Value iface(args.GetIsolate(), args[1]);
|
||||
|
||||
const char* iface_cstr = *iface;
|
||||
if (args[1]->IsUndefined() || args[1]->IsNull()) {
|
||||
@ -276,7 +276,7 @@ void UDPWrap::DoSend(const FunctionCallbackInfo<Value>& args, int family) {
|
||||
size_t offset = args[2]->Uint32Value();
|
||||
size_t length = args[3]->Uint32Value();
|
||||
const unsigned short port = args[4]->Uint32Value();
|
||||
node::Utf8Value address(args[5]);
|
||||
node::Utf8Value address(env->isolate(), args[5]);
|
||||
const bool have_callback = args[6]->IsTrue();
|
||||
|
||||
CHECK_LE(length, Buffer::Length(buffer_obj) - offset);
|
||||
|
@ -25,12 +25,12 @@
|
||||
|
||||
namespace node {
|
||||
|
||||
Utf8Value::Utf8Value(v8::Handle<v8::Value> value)
|
||||
Utf8Value::Utf8Value(v8::Isolate* isolate, v8::Handle<v8::Value> value)
|
||||
: length_(0), str_(nullptr) {
|
||||
if (value.IsEmpty())
|
||||
return;
|
||||
|
||||
v8::Local<v8::String> val_ = value->ToString(v8::Isolate::GetCurrent());
|
||||
v8::Local<v8::String> val_ = value->ToString(isolate);
|
||||
if (val_.IsEmpty())
|
||||
return;
|
||||
|
||||
|
@ -121,7 +121,7 @@ inline TypeName* Unwrap(v8::Local<v8::Object> object);
|
||||
|
||||
class Utf8Value {
|
||||
public:
|
||||
explicit Utf8Value(v8::Handle<v8::Value> value);
|
||||
explicit Utf8Value(v8::Isolate* isolate, v8::Handle<v8::Value> value);
|
||||
|
||||
~Utf8Value() {
|
||||
free(str_);
|
||||
|
Loading…
x
Reference in New Issue
Block a user