mirror of
https://github.com/nodejs/node.git
synced 2025-05-22 04:28:50 +00:00
src: use v8::String::NewFrom*() functions
* Change calls to String::New() and String::NewSymbol() to their respective one-byte, two-byte and UTF-8 counterparts. * Add a FIXED_ONE_BYTE_STRING macro that takes a string literal and turns it into a v8::Local<v8::String>. * Add helper functions that make v8::String::NewFromOneByte() easier to work with. Said function expects a `const uint8_t*` but almost every call site deals with `const char*` or `const unsigned char*`. Helps us avoid doing reinterpret_casts all over the place. * Code that handles file system paths keeps using UTF-8 for backwards compatibility reasons. At least now the use of UTF-8 is explicit. * Remove v8::String::NewSymbol() entirely. Almost all call sites were effectively minor de-optimizations. If you create a string only once, there is no point in making it a symbol. If you are create the same string repeatedly, it should probably be cached in a persistent handle.
This commit is contained in:
parent
c0e70354db
commit
f674b09f40
@ -206,7 +206,7 @@ static Local<Array> HostentToAddresses(struct hostent* host) {
|
|||||||
for (int i = 0; host->h_addr_list[i]; ++i) {
|
for (int i = 0; host->h_addr_list[i]; ++i) {
|
||||||
uv_inet_ntop(host->h_addrtype, host->h_addr_list[i], ip, sizeof(ip));
|
uv_inet_ntop(host->h_addrtype, host->h_addr_list[i], ip, sizeof(ip));
|
||||||
|
|
||||||
Local<String> address = String::New(ip);
|
Local<String> address = OneByteString(node_isolate, ip);
|
||||||
addresses->Set(Integer::New(i, node_isolate), address);
|
addresses->Set(Integer::New(i, node_isolate), address);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -219,7 +219,7 @@ static Local<Array> HostentToNames(struct hostent* host) {
|
|||||||
Local<Array> names = Array::New();
|
Local<Array> names = Array::New();
|
||||||
|
|
||||||
for (int i = 0; host->h_aliases[i]; ++i) {
|
for (int i = 0; host->h_aliases[i]; ++i) {
|
||||||
Local<String> address = String::New(host->h_aliases[i]);
|
Local<String> address = OneByteString(node_isolate, host->h_aliases[i]);
|
||||||
names->Set(Integer::New(i, node_isolate), address);
|
names->Set(Integer::New(i, node_isolate), address);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -426,7 +426,7 @@ class QueryCnameWrap: public QueryWrap {
|
|||||||
// A cname lookup always returns a single record but we follow the
|
// A cname lookup always returns a single record but we follow the
|
||||||
// common API here.
|
// common API here.
|
||||||
Local<Array> result = Array::New(1);
|
Local<Array> result = Array::New(1);
|
||||||
result->Set(0, String::New(host->h_name));
|
result->Set(0, OneByteString(node_isolate, host->h_name));
|
||||||
ares_free_hostent(host);
|
ares_free_hostent(host);
|
||||||
|
|
||||||
this->CallOnComplete(result);
|
this->CallOnComplete(result);
|
||||||
@ -456,14 +456,18 @@ class QueryMxWrap: public QueryWrap {
|
|||||||
}
|
}
|
||||||
|
|
||||||
Local<Array> mx_records = Array::New();
|
Local<Array> mx_records = Array::New();
|
||||||
Local<String> exchange_symbol = String::NewSymbol("exchange");
|
Local<String> exchange_symbol =
|
||||||
Local<String> priority_symbol = String::NewSymbol("priority");
|
FIXED_ONE_BYTE_STRING(node_isolate, "exchange");
|
||||||
|
Local<String> priority_symbol =
|
||||||
|
FIXED_ONE_BYTE_STRING(node_isolate, "priority");
|
||||||
|
|
||||||
int i = 0;
|
int i = 0;
|
||||||
for (struct ares_mx_reply* mx_current = mx_start;
|
for (struct ares_mx_reply* mx_current = mx_start;
|
||||||
mx_current;
|
mx_current;
|
||||||
mx_current = mx_current->next) {
|
mx_current = mx_current->next) {
|
||||||
Local<Object> mx_record = Object::New();
|
Local<Object> mx_record = Object::New();
|
||||||
mx_record->Set(exchange_symbol, String::New(mx_current->host));
|
mx_record->Set(exchange_symbol,
|
||||||
|
OneByteString(node_isolate, mx_current->host));
|
||||||
mx_record->Set(priority_symbol,
|
mx_record->Set(priority_symbol,
|
||||||
Integer::New(mx_current->priority, node_isolate));
|
Integer::New(mx_current->priority, node_isolate));
|
||||||
mx_records->Set(Integer::New(i++, node_isolate), mx_record);
|
mx_records->Set(Integer::New(i++, node_isolate), mx_record);
|
||||||
@ -528,7 +532,7 @@ class QueryTxtWrap: public QueryWrap {
|
|||||||
|
|
||||||
struct ares_txt_reply *current = txt_out;
|
struct ares_txt_reply *current = txt_out;
|
||||||
for (int i = 0; current; ++i, current = current->next) {
|
for (int i = 0; current; ++i, current = current->next) {
|
||||||
Local<String> txt = String::New(reinterpret_cast<char*>(current->txt));
|
Local<String> txt = OneByteString(node_isolate, current->txt);
|
||||||
txt_records->Set(Integer::New(i, node_isolate), txt);
|
txt_records->Set(Integer::New(i, node_isolate), txt);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -566,16 +570,22 @@ class QuerySrvWrap: public QueryWrap {
|
|||||||
}
|
}
|
||||||
|
|
||||||
Local<Array> srv_records = Array::New();
|
Local<Array> srv_records = Array::New();
|
||||||
Local<String> name_symbol = String::NewSymbol("name");
|
Local<String> name_symbol =
|
||||||
Local<String> port_symbol = String::NewSymbol("port");
|
FIXED_ONE_BYTE_STRING(node_isolate, "name");
|
||||||
Local<String> priority_symbol = String::NewSymbol("priority");
|
Local<String> port_symbol =
|
||||||
Local<String> weight_symbol = String::NewSymbol("weight");
|
FIXED_ONE_BYTE_STRING(node_isolate, "port");
|
||||||
|
Local<String> priority_symbol =
|
||||||
|
FIXED_ONE_BYTE_STRING(node_isolate, "priority");
|
||||||
|
Local<String> weight_symbol =
|
||||||
|
FIXED_ONE_BYTE_STRING(node_isolate, "weight");
|
||||||
|
|
||||||
int i = 0;
|
int i = 0;
|
||||||
for (struct ares_srv_reply* srv_current = srv_start;
|
for (struct ares_srv_reply* srv_current = srv_start;
|
||||||
srv_current;
|
srv_current;
|
||||||
srv_current = srv_current->next) {
|
srv_current = srv_current->next) {
|
||||||
Local<Object> srv_record = Object::New();
|
Local<Object> srv_record = Object::New();
|
||||||
srv_record->Set(name_symbol, String::New(srv_current->host));
|
srv_record->Set(name_symbol,
|
||||||
|
OneByteString(node_isolate, srv_current->host));
|
||||||
srv_record->Set(port_symbol,
|
srv_record->Set(port_symbol,
|
||||||
Integer::New(srv_current->port, node_isolate));
|
Integer::New(srv_current->port, node_isolate));
|
||||||
srv_record->Set(priority_symbol,
|
srv_record->Set(priority_symbol,
|
||||||
@ -620,12 +630,18 @@ class QueryNaptrWrap: public QueryWrap {
|
|||||||
}
|
}
|
||||||
|
|
||||||
Local<Array> naptr_records = Array::New();
|
Local<Array> naptr_records = Array::New();
|
||||||
Local<String> flags_symbol = String::NewSymbol("flags");
|
Local<String> flags_symbol =
|
||||||
Local<String> service_symbol = String::NewSymbol("service");
|
FIXED_ONE_BYTE_STRING(node_isolate, "flags");
|
||||||
Local<String> regexp_symbol = String::NewSymbol("regexp");
|
Local<String> service_symbol =
|
||||||
Local<String> replacement_symbol = String::NewSymbol("replacement");
|
FIXED_ONE_BYTE_STRING(node_isolate, "service");
|
||||||
Local<String> order_symbol = String::NewSymbol("order");
|
Local<String> regexp_symbol =
|
||||||
Local<String> preference_symbol = String::NewSymbol("preference");
|
FIXED_ONE_BYTE_STRING(node_isolate, "regexp");
|
||||||
|
Local<String> replacement_symbol =
|
||||||
|
FIXED_ONE_BYTE_STRING(node_isolate, "replacement");
|
||||||
|
Local<String> order_symbol =
|
||||||
|
FIXED_ONE_BYTE_STRING(node_isolate, "order");
|
||||||
|
Local<String> preference_symbol =
|
||||||
|
FIXED_ONE_BYTE_STRING(node_isolate, "preference");
|
||||||
|
|
||||||
int i = 0;
|
int i = 0;
|
||||||
for (ares_naptr_reply* naptr_current = naptr_start;
|
for (ares_naptr_reply* naptr_current = naptr_start;
|
||||||
@ -634,13 +650,14 @@ class QueryNaptrWrap: public QueryWrap {
|
|||||||
Local<Object> naptr_record = Object::New();
|
Local<Object> naptr_record = Object::New();
|
||||||
|
|
||||||
naptr_record->Set(flags_symbol,
|
naptr_record->Set(flags_symbol,
|
||||||
String::New(reinterpret_cast<char*>(naptr_current->flags)));
|
OneByteString(node_isolate, naptr_current->flags));
|
||||||
naptr_record->Set(service_symbol,
|
naptr_record->Set(service_symbol,
|
||||||
String::New(reinterpret_cast<char*>(naptr_current->service)));
|
OneByteString(node_isolate, naptr_current->service));
|
||||||
naptr_record->Set(regexp_symbol,
|
naptr_record->Set(regexp_symbol,
|
||||||
String::New(reinterpret_cast<char*>(naptr_current->regexp)));
|
OneByteString(node_isolate, naptr_current->regexp));
|
||||||
naptr_record->Set(replacement_symbol,
|
naptr_record->Set(replacement_symbol,
|
||||||
String::New(naptr_current->replacement));
|
OneByteString(node_isolate,
|
||||||
|
naptr_current->replacement));
|
||||||
naptr_record->Set(order_symbol, Integer::New(naptr_current->order,
|
naptr_record->Set(order_symbol, Integer::New(naptr_current->order,
|
||||||
node_isolate));
|
node_isolate));
|
||||||
naptr_record->Set(preference_symbol,
|
naptr_record->Set(preference_symbol,
|
||||||
@ -814,7 +831,7 @@ void AfterGetAddrInfo(uv_getaddrinfo_t* req, int status, struct addrinfo* res) {
|
|||||||
continue;
|
continue;
|
||||||
|
|
||||||
// Create JavaScript string
|
// Create JavaScript string
|
||||||
Local<String> s = String::New(ip);
|
Local<String> s = OneByteString(node_isolate, ip);
|
||||||
results->Set(n, s);
|
results->Set(n, s);
|
||||||
n++;
|
n++;
|
||||||
}
|
}
|
||||||
@ -841,7 +858,7 @@ void AfterGetAddrInfo(uv_getaddrinfo_t* req, int status, struct addrinfo* res) {
|
|||||||
continue;
|
continue;
|
||||||
|
|
||||||
// Create JavaScript string
|
// Create JavaScript string
|
||||||
Local<String> s = String::New(ip);
|
Local<String> s = OneByteString(node_isolate, ip);
|
||||||
results->Set(n, s);
|
results->Set(n, s);
|
||||||
n++;
|
n++;
|
||||||
}
|
}
|
||||||
@ -943,7 +960,7 @@ static void GetServers(const FunctionCallbackInfo<Value>& args) {
|
|||||||
int err = uv_inet_ntop(cur->family, caddr, ip, sizeof(ip));
|
int err = uv_inet_ntop(cur->family, caddr, ip, sizeof(ip));
|
||||||
assert(err == 0);
|
assert(err == 0);
|
||||||
|
|
||||||
Local<String> addr = String::New(ip);
|
Local<String> addr = OneByteString(node_isolate, ip);
|
||||||
server_array->Set(i, addr);
|
server_array->Set(i, addr);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -1024,7 +1041,7 @@ static void SetServers(const FunctionCallbackInfo<Value>& args) {
|
|||||||
static void StrError(const FunctionCallbackInfo<Value>& args) {
|
static void StrError(const FunctionCallbackInfo<Value>& args) {
|
||||||
HandleScope scope(node_isolate);
|
HandleScope scope(node_isolate);
|
||||||
const char* errmsg = ares_strerror(args[0]->Int32Value());
|
const char* errmsg = ares_strerror(args[0]->Int32Value());
|
||||||
args.GetReturnValue().Set(String::New(errmsg));
|
args.GetReturnValue().Set(OneByteString(node_isolate, errmsg));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@ -1069,14 +1086,14 @@ static void Initialize(Handle<Object> target) {
|
|||||||
NODE_SET_METHOD(target, "getServers", GetServers);
|
NODE_SET_METHOD(target, "getServers", GetServers);
|
||||||
NODE_SET_METHOD(target, "setServers", SetServers);
|
NODE_SET_METHOD(target, "setServers", SetServers);
|
||||||
|
|
||||||
target->Set(String::NewSymbol("AF_INET"),
|
target->Set(FIXED_ONE_BYTE_STRING(node_isolate, "AF_INET"),
|
||||||
Integer::New(AF_INET, node_isolate));
|
Integer::New(AF_INET, node_isolate));
|
||||||
target->Set(String::NewSymbol("AF_INET6"),
|
target->Set(FIXED_ONE_BYTE_STRING(node_isolate, "AF_INET6"),
|
||||||
Integer::New(AF_INET6, node_isolate));
|
Integer::New(AF_INET6, node_isolate));
|
||||||
target->Set(String::NewSymbol("AF_UNSPEC"),
|
target->Set(FIXED_ONE_BYTE_STRING(node_isolate, "AF_UNSPEC"),
|
||||||
Integer::New(AF_UNSPEC, node_isolate));
|
Integer::New(AF_UNSPEC, node_isolate));
|
||||||
|
|
||||||
oncomplete_sym = String::New("oncomplete");
|
oncomplete_sym = FIXED_ONE_BYTE_STRING(node_isolate, "oncomplete");
|
||||||
}
|
}
|
||||||
|
|
||||||
} // namespace cares_wrap
|
} // namespace cares_wrap
|
||||||
|
@ -75,16 +75,16 @@ void FSEventWrap::Initialize(Handle<Object> target) {
|
|||||||
|
|
||||||
Local<FunctionTemplate> t = FunctionTemplate::New(New);
|
Local<FunctionTemplate> t = FunctionTemplate::New(New);
|
||||||
t->InstanceTemplate()->SetInternalFieldCount(1);
|
t->InstanceTemplate()->SetInternalFieldCount(1);
|
||||||
t->SetClassName(String::NewSymbol("FSEvent"));
|
t->SetClassName(FIXED_ONE_BYTE_STRING(node_isolate, "FSEvent"));
|
||||||
|
|
||||||
NODE_SET_PROTOTYPE_METHOD(t, "start", Start);
|
NODE_SET_PROTOTYPE_METHOD(t, "start", Start);
|
||||||
NODE_SET_PROTOTYPE_METHOD(t, "close", Close);
|
NODE_SET_PROTOTYPE_METHOD(t, "close", Close);
|
||||||
|
|
||||||
target->Set(String::New("FSEvent"), t->GetFunction());
|
target->Set(FIXED_ONE_BYTE_STRING(node_isolate, "FSEvent"), t->GetFunction());
|
||||||
|
|
||||||
change_sym = String::New("change");
|
change_sym = FIXED_ONE_BYTE_STRING(node_isolate, "change");
|
||||||
onchange_sym = String::New("onchange");
|
onchange_sym = FIXED_ONE_BYTE_STRING(node_isolate, "onchange");
|
||||||
rename_sym = String::New("rename");
|
rename_sym = FIXED_ONE_BYTE_STRING(node_isolate, "rename");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@ -161,7 +161,7 @@ void FSEventWrap::OnEvent(uv_fs_event_t* handle, const char* filename,
|
|||||||
};
|
};
|
||||||
|
|
||||||
if (filename != NULL) {
|
if (filename != NULL) {
|
||||||
argv[2] = String::New(filename);
|
argv[2] = OneByteString(node_isolate, filename);
|
||||||
}
|
}
|
||||||
|
|
||||||
MakeCallback(wrap->object(), onchange_sym, ARRAY_SIZE(argv), argv);
|
MakeCallback(wrap->object(), onchange_sym, ARRAY_SIZE(argv), argv);
|
||||||
|
@ -76,7 +76,9 @@ void HandleWrap::Close(const FunctionCallbackInfo<Value>& args) {
|
|||||||
wrap->handle__ = NULL;
|
wrap->handle__ = NULL;
|
||||||
|
|
||||||
if (args[0]->IsFunction()) {
|
if (args[0]->IsFunction()) {
|
||||||
if (close_sym.IsEmpty() == true) close_sym = String::New("close");
|
if (close_sym.IsEmpty() == true) {
|
||||||
|
close_sym = FIXED_ONE_BYTE_STRING(node_isolate, "close");
|
||||||
|
}
|
||||||
wrap->object()->Set(close_sym, args[0]);
|
wrap->object()->Set(close_sym, args[0]);
|
||||||
wrap->flags_ |= kCloseCallback;
|
wrap->flags_ |= kCloseCallback;
|
||||||
}
|
}
|
||||||
|
325
src/node.cc
325
src/node.cc
@ -242,7 +242,8 @@ static void CheckImmediate(uv_check_t* handle, int status) {
|
|||||||
HandleScope scope(node_isolate);
|
HandleScope scope(node_isolate);
|
||||||
|
|
||||||
if (immediate_callback_sym.IsEmpty()) {
|
if (immediate_callback_sym.IsEmpty()) {
|
||||||
immediate_callback_sym = String::New("_immediateCallback");
|
immediate_callback_sym =
|
||||||
|
FIXED_ONE_BYTE_STRING(node_isolate, "_immediateCallback");
|
||||||
}
|
}
|
||||||
|
|
||||||
MakeCallback(process_p, immediate_callback_sym, 0, NULL);
|
MakeCallback(process_p, immediate_callback_sym, 0, NULL);
|
||||||
@ -738,26 +739,30 @@ Local<Value> ErrnoException(int errorno,
|
|||||||
const char *msg,
|
const char *msg,
|
||||||
const char *path) {
|
const char *path) {
|
||||||
Local<Value> e;
|
Local<Value> e;
|
||||||
Local<String> estring = String::NewSymbol(errno_string(errorno));
|
Local<String> estring = OneByteString(node_isolate, errno_string(errorno));
|
||||||
if (msg == NULL || msg[0] == '\0') {
|
if (msg == NULL || msg[0] == '\0') {
|
||||||
msg = strerror(errorno);
|
msg = strerror(errorno);
|
||||||
}
|
}
|
||||||
Local<String> message = String::NewSymbol(msg);
|
Local<String> message = OneByteString(node_isolate, msg);
|
||||||
|
|
||||||
Local<String> cons1 = String::Concat(estring, String::NewSymbol(", "));
|
Local<String> cons1 =
|
||||||
|
String::Concat(estring, FIXED_ONE_BYTE_STRING(node_isolate, ", "));
|
||||||
Local<String> cons2 = String::Concat(cons1, message);
|
Local<String> cons2 = String::Concat(cons1, message);
|
||||||
|
|
||||||
if (syscall_symbol.IsEmpty()) {
|
if (syscall_symbol.IsEmpty()) {
|
||||||
syscall_symbol = String::New("syscall");
|
syscall_symbol = FIXED_ONE_BYTE_STRING(node_isolate, "syscall");
|
||||||
errno_symbol = String::New("errno");
|
errno_symbol = FIXED_ONE_BYTE_STRING(node_isolate, "errno");
|
||||||
errpath_symbol = String::New("path");
|
errpath_symbol = FIXED_ONE_BYTE_STRING(node_isolate, "path");
|
||||||
code_symbol = String::New("code");
|
code_symbol = FIXED_ONE_BYTE_STRING(node_isolate, "code");
|
||||||
}
|
}
|
||||||
|
|
||||||
if (path) {
|
if (path) {
|
||||||
Local<String> cons3 = String::Concat(cons2, String::NewSymbol(" '"));
|
Local<String> cons3 =
|
||||||
Local<String> cons4 = String::Concat(cons3, String::New(path));
|
String::Concat(cons2, FIXED_ONE_BYTE_STRING(node_isolate, " '"));
|
||||||
Local<String> cons5 = String::Concat(cons4, String::NewSymbol("'"));
|
Local<String> cons4 =
|
||||||
|
String::Concat(cons3, String::NewFromUtf8(node_isolate, path));
|
||||||
|
Local<String> cons5 =
|
||||||
|
String::Concat(cons4, FIXED_ONE_BYTE_STRING(node_isolate, "'"));
|
||||||
e = Exception::Error(cons5);
|
e = Exception::Error(cons5);
|
||||||
} else {
|
} else {
|
||||||
e = Exception::Error(cons2);
|
e = Exception::Error(cons2);
|
||||||
@ -767,8 +772,8 @@ Local<Value> ErrnoException(int errorno,
|
|||||||
|
|
||||||
obj->Set(errno_symbol, Integer::New(errorno, node_isolate));
|
obj->Set(errno_symbol, Integer::New(errorno, node_isolate));
|
||||||
obj->Set(code_symbol, estring);
|
obj->Set(code_symbol, estring);
|
||||||
if (path) obj->Set(errpath_symbol, String::New(path));
|
if (path) obj->Set(errpath_symbol, String::NewFromUtf8(node_isolate, path));
|
||||||
if (syscall) obj->Set(syscall_symbol, String::NewSymbol(syscall));
|
if (syscall) obj->Set(syscall_symbol, OneByteString(node_isolate, syscall));
|
||||||
return e;
|
return e;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -779,18 +784,19 @@ Local<Value> UVException(int errorno,
|
|||||||
const char *msg,
|
const char *msg,
|
||||||
const char *path) {
|
const char *path) {
|
||||||
if (syscall_symbol.IsEmpty()) {
|
if (syscall_symbol.IsEmpty()) {
|
||||||
syscall_symbol = String::New("syscall");
|
syscall_symbol = FIXED_ONE_BYTE_STRING(node_isolate, "syscall");
|
||||||
errno_symbol = String::New("errno");
|
errno_symbol = FIXED_ONE_BYTE_STRING(node_isolate, "errno");
|
||||||
errpath_symbol = String::New("path");
|
errpath_symbol = FIXED_ONE_BYTE_STRING(node_isolate, "path");
|
||||||
code_symbol = String::New("code");
|
code_symbol = FIXED_ONE_BYTE_STRING(node_isolate, "code");
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!msg || !msg[0])
|
if (!msg || !msg[0])
|
||||||
msg = uv_strerror(errorno);
|
msg = uv_strerror(errorno);
|
||||||
|
|
||||||
Local<String> estring = String::NewSymbol(uv_err_name(errorno));
|
Local<String> estring = OneByteString(node_isolate, uv_err_name(errorno));
|
||||||
Local<String> message = String::NewSymbol(msg);
|
Local<String> message = OneByteString(node_isolate, msg);
|
||||||
Local<String> cons1 = String::Concat(estring, String::NewSymbol(", "));
|
Local<String> cons1 =
|
||||||
|
String::Concat(estring, FIXED_ONE_BYTE_STRING(node_isolate, ", "));
|
||||||
Local<String> cons2 = String::Concat(cons1, message);
|
Local<String> cons2 = String::Concat(cons1, message);
|
||||||
|
|
||||||
Local<Value> e;
|
Local<Value> e;
|
||||||
@ -800,19 +806,23 @@ Local<Value> UVException(int errorno,
|
|||||||
if (path) {
|
if (path) {
|
||||||
#ifdef _WIN32
|
#ifdef _WIN32
|
||||||
if (strncmp(path, "\\\\?\\UNC\\", 8) == 0) {
|
if (strncmp(path, "\\\\?\\UNC\\", 8) == 0) {
|
||||||
path_str = String::Concat(String::New("\\\\"), String::New(path + 8));
|
path_str = String::Concat(FIXED_ONE_BYTE_STRING(node_isolate, "\\\\"),
|
||||||
|
String::NewFromUtf8(node_isolate, path + 8));
|
||||||
} else if (strncmp(path, "\\\\?\\", 4) == 0) {
|
} else if (strncmp(path, "\\\\?\\", 4) == 0) {
|
||||||
path_str = String::New(path + 4);
|
path_str = String::NewFromUtf8(node_isolate, path + 4);
|
||||||
} else {
|
} else {
|
||||||
path_str = String::New(path);
|
path_str = String::NewFromUtf8(node_isolate, path);
|
||||||
}
|
}
|
||||||
#else
|
#else
|
||||||
path_str = String::New(path);
|
path_str = String::NewFromUtf8(node_isolate, path);
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
Local<String> cons3 = String::Concat(cons2, String::NewSymbol(" '"));
|
Local<String> cons3 =
|
||||||
Local<String> cons4 = String::Concat(cons3, path_str);
|
String::Concat(cons2, FIXED_ONE_BYTE_STRING(node_isolate, " '"));
|
||||||
Local<String> cons5 = String::Concat(cons4, String::NewSymbol("'"));
|
Local<String> cons4 =
|
||||||
|
String::Concat(cons3, path_str);
|
||||||
|
Local<String> cons5 =
|
||||||
|
String::Concat(cons4, FIXED_ONE_BYTE_STRING(node_isolate, "'"));
|
||||||
e = Exception::Error(cons5);
|
e = Exception::Error(cons5);
|
||||||
} else {
|
} else {
|
||||||
e = Exception::Error(cons2);
|
e = Exception::Error(cons2);
|
||||||
@ -824,7 +834,7 @@ Local<Value> UVException(int errorno,
|
|||||||
obj->Set(errno_symbol, Integer::New(errorno, node_isolate));
|
obj->Set(errno_symbol, Integer::New(errorno, node_isolate));
|
||||||
obj->Set(code_symbol, estring);
|
obj->Set(code_symbol, estring);
|
||||||
if (path) obj->Set(errpath_symbol, path_str);
|
if (path) obj->Set(errpath_symbol, path_str);
|
||||||
if (syscall) obj->Set(syscall_symbol, String::NewSymbol(syscall));
|
if (syscall) obj->Set(syscall_symbol, OneByteString(node_isolate, syscall));
|
||||||
return e;
|
return e;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -862,19 +872,22 @@ Local<Value> WinapiErrnoException(int errorno,
|
|||||||
if (!msg || !msg[0]) {
|
if (!msg || !msg[0]) {
|
||||||
msg = winapi_strerror(errorno);
|
msg = winapi_strerror(errorno);
|
||||||
}
|
}
|
||||||
Local<String> message = String::NewSymbol(msg);
|
Local<String> message = OneByteString(node_isolate, msg);
|
||||||
|
|
||||||
if (syscall_symbol.IsEmpty()) {
|
if (syscall_symbol.IsEmpty()) {
|
||||||
syscall_symbol = String::New("syscall");
|
syscall_symbol = FIXED_ONE_BYTE_STRING(node_isolate, "syscall");
|
||||||
errno_symbol = String::New("errno");
|
errno_symbol = FIXED_ONE_BYTE_STRING(node_isolate, "errno");
|
||||||
errpath_symbol = String::New("path");
|
errpath_symbol = FIXED_ONE_BYTE_STRING(node_isolate, "path");
|
||||||
code_symbol = String::New("code");
|
code_symbol = FIXED_ONE_BYTE_STRING(node_isolate, "code");
|
||||||
}
|
}
|
||||||
|
|
||||||
if (path) {
|
if (path) {
|
||||||
Local<String> cons1 = String::Concat(message, String::NewSymbol(" '"));
|
Local<String> cons1 =
|
||||||
Local<String> cons2 = String::Concat(cons1, String::New(path));
|
String::Concat(message, FIXED_ONE_BYTE_STRING(node_isolate, " '"));
|
||||||
Local<String> cons3 = String::Concat(cons2, String::NewSymbol("'"));
|
Local<String> cons2 =
|
||||||
|
String::Concat(cons1, String::NewFromUtf8(node_isolate, path));
|
||||||
|
Local<String> cons3 =
|
||||||
|
String::Concat(cons2, FIXED_ONE_BYTE_STRING(node_isolate, "'"));
|
||||||
e = Exception::Error(cons3);
|
e = Exception::Error(cons3);
|
||||||
} else {
|
} else {
|
||||||
e = Exception::Error(message);
|
e = Exception::Error(message);
|
||||||
@ -883,8 +896,8 @@ Local<Value> WinapiErrnoException(int errorno,
|
|||||||
Local<Object> obj = e->ToObject();
|
Local<Object> obj = e->ToObject();
|
||||||
|
|
||||||
obj->Set(errno_symbol, Integer::New(errorno, node_isolate));
|
obj->Set(errno_symbol, Integer::New(errorno, node_isolate));
|
||||||
if (path) obj->Set(errpath_symbol, String::New(path));
|
if (path) obj->Set(errpath_symbol, String::NewFromUtf8(node_isolate, path));
|
||||||
if (syscall) obj->Set(syscall_symbol, String::NewSymbol(syscall));
|
if (syscall) obj->Set(syscall_symbol, OneByteString(node_isolate, syscall));
|
||||||
return e;
|
return e;
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
@ -895,8 +908,10 @@ void SetupDomainUse(const FunctionCallbackInfo<Value>& args) {
|
|||||||
HandleScope scope(node_isolate);
|
HandleScope scope(node_isolate);
|
||||||
using_domains = true;
|
using_domains = true;
|
||||||
Local<Object> process = PersistentToLocal(node_isolate, process_p);
|
Local<Object> process = PersistentToLocal(node_isolate, process_p);
|
||||||
Local<Value> tdc_v = process->Get(String::New("_tickDomainCallback"));
|
Local<Value> tdc_v =
|
||||||
Local<Value> ndt_v = process->Get(String::New("_nextDomainTick"));
|
process->Get(FIXED_ONE_BYTE_STRING(node_isolate, "_tickDomainCallback"));
|
||||||
|
Local<Value> ndt_v =
|
||||||
|
process->Get(FIXED_ONE_BYTE_STRING(node_isolate, "_nextDomainTick"));
|
||||||
if (!tdc_v->IsFunction()) {
|
if (!tdc_v->IsFunction()) {
|
||||||
fprintf(stderr, "process._tickDomainCallback assigned to non-function\n");
|
fprintf(stderr, "process._tickDomainCallback assigned to non-function\n");
|
||||||
abort();
|
abort();
|
||||||
@ -907,8 +922,8 @@ void SetupDomainUse(const FunctionCallbackInfo<Value>& args) {
|
|||||||
}
|
}
|
||||||
Local<Function> tdc = tdc_v.As<Function>();
|
Local<Function> tdc = tdc_v.As<Function>();
|
||||||
Local<Function> ndt = ndt_v.As<Function>();
|
Local<Function> ndt = ndt_v.As<Function>();
|
||||||
process->Set(String::New("_tickCallback"), tdc);
|
process->Set(FIXED_ONE_BYTE_STRING(node_isolate, "_tickCallback"), tdc);
|
||||||
process->Set(String::New("nextTick"), ndt);
|
process->Set(FIXED_ONE_BYTE_STRING(node_isolate, "nextTick"), ndt);
|
||||||
process_tickCallback.Reset(node_isolate, tdc);
|
process_tickCallback.Reset(node_isolate, tdc);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -922,9 +937,9 @@ MakeDomainCallback(const Handle<Object> object,
|
|||||||
|
|
||||||
// lazy load domain specific symbols
|
// lazy load domain specific symbols
|
||||||
if (enter_symbol.IsEmpty()) {
|
if (enter_symbol.IsEmpty()) {
|
||||||
enter_symbol = String::New("enter");
|
enter_symbol = FIXED_ONE_BYTE_STRING(node_isolate, "enter");
|
||||||
exit_symbol = String::New("exit");
|
exit_symbol = FIXED_ONE_BYTE_STRING(node_isolate, "exit");
|
||||||
disposed_symbol = String::New("_disposed");
|
disposed_symbol = FIXED_ONE_BYTE_STRING(node_isolate, "_disposed");
|
||||||
}
|
}
|
||||||
|
|
||||||
Local<Value> domain_v = object->Get(domain_symbol);
|
Local<Value> domain_v = object->Get(domain_symbol);
|
||||||
@ -1008,7 +1023,8 @@ MakeCallback(const Handle<Object> object,
|
|||||||
|
|
||||||
// lazy load no domain next tick callbacks
|
// lazy load no domain next tick callbacks
|
||||||
if (process_tickCallback.IsEmpty()) {
|
if (process_tickCallback.IsEmpty()) {
|
||||||
Local<Value> cb_v = process->Get(String::New("_tickCallback"));
|
Local<Value> cb_v =
|
||||||
|
process->Get(FIXED_ONE_BYTE_STRING(node_isolate, "_tickCallback"));
|
||||||
if (!cb_v->IsFunction()) {
|
if (!cb_v->IsFunction()) {
|
||||||
fprintf(stderr, "process._tickCallback assigned to non-function\n");
|
fprintf(stderr, "process._tickCallback assigned to non-function\n");
|
||||||
abort();
|
abort();
|
||||||
@ -1069,8 +1085,8 @@ MakeCallback(const Handle<Object> object,
|
|||||||
Handle<Value> argv[]) {
|
Handle<Value> argv[]) {
|
||||||
HandleScope scope(node_isolate);
|
HandleScope scope(node_isolate);
|
||||||
|
|
||||||
Handle<Value> ret =
|
Local<String> method_string = OneByteString(node_isolate, method);
|
||||||
MakeCallback(object, String::NewSymbol(method), argc, argv);
|
Handle<Value> ret = MakeCallback(object, method_string, argc, argv);
|
||||||
|
|
||||||
return scope.Close(ret);
|
return scope.Close(ret);
|
||||||
}
|
}
|
||||||
@ -1219,7 +1235,8 @@ static void ReportException(Handle<Value> er, Handle<Message> message) {
|
|||||||
|
|
||||||
DisplayExceptionLine(message);
|
DisplayExceptionLine(message);
|
||||||
|
|
||||||
Local<Value> trace_value(er->ToObject()->Get(String::New("stack")));
|
Local<Value> trace_value(
|
||||||
|
er->ToObject()->Get(FIXED_ONE_BYTE_STRING(node_isolate, "stack")));
|
||||||
String::Utf8Value trace(trace_value);
|
String::Utf8Value trace(trace_value);
|
||||||
|
|
||||||
// range errors have a trace member set to undefined
|
// range errors have a trace member set to undefined
|
||||||
@ -1229,18 +1246,27 @@ static void ReportException(Handle<Value> er, Handle<Message> message) {
|
|||||||
// this really only happens for RangeErrors, since they're the only
|
// this really only happens for RangeErrors, since they're the only
|
||||||
// kind that won't have all this info in the trace, or when non-Error
|
// kind that won't have all this info in the trace, or when non-Error
|
||||||
// objects are thrown manually.
|
// objects are thrown manually.
|
||||||
bool isErrorObject = er->IsObject() &&
|
Local<Value> message;
|
||||||
!(er->ToObject()->Get(String::New("message"))->IsUndefined()) &&
|
Local<Value> name;
|
||||||
!(er->ToObject()->Get(String::New("name"))->IsUndefined());
|
|
||||||
|
|
||||||
if (isErrorObject) {
|
if (er->IsObject()) {
|
||||||
String::Utf8Value name(er->ToObject()->Get(String::New("name")));
|
Local<Object> err_obj = er.As<Object>();
|
||||||
fprintf(stderr, "%s: ", *name);
|
message = err_obj->Get(FIXED_ONE_BYTE_STRING(node_isolate, "message"));
|
||||||
|
name = err_obj->Get(FIXED_ONE_BYTE_STRING(node_isolate, "name"));
|
||||||
}
|
}
|
||||||
|
|
||||||
String::Utf8Value msg(!isErrorObject ? er
|
if (message.IsEmpty() ||
|
||||||
: er->ToObject()->Get(String::New("message")));
|
message->IsUndefined() ||
|
||||||
fprintf(stderr, "%s\n", *msg);
|
name.IsEmpty() ||
|
||||||
|
name->IsUndefined()) {
|
||||||
|
// Not an error object. Just print as-is.
|
||||||
|
String::Utf8Value message(er);
|
||||||
|
fprintf(stderr, "%s\n", *message);
|
||||||
|
} else {
|
||||||
|
String::Utf8Value name_string(name);
|
||||||
|
String::Utf8Value message_string(message);
|
||||||
|
fprintf(stderr, "%s: %s\n", *name_string, *message_string);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
fflush(stderr);
|
fflush(stderr);
|
||||||
@ -1303,7 +1329,7 @@ void GetActiveHandles(const FunctionCallbackInfo<Value>& args) {
|
|||||||
QUEUE* q = NULL;
|
QUEUE* q = NULL;
|
||||||
int i = 0;
|
int i = 0;
|
||||||
|
|
||||||
Local<String> owner_sym = String::New("owner");
|
Local<String> owner_sym = FIXED_ONE_BYTE_STRING(node_isolate, "owner");
|
||||||
|
|
||||||
QUEUE_FOREACH(q, &handle_wrap_queue) {
|
QUEUE_FOREACH(q, &handle_wrap_queue) {
|
||||||
HandleWrap* w = container_of(q, HandleWrap, handle_wrap_queue_);
|
HandleWrap* w = container_of(q, HandleWrap, handle_wrap_queue_);
|
||||||
@ -1353,7 +1379,7 @@ static void Cwd(const FunctionCallbackInfo<Value>& args) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
buf[ARRAY_SIZE(buf) - 1] = '\0';
|
buf[ARRAY_SIZE(buf) - 1] = '\0';
|
||||||
Local<String> cwd = String::New(buf);
|
Local<String> cwd = String::NewFromUtf8(node_isolate, buf);
|
||||||
|
|
||||||
args.GetReturnValue().Set(cwd);
|
args.GetReturnValue().Set(cwd);
|
||||||
}
|
}
|
||||||
@ -1687,9 +1713,9 @@ void MemoryUsage(const FunctionCallbackInfo<Value>& args) {
|
|||||||
Local<Object> info = Object::New();
|
Local<Object> info = Object::New();
|
||||||
|
|
||||||
if (rss_symbol.IsEmpty()) {
|
if (rss_symbol.IsEmpty()) {
|
||||||
rss_symbol = String::New("rss");
|
rss_symbol = FIXED_ONE_BYTE_STRING(node_isolate, "rss");
|
||||||
heap_total_symbol = String::New("heapTotal");
|
heap_total_symbol = FIXED_ONE_BYTE_STRING(node_isolate, "heapTotal");
|
||||||
heap_used_symbol = String::New("heapUsed");
|
heap_used_symbol = FIXED_ONE_BYTE_STRING(node_isolate, "heapUsed");
|
||||||
}
|
}
|
||||||
|
|
||||||
info->Set(rss_symbol, Number::New(rss));
|
info->Set(rss_symbol, Number::New(rss));
|
||||||
@ -1770,12 +1796,12 @@ void DLOpen(const FunctionCallbackInfo<Value>& args) {
|
|||||||
String::Utf8Value filename(args[1]); // Cast
|
String::Utf8Value filename(args[1]); // Cast
|
||||||
|
|
||||||
if (exports_symbol.IsEmpty()) {
|
if (exports_symbol.IsEmpty()) {
|
||||||
exports_symbol = String::New("exports");
|
exports_symbol = FIXED_ONE_BYTE_STRING(node_isolate, "exports");
|
||||||
}
|
}
|
||||||
Local<Object> exports = module->Get(exports_symbol)->ToObject();
|
Local<Object> exports = module->Get(exports_symbol)->ToObject();
|
||||||
|
|
||||||
if (uv_dlopen(*filename, &lib)) {
|
if (uv_dlopen(*filename, &lib)) {
|
||||||
Local<String> errmsg = String::New(uv_dlerror(&lib));
|
Local<String> errmsg = OneByteString(node_isolate, uv_dlerror(&lib));
|
||||||
#ifdef _WIN32
|
#ifdef _WIN32
|
||||||
// Windows needs to add the filename into the error message
|
// Windows needs to add the filename into the error message
|
||||||
errmsg = String::Concat(errmsg, args[1]->ToString());
|
errmsg = String::Concat(errmsg, args[1]->ToString());
|
||||||
@ -1870,8 +1896,10 @@ NO_RETURN void FatalError(const char* location, const char* message) {
|
|||||||
void FatalException(Handle<Value> error, Handle<Message> message) {
|
void FatalException(Handle<Value> error, Handle<Message> message) {
|
||||||
HandleScope scope(node_isolate);
|
HandleScope scope(node_isolate);
|
||||||
|
|
||||||
if (fatal_exception_symbol.IsEmpty())
|
if (fatal_exception_symbol.IsEmpty()) {
|
||||||
fatal_exception_symbol = String::New("_fatalException");
|
fatal_exception_symbol =
|
||||||
|
FIXED_ONE_BYTE_STRING(node_isolate, "_fatalException");
|
||||||
|
}
|
||||||
|
|
||||||
Local<Object> process = PersistentToLocal(node_isolate, process_p);
|
Local<Object> process = PersistentToLocal(node_isolate, process_p);
|
||||||
Local<Value> fatal_v = process->Get(fatal_exception_symbol);
|
Local<Value> fatal_v = process->Get(fatal_exception_symbol);
|
||||||
@ -1943,7 +1971,7 @@ static void Binding(const FunctionCallbackInfo<Value>& args) {
|
|||||||
|
|
||||||
Local<Array> modules = PersistentToLocal(node_isolate, module_load_list);
|
Local<Array> modules = PersistentToLocal(node_isolate, module_load_list);
|
||||||
uint32_t l = modules->Length();
|
uint32_t l = modules->Length();
|
||||||
modules->Set(l, String::New(buf));
|
modules->Set(l, OneByteString(node_isolate, buf));
|
||||||
|
|
||||||
if ((modp = get_builtin_module(*module_v)) != NULL) {
|
if ((modp = get_builtin_module(*module_v)) != NULL) {
|
||||||
exports = Object::New();
|
exports = Object::New();
|
||||||
@ -1972,7 +2000,7 @@ static void ProcessTitleGetter(Local<String> property,
|
|||||||
HandleScope scope(node_isolate);
|
HandleScope scope(node_isolate);
|
||||||
char buffer[512];
|
char buffer[512];
|
||||||
uv_get_process_title(buffer, sizeof(buffer));
|
uv_get_process_title(buffer, sizeof(buffer));
|
||||||
info.GetReturnValue().Set(String::New(buffer));
|
info.GetReturnValue().Set(String::NewFromUtf8(node_isolate, buffer));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@ -1993,7 +2021,7 @@ static void EnvGetter(Local<String> property,
|
|||||||
String::Utf8Value key(property);
|
String::Utf8Value key(property);
|
||||||
const char* val = getenv(*key);
|
const char* val = getenv(*key);
|
||||||
if (val) {
|
if (val) {
|
||||||
return info.GetReturnValue().Set(String::New(val));
|
return info.GetReturnValue().Set(String::NewFromUtf8(node_isolate, val));
|
||||||
}
|
}
|
||||||
#else // _WIN32
|
#else // _WIN32
|
||||||
String::Value key(property);
|
String::Value key(property);
|
||||||
@ -2006,8 +2034,9 @@ static void EnvGetter(Local<String> property,
|
|||||||
// not found.
|
// not found.
|
||||||
if ((result > 0 || GetLastError() == ERROR_SUCCESS) &&
|
if ((result > 0 || GetLastError() == ERROR_SUCCESS) &&
|
||||||
result < ARRAY_SIZE(buffer)) {
|
result < ARRAY_SIZE(buffer)) {
|
||||||
return info.GetReturnValue().Set(
|
const uint16_t* two_byte_buffer = reinterpret_cast<const uint16_t*>(buffer);
|
||||||
String::New(reinterpret_cast<uint16_t*>(buffer), result));
|
Local<String> rc = String::NewFromTwoByte(node_isolate, two_byte_buffer);
|
||||||
|
return info.GetReturnValue().Set(rc);
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
// Not found. Fetch from prototype.
|
// Not found. Fetch from prototype.
|
||||||
@ -2097,7 +2126,11 @@ static void EnvEnumerator(const PropertyCallbackInfo<Array>& info) {
|
|||||||
const char* var = environ[i];
|
const char* var = environ[i];
|
||||||
const char* s = strchr(var, '=');
|
const char* s = strchr(var, '=');
|
||||||
const int length = s ? s - var : strlen(var);
|
const int length = s ? s - var : strlen(var);
|
||||||
env->Set(i, String::New(var, length));
|
Local<String> name = String::NewFromUtf8(node_isolate,
|
||||||
|
var,
|
||||||
|
String::kNormalString,
|
||||||
|
length);
|
||||||
|
env->Set(i, name);
|
||||||
}
|
}
|
||||||
#else // _WIN32
|
#else // _WIN32
|
||||||
WCHAR* environment = GetEnvironmentStringsW();
|
WCHAR* environment = GetEnvironmentStringsW();
|
||||||
@ -2117,7 +2150,8 @@ static void EnvEnumerator(const PropertyCallbackInfo<Array>& info) {
|
|||||||
if (!s) {
|
if (!s) {
|
||||||
s = p + wcslen(p);
|
s = p + wcslen(p);
|
||||||
}
|
}
|
||||||
env->Set(i++, String::New(reinterpret_cast<uint16_t*>(p), s - p));
|
const uint16_t* two_byte_buffer = reinterpret_cast<const uint16_t*>(p);
|
||||||
|
env->Set(i++, TWO_BYTE_STRING(node_isolate, two_byte_buffer, s - p));
|
||||||
p = s + wcslen(s) + 1;
|
p = s + wcslen(s) + 1;
|
||||||
}
|
}
|
||||||
FreeEnvironmentStringsW(environment);
|
FreeEnvironmentStringsW(environment);
|
||||||
@ -2137,14 +2171,17 @@ static Handle<Object> GetFeatures() {
|
|||||||
Local<Value> debug = False(node_isolate);
|
Local<Value> debug = False(node_isolate);
|
||||||
#endif // defined(DEBUG) && DEBUG
|
#endif // defined(DEBUG) && DEBUG
|
||||||
|
|
||||||
obj->Set(String::NewSymbol("debug"), debug);
|
obj->Set(FIXED_ONE_BYTE_STRING(node_isolate, "debug"), debug);
|
||||||
|
|
||||||
obj->Set(String::NewSymbol("uv"), True(node_isolate));
|
obj->Set(FIXED_ONE_BYTE_STRING(node_isolate, "uv"), True(node_isolate));
|
||||||
// TODO(bnoordhuis) ping libuv
|
// TODO(bnoordhuis) ping libuv
|
||||||
obj->Set(String::NewSymbol("ipv6"), True(node_isolate));
|
obj->Set(FIXED_ONE_BYTE_STRING(node_isolate, "ipv6"), True(node_isolate));
|
||||||
obj->Set(String::NewSymbol("tls_npn"), Boolean::New(use_npn));
|
|
||||||
obj->Set(String::NewSymbol("tls_sni"), Boolean::New(use_sni));
|
obj->Set(FIXED_ONE_BYTE_STRING(node_isolate, "tls_npn"),
|
||||||
obj->Set(String::NewSymbol("tls"),
|
Boolean::New(use_npn));
|
||||||
|
obj->Set(FIXED_ONE_BYTE_STRING(node_isolate, "tls_sni"),
|
||||||
|
Boolean::New(use_sni));
|
||||||
|
obj->Set(FIXED_ONE_BYTE_STRING(node_isolate, "tls"),
|
||||||
Boolean::New(get_builtin_module("crypto") != NULL));
|
Boolean::New(get_builtin_module("crypto") != NULL));
|
||||||
|
|
||||||
return scope.Close(obj);
|
return scope.Close(obj);
|
||||||
@ -2201,7 +2238,7 @@ static void NeedImmediateCallbackSetter(Local<String> property,
|
|||||||
|
|
||||||
#define READONLY_PROPERTY(obj, str, var) \
|
#define READONLY_PROPERTY(obj, str, var) \
|
||||||
do { \
|
do { \
|
||||||
obj->Set(String::New(str), var, v8::ReadOnly); \
|
obj->Set(OneByteString(node_isolate, str), var, v8::ReadOnly); \
|
||||||
} while (0)
|
} while (0)
|
||||||
|
|
||||||
|
|
||||||
@ -2211,7 +2248,8 @@ Handle<Object> SetupProcessObject(int argc, char *argv[]) {
|
|||||||
int i, j;
|
int i, j;
|
||||||
|
|
||||||
Local<FunctionTemplate> process_template = FunctionTemplate::New();
|
Local<FunctionTemplate> process_template = FunctionTemplate::New();
|
||||||
process_template->SetClassName(String::New("process"));
|
process_template->SetClassName(
|
||||||
|
FIXED_ONE_BYTE_STRING(node_isolate, "process"));
|
||||||
|
|
||||||
Local<Object> process = process_template->GetFunction()->NewInstance();
|
Local<Object> process = process_template->GetFunction()->NewInstance();
|
||||||
assert(process.IsEmpty() == false);
|
assert(process.IsEmpty() == false);
|
||||||
@ -2219,12 +2257,14 @@ Handle<Object> SetupProcessObject(int argc, char *argv[]) {
|
|||||||
|
|
||||||
process_p.Reset(node_isolate, process);
|
process_p.Reset(node_isolate, process);
|
||||||
|
|
||||||
process->SetAccessor(String::New("title"),
|
process->SetAccessor(FIXED_ONE_BYTE_STRING(node_isolate, "title"),
|
||||||
ProcessTitleGetter,
|
ProcessTitleGetter,
|
||||||
ProcessTitleSetter);
|
ProcessTitleSetter);
|
||||||
|
|
||||||
// process.version
|
// process.version
|
||||||
READONLY_PROPERTY(process, "version", String::New(NODE_VERSION));
|
READONLY_PROPERTY(process,
|
||||||
|
"version",
|
||||||
|
FIXED_ONE_BYTE_STRING(node_isolate, NODE_VERSION));
|
||||||
|
|
||||||
// process.moduleLoadList
|
// process.moduleLoadList
|
||||||
Local<Array> modules = Array::New();
|
Local<Array> modules = Array::New();
|
||||||
@ -2234,17 +2274,33 @@ Handle<Object> SetupProcessObject(int argc, char *argv[]) {
|
|||||||
// process.versions
|
// process.versions
|
||||||
Local<Object> versions = Object::New();
|
Local<Object> versions = Object::New();
|
||||||
READONLY_PROPERTY(process, "versions", versions);
|
READONLY_PROPERTY(process, "versions", versions);
|
||||||
READONLY_PROPERTY(versions, "http_parser", String::New(
|
|
||||||
NODE_STRINGIFY(HTTP_PARSER_VERSION_MAJOR) "."
|
const char http_parser_version[] = NODE_STRINGIFY(HTTP_PARSER_VERSION_MAJOR)
|
||||||
NODE_STRINGIFY(HTTP_PARSER_VERSION_MINOR)));
|
"."
|
||||||
|
NODE_STRINGIFY(HTTP_PARSER_VERSION_MINOR);
|
||||||
|
READONLY_PROPERTY(versions,
|
||||||
|
"http_parser",
|
||||||
|
FIXED_ONE_BYTE_STRING(node_isolate, http_parser_version));
|
||||||
|
|
||||||
// +1 to get rid of the leading 'v'
|
// +1 to get rid of the leading 'v'
|
||||||
READONLY_PROPERTY(versions, "node", String::New(NODE_VERSION+1));
|
READONLY_PROPERTY(versions,
|
||||||
READONLY_PROPERTY(versions, "v8", String::New(V8::GetVersion()));
|
"node",
|
||||||
READONLY_PROPERTY(versions, "uv", String::New(uv_version_string()));
|
OneByteString(node_isolate, NODE_VERSION + 1));
|
||||||
READONLY_PROPERTY(versions, "zlib", String::New(ZLIB_VERSION));
|
READONLY_PROPERTY(versions,
|
||||||
|
"v8",
|
||||||
|
OneByteString(node_isolate, V8::GetVersion()));
|
||||||
|
READONLY_PROPERTY(versions,
|
||||||
|
"uv",
|
||||||
|
OneByteString(node_isolate, uv_version_string()));
|
||||||
|
READONLY_PROPERTY(versions,
|
||||||
|
"zlib",
|
||||||
|
FIXED_ONE_BYTE_STRING(node_isolate, ZLIB_VERSION));
|
||||||
|
|
||||||
|
const char node_modules_version[] = NODE_STRINGIFY(NODE_MODULE_VERSION);
|
||||||
READONLY_PROPERTY(versions,
|
READONLY_PROPERTY(versions,
|
||||||
"modules",
|
"modules",
|
||||||
String::New(NODE_STRINGIFY(NODE_MODULE_VERSION)));
|
FIXED_ONE_BYTE_STRING(node_isolate, node_modules_version));
|
||||||
|
|
||||||
#if HAVE_OPENSSL
|
#if HAVE_OPENSSL
|
||||||
// Stupid code to slice out the version string.
|
// Stupid code to slice out the version string.
|
||||||
int c, l = strlen(OPENSSL_VERSION_TEXT);
|
int c, l = strlen(OPENSSL_VERSION_TEXT);
|
||||||
@ -2258,37 +2314,36 @@ Handle<Object> SetupProcessObject(int argc, char *argv[]) {
|
|||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
READONLY_PROPERTY(versions,
|
READONLY_PROPERTY(
|
||||||
|
versions,
|
||||||
"openssl",
|
"openssl",
|
||||||
String::New(&OPENSSL_VERSION_TEXT[i], j - i));
|
OneByteString(node_isolate, &OPENSSL_VERSION_TEXT[i], j - i));
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
// process.arch
|
// process.arch
|
||||||
READONLY_PROPERTY(process, "arch", String::New(ARCH));
|
READONLY_PROPERTY(process, "arch", OneByteString(node_isolate, ARCH));
|
||||||
|
|
||||||
// process.platform
|
// process.platform
|
||||||
READONLY_PROPERTY(process, "platform", String::New(PLATFORM));
|
READONLY_PROPERTY(process,
|
||||||
|
"platform",
|
||||||
|
OneByteString(node_isolate, PLATFORM));
|
||||||
|
|
||||||
// process.argv
|
// process.argv
|
||||||
Local<Array> arguments = Array::New(argc - option_end_index + 1);
|
Local<Array> arguments = Array::New(argc - option_end_index + 1);
|
||||||
arguments->Set(Integer::New(0, node_isolate), String::New(argv[0]));
|
arguments->Set(0, String::NewFromUtf8(node_isolate, argv[0]));
|
||||||
for (j = 1, i = option_end_index; i < argc; j++, i++) {
|
for (j = 1, i = option_end_index; i < argc; j++, i++) {
|
||||||
Local<String> arg = String::New(argv[i]);
|
arguments->Set(j, String::NewFromUtf8(node_isolate, argv[i]));
|
||||||
arguments->Set(Integer::New(j, node_isolate), arg);
|
|
||||||
}
|
}
|
||||||
// assign it
|
process->Set(FIXED_ONE_BYTE_STRING(node_isolate, "argv"), arguments);
|
||||||
process->Set(String::NewSymbol("argv"), arguments);
|
|
||||||
|
|
||||||
// process.execArgv
|
// process.execArgv
|
||||||
Local<Array> execArgv = Array::New(option_end_index - 1);
|
Local<Array> exec_argv = Array::New(option_end_index - 1);
|
||||||
for (j = 1, i = 0; j < option_end_index; j++, i++) {
|
for (j = 1, i = 0; j < option_end_index; j++, i++) {
|
||||||
execArgv->Set(Integer::New(i, node_isolate), String::New(argv[j]));
|
exec_argv->Set(i, String::NewFromUtf8(node_isolate, argv[j]));
|
||||||
}
|
}
|
||||||
// assign it
|
process->Set(FIXED_ONE_BYTE_STRING(node_isolate, "execArgv"), exec_argv);
|
||||||
process->Set(String::NewSymbol("execArgv"), execArgv);
|
|
||||||
|
|
||||||
|
|
||||||
// create process.env
|
// create process.env
|
||||||
Local<ObjectTemplate> envTemplate = ObjectTemplate::New();
|
Local<ObjectTemplate> envTemplate = ObjectTemplate::New();
|
||||||
@ -2299,17 +2354,20 @@ Handle<Object> SetupProcessObject(int argc, char *argv[]) {
|
|||||||
EnvEnumerator,
|
EnvEnumerator,
|
||||||
Object::New());
|
Object::New());
|
||||||
Local<Object> env = envTemplate->NewInstance();
|
Local<Object> env = envTemplate->NewInstance();
|
||||||
process->Set(String::NewSymbol("env"), env);
|
process->Set(FIXED_ONE_BYTE_STRING(node_isolate, "env"), env);
|
||||||
|
|
||||||
READONLY_PROPERTY(process, "pid", Integer::New(getpid(), node_isolate));
|
READONLY_PROPERTY(process, "pid", Integer::New(getpid(), node_isolate));
|
||||||
READONLY_PROPERTY(process, "features", GetFeatures());
|
READONLY_PROPERTY(process, "features", GetFeatures());
|
||||||
process->SetAccessor(String::New("_needImmediateCallback"),
|
process->SetAccessor(
|
||||||
|
FIXED_ONE_BYTE_STRING(node_isolate, "_needImmediateCallback"),
|
||||||
NeedImmediateCallbackGetter,
|
NeedImmediateCallbackGetter,
|
||||||
NeedImmediateCallbackSetter);
|
NeedImmediateCallbackSetter);
|
||||||
|
|
||||||
// -e, --eval
|
// -e, --eval
|
||||||
if (eval_string) {
|
if (eval_string) {
|
||||||
READONLY_PROPERTY(process, "_eval", String::New(eval_string));
|
READONLY_PROPERTY(process,
|
||||||
|
"_eval",
|
||||||
|
String::NewFromUtf8(node_isolate, eval_string));
|
||||||
}
|
}
|
||||||
|
|
||||||
// -p, --print
|
// -p, --print
|
||||||
@ -2337,21 +2395,25 @@ Handle<Object> SetupProcessObject(int argc, char *argv[]) {
|
|||||||
READONLY_PROPERTY(process, "traceDeprecation", True(node_isolate));
|
READONLY_PROPERTY(process, "traceDeprecation", True(node_isolate));
|
||||||
}
|
}
|
||||||
|
|
||||||
size_t size = 2*PATH_MAX;
|
size_t exec_path_len = 2 * PATH_MAX;
|
||||||
char* execPath = new char[size];
|
char* exec_path = new char[exec_path_len];
|
||||||
if (uv_exepath(execPath, &size) != 0) {
|
Local<String> exec_path_value;
|
||||||
// as a last ditch effort, fallback on argv[0] ?
|
if (uv_exepath(exec_path, &exec_path_len) == 0) {
|
||||||
process->Set(String::NewSymbol("execPath"), String::New(argv[0]));
|
exec_path_value = String::NewFromUtf8(node_isolate,
|
||||||
|
exec_path,
|
||||||
|
String::kNormalString,
|
||||||
|
exec_path_len);
|
||||||
} else {
|
} else {
|
||||||
process->Set(String::NewSymbol("execPath"), String::New(execPath, size));
|
exec_path_value = String::NewFromUtf8(node_isolate, argv[0]);
|
||||||
}
|
}
|
||||||
delete [] execPath;
|
process->Set(FIXED_ONE_BYTE_STRING(node_isolate, "execPath"),
|
||||||
|
exec_path_value);
|
||||||
|
delete[] exec_path;
|
||||||
|
|
||||||
process->SetAccessor(String::New("debugPort"),
|
process->SetAccessor(FIXED_ONE_BYTE_STRING(node_isolate, "debugPort"),
|
||||||
DebugPortGetter,
|
DebugPortGetter,
|
||||||
DebugPortSetter);
|
DebugPortSetter);
|
||||||
|
|
||||||
|
|
||||||
// define various internal methods
|
// define various internal methods
|
||||||
NODE_SET_METHOD(process, "_getActiveRequests", GetActiveRequests);
|
NODE_SET_METHOD(process, "_getActiveRequests", GetActiveRequests);
|
||||||
NODE_SET_METHOD(process, "_getActiveHandles", GetActiveHandles);
|
NODE_SET_METHOD(process, "_getActiveHandles", GetActiveHandles);
|
||||||
@ -2396,10 +2458,10 @@ Handle<Object> SetupProcessObject(int argc, char *argv[]) {
|
|||||||
info_box->SetIndexedPropertiesToExternalArrayData(&tick_infobox,
|
info_box->SetIndexedPropertiesToExternalArrayData(&tick_infobox,
|
||||||
kExternalUnsignedIntArray,
|
kExternalUnsignedIntArray,
|
||||||
4);
|
4);
|
||||||
process->Set(String::NewSymbol("_tickInfoBox"), info_box);
|
process->Set(FIXED_ONE_BYTE_STRING(node_isolate, "_tickInfoBox"), info_box);
|
||||||
|
|
||||||
// pre-set _events object for faster emit checks
|
// pre-set _events object for faster emit checks
|
||||||
process->Set(String::NewSymbol("_events"), Object::New());
|
process->Set(FIXED_ONE_BYTE_STRING(node_isolate, "_events"), Object::New());
|
||||||
|
|
||||||
return scope.Close(process);
|
return scope.Close(process);
|
||||||
}
|
}
|
||||||
@ -2422,8 +2484,8 @@ static void SignalExit(int signal) {
|
|||||||
void Load(Handle<Object> process_l) {
|
void Load(Handle<Object> process_l) {
|
||||||
HandleScope handle_scope(node_isolate);
|
HandleScope handle_scope(node_isolate);
|
||||||
|
|
||||||
process_symbol = String::New("process");
|
process_symbol = FIXED_ONE_BYTE_STRING(node_isolate, "process");
|
||||||
domain_symbol = String::New("domain");
|
domain_symbol = FIXED_ONE_BYTE_STRING(node_isolate, "domain");
|
||||||
|
|
||||||
// Compile, execute the src/node.js file. (Which was included as static C
|
// Compile, execute the src/node.js file. (Which was included as static C
|
||||||
// string in node_natives.h. 'natve_node' is the string containing that
|
// string in node_natives.h. 'natve_node' is the string containing that
|
||||||
@ -2439,7 +2501,8 @@ void Load(Handle<Object> process_l) {
|
|||||||
// are not safe to ignore.
|
// are not safe to ignore.
|
||||||
try_catch.SetVerbose(false);
|
try_catch.SetVerbose(false);
|
||||||
|
|
||||||
Local<Value> f_value = ExecuteString(MainSource(), String::New("node.js"));
|
Local<String> script_name = FIXED_ONE_BYTE_STRING(node_isolate, "node.js");
|
||||||
|
Local<Value> f_value = ExecuteString(MainSource(), script_name);
|
||||||
if (try_catch.HasCaught()) {
|
if (try_catch.HasCaught()) {
|
||||||
ReportException(try_catch);
|
ReportException(try_catch);
|
||||||
exit(10);
|
exit(10);
|
||||||
@ -2632,8 +2695,12 @@ static void DispatchMessagesDebugAgentCallback() {
|
|||||||
static void EmitDebugEnabledAsyncCallback(uv_async_t* handle, int status) {
|
static void EmitDebugEnabledAsyncCallback(uv_async_t* handle, int status) {
|
||||||
HandleScope handle_scope(node_isolate);
|
HandleScope handle_scope(node_isolate);
|
||||||
Local<Object> obj = Object::New();
|
Local<Object> obj = Object::New();
|
||||||
obj->Set(String::New("cmd"), String::New("NODE_DEBUG_ENABLED"));
|
obj->Set(FIXED_ONE_BYTE_STRING(node_isolate, "cmd"),
|
||||||
Local<Value> args[] = { String::New("internalMessage"), obj };
|
FIXED_ONE_BYTE_STRING(node_isolate, "NODE_DEBUG_ENABLED"));
|
||||||
|
Local<Value> args[] = {
|
||||||
|
FIXED_ONE_BYTE_STRING(node_isolate, "internalMessage"),
|
||||||
|
obj
|
||||||
|
};
|
||||||
MakeCallback(process_p, "emit", ARRAY_SIZE(args), args);
|
MakeCallback(process_p, "emit", ARRAY_SIZE(args), args);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -3001,8 +3068,12 @@ void AtExit(void (*cb)(void* arg), void* arg) {
|
|||||||
|
|
||||||
void EmitExit(v8::Handle<v8::Object> process_l) {
|
void EmitExit(v8::Handle<v8::Object> process_l) {
|
||||||
// process.emit('exit')
|
// process.emit('exit')
|
||||||
process_l->Set(String::NewSymbol("_exiting"), True(node_isolate));
|
process_l->Set(FIXED_ONE_BYTE_STRING(node_isolate, "_exiting"),
|
||||||
Local<Value> args[] = { String::New("exit"), Integer::New(0, node_isolate) };
|
True(node_isolate));
|
||||||
|
Local<Value> args[] = {
|
||||||
|
FIXED_ONE_BYTE_STRING(node_isolate, "exit"),
|
||||||
|
Integer::New(0, node_isolate)
|
||||||
|
};
|
||||||
MakeCallback(process_l, "emit", ARRAY_SIZE(args), args);
|
MakeCallback(process_l, "emit", ARRAY_SIZE(args), args);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
25
src/node.h
25
src/node.h
@ -129,20 +129,30 @@ void EmitExit(v8::Handle<v8::Object> process);
|
|||||||
#define NODE_UNIXTIME_V8(t) v8::Date::New(1000*static_cast<double>(t))
|
#define NODE_UNIXTIME_V8(t) v8::Date::New(1000*static_cast<double>(t))
|
||||||
#define NODE_V8_UNIXTIME(v) (static_cast<double>((v)->NumberValue())/1000.0);
|
#define NODE_V8_UNIXTIME(v) (static_cast<double>((v)->NumberValue())/1000.0);
|
||||||
|
|
||||||
|
// Used to be a macro, hence the uppercase name.
|
||||||
#define NODE_DEFINE_CONSTANT(target, constant) \
|
#define NODE_DEFINE_CONSTANT(target, constant) \
|
||||||
(target)->Set(v8::String::NewSymbol(#constant), \
|
do { \
|
||||||
v8::Number::New(constant), \
|
v8::Isolate* isolate = v8::Isolate::GetCurrent(); \
|
||||||
static_cast<v8::PropertyAttribute>( \
|
v8::Local<v8::String> constant_name = \
|
||||||
v8::ReadOnly|v8::DontDelete))
|
v8::String::NewFromUtf8(isolate, #constant); \
|
||||||
|
v8::Local<v8::Number> constant_value = \
|
||||||
|
v8::Number::New(isolate, static_cast<double>(constant)); \
|
||||||
|
v8::PropertyAttribute constant_attributes = \
|
||||||
|
static_cast<v8::PropertyAttribute>(v8::ReadOnly | v8::DontDelete); \
|
||||||
|
(target)->Set(constant_name, constant_value, constant_attributes); \
|
||||||
|
} \
|
||||||
|
while (0)
|
||||||
|
|
||||||
// Used to be a macro, hence the uppercase name.
|
// Used to be a macro, hence the uppercase name.
|
||||||
template <typename TypeName>
|
template <typename TypeName>
|
||||||
inline void NODE_SET_METHOD(const TypeName& recv,
|
inline void NODE_SET_METHOD(const TypeName& recv,
|
||||||
const char* name,
|
const char* name,
|
||||||
v8::FunctionCallback callback) {
|
v8::FunctionCallback callback) {
|
||||||
|
v8::Isolate* isolate = v8::Isolate::GetCurrent();
|
||||||
|
v8::HandleScope handle_scope(isolate);
|
||||||
v8::Local<v8::FunctionTemplate> t = v8::FunctionTemplate::New(callback);
|
v8::Local<v8::FunctionTemplate> t = v8::FunctionTemplate::New(callback);
|
||||||
v8::Local<v8::Function> fn = t->GetFunction();
|
v8::Local<v8::Function> fn = t->GetFunction();
|
||||||
v8::Local<v8::String> fn_name = v8::String::New(name);
|
v8::Local<v8::String> fn_name = v8::String::NewFromUtf8(isolate, name);
|
||||||
fn->SetName(fn_name);
|
fn->SetName(fn_name);
|
||||||
recv->Set(fn_name, fn);
|
recv->Set(fn_name, fn);
|
||||||
}
|
}
|
||||||
@ -153,8 +163,11 @@ inline void NODE_SET_METHOD(const TypeName& recv,
|
|||||||
inline void NODE_SET_PROTOTYPE_METHOD(v8::Handle<v8::FunctionTemplate> recv,
|
inline void NODE_SET_PROTOTYPE_METHOD(v8::Handle<v8::FunctionTemplate> recv,
|
||||||
const char* name,
|
const char* name,
|
||||||
v8::FunctionCallback callback) {
|
v8::FunctionCallback callback) {
|
||||||
|
v8::Isolate* isolate = v8::Isolate::GetCurrent();
|
||||||
|
v8::HandleScope handle_scope(isolate);
|
||||||
v8::Local<v8::FunctionTemplate> t = v8::FunctionTemplate::New(callback);
|
v8::Local<v8::FunctionTemplate> t = v8::FunctionTemplate::New(callback);
|
||||||
recv->PrototypeTemplate()->Set(v8::String::New(name), t->GetFunction());
|
recv->PrototypeTemplate()->Set(v8::String::NewFromUtf8(isolate, name),
|
||||||
|
t->GetFunction());
|
||||||
}
|
}
|
||||||
#define NODE_SET_PROTOTYPE_METHOD node::NODE_SET_PROTOTYPE_METHOD
|
#define NODE_SET_PROTOTYPE_METHOD node::NODE_SET_PROTOTYPE_METHOD
|
||||||
|
|
||||||
|
@ -559,13 +559,14 @@ void SetupBufferJS(const FunctionCallbackInfo<Value>& args) {
|
|||||||
|
|
||||||
Local<Function> bv = args[0].As<Function>();
|
Local<Function> bv = args[0].As<Function>();
|
||||||
p_buffer_fn.Reset(node_isolate, bv);
|
p_buffer_fn.Reset(node_isolate, bv);
|
||||||
Local<Value> proto_v = bv->Get(String::New("prototype"));
|
Local<Value> proto_v =
|
||||||
|
bv->Get(FIXED_ONE_BYTE_STRING(node_isolate, "prototype"));
|
||||||
|
|
||||||
assert(proto_v->IsObject());
|
assert(proto_v->IsObject());
|
||||||
|
|
||||||
Local<Object> proto = proto_v.As<Object>();
|
Local<Object> proto = proto_v.As<Object>();
|
||||||
|
|
||||||
bv->Set(String::New("byteLength"),
|
bv->Set(FIXED_ONE_BYTE_STRING(node_isolate, "byteLength"),
|
||||||
FunctionTemplate::New(ByteLength)->GetFunction());
|
FunctionTemplate::New(ByteLength)->GetFunction());
|
||||||
|
|
||||||
NODE_SET_METHOD(proto, "asciiSlice", AsciiSlice);
|
NODE_SET_METHOD(proto, "asciiSlice", AsciiSlice);
|
||||||
@ -596,14 +597,16 @@ void SetupBufferJS(const FunctionCallbackInfo<Value>& args) {
|
|||||||
NODE_SET_METHOD(proto, "fill", Fill);
|
NODE_SET_METHOD(proto, "fill", Fill);
|
||||||
|
|
||||||
// for backwards compatibility
|
// for backwards compatibility
|
||||||
proto->Set(String::New("offset"), Uint32::New(0, node_isolate), v8::ReadOnly);
|
proto->Set(FIXED_ONE_BYTE_STRING(node_isolate, "offset"),
|
||||||
|
Uint32::New(0, node_isolate),
|
||||||
|
v8::ReadOnly);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void Initialize(Handle<Object> target) {
|
void Initialize(Handle<Object> target) {
|
||||||
HandleScope scope(node_isolate);
|
HandleScope scope(node_isolate);
|
||||||
|
|
||||||
target->Set(String::New("setupBufferJS"),
|
target->Set(FIXED_ONE_BYTE_STRING(node_isolate, "setupBufferJS"),
|
||||||
FunctionTemplate::New(SetupBufferJS)->GetFunction());
|
FunctionTemplate::New(SetupBufferJS)->GetFunction());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -114,7 +114,7 @@ void InitPerfCounters(Handle<Object> target) {
|
|||||||
};
|
};
|
||||||
|
|
||||||
for (int i = 0; i < ARRAY_SIZE(tab); i++) {
|
for (int i = 0; i < ARRAY_SIZE(tab); i++) {
|
||||||
Local<String> key = String::New(tab[i].name);
|
Local<String> key = OneByteString(node_isolate, tab[i].name);
|
||||||
Local<Value> val = FunctionTemplate::New(tab[i].func)->GetFunction();
|
Local<Value> val = FunctionTemplate::New(tab[i].func)->GetFunction();
|
||||||
target->Set(key, val);
|
target->Set(key, val);
|
||||||
}
|
}
|
||||||
|
@ -179,7 +179,7 @@ void SecureContext::Initialize(Handle<Object> target) {
|
|||||||
secure_context_constructor.Reset(node_isolate, t);
|
secure_context_constructor.Reset(node_isolate, t);
|
||||||
|
|
||||||
t->InstanceTemplate()->SetInternalFieldCount(1);
|
t->InstanceTemplate()->SetInternalFieldCount(1);
|
||||||
t->SetClassName(String::NewSymbol("SecureContext"));
|
t->SetClassName(FIXED_ONE_BYTE_STRING(node_isolate, "SecureContext"));
|
||||||
|
|
||||||
NODE_SET_PROTOTYPE_METHOD(t, "init", SecureContext::Init);
|
NODE_SET_PROTOTYPE_METHOD(t, "init", SecureContext::Init);
|
||||||
NODE_SET_PROTOTYPE_METHOD(t, "setKey", SecureContext::SetKey);
|
NODE_SET_PROTOTYPE_METHOD(t, "setKey", SecureContext::SetKey);
|
||||||
@ -198,7 +198,8 @@ void SecureContext::Initialize(Handle<Object> target) {
|
|||||||
NODE_SET_PROTOTYPE_METHOD(t, "getTicketKeys", SecureContext::GetTicketKeys);
|
NODE_SET_PROTOTYPE_METHOD(t, "getTicketKeys", SecureContext::GetTicketKeys);
|
||||||
NODE_SET_PROTOTYPE_METHOD(t, "setTicketKeys", SecureContext::SetTicketKeys);
|
NODE_SET_PROTOTYPE_METHOD(t, "setTicketKeys", SecureContext::SetTicketKeys);
|
||||||
|
|
||||||
target->Set(String::NewSymbol("SecureContext"), t->GetFunction());
|
target->Set(FIXED_ONE_BYTE_STRING(node_isolate, "SecureContext"),
|
||||||
|
t->GetFunction());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@ -312,7 +313,7 @@ int SecureContext::NewSessionCallback(SSL* s, SSL_SESSION* sess) {
|
|||||||
};
|
};
|
||||||
|
|
||||||
if (onnewsession_sym.IsEmpty()) {
|
if (onnewsession_sym.IsEmpty()) {
|
||||||
onnewsession_sym = String::New("onnewsession");
|
onnewsession_sym = FIXED_ONE_BYTE_STRING(node_isolate, "onnewsession");
|
||||||
}
|
}
|
||||||
|
|
||||||
MakeCallback(p->handle(node_isolate),
|
MakeCallback(p->handle(node_isolate),
|
||||||
@ -647,11 +648,12 @@ void SecureContext::SetSessionIdContext(
|
|||||||
|
|
||||||
bio = BIO_new(BIO_s_mem());
|
bio = BIO_new(BIO_s_mem());
|
||||||
if (bio == NULL) {
|
if (bio == NULL) {
|
||||||
message = String::New("SSL_CTX_set_session_id_context error");
|
message = FIXED_ONE_BYTE_STRING(node_isolate,
|
||||||
|
"SSL_CTX_set_session_id_context error");
|
||||||
} else {
|
} else {
|
||||||
ERR_print_errors(bio);
|
ERR_print_errors(bio);
|
||||||
BIO_get_mem_ptr(bio, &mem);
|
BIO_get_mem_ptr(bio, &mem);
|
||||||
message = String::New(mem->data, mem->length);
|
message = OneByteString(node_isolate, mem->data, mem->length);
|
||||||
BIO_free_all(bio);
|
BIO_free_all(bio);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -800,9 +802,9 @@ void Connection::OnClientHello(void* arg,
|
|||||||
Connection* c = static_cast<Connection*>(arg);
|
Connection* c = static_cast<Connection*>(arg);
|
||||||
|
|
||||||
if (onclienthello_sym.IsEmpty())
|
if (onclienthello_sym.IsEmpty())
|
||||||
onclienthello_sym = String::New("onclienthello");
|
onclienthello_sym = FIXED_ONE_BYTE_STRING(node_isolate, "onclienthello");
|
||||||
if (sessionid_sym.IsEmpty())
|
if (sessionid_sym.IsEmpty())
|
||||||
sessionid_sym = String::New("sessionId");
|
sessionid_sym = FIXED_ONE_BYTE_STRING(node_isolate, "sessionId");
|
||||||
|
|
||||||
Local<Object> obj = Object::New();
|
Local<Object> obj = Object::New();
|
||||||
obj->Set(sessionid_sym,
|
obj->Set(sessionid_sym,
|
||||||
@ -858,8 +860,10 @@ int Connection::HandleBIOError(BIO *bio, const char* func, int rv) {
|
|||||||
ERR_error_string_n(rv, ssl_error_buf, sizeof(ssl_error_buf));
|
ERR_error_string_n(rv, ssl_error_buf, sizeof(ssl_error_buf));
|
||||||
|
|
||||||
HandleScope scope(node_isolate);
|
HandleScope scope(node_isolate);
|
||||||
Local<Value> e = Exception::Error(String::New(ssl_error_buf));
|
Local<Value> exception =
|
||||||
handle(node_isolate)->Set(String::New("error"), e);
|
Exception::Error(OneByteString(node_isolate, ssl_error_buf));
|
||||||
|
handle(node_isolate)->Set(
|
||||||
|
FIXED_ONE_BYTE_STRING(node_isolate, "error"), exception);
|
||||||
|
|
||||||
DEBUG_PRINT("[%p] BIO: %s failed: (%d) %s\n",
|
DEBUG_PRINT("[%p] BIO: %s failed: (%d) %s\n",
|
||||||
ssl_,
|
ssl_,
|
||||||
@ -898,8 +902,10 @@ int Connection::HandleSSLError(const char* func,
|
|||||||
return 0;
|
return 0;
|
||||||
|
|
||||||
} else if (err == SSL_ERROR_ZERO_RETURN) {
|
} else if (err == SSL_ERROR_ZERO_RETURN) {
|
||||||
handle(node_isolate)->Set(String::New("error"),
|
Local<Value> exception =
|
||||||
Exception::Error(String::New("ZERO_RETURN")));
|
Exception::Error(FIXED_ONE_BYTE_STRING(node_isolate, "ZERO_RETURN"));
|
||||||
|
handle(node_isolate)->Set(
|
||||||
|
FIXED_ONE_BYTE_STRING(node_isolate, "error"), exception);
|
||||||
return rv;
|
return rv;
|
||||||
|
|
||||||
} else if ((err == SSL_ERROR_SYSCALL) && (ss == kIgnoreSyscall)) {
|
} else if ((err == SSL_ERROR_SYSCALL) && (ss == kIgnoreSyscall)) {
|
||||||
@ -920,8 +926,10 @@ int Connection::HandleSSLError(const char* func,
|
|||||||
if ((bio = BIO_new(BIO_s_mem()))) {
|
if ((bio = BIO_new(BIO_s_mem()))) {
|
||||||
ERR_print_errors(bio);
|
ERR_print_errors(bio);
|
||||||
BIO_get_mem_ptr(bio, &mem);
|
BIO_get_mem_ptr(bio, &mem);
|
||||||
Local<Value> e = Exception::Error(String::New(mem->data, mem->length));
|
Local<Value> exception =
|
||||||
handle(node_isolate)->Set(String::New("error"), e);
|
Exception::Error(OneByteString(node_isolate, mem->data, mem->length));
|
||||||
|
handle(node_isolate)->Set(
|
||||||
|
FIXED_ONE_BYTE_STRING(node_isolate, "error"), exception);
|
||||||
BIO_free_all(bio);
|
BIO_free_all(bio);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -937,8 +945,9 @@ void Connection::ClearError() {
|
|||||||
HandleScope scope(node_isolate);
|
HandleScope scope(node_isolate);
|
||||||
|
|
||||||
// We should clear the error in JS-land
|
// We should clear the error in JS-land
|
||||||
assert(
|
Local<String> error_key = FIXED_ONE_BYTE_STRING(node_isolate, "error");
|
||||||
handle(node_isolate)->Get(String::New("error"))->BooleanValue() == false);
|
Local<Value> error = handle(node_isolate)->Get(error_key);
|
||||||
|
assert(error->BooleanValue() == false);
|
||||||
#endif // NDEBUG
|
#endif // NDEBUG
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -949,12 +958,15 @@ void Connection::SetShutdownFlags() {
|
|||||||
int flags = SSL_get_shutdown(ssl_);
|
int flags = SSL_get_shutdown(ssl_);
|
||||||
|
|
||||||
if (flags & SSL_SENT_SHUTDOWN) {
|
if (flags & SSL_SENT_SHUTDOWN) {
|
||||||
handle(node_isolate)->Set(String::New("sentShutdown"), True(node_isolate));
|
Local<String> sent_shutdown_key =
|
||||||
|
FIXED_ONE_BYTE_STRING(node_isolate, "sentShutdown");
|
||||||
|
handle(node_isolate)->Set(sent_shutdown_key, True(node_isolate));
|
||||||
}
|
}
|
||||||
|
|
||||||
if (flags & SSL_RECEIVED_SHUTDOWN) {
|
if (flags & SSL_RECEIVED_SHUTDOWN) {
|
||||||
handle(node_isolate)->Set(String::New("receivedShutdown"),
|
Local<String> received_shutdown_key =
|
||||||
True(node_isolate));
|
FIXED_ONE_BYTE_STRING(node_isolate, "receivedShutdown");
|
||||||
|
handle(node_isolate)->Set(received_shutdown_key, True(node_isolate));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -964,7 +976,7 @@ void Connection::Initialize(Handle<Object> target) {
|
|||||||
|
|
||||||
Local<FunctionTemplate> t = FunctionTemplate::New(Connection::New);
|
Local<FunctionTemplate> t = FunctionTemplate::New(Connection::New);
|
||||||
t->InstanceTemplate()->SetInternalFieldCount(1);
|
t->InstanceTemplate()->SetInternalFieldCount(1);
|
||||||
t->SetClassName(String::NewSymbol("Connection"));
|
t->SetClassName(FIXED_ONE_BYTE_STRING(node_isolate, "Connection"));
|
||||||
|
|
||||||
NODE_SET_PROTOTYPE_METHOD(t, "encIn", Connection::EncIn);
|
NODE_SET_PROTOTYPE_METHOD(t, "encIn", Connection::EncIn);
|
||||||
NODE_SET_PROTOTYPE_METHOD(t, "clearOut", Connection::ClearOut);
|
NODE_SET_PROTOTYPE_METHOD(t, "clearOut", Connection::ClearOut);
|
||||||
@ -1006,7 +1018,8 @@ void Connection::Initialize(Handle<Object> target) {
|
|||||||
NODE_SET_PROTOTYPE_METHOD(t, "setSNICallback", Connection::SetSNICallback);
|
NODE_SET_PROTOTYPE_METHOD(t, "setSNICallback", Connection::SetSNICallback);
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
target->Set(String::NewSymbol("Connection"), t->GetFunction());
|
target->Set(FIXED_ONE_BYTE_STRING(node_isolate, "Connection"),
|
||||||
|
t->GetFunction());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@ -1109,10 +1122,11 @@ int Connection::SelectNextProtoCallback_(SSL *s,
|
|||||||
p->selectedNPNProto_.Reset(node_isolate, Null(node_isolate));
|
p->selectedNPNProto_.Reset(node_isolate, Null(node_isolate));
|
||||||
break;
|
break;
|
||||||
case OPENSSL_NPN_NEGOTIATED:
|
case OPENSSL_NPN_NEGOTIATED:
|
||||||
p->selectedNPNProto_.Reset(
|
{
|
||||||
node_isolate,
|
Local<String> string = OneByteString(node_isolate, *out, *outlen);
|
||||||
String::New(reinterpret_cast<const char*>(*out), *outlen));
|
p->selectedNPNProto_.Reset(node_isolate, string);
|
||||||
break;
|
break;
|
||||||
|
}
|
||||||
case OPENSSL_NPN_NO_OVERLAP:
|
case OPENSSL_NPN_NO_OVERLAP:
|
||||||
p->selectedNPNProto_.Reset(node_isolate, False(node_isolate));
|
p->selectedNPNProto_.Reset(node_isolate, False(node_isolate));
|
||||||
break;
|
break;
|
||||||
@ -1133,7 +1147,8 @@ int Connection::SelectSNIContextCallback_(SSL *s, int *ad, void* arg) {
|
|||||||
const char* servername = SSL_get_servername(s, TLSEXT_NAMETYPE_host_name);
|
const char* servername = SSL_get_servername(s, TLSEXT_NAMETYPE_host_name);
|
||||||
|
|
||||||
if (servername) {
|
if (servername) {
|
||||||
p->servername_.Reset(node_isolate, String::New(servername));
|
p->servername_.Reset(node_isolate,
|
||||||
|
OneByteString(node_isolate, servername));
|
||||||
|
|
||||||
// Call the SNI callback and use its return value as context
|
// Call the SNI callback and use its return value as context
|
||||||
if (!p->sniObject_.IsEmpty()) {
|
if (!p->sniObject_.IsEmpty()) {
|
||||||
@ -1247,7 +1262,8 @@ void Connection::SSLInfoCallback(const SSL *ssl_, int where, int ret) {
|
|||||||
HandleScope scope(node_isolate);
|
HandleScope scope(node_isolate);
|
||||||
Connection* c = static_cast<Connection*>(SSL_get_app_data(ssl));
|
Connection* c = static_cast<Connection*>(SSL_get_app_data(ssl));
|
||||||
if (onhandshakestart_sym.IsEmpty()) {
|
if (onhandshakestart_sym.IsEmpty()) {
|
||||||
onhandshakestart_sym = String::New("onhandshakestart");
|
onhandshakestart_sym =
|
||||||
|
FIXED_ONE_BYTE_STRING(node_isolate, "onhandshakestart");
|
||||||
}
|
}
|
||||||
MakeCallback(c->handle(node_isolate), onhandshakestart_sym, 0, NULL);
|
MakeCallback(c->handle(node_isolate), onhandshakestart_sym, 0, NULL);
|
||||||
}
|
}
|
||||||
@ -1255,7 +1271,8 @@ void Connection::SSLInfoCallback(const SSL *ssl_, int where, int ret) {
|
|||||||
HandleScope scope(node_isolate);
|
HandleScope scope(node_isolate);
|
||||||
Connection* c = static_cast<Connection*>(SSL_get_app_data(ssl));
|
Connection* c = static_cast<Connection*>(SSL_get_app_data(ssl));
|
||||||
if (onhandshakedone_sym.IsEmpty()) {
|
if (onhandshakedone_sym.IsEmpty()) {
|
||||||
onhandshakedone_sym = String::New("onhandshakedone");
|
onhandshakedone_sym =
|
||||||
|
FIXED_ONE_BYTE_STRING(node_isolate, "onhandshakedone");
|
||||||
}
|
}
|
||||||
MakeCallback(c->handle(node_isolate), onhandshakedone_sym, 0, NULL);
|
MakeCallback(c->handle(node_isolate), onhandshakedone_sym, 0, NULL);
|
||||||
}
|
}
|
||||||
@ -1483,14 +1500,16 @@ void Connection::GetPeerCertificate(const FunctionCallbackInfo<Value>& args) {
|
|||||||
if (X509_NAME_print_ex(bio, X509_get_subject_name(peer_cert), 0,
|
if (X509_NAME_print_ex(bio, X509_get_subject_name(peer_cert), 0,
|
||||||
X509_NAME_FLAGS) > 0) {
|
X509_NAME_FLAGS) > 0) {
|
||||||
BIO_get_mem_ptr(bio, &mem);
|
BIO_get_mem_ptr(bio, &mem);
|
||||||
info->Set(subject_symbol, String::New(mem->data, mem->length));
|
info->Set(subject_symbol,
|
||||||
|
OneByteString(node_isolate, mem->data, mem->length));
|
||||||
}
|
}
|
||||||
(void) BIO_reset(bio);
|
(void) BIO_reset(bio);
|
||||||
|
|
||||||
if (X509_NAME_print_ex(bio, X509_get_issuer_name(peer_cert), 0,
|
if (X509_NAME_print_ex(bio, X509_get_issuer_name(peer_cert), 0,
|
||||||
X509_NAME_FLAGS) > 0) {
|
X509_NAME_FLAGS) > 0) {
|
||||||
BIO_get_mem_ptr(bio, &mem);
|
BIO_get_mem_ptr(bio, &mem);
|
||||||
info->Set(issuer_symbol, String::New(mem->data, mem->length));
|
info->Set(issuer_symbol,
|
||||||
|
OneByteString(node_isolate, mem->data, mem->length));
|
||||||
}
|
}
|
||||||
(void) BIO_reset(bio);
|
(void) BIO_reset(bio);
|
||||||
|
|
||||||
@ -1506,7 +1525,8 @@ void Connection::GetPeerCertificate(const FunctionCallbackInfo<Value>& args) {
|
|||||||
assert(rv == 1);
|
assert(rv == 1);
|
||||||
|
|
||||||
BIO_get_mem_ptr(bio, &mem);
|
BIO_get_mem_ptr(bio, &mem);
|
||||||
info->Set(subjectaltname_symbol, String::New(mem->data, mem->length));
|
info->Set(subjectaltname_symbol,
|
||||||
|
OneByteString(node_isolate, mem->data, mem->length));
|
||||||
|
|
||||||
(void) BIO_reset(bio);
|
(void) BIO_reset(bio);
|
||||||
}
|
}
|
||||||
@ -1517,12 +1537,14 @@ void Connection::GetPeerCertificate(const FunctionCallbackInfo<Value>& args) {
|
|||||||
NULL != (rsa = EVP_PKEY_get1_RSA(pkey))) {
|
NULL != (rsa = EVP_PKEY_get1_RSA(pkey))) {
|
||||||
BN_print(bio, rsa->n);
|
BN_print(bio, rsa->n);
|
||||||
BIO_get_mem_ptr(bio, &mem);
|
BIO_get_mem_ptr(bio, &mem);
|
||||||
info->Set(modulus_symbol, String::New(mem->data, mem->length) );
|
info->Set(modulus_symbol,
|
||||||
|
OneByteString(node_isolate, mem->data, mem->length));
|
||||||
(void) BIO_reset(bio);
|
(void) BIO_reset(bio);
|
||||||
|
|
||||||
BN_print(bio, rsa->e);
|
BN_print(bio, rsa->e);
|
||||||
BIO_get_mem_ptr(bio, &mem);
|
BIO_get_mem_ptr(bio, &mem);
|
||||||
info->Set(exponent_symbol, String::New(mem->data, mem->length) );
|
info->Set(exponent_symbol,
|
||||||
|
OneByteString(node_isolate, mem->data, mem->length));
|
||||||
(void) BIO_reset(bio);
|
(void) BIO_reset(bio);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -1537,12 +1559,14 @@ void Connection::GetPeerCertificate(const FunctionCallbackInfo<Value>& args) {
|
|||||||
|
|
||||||
ASN1_TIME_print(bio, X509_get_notBefore(peer_cert));
|
ASN1_TIME_print(bio, X509_get_notBefore(peer_cert));
|
||||||
BIO_get_mem_ptr(bio, &mem);
|
BIO_get_mem_ptr(bio, &mem);
|
||||||
info->Set(valid_from_symbol, String::New(mem->data, mem->length));
|
info->Set(valid_from_symbol,
|
||||||
|
OneByteString(node_isolate, mem->data, mem->length));
|
||||||
(void) BIO_reset(bio);
|
(void) BIO_reset(bio);
|
||||||
|
|
||||||
ASN1_TIME_print(bio, X509_get_notAfter(peer_cert));
|
ASN1_TIME_print(bio, X509_get_notAfter(peer_cert));
|
||||||
BIO_get_mem_ptr(bio, &mem);
|
BIO_get_mem_ptr(bio, &mem);
|
||||||
info->Set(valid_to_symbol, String::New(mem->data, mem->length));
|
info->Set(valid_to_symbol,
|
||||||
|
OneByteString(node_isolate, mem->data, mem->length));
|
||||||
BIO_free_all(bio);
|
BIO_free_all(bio);
|
||||||
|
|
||||||
unsigned int md_size, i;
|
unsigned int md_size, i;
|
||||||
@ -1563,7 +1587,7 @@ void Connection::GetPeerCertificate(const FunctionCallbackInfo<Value>& args) {
|
|||||||
fingerprint[0] = '\0';
|
fingerprint[0] = '\0';
|
||||||
}
|
}
|
||||||
|
|
||||||
info->Set(fingerprint_symbol, String::New(fingerprint));
|
info->Set(fingerprint_symbol, OneByteString(node_isolate, fingerprint));
|
||||||
}
|
}
|
||||||
|
|
||||||
STACK_OF(ASN1_OBJECT) *eku = (STACK_OF(ASN1_OBJECT) *)X509_get_ext_d2i(
|
STACK_OF(ASN1_OBJECT) *eku = (STACK_OF(ASN1_OBJECT) *)X509_get_ext_d2i(
|
||||||
@ -1575,7 +1599,8 @@ void Connection::GetPeerCertificate(const FunctionCallbackInfo<Value>& args) {
|
|||||||
for (int i = 0; i < sk_ASN1_OBJECT_num(eku); i++) {
|
for (int i = 0; i < sk_ASN1_OBJECT_num(eku); i++) {
|
||||||
memset(buf, 0, sizeof(buf));
|
memset(buf, 0, sizeof(buf));
|
||||||
OBJ_obj2txt(buf, sizeof(buf) - 1, sk_ASN1_OBJECT_value(eku, i), 1);
|
OBJ_obj2txt(buf, sizeof(buf) - 1, sk_ASN1_OBJECT_value(eku, i), 1);
|
||||||
ext_key_usage->Set(Integer::New(i, node_isolate), String::New(buf));
|
ext_key_usage->Set(Integer::New(i, node_isolate),
|
||||||
|
OneByteString(node_isolate, buf));
|
||||||
}
|
}
|
||||||
|
|
||||||
sk_ASN1_OBJECT_pop_free(eku, ASN1_OBJECT_free);
|
sk_ASN1_OBJECT_pop_free(eku, ASN1_OBJECT_free);
|
||||||
@ -1748,8 +1773,10 @@ void Connection::VerifyError(const FunctionCallbackInfo<Value>& args) {
|
|||||||
// We requested a certificate and they did not send us one.
|
// We requested a certificate and they did not send us one.
|
||||||
// Definitely an error.
|
// Definitely an error.
|
||||||
// XXX is this the right error message?
|
// XXX is this the right error message?
|
||||||
return args.GetReturnValue().Set(
|
Local<String> error_message =
|
||||||
Exception::Error(String::New("UNABLE_TO_GET_ISSUER_CERT")));
|
FIXED_ONE_BYTE_STRING(node_isolate, "UNABLE_TO_GET_ISSUER_CERT");
|
||||||
|
Local<Value> exception = Exception::Error(error_message);
|
||||||
|
return args.GetReturnValue().Set(exception);
|
||||||
}
|
}
|
||||||
X509_free(peer_cert);
|
X509_free(peer_cert);
|
||||||
|
|
||||||
@ -1762,115 +1789,121 @@ void Connection::VerifyError(const FunctionCallbackInfo<Value>& args) {
|
|||||||
break;
|
break;
|
||||||
|
|
||||||
case X509_V_ERR_UNABLE_TO_GET_ISSUER_CERT:
|
case X509_V_ERR_UNABLE_TO_GET_ISSUER_CERT:
|
||||||
s = String::New("UNABLE_TO_GET_ISSUER_CERT");
|
s = FIXED_ONE_BYTE_STRING(node_isolate, "UNABLE_TO_GET_ISSUER_CERT");
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case X509_V_ERR_UNABLE_TO_GET_CRL:
|
case X509_V_ERR_UNABLE_TO_GET_CRL:
|
||||||
s = String::New("UNABLE_TO_GET_CRL");
|
s = FIXED_ONE_BYTE_STRING(node_isolate, "UNABLE_TO_GET_CRL");
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case X509_V_ERR_UNABLE_TO_DECRYPT_CERT_SIGNATURE:
|
case X509_V_ERR_UNABLE_TO_DECRYPT_CERT_SIGNATURE:
|
||||||
s = String::New("UNABLE_TO_DECRYPT_CERT_SIGNATURE");
|
s = FIXED_ONE_BYTE_STRING(node_isolate,
|
||||||
|
"UNABLE_TO_DECRYPT_CERT_SIGNATURE");
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case X509_V_ERR_UNABLE_TO_DECRYPT_CRL_SIGNATURE:
|
case X509_V_ERR_UNABLE_TO_DECRYPT_CRL_SIGNATURE:
|
||||||
s = String::New("UNABLE_TO_DECRYPT_CRL_SIGNATURE");
|
s = FIXED_ONE_BYTE_STRING(node_isolate,
|
||||||
|
"UNABLE_TO_DECRYPT_CRL_SIGNATURE");
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case X509_V_ERR_UNABLE_TO_DECODE_ISSUER_PUBLIC_KEY:
|
case X509_V_ERR_UNABLE_TO_DECODE_ISSUER_PUBLIC_KEY:
|
||||||
s = String::New("UNABLE_TO_DECODE_ISSUER_PUBLIC_KEY");
|
s = FIXED_ONE_BYTE_STRING(node_isolate,
|
||||||
|
"UNABLE_TO_DECODE_ISSUER_PUBLIC_KEY");
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case X509_V_ERR_CERT_SIGNATURE_FAILURE:
|
case X509_V_ERR_CERT_SIGNATURE_FAILURE:
|
||||||
s = String::New("CERT_SIGNATURE_FAILURE");
|
s = FIXED_ONE_BYTE_STRING(node_isolate, "CERT_SIGNATURE_FAILURE");
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case X509_V_ERR_CRL_SIGNATURE_FAILURE:
|
case X509_V_ERR_CRL_SIGNATURE_FAILURE:
|
||||||
s = String::New("CRL_SIGNATURE_FAILURE");
|
s = FIXED_ONE_BYTE_STRING(node_isolate, "CRL_SIGNATURE_FAILURE");
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case X509_V_ERR_CERT_NOT_YET_VALID:
|
case X509_V_ERR_CERT_NOT_YET_VALID:
|
||||||
s = String::New("CERT_NOT_YET_VALID");
|
s = FIXED_ONE_BYTE_STRING(node_isolate, "CERT_NOT_YET_VALID");
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case X509_V_ERR_CERT_HAS_EXPIRED:
|
case X509_V_ERR_CERT_HAS_EXPIRED:
|
||||||
s = String::New("CERT_HAS_EXPIRED");
|
s = FIXED_ONE_BYTE_STRING(node_isolate, "CERT_HAS_EXPIRED");
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case X509_V_ERR_CRL_NOT_YET_VALID:
|
case X509_V_ERR_CRL_NOT_YET_VALID:
|
||||||
s = String::New("CRL_NOT_YET_VALID");
|
s = FIXED_ONE_BYTE_STRING(node_isolate, "CRL_NOT_YET_VALID");
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case X509_V_ERR_CRL_HAS_EXPIRED:
|
case X509_V_ERR_CRL_HAS_EXPIRED:
|
||||||
s = String::New("CRL_HAS_EXPIRED");
|
s = FIXED_ONE_BYTE_STRING(node_isolate, "CRL_HAS_EXPIRED");
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case X509_V_ERR_ERROR_IN_CERT_NOT_BEFORE_FIELD:
|
case X509_V_ERR_ERROR_IN_CERT_NOT_BEFORE_FIELD:
|
||||||
s = String::New("ERROR_IN_CERT_NOT_BEFORE_FIELD");
|
s = FIXED_ONE_BYTE_STRING(node_isolate, "ERROR_IN_CERT_NOT_BEFORE_FIELD");
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case X509_V_ERR_ERROR_IN_CERT_NOT_AFTER_FIELD:
|
case X509_V_ERR_ERROR_IN_CERT_NOT_AFTER_FIELD:
|
||||||
s = String::New("ERROR_IN_CERT_NOT_AFTER_FIELD");
|
s = FIXED_ONE_BYTE_STRING(node_isolate, "ERROR_IN_CERT_NOT_AFTER_FIELD");
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case X509_V_ERR_ERROR_IN_CRL_LAST_UPDATE_FIELD:
|
case X509_V_ERR_ERROR_IN_CRL_LAST_UPDATE_FIELD:
|
||||||
s = String::New("ERROR_IN_CRL_LAST_UPDATE_FIELD");
|
s = FIXED_ONE_BYTE_STRING(node_isolate, "ERROR_IN_CRL_LAST_UPDATE_FIELD");
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case X509_V_ERR_ERROR_IN_CRL_NEXT_UPDATE_FIELD:
|
case X509_V_ERR_ERROR_IN_CRL_NEXT_UPDATE_FIELD:
|
||||||
s = String::New("ERROR_IN_CRL_NEXT_UPDATE_FIELD");
|
s = FIXED_ONE_BYTE_STRING(node_isolate, "ERROR_IN_CRL_NEXT_UPDATE_FIELD");
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case X509_V_ERR_OUT_OF_MEM:
|
case X509_V_ERR_OUT_OF_MEM:
|
||||||
s = String::New("OUT_OF_MEM");
|
s = FIXED_ONE_BYTE_STRING(node_isolate, "OUT_OF_MEM");
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case X509_V_ERR_DEPTH_ZERO_SELF_SIGNED_CERT:
|
case X509_V_ERR_DEPTH_ZERO_SELF_SIGNED_CERT:
|
||||||
s = String::New("DEPTH_ZERO_SELF_SIGNED_CERT");
|
s = FIXED_ONE_BYTE_STRING(node_isolate, "DEPTH_ZERO_SELF_SIGNED_CERT");
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case X509_V_ERR_SELF_SIGNED_CERT_IN_CHAIN:
|
case X509_V_ERR_SELF_SIGNED_CERT_IN_CHAIN:
|
||||||
s = String::New("SELF_SIGNED_CERT_IN_CHAIN");
|
s = FIXED_ONE_BYTE_STRING(node_isolate, "SELF_SIGNED_CERT_IN_CHAIN");
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case X509_V_ERR_UNABLE_TO_GET_ISSUER_CERT_LOCALLY:
|
case X509_V_ERR_UNABLE_TO_GET_ISSUER_CERT_LOCALLY:
|
||||||
s = String::New("UNABLE_TO_GET_ISSUER_CERT_LOCALLY");
|
s = FIXED_ONE_BYTE_STRING(node_isolate,
|
||||||
|
"UNABLE_TO_GET_ISSUER_CERT_LOCALLY");
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case X509_V_ERR_UNABLE_TO_VERIFY_LEAF_SIGNATURE:
|
case X509_V_ERR_UNABLE_TO_VERIFY_LEAF_SIGNATURE:
|
||||||
s = String::New("UNABLE_TO_VERIFY_LEAF_SIGNATURE");
|
s = FIXED_ONE_BYTE_STRING(node_isolate,
|
||||||
|
"UNABLE_TO_VERIFY_LEAF_SIGNATURE");
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case X509_V_ERR_CERT_CHAIN_TOO_LONG:
|
case X509_V_ERR_CERT_CHAIN_TOO_LONG:
|
||||||
s = String::New("CERT_CHAIN_TOO_LONG");
|
s = FIXED_ONE_BYTE_STRING(node_isolate, "CERT_CHAIN_TOO_LONG");
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case X509_V_ERR_CERT_REVOKED:
|
case X509_V_ERR_CERT_REVOKED:
|
||||||
s = String::New("CERT_REVOKED");
|
s = FIXED_ONE_BYTE_STRING(node_isolate, "CERT_REVOKED");
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case X509_V_ERR_INVALID_CA:
|
case X509_V_ERR_INVALID_CA:
|
||||||
s = String::New("INVALID_CA");
|
s = FIXED_ONE_BYTE_STRING(node_isolate, "INVALID_CA");
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case X509_V_ERR_PATH_LENGTH_EXCEEDED:
|
case X509_V_ERR_PATH_LENGTH_EXCEEDED:
|
||||||
s = String::New("PATH_LENGTH_EXCEEDED");
|
s = FIXED_ONE_BYTE_STRING(node_isolate, "PATH_LENGTH_EXCEEDED");
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case X509_V_ERR_INVALID_PURPOSE:
|
case X509_V_ERR_INVALID_PURPOSE:
|
||||||
s = String::New("INVALID_PURPOSE");
|
s = FIXED_ONE_BYTE_STRING(node_isolate, "INVALID_PURPOSE");
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case X509_V_ERR_CERT_UNTRUSTED:
|
case X509_V_ERR_CERT_UNTRUSTED:
|
||||||
s = String::New("CERT_UNTRUSTED");
|
s = FIXED_ONE_BYTE_STRING(node_isolate, "CERT_UNTRUSTED");
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case X509_V_ERR_CERT_REJECTED:
|
case X509_V_ERR_CERT_REJECTED:
|
||||||
s = String::New("CERT_REJECTED");
|
s = FIXED_ONE_BYTE_STRING(node_isolate, "CERT_REJECTED");
|
||||||
break;
|
break;
|
||||||
|
|
||||||
default:
|
default:
|
||||||
s = String::New(X509_verify_cert_error_string(x509_verify_error));
|
s = OneByteString(node_isolate,
|
||||||
|
X509_verify_cert_error_string(x509_verify_error));
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -1893,9 +1926,9 @@ void Connection::GetCurrentCipher(const FunctionCallbackInfo<Value>& args) {
|
|||||||
if (c == NULL) return;
|
if (c == NULL) return;
|
||||||
Local<Object> info = Object::New();
|
Local<Object> info = Object::New();
|
||||||
const char* cipher_name = SSL_CIPHER_get_name(c);
|
const char* cipher_name = SSL_CIPHER_get_name(c);
|
||||||
info->Set(name_symbol, String::New(cipher_name));
|
info->Set(name_symbol, OneByteString(node_isolate, cipher_name));
|
||||||
const char* cipher_version = SSL_CIPHER_get_version(c);
|
const char* cipher_version = SSL_CIPHER_get_version(c);
|
||||||
info->Set(version_symbol, String::New(cipher_version));
|
info->Set(version_symbol, OneByteString(node_isolate, cipher_version));
|
||||||
args.GetReturnValue().Set(info);
|
args.GetReturnValue().Set(info);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -1929,7 +1962,7 @@ void Connection::GetNegotiatedProto(const FunctionCallbackInfo<Value>& args) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
args.GetReturnValue().Set(
|
args.GetReturnValue().Set(
|
||||||
String::New(reinterpret_cast<const char*>(npn_proto), npn_proto_len));
|
OneByteString(node_isolate, npn_proto, npn_proto_len));
|
||||||
} else {
|
} else {
|
||||||
args.GetReturnValue().Set(ss->selectedNPNProto_);
|
args.GetReturnValue().Set(ss->selectedNPNProto_);
|
||||||
}
|
}
|
||||||
@ -1974,7 +2007,7 @@ void Connection::SetSNICallback(const FunctionCallbackInfo<Value>& args) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
Local<Object> obj = Object::New();
|
Local<Object> obj = Object::New();
|
||||||
obj->Set(String::New("onselect"), args[0]);
|
obj->Set(FIXED_ONE_BYTE_STRING(node_isolate, "onselect"), args[0]);
|
||||||
ss->sniObject_.Reset(node_isolate, obj);
|
ss->sniObject_.Reset(node_isolate, obj);
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
@ -1993,7 +2026,8 @@ void CipherBase::Initialize(Handle<Object> target) {
|
|||||||
NODE_SET_PROTOTYPE_METHOD(t, "final", Final);
|
NODE_SET_PROTOTYPE_METHOD(t, "final", Final);
|
||||||
NODE_SET_PROTOTYPE_METHOD(t, "setAutoPadding", SetAutoPadding);
|
NODE_SET_PROTOTYPE_METHOD(t, "setAutoPadding", SetAutoPadding);
|
||||||
|
|
||||||
target->Set(String::NewSymbol("CipherBase"), t->GetFunction());
|
target->Set(FIXED_ONE_BYTE_STRING(node_isolate, "CipherBase"),
|
||||||
|
t->GetFunction());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@ -2232,7 +2266,7 @@ void Hmac::Initialize(v8::Handle<v8::Object> target) {
|
|||||||
NODE_SET_PROTOTYPE_METHOD(t, "update", HmacUpdate);
|
NODE_SET_PROTOTYPE_METHOD(t, "update", HmacUpdate);
|
||||||
NODE_SET_PROTOTYPE_METHOD(t, "digest", HmacDigest);
|
NODE_SET_PROTOTYPE_METHOD(t, "digest", HmacDigest);
|
||||||
|
|
||||||
target->Set(String::NewSymbol("Hmac"), t->GetFunction());
|
target->Set(FIXED_ONE_BYTE_STRING(node_isolate, "Hmac"), t->GetFunction());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@ -2363,7 +2397,7 @@ void Hash::Initialize(v8::Handle<v8::Object> target) {
|
|||||||
NODE_SET_PROTOTYPE_METHOD(t, "update", HashUpdate);
|
NODE_SET_PROTOTYPE_METHOD(t, "update", HashUpdate);
|
||||||
NODE_SET_PROTOTYPE_METHOD(t, "digest", HashDigest);
|
NODE_SET_PROTOTYPE_METHOD(t, "digest", HashDigest);
|
||||||
|
|
||||||
target->Set(String::NewSymbol("Hash"), t->GetFunction());
|
target->Set(FIXED_ONE_BYTE_STRING(node_isolate, "Hash"), t->GetFunction());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@ -2473,7 +2507,7 @@ void Sign::Initialize(v8::Handle<v8::Object> target) {
|
|||||||
NODE_SET_PROTOTYPE_METHOD(t, "update", SignUpdate);
|
NODE_SET_PROTOTYPE_METHOD(t, "update", SignUpdate);
|
||||||
NODE_SET_PROTOTYPE_METHOD(t, "sign", SignFinal);
|
NODE_SET_PROTOTYPE_METHOD(t, "sign", SignFinal);
|
||||||
|
|
||||||
target->Set(String::NewSymbol("Sign"), t->GetFunction());
|
target->Set(FIXED_ONE_BYTE_STRING(node_isolate, "Sign"), t->GetFunction());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@ -2618,7 +2652,7 @@ void Verify::Initialize(v8::Handle<v8::Object> target) {
|
|||||||
NODE_SET_PROTOTYPE_METHOD(t, "update", VerifyUpdate);
|
NODE_SET_PROTOTYPE_METHOD(t, "update", VerifyUpdate);
|
||||||
NODE_SET_PROTOTYPE_METHOD(t, "verify", VerifyFinal);
|
NODE_SET_PROTOTYPE_METHOD(t, "verify", VerifyFinal);
|
||||||
|
|
||||||
target->Set(String::NewSymbol("Verify"), t->GetFunction());
|
target->Set(FIXED_ONE_BYTE_STRING(node_isolate, "Verify"), t->GetFunction());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@ -2826,7 +2860,8 @@ void DiffieHellman::Initialize(v8::Handle<v8::Object> target) {
|
|||||||
NODE_SET_PROTOTYPE_METHOD(t, "setPublicKey", SetPublicKey);
|
NODE_SET_PROTOTYPE_METHOD(t, "setPublicKey", SetPublicKey);
|
||||||
NODE_SET_PROTOTYPE_METHOD(t, "setPrivateKey", SetPrivateKey);
|
NODE_SET_PROTOTYPE_METHOD(t, "setPrivateKey", SetPrivateKey);
|
||||||
|
|
||||||
target->Set(String::NewSymbol("DiffieHellman"), t->GetFunction());
|
target->Set(FIXED_ONE_BYTE_STRING(node_isolate, "DiffieHellman"),
|
||||||
|
t->GetFunction());
|
||||||
|
|
||||||
Local<FunctionTemplate> t2 = FunctionTemplate::New(DiffieHellmanGroup);
|
Local<FunctionTemplate> t2 = FunctionTemplate::New(DiffieHellmanGroup);
|
||||||
t2->InstanceTemplate()->SetInternalFieldCount(1);
|
t2->InstanceTemplate()->SetInternalFieldCount(1);
|
||||||
@ -2838,7 +2873,8 @@ void DiffieHellman::Initialize(v8::Handle<v8::Object> target) {
|
|||||||
NODE_SET_PROTOTYPE_METHOD(t2, "getPublicKey", GetPublicKey);
|
NODE_SET_PROTOTYPE_METHOD(t2, "getPublicKey", GetPublicKey);
|
||||||
NODE_SET_PROTOTYPE_METHOD(t2, "getPrivateKey", GetPrivateKey);
|
NODE_SET_PROTOTYPE_METHOD(t2, "getPrivateKey", GetPrivateKey);
|
||||||
|
|
||||||
target->Set(String::NewSymbol("DiffieHellmanGroup"), t2->GetFunction());
|
target->Set(FIXED_ONE_BYTE_STRING(node_isolate, "DiffieHellmanGroup"),
|
||||||
|
t2->GetFunction());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@ -3201,7 +3237,8 @@ void EIO_PBKDF2After(pbkdf2_req* req, Local<Value> argv[2]) {
|
|||||||
argv[1] = Encode(req->key, req->keylen, BUFFER);
|
argv[1] = Encode(req->key, req->keylen, BUFFER);
|
||||||
memset(req->key, 0, req->keylen);
|
memset(req->key, 0, req->keylen);
|
||||||
} else {
|
} else {
|
||||||
argv[0] = Exception::Error(String::New("PBKDF2 error"));
|
argv[0] = Exception::Error(
|
||||||
|
FIXED_ONE_BYTE_STRING(node_isolate, "PBKDF2 error"));
|
||||||
argv[1] = Undefined(node_isolate);
|
argv[1] = Undefined(node_isolate);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -3302,7 +3339,7 @@ void PBKDF2(const FunctionCallbackInfo<Value>& args) {
|
|||||||
|
|
||||||
if (args[4]->IsFunction()) {
|
if (args[4]->IsFunction()) {
|
||||||
Local<Object> obj = Object::New();
|
Local<Object> obj = Object::New();
|
||||||
obj->Set(String::New("ondone"), args[4]);
|
obj->Set(FIXED_ONE_BYTE_STRING(node_isolate, "ondone"), args[4]);
|
||||||
req->obj.Reset(node_isolate, obj);
|
req->obj.Reset(node_isolate, obj);
|
||||||
uv_queue_work(uv_default_loop(),
|
uv_queue_work(uv_default_loop(),
|
||||||
&req->work_req,
|
&req->work_req,
|
||||||
@ -3373,7 +3410,7 @@ void RandomBytesCheck(RandomBytesRequest* req, Local<Value> argv[2]) {
|
|||||||
if (req->error_ != (unsigned long) -1)
|
if (req->error_ != (unsigned long) -1)
|
||||||
ERR_error_string_n(req->error_, errmsg, sizeof errmsg);
|
ERR_error_string_n(req->error_, errmsg, sizeof errmsg);
|
||||||
|
|
||||||
argv[0] = Exception::Error(String::New(errmsg));
|
argv[0] = Exception::Error(OneByteString(node_isolate, errmsg));
|
||||||
argv[1] = Null(node_isolate);
|
argv[1] = Null(node_isolate);
|
||||||
} else {
|
} else {
|
||||||
argv[0] = Null(node_isolate);
|
argv[0] = Null(node_isolate);
|
||||||
@ -3417,7 +3454,7 @@ void RandomBytes(const FunctionCallbackInfo<Value>& args) {
|
|||||||
|
|
||||||
if (args[1]->IsFunction()) {
|
if (args[1]->IsFunction()) {
|
||||||
Local<Object> obj = Object::New();
|
Local<Object> obj = Object::New();
|
||||||
obj->Set(String::New("ondone"), args[1]);
|
obj->Set(FIXED_ONE_BYTE_STRING(node_isolate, "ondone"), args[1]);
|
||||||
req->obj_.Reset(node_isolate, obj);
|
req->obj_.Reset(node_isolate, obj);
|
||||||
|
|
||||||
uv_queue_work(uv_default_loop(),
|
uv_queue_work(uv_default_loop(),
|
||||||
@ -3458,7 +3495,7 @@ void GetSSLCiphers(const FunctionCallbackInfo<Value>& args) {
|
|||||||
|
|
||||||
for (int i = 0; i < sk_SSL_CIPHER_num(ciphers); ++i) {
|
for (int i = 0; i < sk_SSL_CIPHER_num(ciphers); ++i) {
|
||||||
SSL_CIPHER* cipher = sk_SSL_CIPHER_value(ciphers, i);
|
SSL_CIPHER* cipher = sk_SSL_CIPHER_value(ciphers, i);
|
||||||
arr->Set(i, String::New(SSL_CIPHER_get_name(cipher)));
|
arr->Set(i, OneByteString(node_isolate, SSL_CIPHER_get_name(cipher)));
|
||||||
}
|
}
|
||||||
|
|
||||||
SSL_free(ssl);
|
SSL_free(ssl);
|
||||||
@ -3474,7 +3511,7 @@ static void array_push_back(const TypeName* md,
|
|||||||
const char* to,
|
const char* to,
|
||||||
void* arg) {
|
void* arg) {
|
||||||
Local<Array>& arr = *static_cast<Local<Array>*>(arg);
|
Local<Array>& arr = *static_cast<Local<Array>*>(arg);
|
||||||
arr->Set(arr->Length(), String::New(from));
|
arr->Set(arr->Length(), OneByteString(node_isolate, from));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@ -3534,17 +3571,17 @@ void InitCrypto(Handle<Object> target) {
|
|||||||
NODE_SET_METHOD(target, "getCiphers", GetCiphers);
|
NODE_SET_METHOD(target, "getCiphers", GetCiphers);
|
||||||
NODE_SET_METHOD(target, "getHashes", GetHashes);
|
NODE_SET_METHOD(target, "getHashes", GetHashes);
|
||||||
|
|
||||||
subject_symbol = String::New("subject");
|
subject_symbol = FIXED_ONE_BYTE_STRING(node_isolate, "subject");
|
||||||
issuer_symbol = String::New("issuer");
|
issuer_symbol = FIXED_ONE_BYTE_STRING(node_isolate, "issuer");
|
||||||
valid_from_symbol = String::New("valid_from");
|
valid_from_symbol = FIXED_ONE_BYTE_STRING(node_isolate, "valid_from");
|
||||||
valid_to_symbol = String::New("valid_to");
|
valid_to_symbol = FIXED_ONE_BYTE_STRING(node_isolate, "valid_to");
|
||||||
subjectaltname_symbol = String::New("subjectaltname");
|
subjectaltname_symbol = FIXED_ONE_BYTE_STRING(node_isolate, "subjectaltname");
|
||||||
modulus_symbol = String::New("modulus");
|
modulus_symbol = FIXED_ONE_BYTE_STRING(node_isolate, "modulus");
|
||||||
exponent_symbol = String::New("exponent");
|
exponent_symbol = FIXED_ONE_BYTE_STRING(node_isolate, "exponent");
|
||||||
fingerprint_symbol = String::New("fingerprint");
|
fingerprint_symbol = FIXED_ONE_BYTE_STRING(node_isolate, "fingerprint");
|
||||||
name_symbol = String::New("name");
|
name_symbol = FIXED_ONE_BYTE_STRING(node_isolate, "name");
|
||||||
version_symbol = String::New("version");
|
version_symbol = FIXED_ONE_BYTE_STRING(node_isolate, "version");
|
||||||
ext_key_usage_symbol = String::New("ext_key_usage");
|
ext_key_usage_symbol = FIXED_ONE_BYTE_STRING(node_isolate, "ext_key_usage");
|
||||||
}
|
}
|
||||||
|
|
||||||
} // namespace crypto
|
} // namespace crypto
|
||||||
|
@ -77,7 +77,7 @@ using v8::Value;
|
|||||||
return ThrowError( \
|
return ThrowError( \
|
||||||
"expected object for " #obj " to contain string member " #member); \
|
"expected object for " #obj " to contain string member " #member); \
|
||||||
} \
|
} \
|
||||||
String::Utf8Value _##member(obj->Get(String::New(#member))); \
|
String::Utf8Value _##member(obj->Get(OneByteString(node_isolate, #member))); \
|
||||||
if ((*(const char **)valp = *_##member) == NULL) \
|
if ((*(const char **)valp = *_##member) == NULL) \
|
||||||
*(const char **)valp = "<unknown>";
|
*(const char **)valp = "<unknown>";
|
||||||
|
|
||||||
@ -86,14 +86,14 @@ using v8::Value;
|
|||||||
return ThrowError( \
|
return ThrowError( \
|
||||||
"expected object for " #obj " to contain integer member " #member); \
|
"expected object for " #obj " to contain integer member " #member); \
|
||||||
} \
|
} \
|
||||||
*valp = obj->Get(String::New(#member))->ToInteger()->Value();
|
*valp = obj->Get(OneByteString(node_isolate, #member))->ToInteger()->Value();
|
||||||
|
|
||||||
#define SLURP_OBJECT(obj, member, valp) \
|
#define SLURP_OBJECT(obj, member, valp) \
|
||||||
if (!(obj)->IsObject()) { \
|
if (!(obj)->IsObject()) { \
|
||||||
return ThrowError( \
|
return ThrowError( \
|
||||||
"expected object for " #obj " to contain object member " #member); \
|
"expected object for " #obj " to contain object member " #member); \
|
||||||
} \
|
} \
|
||||||
*valp = Local<Object>::Cast(obj->Get(String::New(#member)));
|
*valp = Local<Object>::Cast(obj->Get(OneByteString(node_isolate, #member)));
|
||||||
|
|
||||||
#define SLURP_CONNECTION(arg, conn) \
|
#define SLURP_CONNECTION(arg, conn) \
|
||||||
if (!(arg)->IsObject()) { \
|
if (!(arg)->IsObject()) { \
|
||||||
@ -102,7 +102,7 @@ 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 = (_##conn)->Get(String::New("_handle")); \
|
Local<Value> _handle = (_##conn)->Get(FIXED_ONE_BYTE_STRING(node_isolate, "_handle")); \
|
||||||
if (_handle->IsObject()) { \
|
if (_handle->IsObject()) { \
|
||||||
SLURP_INT(_handle.As<Object>(), fd, &conn.fd); \
|
SLURP_INT(_handle.As<Object>(), fd, &conn.fd); \
|
||||||
} else { \
|
} else { \
|
||||||
@ -221,7 +221,7 @@ 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(String::New("x-forwarded-for"));
|
Local<Value> strfwdfor = headers->Get(FIXED_ONE_BYTE_STRING(node_isolate, "x-forwarded-for"));
|
||||||
String::Utf8Value fwdfor(strfwdfor);
|
String::Utf8Value fwdfor(strfwdfor);
|
||||||
|
|
||||||
if (!strfwdfor->IsString() || (req.forwardedFor = *fwdfor) == NULL)
|
if (!strfwdfor->IsString() || (req.forwardedFor = *fwdfor) == NULL)
|
||||||
@ -332,7 +332,7 @@ void InitDTrace(Handle<Object> target) {
|
|||||||
};
|
};
|
||||||
|
|
||||||
for (unsigned int i = 0; i < ARRAY_SIZE(tab); i++) {
|
for (unsigned int i = 0; i < ARRAY_SIZE(tab); i++) {
|
||||||
Local<String> key = String::New(tab[i].name);
|
Local<String> key = OneByteString(node_isolate, tab[i].name);
|
||||||
Local<Value> val = FunctionTemplate::New(tab[i].func)->GetFunction();
|
Local<Value> val = FunctionTemplate::New(tab[i].func)->GetFunction();
|
||||||
target->Set(key, val);
|
target->Set(key, val);
|
||||||
}
|
}
|
||||||
|
@ -169,7 +169,8 @@ static void After(uv_fs_t *req) {
|
|||||||
break;
|
break;
|
||||||
|
|
||||||
case UV_FS_READLINK:
|
case UV_FS_READLINK:
|
||||||
argv[1] = String::New(static_cast<char*>(req->ptr));
|
argv[1] = String::NewFromUtf8(node_isolate,
|
||||||
|
static_cast<const char*>(req->ptr));
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case UV_FS_READ:
|
case UV_FS_READ:
|
||||||
@ -185,7 +186,7 @@ static void After(uv_fs_t *req) {
|
|||||||
Local<Array> names = Array::New(nnames);
|
Local<Array> names = Array::New(nnames);
|
||||||
|
|
||||||
for (int i = 0; i < nnames; i++) {
|
for (int i = 0; i < nnames; i++) {
|
||||||
Local<String> name = String::New(namebuf);
|
Local<String> name = String::NewFromUtf8(node_isolate, namebuf);
|
||||||
names->Set(Integer::New(i, node_isolate), name);
|
names->Set(Integer::New(i, node_isolate), name);
|
||||||
#ifndef NDEBUG
|
#ifndef NDEBUG
|
||||||
namebuf += strlen(namebuf);
|
namebuf += strlen(namebuf);
|
||||||
@ -206,7 +207,7 @@ static void After(uv_fs_t *req) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (oncomplete_sym.IsEmpty()) {
|
if (oncomplete_sym.IsEmpty()) {
|
||||||
oncomplete_sym = String::New("oncomplete");
|
oncomplete_sym = FIXED_ONE_BYTE_STRING(node_isolate, "oncomplete");
|
||||||
}
|
}
|
||||||
MakeCallback(req_wrap->object(), oncomplete_sym, argc, argv);
|
MakeCallback(req_wrap->object(), oncomplete_sym, argc, argv);
|
||||||
|
|
||||||
@ -290,19 +291,19 @@ Local<Object> BuildStatsObject(const uv_stat_t* s) {
|
|||||||
HandleScope scope(node_isolate);
|
HandleScope scope(node_isolate);
|
||||||
|
|
||||||
if (dev_symbol.IsEmpty()) {
|
if (dev_symbol.IsEmpty()) {
|
||||||
dev_symbol = String::New("dev");
|
dev_symbol = FIXED_ONE_BYTE_STRING(node_isolate, "dev");
|
||||||
ino_symbol = String::New("ino");
|
ino_symbol = FIXED_ONE_BYTE_STRING(node_isolate, "ino");
|
||||||
mode_symbol = String::New("mode");
|
mode_symbol = FIXED_ONE_BYTE_STRING(node_isolate, "mode");
|
||||||
nlink_symbol = String::New("nlink");
|
nlink_symbol = FIXED_ONE_BYTE_STRING(node_isolate, "nlink");
|
||||||
uid_symbol = String::New("uid");
|
uid_symbol = FIXED_ONE_BYTE_STRING(node_isolate, "uid");
|
||||||
gid_symbol = String::New("gid");
|
gid_symbol = FIXED_ONE_BYTE_STRING(node_isolate, "gid");
|
||||||
rdev_symbol = String::New("rdev");
|
rdev_symbol = FIXED_ONE_BYTE_STRING(node_isolate, "rdev");
|
||||||
size_symbol = String::New("size");
|
size_symbol = FIXED_ONE_BYTE_STRING(node_isolate, "size");
|
||||||
blksize_symbol = String::New("blksize");
|
blksize_symbol = FIXED_ONE_BYTE_STRING(node_isolate, "blksize");
|
||||||
blocks_symbol = String::New("blocks");
|
blocks_symbol = FIXED_ONE_BYTE_STRING(node_isolate, "blocks");
|
||||||
atime_symbol = String::New("atime");
|
atime_symbol = FIXED_ONE_BYTE_STRING(node_isolate, "atime");
|
||||||
mtime_symbol = String::New("mtime");
|
mtime_symbol = FIXED_ONE_BYTE_STRING(node_isolate, "mtime");
|
||||||
ctime_symbol = String::New("ctime");
|
ctime_symbol = FIXED_ONE_BYTE_STRING(node_isolate, "ctime");
|
||||||
}
|
}
|
||||||
|
|
||||||
Local<Function> constructor =
|
Local<Function> constructor =
|
||||||
@ -481,8 +482,9 @@ static void ReadLink(const FunctionCallbackInfo<Value>& args) {
|
|||||||
ASYNC_CALL(readlink, args[1], *path)
|
ASYNC_CALL(readlink, args[1], *path)
|
||||||
} else {
|
} else {
|
||||||
SYNC_CALL(readlink, *path, *path)
|
SYNC_CALL(readlink, *path, *path)
|
||||||
args.GetReturnValue().Set(
|
const char* link_path = static_cast<const char*>(SYNC_REQ.ptr);
|
||||||
String::New(static_cast<const char*>(SYNC_REQ.ptr)));
|
Local<String> rc = String::NewFromUtf8(node_isolate, link_path);
|
||||||
|
args.GetReturnValue().Set(rc);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -621,7 +623,7 @@ static void ReadDir(const FunctionCallbackInfo<Value>& args) {
|
|||||||
Local<Array> names = Array::New(nnames);
|
Local<Array> names = Array::New(nnames);
|
||||||
|
|
||||||
for (int i = 0; i < nnames; i++) {
|
for (int i = 0; i < nnames; i++) {
|
||||||
Local<String> name = String::New(namebuf);
|
Local<String> name = String::NewFromUtf8(node_isolate, namebuf);
|
||||||
names->Set(Integer::New(i, node_isolate), name);
|
names->Set(Integer::New(i, node_isolate), name);
|
||||||
#ifndef NDEBUG
|
#ifndef NDEBUG
|
||||||
namebuf += strlen(namebuf);
|
namebuf += strlen(namebuf);
|
||||||
@ -1005,12 +1007,12 @@ void InitFs(Handle<Object> target) {
|
|||||||
|
|
||||||
// Initialize the stats object
|
// Initialize the stats object
|
||||||
Local<Function> constructor = FunctionTemplate::New()->GetFunction();
|
Local<Function> constructor = FunctionTemplate::New()->GetFunction();
|
||||||
target->Set(String::NewSymbol("Stats"), constructor);
|
target->Set(FIXED_ONE_BYTE_STRING(node_isolate, "Stats"), constructor);
|
||||||
stats_constructor.Reset(node_isolate, constructor);
|
stats_constructor.Reset(node_isolate, constructor);
|
||||||
|
|
||||||
File::Initialize(target);
|
File::Initialize(target);
|
||||||
|
|
||||||
oncomplete_sym = String::New("oncomplete");
|
oncomplete_sym = FIXED_ONE_BYTE_STRING(node_isolate, "oncomplete");
|
||||||
|
|
||||||
StatWatcher::Initialize(target);
|
StatWatcher::Initialize(target);
|
||||||
}
|
}
|
||||||
|
@ -179,7 +179,7 @@ struct StringPtr {
|
|||||||
|
|
||||||
Local<String> ToString() const {
|
Local<String> ToString() const {
|
||||||
if (str_)
|
if (str_)
|
||||||
return String::New(str_, size_);
|
return OneByteString(node_isolate, str_, size_);
|
||||||
else
|
else
|
||||||
return String::Empty(node_isolate);
|
return String::Empty(node_isolate);
|
||||||
}
|
}
|
||||||
@ -433,10 +433,12 @@ class Parser : public ObjectWrap {
|
|||||||
if (!parser->parser_.upgrade && nparsed != buffer_len) {
|
if (!parser->parser_.upgrade && nparsed != buffer_len) {
|
||||||
enum http_errno err = HTTP_PARSER_ERRNO(&parser->parser_);
|
enum http_errno err = HTTP_PARSER_ERRNO(&parser->parser_);
|
||||||
|
|
||||||
Local<Value> e = Exception::Error(String::NewSymbol("Parse Error"));
|
Local<Value> e = Exception::Error(
|
||||||
|
FIXED_ONE_BYTE_STRING(node_isolate, "Parse Error"));
|
||||||
Local<Object> obj = e->ToObject();
|
Local<Object> obj = e->ToObject();
|
||||||
obj->Set(String::NewSymbol("bytesParsed"), nparsed_obj);
|
obj->Set(FIXED_ONE_BYTE_STRING(node_isolate, "bytesParsed"), nparsed_obj);
|
||||||
obj->Set(String::NewSymbol("code"), String::New(http_errno_name(err)));
|
obj->Set(FIXED_ONE_BYTE_STRING(node_isolate, "code"),
|
||||||
|
OneByteString(node_isolate, http_errno_name(err)));
|
||||||
args.GetReturnValue().Set(e);
|
args.GetReturnValue().Set(e);
|
||||||
} else {
|
} else {
|
||||||
args.GetReturnValue().Set(nparsed_obj);
|
args.GetReturnValue().Set(nparsed_obj);
|
||||||
@ -459,10 +461,13 @@ class Parser : public ObjectWrap {
|
|||||||
if (rv != 0) {
|
if (rv != 0) {
|
||||||
enum http_errno err = HTTP_PARSER_ERRNO(&parser->parser_);
|
enum http_errno err = HTTP_PARSER_ERRNO(&parser->parser_);
|
||||||
|
|
||||||
Local<Value> e = Exception::Error(String::NewSymbol("Parse Error"));
|
Local<Value> e = Exception::Error(
|
||||||
|
FIXED_ONE_BYTE_STRING(node_isolate, "Parse Error"));
|
||||||
Local<Object> obj = e->ToObject();
|
Local<Object> obj = e->ToObject();
|
||||||
obj->Set(String::NewSymbol("bytesParsed"), Integer::New(0, node_isolate));
|
obj->Set(FIXED_ONE_BYTE_STRING(node_isolate, "bytesParsed"),
|
||||||
obj->Set(String::NewSymbol("code"), String::New(http_errno_name(err)));
|
Integer::New(0, node_isolate));
|
||||||
|
obj->Set(FIXED_ONE_BYTE_STRING(node_isolate, "code"),
|
||||||
|
OneByteString(node_isolate, http_errno_name(err)));
|
||||||
args.GetReturnValue().Set(e);
|
args.GetReturnValue().Set(e);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -547,38 +552,45 @@ void InitHttpParser(Handle<Object> target) {
|
|||||||
|
|
||||||
Local<FunctionTemplate> t = FunctionTemplate::New(Parser::New);
|
Local<FunctionTemplate> t = FunctionTemplate::New(Parser::New);
|
||||||
t->InstanceTemplate()->SetInternalFieldCount(1);
|
t->InstanceTemplate()->SetInternalFieldCount(1);
|
||||||
t->SetClassName(String::NewSymbol("HTTPParser"));
|
t->SetClassName(FIXED_ONE_BYTE_STRING(node_isolate, "HTTPParser"));
|
||||||
|
|
||||||
t->Set(String::NewSymbol("REQUEST"),
|
t->Set(FIXED_ONE_BYTE_STRING(node_isolate, "REQUEST"),
|
||||||
Integer::New(HTTP_REQUEST, node_isolate));
|
Integer::New(HTTP_REQUEST, node_isolate));
|
||||||
t->Set(String::NewSymbol("RESPONSE"),
|
t->Set(FIXED_ONE_BYTE_STRING(node_isolate, "RESPONSE"),
|
||||||
Integer::New(HTTP_RESPONSE, node_isolate));
|
Integer::New(HTTP_RESPONSE, node_isolate));
|
||||||
|
|
||||||
NODE_SET_PROTOTYPE_METHOD(t, "execute", Parser::Execute);
|
NODE_SET_PROTOTYPE_METHOD(t, "execute", Parser::Execute);
|
||||||
NODE_SET_PROTOTYPE_METHOD(t, "finish", Parser::Finish);
|
NODE_SET_PROTOTYPE_METHOD(t, "finish", Parser::Finish);
|
||||||
NODE_SET_PROTOTYPE_METHOD(t, "reinitialize", Parser::Reinitialize);
|
NODE_SET_PROTOTYPE_METHOD(t, "reinitialize", Parser::Reinitialize);
|
||||||
|
|
||||||
target->Set(String::NewSymbol("HTTPParser"), t->GetFunction());
|
target->Set(FIXED_ONE_BYTE_STRING(node_isolate, "HTTPParser"),
|
||||||
|
t->GetFunction());
|
||||||
|
|
||||||
on_headers_sym = String::New("onHeaders");
|
on_headers_sym =
|
||||||
on_headers_complete_sym = String::New("onHeadersComplete");
|
FIXED_ONE_BYTE_STRING(node_isolate, "onHeaders");
|
||||||
on_body_sym = String::New("onBody");
|
on_headers_complete_sym =
|
||||||
on_message_complete_sym = String::New("onMessageComplete");
|
FIXED_ONE_BYTE_STRING(node_isolate, "onHeadersComplete");
|
||||||
|
on_body_sym =
|
||||||
|
FIXED_ONE_BYTE_STRING(node_isolate, "onBody");
|
||||||
|
on_message_complete_sym =
|
||||||
|
FIXED_ONE_BYTE_STRING(node_isolate, "onMessageComplete");
|
||||||
|
|
||||||
#define X(num, name, string) name##_sym = String::New(#string);
|
#define X(num, name, string) \
|
||||||
|
name ## _sym = OneByteString(node_isolate, #string);
|
||||||
HTTP_METHOD_MAP(X)
|
HTTP_METHOD_MAP(X)
|
||||||
#undef X
|
#undef X
|
||||||
unknown_method_sym = String::New("UNKNOWN_METHOD");
|
unknown_method_sym = FIXED_ONE_BYTE_STRING(node_isolate, "UNKNOWN_METHOD");
|
||||||
|
|
||||||
method_sym = String::New("method");
|
method_sym = FIXED_ONE_BYTE_STRING(node_isolate, "method");
|
||||||
status_code_sym = String::New("statusCode");
|
status_code_sym = FIXED_ONE_BYTE_STRING(node_isolate, "statusCode");
|
||||||
http_version_sym = String::New("httpVersion");
|
http_version_sym = FIXED_ONE_BYTE_STRING(node_isolate, "httpVersion");
|
||||||
version_major_sym = String::New("versionMajor");
|
version_major_sym = FIXED_ONE_BYTE_STRING(node_isolate, "versionMajor");
|
||||||
version_minor_sym = String::New("versionMinor");
|
version_minor_sym = FIXED_ONE_BYTE_STRING(node_isolate, "versionMinor");
|
||||||
should_keep_alive_sym = String::New("shouldKeepAlive");
|
should_keep_alive_sym =
|
||||||
upgrade_sym = String::New("upgrade");
|
FIXED_ONE_BYTE_STRING(node_isolate, "shouldKeepAlive");
|
||||||
headers_sym = String::New("headers");
|
upgrade_sym = FIXED_ONE_BYTE_STRING(node_isolate, "upgrade");
|
||||||
url_sym = String::New("url");
|
headers_sym = FIXED_ONE_BYTE_STRING(node_isolate, "headers");
|
||||||
|
url_sym = FIXED_ONE_BYTE_STRING(node_isolate, "url");
|
||||||
|
|
||||||
settings.on_message_begin = Parser::on_message_begin;
|
settings.on_message_begin = Parser::on_message_begin;
|
||||||
settings.on_url = Parser::on_url;
|
settings.on_url = Parser::on_url;
|
||||||
|
@ -25,8 +25,12 @@
|
|||||||
#include "v8.h"
|
#include "v8.h"
|
||||||
|
|
||||||
#include <assert.h>
|
#include <assert.h>
|
||||||
|
#include <stdint.h>
|
||||||
#include <stdlib.h>
|
#include <stdlib.h>
|
||||||
|
|
||||||
|
#define FIXED_ONE_BYTE_STRING(isolate, string) \
|
||||||
|
(node::OneByteString((isolate), (string), sizeof(string) - 1))
|
||||||
|
|
||||||
struct sockaddr;
|
struct sockaddr;
|
||||||
|
|
||||||
namespace node {
|
namespace node {
|
||||||
@ -95,6 +99,20 @@ inline v8::Local<v8::Object> NewInstance(
|
|||||||
int argc = 0,
|
int argc = 0,
|
||||||
v8::Handle<v8::Value>* argv = NULL);
|
v8::Handle<v8::Value>* argv = NULL);
|
||||||
|
|
||||||
|
// Convenience wrapper around v8::String::NewFromOneByte().
|
||||||
|
inline v8::Local<v8::String> OneByteString(v8::Isolate* isolate,
|
||||||
|
const char* data,
|
||||||
|
int length = -1);
|
||||||
|
|
||||||
|
// For the people that compile with -funsigned-char.
|
||||||
|
inline v8::Local<v8::String> OneByteString(v8::Isolate* isolate,
|
||||||
|
const signed char* data,
|
||||||
|
int length = -1);
|
||||||
|
|
||||||
|
inline v8::Local<v8::String> OneByteString(v8::Isolate* isolate,
|
||||||
|
const unsigned char* data,
|
||||||
|
int length = -1);
|
||||||
|
|
||||||
// Convert a struct sockaddr to a { address: '1.2.3.4', port: 1234 } JS object.
|
// Convert a struct sockaddr to a { address: '1.2.3.4', port: 1234 } JS object.
|
||||||
// Sets address and port properties on the info object and returns it.
|
// Sets address and port properties on the info object and returns it.
|
||||||
// If |info| is omitted, a new object is returned.
|
// If |info| is omitted, a new object is returned.
|
||||||
@ -157,7 +175,7 @@ inline static int snprintf(char* buf, unsigned int len, const char* fmt, ...) {
|
|||||||
#define THROW_ERROR(fun) \
|
#define THROW_ERROR(fun) \
|
||||||
do { \
|
do { \
|
||||||
v8::HandleScope scope(node_isolate); \
|
v8::HandleScope scope(node_isolate); \
|
||||||
v8::ThrowException(fun(v8::String::New(errmsg))); \
|
v8::ThrowException(fun(OneByteString(node_isolate, errmsg))); \
|
||||||
} \
|
} \
|
||||||
while (0)
|
while (0)
|
||||||
|
|
||||||
@ -333,6 +351,33 @@ inline v8::Local<v8::Object> NewInstance(
|
|||||||
return constructor_handle->NewInstance(argc, argv);
|
return constructor_handle->NewInstance(argc, argv);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
inline v8::Local<v8::String> OneByteString(v8::Isolate* isolate,
|
||||||
|
const char* data,
|
||||||
|
int length) {
|
||||||
|
return v8::String::NewFromOneByte(isolate,
|
||||||
|
reinterpret_cast<const uint8_t*>(data),
|
||||||
|
v8::String::kNormalString,
|
||||||
|
length);
|
||||||
|
}
|
||||||
|
|
||||||
|
inline v8::Local<v8::String> OneByteString(v8::Isolate* isolate,
|
||||||
|
const signed char* data,
|
||||||
|
int length) {
|
||||||
|
return v8::String::NewFromOneByte(isolate,
|
||||||
|
reinterpret_cast<const uint8_t*>(data),
|
||||||
|
v8::String::kNormalString,
|
||||||
|
length);
|
||||||
|
}
|
||||||
|
|
||||||
|
inline v8::Local<v8::String> OneByteString(v8::Isolate* isolate,
|
||||||
|
const unsigned char* data,
|
||||||
|
int length) {
|
||||||
|
return v8::String::NewFromOneByte(isolate,
|
||||||
|
reinterpret_cast<const uint8_t*>(data),
|
||||||
|
v8::String::kNormalString,
|
||||||
|
length);
|
||||||
|
}
|
||||||
|
|
||||||
} // namespace node
|
} // namespace node
|
||||||
|
|
||||||
#endif // SRC_NODE_INTERNALS_H_
|
#endif // SRC_NODE_INTERNALS_H_
|
||||||
|
@ -37,7 +37,7 @@ using v8::Object;
|
|||||||
using v8::String;
|
using v8::String;
|
||||||
|
|
||||||
Handle<String> MainSource() {
|
Handle<String> MainSource() {
|
||||||
return String::New(node_native, sizeof(node_native) - 1);
|
return OneByteString(node_isolate, node_native, sizeof(node_native) - 1);
|
||||||
}
|
}
|
||||||
|
|
||||||
void DefineJavaScript(Handle<Object> target) {
|
void DefineJavaScript(Handle<Object> target) {
|
||||||
@ -45,8 +45,10 @@ void DefineJavaScript(Handle<Object> target) {
|
|||||||
|
|
||||||
for (int i = 0; natives[i].name; i++) {
|
for (int i = 0; natives[i].name; i++) {
|
||||||
if (natives[i].source != node_native) {
|
if (natives[i].source != node_native) {
|
||||||
Local<String> name = String::New(natives[i].name);
|
Local<String> name = String::NewFromUtf8(node_isolate, natives[i].name);
|
||||||
Handle<String> source = String::New(natives[i].source,
|
Handle<String> source = String::NewFromUtf8(node_isolate,
|
||||||
|
natives[i].source,
|
||||||
|
String::kNormalString,
|
||||||
natives[i].source_len);
|
natives[i].source_len);
|
||||||
target->Set(name, source);
|
target->Set(name, source);
|
||||||
}
|
}
|
||||||
|
@ -59,7 +59,7 @@ using v8::Value;
|
|||||||
static void GetEndianness(const FunctionCallbackInfo<Value>& args) {
|
static void GetEndianness(const FunctionCallbackInfo<Value>& args) {
|
||||||
HandleScope scope(node_isolate);
|
HandleScope scope(node_isolate);
|
||||||
const char* rval = IsBigEndian() ? "BE" : "LE";
|
const char* rval = IsBigEndian() ? "BE" : "LE";
|
||||||
args.GetReturnValue().Set(String::New(rval));
|
args.GetReturnValue().Set(OneByteString(node_isolate, rval));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@ -77,7 +77,7 @@ static void GetHostname(const FunctionCallbackInfo<Value>& args) {
|
|||||||
}
|
}
|
||||||
buf[sizeof(buf) - 1] = '\0';
|
buf[sizeof(buf) - 1] = '\0';
|
||||||
|
|
||||||
args.GetReturnValue().Set(String::New(buf));
|
args.GetReturnValue().Set(OneByteString(node_isolate, buf));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@ -95,7 +95,7 @@ static void GetOSType(const FunctionCallbackInfo<Value>& args) {
|
|||||||
rval ="Windows_NT";
|
rval ="Windows_NT";
|
||||||
#endif // __POSIX__
|
#endif // __POSIX__
|
||||||
|
|
||||||
args.GetReturnValue().Set(String::New(rval));
|
args.GetReturnValue().Set(OneByteString(node_isolate, rval));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@ -125,7 +125,7 @@ static void GetOSRelease(const FunctionCallbackInfo<Value>& args) {
|
|||||||
rval = release;
|
rval = release;
|
||||||
#endif // __POSIX__
|
#endif // __POSIX__
|
||||||
|
|
||||||
args.GetReturnValue().Set(String::New(rval));
|
args.GetReturnValue().Set(OneByteString(node_isolate, rval));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@ -142,21 +142,23 @@ static void GetCPUInfo(const FunctionCallbackInfo<Value>& args) {
|
|||||||
uv_cpu_info_t* ci = cpu_infos + i;
|
uv_cpu_info_t* ci = cpu_infos + i;
|
||||||
|
|
||||||
Local<Object> times_info = Object::New();
|
Local<Object> times_info = Object::New();
|
||||||
times_info->Set(String::New("user"),
|
times_info->Set(FIXED_ONE_BYTE_STRING(node_isolate, "user"),
|
||||||
Number::New(node_isolate, ci->cpu_times.user));
|
Number::New(node_isolate, ci->cpu_times.user));
|
||||||
times_info->Set(String::New("nice"),
|
times_info->Set(FIXED_ONE_BYTE_STRING(node_isolate, "nice"),
|
||||||
Number::New(node_isolate, ci->cpu_times.nice));
|
Number::New(node_isolate, ci->cpu_times.nice));
|
||||||
times_info->Set(String::New("sys"),
|
times_info->Set(FIXED_ONE_BYTE_STRING(node_isolate, "sys"),
|
||||||
Number::New(node_isolate, ci->cpu_times.sys));
|
Number::New(node_isolate, ci->cpu_times.sys));
|
||||||
times_info->Set(String::New("idle"),
|
times_info->Set(FIXED_ONE_BYTE_STRING(node_isolate, "idle"),
|
||||||
Number::New(node_isolate, ci->cpu_times.idle));
|
Number::New(node_isolate, ci->cpu_times.idle));
|
||||||
times_info->Set(String::New("irq"),
|
times_info->Set(FIXED_ONE_BYTE_STRING(node_isolate, "irq"),
|
||||||
Number::New(node_isolate, ci->cpu_times.irq));
|
Number::New(node_isolate, ci->cpu_times.irq));
|
||||||
|
|
||||||
Local<Object> cpu_info = Object::New();
|
Local<Object> cpu_info = Object::New();
|
||||||
cpu_info->Set(String::New("model"), String::New(ci->model));
|
cpu_info->Set(FIXED_ONE_BYTE_STRING(node_isolate, "model"),
|
||||||
cpu_info->Set(String::New("speed"), Number::New(node_isolate, ci->speed));
|
OneByteString(node_isolate, ci->model));
|
||||||
cpu_info->Set(String::New("times"), times_info);
|
cpu_info->Set(FIXED_ONE_BYTE_STRING(node_isolate, "speed"),
|
||||||
|
Number::New(node_isolate, ci->speed));
|
||||||
|
cpu_info->Set(FIXED_ONE_BYTE_STRING(node_isolate, "times"), times_info);
|
||||||
|
|
||||||
(*cpus)->Set(i, cpu_info);
|
(*cpus)->Set(i, cpu_info);
|
||||||
}
|
}
|
||||||
@ -221,7 +223,7 @@ static void GetInterfaceAddresses(const FunctionCallbackInfo<Value>& args) {
|
|||||||
ret = Object::New();
|
ret = Object::New();
|
||||||
|
|
||||||
for (i = 0; i < count; i++) {
|
for (i = 0; i < count; i++) {
|
||||||
name = String::New(interfaces[i].name);
|
name = OneByteString(node_isolate, interfaces[i].name);
|
||||||
if (ret->Has(name)) {
|
if (ret->Has(name)) {
|
||||||
ifarr = Local<Array>::Cast(ret->Get(name));
|
ifarr = Local<Array>::Cast(ret->Get(name));
|
||||||
} else {
|
} else {
|
||||||
@ -242,24 +244,27 @@ static void GetInterfaceAddresses(const FunctionCallbackInfo<Value>& args) {
|
|||||||
if (interfaces[i].address.address4.sin_family == AF_INET) {
|
if (interfaces[i].address.address4.sin_family == AF_INET) {
|
||||||
uv_ip4_name(&interfaces[i].address.address4, ip, sizeof(ip));
|
uv_ip4_name(&interfaces[i].address.address4, ip, sizeof(ip));
|
||||||
uv_ip4_name(&interfaces[i].netmask.netmask4, netmask, sizeof(netmask));
|
uv_ip4_name(&interfaces[i].netmask.netmask4, netmask, sizeof(netmask));
|
||||||
family = String::New("IPv4");
|
family = FIXED_ONE_BYTE_STRING(node_isolate, "IPv4");
|
||||||
} else if (interfaces[i].address.address4.sin_family == AF_INET6) {
|
} else if (interfaces[i].address.address4.sin_family == AF_INET6) {
|
||||||
uv_ip6_name(&interfaces[i].address.address6, ip, sizeof(ip));
|
uv_ip6_name(&interfaces[i].address.address6, ip, sizeof(ip));
|
||||||
uv_ip6_name(&interfaces[i].netmask.netmask6, netmask, sizeof(netmask));
|
uv_ip6_name(&interfaces[i].netmask.netmask6, netmask, sizeof(netmask));
|
||||||
family = String::New("IPv6");
|
family = FIXED_ONE_BYTE_STRING(node_isolate, "IPv6");
|
||||||
} else {
|
} else {
|
||||||
strncpy(ip, "<unknown sa family>", INET6_ADDRSTRLEN);
|
strncpy(ip, "<unknown sa family>", INET6_ADDRSTRLEN);
|
||||||
family = String::New("<unknown>");
|
family = FIXED_ONE_BYTE_STRING(node_isolate, "<unknown>");
|
||||||
}
|
}
|
||||||
|
|
||||||
o = Object::New();
|
o = Object::New();
|
||||||
o->Set(String::New("address"), String::New(ip));
|
o->Set(FIXED_ONE_BYTE_STRING(node_isolate, "address"),
|
||||||
o->Set(String::New("netmask"), String::New(netmask));
|
OneByteString(node_isolate, ip));
|
||||||
o->Set(String::New("family"), family);
|
o->Set(FIXED_ONE_BYTE_STRING(node_isolate, "netmask"),
|
||||||
o->Set(String::New("mac"), String::New(mac));
|
OneByteString(node_isolate, netmask));
|
||||||
|
o->Set(FIXED_ONE_BYTE_STRING(node_isolate, "family"), family);
|
||||||
|
o->Set(FIXED_ONE_BYTE_STRING(node_isolate, "mac"),
|
||||||
|
FIXED_ONE_BYTE_STRING(node_isolate, mac));
|
||||||
|
|
||||||
const bool internal = interfaces[i].is_internal;
|
const bool internal = interfaces[i].is_internal;
|
||||||
o->Set(String::New("internal"),
|
o->Set(FIXED_ONE_BYTE_STRING(node_isolate, "internal"),
|
||||||
internal ? True(node_isolate) : False(node_isolate));
|
internal ? True(node_isolate) : False(node_isolate));
|
||||||
|
|
||||||
ifarr->Set(ifarr->Length(), o);
|
ifarr->Set(ifarr->Length(), o);
|
||||||
|
@ -118,9 +118,10 @@ void CloneObject(Handle<Object> recv,
|
|||||||
"}); \n";
|
"}); \n";
|
||||||
|
|
||||||
Local<String> script_source =
|
Local<String> script_source =
|
||||||
String::New(raw_script_source, sizeof(raw_script_source) - 1);
|
FIXED_ONE_BYTE_STRING(node_isolate, raw_script_source);
|
||||||
Local<Script> script =
|
Local<String> script_name =
|
||||||
Script::Compile(script_source, String::New("binding:script"));
|
FIXED_ONE_BYTE_STRING(node_isolate, "binding:script");
|
||||||
|
Local<Script> script = Script::Compile(script_source, script_name);
|
||||||
|
|
||||||
Local<Function> fun = script->Run().As<Function>();
|
Local<Function> fun = script->Run().As<Function>();
|
||||||
assert(fun.IsEmpty() == false);
|
assert(fun.IsEmpty() == false);
|
||||||
@ -137,9 +138,9 @@ void WrappedContext::Initialize(Handle<Object> target) {
|
|||||||
|
|
||||||
Local<FunctionTemplate> t = FunctionTemplate::New(WrappedContext::New);
|
Local<FunctionTemplate> t = FunctionTemplate::New(WrappedContext::New);
|
||||||
t->InstanceTemplate()->SetInternalFieldCount(1);
|
t->InstanceTemplate()->SetInternalFieldCount(1);
|
||||||
t->SetClassName(String::NewSymbol("Context"));
|
t->SetClassName(FIXED_ONE_BYTE_STRING(node_isolate, "Context"));
|
||||||
|
|
||||||
target->Set(String::NewSymbol("Context"), t->GetFunction());
|
target->Set(FIXED_ONE_BYTE_STRING(node_isolate, "Context"), t->GetFunction());
|
||||||
constructor_template.Reset(node_isolate, t);
|
constructor_template.Reset(node_isolate, t);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -186,7 +187,7 @@ void WrappedScript::Initialize(Handle<Object> target) {
|
|||||||
// Note: We use 'NodeScript' instead of 'Script' so that we do not
|
// Note: We use 'NodeScript' instead of 'Script' so that we do not
|
||||||
// conflict with V8's Script class defined in v8/src/messages.js
|
// conflict with V8's Script class defined in v8/src/messages.js
|
||||||
// See GH-203 https://github.com/joyent/node/issues/203
|
// See GH-203 https://github.com/joyent/node/issues/203
|
||||||
t->SetClassName(String::NewSymbol("NodeScript"));
|
t->SetClassName(FIXED_ONE_BYTE_STRING(node_isolate, "NodeScript"));
|
||||||
|
|
||||||
NODE_SET_PROTOTYPE_METHOD(t,
|
NODE_SET_PROTOTYPE_METHOD(t,
|
||||||
"createContext",
|
"createContext",
|
||||||
@ -220,7 +221,8 @@ void WrappedScript::Initialize(Handle<Object> target) {
|
|||||||
"runInNewContext",
|
"runInNewContext",
|
||||||
WrappedScript::CompileRunInNewContext);
|
WrappedScript::CompileRunInNewContext);
|
||||||
|
|
||||||
target->Set(String::NewSymbol("NodeScript"), t->GetFunction());
|
target->Set(FIXED_ONE_BYTE_STRING(node_isolate, "NodeScript"),
|
||||||
|
t->GetFunction());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@ -328,9 +330,12 @@ void WrappedScript::EvalMachine(const FunctionCallbackInfo<Value>& args) {
|
|||||||
|
|
||||||
const int filename_index = sandbox_index +
|
const int filename_index = sandbox_index +
|
||||||
(context_flag == thisContext? 0 : 1);
|
(context_flag == thisContext? 0 : 1);
|
||||||
Local<String> filename = args.Length() > filename_index
|
Local<String> filename;
|
||||||
? args[filename_index]->ToString()
|
if (args.Length() > filename_index) {
|
||||||
: String::New("evalmachine.<anonymous>");
|
filename = args[filename_index]->ToString();
|
||||||
|
} else {
|
||||||
|
filename = FIXED_ONE_BYTE_STRING(node_isolate, "evalmachine.<anonymous>");
|
||||||
|
}
|
||||||
|
|
||||||
uint64_t timeout = 0;
|
uint64_t timeout = 0;
|
||||||
const int timeout_index = filename_index + 1;
|
const int timeout_index = filename_index + 1;
|
||||||
|
@ -46,12 +46,13 @@ void StatWatcher::Initialize(Handle<Object> target) {
|
|||||||
|
|
||||||
Local<FunctionTemplate> t = FunctionTemplate::New(StatWatcher::New);
|
Local<FunctionTemplate> t = FunctionTemplate::New(StatWatcher::New);
|
||||||
t->InstanceTemplate()->SetInternalFieldCount(1);
|
t->InstanceTemplate()->SetInternalFieldCount(1);
|
||||||
t->SetClassName(String::NewSymbol("StatWatcher"));
|
t->SetClassName(FIXED_ONE_BYTE_STRING(node_isolate, "StatWatcher"));
|
||||||
|
|
||||||
NODE_SET_PROTOTYPE_METHOD(t, "start", StatWatcher::Start);
|
NODE_SET_PROTOTYPE_METHOD(t, "start", StatWatcher::Start);
|
||||||
NODE_SET_PROTOTYPE_METHOD(t, "stop", StatWatcher::Stop);
|
NODE_SET_PROTOTYPE_METHOD(t, "stop", StatWatcher::Stop);
|
||||||
|
|
||||||
target->Set(String::NewSymbol("StatWatcher"), t->GetFunction());
|
target->Set(FIXED_ONE_BYTE_STRING(node_isolate, "StatWatcher"),
|
||||||
|
t->GetFunction());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@ -85,7 +86,7 @@ void StatWatcher::Callback(uv_fs_poll_t* handle,
|
|||||||
argv[1] = BuildStatsObject(prev);
|
argv[1] = BuildStatsObject(prev);
|
||||||
argv[2] = Integer::New(status, node_isolate);
|
argv[2] = Integer::New(status, node_isolate);
|
||||||
if (onchange_sym.IsEmpty()) {
|
if (onchange_sym.IsEmpty()) {
|
||||||
onchange_sym = String::New("onchange");
|
onchange_sym = FIXED_ONE_BYTE_STRING(node_isolate, "onchange");
|
||||||
}
|
}
|
||||||
MakeCallback(wrap->handle(node_isolate),
|
MakeCallback(wrap->handle(node_isolate),
|
||||||
onchange_sym,
|
onchange_sym,
|
||||||
@ -121,7 +122,7 @@ void StatWatcher::Stop(const FunctionCallbackInfo<Value>& args) {
|
|||||||
HandleScope scope(node_isolate);
|
HandleScope scope(node_isolate);
|
||||||
StatWatcher* wrap = ObjectWrap::Unwrap<StatWatcher>(args.This());
|
StatWatcher* wrap = ObjectWrap::Unwrap<StatWatcher>(args.This());
|
||||||
if (onstop_sym.IsEmpty()) {
|
if (onstop_sym.IsEmpty()) {
|
||||||
onstop_sym = String::New("onstop");
|
onstop_sym = FIXED_ONE_BYTE_STRING(node_isolate, "onstop");
|
||||||
}
|
}
|
||||||
MakeCallback(wrap->handle(node_isolate), onstop_sym, 0, NULL);
|
MakeCallback(wrap->handle(node_isolate), onstop_sym, 0, NULL);
|
||||||
wrap->Stop();
|
wrap->Stop();
|
||||||
|
@ -294,7 +294,7 @@ class ZCtx : public ObjectWrap {
|
|||||||
assert(handle->Get(onerror_sym)->IsFunction() && "Invalid error handler");
|
assert(handle->Get(onerror_sym)->IsFunction() && "Invalid error handler");
|
||||||
HandleScope scope(node_isolate);
|
HandleScope scope(node_isolate);
|
||||||
Local<Value> args[2] = {
|
Local<Value> args[2] = {
|
||||||
String::New(msg),
|
OneByteString(node_isolate, msg),
|
||||||
Number::New(ctx->err_)
|
Number::New(ctx->err_)
|
||||||
};
|
};
|
||||||
MakeCallback(handle, onerror_sym, ARRAY_SIZE(args), args);
|
MakeCallback(handle, onerror_sym, ARRAY_SIZE(args), args);
|
||||||
@ -543,11 +543,11 @@ void InitZlib(Handle<Object> target) {
|
|||||||
NODE_SET_PROTOTYPE_METHOD(z, "params", ZCtx::Params);
|
NODE_SET_PROTOTYPE_METHOD(z, "params", ZCtx::Params);
|
||||||
NODE_SET_PROTOTYPE_METHOD(z, "reset", ZCtx::Reset);
|
NODE_SET_PROTOTYPE_METHOD(z, "reset", ZCtx::Reset);
|
||||||
|
|
||||||
z->SetClassName(String::NewSymbol("Zlib"));
|
z->SetClassName(FIXED_ONE_BYTE_STRING(node_isolate, "Zlib"));
|
||||||
target->Set(String::NewSymbol("Zlib"), z->GetFunction());
|
target->Set(FIXED_ONE_BYTE_STRING(node_isolate, "Zlib"), z->GetFunction());
|
||||||
|
|
||||||
callback_sym = String::New("callback");
|
callback_sym = FIXED_ONE_BYTE_STRING(node_isolate, "callback");
|
||||||
onerror_sym = String::New("onerror");
|
onerror_sym = FIXED_ONE_BYTE_STRING(node_isolate, "onerror");
|
||||||
|
|
||||||
// valid flush values.
|
// valid flush values.
|
||||||
NODE_DEFINE_CONSTANT(target, Z_NO_FLUSH);
|
NODE_DEFINE_CONSTANT(target, Z_NO_FLUSH);
|
||||||
@ -587,7 +587,8 @@ void InitZlib(Handle<Object> target) {
|
|||||||
NODE_DEFINE_CONSTANT(target, INFLATERAW);
|
NODE_DEFINE_CONSTANT(target, INFLATERAW);
|
||||||
NODE_DEFINE_CONSTANT(target, UNZIP);
|
NODE_DEFINE_CONSTANT(target, UNZIP);
|
||||||
|
|
||||||
target->Set(String::NewSymbol("ZLIB_VERSION"), String::New(ZLIB_VERSION));
|
target->Set(FIXED_ONE_BYTE_STRING(node_isolate, "ZLIB_VERSION"),
|
||||||
|
FIXED_ONE_BYTE_STRING(node_isolate, ZLIB_VERSION));
|
||||||
}
|
}
|
||||||
|
|
||||||
} // namespace node
|
} // namespace node
|
||||||
|
@ -78,13 +78,13 @@ void PipeWrap::Initialize(Handle<Object> target) {
|
|||||||
HandleScope scope(node_isolate);
|
HandleScope scope(node_isolate);
|
||||||
|
|
||||||
Local<FunctionTemplate> t = FunctionTemplate::New(New);
|
Local<FunctionTemplate> t = FunctionTemplate::New(New);
|
||||||
t->SetClassName(String::NewSymbol("Pipe"));
|
t->SetClassName(FIXED_ONE_BYTE_STRING(node_isolate, "Pipe"));
|
||||||
|
|
||||||
t->InstanceTemplate()->SetInternalFieldCount(1);
|
t->InstanceTemplate()->SetInternalFieldCount(1);
|
||||||
|
|
||||||
enum PropertyAttribute attributes =
|
enum PropertyAttribute attributes =
|
||||||
static_cast<PropertyAttribute>(v8::ReadOnly | v8::DontDelete);
|
static_cast<PropertyAttribute>(v8::ReadOnly | v8::DontDelete);
|
||||||
t->InstanceTemplate()->SetAccessor(String::New("fd"),
|
t->InstanceTemplate()->SetAccessor(FIXED_ONE_BYTE_STRING(node_isolate, "fd"),
|
||||||
StreamWrap::GetFD,
|
StreamWrap::GetFD,
|
||||||
NULL,
|
NULL,
|
||||||
Handle<Value>(),
|
Handle<Value>(),
|
||||||
@ -117,7 +117,7 @@ void PipeWrap::Initialize(Handle<Object> target) {
|
|||||||
|
|
||||||
pipeConstructorTmpl.Reset(node_isolate, t);
|
pipeConstructorTmpl.Reset(node_isolate, t);
|
||||||
pipeConstructor.Reset(node_isolate, t->GetFunction());
|
pipeConstructor.Reset(node_isolate, t->GetFunction());
|
||||||
target->Set(String::NewSymbol("Pipe"), t->GetFunction());
|
target->Set(FIXED_ONE_BYTE_STRING(node_isolate, "Pipe"), t->GetFunction());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@ -214,7 +214,7 @@ void PipeWrap::OnConnection(uv_stream_t* handle, int status) {
|
|||||||
// Successful accept. Call the onconnection callback in JavaScript land.
|
// Successful accept. Call the onconnection callback in JavaScript land.
|
||||||
argv[1] = client_obj;
|
argv[1] = client_obj;
|
||||||
if (onconnection_sym.IsEmpty()) {
|
if (onconnection_sym.IsEmpty()) {
|
||||||
onconnection_sym = String::New("onconnection");
|
onconnection_sym = FIXED_ONE_BYTE_STRING(node_isolate, "onconnection");
|
||||||
}
|
}
|
||||||
MakeCallback(wrap->object(), onconnection_sym, ARRAY_SIZE(argv), argv);
|
MakeCallback(wrap->object(), onconnection_sym, ARRAY_SIZE(argv), argv);
|
||||||
}
|
}
|
||||||
@ -249,7 +249,7 @@ void PipeWrap::AfterConnect(uv_connect_t* req, int status) {
|
|||||||
};
|
};
|
||||||
|
|
||||||
if (oncomplete_sym.IsEmpty()) {
|
if (oncomplete_sym.IsEmpty()) {
|
||||||
oncomplete_sym = String::New("oncomplete");
|
oncomplete_sym = FIXED_ONE_BYTE_STRING(node_isolate, "oncomplete");
|
||||||
}
|
}
|
||||||
MakeCallback(req_wrap_obj, oncomplete_sym, ARRAY_SIZE(argv), argv);
|
MakeCallback(req_wrap_obj, oncomplete_sym, ARRAY_SIZE(argv), argv);
|
||||||
|
|
||||||
|
@ -50,7 +50,7 @@ class ProcessWrap : public HandleWrap {
|
|||||||
|
|
||||||
Local<FunctionTemplate> constructor = FunctionTemplate::New(New);
|
Local<FunctionTemplate> constructor = FunctionTemplate::New(New);
|
||||||
constructor->InstanceTemplate()->SetInternalFieldCount(1);
|
constructor->InstanceTemplate()->SetInternalFieldCount(1);
|
||||||
constructor->SetClassName(String::NewSymbol("Process"));
|
constructor->SetClassName(FIXED_ONE_BYTE_STRING(node_isolate, "Process"));
|
||||||
|
|
||||||
NODE_SET_PROTOTYPE_METHOD(constructor, "close", HandleWrap::Close);
|
NODE_SET_PROTOTYPE_METHOD(constructor, "close", HandleWrap::Close);
|
||||||
|
|
||||||
@ -60,7 +60,8 @@ class ProcessWrap : public HandleWrap {
|
|||||||
NODE_SET_PROTOTYPE_METHOD(constructor, "ref", HandleWrap::Ref);
|
NODE_SET_PROTOTYPE_METHOD(constructor, "ref", HandleWrap::Ref);
|
||||||
NODE_SET_PROTOTYPE_METHOD(constructor, "unref", HandleWrap::Unref);
|
NODE_SET_PROTOTYPE_METHOD(constructor, "unref", HandleWrap::Unref);
|
||||||
|
|
||||||
target->Set(String::NewSymbol("Process"), constructor->GetFunction());
|
target->Set(FIXED_ONE_BYTE_STRING(node_isolate, "Process"),
|
||||||
|
constructor->GetFunction());
|
||||||
}
|
}
|
||||||
|
|
||||||
private:
|
private:
|
||||||
@ -82,34 +83,41 @@ class ProcessWrap : public HandleWrap {
|
|||||||
|
|
||||||
static void ParseStdioOptions(Local<Object> js_options,
|
static void ParseStdioOptions(Local<Object> js_options,
|
||||||
uv_process_options_t* options) {
|
uv_process_options_t* options) {
|
||||||
Local<Array> stdios = js_options
|
Local<String> stdio_key =
|
||||||
->Get(String::NewSymbol("stdio")).As<Array>();
|
FIXED_ONE_BYTE_STRING(node_isolate, "stdio");
|
||||||
|
Local<Array> stdios = js_options->Get(stdio_key).As<Array>();
|
||||||
uint32_t len = stdios->Length();
|
uint32_t len = stdios->Length();
|
||||||
options->stdio = new uv_stdio_container_t[len];
|
options->stdio = new uv_stdio_container_t[len];
|
||||||
options->stdio_count = len;
|
options->stdio_count = len;
|
||||||
|
|
||||||
for (uint32_t i = 0; i < len; i++) {
|
for (uint32_t i = 0; i < len; i++) {
|
||||||
Local<Object> stdio = stdios->Get(i).As<Object>();
|
Local<Object> stdio = stdios->Get(i).As<Object>();
|
||||||
Local<Value> type = stdio->Get(String::NewSymbol("type"));
|
Local<Value> type =
|
||||||
|
stdio->Get(FIXED_ONE_BYTE_STRING(node_isolate, "type"));
|
||||||
|
|
||||||
if (type->Equals(String::NewSymbol("ignore"))) {
|
if (type->Equals(FIXED_ONE_BYTE_STRING(node_isolate, "ignore"))) {
|
||||||
options->stdio[i].flags = UV_IGNORE;
|
options->stdio[i].flags = UV_IGNORE;
|
||||||
} else if (type->Equals(String::NewSymbol("pipe"))) {
|
} else if (type->Equals(FIXED_ONE_BYTE_STRING(node_isolate, "pipe"))) {
|
||||||
options->stdio[i].flags = static_cast<uv_stdio_flags>(
|
options->stdio[i].flags = static_cast<uv_stdio_flags>(
|
||||||
UV_CREATE_PIPE | UV_READABLE_PIPE | UV_WRITABLE_PIPE);
|
UV_CREATE_PIPE | UV_READABLE_PIPE | UV_WRITABLE_PIPE);
|
||||||
options->stdio[i].data.stream = reinterpret_cast<uv_stream_t*>(
|
Local<String> handle_key =
|
||||||
PipeWrap::Unwrap(stdio
|
FIXED_ONE_BYTE_STRING(node_isolate, "handle");
|
||||||
->Get(String::NewSymbol("handle")).As<Object>())->UVHandle());
|
Local<Object> handle = stdio->Get(handle_key).As<Object>();
|
||||||
} else if (type->Equals(String::NewSymbol("wrap"))) {
|
options->stdio[i].data.stream =
|
||||||
uv_stream_t* stream = HandleToStream(
|
reinterpret_cast<uv_stream_t*>(
|
||||||
stdio->Get(String::NewSymbol("handle")).As<Object>());
|
PipeWrap::Unwrap(handle)->UVHandle());
|
||||||
|
} else if (type->Equals(FIXED_ONE_BYTE_STRING(node_isolate, "wrap"))) {
|
||||||
|
Local<String> handle_key =
|
||||||
|
FIXED_ONE_BYTE_STRING(node_isolate, "handle");
|
||||||
|
Local<Object> handle = stdio->Get(handle_key).As<Object>();
|
||||||
|
uv_stream_t* stream = HandleToStream(handle);
|
||||||
assert(stream != NULL);
|
assert(stream != NULL);
|
||||||
|
|
||||||
options->stdio[i].flags = UV_INHERIT_STREAM;
|
options->stdio[i].flags = UV_INHERIT_STREAM;
|
||||||
options->stdio[i].data.stream = stream;
|
options->stdio[i].data.stream = stream;
|
||||||
} else {
|
} else {
|
||||||
int fd = static_cast<int>(
|
Local<String> fd_key = FIXED_ONE_BYTE_STRING(node_isolate, "fd");
|
||||||
stdio->Get(String::NewSymbol("fd"))->IntegerValue());
|
int fd = static_cast<int>(stdio->Get(fd_key)->IntegerValue());
|
||||||
|
|
||||||
options->stdio[i].flags = UV_INHERIT_FD;
|
options->stdio[i].flags = UV_INHERIT_FD;
|
||||||
options->stdio[i].data.fd = fd;
|
options->stdio[i].data.fd = fd;
|
||||||
@ -130,7 +138,8 @@ class ProcessWrap : public HandleWrap {
|
|||||||
options.exit_cb = OnExit;
|
options.exit_cb = OnExit;
|
||||||
|
|
||||||
// options.uid
|
// options.uid
|
||||||
Local<Value> uid_v = js_options->Get(String::NewSymbol("uid"));
|
Local<Value> uid_v =
|
||||||
|
js_options->Get(FIXED_ONE_BYTE_STRING(node_isolate, "uid"));
|
||||||
if (uid_v->IsInt32()) {
|
if (uid_v->IsInt32()) {
|
||||||
int32_t uid = uid_v->Int32Value();
|
int32_t uid = uid_v->Int32Value();
|
||||||
if (uid & ~((uv_uid_t) ~0)) {
|
if (uid & ~((uv_uid_t) ~0)) {
|
||||||
@ -143,7 +152,8 @@ class ProcessWrap : public HandleWrap {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// options.gid
|
// options.gid
|
||||||
Local<Value> gid_v = js_options->Get(String::NewSymbol("gid"));
|
Local<Value> gid_v =
|
||||||
|
js_options->Get(FIXED_ONE_BYTE_STRING(node_isolate, "gid"));
|
||||||
if (gid_v->IsInt32()) {
|
if (gid_v->IsInt32()) {
|
||||||
int32_t gid = gid_v->Int32Value();
|
int32_t gid = gid_v->Int32Value();
|
||||||
if (gid & ~((uv_gid_t) ~0)) {
|
if (gid & ~((uv_gid_t) ~0)) {
|
||||||
@ -158,7 +168,8 @@ class ProcessWrap : public HandleWrap {
|
|||||||
// TODO(bnoordhuis) is this possible to do without mallocing ?
|
// TODO(bnoordhuis) is this possible to do without mallocing ?
|
||||||
|
|
||||||
// options.file
|
// options.file
|
||||||
Local<Value> file_v = js_options->Get(String::NewSymbol("file"));
|
Local<Value> file_v =
|
||||||
|
js_options->Get(FIXED_ONE_BYTE_STRING(node_isolate, "file"));
|
||||||
String::Utf8Value file(file_v->IsString() ? file_v : Local<Value>());
|
String::Utf8Value file(file_v->IsString() ? file_v : Local<Value>());
|
||||||
if (file.length() > 0) {
|
if (file.length() > 0) {
|
||||||
options.file = *file;
|
options.file = *file;
|
||||||
@ -167,7 +178,8 @@ class ProcessWrap : public HandleWrap {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// options.args
|
// options.args
|
||||||
Local<Value> argv_v = js_options->Get(String::NewSymbol("args"));
|
Local<Value> argv_v =
|
||||||
|
js_options->Get(FIXED_ONE_BYTE_STRING(node_isolate, "args"));
|
||||||
if (!argv_v.IsEmpty() && argv_v->IsArray()) {
|
if (!argv_v.IsEmpty() && argv_v->IsArray()) {
|
||||||
Local<Array> js_argv = Local<Array>::Cast(argv_v);
|
Local<Array> js_argv = Local<Array>::Cast(argv_v);
|
||||||
int argc = js_argv->Length();
|
int argc = js_argv->Length();
|
||||||
@ -181,14 +193,16 @@ class ProcessWrap : public HandleWrap {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// options.cwd
|
// options.cwd
|
||||||
Local<Value> cwd_v = js_options->Get(String::NewSymbol("cwd"));
|
Local<Value> cwd_v =
|
||||||
|
js_options->Get(FIXED_ONE_BYTE_STRING(node_isolate, "cwd"));
|
||||||
String::Utf8Value cwd(cwd_v->IsString() ? cwd_v : Local<Value>());
|
String::Utf8Value cwd(cwd_v->IsString() ? cwd_v : Local<Value>());
|
||||||
if (cwd.length() > 0) {
|
if (cwd.length() > 0) {
|
||||||
options.cwd = *cwd;
|
options.cwd = *cwd;
|
||||||
}
|
}
|
||||||
|
|
||||||
// options.env
|
// options.env
|
||||||
Local<Value> env_v = js_options->Get(String::NewSymbol("envPairs"));
|
Local<Value> env_v =
|
||||||
|
js_options->Get(FIXED_ONE_BYTE_STRING(node_isolate, "envPairs"));
|
||||||
if (!env_v.IsEmpty() && env_v->IsArray()) {
|
if (!env_v.IsEmpty() && env_v->IsArray()) {
|
||||||
Local<Array> env = Local<Array>::Cast(env_v);
|
Local<Array> env = Local<Array>::Cast(env_v);
|
||||||
int envc = env->Length();
|
int envc = env->Length();
|
||||||
@ -204,13 +218,16 @@ class ProcessWrap : public HandleWrap {
|
|||||||
ParseStdioOptions(js_options, &options);
|
ParseStdioOptions(js_options, &options);
|
||||||
|
|
||||||
// options.windows_verbatim_arguments
|
// options.windows_verbatim_arguments
|
||||||
if (js_options->Get(String::NewSymbol("windowsVerbatimArguments"))->
|
Local<String> windows_verbatim_arguments_key =
|
||||||
IsTrue()) {
|
FIXED_ONE_BYTE_STRING(node_isolate, "windowsVerbatimArguments");
|
||||||
|
if (js_options->Get(windows_verbatim_arguments_key)->IsTrue()) {
|
||||||
options.flags |= UV_PROCESS_WINDOWS_VERBATIM_ARGUMENTS;
|
options.flags |= UV_PROCESS_WINDOWS_VERBATIM_ARGUMENTS;
|
||||||
}
|
}
|
||||||
|
|
||||||
// options.detached
|
// options.detached
|
||||||
if (js_options->Get(String::NewSymbol("detached"))->IsTrue()) {
|
Local<String> detached_key =
|
||||||
|
FIXED_ONE_BYTE_STRING(node_isolate, "detached");
|
||||||
|
if (js_options->Get(detached_key)->IsTrue()) {
|
||||||
options.flags |= UV_PROCESS_DETACHED;
|
options.flags |= UV_PROCESS_DETACHED;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -218,7 +235,7 @@ class ProcessWrap : public HandleWrap {
|
|||||||
|
|
||||||
if (err == 0) {
|
if (err == 0) {
|
||||||
assert(wrap->process_.data == wrap);
|
assert(wrap->process_.data == wrap);
|
||||||
wrap->object()->Set(String::New("pid"),
|
wrap->object()->Set(FIXED_ONE_BYTE_STRING(node_isolate, "pid"),
|
||||||
Integer::New(wrap->process_.pid, node_isolate));
|
Integer::New(wrap->process_.pid, node_isolate));
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -255,11 +272,11 @@ class ProcessWrap : public HandleWrap {
|
|||||||
|
|
||||||
Local<Value> argv[] = {
|
Local<Value> argv[] = {
|
||||||
Integer::New(exit_status, node_isolate),
|
Integer::New(exit_status, node_isolate),
|
||||||
String::New(signo_string(term_signal))
|
OneByteString(node_isolate, signo_string(term_signal))
|
||||||
};
|
};
|
||||||
|
|
||||||
if (onexit_sym.IsEmpty()) {
|
if (onexit_sym.IsEmpty()) {
|
||||||
onexit_sym = String::New("onexit");
|
onexit_sym = FIXED_ONE_BYTE_STRING(node_isolate, "onexit");
|
||||||
}
|
}
|
||||||
|
|
||||||
MakeCallback(wrap->object(), onexit_sym, ARRAY_SIZE(argv), argv);
|
MakeCallback(wrap->object(), onexit_sym, ARRAY_SIZE(argv), argv);
|
||||||
|
@ -46,7 +46,7 @@ class SignalWrap : public HandleWrap {
|
|||||||
|
|
||||||
Local<FunctionTemplate> constructor = FunctionTemplate::New(New);
|
Local<FunctionTemplate> constructor = FunctionTemplate::New(New);
|
||||||
constructor->InstanceTemplate()->SetInternalFieldCount(1);
|
constructor->InstanceTemplate()->SetInternalFieldCount(1);
|
||||||
constructor->SetClassName(String::NewSymbol("Signal"));
|
constructor->SetClassName(FIXED_ONE_BYTE_STRING(node_isolate, "Signal"));
|
||||||
|
|
||||||
NODE_SET_PROTOTYPE_METHOD(constructor, "close", HandleWrap::Close);
|
NODE_SET_PROTOTYPE_METHOD(constructor, "close", HandleWrap::Close);
|
||||||
NODE_SET_PROTOTYPE_METHOD(constructor, "ref", HandleWrap::Ref);
|
NODE_SET_PROTOTYPE_METHOD(constructor, "ref", HandleWrap::Ref);
|
||||||
@ -54,9 +54,10 @@ class SignalWrap : public HandleWrap {
|
|||||||
NODE_SET_PROTOTYPE_METHOD(constructor, "start", Start);
|
NODE_SET_PROTOTYPE_METHOD(constructor, "start", Start);
|
||||||
NODE_SET_PROTOTYPE_METHOD(constructor, "stop", Stop);
|
NODE_SET_PROTOTYPE_METHOD(constructor, "stop", Stop);
|
||||||
|
|
||||||
onsignal_sym = String::New("onsignal");
|
onsignal_sym = FIXED_ONE_BYTE_STRING(node_isolate, "onsignal");
|
||||||
|
|
||||||
target->Set(String::NewSymbol("Signal"), constructor->GetFunction());
|
target->Set(FIXED_ONE_BYTE_STRING(node_isolate, "Signal"),
|
||||||
|
constructor->GetFunction());
|
||||||
}
|
}
|
||||||
|
|
||||||
private:
|
private:
|
||||||
|
@ -359,7 +359,7 @@ void Alloc(Handle<Object> obj,
|
|||||||
assert(!obj->HasIndexedPropertiesInExternalArrayData());
|
assert(!obj->HasIndexedPropertiesInExternalArrayData());
|
||||||
|
|
||||||
if (smalloc_sym.IsEmpty()) {
|
if (smalloc_sym.IsEmpty()) {
|
||||||
smalloc_sym = String::New("_smalloc_p");
|
smalloc_sym = FIXED_ONE_BYTE_STRING(node_isolate, "_smalloc_p");
|
||||||
using_alloc_cb = true;
|
using_alloc_cb = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -466,7 +466,7 @@ void Initialize(Handle<Object> exports) {
|
|||||||
NODE_SET_METHOD(exports, "alloc", Alloc);
|
NODE_SET_METHOD(exports, "alloc", Alloc);
|
||||||
NODE_SET_METHOD(exports, "dispose", AllocDispose);
|
NODE_SET_METHOD(exports, "dispose", AllocDispose);
|
||||||
|
|
||||||
exports->Set(String::New("kMaxLength"),
|
exports->Set(FIXED_ONE_BYTE_STRING(node_isolate, "kMaxLength"),
|
||||||
Uint32::NewFromUnsigned(kMaxLength, node_isolate));
|
Uint32::NewFromUnsigned(kMaxLength, node_isolate));
|
||||||
|
|
||||||
// for performance, begin checking if allocation object may contain
|
// for performance, begin checking if allocation object may contain
|
||||||
|
@ -63,11 +63,11 @@ void StreamWrap::Initialize(Handle<Object> target) {
|
|||||||
initialized = true;
|
initialized = true;
|
||||||
|
|
||||||
HandleScope scope(node_isolate);
|
HandleScope scope(node_isolate);
|
||||||
buffer_sym = String::New("buffer");
|
buffer_sym = FIXED_ONE_BYTE_STRING(node_isolate, "buffer");
|
||||||
bytes_sym = String::New("bytes");
|
bytes_sym = FIXED_ONE_BYTE_STRING(node_isolate, "bytes");
|
||||||
write_queue_size_sym = String::New("writeQueueSize");
|
write_queue_size_sym = FIXED_ONE_BYTE_STRING(node_isolate, "writeQueueSize");
|
||||||
onread_sym = String::New("onread");
|
onread_sym = FIXED_ONE_BYTE_STRING(node_isolate, "onread");
|
||||||
oncomplete_sym = String::New("oncomplete");
|
oncomplete_sym = FIXED_ONE_BYTE_STRING(node_isolate, "oncomplete");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@ -299,7 +299,7 @@ void StreamWrap::WriteStringImpl(const FunctionCallbackInfo<Value>& args) {
|
|||||||
// Reference StreamWrap instance to prevent it from being garbage
|
// Reference StreamWrap instance to prevent it from being garbage
|
||||||
// collected before `AfterWrite` is called.
|
// collected before `AfterWrite` is called.
|
||||||
if (handle_sym.IsEmpty()) {
|
if (handle_sym.IsEmpty()) {
|
||||||
handle_sym = String::New("handle");
|
handle_sym = FIXED_ONE_BYTE_STRING(node_isolate, "handle");
|
||||||
}
|
}
|
||||||
assert(!req_wrap->persistent().IsEmpty());
|
assert(!req_wrap->persistent().IsEmpty());
|
||||||
req_wrap->object()->Set(handle_sym, send_handle_obj);
|
req_wrap->object()->Set(handle_sym, send_handle_obj);
|
||||||
|
@ -645,20 +645,14 @@ Local<Value> StringBytes::Encode(const char* buf,
|
|||||||
char* out = new char[buflen];
|
char* out = new char[buflen];
|
||||||
force_ascii(buf, out, buflen);
|
force_ascii(buf, out, buflen);
|
||||||
if (buflen < EXTERN_APEX) {
|
if (buflen < EXTERN_APEX) {
|
||||||
val = String::NewFromOneByte(node_isolate,
|
val = OneByteString(node_isolate, out, buflen);
|
||||||
reinterpret_cast<const uint8_t*>(out),
|
|
||||||
String::kNormalString,
|
|
||||||
buflen);
|
|
||||||
delete[] out;
|
delete[] out;
|
||||||
} else {
|
} else {
|
||||||
val = ExternOneByteString::New(out, buflen);
|
val = ExternOneByteString::New(out, buflen);
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
if (buflen < EXTERN_APEX)
|
if (buflen < EXTERN_APEX)
|
||||||
val = String::NewFromOneByte(node_isolate,
|
val = OneByteString(node_isolate, buf, buflen);
|
||||||
reinterpret_cast<const uint8_t*>(buf),
|
|
||||||
String::kNormalString,
|
|
||||||
buflen);
|
|
||||||
else
|
else
|
||||||
val = ExternOneByteString::NewFromCopy(buf, buflen);
|
val = ExternOneByteString::NewFromCopy(buf, buflen);
|
||||||
}
|
}
|
||||||
@ -673,10 +667,7 @@ Local<Value> StringBytes::Encode(const char* buf,
|
|||||||
|
|
||||||
case BINARY:
|
case BINARY:
|
||||||
if (buflen < EXTERN_APEX)
|
if (buflen < EXTERN_APEX)
|
||||||
val = String::NewFromOneByte(node_isolate,
|
val = OneByteString(node_isolate, buf, buflen);
|
||||||
reinterpret_cast<const uint8_t*>(buf),
|
|
||||||
String::kNormalString,
|
|
||||||
buflen);
|
|
||||||
else
|
else
|
||||||
val = ExternOneByteString::NewFromCopy(buf, buflen);
|
val = ExternOneByteString::NewFromCopy(buf, buflen);
|
||||||
break;
|
break;
|
||||||
@ -689,10 +680,7 @@ Local<Value> StringBytes::Encode(const char* buf,
|
|||||||
assert(written == dlen);
|
assert(written == dlen);
|
||||||
|
|
||||||
if (dlen < EXTERN_APEX) {
|
if (dlen < EXTERN_APEX) {
|
||||||
val = String::NewFromOneByte(node_isolate,
|
val = OneByteString(node_isolate, dst, dlen);
|
||||||
reinterpret_cast<const uint8_t*>(dst),
|
|
||||||
String::kNormalString,
|
|
||||||
dlen);
|
|
||||||
delete[] dst;
|
delete[] dst;
|
||||||
} else {
|
} else {
|
||||||
val = ExternOneByteString::New(dst, dlen);
|
val = ExternOneByteString::New(dst, dlen);
|
||||||
@ -719,10 +707,7 @@ Local<Value> StringBytes::Encode(const char* buf,
|
|||||||
assert(written == dlen);
|
assert(written == dlen);
|
||||||
|
|
||||||
if (dlen < EXTERN_APEX) {
|
if (dlen < EXTERN_APEX) {
|
||||||
val = String::NewFromOneByte(node_isolate,
|
val = OneByteString(node_isolate, dst, dlen);
|
||||||
reinterpret_cast<const uint8_t*>(dst),
|
|
||||||
String::kNormalString,
|
|
||||||
dlen);
|
|
||||||
delete[] dst;
|
delete[] dst;
|
||||||
} else {
|
} else {
|
||||||
val = ExternOneByteString::New(dst, dlen);
|
val = ExternOneByteString::New(dst, dlen);
|
||||||
|
@ -72,13 +72,13 @@ void TCPWrap::Initialize(Handle<Object> target) {
|
|||||||
HandleScope scope(node_isolate);
|
HandleScope scope(node_isolate);
|
||||||
|
|
||||||
Local<FunctionTemplate> t = FunctionTemplate::New(New);
|
Local<FunctionTemplate> t = FunctionTemplate::New(New);
|
||||||
t->SetClassName(String::NewSymbol("TCP"));
|
t->SetClassName(FIXED_ONE_BYTE_STRING(node_isolate, "TCP"));
|
||||||
|
|
||||||
t->InstanceTemplate()->SetInternalFieldCount(1);
|
t->InstanceTemplate()->SetInternalFieldCount(1);
|
||||||
|
|
||||||
enum PropertyAttribute attributes =
|
enum PropertyAttribute attributes =
|
||||||
static_cast<PropertyAttribute>(v8::ReadOnly | v8::DontDelete);
|
static_cast<PropertyAttribute>(v8::ReadOnly | v8::DontDelete);
|
||||||
t->InstanceTemplate()->SetAccessor(String::New("fd"),
|
t->InstanceTemplate()->SetAccessor(FIXED_ONE_BYTE_STRING(node_isolate, "fd"),
|
||||||
StreamWrap::GetFD,
|
StreamWrap::GetFD,
|
||||||
NULL,
|
NULL,
|
||||||
Handle<Value>(),
|
Handle<Value>(),
|
||||||
@ -119,12 +119,12 @@ void TCPWrap::Initialize(Handle<Object> target) {
|
|||||||
SetSimultaneousAccepts);
|
SetSimultaneousAccepts);
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
onconnection_sym = String::New("onconnection");
|
onconnection_sym = FIXED_ONE_BYTE_STRING(node_isolate, "onconnection");
|
||||||
oncomplete_sym = String::New("oncomplete");
|
oncomplete_sym = FIXED_ONE_BYTE_STRING(node_isolate, "oncomplete");
|
||||||
|
|
||||||
tcpConstructorTmpl.Reset(node_isolate, t);
|
tcpConstructorTmpl.Reset(node_isolate, t);
|
||||||
tcpConstructor.Reset(node_isolate, t->GetFunction());
|
tcpConstructor.Reset(node_isolate, t->GetFunction());
|
||||||
target->Set(String::NewSymbol("TCP"), t->GetFunction());
|
target->Set(FIXED_ONE_BYTE_STRING(node_isolate, "TCP"), t->GetFunction());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@ -431,11 +431,11 @@ Local<Object> AddressToJS(const sockaddr* addr, Handle<Object> info) {
|
|||||||
int port;
|
int port;
|
||||||
|
|
||||||
if (address_sym.IsEmpty()) {
|
if (address_sym.IsEmpty()) {
|
||||||
address_sym = String::New("address");
|
address_sym = FIXED_ONE_BYTE_STRING(node_isolate, "address");
|
||||||
family_sym = String::New("family");
|
family_sym = FIXED_ONE_BYTE_STRING(node_isolate, "family");
|
||||||
port_sym = String::New("port");
|
port_sym = FIXED_ONE_BYTE_STRING(node_isolate, "port");
|
||||||
ipv4_sym = String::New("IPv4");
|
ipv4_sym = FIXED_ONE_BYTE_STRING(node_isolate, "IPv4");
|
||||||
ipv6_sym = String::New("IPv6");
|
ipv6_sym = FIXED_ONE_BYTE_STRING(node_isolate, "IPv6");
|
||||||
}
|
}
|
||||||
|
|
||||||
if (info.IsEmpty()) info = Object::New();
|
if (info.IsEmpty()) info = Object::New();
|
||||||
@ -445,7 +445,7 @@ Local<Object> AddressToJS(const sockaddr* addr, Handle<Object> info) {
|
|||||||
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(address_sym, String::New(ip));
|
info->Set(address_sym, OneByteString(node_isolate, ip));
|
||||||
info->Set(family_sym, ipv6_sym);
|
info->Set(family_sym, ipv6_sym);
|
||||||
info->Set(port_sym, Integer::New(port, node_isolate));
|
info->Set(port_sym, Integer::New(port, node_isolate));
|
||||||
break;
|
break;
|
||||||
@ -454,7 +454,7 @@ Local<Object> AddressToJS(const sockaddr* addr, Handle<Object> info) {
|
|||||||
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(address_sym, String::New(ip));
|
info->Set(address_sym, OneByteString(node_isolate, ip));
|
||||||
info->Set(family_sym, ipv4_sym);
|
info->Set(family_sym, ipv4_sym);
|
||||||
info->Set(port_sym, Integer::New(port, node_isolate));
|
info->Set(port_sym, Integer::New(port, node_isolate));
|
||||||
break;
|
break;
|
||||||
|
@ -44,7 +44,7 @@ class TimerWrap : public HandleWrap {
|
|||||||
|
|
||||||
Local<FunctionTemplate> constructor = FunctionTemplate::New(New);
|
Local<FunctionTemplate> constructor = FunctionTemplate::New(New);
|
||||||
constructor->InstanceTemplate()->SetInternalFieldCount(1);
|
constructor->InstanceTemplate()->SetInternalFieldCount(1);
|
||||||
constructor->SetClassName(String::NewSymbol("Timer"));
|
constructor->SetClassName(FIXED_ONE_BYTE_STRING(node_isolate, "Timer"));
|
||||||
|
|
||||||
NODE_SET_METHOD(constructor, "now", Now);
|
NODE_SET_METHOD(constructor, "now", Now);
|
||||||
|
|
||||||
@ -58,9 +58,10 @@ class TimerWrap : public HandleWrap {
|
|||||||
NODE_SET_PROTOTYPE_METHOD(constructor, "getRepeat", GetRepeat);
|
NODE_SET_PROTOTYPE_METHOD(constructor, "getRepeat", GetRepeat);
|
||||||
NODE_SET_PROTOTYPE_METHOD(constructor, "again", Again);
|
NODE_SET_PROTOTYPE_METHOD(constructor, "again", Again);
|
||||||
|
|
||||||
ontimeout_sym = String::New("ontimeout");
|
ontimeout_sym = FIXED_ONE_BYTE_STRING(node_isolate, "ontimeout");
|
||||||
|
|
||||||
target->Set(String::NewSymbol("Timer"), constructor->GetFunction());
|
target->Set(FIXED_ONE_BYTE_STRING(node_isolate, "Timer"),
|
||||||
|
constructor->GetFunction());
|
||||||
}
|
}
|
||||||
|
|
||||||
private:
|
private:
|
||||||
|
106
src/tls_wrap.cc
106
src/tls_wrap.cc
@ -420,7 +420,7 @@ void TLSCallbacks::EncOutCb(uv_write_t* req, int status) {
|
|||||||
|
|
||||||
// Notify about error
|
// Notify about error
|
||||||
Local<Value> arg = String::Concat(
|
Local<Value> arg = String::Concat(
|
||||||
String::New("write cb error, status: "),
|
FIXED_ONE_BYTE_STRING(node_isolate, "write cb error, status: "),
|
||||||
Integer::New(status, node_isolate)->ToString());
|
Integer::New(status, node_isolate)->ToString());
|
||||||
MakeCallback(callbacks->object(), onerror_sym, 1, &arg);
|
MakeCallback(callbacks->object(), onerror_sym, 1, &arg);
|
||||||
callbacks->InvokeQueued(status);
|
callbacks->InvokeQueued(status);
|
||||||
@ -446,7 +446,7 @@ Handle<Value> TLSCallbacks::GetSSLError(int status, int* err) {
|
|||||||
case SSL_ERROR_WANT_WRITE:
|
case SSL_ERROR_WANT_WRITE:
|
||||||
break;
|
break;
|
||||||
case SSL_ERROR_ZERO_RETURN:
|
case SSL_ERROR_ZERO_RETURN:
|
||||||
return scope.Close(String::NewSymbol("ZERO_RETURN"));
|
return scope.Close(FIXED_ONE_BYTE_STRING(node_isolate, "ZERO_RETURN"));
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
{
|
{
|
||||||
@ -459,10 +459,12 @@ Handle<Value> TLSCallbacks::GetSSLError(int status, int* err) {
|
|||||||
assert(bio != NULL);
|
assert(bio != NULL);
|
||||||
ERR_print_errors(bio);
|
ERR_print_errors(bio);
|
||||||
BIO_get_mem_ptr(bio, &mem);
|
BIO_get_mem_ptr(bio, &mem);
|
||||||
Handle<Value> r = Exception::Error(String::New(mem->data, mem->length));
|
Local<String> message =
|
||||||
|
OneByteString(node_isolate, mem->data, mem->length);
|
||||||
|
Local<Value> exception = Exception::Error(message);
|
||||||
BIO_free_all(bio);
|
BIO_free_all(bio);
|
||||||
|
|
||||||
return scope.Close(r);
|
return scope.Close(exception);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return Handle<Value>();
|
return Handle<Value>();
|
||||||
@ -672,7 +674,8 @@ void TLSCallbacks::VerifyError(const FunctionCallbackInfo<Value>& args) {
|
|||||||
// We requested a certificate and they did not send us one.
|
// We requested a certificate and they did not send us one.
|
||||||
// Definitely an error.
|
// Definitely an error.
|
||||||
// XXX is this the right error message?
|
// XXX is this the right error message?
|
||||||
Local<String> s = String::New("UNABLE_TO_GET_ISSUER_CERT");
|
Local<String> s =
|
||||||
|
FIXED_ONE_BYTE_STRING(node_isolate, "UNABLE_TO_GET_ISSUER_CERT");
|
||||||
return args.GetReturnValue().Set(Exception::Error(s));
|
return args.GetReturnValue().Set(Exception::Error(s));
|
||||||
}
|
}
|
||||||
X509_free(peer_cert);
|
X509_free(peer_cert);
|
||||||
@ -712,12 +715,13 @@ void TLSCallbacks::VerifyError(const FunctionCallbackInfo<Value>& args) {
|
|||||||
CASE_X509_ERR(CERT_UNTRUSTED)
|
CASE_X509_ERR(CERT_UNTRUSTED)
|
||||||
CASE_X509_ERR(CERT_REJECTED)
|
CASE_X509_ERR(CERT_REJECTED)
|
||||||
default:
|
default:
|
||||||
s = String::New(X509_verify_cert_error_string(x509_verify_error));
|
s = OneByteString(node_isolate,
|
||||||
|
X509_verify_cert_error_string(x509_verify_error));
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (s.IsEmpty()) {
|
if (s.IsEmpty()) {
|
||||||
s = String::New(reason);
|
s = OneByteString(node_isolate, reason);
|
||||||
}
|
}
|
||||||
|
|
||||||
args.GetReturnValue().Set(Exception::Error(s));
|
args.GetReturnValue().Set(Exception::Error(s));
|
||||||
@ -797,8 +801,8 @@ void TLSCallbacks::OnClientHello(void* arg,
|
|||||||
if (hello.servername() == NULL) {
|
if (hello.servername() == NULL) {
|
||||||
hello_obj->Set(servername_sym, String::Empty(node_isolate));
|
hello_obj->Set(servername_sym, String::Empty(node_isolate));
|
||||||
} else {
|
} else {
|
||||||
Local<String> servername = String::New(
|
Local<String> servername = OneByteString(node_isolate,
|
||||||
reinterpret_cast<const char*>(hello.servername()),
|
hello.servername(),
|
||||||
hello.servername_size());
|
hello.servername_size());
|
||||||
hello_obj->Set(servername_sym, servername);
|
hello_obj->Set(servername_sym, servername);
|
||||||
}
|
}
|
||||||
@ -830,7 +834,8 @@ void TLSCallbacks::GetPeerCertificate(const FunctionCallbackInfo<Value>& args) {
|
|||||||
0,
|
0,
|
||||||
X509_NAME_FLAGS) > 0) {
|
X509_NAME_FLAGS) > 0) {
|
||||||
BIO_get_mem_ptr(bio, &mem);
|
BIO_get_mem_ptr(bio, &mem);
|
||||||
info->Set(subject_sym, String::New(mem->data, mem->length));
|
info->Set(subject_sym,
|
||||||
|
OneByteString(node_isolate, mem->data, mem->length));
|
||||||
}
|
}
|
||||||
(void) BIO_reset(bio);
|
(void) BIO_reset(bio);
|
||||||
|
|
||||||
@ -839,7 +844,8 @@ void TLSCallbacks::GetPeerCertificate(const FunctionCallbackInfo<Value>& args) {
|
|||||||
0,
|
0,
|
||||||
X509_NAME_FLAGS) > 0) {
|
X509_NAME_FLAGS) > 0) {
|
||||||
BIO_get_mem_ptr(bio, &mem);
|
BIO_get_mem_ptr(bio, &mem);
|
||||||
info->Set(issuer_sym, String::New(mem->data, mem->length));
|
info->Set(issuer_sym,
|
||||||
|
OneByteString(node_isolate, mem->data, mem->length));
|
||||||
}
|
}
|
||||||
(void) BIO_reset(bio);
|
(void) BIO_reset(bio);
|
||||||
|
|
||||||
@ -855,7 +861,8 @@ void TLSCallbacks::GetPeerCertificate(const FunctionCallbackInfo<Value>& args) {
|
|||||||
assert(rv == 1);
|
assert(rv == 1);
|
||||||
|
|
||||||
BIO_get_mem_ptr(bio, &mem);
|
BIO_get_mem_ptr(bio, &mem);
|
||||||
info->Set(subjectaltname_sym, String::New(mem->data, mem->length));
|
info->Set(subjectaltname_sym,
|
||||||
|
OneByteString(node_isolate, mem->data, mem->length));
|
||||||
|
|
||||||
(void) BIO_reset(bio);
|
(void) BIO_reset(bio);
|
||||||
}
|
}
|
||||||
@ -866,12 +873,14 @@ void TLSCallbacks::GetPeerCertificate(const FunctionCallbackInfo<Value>& args) {
|
|||||||
NULL != (rsa = EVP_PKEY_get1_RSA(pkey))) {
|
NULL != (rsa = EVP_PKEY_get1_RSA(pkey))) {
|
||||||
BN_print(bio, rsa->n);
|
BN_print(bio, rsa->n);
|
||||||
BIO_get_mem_ptr(bio, &mem);
|
BIO_get_mem_ptr(bio, &mem);
|
||||||
info->Set(modulus_sym, String::New(mem->data, mem->length) );
|
info->Set(modulus_sym,
|
||||||
|
OneByteString(node_isolate, mem->data, mem->length));
|
||||||
(void) BIO_reset(bio);
|
(void) BIO_reset(bio);
|
||||||
|
|
||||||
BN_print(bio, rsa->e);
|
BN_print(bio, rsa->e);
|
||||||
BIO_get_mem_ptr(bio, &mem);
|
BIO_get_mem_ptr(bio, &mem);
|
||||||
info->Set(exponent_sym, String::New(mem->data, mem->length) );
|
info->Set(exponent_sym,
|
||||||
|
OneByteString(node_isolate, mem->data, mem->length));
|
||||||
(void) BIO_reset(bio);
|
(void) BIO_reset(bio);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -886,12 +895,14 @@ void TLSCallbacks::GetPeerCertificate(const FunctionCallbackInfo<Value>& args) {
|
|||||||
|
|
||||||
ASN1_TIME_print(bio, X509_get_notBefore(peer_cert));
|
ASN1_TIME_print(bio, X509_get_notBefore(peer_cert));
|
||||||
BIO_get_mem_ptr(bio, &mem);
|
BIO_get_mem_ptr(bio, &mem);
|
||||||
info->Set(valid_from_sym, String::New(mem->data, mem->length));
|
info->Set(valid_from_sym,
|
||||||
|
OneByteString(node_isolate, mem->data, mem->length));
|
||||||
(void) BIO_reset(bio);
|
(void) BIO_reset(bio);
|
||||||
|
|
||||||
ASN1_TIME_print(bio, X509_get_notAfter(peer_cert));
|
ASN1_TIME_print(bio, X509_get_notAfter(peer_cert));
|
||||||
BIO_get_mem_ptr(bio, &mem);
|
BIO_get_mem_ptr(bio, &mem);
|
||||||
info->Set(valid_to_sym, String::New(mem->data, mem->length));
|
info->Set(valid_to_sym,
|
||||||
|
OneByteString(node_isolate, mem->data, mem->length));
|
||||||
BIO_free_all(bio);
|
BIO_free_all(bio);
|
||||||
|
|
||||||
unsigned int md_size, i;
|
unsigned int md_size, i;
|
||||||
@ -911,7 +922,7 @@ void TLSCallbacks::GetPeerCertificate(const FunctionCallbackInfo<Value>& args) {
|
|||||||
else
|
else
|
||||||
fingerprint[0] = '\0';
|
fingerprint[0] = '\0';
|
||||||
|
|
||||||
info->Set(fingerprint_sym, String::New(fingerprint));
|
info->Set(fingerprint_sym, OneByteString(node_isolate, fingerprint));
|
||||||
}
|
}
|
||||||
|
|
||||||
STACK_OF(ASN1_OBJECT)* eku = static_cast<STACK_OF(ASN1_OBJECT)*>(
|
STACK_OF(ASN1_OBJECT)* eku = static_cast<STACK_OF(ASN1_OBJECT)*>(
|
||||||
@ -926,7 +937,8 @@ void TLSCallbacks::GetPeerCertificate(const FunctionCallbackInfo<Value>& args) {
|
|||||||
for (int i = 0; i < sk_ASN1_OBJECT_num(eku); i++) {
|
for (int i = 0; i < sk_ASN1_OBJECT_num(eku); i++) {
|
||||||
memset(buf, 0, sizeof(buf));
|
memset(buf, 0, sizeof(buf));
|
||||||
OBJ_obj2txt(buf, sizeof(buf) - 1, sk_ASN1_OBJECT_value(eku, i), 1);
|
OBJ_obj2txt(buf, sizeof(buf) - 1, sk_ASN1_OBJECT_value(eku, i), 1);
|
||||||
ext_key_usage->Set(Integer::New(i, node_isolate), String::New(buf));
|
ext_key_usage->Set(Integer::New(i, node_isolate),
|
||||||
|
OneByteString(node_isolate, buf));
|
||||||
}
|
}
|
||||||
|
|
||||||
sk_ASN1_OBJECT_pop_free(eku, ASN1_OBJECT_free);
|
sk_ASN1_OBJECT_pop_free(eku, ASN1_OBJECT_free);
|
||||||
@ -1022,7 +1034,8 @@ void TLSCallbacks::LoadSession(const FunctionCallbackInfo<Value>& args) {
|
|||||||
if (sess->tlsext_hostname == NULL) {
|
if (sess->tlsext_hostname == NULL) {
|
||||||
info->Set(servername_sym, False(node_isolate));
|
info->Set(servername_sym, False(node_isolate));
|
||||||
} else {
|
} else {
|
||||||
info->Set(servername_sym, String::New(sess->tlsext_hostname));
|
info->Set(servername_sym,
|
||||||
|
OneByteString(node_isolate, sess->tlsext_hostname));
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
args.GetReturnValue().Set(info);
|
args.GetReturnValue().Set(info);
|
||||||
@ -1053,8 +1066,8 @@ void TLSCallbacks::GetCurrentCipher(const FunctionCallbackInfo<Value>& args) {
|
|||||||
const char* cipher_version = SSL_CIPHER_get_version(c);
|
const char* cipher_version = SSL_CIPHER_get_version(c);
|
||||||
|
|
||||||
Local<Object> info = Object::New();
|
Local<Object> info = Object::New();
|
||||||
info->Set(name_sym, String::New(cipher_name));
|
info->Set(name_sym, OneByteString(node_isolate, cipher_name));
|
||||||
info->Set(version_sym, String::New(cipher_version));
|
info->Set(version_sym, OneByteString(node_isolate, cipher_version));
|
||||||
args.GetReturnValue().Set(info);
|
args.GetReturnValue().Set(info);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -1115,7 +1128,7 @@ int TLSCallbacks::SelectNextProtoCallback(SSL* s,
|
|||||||
result = Null(node_isolate);
|
result = Null(node_isolate);
|
||||||
break;
|
break;
|
||||||
case OPENSSL_NPN_NEGOTIATED:
|
case OPENSSL_NPN_NEGOTIATED:
|
||||||
result = String::New(reinterpret_cast<const char*>(*out), *outlen);
|
result = OneByteString(node_isolate, *out, *outlen);
|
||||||
break;
|
break;
|
||||||
case OPENSSL_NPN_NO_OVERLAP:
|
case OPENSSL_NPN_NO_OVERLAP:
|
||||||
result = False(node_isolate);
|
result = False(node_isolate);
|
||||||
@ -1153,7 +1166,7 @@ void TLSCallbacks::GetNegotiatedProto(const FunctionCallbackInfo<Value>& args) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
args.GetReturnValue().Set(
|
args.GetReturnValue().Set(
|
||||||
String::New(reinterpret_cast<const char*>(npn_proto), npn_proto_len));
|
OneByteString(node_isolate, npn_proto, npn_proto_len));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@ -1179,7 +1192,7 @@ void TLSCallbacks::GetServername(const FunctionCallbackInfo<Value>& args) {
|
|||||||
const char* servername = SSL_get_servername(wrap->ssl_,
|
const char* servername = SSL_get_servername(wrap->ssl_,
|
||||||
TLSEXT_NAMETYPE_host_name);
|
TLSEXT_NAMETYPE_host_name);
|
||||||
if (servername != NULL) {
|
if (servername != NULL) {
|
||||||
args.GetReturnValue().Set(String::New(servername));
|
args.GetReturnValue().Set(OneByteString(node_isolate, servername));
|
||||||
} else {
|
} else {
|
||||||
args.GetReturnValue().Set(false);
|
args.GetReturnValue().Set(false);
|
||||||
}
|
}
|
||||||
@ -1244,7 +1257,7 @@ void TLSCallbacks::Initialize(Handle<Object> target) {
|
|||||||
|
|
||||||
Local<FunctionTemplate> t = FunctionTemplate::New();
|
Local<FunctionTemplate> t = FunctionTemplate::New();
|
||||||
t->InstanceTemplate()->SetInternalFieldCount(1);
|
t->InstanceTemplate()->SetInternalFieldCount(1);
|
||||||
t->SetClassName(String::NewSymbol("TLSWrap"));
|
t->SetClassName(FIXED_ONE_BYTE_STRING(node_isolate, "TLSWrap"));
|
||||||
|
|
||||||
NODE_SET_PROTOTYPE_METHOD(t, "start", Start);
|
NODE_SET_PROTOTYPE_METHOD(t, "start", Start);
|
||||||
NODE_SET_PROTOTYPE_METHOD(t, "getPeerCertificate", GetPeerCertificate);
|
NODE_SET_PROTOTYPE_METHOD(t, "getPeerCertificate", GetPeerCertificate);
|
||||||
@ -1275,28 +1288,29 @@ void TLSCallbacks::Initialize(Handle<Object> target) {
|
|||||||
|
|
||||||
tlsWrap.Reset(node_isolate, t->GetFunction());
|
tlsWrap.Reset(node_isolate, t->GetFunction());
|
||||||
|
|
||||||
onread_sym = String::New("onread");
|
onread_sym = FIXED_ONE_BYTE_STRING(node_isolate, "onread");
|
||||||
onerror_sym = String::New("onerror");
|
onerror_sym = FIXED_ONE_BYTE_STRING(node_isolate, "onerror");
|
||||||
onhandshakestart_sym = String::New("onhandshakestart");
|
onhandshakestart_sym =
|
||||||
onhandshakedone_sym = String::New("onhandshakedone");
|
FIXED_ONE_BYTE_STRING(node_isolate, "onhandshakestart");
|
||||||
onclienthello_sym = String::New("onclienthello");
|
onhandshakedone_sym = FIXED_ONE_BYTE_STRING(node_isolate, "onhandshakedone");
|
||||||
onnewsession_sym = String::New("onnewsession");
|
onclienthello_sym = FIXED_ONE_BYTE_STRING(node_isolate, "onclienthello");
|
||||||
|
onnewsession_sym = FIXED_ONE_BYTE_STRING(node_isolate, "onnewsession");
|
||||||
|
|
||||||
subject_sym = String::New("subject");
|
subject_sym = FIXED_ONE_BYTE_STRING(node_isolate, "subject");
|
||||||
issuer_sym = String::New("issuer");
|
issuer_sym = FIXED_ONE_BYTE_STRING(node_isolate, "issuer");
|
||||||
valid_from_sym = String::New("valid_from");
|
valid_from_sym = FIXED_ONE_BYTE_STRING(node_isolate, "valid_from");
|
||||||
valid_to_sym = String::New("valid_to");
|
valid_to_sym = FIXED_ONE_BYTE_STRING(node_isolate, "valid_to");
|
||||||
subjectaltname_sym = String::New("subjectaltname");
|
subjectaltname_sym = FIXED_ONE_BYTE_STRING(node_isolate, "subjectaltname");
|
||||||
modulus_sym = String::New("modulus");
|
modulus_sym = FIXED_ONE_BYTE_STRING(node_isolate, "modulus");
|
||||||
exponent_sym = String::New("exponent");
|
exponent_sym = FIXED_ONE_BYTE_STRING(node_isolate, "exponent");
|
||||||
fingerprint_sym = String::New("fingerprint");
|
fingerprint_sym = FIXED_ONE_BYTE_STRING(node_isolate, "fingerprint");
|
||||||
name_sym = String::New("name");
|
name_sym = FIXED_ONE_BYTE_STRING(node_isolate, "name");
|
||||||
version_sym = String::New("version");
|
version_sym = FIXED_ONE_BYTE_STRING(node_isolate, "version");
|
||||||
ext_key_usage_sym = String::New("ext_key_usage");
|
ext_key_usage_sym = FIXED_ONE_BYTE_STRING(node_isolate, "ext_key_usage");
|
||||||
sessionid_sym = String::New("sessionId");
|
sessionid_sym = FIXED_ONE_BYTE_STRING(node_isolate, "sessionId");
|
||||||
tls_ticket_sym = String::New("tlsTicket");
|
tls_ticket_sym = FIXED_ONE_BYTE_STRING(node_isolate, "tlsTicket");
|
||||||
servername_sym = String::New("servername");
|
servername_sym = FIXED_ONE_BYTE_STRING(node_isolate, "servername");
|
||||||
sni_context_sym = String::New("sni_context");
|
sni_context_sym = FIXED_ONE_BYTE_STRING(node_isolate, "sni_context");
|
||||||
}
|
}
|
||||||
|
|
||||||
} // namespace node
|
} // namespace node
|
||||||
|
@ -49,13 +49,13 @@ void TTYWrap::Initialize(Handle<Object> target) {
|
|||||||
HandleScope scope(node_isolate);
|
HandleScope scope(node_isolate);
|
||||||
|
|
||||||
Local<FunctionTemplate> t = FunctionTemplate::New(New);
|
Local<FunctionTemplate> t = FunctionTemplate::New(New);
|
||||||
t->SetClassName(String::NewSymbol("TTY"));
|
t->SetClassName(FIXED_ONE_BYTE_STRING(node_isolate, "TTY"));
|
||||||
|
|
||||||
t->InstanceTemplate()->SetInternalFieldCount(1);
|
t->InstanceTemplate()->SetInternalFieldCount(1);
|
||||||
|
|
||||||
enum PropertyAttribute attributes =
|
enum PropertyAttribute attributes =
|
||||||
static_cast<PropertyAttribute>(v8::ReadOnly | v8::DontDelete);
|
static_cast<PropertyAttribute>(v8::ReadOnly | v8::DontDelete);
|
||||||
t->InstanceTemplate()->SetAccessor(String::New("fd"),
|
t->InstanceTemplate()->SetAccessor(FIXED_ONE_BYTE_STRING(node_isolate, "fd"),
|
||||||
StreamWrap::GetFD,
|
StreamWrap::GetFD,
|
||||||
NULL,
|
NULL,
|
||||||
Handle<Value>(),
|
Handle<Value>(),
|
||||||
@ -82,7 +82,7 @@ void TTYWrap::Initialize(Handle<Object> target) {
|
|||||||
NODE_SET_METHOD(target, "guessHandleType", GuessHandleType);
|
NODE_SET_METHOD(target, "guessHandleType", GuessHandleType);
|
||||||
|
|
||||||
ttyConstructorTmpl.Reset(node_isolate, t);
|
ttyConstructorTmpl.Reset(node_isolate, t);
|
||||||
target->Set(String::NewSymbol("TTY"), t->GetFunction());
|
target->Set(FIXED_ONE_BYTE_STRING(node_isolate, "TTY"), t->GetFunction());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@ -117,7 +117,7 @@ void TTYWrap::GuessHandleType(const FunctionCallbackInfo<Value>& args) {
|
|||||||
abort();
|
abort();
|
||||||
}
|
}
|
||||||
|
|
||||||
args.GetReturnValue().Set(String::New(type));
|
args.GetReturnValue().Set(OneByteString(node_isolate, type));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -68,17 +68,17 @@ UDPWrap::~UDPWrap() {
|
|||||||
void UDPWrap::Initialize(Handle<Object> target) {
|
void UDPWrap::Initialize(Handle<Object> target) {
|
||||||
HandleScope scope(node_isolate);
|
HandleScope scope(node_isolate);
|
||||||
|
|
||||||
buffer_sym = String::New("buffer");
|
buffer_sym = FIXED_ONE_BYTE_STRING(node_isolate, "buffer");
|
||||||
oncomplete_sym = String::New("oncomplete");
|
oncomplete_sym = FIXED_ONE_BYTE_STRING(node_isolate, "oncomplete");
|
||||||
onmessage_sym = String::New("onmessage");
|
onmessage_sym = FIXED_ONE_BYTE_STRING(node_isolate, "onmessage");
|
||||||
|
|
||||||
Local<FunctionTemplate> t = FunctionTemplate::New(New);
|
Local<FunctionTemplate> t = FunctionTemplate::New(New);
|
||||||
t->InstanceTemplate()->SetInternalFieldCount(1);
|
t->InstanceTemplate()->SetInternalFieldCount(1);
|
||||||
t->SetClassName(String::NewSymbol("UDP"));
|
t->SetClassName(FIXED_ONE_BYTE_STRING(node_isolate, "UDP"));
|
||||||
|
|
||||||
enum PropertyAttribute attributes =
|
enum PropertyAttribute attributes =
|
||||||
static_cast<PropertyAttribute>(v8::ReadOnly | v8::DontDelete);
|
static_cast<PropertyAttribute>(v8::ReadOnly | v8::DontDelete);
|
||||||
t->InstanceTemplate()->SetAccessor(String::New("fd"),
|
t->InstanceTemplate()->SetAccessor(FIXED_ONE_BYTE_STRING(node_isolate, "fd"),
|
||||||
UDPWrap::GetFD,
|
UDPWrap::GetFD,
|
||||||
NULL,
|
NULL,
|
||||||
Handle<Value>(),
|
Handle<Value>(),
|
||||||
@ -104,7 +104,7 @@ void UDPWrap::Initialize(Handle<Object> target) {
|
|||||||
NODE_SET_PROTOTYPE_METHOD(t, "unref", HandleWrap::Unref);
|
NODE_SET_PROTOTYPE_METHOD(t, "unref", HandleWrap::Unref);
|
||||||
|
|
||||||
constructor.Reset(node_isolate, t->GetFunction());
|
constructor.Reset(node_isolate, t->GetFunction());
|
||||||
target->Set(String::NewSymbol("UDP"), t->GetFunction());
|
target->Set(FIXED_ONE_BYTE_STRING(node_isolate, "UDP"), t->GetFunction());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -40,15 +40,16 @@ void ErrName(const FunctionCallbackInfo<Value>& args) {
|
|||||||
int err = args[0]->Int32Value();
|
int err = args[0]->Int32Value();
|
||||||
if (err >= 0) return ThrowError("err >= 0");
|
if (err >= 0) return ThrowError("err >= 0");
|
||||||
const char* name = uv_err_name(err);
|
const char* name = uv_err_name(err);
|
||||||
args.GetReturnValue().Set(String::New(name));
|
args.GetReturnValue().Set(OneByteString(node_isolate, name));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void Initialize(Handle<Object> target) {
|
void Initialize(Handle<Object> target) {
|
||||||
v8::HandleScope handle_scope(node_isolate);
|
v8::HandleScope handle_scope(node_isolate);
|
||||||
target->Set(String::New("errname"),
|
target->Set(FIXED_ONE_BYTE_STRING(node_isolate, "errname"),
|
||||||
FunctionTemplate::New(ErrName)->GetFunction());
|
FunctionTemplate::New(ErrName)->GetFunction());
|
||||||
#define V(name, _) target->Set(String::New("UV_" # name), \
|
#define V(name, _) \
|
||||||
|
target->Set(FIXED_ONE_BYTE_STRING(node_isolate, "UV_" # name), \
|
||||||
Integer::New(UV_ ## name, node_isolate));
|
Integer::New(UV_ ## name, node_isolate));
|
||||||
UV_ERRNO_MAP(V)
|
UV_ERRNO_MAP(V)
|
||||||
#undef V
|
#undef V
|
||||||
|
Loading…
Reference in New Issue
Block a user