Browse Source

src: pass Isolate to all applicable api

Update the api to pass node_isolate to all supported methods.

Much thanks to Ben Noordhuis and his work in 51f6e6a.
v0.11.0-release
Trevor Norris 12 years ago
committed by Ben Noordhuis
parent
commit
f65e14ed1d
  1. 99
      src/cares_wrap.cc
  2. 20
      src/fs_event_wrap.cc
  3. 16
      src/handle_wrap.cc
  4. 219
      src/node.cc
  5. 108
      src/node_buffer.cc
  6. 14
      src/node_counters.cc
  7. 350
      src/node_crypto.cc
  8. 48
      src/node_dtrace.cc
  9. 108
      src/node_file.cc
  10. 48
      src/node_http_parser.cc
  11. 2
      src/node_javascript.cc
  12. 46
      src/node_os.cc
  13. 20
      src/node_script.cc
  14. 16
      src/node_stat_watcher.cc
  15. 4
      src/node_string.cc
  16. 29
      src/node_zlib.cc
  17. 38
      src/pipe_wrap.cc
  18. 18
      src/process_wrap.cc
  19. 16
      src/signal_wrap.cc
  20. 12
      src/slab_allocator.cc
  21. 60
      src/stream_wrap.cc
  22. 70
      src/tcp_wrap.cc
  23. 28
      src/timer_wrap.cc
  24. 26
      src/tty_wrap.cc
  25. 63
      src/udp_wrap.cc
  26. 68
      src/v8_typed_array.cc

99
src/cares_wrap.cc

@ -195,7 +195,7 @@ static void ares_sockstate_cb(void* data, ares_socket_t sock,
static Local<Array> HostentToAddresses(struct hostent* host) { static Local<Array> HostentToAddresses(struct hostent* host) {
HandleScope scope; HandleScope scope(node_isolate);
Local<Array> addresses = Array::New(); Local<Array> addresses = Array::New();
char ip[INET6_ADDRSTRLEN]; char ip[INET6_ADDRSTRLEN];
@ -203,7 +203,7 @@ static Local<Array> HostentToAddresses(struct hostent* host) {
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 = String::New(ip);
addresses->Set(Integer::New(i), address); addresses->Set(Integer::New(i, node_isolate), address);
} }
return scope.Close(addresses); return scope.Close(addresses);
@ -211,12 +211,12 @@ static Local<Array> HostentToAddresses(struct hostent* host) {
static Local<Array> HostentToNames(struct hostent* host) { static Local<Array> HostentToNames(struct hostent* host) {
HandleScope scope; HandleScope scope(node_isolate);
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 = String::New(host->h_aliases[i]);
names->Set(Integer::New(i), address); names->Set(Integer::New(i, node_isolate), address);
} }
return scope.Close(names); return scope.Close(names);
@ -260,7 +260,7 @@ static const char* AresErrnoString(int errorno) {
static void SetAresErrno(int errorno) { static void SetAresErrno(int errorno) {
HandleScope scope; HandleScope scope(node_isolate);
Local<Value> key = String::NewSymbol("_errno"); Local<Value> key = String::NewSymbol("_errno");
Local<Value> value = String::NewSymbol(AresErrnoString(errorno)); Local<Value> value = String::NewSymbol(AresErrnoString(errorno));
node::process->Set(key, value); node::process->Set(key, value);
@ -270,7 +270,7 @@ static void SetAresErrno(int errorno) {
class QueryWrap { class QueryWrap {
public: public:
QueryWrap() { QueryWrap() {
HandleScope scope; HandleScope scope(node_isolate);
object_ = Persistent<Object>::New(node_isolate, Object::New()); object_ = Persistent<Object>::New(node_isolate, Object::New());
} }
@ -336,14 +336,14 @@ class QueryWrap {
} }
void CallOnComplete(Local<Value> answer) { void CallOnComplete(Local<Value> answer) {
HandleScope scope; HandleScope scope(node_isolate);
Local<Value> argv[2] = { Integer::New(0), answer }; Local<Value> argv[2] = { Integer::New(0, node_isolate), answer };
MakeCallback(object_, oncomplete_sym, ARRAY_SIZE(argv), argv); MakeCallback(object_, oncomplete_sym, ARRAY_SIZE(argv), argv);
} }
void CallOnComplete(Local<Value> answer, Local<Value> family) { void CallOnComplete(Local<Value> answer, Local<Value> family) {
HandleScope scope; HandleScope scope(node_isolate);
Local<Value> argv[3] = { Integer::New(0), answer, family }; Local<Value> argv[3] = { Integer::New(0, node_isolate), answer, family };
MakeCallback(object_, oncomplete_sym, ARRAY_SIZE(argv), argv); MakeCallback(object_, oncomplete_sym, ARRAY_SIZE(argv), argv);
} }
@ -351,8 +351,8 @@ class QueryWrap {
assert(status != ARES_SUCCESS); assert(status != ARES_SUCCESS);
SetAresErrno(status); SetAresErrno(status);
HandleScope scope; HandleScope scope(node_isolate);
Local<Value> argv[1] = { Integer::New(-1) }; Local<Value> argv[1] = { Integer::New(-1, node_isolate) };
MakeCallback(object_, oncomplete_sym, ARRAY_SIZE(argv), argv); MakeCallback(object_, oncomplete_sym, ARRAY_SIZE(argv), argv);
} }
@ -379,7 +379,7 @@ class QueryAWrap: public QueryWrap {
protected: protected:
void Parse(unsigned char* buf, int len) { void Parse(unsigned char* buf, int len) {
HandleScope scope; HandleScope scope(node_isolate);
struct hostent* host; struct hostent* host;
@ -411,7 +411,7 @@ class QueryAaaaWrap: public QueryWrap {
protected: protected:
void Parse(unsigned char* buf, int len) { void Parse(unsigned char* buf, int len) {
HandleScope scope; HandleScope scope(node_isolate);
struct hostent* host; struct hostent* host;
@ -443,7 +443,7 @@ class QueryCnameWrap: public QueryWrap {
protected: protected:
void Parse(unsigned char* buf, int len) { void Parse(unsigned char* buf, int len) {
HandleScope scope; HandleScope scope(node_isolate);
struct hostent* host; struct hostent* host;
@ -473,7 +473,7 @@ class QueryMxWrap: public QueryWrap {
protected: protected:
void Parse(unsigned char* buf, int len) { void Parse(unsigned char* buf, int len) {
HandleScope scope; HandleScope scope(node_isolate);
struct ares_mx_reply* mx_start; struct ares_mx_reply* mx_start;
int status = ares_parse_mx_reply(buf, len, &mx_start); int status = ares_parse_mx_reply(buf, len, &mx_start);
@ -492,8 +492,8 @@ class QueryMxWrap: public QueryWrap {
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, String::New(mx_current->host));
mx_record->Set(priority_symbol, mx_record->Set(priority_symbol,
Integer::New(mx_current->priority)); Integer::New(mx_current->priority, node_isolate));
mx_records->Set(Integer::New(i++), mx_record); mx_records->Set(Integer::New(i++, node_isolate), mx_record);
} }
ares_free_data(mx_start); ares_free_data(mx_start);
@ -550,7 +550,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 = String::New(reinterpret_cast<char*>(current->txt));
txt_records->Set(Integer::New(i), txt); txt_records->Set(Integer::New(i, node_isolate), txt);
} }
ares_free_data(txt_out); ares_free_data(txt_out);
@ -574,7 +574,7 @@ class QuerySrvWrap: public QueryWrap {
protected: protected:
void Parse(unsigned char* buf, int len) { void Parse(unsigned char* buf, int len) {
HandleScope scope; HandleScope scope(node_isolate);
struct ares_srv_reply* srv_start; struct ares_srv_reply* srv_start;
int status = ares_parse_srv_reply(buf, len, &srv_start); int status = ares_parse_srv_reply(buf, len, &srv_start);
@ -595,12 +595,12 @@ class QuerySrvWrap: public QueryWrap {
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, String::New(srv_current->host));
srv_record->Set(port_symbol, srv_record->Set(port_symbol,
Integer::New(srv_current->port)); Integer::New(srv_current->port, node_isolate));
srv_record->Set(priority_symbol, srv_record->Set(priority_symbol,
Integer::New(srv_current->priority)); Integer::New(srv_current->priority, node_isolate));
srv_record->Set(weight_symbol, srv_record->Set(weight_symbol,
Integer::New(srv_current->weight)); Integer::New(srv_current->weight, node_isolate));
srv_records->Set(Integer::New(i++), srv_record); srv_records->Set(Integer::New(i++, node_isolate), srv_record);
} }
ares_free_data(srv_start); ares_free_data(srv_start);
@ -623,7 +623,7 @@ class QueryNaptrWrap: public QueryWrap {
protected: protected:
void Parse(unsigned char* buf, int len) { void Parse(unsigned char* buf, int len) {
HandleScope scope; HandleScope scope(node_isolate);
ares_naptr_reply* naptr_start; ares_naptr_reply* naptr_start;
int status = ares_parse_naptr_reply(buf, len, &naptr_start); int status = ares_parse_naptr_reply(buf, len, &naptr_start);
@ -656,11 +656,12 @@ class QueryNaptrWrap: public QueryWrap {
String::New(reinterpret_cast<char*>(naptr_current->regexp))); String::New(reinterpret_cast<char*>(naptr_current->regexp)));
naptr_record->Set(replacement_symbol, naptr_record->Set(replacement_symbol,
String::New(naptr_current->replacement)); String::New(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));
naptr_record->Set(preference_symbol, naptr_record->Set(preference_symbol,
Integer::New(naptr_current->preference)); Integer::New(naptr_current->preference, node_isolate));
naptr_records->Set(Integer::New(i++), naptr_record); naptr_records->Set(Integer::New(i++, node_isolate), naptr_record);
} }
ares_free_data(naptr_start); ares_free_data(naptr_start);
@ -697,7 +698,7 @@ class GetHostByAddrWrap: public QueryWrap {
protected: protected:
void Parse(struct hostent* host) { void Parse(struct hostent* host) {
HandleScope scope; HandleScope scope(node_isolate);
this->CallOnComplete(HostentToNames(host)); this->CallOnComplete(HostentToNames(host));
} }
@ -713,10 +714,10 @@ class GetHostByNameWrap: public QueryWrap {
protected: protected:
void Parse(struct hostent* host) { void Parse(struct hostent* host) {
HandleScope scope; HandleScope scope(node_isolate);
Local<Array> addresses = HostentToAddresses(host); Local<Array> addresses = HostentToAddresses(host);
Local<Integer> family = Integer::New(host->h_addrtype); Local<Integer> family = Integer::New(host->h_addrtype, node_isolate);
this->CallOnComplete(addresses, family); this->CallOnComplete(addresses, family);
} }
@ -725,7 +726,7 @@ class GetHostByNameWrap: public QueryWrap {
template <class Wrap> template <class Wrap>
static Handle<Value> Query(const Arguments& args) { static Handle<Value> Query(const Arguments& args) {
HandleScope scope; HandleScope scope(node_isolate);
assert(!args.IsConstructCall()); assert(!args.IsConstructCall());
assert(args.Length() >= 2); assert(args.Length() >= 2);
@ -737,7 +738,7 @@ static Handle<Value> Query(const Arguments& args) {
// We must cache the wrap's js object here, because cares might make the // We must cache the wrap's js object here, because cares might make the
// callback from the wrap->Send stack. This will destroy the wrap's internal // callback from the wrap->Send stack. This will destroy the wrap's internal
// object reference, causing wrap->GetObject() to return undefined. // object reference, causing wrap->GetObject() to return undefined.
Local<Object> object = Local<Object>::New(wrap->GetObject()); Local<Object> object = Local<Object>::New(node_isolate, wrap->GetObject());
String::Utf8Value name(args[0]); String::Utf8Value name(args[0]);
@ -745,7 +746,7 @@ static Handle<Value> Query(const Arguments& args) {
if (r) { if (r) {
SetAresErrno(r); SetAresErrno(r);
delete wrap; delete wrap;
return scope.Close(v8::Null()); return scope.Close(v8::Null(node_isolate));
} else { } else {
return scope.Close(object); return scope.Close(object);
} }
@ -754,7 +755,7 @@ static Handle<Value> Query(const Arguments& args) {
template <class Wrap> template <class Wrap>
static Handle<Value> QueryWithFamily(const Arguments& args) { static Handle<Value> QueryWithFamily(const Arguments& args) {
HandleScope scope; HandleScope scope(node_isolate);
assert(!args.IsConstructCall()); assert(!args.IsConstructCall());
assert(args.Length() >= 3); assert(args.Length() >= 3);
@ -766,7 +767,7 @@ static Handle<Value> QueryWithFamily(const Arguments& args) {
// We must cache the wrap's js object here, because cares might make the // We must cache the wrap's js object here, because cares might make the
// callback from the wrap->Send stack. This will destroy the wrap's internal // callback from the wrap->Send stack. This will destroy the wrap's internal
// object reference, causing wrap->GetObject() to return undefined. // object reference, causing wrap->GetObject() to return undefined.
Local<Object> object = Local<Object>::New(wrap->GetObject()); Local<Object> object = Local<Object>::New(node_isolate, wrap->GetObject());
String::Utf8Value name(args[0]); String::Utf8Value name(args[0]);
int family = args[1]->Int32Value(); int family = args[1]->Int32Value();
@ -775,7 +776,7 @@ static Handle<Value> QueryWithFamily(const Arguments& args) {
if (r) { if (r) {
SetAresErrno(r); SetAresErrno(r);
delete wrap; delete wrap;
return scope.Close(v8::Null()); return scope.Close(v8::Null(node_isolate));
} else { } else {
return scope.Close(object); return scope.Close(object);
} }
@ -783,7 +784,7 @@ static Handle<Value> QueryWithFamily(const Arguments& args) {
void AfterGetAddrInfo(uv_getaddrinfo_t* req, int status, struct addrinfo* res) { void AfterGetAddrInfo(uv_getaddrinfo_t* req, int status, struct addrinfo* res) {
HandleScope scope; HandleScope scope(node_isolate);
GetAddrInfoReqWrap* req_wrap = (GetAddrInfoReqWrap*) req->data; GetAddrInfoReqWrap* req_wrap = (GetAddrInfoReqWrap*) req->data;
@ -792,7 +793,7 @@ void AfterGetAddrInfo(uv_getaddrinfo_t* req, int status, struct addrinfo* res) {
if (status) { if (status) {
// Error // Error
SetErrno(uv_last_error(uv_default_loop())); SetErrno(uv_last_error(uv_default_loop()));
argv[0] = Local<Value>::New(Null()); argv[0] = Local<Value>::New(node_isolate, Null(node_isolate));
} else { } else {
// Success // Success
struct addrinfo *address; struct addrinfo *address;
@ -878,25 +879,25 @@ void AfterGetAddrInfo(uv_getaddrinfo_t* req, int status, struct addrinfo* res) {
static Handle<Value> IsIP(const Arguments& args) { static Handle<Value> IsIP(const Arguments& args) {
HandleScope scope; HandleScope scope(node_isolate);
String::AsciiValue ip(args[0]); String::AsciiValue ip(args[0]);
char address_buffer[sizeof(struct in6_addr)]; char address_buffer[sizeof(struct in6_addr)];
if (uv_inet_pton(AF_INET, *ip, &address_buffer).code == UV_OK) { if (uv_inet_pton(AF_INET, *ip, &address_buffer).code == UV_OK) {
return scope.Close(v8::Integer::New(4)); return scope.Close(v8::Integer::New(4, node_isolate));
} }
if (uv_inet_pton(AF_INET6, *ip, &address_buffer).code == UV_OK) { if (uv_inet_pton(AF_INET6, *ip, &address_buffer).code == UV_OK) {
return scope.Close(v8::Integer::New(6)); return scope.Close(v8::Integer::New(6, node_isolate));
} }
return scope.Close(v8::Integer::New(0)); return scope.Close(v8::Integer::New(0, node_isolate));
} }
static Handle<Value> GetAddrInfo(const Arguments& args) { static Handle<Value> GetAddrInfo(const Arguments& args) {
HandleScope scope; HandleScope scope(node_isolate);
String::Utf8Value hostname(args[0]); String::Utf8Value hostname(args[0]);
@ -931,7 +932,7 @@ static Handle<Value> GetAddrInfo(const Arguments& args) {
if (r) { if (r) {
SetErrno(uv_last_error(uv_default_loop())); SetErrno(uv_last_error(uv_default_loop()));
delete req_wrap; delete req_wrap;
return scope.Close(v8::Null()); return scope.Close(v8::Null(node_isolate));
} else { } else {
return scope.Close(req_wrap->object_); return scope.Close(req_wrap->object_);
} }
@ -939,7 +940,7 @@ static Handle<Value> GetAddrInfo(const Arguments& args) {
static void Initialize(Handle<Object> target) { static void Initialize(Handle<Object> target) {
HandleScope scope; HandleScope scope(node_isolate);
int r; int r;
r = ares_library_init(ARES_LIB_INIT_ALL); r = ares_library_init(ARES_LIB_INIT_ALL);
@ -976,11 +977,11 @@ static void Initialize(Handle<Object> target) {
NODE_SET_METHOD(target, "isIP", IsIP); NODE_SET_METHOD(target, "isIP", IsIP);
target->Set(String::NewSymbol("AF_INET"), target->Set(String::NewSymbol("AF_INET"),
Integer::New(AF_INET)); Integer::New(AF_INET, node_isolate));
target->Set(String::NewSymbol("AF_INET6"), target->Set(String::NewSymbol("AF_INET6"),
Integer::New(AF_INET6)); Integer::New(AF_INET6, node_isolate));
target->Set(String::NewSymbol("AF_UNSPEC"), target->Set(String::NewSymbol("AF_UNSPEC"),
Integer::New(AF_UNSPEC)); Integer::New(AF_UNSPEC, node_isolate));
oncomplete_sym = NODE_PSYMBOL("oncomplete"); oncomplete_sym = NODE_PSYMBOL("oncomplete");
} }

20
src/fs_event_wrap.cc

@ -64,7 +64,7 @@ FSEventWrap::~FSEventWrap() {
void FSEventWrap::Initialize(Handle<Object> target) { void FSEventWrap::Initialize(Handle<Object> target) {
HandleWrap::Initialize(target); HandleWrap::Initialize(target);
HandleScope scope; HandleScope scope(node_isolate);
Local<FunctionTemplate> t = FunctionTemplate::New(New); Local<FunctionTemplate> t = FunctionTemplate::New(New);
t->InstanceTemplate()->SetInternalFieldCount(1); t->InstanceTemplate()->SetInternalFieldCount(1);
@ -80,7 +80,7 @@ void FSEventWrap::Initialize(Handle<Object> target) {
Handle<Value> FSEventWrap::New(const Arguments& args) { Handle<Value> FSEventWrap::New(const Arguments& args) {
HandleScope scope; HandleScope scope(node_isolate);
assert(args.IsConstructCall()); assert(args.IsConstructCall());
new FSEventWrap(args.This()); new FSEventWrap(args.This());
@ -90,7 +90,7 @@ Handle<Value> FSEventWrap::New(const Arguments& args) {
Handle<Value> FSEventWrap::Start(const Arguments& args) { Handle<Value> FSEventWrap::Start(const Arguments& args) {
HandleScope scope; HandleScope scope(node_isolate);
UNWRAP(FSEventWrap) UNWRAP(FSEventWrap)
@ -111,13 +111,13 @@ Handle<Value> FSEventWrap::Start(const Arguments& args) {
SetErrno(uv_last_error(uv_default_loop())); SetErrno(uv_last_error(uv_default_loop()));
} }
return scope.Close(Integer::New(r)); return scope.Close(Integer::New(r, node_isolate));
} }
void FSEventWrap::OnEvent(uv_fs_event_t* handle, const char* filename, void FSEventWrap::OnEvent(uv_fs_event_t* handle, const char* filename,
int events, int status) { int events, int status) {
HandleScope scope; HandleScope scope(node_isolate);
Local<String> eventStr; Local<String> eventStr;
FSEventWrap* wrap = static_cast<FSEventWrap*>(handle->data); FSEventWrap* wrap = static_cast<FSEventWrap*>(handle->data);
@ -137,7 +137,7 @@ void FSEventWrap::OnEvent(uv_fs_event_t* handle, const char* filename,
// unreasonable, right? Still, we should revisit this before v1.0. // unreasonable, right? Still, we should revisit this before v1.0.
if (status) { if (status) {
SetErrno(uv_last_error(uv_default_loop())); SetErrno(uv_last_error(uv_default_loop()));
eventStr = String::Empty(); eventStr = String::Empty(node_isolate);
} }
else if (events & UV_RENAME) { else if (events & UV_RENAME) {
eventStr = String::New("rename"); eventStr = String::New("rename");
@ -151,10 +151,10 @@ void FSEventWrap::OnEvent(uv_fs_event_t* handle, const char* filename,
} }
Local<Value> argv[3] = { Local<Value> argv[3] = {
Integer::New(status), Integer::New(status, node_isolate),
eventStr, eventStr,
filename ? static_cast<Local<Value> >(String::New(filename)) filename ? static_cast<Local<Value> >(String::New(filename))
: Local<Value>::New(v8::Null()) : Local<Value>::New(node_isolate, v8::Null(node_isolate))
}; };
if (onchange_sym.IsEmpty()) { if (onchange_sym.IsEmpty()) {
@ -166,7 +166,7 @@ void FSEventWrap::OnEvent(uv_fs_event_t* handle, const char* filename,
Handle<Value> FSEventWrap::Close(const Arguments& args) { Handle<Value> FSEventWrap::Close(const Arguments& args) {
HandleScope scope; HandleScope scope(node_isolate);
// Unwrap manually here. The UNWRAP() macro asserts that wrap != NULL. // Unwrap manually here. The UNWRAP() macro asserts that wrap != NULL.
// That usually indicates an error but not here: double closes are possible // That usually indicates an error but not here: double closes are possible
@ -177,7 +177,7 @@ Handle<Value> FSEventWrap::Close(const Arguments& args) {
FSEventWrap* wrap = static_cast<FSEventWrap*>(ptr); FSEventWrap* wrap = static_cast<FSEventWrap*>(ptr);
if (wrap == NULL || wrap->initialized_ == false) { if (wrap == NULL || wrap->initialized_ == false) {
return Undefined(); return Undefined(node_isolate);
} }
wrap->initialized_ = false; wrap->initialized_ = false;

16
src/handle_wrap.cc

@ -53,7 +53,7 @@ void HandleWrap::Initialize(Handle<Object> target) {
Handle<Value> HandleWrap::Ref(const Arguments& args) { Handle<Value> HandleWrap::Ref(const Arguments& args) {
HandleScope scope; HandleScope scope(node_isolate);
UNWRAP_NO_ABORT(HandleWrap) UNWRAP_NO_ABORT(HandleWrap)
@ -62,12 +62,12 @@ Handle<Value> HandleWrap::Ref(const Arguments& args) {
wrap->flags_ &= ~kUnref; wrap->flags_ &= ~kUnref;
} }
return v8::Undefined(); return v8::Undefined(node_isolate);
} }
Handle<Value> HandleWrap::Unref(const Arguments& args) { Handle<Value> HandleWrap::Unref(const Arguments& args) {
HandleScope scope; HandleScope scope(node_isolate);
UNWRAP_NO_ABORT(HandleWrap) UNWRAP_NO_ABORT(HandleWrap)
@ -76,19 +76,19 @@ Handle<Value> HandleWrap::Unref(const Arguments& args) {
wrap->flags_ |= kUnref; wrap->flags_ |= kUnref;
} }
return v8::Undefined(); return v8::Undefined(node_isolate);
} }
Handle<Value> HandleWrap::Close(const Arguments& args) { Handle<Value> HandleWrap::Close(const Arguments& args) {
HandleScope scope; HandleScope scope(node_isolate);
HandleWrap *wrap = static_cast<HandleWrap*>( HandleWrap *wrap = static_cast<HandleWrap*>(
args.Holder()->GetAlignedPointerFromInternalField(0)); args.Holder()->GetAlignedPointerFromInternalField(0));
// guard against uninitialized handle or double close // guard against uninitialized handle or double close
if (wrap == NULL || wrap->handle__ == NULL) { if (wrap == NULL || wrap->handle__ == NULL) {
return Undefined(); return Undefined(node_isolate);
} }
assert(!wrap->object_.IsEmpty()); assert(!wrap->object_.IsEmpty());
@ -101,7 +101,7 @@ Handle<Value> HandleWrap::Close(const Arguments& args) {
wrap->flags_ |= kCloseCallback; wrap->flags_ |= kCloseCallback;
} }
return Undefined(); return Undefined(node_isolate);
} }
@ -112,7 +112,7 @@ HandleWrap::HandleWrap(Handle<Object> object, uv_handle_t* h) {
h->data = this; h->data = this;
} }
HandleScope scope; HandleScope scope(node_isolate);
assert(object_.IsEmpty()); assert(object_.IsEmpty());
assert(object->InternalFieldCount() > 0); assert(object->InternalFieldCount() > 0);
object_ = v8::Persistent<v8::Object>::New(node_isolate, object); object_ = v8::Persistent<v8::Object>::New(node_isolate, object);

219
src/node.cc

@ -186,7 +186,7 @@ static void Spin(uv_idle_t* handle, int status) {
uv_idle_stop(&tick_spinner); uv_idle_stop(&tick_spinner);
HandleScope scope; HandleScope scope(node_isolate);
if (process_tickFromSpinner.IsEmpty()) { if (process_tickFromSpinner.IsEmpty()) {
Local<Value> cb_v = process->Get(String::New("_tickFromSpinner")); Local<Value> cb_v = process->Get(String::New("_tickFromSpinner"));
@ -211,7 +211,7 @@ static void Spin(uv_idle_t* handle, int status) {
static Handle<Value> NeedTickCallback(const Arguments& args) { static Handle<Value> NeedTickCallback(const Arguments& args) {
need_tick_cb = true; need_tick_cb = true;
uv_idle_start(&tick_spinner, Spin); uv_idle_start(&tick_spinner, Spin);
return Undefined(); return Undefined(node_isolate);
} }
@ -219,7 +219,7 @@ static void CheckImmediate(uv_check_t* handle, int status) {
assert(handle == &check_immediate_watcher); assert(handle == &check_immediate_watcher);
assert(status == 0); assert(status == 0);
HandleScope scope; HandleScope scope(node_isolate);
if (immediate_callback_sym.IsEmpty()) { if (immediate_callback_sym.IsEmpty()) {
immediate_callback_sym = NODE_PSYMBOL("_immediateCallback"); immediate_callback_sym = NODE_PSYMBOL("_immediateCallback");
@ -747,7 +747,7 @@ Local<Value> ErrnoException(int errorno,
Local<Object> obj = e->ToObject(); Local<Object> obj = e->ToObject();
obj->Set(errno_symbol, Integer::New(errorno)); 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::New(path));
if (syscall) obj->Set(syscall_symbol, String::NewSymbol(syscall)); if (syscall) obj->Set(syscall_symbol, String::NewSymbol(syscall));
@ -819,7 +819,7 @@ Local<Value> UVException(int errorno,
Local<Object> obj = e->ToObject(); Local<Object> obj = e->ToObject();
// TODO errno should probably go // TODO errno should probably go
obj->Set(errno_symbol, Integer::New(errorno)); 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, String::NewSymbol(syscall));
@ -880,7 +880,7 @@ Local<Value> WinapiErrnoException(int errorno,
Local<Object> obj = e->ToObject(); Local<Object> obj = e->ToObject();
obj->Set(errno_symbol, Integer::New(errorno)); 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::New(path));
if (syscall) obj->Set(syscall_symbol, String::NewSymbol(syscall)); if (syscall) obj->Set(syscall_symbol, String::NewSymbol(syscall));
return e; return e;
@ -890,7 +890,7 @@ Local<Value> WinapiErrnoException(int errorno,
Handle<Value> FromConstructorTemplate(Persistent<FunctionTemplate> t, Handle<Value> FromConstructorTemplate(Persistent<FunctionTemplate> t,
const Arguments& args) { const Arguments& args) {
HandleScope scope; HandleScope scope(node_isolate);
Local<Value> argv[32]; Local<Value> argv[32];
unsigned argc = args.Length(); unsigned argc = args.Length();
if (argc > ARRAY_SIZE(argv)) argc = ARRAY_SIZE(argv); if (argc > ARRAY_SIZE(argv)) argc = ARRAY_SIZE(argv);
@ -933,7 +933,7 @@ MakeDomainCallback(const Handle<Object> object,
assert(!domain.IsEmpty()); assert(!domain.IsEmpty());
if (domain->Get(disposed_symbol)->IsTrue()) { if (domain->Get(disposed_symbol)->IsTrue()) {
// domain has been disposed of. // domain has been disposed of.
return Undefined(); return Undefined(node_isolate);
} }
enter = Local<Function>::Cast(domain->Get(enter_symbol)); enter = Local<Function>::Cast(domain->Get(enter_symbol));
assert(!enter.IsEmpty()); assert(!enter.IsEmpty());
@ -941,14 +941,14 @@ MakeDomainCallback(const Handle<Object> object,
if (try_catch.HasCaught()) { if (try_catch.HasCaught()) {
FatalException(try_catch); FatalException(try_catch);
return Undefined(); return Undefined(node_isolate);
} }
Local<Value> ret = callback->Call(object, argc, argv); Local<Value> ret = callback->Call(object, argc, argv);
if (try_catch.HasCaught()) { if (try_catch.HasCaught()) {
FatalException(try_catch); FatalException(try_catch);
return Undefined(); return Undefined(node_isolate);
} }
exit = Local<Function>::Cast(domain->Get(exit_symbol)); exit = Local<Function>::Cast(domain->Get(exit_symbol));
@ -957,7 +957,7 @@ MakeDomainCallback(const Handle<Object> object,
if (try_catch.HasCaught()) { if (try_catch.HasCaught()) {
FatalException(try_catch); FatalException(try_catch);
return Undefined(); return Undefined(node_isolate);
} }
if (tick_infobox.length == 0) { if (tick_infobox.length == 0) {
@ -971,7 +971,7 @@ MakeDomainCallback(const Handle<Object> object,
if (try_catch.HasCaught()) { if (try_catch.HasCaught()) {
FatalException(try_catch); FatalException(try_catch);
return Undefined(); return Undefined(node_isolate);
} }
return ret; return ret;
@ -983,7 +983,7 @@ MakeCallback(const Handle<Object> object,
const Handle<String> symbol, const Handle<String> symbol,
int argc, int argc,
Handle<Value> argv[]) { Handle<Value> argv[]) {
HandleScope scope; HandleScope scope(node_isolate);
Local<Function> callback = object->Get(symbol).As<Function>(); Local<Function> callback = object->Get(symbol).As<Function>();
Local<Value> domain = object->Get(domain_symbol); Local<Value> domain = object->Get(domain_symbol);
@ -1011,7 +1011,7 @@ MakeCallback(const Handle<Object> object,
if (try_catch.HasCaught()) { if (try_catch.HasCaught()) {
FatalException(try_catch); FatalException(try_catch);
return Undefined(); return Undefined(node_isolate);
} }
if (tick_infobox.length == 0) { if (tick_infobox.length == 0) {
@ -1025,7 +1025,7 @@ MakeCallback(const Handle<Object> object,
if (try_catch.HasCaught()) { if (try_catch.HasCaught()) {
FatalException(try_catch); FatalException(try_catch);
return Undefined(); return Undefined(node_isolate);
} }
return scope.Close(ret); return scope.Close(ret);
@ -1037,7 +1037,7 @@ MakeCallback(const Handle<Object> object,
const char* method, const char* method,
int argc, int argc,
Handle<Value> argv[]) { Handle<Value> argv[]) {
HandleScope scope; HandleScope scope(node_isolate);
Handle<Value> ret = Handle<Value> ret =
MakeCallback(object, String::NewSymbol(method), argc, argv); MakeCallback(object, String::NewSymbol(method), argc, argv);
@ -1047,7 +1047,7 @@ MakeCallback(const Handle<Object> object,
void SetErrno(uv_err_t err) { void SetErrno(uv_err_t err) {
HandleScope scope; HandleScope scope(node_isolate);
static Persistent<String> errno_symbol; static Persistent<String> errno_symbol;
if (errno_symbol.IsEmpty()) { if (errno_symbol.IsEmpty()) {
@ -1065,7 +1065,7 @@ void SetErrno(uv_err_t err) {
enum encoding ParseEncoding(Handle<Value> encoding_v, enum encoding _default) { enum encoding ParseEncoding(Handle<Value> encoding_v, enum encoding _default) {
HandleScope scope; HandleScope scope(node_isolate);
if (!encoding_v->IsString()) return _default; if (!encoding_v->IsString()) return _default;
@ -1111,14 +1111,14 @@ enum encoding ParseEncoding(Handle<Value> encoding_v, enum encoding _default) {
} }
Local<Value> Encode(const void *buf, size_t len, enum encoding encoding) { Local<Value> Encode(const void *buf, size_t len, enum encoding encoding) {
HandleScope scope; HandleScope scope(node_isolate);
if (encoding == BUFFER) { if (encoding == BUFFER) {
return scope.Close( return scope.Close(
Buffer::New(static_cast<const char*>(buf), len)->handle_); Buffer::New(static_cast<const char*>(buf), len)->handle_);
} }
if (!len) return scope.Close(String::Empty()); if (!len) return scope.Close(String::Empty(node_isolate));
if (encoding == BINARY) { if (encoding == BINARY) {
const unsigned char *cbuf = static_cast<const unsigned char*>(buf); const unsigned char *cbuf = static_cast<const unsigned char*>(buf);
@ -1139,7 +1139,7 @@ Local<Value> Encode(const void *buf, size_t len, enum encoding encoding) {
// Returns -1 if the handle was not valid for decoding // Returns -1 if the handle was not valid for decoding
ssize_t DecodeBytes(v8::Handle<v8::Value> val, enum encoding encoding) { ssize_t DecodeBytes(v8::Handle<v8::Value> val, enum encoding encoding) {
HandleScope scope; HandleScope scope(node_isolate);
if (val->IsArray()) { if (val->IsArray()) {
fprintf(stderr, "'raw' encoding (array of integers) has been removed. " fprintf(stderr, "'raw' encoding (array of integers) has been removed. "
@ -1170,7 +1170,7 @@ ssize_t DecodeWrite(char *buf,
size_t buflen, size_t buflen,
v8::Handle<v8::Value> val, v8::Handle<v8::Value> val,
enum encoding encoding) { enum encoding encoding) {
HandleScope scope; HandleScope scope(node_isolate);
// XXX // XXX
// A lot of improvement can be made here. See: // A lot of improvement can be made here. See:
@ -1243,7 +1243,7 @@ void DisplayExceptionLine (TryCatch &try_catch) {
if (displayed_error) return; if (displayed_error) return;
displayed_error = true; displayed_error = true;
HandleScope scope; HandleScope scope(node_isolate);
Handle<Message> message = try_catch.Message(); Handle<Message> message = try_catch.Message();
@ -1301,7 +1301,7 @@ void DisplayExceptionLine (TryCatch &try_catch) {
static void ReportException(TryCatch &try_catch, bool show_line) { static void ReportException(TryCatch &try_catch, bool show_line) {
HandleScope scope; HandleScope scope(node_isolate);
if (show_line) DisplayExceptionLine(try_catch); if (show_line) DisplayExceptionLine(try_catch);
@ -1334,7 +1334,7 @@ static void ReportException(TryCatch &try_catch, bool show_line) {
// Executes a str within the current v8 context. // Executes a str within the current v8 context.
Local<Value> ExecuteString(Handle<String> source, Handle<Value> filename) { Local<Value> ExecuteString(Handle<String> source, Handle<Value> filename) {
HandleScope scope; HandleScope scope(node_isolate);
TryCatch try_catch; TryCatch try_catch;
Local<v8::Script> script = v8::Script::Compile(source, filename); Local<v8::Script> script = v8::Script::Compile(source, filename);
@ -1354,7 +1354,7 @@ Local<Value> ExecuteString(Handle<String> source, Handle<Value> filename) {
static Handle<Value> GetActiveRequests(const Arguments& args) { static Handle<Value> GetActiveRequests(const Arguments& args) {
HandleScope scope; HandleScope scope(node_isolate);
Local<Array> ary = Array::New(); Local<Array> ary = Array::New();
ngx_queue_t* q = NULL; ngx_queue_t* q = NULL;
@ -1373,7 +1373,7 @@ static Handle<Value> GetActiveRequests(const Arguments& args) {
// Non-static, friend of HandleWrap. Could have been a HandleWrap method but // Non-static, friend of HandleWrap. Could have been a HandleWrap method but
// implemented here for consistency with GetActiveRequests(). // implemented here for consistency with GetActiveRequests().
Handle<Value> GetActiveHandles(const Arguments& args) { Handle<Value> GetActiveHandles(const Arguments& args) {
HandleScope scope; HandleScope scope(node_isolate);
Local<Array> ary = Array::New(); Local<Array> ary = Array::New();
ngx_queue_t* q = NULL; ngx_queue_t* q = NULL;
@ -1395,12 +1395,12 @@ Handle<Value> GetActiveHandles(const Arguments& args) {
static Handle<Value> Abort(const Arguments& args) { static Handle<Value> Abort(const Arguments& args) {
abort(); abort();
return Undefined(); return Undefined(node_isolate);
} }
static Handle<Value> Chdir(const Arguments& args) { static Handle<Value> Chdir(const Arguments& args) {
HandleScope scope; HandleScope scope(node_isolate);
if (args.Length() != 1 || !args[0]->IsString()) { if (args.Length() != 1 || !args[0]->IsString()) {
return ThrowException(Exception::Error(String::New("Bad argument."))); return ThrowException(Exception::Error(String::New("Bad argument.")));
@ -1414,12 +1414,12 @@ static Handle<Value> Chdir(const Arguments& args) {
return ThrowException(UVException(r.code, "uv_chdir")); return ThrowException(UVException(r.code, "uv_chdir"));
} }
return Undefined(); return Undefined(node_isolate);
} }
static Handle<Value> Cwd(const Arguments& args) { static Handle<Value> Cwd(const Arguments& args) {
HandleScope scope; HandleScope scope(node_isolate);
#ifdef _WIN32 #ifdef _WIN32
/* MAX_PATH is in characters, not bytes. Make sure we have enough headroom. */ /* MAX_PATH is in characters, not bytes. Make sure we have enough headroom. */
char buf[MAX_PATH * 4 + 1]; char buf[MAX_PATH * 4 + 1];
@ -1440,7 +1440,7 @@ static Handle<Value> Cwd(const Arguments& args) {
static Handle<Value> Umask(const Arguments& args) { static Handle<Value> Umask(const Arguments& args) {
HandleScope scope; HandleScope scope(node_isolate);
unsigned int old; unsigned int old;
if (args.Length() < 1 || args[0]->IsUndefined()) { if (args.Length() < 1 || args[0]->IsUndefined()) {
@ -1473,7 +1473,7 @@ static Handle<Value> Umask(const Arguments& args) {
old = umask(static_cast<mode_t>(oct)); old = umask(static_cast<mode_t>(oct));
} }
return scope.Close(Uint32::New(old)); return scope.Close(Uint32::New(old, node_isolate));
} }
@ -1582,21 +1582,21 @@ static gid_t gid_by_name(Handle<Value> value) {
static Handle<Value> GetUid(const Arguments& args) { static Handle<Value> GetUid(const Arguments& args) {
HandleScope scope; HandleScope scope(node_isolate);
int uid = getuid(); int uid = getuid();
return scope.Close(Integer::New(uid)); return scope.Close(Integer::New(uid, node_isolate));
} }
static Handle<Value> GetGid(const Arguments& args) { static Handle<Value> GetGid(const Arguments& args) {
HandleScope scope; HandleScope scope(node_isolate);
int gid = getgid(); int gid = getgid();
return scope.Close(Integer::New(gid)); return scope.Close(Integer::New(gid, node_isolate));
} }
static Handle<Value> SetGid(const Arguments& args) { static Handle<Value> SetGid(const Arguments& args) {
HandleScope scope; HandleScope scope(node_isolate);
if (!args[0]->IsUint32() && !args[0]->IsString()) { if (!args[0]->IsUint32() && !args[0]->IsString()) {
return ThrowTypeError("setgid argument must be a number or a string"); return ThrowTypeError("setgid argument must be a number or a string");
@ -1612,12 +1612,12 @@ static Handle<Value> SetGid(const Arguments& args) {
return ThrowException(ErrnoException(errno, "setgid")); return ThrowException(ErrnoException(errno, "setgid"));
} }
return Undefined(); return Undefined(node_isolate);
} }
static Handle<Value> SetUid(const Arguments& args) { static Handle<Value> SetUid(const Arguments& args) {
HandleScope scope; HandleScope scope(node_isolate);
if (!args[0]->IsUint32() && !args[0]->IsString()) { if (!args[0]->IsUint32() && !args[0]->IsString()) {
return ThrowTypeError("setuid argument must be a number or a string"); return ThrowTypeError("setuid argument must be a number or a string");
@ -1633,12 +1633,12 @@ static Handle<Value> SetUid(const Arguments& args) {
return ThrowException(ErrnoException(errno, "setuid")); return ThrowException(ErrnoException(errno, "setuid"));
} }
return Undefined(); return Undefined(node_isolate);
} }
static Handle<Value> GetGroups(const Arguments& args) { static Handle<Value> GetGroups(const Arguments& args) {
HandleScope scope; HandleScope scope(node_isolate);
int ngroups = getgroups(0, NULL); int ngroups = getgroups(0, NULL);
@ -1660,14 +1660,14 @@ static Handle<Value> GetGroups(const Arguments& args) {
gid_t egid = getegid(); gid_t egid = getegid();
for (int i = 0; i < ngroups; i++) { for (int i = 0; i < ngroups; i++) {
groups_list->Set(i, Integer::New(groups[i])); groups_list->Set(i, Integer::New(groups[i], node_isolate));
if (groups[i] == egid) seen_egid = true; if (groups[i] == egid) seen_egid = true;
} }
delete[] groups; delete[] groups;
if (seen_egid == false) { if (seen_egid == false) {
groups_list->Set(ngroups, Integer::New(egid)); groups_list->Set(ngroups, Integer::New(egid, node_isolate));
} }
return scope.Close(groups_list); return scope.Close(groups_list);
@ -1675,7 +1675,7 @@ static Handle<Value> GetGroups(const Arguments& args) {
static Handle<Value> SetGroups(const Arguments& args) { static Handle<Value> SetGroups(const Arguments& args) {
HandleScope scope; HandleScope scope(node_isolate);
if (!args[0]->IsArray()) { if (!args[0]->IsArray()) {
return ThrowTypeError("argument 1 must be an array"); return ThrowTypeError("argument 1 must be an array");
@ -1703,12 +1703,12 @@ static Handle<Value> SetGroups(const Arguments& args) {
return ThrowException(ErrnoException(errno, "setgroups")); return ThrowException(ErrnoException(errno, "setgroups"));
} }
return Undefined(); return Undefined(node_isolate);
} }
static Handle<Value> InitGroups(const Arguments& args) { static Handle<Value> InitGroups(const Arguments& args) {
HandleScope scope; HandleScope scope(node_isolate);
if (!args[0]->IsUint32() && !args[0]->IsString()) { if (!args[0]->IsUint32() && !args[0]->IsString()) {
return ThrowTypeError("argument 1 must be a number or a string"); return ThrowTypeError("argument 1 must be a number or a string");
@ -1752,27 +1752,27 @@ static Handle<Value> InitGroups(const Arguments& args) {
return ThrowException(ErrnoException(errno, "initgroups")); return ThrowException(ErrnoException(errno, "initgroups"));
} }
return Undefined(); return Undefined(node_isolate);
} }
#endif // __POSIX__ #endif // __POSIX__
v8::Handle<v8::Value> Exit(const v8::Arguments& args) { v8::Handle<v8::Value> Exit(const v8::Arguments& args) {
HandleScope scope; HandleScope scope(node_isolate);
exit(args[0]->IntegerValue()); exit(args[0]->IntegerValue());
return Undefined(); return Undefined(node_isolate);
} }
static Handle<Value> Uptime(const Arguments& args) { static Handle<Value> Uptime(const Arguments& args) {
HandleScope scope; HandleScope scope(node_isolate);
double uptime; double uptime;
uv_err_t err = uv_uptime(&uptime); uv_err_t err = uv_uptime(&uptime);
if (err.code != UV_OK) { if (err.code != UV_OK) {
return Undefined(); return Undefined(node_isolate);
} }
return scope.Close(Number::New(uptime - prog_start_time)); return scope.Close(Number::New(uptime - prog_start_time));
@ -1780,7 +1780,7 @@ static Handle<Value> Uptime(const Arguments& args) {
v8::Handle<v8::Value> MemoryUsage(const v8::Arguments& args) { v8::Handle<v8::Value> MemoryUsage(const v8::Arguments& args) {
HandleScope scope; HandleScope scope(node_isolate);
size_t rss; size_t rss;
@ -1804,16 +1804,18 @@ v8::Handle<v8::Value> MemoryUsage(const v8::Arguments& args) {
HeapStatistics v8_heap_stats; HeapStatistics v8_heap_stats;
node_isolate->GetHeapStatistics(&v8_heap_stats); node_isolate->GetHeapStatistics(&v8_heap_stats);
info->Set(heap_total_symbol, info->Set(heap_total_symbol,
Integer::NewFromUnsigned(v8_heap_stats.total_heap_size())); Integer::NewFromUnsigned(v8_heap_stats.total_heap_size(),
node_isolate));
info->Set(heap_used_symbol, info->Set(heap_used_symbol,
Integer::NewFromUnsigned(v8_heap_stats.used_heap_size())); Integer::NewFromUnsigned(v8_heap_stats.used_heap_size(),
node_isolate));
return scope.Close(info); return scope.Close(info);
} }
Handle<Value> Kill(const Arguments& args) { Handle<Value> Kill(const Arguments& args) {
HandleScope scope; HandleScope scope(node_isolate);
if (args.Length() != 2) { if (args.Length() != 2) {
return ThrowException(Exception::Error(String::New("Bad argument."))); return ThrowException(Exception::Error(String::New("Bad argument.")));
@ -1825,10 +1827,10 @@ Handle<Value> Kill(const Arguments& args) {
if (err.code != UV_OK) { if (err.code != UV_OK) {
SetErrno(err); SetErrno(err);
return scope.Close(Integer::New(-1)); return scope.Close(Integer::New(-1, node_isolate));
} }
return Undefined(); return Undefined(node_isolate);
} }
// used in Hrtime() below // used in Hrtime() below
@ -1840,7 +1842,7 @@ Handle<Value> Kill(const Arguments& args) {
// and nanoseconds, to avoid any integer overflow possibility. // and nanoseconds, to avoid any integer overflow possibility.
// Pass in an Array from a previous hrtime() call to instead get a time diff. // Pass in an Array from a previous hrtime() call to instead get a time diff.
Handle<Value> Hrtime(const v8::Arguments& args) { Handle<Value> Hrtime(const v8::Arguments& args) {
HandleScope scope; HandleScope scope(node_isolate);
uint64_t t = uv_hrtime(); uint64_t t = uv_hrtime();
@ -1858,8 +1860,8 @@ Handle<Value> Hrtime(const v8::Arguments& args) {
} }
Local<Array> tuple = Array::New(2); Local<Array> tuple = Array::New(2);
tuple->Set(0, Integer::NewFromUnsigned(t / NANOS_PER_SEC)); tuple->Set(0, Integer::NewFromUnsigned(t / NANOS_PER_SEC, node_isolate));
tuple->Set(1, Integer::NewFromUnsigned(t % NANOS_PER_SEC)); tuple->Set(1, Integer::NewFromUnsigned(t % NANOS_PER_SEC, node_isolate));
return scope.Close(tuple); return scope.Close(tuple);
} }
@ -1870,7 +1872,7 @@ typedef void (UV_DYNAMIC* extInit)(Handle<Object> exports);
// DLOpen is process.dlopen(module, filename). // DLOpen is process.dlopen(module, filename).
// Used to load 'module.node' dynamically shared objects. // Used to load 'module.node' dynamically shared objects.
Handle<Value> DLOpen(const v8::Arguments& args) { Handle<Value> DLOpen(const v8::Arguments& args) {
HandleScope scope; HandleScope scope(node_isolate);
char symbol[1024], *base, *pos; char symbol[1024], *base, *pos;
uv_lib_t lib; uv_lib_t lib;
int r; int r;
@ -1959,7 +1961,7 @@ Handle<Value> DLOpen(const v8::Arguments& args) {
// Tell coverity that 'handle' should not be freed when we return. // Tell coverity that 'handle' should not be freed when we return.
// coverity[leaked_storage] // coverity[leaked_storage]
return Undefined(); return Undefined(node_isolate);
} }
@ -1973,7 +1975,7 @@ static void OnFatalError(const char* location, const char* message) {
} }
void FatalException(TryCatch &try_catch) { void FatalException(TryCatch &try_catch) {
HandleScope scope; HandleScope scope(node_isolate);
if (fatal_exception_symbol.IsEmpty()) if (fatal_exception_symbol.IsEmpty())
fatal_exception_symbol = NODE_PSYMBOL("_fatalException"); fatal_exception_symbol = NODE_PSYMBOL("_fatalException");
@ -2014,7 +2016,7 @@ Persistent<Object> binding_cache;
Persistent<Array> module_load_list; Persistent<Array> module_load_list;
static Handle<Value> Binding(const Arguments& args) { static Handle<Value> Binding(const Arguments& args) {
HandleScope scope; HandleScope scope(node_isolate);
Local<String> module = args[0]->ToString(); Local<String> module = args[0]->ToString();
String::Utf8Value module_v(module); String::Utf8Value module_v(module);
@ -2041,7 +2043,7 @@ static Handle<Value> Binding(const Arguments& args) {
exports = Object::New(); exports = Object::New();
// Internal bindings don't have a "module" object, // Internal bindings don't have a "module" object,
// only exports. // only exports.
modp->register_func(exports, Undefined()); modp->register_func(exports, Undefined(node_isolate));
binding_cache->Set(module, exports); binding_cache->Set(module, exports);
} else if (!strcmp(*module_v, "constants")) { } else if (!strcmp(*module_v, "constants")) {
@ -2065,7 +2067,7 @@ static Handle<Value> Binding(const Arguments& args) {
static Handle<Value> ProcessTitleGetter(Local<String> property, static Handle<Value> ProcessTitleGetter(Local<String> property,
const AccessorInfo& info) { const AccessorInfo& info) {
HandleScope scope; HandleScope scope(node_isolate);
char buffer[512]; char buffer[512];
uv_get_process_title(buffer, sizeof(buffer)); uv_get_process_title(buffer, sizeof(buffer));
return scope.Close(String::New(buffer)); return scope.Close(String::New(buffer));
@ -2075,7 +2077,7 @@ static Handle<Value> ProcessTitleGetter(Local<String> property,
static void ProcessTitleSetter(Local<String> property, static void ProcessTitleSetter(Local<String> property,
Local<Value> value, Local<Value> value,
const AccessorInfo& info) { const AccessorInfo& info) {
HandleScope scope; HandleScope scope(node_isolate);
String::Utf8Value title(value); String::Utf8Value title(value);
// TODO: protect with a lock // TODO: protect with a lock
uv_set_process_title(*title); uv_set_process_title(*title);
@ -2084,7 +2086,7 @@ static void ProcessTitleSetter(Local<String> property,
static Handle<Value> EnvGetter(Local<String> property, static Handle<Value> EnvGetter(Local<String> property,
const AccessorInfo& info) { const AccessorInfo& info) {
HandleScope scope; HandleScope scope(node_isolate);
#ifdef __POSIX__ #ifdef __POSIX__
String::Utf8Value key(property); String::Utf8Value key(property);
const char* val = getenv(*key); const char* val = getenv(*key);
@ -2113,7 +2115,7 @@ static Handle<Value> EnvGetter(Local<String> property,
static Handle<Value> EnvSetter(Local<String> property, static Handle<Value> EnvSetter(Local<String> property,
Local<Value> value, Local<Value> value,
const AccessorInfo& info) { const AccessorInfo& info) {
HandleScope scope; HandleScope scope(node_isolate);
#ifdef __POSIX__ #ifdef __POSIX__
String::Utf8Value key(property); String::Utf8Value key(property);
String::Utf8Value val(value); String::Utf8Value val(value);
@ -2134,11 +2136,11 @@ static Handle<Value> EnvSetter(Local<String> property,
static Handle<Integer> EnvQuery(Local<String> property, static Handle<Integer> EnvQuery(Local<String> property,
const AccessorInfo& info) { const AccessorInfo& info) {
HandleScope scope; HandleScope scope(node_isolate);
#ifdef __POSIX__ #ifdef __POSIX__
String::Utf8Value key(property); String::Utf8Value key(property);
if (getenv(*key)) { if (getenv(*key)) {
return scope.Close(Integer::New(0)); return scope.Close(Integer::New(0, node_isolate));
} }
#else // _WIN32 #else // _WIN32
String::Value key(property); String::Value key(property);
@ -2149,9 +2151,10 @@ static Handle<Integer> EnvQuery(Local<String> property,
// Environment variables that start with '=' are hidden and read-only. // Environment variables that start with '=' are hidden and read-only.
return scope.Close(Integer::New(v8::ReadOnly || return scope.Close(Integer::New(v8::ReadOnly ||
v8::DontDelete || v8::DontDelete ||
v8::DontEnum)); v8::DontEnum,
node_isolate));
} else { } else {
return scope.Close(Integer::New(0)); return scope.Close(Integer::New(0, node_isolate));
} }
} }
#endif #endif
@ -2162,12 +2165,12 @@ static Handle<Integer> EnvQuery(Local<String> property,
static Handle<Boolean> EnvDeleter(Local<String> property, static Handle<Boolean> EnvDeleter(Local<String> property,
const AccessorInfo& info) { const AccessorInfo& info) {
HandleScope scope; HandleScope scope(node_isolate);
#ifdef __POSIX__ #ifdef __POSIX__
String::Utf8Value key(property); String::Utf8Value key(property);
if (!getenv(*key)) return False(); if (!getenv(*key)) return False(node_isolate);
unsetenv(*key); // can't check return value, it's void on some platforms unsetenv(*key); // can't check return value, it's void on some platforms
return True(); return True(node_isolate);
#else #else
String::Value key(property); String::Value key(property);
WCHAR* key_ptr = reinterpret_cast<WCHAR*>(*key); WCHAR* key_ptr = reinterpret_cast<WCHAR*>(*key);
@ -2178,13 +2181,13 @@ static Handle<Boolean> EnvDeleter(Local<String> property,
GetLastError() != ERROR_SUCCESS; GetLastError() != ERROR_SUCCESS;
return scope.Close(Boolean::New(rv)); return scope.Close(Boolean::New(rv));
} }
return True(); return True(node_isolate);
#endif #endif
} }
static Handle<Array> EnvEnumerator(const AccessorInfo& info) { static Handle<Array> EnvEnumerator(const AccessorInfo& info) {
HandleScope scope; HandleScope scope(node_isolate);
#ifdef __POSIX__ #ifdef __POSIX__
int size = 0; int size = 0;
while (environ[size]) size++; while (environ[size]) size++;
@ -2228,19 +2231,19 @@ static Handle<Array> EnvEnumerator(const AccessorInfo& info) {
static Handle<Object> GetFeatures() { static Handle<Object> GetFeatures() {
HandleScope scope; HandleScope scope(node_isolate);
Local<Object> obj = Object::New(); Local<Object> obj = Object::New();
obj->Set(String::NewSymbol("debug"), obj->Set(String::NewSymbol("debug"),
#if defined(DEBUG) && DEBUG #if defined(DEBUG) && DEBUG
True() True(node_isolate)
#else #else
False() False(node_isolate)
#endif #endif
); );
obj->Set(String::NewSymbol("uv"), True()); obj->Set(String::NewSymbol("uv"), True(node_isolate));
obj->Set(String::NewSymbol("ipv6"), True()); // TODO ping libuv obj->Set(String::NewSymbol("ipv6"), True(node_isolate)); // TODO ping libuv
obj->Set(String::NewSymbol("tls_npn"), Boolean::New(use_npn)); obj->Set(String::NewSymbol("tls_npn"), Boolean::New(use_npn));
obj->Set(String::NewSymbol("tls_sni"), Boolean::New(use_sni)); obj->Set(String::NewSymbol("tls_sni"), Boolean::New(use_sni));
obj->Set(String::NewSymbol("tls"), obj->Set(String::NewSymbol("tls"),
@ -2252,15 +2255,15 @@ static Handle<Object> GetFeatures() {
static Handle<Value> DebugPortGetter(Local<String> property, static Handle<Value> DebugPortGetter(Local<String> property,
const AccessorInfo& info) { const AccessorInfo& info) {
HandleScope scope; HandleScope scope(node_isolate);
return scope.Close(Integer::NewFromUnsigned(debug_port)); return scope.Close(Integer::NewFromUnsigned(debug_port, node_isolate));
} }
static void DebugPortSetter(Local<String> property, static void DebugPortSetter(Local<String> property,
Local<Value> value, Local<Value> value,
const AccessorInfo& info) { const AccessorInfo& info) {
HandleScope scope; HandleScope scope(node_isolate);
debug_port = value->NumberValue(); debug_port = value->NumberValue();
} }
@ -2279,7 +2282,7 @@ Handle<Value> NeedImmediateCallbackGetter(Local<String> property,
static void NeedImmediateCallbackSetter(Local<String> property, static void NeedImmediateCallbackSetter(Local<String> property,
Local<Value> value, Local<Value> value,
const AccessorInfo& info) { const AccessorInfo& info) {
HandleScope scope; HandleScope scope(node_isolate);
bool bool_value = value->BooleanValue(); bool bool_value = value->BooleanValue();
@ -2299,7 +2302,7 @@ static void NeedImmediateCallbackSetter(Local<String> property,
Handle<Object> SetupProcessObject(int argc, char *argv[]) { Handle<Object> SetupProcessObject(int argc, char *argv[]) {
HandleScope scope; HandleScope scope(node_isolate);
int i, j; int i, j;
@ -2362,10 +2365,10 @@ Handle<Object> SetupProcessObject(int argc, char *argv[]) {
// 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), String::New(argv[0])); arguments->Set(Integer::New(0, node_isolate), String::New(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]); Local<String> arg = String::New(argv[i]);
arguments->Set(Integer::New(j), arg); arguments->Set(Integer::New(j, node_isolate), arg);
} }
// assign it // assign it
process->Set(String::NewSymbol("argv"), arguments); process->Set(String::NewSymbol("argv"), arguments);
@ -2373,7 +2376,7 @@ Handle<Object> SetupProcessObject(int argc, char *argv[]) {
// process.execArgv // process.execArgv
Local<Array> execArgv = Array::New(option_end_index - 1); Local<Array> execArgv = 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), String::New(argv[j])); execArgv->Set(Integer::New(i, node_isolate), String::New(argv[j]));
} }
// assign it // assign it
process->Set(String::NewSymbol("execArgv"), execArgv); process->Set(String::NewSymbol("execArgv"), execArgv);
@ -2390,7 +2393,7 @@ Handle<Object> SetupProcessObject(int argc, char *argv[]) {
Local<Object> env = envTemplate->NewInstance(); Local<Object> env = envTemplate->NewInstance();
process->Set(String::NewSymbol("env"), env); process->Set(String::NewSymbol("env"), env);
process->Set(String::NewSymbol("pid"), Integer::New(getpid())); process->Set(String::NewSymbol("pid"), Integer::New(getpid(), node_isolate));
process->Set(String::NewSymbol("features"), GetFeatures()); process->Set(String::NewSymbol("features"), GetFeatures());
process->SetAccessor(String::New("_needImmediateCallback"), process->SetAccessor(String::New("_needImmediateCallback"),
NeedImmediateCallbackGetter, NeedImmediateCallbackGetter,
@ -2403,17 +2406,17 @@ Handle<Object> SetupProcessObject(int argc, char *argv[]) {
// -p, --print // -p, --print
if (print_eval) { if (print_eval) {
process->Set(String::NewSymbol("_print_eval"), True()); process->Set(String::NewSymbol("_print_eval"), True(node_isolate));
} }
// -i, --interactive // -i, --interactive
if (force_repl) { if (force_repl) {
process->Set(String::NewSymbol("_forceRepl"), True()); process->Set(String::NewSymbol("_forceRepl"), True(node_isolate));
} }
// --no-deprecation // --no-deprecation
if (no_deprecation) { if (no_deprecation) {
process->Set(String::NewSymbol("noDeprecation"), True()); process->Set(String::NewSymbol("noDeprecation"), True(node_isolate));
} }
// --throw-deprecation // --throw-deprecation
@ -2423,7 +2426,7 @@ Handle<Object> SetupProcessObject(int argc, char *argv[]) {
// --trace-deprecation // --trace-deprecation
if (trace_deprecation) { if (trace_deprecation) {
process->Set(String::NewSymbol("traceDeprecation"), True()); process->Set(String::NewSymbol("traceDeprecation"), True(node_isolate));
} }
size_t size = 2*PATH_MAX; size_t size = 2*PATH_MAX;
@ -2536,7 +2539,7 @@ void Load(Handle<Object> process_l) {
// Add a reference to the global object // Add a reference to the global object
Local<Object> global = v8::Context::GetCurrent()->Global(); Local<Object> global = v8::Context::GetCurrent()->Global();
Local<Value> args[1] = { Local<Value>::New(process_l) }; Local<Value> args[1] = { Local<Value>::New(node_isolate, process_l) };
#if defined HAVE_DTRACE || defined HAVE_ETW || defined HAVE_SYSTEMTAP #if defined HAVE_DTRACE || defined HAVE_ETW || defined HAVE_SYSTEMTAP
InitDTrace(global); InitDTrace(global);
@ -2751,7 +2754,7 @@ static void RegisterSignalHandler(int signal, void (*handler)(int)) {
Handle<Value> DebugProcess(const Arguments& args) { Handle<Value> DebugProcess(const Arguments& args) {
HandleScope scope; HandleScope scope(node_isolate);
if (args.Length() != 1) { if (args.Length() != 1) {
return ThrowException(Exception::Error( return ThrowException(Exception::Error(
@ -2767,7 +2770,7 @@ Handle<Value> DebugProcess(const Arguments& args) {
return ThrowException(ErrnoException(errno, "kill")); return ThrowException(ErrnoException(errno, "kill"));
} }
return Undefined(); return Undefined(node_isolate);
} }
#endif // __POSIX__ #endif // __POSIX__
@ -2783,7 +2786,7 @@ DWORD WINAPI EnableDebugThreadProc(void* arg) {
} }
} }
v8::Debug::DebugBreak(); v8::Debug::DebugBreak(node_isolate);
return 0; return 0;
} }
@ -2839,8 +2842,8 @@ static int RegisterDebugSignalHandler() {
static Handle<Value> DebugProcess(const Arguments& args) { static Handle<Value> DebugProcess(const Arguments& args) {
HandleScope scope; HandleScope scope(node_isolate);
Handle<Value> rv = Undefined(); Handle<Value> rv = Undefined(node_isolate);
DWORD pid; DWORD pid;
HANDLE process = NULL; HANDLE process = NULL;
HANDLE thread = NULL; HANDLE thread = NULL;
@ -2924,14 +2927,14 @@ static Handle<Value> DebugProcess(const Arguments& args) {
CloseHandle(mapping); CloseHandle(mapping);
} }
return Undefined(); return Undefined(node_isolate);
} }
#endif // _WIN32 #endif // _WIN32
static Handle<Value> DebugPause(const Arguments& args) { static Handle<Value> DebugPause(const Arguments& args) {
v8::Debug::DebugBreak(node_isolate); v8::Debug::DebugBreak(node_isolate);
return Undefined(); return Undefined(node_isolate);
} }
@ -2941,7 +2944,7 @@ static Handle<Value> DebugEnd(const Arguments& args) {
debugger_running = false; debugger_running = false;
} }
return Undefined(); return Undefined(node_isolate);
} }
@ -3055,11 +3058,11 @@ 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()); process_l->Set(String::NewSymbol("_exiting"), True(node_isolate));
Local<Value> emit_v = process_l->Get(String::New("emit")); Local<Value> emit_v = process_l->Get(String::New("emit"));
assert(emit_v->IsFunction()); assert(emit_v->IsFunction());
Local<Function> emit = Local<Function>::Cast(emit_v); Local<Function> emit = Local<Function>::Cast(emit_v);
Local<Value> args[] = { String::New("exit"), Integer::New(0) }; Local<Value> args[] = { String::New("exit"), Integer::New(0, node_isolate) };
TryCatch try_catch; TryCatch try_catch;
emit->Call(process_l, 2, args); emit->Call(process_l, 2, args);
if (try_catch.HasCaught()) { if (try_catch.HasCaught()) {

108
src/node_buffer.cc

@ -92,7 +92,7 @@ static inline size_t base64_decoded_size(const char *src, size_t size) {
static size_t ByteLength (Handle<String> string, enum encoding enc) { static size_t ByteLength (Handle<String> string, enum encoding enc) {
HandleScope scope; HandleScope scope(node_isolate);
if (enc == UTF8) { if (enc == UTF8) {
return string->Utf8Length(); return string->Utf8Length();
@ -110,7 +110,7 @@ static size_t ByteLength (Handle<String> string, enum encoding enc) {
Handle<Object> Buffer::New(Handle<String> string) { Handle<Object> Buffer::New(Handle<String> string) {
HandleScope scope; HandleScope scope(node_isolate);
// get Buffer from global scope. // get Buffer from global scope.
Local<Object> global = v8::Context::GetCurrent()->Global(); Local<Object> global = v8::Context::GetCurrent()->Global();
@ -118,7 +118,7 @@ Handle<Object> Buffer::New(Handle<String> string) {
assert(bv->IsFunction()); assert(bv->IsFunction());
Local<Function> b = Local<Function>::Cast(bv); Local<Function> b = Local<Function>::Cast(bv);
Local<Value> argv[1] = { Local<Value>::New(string) }; Local<Value> argv[1] = { Local<Value>::New(node_isolate, string) };
Local<Object> instance = b->NewInstance(1, argv); Local<Object> instance = b->NewInstance(1, argv);
return scope.Close(instance); return scope.Close(instance);
@ -126,9 +126,9 @@ Handle<Object> Buffer::New(Handle<String> string) {
Buffer* Buffer::New(size_t length) { Buffer* Buffer::New(size_t length) {
HandleScope scope; HandleScope scope(node_isolate);
Local<Value> arg = Integer::NewFromUnsigned(length); Local<Value> arg = Integer::NewFromUnsigned(length, node_isolate);
Local<Object> b = constructor_template->GetFunction()->NewInstance(1, &arg); Local<Object> b = constructor_template->GetFunction()->NewInstance(1, &arg);
if (b.IsEmpty()) return NULL; if (b.IsEmpty()) return NULL;
@ -137,9 +137,9 @@ Buffer* Buffer::New(size_t length) {
Buffer* Buffer::New(const char* data, size_t length) { Buffer* Buffer::New(const char* data, size_t length) {
HandleScope scope; HandleScope scope(node_isolate);
Local<Value> arg = Integer::NewFromUnsigned(0); Local<Value> arg = Integer::NewFromUnsigned(0, node_isolate);
Local<Object> obj = constructor_template->GetFunction()->NewInstance(1, &arg); Local<Object> obj = constructor_template->GetFunction()->NewInstance(1, &arg);
Buffer *buffer = ObjectWrap::Unwrap<Buffer>(obj); Buffer *buffer = ObjectWrap::Unwrap<Buffer>(obj);
@ -151,9 +151,9 @@ Buffer* Buffer::New(const char* data, size_t length) {
Buffer* Buffer::New(char *data, size_t length, Buffer* Buffer::New(char *data, size_t length,
free_callback callback, void *hint) { free_callback callback, void *hint) {
HandleScope scope; HandleScope scope(node_isolate);
Local<Value> arg = Integer::NewFromUnsigned(0); Local<Value> arg = Integer::NewFromUnsigned(0, node_isolate);
Local<Object> obj = constructor_template->GetFunction()->NewInstance(1, &arg); Local<Object> obj = constructor_template->GetFunction()->NewInstance(1, &arg);
Buffer *buffer = ObjectWrap::Unwrap<Buffer>(obj); Buffer *buffer = ObjectWrap::Unwrap<Buffer>(obj);
@ -168,7 +168,7 @@ Handle<Value> Buffer::New(const Arguments &args) {
return FromConstructorTemplate(constructor_template, args); return FromConstructorTemplate(constructor_template, args);
} }
HandleScope scope; HandleScope scope(node_isolate);
if (!args[0]->IsUint32()) return ThrowTypeError("Bad argument"); if (!args[0]->IsUint32()) return ThrowTypeError("Bad argument");
@ -202,7 +202,7 @@ Buffer::~Buffer() {
// const_cast in Buffer::New requires this // const_cast in Buffer::New requires this
void Buffer::Replace(char *data, size_t length, void Buffer::Replace(char *data, size_t length,
free_callback callback, void *hint) { free_callback callback, void *hint) {
HandleScope scope; HandleScope scope(node_isolate);
if (callback_) { if (callback_) {
callback_(data_, callback_hint_); callback_(data_, callback_hint_);
@ -231,12 +231,12 @@ void Buffer::Replace(char *data, size_t length,
handle_->SetIndexedPropertiesToExternalArrayData(data_, handle_->SetIndexedPropertiesToExternalArrayData(data_,
kExternalUnsignedByteArray, kExternalUnsignedByteArray,
length_); length_);
handle_->Set(length_symbol, Integer::NewFromUnsigned(length_)); handle_->Set(length_symbol, Integer::NewFromUnsigned(length_, node_isolate));
} }
Handle<Value> Buffer::BinarySlice(const Arguments &args) { Handle<Value> Buffer::BinarySlice(const Arguments &args) {
HandleScope scope; HandleScope scope(node_isolate);
Buffer *parent = ObjectWrap::Unwrap<Buffer>(args.This()); Buffer *parent = ObjectWrap::Unwrap<Buffer>(args.This());
SLICE_ARGS(args[0], args[1]) SLICE_ARGS(args[0], args[1])
@ -352,7 +352,7 @@ static void force_ascii(const char* src, char* dst, size_t len) {
Handle<Value> Buffer::AsciiSlice(const Arguments &args) { Handle<Value> Buffer::AsciiSlice(const Arguments &args) {
HandleScope scope; HandleScope scope(node_isolate);
Buffer *parent = ObjectWrap::Unwrap<Buffer>(args.This()); Buffer *parent = ObjectWrap::Unwrap<Buffer>(args.This());
SLICE_ARGS(args[0], args[1]) SLICE_ARGS(args[0], args[1])
@ -372,7 +372,7 @@ Handle<Value> Buffer::AsciiSlice(const Arguments &args) {
Handle<Value> Buffer::Utf8Slice(const Arguments &args) { Handle<Value> Buffer::Utf8Slice(const Arguments &args) {
HandleScope scope; HandleScope scope(node_isolate);
Buffer *parent = ObjectWrap::Unwrap<Buffer>(args.This()); Buffer *parent = ObjectWrap::Unwrap<Buffer>(args.This());
SLICE_ARGS(args[0], args[1]) SLICE_ARGS(args[0], args[1])
char *data = parent->data_ + start; char *data = parent->data_ + start;
@ -382,7 +382,7 @@ Handle<Value> Buffer::Utf8Slice(const Arguments &args) {
Handle<Value> Buffer::Ucs2Slice(const Arguments &args) { Handle<Value> Buffer::Ucs2Slice(const Arguments &args) {
HandleScope scope; HandleScope scope(node_isolate);
Buffer *parent = ObjectWrap::Unwrap<Buffer>(args.This()); Buffer *parent = ObjectWrap::Unwrap<Buffer>(args.This());
SLICE_ARGS(args[0], args[1]) SLICE_ARGS(args[0], args[1])
uint16_t *data = (uint16_t*)(parent->data_ + start); uint16_t *data = (uint16_t*)(parent->data_ + start);
@ -392,12 +392,12 @@ Handle<Value> Buffer::Ucs2Slice(const Arguments &args) {
Handle<Value> Buffer::HexSlice(const Arguments &args) { Handle<Value> Buffer::HexSlice(const Arguments &args) {
HandleScope scope; HandleScope scope(node_isolate);
Buffer* parent = ObjectWrap::Unwrap<Buffer>(args.This()); Buffer* parent = ObjectWrap::Unwrap<Buffer>(args.This());
SLICE_ARGS(args[0], args[1]) SLICE_ARGS(args[0], args[1])
char* src = parent->data_ + start; char* src = parent->data_ + start;
uint32_t dstlen = (end - start) * 2; uint32_t dstlen = (end - start) * 2;
if (dstlen == 0) return scope.Close(String::Empty()); if (dstlen == 0) return scope.Close(String::Empty(node_isolate));
char* dst = new char[dstlen]; char* dst = new char[dstlen];
for (uint32_t i = 0, k = 0; k < dstlen; i += 1, k += 2) { for (uint32_t i = 0, k = 0; k < dstlen; i += 1, k += 2) {
static const char hex[] = "0123456789abcdef"; static const char hex[] = "0123456789abcdef";
@ -434,7 +434,7 @@ static const int unbase64_table[] =
Handle<Value> Buffer::Base64Slice(const Arguments &args) { Handle<Value> Buffer::Base64Slice(const Arguments &args) {
HandleScope scope; HandleScope scope(node_isolate);
Buffer *parent = ObjectWrap::Unwrap<Buffer>(args.This()); Buffer *parent = ObjectWrap::Unwrap<Buffer>(args.This());
SLICE_ARGS(args[0], args[1]) SLICE_ARGS(args[0], args[1])
@ -503,7 +503,7 @@ Handle<Value> Buffer::Base64Slice(const Arguments &args) {
// buffer.fill(value, start, end); // buffer.fill(value, start, end);
Handle<Value> Buffer::Fill(const Arguments &args) { Handle<Value> Buffer::Fill(const Arguments &args) {
HandleScope scope; HandleScope scope(node_isolate);
if (!args[0]->IsInt32()) { if (!args[0]->IsInt32()) {
return ThrowException(Exception::Error(String::New( return ThrowException(Exception::Error(String::New(
@ -518,13 +518,13 @@ Handle<Value> Buffer::Fill(const Arguments &args) {
value, value,
end - start); end - start);
return Undefined(); return Undefined(node_isolate);
} }
// var bytesCopied = buffer.copy(target, targetStart, sourceStart, sourceEnd); // var bytesCopied = buffer.copy(target, targetStart, sourceStart, sourceEnd);
Handle<Value> Buffer::Copy(const Arguments &args) { Handle<Value> Buffer::Copy(const Arguments &args) {
HandleScope scope; HandleScope scope(node_isolate);
Buffer *source = ObjectWrap::Unwrap<Buffer>(args.This()); Buffer *source = ObjectWrap::Unwrap<Buffer>(args.This());
@ -546,7 +546,7 @@ Handle<Value> Buffer::Copy(const Arguments &args) {
// Copy 0 bytes; we're done // Copy 0 bytes; we're done
if (source_end == source_start) { if (source_end == source_start) {
return scope.Close(Integer::New(0)); return scope.Close(Integer::New(0, node_isolate));
} }
if (target_start >= target_length) { if (target_start >= target_length) {
@ -570,13 +570,13 @@ Handle<Value> Buffer::Copy(const Arguments &args) {
(const void*)(source->data_ + source_start), (const void*)(source->data_ + source_start),
to_copy); to_copy);
return scope.Close(Integer::New(to_copy)); return scope.Close(Integer::New(to_copy, node_isolate));
} }
// var charsWritten = buffer.utf8Write(string, offset, [maxLength]); // var charsWritten = buffer.utf8Write(string, offset, [maxLength]);
Handle<Value> Buffer::Utf8Write(const Arguments &args) { Handle<Value> Buffer::Utf8Write(const Arguments &args) {
HandleScope scope; HandleScope scope(node_isolate);
Buffer *buffer = ObjectWrap::Unwrap<Buffer>(args.This()); Buffer *buffer = ObjectWrap::Unwrap<Buffer>(args.This());
if (!args[0]->IsString()) { if (!args[0]->IsString()) {
@ -592,8 +592,8 @@ Handle<Value> Buffer::Utf8Write(const Arguments &args) {
if (length == 0) { if (length == 0) {
constructor_template->GetFunction()->Set(chars_written_sym, constructor_template->GetFunction()->Set(chars_written_sym,
Integer::New(0)); Integer::New(0, node_isolate));
return scope.Close(Integer::New(0)); return scope.Close(Integer::New(0, node_isolate));
} }
if (length > 0 && offset >= buffer->length_) { if (length > 0 && offset >= buffer->length_) {
@ -615,15 +615,16 @@ Handle<Value> Buffer::Utf8Write(const Arguments &args) {
String::NO_NULL_TERMINATION)); String::NO_NULL_TERMINATION));
constructor_template->GetFunction()->Set(chars_written_sym, constructor_template->GetFunction()->Set(chars_written_sym,
Integer::New(char_written)); Integer::New(char_written,
node_isolate));
return scope.Close(Integer::New(written)); return scope.Close(Integer::New(written, node_isolate));
} }
// var charsWritten = buffer.ucs2Write(string, offset, [maxLength]); // var charsWritten = buffer.ucs2Write(string, offset, [maxLength]);
Handle<Value> Buffer::Ucs2Write(const Arguments &args) { Handle<Value> Buffer::Ucs2Write(const Arguments &args) {
HandleScope scope; HandleScope scope(node_isolate);
Buffer *buffer = ObjectWrap::Unwrap<Buffer>(args.This()); Buffer *buffer = ObjectWrap::Unwrap<Buffer>(args.This());
if (!args[0]->IsString()) { if (!args[0]->IsString()) {
@ -652,9 +653,9 @@ Handle<Value> Buffer::Ucs2Write(const Arguments &args) {
String::NO_NULL_TERMINATION)); String::NO_NULL_TERMINATION));
constructor_template->GetFunction()->Set(chars_written_sym, constructor_template->GetFunction()->Set(chars_written_sym,
Integer::New(written)); Integer::New(written, node_isolate));
return scope.Close(Integer::New(written * 2)); return scope.Close(Integer::New(written * 2, node_isolate));
} }
@ -667,7 +668,7 @@ inline unsigned hex2bin(char c) {
Handle<Value> Buffer::HexWrite(const Arguments& args) { Handle<Value> Buffer::HexWrite(const Arguments& args) {
HandleScope scope; HandleScope scope(node_isolate);
Buffer* parent = ObjectWrap::Unwrap<Buffer>(args.This()); Buffer* parent = ObjectWrap::Unwrap<Buffer>(args.This());
if (args[0]->IsString() == false) { if (args[0]->IsString() == false) {
@ -685,7 +686,7 @@ Handle<Value> Buffer::HexWrite(const Arguments& args) {
uint32_t end = start + size; uint32_t end = start + size;
if (start >= parent->length_) { if (start >= parent->length_) {
Local<Integer> val = Integer::New(0); Local<Integer> val = Integer::New(0, node_isolate);
constructor_template->GetFunction()->Set(chars_written_sym, val); constructor_template->GetFunction()->Set(chars_written_sym, val);
return scope.Close(val); return scope.Close(val);
} }
@ -696,7 +697,7 @@ Handle<Value> Buffer::HexWrite(const Arguments& args) {
} }
if (size == 0) { if (size == 0) {
Local<Integer> val = Integer::New(0); Local<Integer> val = Integer::New(0, node_isolate);
constructor_template->GetFunction()->Set(chars_written_sym, val); constructor_template->GetFunction()->Set(chars_written_sym, val);
return scope.Close(val); return scope.Close(val);
} }
@ -718,15 +719,15 @@ Handle<Value> Buffer::HexWrite(const Arguments& args) {
} }
constructor_template->GetFunction()->Set(chars_written_sym, constructor_template->GetFunction()->Set(chars_written_sym,
Integer::New(max * 2)); Integer::New(max * 2, node_isolate));
return scope.Close(Integer::New(max)); return scope.Close(Integer::New(max, node_isolate));
} }
// var charsWritten = buffer.asciiWrite(string, offset); // var charsWritten = buffer.asciiWrite(string, offset);
Handle<Value> Buffer::AsciiWrite(const Arguments &args) { Handle<Value> Buffer::AsciiWrite(const Arguments &args) {
HandleScope scope; HandleScope scope(node_isolate);
Buffer *buffer = ObjectWrap::Unwrap<Buffer>(args.This()); Buffer *buffer = ObjectWrap::Unwrap<Buffer>(args.This());
@ -755,15 +756,15 @@ Handle<Value> Buffer::AsciiWrite(const Arguments &args) {
String::NO_NULL_TERMINATION)); String::NO_NULL_TERMINATION));
constructor_template->GetFunction()->Set(chars_written_sym, constructor_template->GetFunction()->Set(chars_written_sym,
Integer::New(written)); Integer::New(written, node_isolate));
return scope.Close(Integer::New(written)); return scope.Close(Integer::New(written, node_isolate));
} }
// var bytesWritten = buffer.base64Write(string, offset, [maxLength]); // var bytesWritten = buffer.base64Write(string, offset, [maxLength]);
Handle<Value> Buffer::Base64Write(const Arguments &args) { Handle<Value> Buffer::Base64Write(const Arguments &args) {
HandleScope scope; HandleScope scope(node_isolate);
Buffer *buffer = ObjectWrap::Unwrap<Buffer>(args.This()); Buffer *buffer = ObjectWrap::Unwrap<Buffer>(args.This());
@ -818,14 +819,15 @@ Handle<Value> Buffer::Base64Write(const Arguments &args) {
} }
constructor_template->GetFunction()->Set(chars_written_sym, constructor_template->GetFunction()->Set(chars_written_sym,
Integer::New(dst - start)); Integer::New(dst - start,
node_isolate));
return scope.Close(Integer::New(dst - start)); return scope.Close(Integer::New(dst - start, node_isolate));
} }
Handle<Value> Buffer::BinaryWrite(const Arguments &args) { Handle<Value> Buffer::BinaryWrite(const Arguments &args) {
HandleScope scope; HandleScope scope(node_isolate);
Buffer *buffer = ObjectWrap::Unwrap<Buffer>(args.This()); Buffer *buffer = ObjectWrap::Unwrap<Buffer>(args.This());
@ -850,9 +852,9 @@ Handle<Value> Buffer::BinaryWrite(const Arguments &args) {
int written = DecodeWrite(p, max_length, s, BINARY); int written = DecodeWrite(p, max_length, s, BINARY);
constructor_template->GetFunction()->Set(chars_written_sym, constructor_template->GetFunction()->Set(chars_written_sym,
Integer::New(written)); Integer::New(written, node_isolate));
return scope.Close(Integer::New(written)); return scope.Close(Integer::New(written, node_isolate));
} }
@ -949,7 +951,7 @@ Handle<Value> WriteFloatGeneric(const Arguments& args) {
if (ENDIANNESS != is_big_endian()) if (ENDIANNESS != is_big_endian())
swizzle(ptr, sizeof(T)); swizzle(ptr, sizeof(T));
return Undefined(); return Undefined(node_isolate);
} }
@ -975,7 +977,7 @@ Handle<Value> Buffer::WriteDoubleBE(const Arguments& args) {
// var nbytes = Buffer.byteLength("string", "utf8") // var nbytes = Buffer.byteLength("string", "utf8")
Handle<Value> Buffer::ByteLength(const Arguments &args) { Handle<Value> Buffer::ByteLength(const Arguments &args) {
HandleScope scope; HandleScope scope(node_isolate);
if (!args[0]->IsString()) { if (!args[0]->IsString()) {
return ThrowTypeError("Argument must be a string"); return ThrowTypeError("Argument must be a string");
@ -984,12 +986,12 @@ Handle<Value> Buffer::ByteLength(const Arguments &args) {
Local<String> s = args[0]->ToString(); Local<String> s = args[0]->ToString();
enum encoding e = ParseEncoding(args[1], UTF8); enum encoding e = ParseEncoding(args[1], UTF8);
return scope.Close(Integer::New(node::ByteLength(s, e))); return scope.Close(Integer::New(node::ByteLength(s, e), node_isolate));
} }
Handle<Value> Buffer::MakeFastBuffer(const Arguments &args) { Handle<Value> Buffer::MakeFastBuffer(const Arguments &args) {
HandleScope scope; HandleScope scope(node_isolate);
if (!Buffer::HasInstance(args[0])) { if (!Buffer::HasInstance(args[0])) {
return ThrowTypeError("First argument must be a Buffer"); return ThrowTypeError("First argument must be a Buffer");
@ -1017,7 +1019,7 @@ Handle<Value> Buffer::MakeFastBuffer(const Arguments &args) {
kExternalUnsignedByteArray, kExternalUnsignedByteArray,
length); length);
return Undefined(); return Undefined(node_isolate);
} }
@ -1042,7 +1044,7 @@ Handle<Value> SetFastBufferConstructor(const Arguments& args) {
assert(args[0]->IsFunction()); assert(args[0]->IsFunction());
fast_buffer_constructor = Persistent<Function>::New(node_isolate, fast_buffer_constructor = Persistent<Function>::New(node_isolate,
args[0].As<Function>()); args[0].As<Function>());
return Undefined(); return Undefined(node_isolate);
} }
@ -1102,7 +1104,7 @@ RetainedObjectInfo* WrapperInfo(uint16_t class_id, Handle<Value> wrapper) {
void Buffer::Initialize(Handle<Object> target) { void Buffer::Initialize(Handle<Object> target) {
HandleScope scope; HandleScope scope(node_isolate);
// sanity checks // sanity checks
assert(unbase64('/') == 63); assert(unbase64('/') == 63);

14
src/node_counters.cc

@ -44,37 +44,37 @@ static uint64_t counter_gc_end_time;
Handle<Value> COUNTER_NET_SERVER_CONNECTION(const Arguments& args) { Handle<Value> COUNTER_NET_SERVER_CONNECTION(const Arguments& args) {
NODE_COUNT_SERVER_CONN_OPEN(); NODE_COUNT_SERVER_CONN_OPEN();
return Undefined(); return Undefined(node_isolate);
} }
Handle<Value> COUNTER_NET_SERVER_CONNECTION_CLOSE(const Arguments& args) { Handle<Value> COUNTER_NET_SERVER_CONNECTION_CLOSE(const Arguments& args) {
NODE_COUNT_SERVER_CONN_CLOSE(); NODE_COUNT_SERVER_CONN_CLOSE();
return Undefined(); return Undefined(node_isolate);
} }
Handle<Value> COUNTER_HTTP_SERVER_REQUEST(const Arguments& args) { Handle<Value> COUNTER_HTTP_SERVER_REQUEST(const Arguments& args) {
NODE_COUNT_HTTP_SERVER_REQUEST(); NODE_COUNT_HTTP_SERVER_REQUEST();
return Undefined(); return Undefined(node_isolate);
} }
Handle<Value> COUNTER_HTTP_SERVER_RESPONSE(const Arguments& args) { Handle<Value> COUNTER_HTTP_SERVER_RESPONSE(const Arguments& args) {
NODE_COUNT_HTTP_SERVER_RESPONSE(); NODE_COUNT_HTTP_SERVER_RESPONSE();
return Undefined(); return Undefined(node_isolate);
} }
Handle<Value> COUNTER_HTTP_CLIENT_REQUEST(const Arguments& args) { Handle<Value> COUNTER_HTTP_CLIENT_REQUEST(const Arguments& args) {
NODE_COUNT_HTTP_CLIENT_REQUEST(); NODE_COUNT_HTTP_CLIENT_REQUEST();
return Undefined(); return Undefined(node_isolate);
} }
Handle<Value> COUNTER_HTTP_CLIENT_RESPONSE(const Arguments& args) { Handle<Value> COUNTER_HTTP_CLIENT_RESPONSE(const Arguments& args) {
NODE_COUNT_HTTP_CLIENT_RESPONSE(); NODE_COUNT_HTTP_CLIENT_RESPONSE();
return Undefined(); return Undefined(node_isolate);
} }
@ -106,7 +106,7 @@ static void counter_gc_done(GCType type, GCCallbackFlags flags) {
#define NODE_PROBE(name) #name, name #define NODE_PROBE(name) #name, name
void InitPerfCounters(Handle<Object> target) { void InitPerfCounters(Handle<Object> target) {
HandleScope scope; HandleScope scope(node_isolate);
static struct { static struct {
const char* name; const char* name;

350
src/node_crypto.cc

File diff suppressed because it is too large

48
src/node_dtrace.cc

@ -129,10 +129,10 @@ using namespace v8;
Handle<Value> DTRACE_NET_SERVER_CONNECTION(const Arguments& args) { Handle<Value> DTRACE_NET_SERVER_CONNECTION(const Arguments& args) {
#ifndef HAVE_SYSTEMTAP #ifndef HAVE_SYSTEMTAP
if (!NODE_NET_SERVER_CONNECTION_ENABLED()) if (!NODE_NET_SERVER_CONNECTION_ENABLED())
return Undefined(); return Undefined(node_isolate);
#endif #endif
HandleScope scope; HandleScope scope(node_isolate);
SLURP_CONNECTION(args[0], conn); SLURP_CONNECTION(args[0], conn);
#ifdef HAVE_SYSTEMTAP #ifdef HAVE_SYSTEMTAP
@ -142,16 +142,16 @@ Handle<Value> DTRACE_NET_SERVER_CONNECTION(const Arguments& args) {
NODE_NET_SERVER_CONNECTION(&conn); NODE_NET_SERVER_CONNECTION(&conn);
#endif #endif
return Undefined(); return Undefined(node_isolate);
} }
Handle<Value> DTRACE_NET_STREAM_END(const Arguments& args) { Handle<Value> DTRACE_NET_STREAM_END(const Arguments& args) {
#ifndef HAVE_SYSTEMTAP #ifndef HAVE_SYSTEMTAP
if (!NODE_NET_STREAM_END_ENABLED()) if (!NODE_NET_STREAM_END_ENABLED())
return Undefined(); return Undefined(node_isolate);
#endif #endif
HandleScope scope; HandleScope scope(node_isolate);
SLURP_CONNECTION(args[0], conn); SLURP_CONNECTION(args[0], conn);
#ifdef HAVE_SYSTEMTAP #ifdef HAVE_SYSTEMTAP
@ -160,16 +160,16 @@ Handle<Value> DTRACE_NET_STREAM_END(const Arguments& args) {
NODE_NET_STREAM_END(&conn); NODE_NET_STREAM_END(&conn);
#endif #endif
return Undefined(); return Undefined(node_isolate);
} }
Handle<Value> DTRACE_NET_SOCKET_READ(const Arguments& args) { Handle<Value> DTRACE_NET_SOCKET_READ(const Arguments& args) {
#ifndef HAVE_SYSTEMTAP #ifndef HAVE_SYSTEMTAP
if (!NODE_NET_SOCKET_READ_ENABLED()) if (!NODE_NET_SOCKET_READ_ENABLED())
return Undefined(); return Undefined(node_isolate);
#endif #endif
HandleScope scope; HandleScope scope(node_isolate);
SLURP_CONNECTION(args[0], conn); SLURP_CONNECTION(args[0], conn);
@ -184,16 +184,16 @@ Handle<Value> DTRACE_NET_SOCKET_READ(const Arguments& args) {
NODE_NET_SOCKET_READ(&conn, nbytes); NODE_NET_SOCKET_READ(&conn, nbytes);
#endif #endif
return Undefined(); return Undefined(node_isolate);
} }
Handle<Value> DTRACE_NET_SOCKET_WRITE(const Arguments& args) { Handle<Value> DTRACE_NET_SOCKET_WRITE(const Arguments& args) {
#ifndef HAVE_SYSTEMTAP #ifndef HAVE_SYSTEMTAP
if (!NODE_NET_SOCKET_WRITE_ENABLED()) if (!NODE_NET_SOCKET_WRITE_ENABLED())
return Undefined(); return Undefined(node_isolate);
#endif #endif
HandleScope scope; HandleScope scope(node_isolate);
SLURP_CONNECTION(args[0], conn); SLURP_CONNECTION(args[0], conn);
@ -208,7 +208,7 @@ Handle<Value> DTRACE_NET_SOCKET_WRITE(const Arguments& args) {
NODE_NET_SOCKET_WRITE(&conn, nbytes); NODE_NET_SOCKET_WRITE(&conn, nbytes);
#endif #endif
return Undefined(); return Undefined(node_isolate);
} }
Handle<Value> DTRACE_HTTP_SERVER_REQUEST(const Arguments& args) { Handle<Value> DTRACE_HTTP_SERVER_REQUEST(const Arguments& args) {
@ -216,10 +216,10 @@ Handle<Value> DTRACE_HTTP_SERVER_REQUEST(const Arguments& args) {
#ifndef HAVE_SYSTEMTAP #ifndef HAVE_SYSTEMTAP
if (!NODE_HTTP_SERVER_REQUEST_ENABLED()) if (!NODE_HTTP_SERVER_REQUEST_ENABLED())
return Undefined(); return Undefined(node_isolate);
#endif #endif
HandleScope scope; HandleScope scope(node_isolate);
Local<Object> arg0 = Local<Object>::Cast(args[0]); Local<Object> arg0 = Local<Object>::Cast(args[0]);
Local<Object> headers; Local<Object> headers;
@ -249,16 +249,16 @@ Handle<Value> DTRACE_HTTP_SERVER_REQUEST(const Arguments& args) {
#else #else
NODE_HTTP_SERVER_REQUEST(&req, &conn); NODE_HTTP_SERVER_REQUEST(&req, &conn);
#endif #endif
return Undefined(); return Undefined(node_isolate);
} }
Handle<Value> DTRACE_HTTP_SERVER_RESPONSE(const Arguments& args) { Handle<Value> DTRACE_HTTP_SERVER_RESPONSE(const Arguments& args) {
#ifndef HAVE_SYSTEMTAP #ifndef HAVE_SYSTEMTAP
if (!NODE_HTTP_SERVER_RESPONSE_ENABLED()) if (!NODE_HTTP_SERVER_RESPONSE_ENABLED())
return Undefined(); return Undefined(node_isolate);
#endif #endif
HandleScope scope; HandleScope scope(node_isolate);
SLURP_CONNECTION(args[0], conn); SLURP_CONNECTION(args[0], conn);
#ifdef HAVE_SYSTEMTAP #ifdef HAVE_SYSTEMTAP
@ -267,7 +267,7 @@ Handle<Value> DTRACE_HTTP_SERVER_RESPONSE(const Arguments& args) {
NODE_HTTP_SERVER_RESPONSE(&conn); NODE_HTTP_SERVER_RESPONSE(&conn);
#endif #endif
return Undefined(); return Undefined(node_isolate);
} }
Handle<Value> DTRACE_HTTP_CLIENT_REQUEST(const Arguments& args) { Handle<Value> DTRACE_HTTP_CLIENT_REQUEST(const Arguments& args) {
@ -276,10 +276,10 @@ Handle<Value> DTRACE_HTTP_CLIENT_REQUEST(const Arguments& args) {
#ifndef HAVE_SYSTEMTAP #ifndef HAVE_SYSTEMTAP
if (!NODE_HTTP_CLIENT_REQUEST_ENABLED()) if (!NODE_HTTP_CLIENT_REQUEST_ENABLED())
return Undefined(); return Undefined(node_isolate);
#endif #endif
HandleScope scope; HandleScope scope(node_isolate);
/* /*
* For the method and URL, we're going to dig them out of the header. This * For the method and URL, we're going to dig them out of the header. This
@ -312,15 +312,15 @@ Handle<Value> DTRACE_HTTP_CLIENT_REQUEST(const Arguments& args) {
#else #else
NODE_HTTP_CLIENT_REQUEST(&req, &conn); NODE_HTTP_CLIENT_REQUEST(&req, &conn);
#endif #endif
return Undefined(); return Undefined(node_isolate);
} }
Handle<Value> DTRACE_HTTP_CLIENT_RESPONSE(const Arguments& args) { Handle<Value> DTRACE_HTTP_CLIENT_RESPONSE(const Arguments& args) {
#ifndef HAVE_SYSTEMTAP #ifndef HAVE_SYSTEMTAP
if (!NODE_HTTP_CLIENT_RESPONSE_ENABLED()) if (!NODE_HTTP_CLIENT_RESPONSE_ENABLED())
return Undefined(); return Undefined(node_isolate);
#endif #endif
HandleScope scope; HandleScope scope(node_isolate);
SLURP_CONNECTION_HTTP_CLIENT_RESPONSE(args[0], args[1], conn); SLURP_CONNECTION_HTTP_CLIENT_RESPONSE(args[0], args[1], conn);
#ifdef HAVE_SYSTEMTAP #ifdef HAVE_SYSTEMTAP
@ -329,7 +329,7 @@ Handle<Value> DTRACE_HTTP_CLIENT_RESPONSE(const Arguments& args) {
NODE_HTTP_CLIENT_RESPONSE(&conn); NODE_HTTP_CLIENT_RESPONSE(&conn);
#endif #endif
return Undefined(); return Undefined(node_isolate);
} }
#define NODE_PROBE(name) #name, name, Persistent<FunctionTemplate>() #define NODE_PROBE(name) #name, name, Persistent<FunctionTemplate>()

108
src/node_file.cc

@ -81,7 +81,7 @@ static inline int IsInt64(double x) {
static void After(uv_fs_t *req) { static void After(uv_fs_t *req) {
HandleScope scope; HandleScope scope(node_isolate);
FSReqWrap* req_wrap = (FSReqWrap*) req->data; FSReqWrap* req_wrap = (FSReqWrap*) req->data;
assert(&req_wrap->req_ == req); assert(&req_wrap->req_ == req);
@ -110,7 +110,7 @@ static void After(uv_fs_t *req) {
} }
} else { } else {
// error value is empty or null for non-error. // error value is empty or null for non-error.
argv[0] = Local<Value>::New(Null()); argv[0] = Local<Value>::New(node_isolate, Null(node_isolate));
// All have at least two args now. // All have at least two args now.
argc = 2; argc = 2;
@ -141,11 +141,11 @@ static void After(uv_fs_t *req) {
break; break;
case UV_FS_OPEN: case UV_FS_OPEN:
argv[1] = Integer::New(req->result); argv[1] = Integer::New(req->result, node_isolate);
break; break;
case UV_FS_WRITE: case UV_FS_WRITE:
argv[1] = Integer::New(req->result); argv[1] = Integer::New(req->result, node_isolate);
break; break;
case UV_FS_STAT: case UV_FS_STAT:
@ -160,7 +160,7 @@ static void After(uv_fs_t *req) {
case UV_FS_READ: case UV_FS_READ:
// Buffer interface // Buffer interface
argv[1] = Integer::New(req->result); argv[1] = Integer::New(req->result, node_isolate);
break; break;
case UV_FS_READDIR: case UV_FS_READDIR:
@ -172,7 +172,7 @@ static void After(uv_fs_t *req) {
for (int i = 0; i < nnames; i++) { for (int i = 0; i < nnames; i++) {
Local<String> name = String::New(namebuf); Local<String> name = String::New(namebuf);
names->Set(Integer::New(i), name); names->Set(Integer::New(i, node_isolate), name);
#ifndef NDEBUG #ifndef NDEBUG
namebuf += strlen(namebuf); namebuf += strlen(namebuf);
assert(*namebuf == '\0'); assert(*namebuf == '\0');
@ -241,7 +241,7 @@ struct fs_req_wrap {
static Handle<Value> Close(const Arguments& args) { static Handle<Value> Close(const Arguments& args) {
HandleScope scope; HandleScope scope(node_isolate);
if (args.Length() < 1 || !args[0]->IsInt32()) { if (args.Length() < 1 || !args[0]->IsInt32()) {
return THROW_BAD_ARGS; return THROW_BAD_ARGS;
@ -253,7 +253,7 @@ static Handle<Value> Close(const Arguments& args) {
ASYNC_CALL(close, args[1], fd) ASYNC_CALL(close, args[1], fd)
} else { } else {
SYNC_CALL(close, 0, fd) SYNC_CALL(close, 0, fd)
return Undefined(); return Undefined(node_isolate);
} }
} }
@ -275,7 +275,7 @@ static Persistent<String> mtime_symbol;
static Persistent<String> ctime_symbol; static Persistent<String> ctime_symbol;
Local<Object> BuildStatsObject(const uv_statbuf_t* s) { Local<Object> BuildStatsObject(const uv_statbuf_t* s) {
HandleScope scope; HandleScope scope(node_isolate);
if (dev_symbol.IsEmpty()) { if (dev_symbol.IsEmpty()) {
dev_symbol = NODE_PSYMBOL("dev"); dev_symbol = NODE_PSYMBOL("dev");
@ -311,7 +311,7 @@ Local<Object> BuildStatsObject(const uv_statbuf_t* s) {
// and make sure that we bail out when V8 returns an empty handle. // and make sure that we bail out when V8 returns an empty handle.
#define X(name) \ #define X(name) \
{ \ { \
Local<Value> val = Integer::New(s->st_##name); \ Local<Value> val = Integer::New(s->st_##name, node_isolate); \
if (val.IsEmpty()) return Local<Object>(); \ if (val.IsEmpty()) return Local<Object>(); \
stats->Set(name##_symbol, val); \ stats->Set(name##_symbol, val); \
} }
@ -354,7 +354,7 @@ Local<Object> BuildStatsObject(const uv_statbuf_t* s) {
} }
static Handle<Value> Stat(const Arguments& args) { static Handle<Value> Stat(const Arguments& args) {
HandleScope scope; HandleScope scope(node_isolate);
if (args.Length() < 1) return TYPE_ERROR("path required"); if (args.Length() < 1) return TYPE_ERROR("path required");
if (!args[0]->IsString()) return TYPE_ERROR("path must be a string"); if (!args[0]->IsString()) return TYPE_ERROR("path must be a string");
@ -371,7 +371,7 @@ static Handle<Value> Stat(const Arguments& args) {
} }
static Handle<Value> LStat(const Arguments& args) { static Handle<Value> LStat(const Arguments& args) {
HandleScope scope; HandleScope scope(node_isolate);
if (args.Length() < 1) return TYPE_ERROR("path required"); if (args.Length() < 1) return TYPE_ERROR("path required");
if (!args[0]->IsString()) return TYPE_ERROR("path must be a string"); if (!args[0]->IsString()) return TYPE_ERROR("path must be a string");
@ -388,7 +388,7 @@ static Handle<Value> LStat(const Arguments& args) {
} }
static Handle<Value> FStat(const Arguments& args) { static Handle<Value> FStat(const Arguments& args) {
HandleScope scope; HandleScope scope(node_isolate);
if (args.Length() < 1 || !args[0]->IsInt32()) { if (args.Length() < 1 || !args[0]->IsInt32()) {
return THROW_BAD_ARGS; return THROW_BAD_ARGS;
@ -406,7 +406,7 @@ static Handle<Value> FStat(const Arguments& args) {
} }
static Handle<Value> Symlink(const Arguments& args) { static Handle<Value> Symlink(const Arguments& args) {
HandleScope scope; HandleScope scope(node_isolate);
int len = args.Length(); int len = args.Length();
if (len < 1) return TYPE_ERROR("dest path required"); if (len < 1) return TYPE_ERROR("dest path required");
@ -434,12 +434,12 @@ static Handle<Value> Symlink(const Arguments& args) {
ASYNC_CALL(symlink, args[3], *dest, *path, flags) ASYNC_CALL(symlink, args[3], *dest, *path, flags)
} else { } else {
SYNC_CALL(symlink, *path, *dest, *path, flags) SYNC_CALL(symlink, *path, *dest, *path, flags)
return Undefined(); return Undefined(node_isolate);
} }
} }
static Handle<Value> Link(const Arguments& args) { static Handle<Value> Link(const Arguments& args) {
HandleScope scope; HandleScope scope(node_isolate);
int len = args.Length(); int len = args.Length();
if (len < 1) return TYPE_ERROR("dest path required"); if (len < 1) return TYPE_ERROR("dest path required");
@ -454,12 +454,12 @@ static Handle<Value> Link(const Arguments& args) {
ASYNC_CALL(link, args[2], *orig_path, *new_path) ASYNC_CALL(link, args[2], *orig_path, *new_path)
} else { } else {
SYNC_CALL(link, *orig_path, *orig_path, *new_path) SYNC_CALL(link, *orig_path, *orig_path, *new_path)
return Undefined(); return Undefined(node_isolate);
} }
} }
static Handle<Value> ReadLink(const Arguments& args) { static Handle<Value> ReadLink(const Arguments& args) {
HandleScope scope; HandleScope scope(node_isolate);
if (args.Length() < 1) return TYPE_ERROR("path required"); if (args.Length() < 1) return TYPE_ERROR("path required");
if (!args[0]->IsString()) return TYPE_ERROR("path must be a string"); if (!args[0]->IsString()) return TYPE_ERROR("path must be a string");
@ -475,7 +475,7 @@ static Handle<Value> ReadLink(const Arguments& args) {
} }
static Handle<Value> Rename(const Arguments& args) { static Handle<Value> Rename(const Arguments& args) {
HandleScope scope; HandleScope scope(node_isolate);
int len = args.Length(); int len = args.Length();
if (len < 1) return TYPE_ERROR("old path required"); if (len < 1) return TYPE_ERROR("old path required");
@ -490,12 +490,12 @@ static Handle<Value> Rename(const Arguments& args) {
ASYNC_CALL(rename, args[2], *old_path, *new_path) ASYNC_CALL(rename, args[2], *old_path, *new_path)
} else { } else {
SYNC_CALL(rename, *old_path, *old_path, *new_path) SYNC_CALL(rename, *old_path, *old_path, *new_path)
return Undefined(); return Undefined(node_isolate);
} }
} }
static Handle<Value> FTruncate(const Arguments& args) { static Handle<Value> FTruncate(const Arguments& args) {
HandleScope scope; HandleScope scope(node_isolate);
if (args.Length() < 2 || !args[0]->IsInt32()) { if (args.Length() < 2 || !args[0]->IsInt32()) {
return THROW_BAD_ARGS; return THROW_BAD_ARGS;
@ -510,12 +510,12 @@ static Handle<Value> FTruncate(const Arguments& args) {
ASYNC_CALL(ftruncate, args[2], fd, len) ASYNC_CALL(ftruncate, args[2], fd, len)
} else { } else {
SYNC_CALL(ftruncate, 0, fd, len) SYNC_CALL(ftruncate, 0, fd, len)
return Undefined(); return Undefined(node_isolate);
} }
} }
static Handle<Value> Fdatasync(const Arguments& args) { static Handle<Value> Fdatasync(const Arguments& args) {
HandleScope scope; HandleScope scope(node_isolate);
if (args.Length() < 1 || !args[0]->IsInt32()) { if (args.Length() < 1 || !args[0]->IsInt32()) {
return THROW_BAD_ARGS; return THROW_BAD_ARGS;
@ -527,12 +527,12 @@ static Handle<Value> Fdatasync(const Arguments& args) {
ASYNC_CALL(fdatasync, args[1], fd) ASYNC_CALL(fdatasync, args[1], fd)
} else { } else {
SYNC_CALL(fdatasync, 0, fd) SYNC_CALL(fdatasync, 0, fd)
return Undefined(); return Undefined(node_isolate);
} }
} }
static Handle<Value> Fsync(const Arguments& args) { static Handle<Value> Fsync(const Arguments& args) {
HandleScope scope; HandleScope scope(node_isolate);
if (args.Length() < 1 || !args[0]->IsInt32()) { if (args.Length() < 1 || !args[0]->IsInt32()) {
return THROW_BAD_ARGS; return THROW_BAD_ARGS;
@ -544,12 +544,12 @@ static Handle<Value> Fsync(const Arguments& args) {
ASYNC_CALL(fsync, args[1], fd) ASYNC_CALL(fsync, args[1], fd)
} else { } else {
SYNC_CALL(fsync, 0, fd) SYNC_CALL(fsync, 0, fd)
return Undefined(); return Undefined(node_isolate);
} }
} }
static Handle<Value> Unlink(const Arguments& args) { static Handle<Value> Unlink(const Arguments& args) {
HandleScope scope; HandleScope scope(node_isolate);
if (args.Length() < 1) return TYPE_ERROR("path required"); if (args.Length() < 1) return TYPE_ERROR("path required");
if (!args[0]->IsString()) return TYPE_ERROR("path must be a string"); if (!args[0]->IsString()) return TYPE_ERROR("path must be a string");
@ -560,12 +560,12 @@ static Handle<Value> Unlink(const Arguments& args) {
ASYNC_CALL(unlink, args[1], *path) ASYNC_CALL(unlink, args[1], *path)
} else { } else {
SYNC_CALL(unlink, *path, *path) SYNC_CALL(unlink, *path, *path)
return Undefined(); return Undefined(node_isolate);
} }
} }
static Handle<Value> RMDir(const Arguments& args) { static Handle<Value> RMDir(const Arguments& args) {
HandleScope scope; HandleScope scope(node_isolate);
if (args.Length() < 1) return TYPE_ERROR("path required"); if (args.Length() < 1) return TYPE_ERROR("path required");
if (!args[0]->IsString()) return TYPE_ERROR("path must be a string"); if (!args[0]->IsString()) return TYPE_ERROR("path must be a string");
@ -576,12 +576,12 @@ static Handle<Value> RMDir(const Arguments& args) {
ASYNC_CALL(rmdir, args[1], *path) ASYNC_CALL(rmdir, args[1], *path)
} else { } else {
SYNC_CALL(rmdir, *path, *path) SYNC_CALL(rmdir, *path, *path)
return Undefined(); return Undefined(node_isolate);
} }
} }
static Handle<Value> MKDir(const Arguments& args) { static Handle<Value> MKDir(const Arguments& args) {
HandleScope scope; HandleScope scope(node_isolate);
if (args.Length() < 2 || !args[0]->IsString() || !args[1]->IsInt32()) { if (args.Length() < 2 || !args[0]->IsString() || !args[1]->IsInt32()) {
return THROW_BAD_ARGS; return THROW_BAD_ARGS;
@ -594,12 +594,12 @@ static Handle<Value> MKDir(const Arguments& args) {
ASYNC_CALL(mkdir, args[2], *path, mode) ASYNC_CALL(mkdir, args[2], *path, mode)
} else { } else {
SYNC_CALL(mkdir, *path, *path, mode) SYNC_CALL(mkdir, *path, *path, mode)
return Undefined(); return Undefined(node_isolate);
} }
} }
static Handle<Value> ReadDir(const Arguments& args) { static Handle<Value> ReadDir(const Arguments& args) {
HandleScope scope; HandleScope scope(node_isolate);
if (args.Length() < 1) return TYPE_ERROR("path required"); if (args.Length() < 1) return TYPE_ERROR("path required");
if (!args[0]->IsString()) return TYPE_ERROR("path must be a string"); if (!args[0]->IsString()) return TYPE_ERROR("path must be a string");
@ -617,7 +617,7 @@ static Handle<Value> ReadDir(const Arguments& args) {
for (int i = 0; i < nnames; i++) { for (int i = 0; i < nnames; i++) {
Local<String> name = String::New(namebuf); Local<String> name = String::New(namebuf);
names->Set(Integer::New(i), name); names->Set(Integer::New(i, node_isolate), name);
#ifndef NDEBUG #ifndef NDEBUG
namebuf += strlen(namebuf); namebuf += strlen(namebuf);
assert(*namebuf == '\0'); assert(*namebuf == '\0');
@ -632,7 +632,7 @@ static Handle<Value> ReadDir(const Arguments& args) {
} }
static Handle<Value> Open(const Arguments& args) { static Handle<Value> Open(const Arguments& args) {
HandleScope scope; HandleScope scope(node_isolate);
int len = args.Length(); int len = args.Length();
if (len < 1) return TYPE_ERROR("path required"); if (len < 1) return TYPE_ERROR("path required");
@ -651,7 +651,7 @@ static Handle<Value> Open(const Arguments& args) {
} else { } else {
SYNC_CALL(open, *path, *path, flags, mode) SYNC_CALL(open, *path, *path, flags, mode)
int fd = SYNC_RESULT; int fd = SYNC_RESULT;
return scope.Close(Integer::New(fd)); return scope.Close(Integer::New(fd, node_isolate));
} }
} }
@ -665,7 +665,7 @@ static Handle<Value> Open(const Arguments& args) {
// 4 position if integer, position to write at in the file. // 4 position if integer, position to write at in the file.
// if null, write from the current position // if null, write from the current position
static Handle<Value> Write(const Arguments& args) { static Handle<Value> Write(const Arguments& args) {
HandleScope scope; HandleScope scope(node_isolate);
if (!args[0]->IsInt32()) { if (!args[0]->IsInt32()) {
return THROW_BAD_ARGS; return THROW_BAD_ARGS;
@ -704,7 +704,7 @@ static Handle<Value> Write(const Arguments& args) {
ASYNC_CALL(write, cb, fd, buf, len, pos) ASYNC_CALL(write, cb, fd, buf, len, pos)
} else { } else {
SYNC_CALL(write, 0, fd, buf, len, pos) SYNC_CALL(write, 0, fd, buf, len, pos)
return scope.Close(Integer::New(SYNC_RESULT)); return scope.Close(Integer::New(SYNC_RESULT, node_isolate));
} }
} }
@ -721,7 +721,7 @@ static Handle<Value> Write(const Arguments& args) {
* *
*/ */
static Handle<Value> Read(const Arguments& args) { static Handle<Value> Read(const Arguments& args) {
HandleScope scope; HandleScope scope(node_isolate);
if (args.Length() < 2 || !args[0]->IsInt32()) { if (args.Length() < 2 || !args[0]->IsInt32()) {
return THROW_BAD_ARGS; return THROW_BAD_ARGS;
@ -767,7 +767,7 @@ static Handle<Value> Read(const Arguments& args) {
ASYNC_CALL(read, cb, fd, buf, len, pos); ASYNC_CALL(read, cb, fd, buf, len, pos);
} else { } else {
SYNC_CALL(read, 0, fd, buf, len, pos) SYNC_CALL(read, 0, fd, buf, len, pos)
Local<Integer> bytesRead = Integer::New(SYNC_RESULT); Local<Integer> bytesRead = Integer::New(SYNC_RESULT, node_isolate);
return scope.Close(bytesRead); return scope.Close(bytesRead);
} }
} }
@ -777,7 +777,7 @@ static Handle<Value> Read(const Arguments& args) {
* Wrapper for chmod(1) / EIO_CHMOD * Wrapper for chmod(1) / EIO_CHMOD
*/ */
static Handle<Value> Chmod(const Arguments& args) { static Handle<Value> Chmod(const Arguments& args) {
HandleScope scope; HandleScope scope(node_isolate);
if(args.Length() < 2 || !args[0]->IsString() || !args[1]->IsInt32()) { if(args.Length() < 2 || !args[0]->IsString() || !args[1]->IsInt32()) {
return THROW_BAD_ARGS; return THROW_BAD_ARGS;
@ -789,7 +789,7 @@ static Handle<Value> Chmod(const Arguments& args) {
ASYNC_CALL(chmod, args[2], *path, mode); ASYNC_CALL(chmod, args[2], *path, mode);
} else { } else {
SYNC_CALL(chmod, *path, *path, mode); SYNC_CALL(chmod, *path, *path, mode);
return Undefined(); return Undefined(node_isolate);
} }
} }
@ -798,7 +798,7 @@ static Handle<Value> Chmod(const Arguments& args) {
* Wrapper for fchmod(1) / EIO_FCHMOD * Wrapper for fchmod(1) / EIO_FCHMOD
*/ */
static Handle<Value> FChmod(const Arguments& args) { static Handle<Value> FChmod(const Arguments& args) {
HandleScope scope; HandleScope scope(node_isolate);
if(args.Length() < 2 || !args[0]->IsInt32() || !args[1]->IsInt32()) { if(args.Length() < 2 || !args[0]->IsInt32() || !args[1]->IsInt32()) {
return THROW_BAD_ARGS; return THROW_BAD_ARGS;
@ -810,7 +810,7 @@ static Handle<Value> FChmod(const Arguments& args) {
ASYNC_CALL(fchmod, args[2], fd, mode); ASYNC_CALL(fchmod, args[2], fd, mode);
} else { } else {
SYNC_CALL(fchmod, 0, fd, mode); SYNC_CALL(fchmod, 0, fd, mode);
return Undefined(); return Undefined(node_isolate);
} }
} }
@ -819,7 +819,7 @@ static Handle<Value> FChmod(const Arguments& args) {
* Wrapper for chown(1) / EIO_CHOWN * Wrapper for chown(1) / EIO_CHOWN
*/ */
static Handle<Value> Chown(const Arguments& args) { static Handle<Value> Chown(const Arguments& args) {
HandleScope scope; HandleScope scope(node_isolate);
int len = args.Length(); int len = args.Length();
if (len < 1) return TYPE_ERROR("path required"); if (len < 1) return TYPE_ERROR("path required");
@ -837,7 +837,7 @@ static Handle<Value> Chown(const Arguments& args) {
ASYNC_CALL(chown, args[3], *path, uid, gid); ASYNC_CALL(chown, args[3], *path, uid, gid);
} else { } else {
SYNC_CALL(chown, *path, *path, uid, gid); SYNC_CALL(chown, *path, *path, uid, gid);
return Undefined(); return Undefined(node_isolate);
} }
} }
@ -846,7 +846,7 @@ static Handle<Value> Chown(const Arguments& args) {
* Wrapper for fchown(1) / EIO_FCHOWN * Wrapper for fchown(1) / EIO_FCHOWN
*/ */
static Handle<Value> FChown(const Arguments& args) { static Handle<Value> FChown(const Arguments& args) {
HandleScope scope; HandleScope scope(node_isolate);
int len = args.Length(); int len = args.Length();
if (len < 1) return TYPE_ERROR("fd required"); if (len < 1) return TYPE_ERROR("fd required");
@ -864,13 +864,13 @@ static Handle<Value> FChown(const Arguments& args) {
ASYNC_CALL(fchown, args[3], fd, uid, gid); ASYNC_CALL(fchown, args[3], fd, uid, gid);
} else { } else {
SYNC_CALL(fchown, 0, fd, uid, gid); SYNC_CALL(fchown, 0, fd, uid, gid);
return Undefined(); return Undefined(node_isolate);
} }
} }
static Handle<Value> UTimes(const Arguments& args) { static Handle<Value> UTimes(const Arguments& args) {
HandleScope scope; HandleScope scope(node_isolate);
int len = args.Length(); int len = args.Length();
if (len < 1) return TYPE_ERROR("path required"); if (len < 1) return TYPE_ERROR("path required");
@ -888,12 +888,12 @@ static Handle<Value> UTimes(const Arguments& args) {
ASYNC_CALL(utime, args[3], *path, atime, mtime); ASYNC_CALL(utime, args[3], *path, atime, mtime);
} else { } else {
SYNC_CALL(utime, *path, *path, atime, mtime); SYNC_CALL(utime, *path, *path, atime, mtime);
return Undefined(); return Undefined(node_isolate);
} }
} }
static Handle<Value> FUTimes(const Arguments& args) { static Handle<Value> FUTimes(const Arguments& args) {
HandleScope scope; HandleScope scope(node_isolate);
int len = args.Length(); int len = args.Length();
if (len < 1) return TYPE_ERROR("fd required"); if (len < 1) return TYPE_ERROR("fd required");
@ -911,13 +911,13 @@ static Handle<Value> FUTimes(const Arguments& args) {
ASYNC_CALL(futime, args[3], fd, atime, mtime); ASYNC_CALL(futime, args[3], fd, atime, mtime);
} else { } else {
SYNC_CALL(futime, 0, fd, atime, mtime); SYNC_CALL(futime, 0, fd, atime, mtime);
return Undefined(); return Undefined(node_isolate);
} }
} }
void File::Initialize(Handle<Object> target) { void File::Initialize(Handle<Object> target) {
HandleScope scope; HandleScope scope(node_isolate);
NODE_SET_METHOD(target, "close", Close); NODE_SET_METHOD(target, "close", Close);
NODE_SET_METHOD(target, "open", Open); NODE_SET_METHOD(target, "open", Open);
@ -951,7 +951,7 @@ void File::Initialize(Handle<Object> target) {
} }
void InitFs(Handle<Object> target) { void InitFs(Handle<Object> target) {
HandleScope scope; HandleScope scope(node_isolate);
// Initialize the stats object // Initialize the stats object
Local<FunctionTemplate> stat_templ = FunctionTemplate::New(); Local<FunctionTemplate> stat_templ = FunctionTemplate::New();
stats_constructor_template = Persistent<FunctionTemplate>::New(node_isolate, stats_constructor_template = Persistent<FunctionTemplate>::New(node_isolate,

48
src/node_http_parser.cc

@ -170,7 +170,7 @@ struct StringPtr {
if (str_) if (str_)
return String::New(str_, size_); return String::New(str_, size_);
else else
return String::Empty(); return String::Empty(node_isolate);
} }
@ -270,22 +270,22 @@ public:
// STATUS // STATUS
if (parser_.type == HTTP_RESPONSE) { if (parser_.type == HTTP_RESPONSE) {
message_info->Set(status_code_sym, message_info->Set(status_code_sym,
Integer::New(parser_.status_code)); Integer::New(parser_.status_code, node_isolate));
} }
// VERSION // VERSION
message_info->Set(version_major_sym, message_info->Set(version_major_sym,
Integer::New(parser_.http_major)); Integer::New(parser_.http_major, node_isolate));
message_info->Set(version_minor_sym, message_info->Set(version_minor_sym,
Integer::New(parser_.http_minor)); Integer::New(parser_.http_minor, node_isolate));
message_info->Set(should_keep_alive_sym, message_info->Set(should_keep_alive_sym,
http_should_keep_alive(&parser_) ? True() http_should_keep_alive(&parser_) ? True(node_isolate)
: False()); : False(node_isolate));
message_info->Set(upgrade_sym, message_info->Set(upgrade_sym,
parser_.upgrade ? True() parser_.upgrade ? True(node_isolate)
: False()); : False(node_isolate));
Local<Value> argv[1] = { message_info }; Local<Value> argv[1] = { message_info };
@ -302,7 +302,7 @@ public:
HTTP_DATA_CB(on_body) { HTTP_DATA_CB(on_body) {
HandleScope scope; HandleScope scope(node_isolate);
Local<Value> cb = handle_->Get(on_body_sym); Local<Value> cb = handle_->Get(on_body_sym);
if (!cb->IsFunction()) if (!cb->IsFunction())
@ -310,8 +310,8 @@ public:
Local<Value> argv[3] = { Local<Value> argv[3] = {
*current_buffer, *current_buffer,
Integer::New(at - current_buffer_data), Integer::New(at - current_buffer_data, node_isolate),
Integer::New(length) Integer::New(length, node_isolate)
}; };
Local<Value> r = Local<Function>::Cast(cb)->Call(handle_, 3, argv); Local<Value> r = Local<Function>::Cast(cb)->Call(handle_, 3, argv);
@ -326,7 +326,7 @@ public:
HTTP_CB(on_message_complete) { HTTP_CB(on_message_complete) {
HandleScope scope; HandleScope scope(node_isolate);
if (num_fields_) if (num_fields_)
Flush(); // Flush trailing HTTP headers. Flush(); // Flush trailing HTTP headers.
@ -348,7 +348,7 @@ public:
static Handle<Value> New(const Arguments& args) { static Handle<Value> New(const Arguments& args) {
HandleScope scope; HandleScope scope(node_isolate);
http_parser_type type = http_parser_type type =
static_cast<http_parser_type>(args[0]->Int32Value()); static_cast<http_parser_type>(args[0]->Int32Value());
@ -380,7 +380,7 @@ public:
// var bytesParsed = parser->execute(buffer, off, len); // var bytesParsed = parser->execute(buffer, off, len);
static Handle<Value> Execute(const Arguments& args) { static Handle<Value> Execute(const Arguments& args) {
HandleScope scope; HandleScope scope(node_isolate);
Parser* parser = ObjectWrap::Unwrap<Parser>(args.This()); Parser* parser = ObjectWrap::Unwrap<Parser>(args.This());
@ -434,7 +434,7 @@ public:
// If there was an exception in one of the callbacks // If there was an exception in one of the callbacks
if (parser->got_exception_) return Local<Value>(); if (parser->got_exception_) return Local<Value>();
Local<Integer> nparsed_obj = Integer::New(nparsed); Local<Integer> nparsed_obj = Integer::New(nparsed, node_isolate);
// If there was a parse error in one of the callbacks // If there was a parse error in one of the callbacks
// TODO What if there is an error on EOF? // TODO What if there is an error on EOF?
if (!parser->parser_.upgrade && nparsed != len) { if (!parser->parser_.upgrade && nparsed != len) {
@ -452,7 +452,7 @@ public:
static Handle<Value> Finish(const Arguments& args) { static Handle<Value> Finish(const Arguments& args) {
HandleScope scope; HandleScope scope(node_isolate);
Parser* parser = ObjectWrap::Unwrap<Parser>(args.This()); Parser* parser = ObjectWrap::Unwrap<Parser>(args.This());
@ -468,17 +468,17 @@ public:
Local<Value> e = Exception::Error(String::NewSymbol("Parse Error")); Local<Value> e = Exception::Error(String::NewSymbol("Parse Error"));
Local<Object> obj = e->ToObject(); Local<Object> obj = e->ToObject();
obj->Set(String::NewSymbol("bytesParsed"), Integer::New(0)); obj->Set(String::NewSymbol("bytesParsed"), Integer::New(0, node_isolate));
obj->Set(String::NewSymbol("code"), String::New(http_errno_name(err))); obj->Set(String::NewSymbol("code"), String::New(http_errno_name(err)));
return scope.Close(e); return scope.Close(e);
} }
return Undefined(); return Undefined(node_isolate);
} }
static Handle<Value> Reinitialize(const Arguments& args) { static Handle<Value> Reinitialize(const Arguments& args) {
HandleScope scope; HandleScope scope(node_isolate);
http_parser_type type = http_parser_type type =
static_cast<http_parser_type>(args[0]->Int32Value()); static_cast<http_parser_type>(args[0]->Int32Value());
@ -491,7 +491,7 @@ public:
Parser* parser = ObjectWrap::Unwrap<Parser>(args.This()); Parser* parser = ObjectWrap::Unwrap<Parser>(args.This());
parser->Init(type); parser->Init(type);
return Undefined(); return Undefined(node_isolate);
} }
@ -513,7 +513,7 @@ private:
// spill headers and request path to JS land // spill headers and request path to JS land
void Flush() { void Flush() {
HandleScope scope; HandleScope scope(node_isolate);
Local<Value> cb = handle_->Get(on_headers_sym); Local<Value> cb = handle_->Get(on_headers_sym);
@ -557,7 +557,7 @@ private:
void InitHttpParser(Handle<Object> target) { void InitHttpParser(Handle<Object> target) {
HandleScope scope; HandleScope scope(node_isolate);
Local<FunctionTemplate> t = FunctionTemplate::New(Parser::New); Local<FunctionTemplate> t = FunctionTemplate::New(Parser::New);
t->InstanceTemplate()->SetInternalFieldCount(1); t->InstanceTemplate()->SetInternalFieldCount(1);
@ -565,10 +565,10 @@ void InitHttpParser(Handle<Object> target) {
PropertyAttribute attrib = (PropertyAttribute) (ReadOnly | DontDelete); PropertyAttribute attrib = (PropertyAttribute) (ReadOnly | DontDelete);
t->Set(String::NewSymbol("REQUEST"), t->Set(String::NewSymbol("REQUEST"),
Integer::New(HTTP_REQUEST), Integer::New(HTTP_REQUEST, node_isolate),
attrib); attrib);
t->Set(String::NewSymbol("RESPONSE"), t->Set(String::NewSymbol("RESPONSE"),
Integer::New(HTTP_RESPONSE), Integer::New(HTTP_RESPONSE, node_isolate),
attrib); attrib);
NODE_SET_PROTOTYPE_METHOD(t, "execute", Parser::Execute); NODE_SET_PROTOTYPE_METHOD(t, "execute", Parser::Execute);

2
src/node_javascript.cc

@ -37,7 +37,7 @@ Handle<String> MainSource() {
} }
void DefineJavaScript(v8::Handle<v8::Object> target) { void DefineJavaScript(v8::Handle<v8::Object> target) {
HandleScope scope; HandleScope scope(node_isolate);
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) {

46
src/node_os.cc

@ -42,7 +42,7 @@ namespace node {
using namespace v8; using namespace v8;
static Handle<Value> GetEndianness(const Arguments& args) { static Handle<Value> GetEndianness(const Arguments& args) {
HandleScope scope; HandleScope scope(node_isolate);
int i = 1; int i = 1;
bool big = (*(char *)&i) == 0; bool big = (*(char *)&i) == 0;
Local<String> endianness = String::New(big ? "BE" : "LE"); Local<String> endianness = String::New(big ? "BE" : "LE");
@ -50,7 +50,7 @@ static Handle<Value> GetEndianness(const Arguments& args) {
} }
static Handle<Value> GetHostname(const Arguments& args) { static Handle<Value> GetHostname(const Arguments& args) {
HandleScope scope; HandleScope scope(node_isolate);
char s[255]; char s[255];
int r = gethostname(s, 255); int r = gethostname(s, 255);
@ -66,7 +66,7 @@ static Handle<Value> GetHostname(const Arguments& args) {
} }
static Handle<Value> GetOSType(const Arguments& args) { static Handle<Value> GetOSType(const Arguments& args) {
HandleScope scope; HandleScope scope(node_isolate);
#ifdef __POSIX__ #ifdef __POSIX__
char type[256]; char type[256];
@ -83,7 +83,7 @@ static Handle<Value> GetOSType(const Arguments& args) {
} }
static Handle<Value> GetOSRelease(const Arguments& args) { static Handle<Value> GetOSRelease(const Arguments& args) {
HandleScope scope; HandleScope scope(node_isolate);
char release[256]; char release[256];
#ifdef __POSIX__ #ifdef __POSIX__
@ -98,7 +98,7 @@ static Handle<Value> GetOSRelease(const Arguments& args) {
info.dwOSVersionInfoSize = sizeof(info); info.dwOSVersionInfoSize = sizeof(info);
if (GetVersionEx(&info) == 0) { if (GetVersionEx(&info) == 0) {
return Undefined(); return Undefined(node_isolate);
} }
sprintf(release, "%d.%d.%d", static_cast<int>(info.dwMajorVersion), sprintf(release, "%d.%d.%d", static_cast<int>(info.dwMajorVersion),
@ -109,14 +109,14 @@ static Handle<Value> GetOSRelease(const Arguments& args) {
} }
static Handle<Value> GetCPUInfo(const Arguments& args) { static Handle<Value> GetCPUInfo(const Arguments& args) {
HandleScope scope; HandleScope scope(node_isolate);
uv_cpu_info_t* cpu_infos; uv_cpu_info_t* cpu_infos;
int count, i; int count, i;
uv_err_t err = uv_cpu_info(&cpu_infos, &count); uv_err_t err = uv_cpu_info(&cpu_infos, &count);
if (err.code != UV_OK) { if (err.code != UV_OK) {
return Undefined(); return Undefined(node_isolate);
} }
Local<Array> cpus = Array::New(); Local<Array> cpus = Array::New();
@ -124,20 +124,20 @@ static Handle<Value> GetCPUInfo(const Arguments& args) {
for (i = 0; i < count; i++) { for (i = 0; i < count; i++) {
Local<Object> times_info = Object::New(); Local<Object> times_info = Object::New();
times_info->Set(String::New("user"), times_info->Set(String::New("user"),
Integer::New(cpu_infos[i].cpu_times.user)); Integer::New(cpu_infos[i].cpu_times.user, node_isolate));
times_info->Set(String::New("nice"), times_info->Set(String::New("nice"),
Integer::New(cpu_infos[i].cpu_times.nice)); Integer::New(cpu_infos[i].cpu_times.nice, node_isolate));
times_info->Set(String::New("sys"), times_info->Set(String::New("sys"),
Integer::New(cpu_infos[i].cpu_times.sys)); Integer::New(cpu_infos[i].cpu_times.sys, node_isolate));
times_info->Set(String::New("idle"), times_info->Set(String::New("idle"),
Integer::New(cpu_infos[i].cpu_times.idle)); Integer::New(cpu_infos[i].cpu_times.idle, node_isolate));
times_info->Set(String::New("irq"), times_info->Set(String::New("irq"),
Integer::New(cpu_infos[i].cpu_times.irq)); Integer::New(cpu_infos[i].cpu_times.irq, node_isolate));
Local<Object> cpu_info = Object::New(); Local<Object> cpu_info = Object::New();
cpu_info->Set(String::New("model"), String::New(cpu_infos[i].model)); cpu_info->Set(String::New("model"), String::New(cpu_infos[i].model));
cpu_info->Set(String::New("speed"), cpu_info->Set(String::New("speed"),
Integer::New(cpu_infos[i].speed)); Integer::New(cpu_infos[i].speed, node_isolate));
cpu_info->Set(String::New("times"), times_info); cpu_info->Set(String::New("times"), times_info);
(*cpus)->Set(i,cpu_info); (*cpus)->Set(i,cpu_info);
} }
@ -148,42 +148,42 @@ static Handle<Value> GetCPUInfo(const Arguments& args) {
} }
static Handle<Value> GetFreeMemory(const Arguments& args) { static Handle<Value> GetFreeMemory(const Arguments& args) {
HandleScope scope; HandleScope scope(node_isolate);
double amount = uv_get_free_memory(); double amount = uv_get_free_memory();
if (amount < 0) { if (amount < 0) {
return Undefined(); return Undefined(node_isolate);
} }
return scope.Close(Number::New(amount)); return scope.Close(Number::New(amount));
} }
static Handle<Value> GetTotalMemory(const Arguments& args) { static Handle<Value> GetTotalMemory(const Arguments& args) {
HandleScope scope; HandleScope scope(node_isolate);
double amount = uv_get_total_memory(); double amount = uv_get_total_memory();
if (amount < 0) { if (amount < 0) {
return Undefined(); return Undefined(node_isolate);
} }
return scope.Close(Number::New(amount)); return scope.Close(Number::New(amount));
} }
static Handle<Value> GetUptime(const Arguments& args) { static Handle<Value> GetUptime(const Arguments& args) {
HandleScope scope; HandleScope scope(node_isolate);
double uptime; double uptime;
uv_err_t err = uv_uptime(&uptime); uv_err_t err = uv_uptime(&uptime);
if (err.code != UV_OK) { if (err.code != UV_OK) {
return Undefined(); return Undefined(node_isolate);
} }
return scope.Close(Number::New(uptime)); return scope.Close(Number::New(uptime));
} }
static Handle<Value> GetLoadAvg(const Arguments& args) { static Handle<Value> GetLoadAvg(const Arguments& args) {
HandleScope scope; HandleScope scope(node_isolate);
double loadavg[3]; double loadavg[3];
uv_loadavg(loadavg); uv_loadavg(loadavg);
@ -197,7 +197,7 @@ static Handle<Value> GetLoadAvg(const Arguments& args) {
static Handle<Value> GetInterfaceAddresses(const Arguments& args) { static Handle<Value> GetInterfaceAddresses(const Arguments& args) {
HandleScope scope; HandleScope scope(node_isolate);
uv_interface_address_t* interfaces; uv_interface_address_t* interfaces;
int count, i; int count, i;
char ip[INET6_ADDRSTRLEN]; char ip[INET6_ADDRSTRLEN];
@ -238,7 +238,7 @@ static Handle<Value> GetInterfaceAddresses(const Arguments& args) {
const bool internal = interfaces[i].is_internal; const bool internal = interfaces[i].is_internal;
o->Set(String::New("internal"), o->Set(String::New("internal"),
internal ? True() : False()); internal ? True(node_isolate) : False(node_isolate));
ifarr->Set(ifarr->Length(), o); ifarr->Set(ifarr->Length(), o);
} }
@ -250,7 +250,7 @@ static Handle<Value> GetInterfaceAddresses(const Arguments& args) {
void OS::Initialize(v8::Handle<v8::Object> target) { void OS::Initialize(v8::Handle<v8::Object> target) {
HandleScope scope; HandleScope scope(node_isolate);
NODE_SET_METHOD(target, "getEndianness", GetEndianness); NODE_SET_METHOD(target, "getEndianness", GetEndianness);
NODE_SET_METHOD(target, "getHostname", GetHostname); NODE_SET_METHOD(target, "getHostname", GetHostname);

20
src/node_script.cc

@ -103,7 +103,7 @@ Persistent<Function> cloneObjectMethod;
void CloneObject(Handle<Object> recv, void CloneObject(Handle<Object> recv,
Handle<Value> source, Handle<Value> target) { Handle<Value> source, Handle<Value> target) {
HandleScope scope; HandleScope scope(node_isolate);
Handle<Value> args[] = {source, target}; Handle<Value> args[] = {source, target};
@ -133,7 +133,7 @@ void CloneObject(Handle<Object> recv,
void WrappedContext::Initialize(Handle<Object> target) { void WrappedContext::Initialize(Handle<Object> target) {
HandleScope scope; HandleScope scope(node_isolate);
Local<FunctionTemplate> t = FunctionTemplate::New(WrappedContext::New); Local<FunctionTemplate> t = FunctionTemplate::New(WrappedContext::New);
constructor_template = Persistent<FunctionTemplate>::New(node_isolate, t); constructor_template = Persistent<FunctionTemplate>::New(node_isolate, t);
@ -151,7 +151,7 @@ bool WrappedContext::InstanceOf(Handle<Value> value) {
Handle<Value> WrappedContext::New(const Arguments& args) { Handle<Value> WrappedContext::New(const Arguments& args) {
HandleScope scope; HandleScope scope(node_isolate);
WrappedContext *t = new WrappedContext(); WrappedContext *t = new WrappedContext();
t->Wrap(args.This()); t->Wrap(args.This());
@ -185,7 +185,7 @@ Persistent<FunctionTemplate> WrappedScript::constructor_template;
void WrappedScript::Initialize(Handle<Object> target) { void WrappedScript::Initialize(Handle<Object> target) {
HandleScope scope; HandleScope scope(node_isolate);
Local<FunctionTemplate> t = FunctionTemplate::New(WrappedScript::New); Local<FunctionTemplate> t = FunctionTemplate::New(WrappedScript::New);
constructor_template = Persistent<FunctionTemplate>::New(node_isolate, t); constructor_template = Persistent<FunctionTemplate>::New(node_isolate, t);
@ -237,7 +237,7 @@ Handle<Value> WrappedScript::New(const Arguments& args) {
return FromConstructorTemplate(constructor_template, args); return FromConstructorTemplate(constructor_template, args);
} }
HandleScope scope; HandleScope scope(node_isolate);
WrappedScript *t = new WrappedScript(); WrappedScript *t = new WrappedScript();
t->Wrap(args.Holder()); t->Wrap(args.Holder());
@ -253,7 +253,7 @@ WrappedScript::~WrappedScript() {
Handle<Value> WrappedScript::CreateContext(const Arguments& args) { Handle<Value> WrappedScript::CreateContext(const Arguments& args) {
HandleScope scope; HandleScope scope(node_isolate);
Local<Object> context = WrappedContext::NewInstance(); Local<Object> context = WrappedContext::NewInstance();
@ -313,7 +313,7 @@ template <WrappedScript::EvalInputFlags input_flag,
WrappedScript::EvalContextFlags context_flag, WrappedScript::EvalContextFlags context_flag,
WrappedScript::EvalOutputFlags output_flag> WrappedScript::EvalOutputFlags output_flag>
Handle<Value> WrappedScript::EvalMachine(const Arguments& args) { Handle<Value> WrappedScript::EvalMachine(const Arguments& args) {
HandleScope scope; HandleScope scope(node_isolate);
if (input_flag == compileCode && args.Length() < 1) { if (input_flag == compileCode && args.Length() < 1) {
return ThrowException(Exception::TypeError( return ThrowException(Exception::TypeError(
@ -364,7 +364,7 @@ Handle<Value> WrappedScript::EvalMachine(const Arguments& args) {
// to a local handle, and then dispose the persistent handle. This ensures // to a local handle, and then dispose the persistent handle. This ensures
// that when this function exits the context will be disposed. // that when this function exits the context will be disposed.
Persistent<Context> tmp = Context::New(); Persistent<Context> tmp = Context::New();
context = Local<Context>::New(tmp); context = Local<Context>::New(node_isolate, tmp);
tmp.Dispose(node_isolate); tmp.Dispose(node_isolate);
} else if (context_flag == userContext) { } else if (context_flag == userContext) {
@ -427,7 +427,7 @@ Handle<Value> WrappedScript::EvalMachine(const Arguments& args) {
return ThrowException(Exception::Error( return ThrowException(Exception::Error(
String::New("Must be called as a method of Script."))); String::New("Must be called as a method of Script.")));
} }
n_script->script_ = Persistent<Script>::New(script); n_script->script_ = Persistent<Script>::New(node_isolate, script);
result = args.This(); result = args.This();
} }
@ -441,7 +441,7 @@ Handle<Value> WrappedScript::EvalMachine(const Arguments& args) {
void InitEvals(Handle<Object> target) { void InitEvals(Handle<Object> target) {
HandleScope scope; HandleScope scope(node_isolate);
WrappedContext::Initialize(target); WrappedContext::Initialize(target);
WrappedScript::Initialize(target); WrappedScript::Initialize(target);

16
src/node_stat_watcher.cc

@ -35,7 +35,7 @@ static Persistent<String> onstop_sym;
void StatWatcher::Initialize(Handle<Object> target) { void StatWatcher::Initialize(Handle<Object> target) {
HandleScope scope; HandleScope scope(node_isolate);
Local<FunctionTemplate> t = FunctionTemplate::New(StatWatcher::New); Local<FunctionTemplate> t = FunctionTemplate::New(StatWatcher::New);
constructor_template = Persistent<FunctionTemplate>::New(node_isolate, t); constructor_template = Persistent<FunctionTemplate>::New(node_isolate, t);
@ -75,11 +75,11 @@ void StatWatcher::Callback(uv_fs_poll_t* handle,
const uv_statbuf_t* curr) { const uv_statbuf_t* curr) {
StatWatcher* wrap = static_cast<StatWatcher*>(handle->data); StatWatcher* wrap = static_cast<StatWatcher*>(handle->data);
assert(wrap->watcher_ == handle); assert(wrap->watcher_ == handle);
HandleScope scope; HandleScope scope(node_isolate);
Local<Value> argv[3]; Local<Value> argv[3];
argv[0] = BuildStatsObject(curr); argv[0] = BuildStatsObject(curr);
argv[1] = BuildStatsObject(prev); argv[1] = BuildStatsObject(prev);
argv[2] = Integer::New(status); argv[2] = Integer::New(status, node_isolate);
if (status == -1) { if (status == -1) {
SetErrno(uv_last_error(wrap->watcher_->loop)); SetErrno(uv_last_error(wrap->watcher_->loop));
} }
@ -92,7 +92,7 @@ void StatWatcher::Callback(uv_fs_poll_t* handle,
Handle<Value> StatWatcher::New(const Arguments& args) { Handle<Value> StatWatcher::New(const Arguments& args) {
assert(args.IsConstructCall()); assert(args.IsConstructCall());
HandleScope scope; HandleScope scope(node_isolate);
StatWatcher* s = new StatWatcher(); StatWatcher* s = new StatWatcher();
s->Wrap(args.Holder()); s->Wrap(args.Holder());
return args.This(); return args.This();
@ -101,7 +101,7 @@ Handle<Value> StatWatcher::New(const Arguments& args) {
Handle<Value> StatWatcher::Start(const Arguments& args) { Handle<Value> StatWatcher::Start(const Arguments& args) {
assert(args.Length() == 3); assert(args.Length() == 3);
HandleScope scope; HandleScope scope(node_isolate);
StatWatcher* wrap = ObjectWrap::Unwrap<StatWatcher>(args.Holder()); StatWatcher* wrap = ObjectWrap::Unwrap<StatWatcher>(args.Holder());
String::Utf8Value path(args[0]); String::Utf8Value path(args[0]);
@ -112,19 +112,19 @@ Handle<Value> StatWatcher::Start(const Arguments& args) {
uv_fs_poll_start(wrap->watcher_, Callback, *path, interval); uv_fs_poll_start(wrap->watcher_, Callback, *path, interval);
wrap->Ref(); wrap->Ref();
return Undefined(); return Undefined(node_isolate);
} }
Handle<Value> StatWatcher::Stop(const Arguments& args) { Handle<Value> StatWatcher::Stop(const Arguments& args) {
HandleScope scope; HandleScope scope(node_isolate);
StatWatcher* wrap = ObjectWrap::Unwrap<StatWatcher>(args.Holder()); StatWatcher* wrap = ObjectWrap::Unwrap<StatWatcher>(args.Holder());
if (onstop_sym.IsEmpty()) { if (onstop_sym.IsEmpty()) {
onstop_sym = NODE_PSYMBOL("onstop"); onstop_sym = NODE_PSYMBOL("onstop");
} }
MakeCallback(wrap->handle_, onstop_sym, 0, NULL); MakeCallback(wrap->handle_, onstop_sym, 0, NULL);
wrap->Stop(); wrap->Stop();
return Undefined(); return Undefined(node_isolate);
} }

4
src/node_string.cc

@ -25,10 +25,12 @@ namespace node {
using namespace v8; using namespace v8;
extern Isolate* node_isolate;
Handle<String> ImmutableAsciiSource::CreateFromLiteral( Handle<String> ImmutableAsciiSource::CreateFromLiteral(
const char *string_literal, const char *string_literal,
size_t length) { size_t length) {
HandleScope scope; HandleScope scope(node_isolate);
Local<String> ret = String::NewExternal(new ImmutableAsciiSource( Local<String> ret = String::NewExternal(new ImmutableAsciiSource(
string_literal, string_literal,

29
src/node_zlib.cc

@ -105,16 +105,16 @@ class ZCtx : public ObjectWrap {
static Handle<Value> Close(const Arguments& args) { static Handle<Value> Close(const Arguments& args) {
HandleScope scope; HandleScope scope(node_isolate);
ZCtx *ctx = ObjectWrap::Unwrap<ZCtx>(args.This()); ZCtx *ctx = ObjectWrap::Unwrap<ZCtx>(args.This());
ctx->Close(); ctx->Close();
return scope.Close(Undefined()); return scope.Close(Undefined(node_isolate));
} }
// write(flush, in, in_off, in_len, out, out_off, out_len) // write(flush, in, in_off, in_len, out, out_off, out_len)
static Handle<Value> Write(const Arguments& args) { static Handle<Value> Write(const Arguments& args) {
HandleScope scope; HandleScope scope(node_isolate);
assert(args.Length() == 7); assert(args.Length() == 7);
ZCtx *ctx = ObjectWrap::Unwrap<ZCtx>(args.This()); ZCtx *ctx = ObjectWrap::Unwrap<ZCtx>(args.This());
@ -244,7 +244,7 @@ class ZCtx : public ObjectWrap {
static void After(uv_work_t* work_req, int status) { static void After(uv_work_t* work_req, int status) {
assert(status == 0); assert(status == 0);
HandleScope scope; HandleScope scope(node_isolate);
ZCtx *ctx = container_of(work_req, ZCtx, work_req_); ZCtx *ctx = container_of(work_req, ZCtx, work_req_);
// Acceptable error states depend on the type of zlib stream. // Acceptable error states depend on the type of zlib stream.
@ -267,8 +267,8 @@ class ZCtx : public ObjectWrap {
return; return;
} }
Local<Integer> avail_out = Integer::New(ctx->strm_.avail_out); Local<Integer> avail_out = Integer::New(ctx->strm_.avail_out, node_isolate);
Local<Integer> avail_in = Integer::New(ctx->strm_.avail_in); Local<Integer> avail_in = Integer::New(ctx->strm_.avail_in, node_isolate);
ctx->write_in_progress_ = false; ctx->write_in_progress_ = false;
@ -291,9 +291,10 @@ class ZCtx : public ObjectWrap {
assert(ctx->handle_->Get(onerror_sym)->IsFunction() && assert(ctx->handle_->Get(onerror_sym)->IsFunction() &&
"Invalid error handler"); "Invalid error handler");
HandleScope scope; HandleScope scope(node_isolate);
Local<Value> args[2] = { String::New(msg), Local<Value> args[2] = { String::New(msg),
Local<Value>::New(Number::New(ctx->err_)) }; Local<Value>::New(node_isolate,
Number::New(ctx->err_)) };
MakeCallback(ctx->handle_, onerror_sym, ARRAY_SIZE(args), args); MakeCallback(ctx->handle_, onerror_sym, ARRAY_SIZE(args), args);
// no hope of rescue. // no hope of rescue.
@ -302,7 +303,7 @@ class ZCtx : public ObjectWrap {
} }
static Handle<Value> New(const Arguments& args) { static Handle<Value> New(const Arguments& args) {
HandleScope scope; HandleScope scope(node_isolate);
if (args.Length() < 1 || !args[0]->IsInt32()) { if (args.Length() < 1 || !args[0]->IsInt32()) {
return ThrowException(Exception::TypeError(String::New("Bad argument"))); return ThrowException(Exception::TypeError(String::New("Bad argument")));
} }
@ -319,7 +320,7 @@ class ZCtx : public ObjectWrap {
// just pull the ints out of the args and call the other Init // just pull the ints out of the args and call the other Init
static Handle<Value> Init(const Arguments& args) { static Handle<Value> Init(const Arguments& args) {
HandleScope scope; HandleScope scope(node_isolate);
assert((args.Length() == 4 || args.Length() == 5) && assert((args.Length() == 4 || args.Length() == 5) &&
"init(windowBits, level, memLevel, strategy, [dictionary])"); "init(windowBits, level, memLevel, strategy, [dictionary])");
@ -356,17 +357,17 @@ class ZCtx : public ObjectWrap {
Init(ctx, level, windowBits, memLevel, strategy, Init(ctx, level, windowBits, memLevel, strategy,
dictionary, dictionary_len); dictionary, dictionary_len);
SetDictionary(ctx); SetDictionary(ctx);
return Undefined(); return Undefined(node_isolate);
} }
static Handle<Value> Reset(const Arguments &args) { static Handle<Value> Reset(const Arguments &args) {
HandleScope scope; HandleScope scope(node_isolate);
ZCtx *ctx = ObjectWrap::Unwrap<ZCtx>(args.This()); ZCtx *ctx = ObjectWrap::Unwrap<ZCtx>(args.This());
Reset(ctx); Reset(ctx);
SetDictionary(ctx); SetDictionary(ctx);
return Undefined(); return Undefined(node_isolate);
} }
static void Init(ZCtx *ctx, int level, int windowBits, int memLevel, static void Init(ZCtx *ctx, int level, int windowBits, int memLevel,
@ -504,7 +505,7 @@ class ZCtx : public ObjectWrap {
void InitZlib(Handle<Object> target) { void InitZlib(Handle<Object> target) {
HandleScope scope; HandleScope scope(node_isolate);
Local<FunctionTemplate> z = FunctionTemplate::New(ZCtx::New); Local<FunctionTemplate> z = FunctionTemplate::New(ZCtx::New);

38
src/pipe_wrap.cc

@ -60,7 +60,7 @@ uv_pipe_t* PipeWrap::UVHandle() {
Local<Object> PipeWrap::Instantiate() { Local<Object> PipeWrap::Instantiate() {
HandleScope scope; HandleScope scope(node_isolate);
assert(!pipeConstructor.IsEmpty()); assert(!pipeConstructor.IsEmpty());
return scope.Close(pipeConstructor->NewInstance()); return scope.Close(pipeConstructor->NewInstance());
} }
@ -76,7 +76,7 @@ PipeWrap* PipeWrap::Unwrap(Local<Object> obj) {
void PipeWrap::Initialize(Handle<Object> target) { void PipeWrap::Initialize(Handle<Object> target) {
StreamWrap::Initialize(target); StreamWrap::Initialize(target);
HandleScope scope; HandleScope scope(node_isolate);
Local<FunctionTemplate> t = FunctionTemplate::New(New); Local<FunctionTemplate> t = FunctionTemplate::New(New);
t->SetClassName(String::NewSymbol("Pipe")); t->SetClassName(String::NewSymbol("Pipe"));
@ -126,7 +126,7 @@ Handle<Value> PipeWrap::New(const Arguments& args) {
// normal function. // normal function.
assert(args.IsConstructCall()); assert(args.IsConstructCall());
HandleScope scope; HandleScope scope(node_isolate);
PipeWrap* wrap = new PipeWrap(args.This(), args[0]->IsTrue()); PipeWrap* wrap = new PipeWrap(args.This(), args[0]->IsTrue());
assert(wrap); assert(wrap);
@ -145,7 +145,7 @@ PipeWrap::PipeWrap(Handle<Object> object, bool ipc)
Handle<Value> PipeWrap::Bind(const Arguments& args) { Handle<Value> PipeWrap::Bind(const Arguments& args) {
HandleScope scope; HandleScope scope(node_isolate);
UNWRAP(PipeWrap) UNWRAP(PipeWrap)
@ -156,13 +156,13 @@ Handle<Value> PipeWrap::Bind(const Arguments& args) {
// Error starting the pipe. // Error starting the pipe.
if (r) SetErrno(uv_last_error(uv_default_loop())); if (r) SetErrno(uv_last_error(uv_default_loop()));
return scope.Close(Integer::New(r)); return scope.Close(Integer::New(r, node_isolate));
} }
#ifdef _WIN32 #ifdef _WIN32
Handle<Value> PipeWrap::SetPendingInstances(const Arguments& args) { Handle<Value> PipeWrap::SetPendingInstances(const Arguments& args) {
HandleScope scope; HandleScope scope(node_isolate);
UNWRAP(PipeWrap) UNWRAP(PipeWrap)
@ -170,13 +170,13 @@ Handle<Value> PipeWrap::SetPendingInstances(const Arguments& args) {
uv_pipe_pending_instances(&wrap->handle_, instances); uv_pipe_pending_instances(&wrap->handle_, instances);
return v8::Null(); return v8::Null(node_isolate);
} }
#endif #endif
Handle<Value> PipeWrap::Listen(const Arguments& args) { Handle<Value> PipeWrap::Listen(const Arguments& args) {
HandleScope scope; HandleScope scope(node_isolate);
UNWRAP(PipeWrap) UNWRAP(PipeWrap)
@ -187,13 +187,13 @@ Handle<Value> PipeWrap::Listen(const Arguments& args) {
// Error starting the pipe. // Error starting the pipe.
if (r) SetErrno(uv_last_error(uv_default_loop())); if (r) SetErrno(uv_last_error(uv_default_loop()));
return scope.Close(Integer::New(r)); return scope.Close(Integer::New(r, node_isolate));
} }
// TODO maybe share with TCPWrap? // TODO maybe share with TCPWrap?
void PipeWrap::OnConnection(uv_stream_t* handle, int status) { void PipeWrap::OnConnection(uv_stream_t* handle, int status) {
HandleScope scope; HandleScope scope(node_isolate);
PipeWrap* wrap = static_cast<PipeWrap*>(handle->data); PipeWrap* wrap = static_cast<PipeWrap*>(handle->data);
assert(&wrap->handle_ == (uv_pipe_t*)handle); assert(&wrap->handle_ == (uv_pipe_t*)handle);
@ -231,7 +231,7 @@ void PipeWrap::AfterConnect(uv_connect_t* req, int status) {
ConnectWrap* req_wrap = (ConnectWrap*) req->data; ConnectWrap* req_wrap = (ConnectWrap*) req->data;
PipeWrap* wrap = (PipeWrap*) req->handle->data; PipeWrap* wrap = (PipeWrap*) req->handle->data;
HandleScope scope; HandleScope scope(node_isolate);
// The wrap and request objects should still be there. // The wrap and request objects should still be there.
assert(req_wrap->object_.IsEmpty() == false); assert(req_wrap->object_.IsEmpty() == false);
@ -248,11 +248,11 @@ void PipeWrap::AfterConnect(uv_connect_t* req, int status) {
} }
Local<Value> argv[5] = { Local<Value> argv[5] = {
Integer::New(status), Integer::New(status, node_isolate),
Local<Value>::New(wrap->object_), Local<Value>::New(node_isolate, wrap->object_),
Local<Value>::New(req_wrap->object_), Local<Value>::New(node_isolate, req_wrap->object_),
Local<Value>::New(Boolean::New(readable)), Local<Value>::New(node_isolate, Boolean::New(readable)),
Local<Value>::New(Boolean::New(writable)) Local<Value>::New(node_isolate, Boolean::New(writable))
}; };
if (oncomplete_sym.IsEmpty()) { if (oncomplete_sym.IsEmpty()) {
@ -265,7 +265,7 @@ void PipeWrap::AfterConnect(uv_connect_t* req, int status) {
Handle<Value> PipeWrap::Open(const Arguments& args) { Handle<Value> PipeWrap::Open(const Arguments& args) {
HandleScope scope; HandleScope scope(node_isolate);
UNWRAP(PipeWrap) UNWRAP(PipeWrap)
@ -273,12 +273,12 @@ Handle<Value> PipeWrap::Open(const Arguments& args) {
uv_pipe_open(&wrap->handle_, fd); uv_pipe_open(&wrap->handle_, fd);
return scope.Close(v8::Null()); return scope.Close(v8::Null(node_isolate));
} }
Handle<Value> PipeWrap::Connect(const Arguments& args) { Handle<Value> PipeWrap::Connect(const Arguments& args) {
HandleScope scope; HandleScope scope(node_isolate);
UNWRAP(PipeWrap) UNWRAP(PipeWrap)

18
src/process_wrap.cc

@ -54,7 +54,7 @@ static Persistent<String> onexit_sym;
class ProcessWrap : public HandleWrap { class ProcessWrap : public HandleWrap {
public: public:
static void Initialize(Handle<Object> target) { static void Initialize(Handle<Object> target) {
HandleScope scope; HandleScope scope(node_isolate);
HandleWrap::Initialize(target); HandleWrap::Initialize(target);
@ -80,7 +80,7 @@ class ProcessWrap : public HandleWrap {
// normal function. // normal function.
assert(args.IsConstructCall()); assert(args.IsConstructCall());
HandleScope scope; HandleScope scope(node_isolate);
ProcessWrap *wrap = new ProcessWrap(args.This()); ProcessWrap *wrap = new ProcessWrap(args.This());
assert(wrap); assert(wrap);
@ -142,7 +142,7 @@ class ProcessWrap : public HandleWrap {
} }
static Handle<Value> Spawn(const Arguments& args) { static Handle<Value> Spawn(const Arguments& args) {
HandleScope scope; HandleScope scope(node_isolate);
UNWRAP(ProcessWrap) UNWRAP(ProcessWrap)
@ -251,7 +251,7 @@ class ProcessWrap : public HandleWrap {
wrap->SetHandle((uv_handle_t*)&wrap->process_); wrap->SetHandle((uv_handle_t*)&wrap->process_);
assert(wrap->process_.data == wrap); assert(wrap->process_.data == wrap);
wrap->object_->Set(String::New("pid"), wrap->object_->Set(String::New("pid"),
Integer::New(wrap->process_.pid)); Integer::New(wrap->process_.pid, node_isolate));
} }
if (options.args) { if (options.args) {
@ -266,11 +266,11 @@ class ProcessWrap : public HandleWrap {
delete[] options.stdio; delete[] options.stdio;
return scope.Close(Integer::New(r)); return scope.Close(Integer::New(r, node_isolate));
} }
static Handle<Value> Kill(const Arguments& args) { static Handle<Value> Kill(const Arguments& args) {
HandleScope scope; HandleScope scope(node_isolate);
UNWRAP(ProcessWrap) UNWRAP(ProcessWrap)
@ -280,18 +280,18 @@ class ProcessWrap : public HandleWrap {
if (r) SetErrno(uv_last_error(uv_default_loop())); if (r) SetErrno(uv_last_error(uv_default_loop()));
return scope.Close(Integer::New(r)); return scope.Close(Integer::New(r, node_isolate));
} }
static void OnExit(uv_process_t* handle, int exit_status, int term_signal) { static void OnExit(uv_process_t* handle, int exit_status, int term_signal) {
HandleScope scope; HandleScope scope(node_isolate);
ProcessWrap* wrap = static_cast<ProcessWrap*>(handle->data); ProcessWrap* wrap = static_cast<ProcessWrap*>(handle->data);
assert(wrap); assert(wrap);
assert(&wrap->process_ == handle); assert(&wrap->process_ == handle);
Local<Value> argv[2] = { Local<Value> argv[2] = {
Integer::New(exit_status), Integer::New(exit_status, node_isolate),
String::New(signo_string(term_signal)) String::New(signo_string(term_signal))
}; };

16
src/signal_wrap.cc

@ -45,7 +45,7 @@ static Persistent<String> onsignal_sym;
class SignalWrap : public HandleWrap { class SignalWrap : public HandleWrap {
public: public:
static void Initialize(Handle<Object> target) { static void Initialize(Handle<Object> target) {
HandleScope scope; HandleScope scope(node_isolate);
HandleWrap::Initialize(target); HandleWrap::Initialize(target);
@ -71,7 +71,7 @@ class SignalWrap : public HandleWrap {
// normal function. // normal function.
assert(args.IsConstructCall()); assert(args.IsConstructCall());
HandleScope scope; HandleScope scope(node_isolate);
new SignalWrap(args.This()); new SignalWrap(args.This());
return scope.Close(args.This()); return scope.Close(args.This());
@ -87,7 +87,7 @@ class SignalWrap : public HandleWrap {
} }
static Handle<Value> Start(const Arguments& args) { static Handle<Value> Start(const Arguments& args) {
HandleScope scope; HandleScope scope(node_isolate);
UNWRAP(SignalWrap) UNWRAP(SignalWrap)
@ -97,11 +97,11 @@ class SignalWrap : public HandleWrap {
if (r) SetErrno(uv_last_error(uv_default_loop())); if (r) SetErrno(uv_last_error(uv_default_loop()));
return scope.Close(Integer::New(r)); return scope.Close(Integer::New(r, node_isolate));
} }
static Handle<Value> Stop(const Arguments& args) { static Handle<Value> Stop(const Arguments& args) {
HandleScope scope; HandleScope scope(node_isolate);
UNWRAP(SignalWrap) UNWRAP(SignalWrap)
@ -109,16 +109,16 @@ class SignalWrap : public HandleWrap {
if (r) SetErrno(uv_last_error(uv_default_loop())); if (r) SetErrno(uv_last_error(uv_default_loop()));
return scope.Close(Integer::New(r)); return scope.Close(Integer::New(r, node_isolate));
} }
static void OnSignal(uv_signal_t* handle, int signum) { static void OnSignal(uv_signal_t* handle, int signum) {
HandleScope scope; HandleScope scope(node_isolate);
SignalWrap* wrap = container_of(handle, SignalWrap, handle_); SignalWrap* wrap = container_of(handle, SignalWrap, handle_);
assert(wrap); assert(wrap);
Local<Value> argv[1] = { Integer::New(signum) }; Local<Value> argv[1] = { Integer::New(signum, node_isolate) };
MakeCallback(wrap->object_, onsignal_sym, ARRAY_SIZE(argv), argv); MakeCallback(wrap->object_, onsignal_sym, ARRAY_SIZE(argv), argv);
} }

12
src/slab_allocator.cc

@ -59,7 +59,7 @@ SlabAllocator::~SlabAllocator() {
void SlabAllocator::Initialize() { void SlabAllocator::Initialize() {
HandleScope scope; HandleScope scope(node_isolate);
char sym[256]; char sym[256];
snprintf(sym, sizeof(sym), "slab_%p", this); // namespace object key snprintf(sym, sizeof(sym), "slab_%p", this); // namespace object key
offset_ = 0; offset_ = 0;
@ -70,8 +70,8 @@ void SlabAllocator::Initialize() {
static Local<Object> NewSlab(unsigned int size) { static Local<Object> NewSlab(unsigned int size) {
HandleScope scope; HandleScope scope(node_isolate);
Local<Value> arg = Integer::NewFromUnsigned(ROUND_UP(size, 16)); Local<Value> arg = Integer::NewFromUnsigned(ROUND_UP(size, 16), node_isolate);
Local<Object> buf = Buffer::constructor_template Local<Object> buf = Buffer::constructor_template
->GetFunction() ->GetFunction()
->NewInstance(1, &arg); ->NewInstance(1, &arg);
@ -80,7 +80,7 @@ static Local<Object> NewSlab(unsigned int size) {
char* SlabAllocator::Allocate(Handle<Object> obj, unsigned int size) { char* SlabAllocator::Allocate(Handle<Object> obj, unsigned int size) {
HandleScope scope; HandleScope scope(node_isolate);
assert(!obj.IsEmpty()); assert(!obj.IsEmpty());
@ -112,9 +112,9 @@ char* SlabAllocator::Allocate(Handle<Object> obj, unsigned int size) {
Local<Object> SlabAllocator::Shrink(Handle<Object> obj, Local<Object> SlabAllocator::Shrink(Handle<Object> obj,
char* ptr, char* ptr,
unsigned int size) { unsigned int size) {
HandleScope scope; HandleScope scope(node_isolate);
Local<Value> slab_v = obj->GetHiddenValue(slab_sym_); Local<Value> slab_v = obj->GetHiddenValue(slab_sym_);
obj->SetHiddenValue(slab_sym_, Null()); obj->SetHiddenValue(slab_sym_, Null(node_isolate));
assert(!slab_v.IsEmpty()); assert(!slab_v.IsEmpty());
assert(slab_v->IsObject()); assert(slab_v->IsObject());
Local<Object> slab = slab_v->ToObject(); Local<Object> slab = slab_v->ToObject();

60
src/stream_wrap.cc

@ -96,7 +96,7 @@ void StreamWrap::Initialize(Handle<Object> target) {
slab_allocator = new SlabAllocator(SLAB_SIZE); slab_allocator = new SlabAllocator(SLAB_SIZE);
AtExit(DeleteSlabAllocator, NULL); AtExit(DeleteSlabAllocator, NULL);
HandleScope scope; HandleScope scope(node_isolate);
HandleWrap::Initialize(target); HandleWrap::Initialize(target);
@ -119,13 +119,13 @@ StreamWrap::StreamWrap(Handle<Object> object, uv_stream_t* stream)
Handle<Value> StreamWrap::GetFD(Local<String>, const AccessorInfo& args) { Handle<Value> StreamWrap::GetFD(Local<String>, const AccessorInfo& args) {
#if defined(_WIN32) #if defined(_WIN32)
return v8::Null(); return v8::Null(node_isolate);
#else #else
HandleScope scope; HandleScope scope(node_isolate);
UNWRAP_NO_ABORT(StreamWrap) UNWRAP_NO_ABORT(StreamWrap)
int fd = -1; int fd = -1;
if (wrap != NULL && wrap->stream_ != NULL) fd = wrap->stream_->io_watcher.fd; if (wrap != NULL && wrap->stream_ != NULL) fd = wrap->stream_->io_watcher.fd;
return scope.Close(Integer::New(fd)); return scope.Close(Integer::New(fd, node_isolate));
#endif #endif
} }
@ -138,14 +138,14 @@ void StreamWrap::SetHandle(uv_handle_t* h) {
void StreamWrap::UpdateWriteQueueSize() { void StreamWrap::UpdateWriteQueueSize() {
HandleScope scope; HandleScope scope(node_isolate);
object_->Set(write_queue_size_sym, object_->Set(write_queue_size_sym,
Integer::New(stream_->write_queue_size)); Integer::New(stream_->write_queue_size, node_isolate));
} }
Handle<Value> StreamWrap::ReadStart(const Arguments& args) { Handle<Value> StreamWrap::ReadStart(const Arguments& args) {
HandleScope scope; HandleScope scope(node_isolate);
UNWRAP(StreamWrap) UNWRAP(StreamWrap)
@ -161,12 +161,12 @@ Handle<Value> StreamWrap::ReadStart(const Arguments& args) {
// Error starting the tcp. // Error starting the tcp.
if (r) SetErrno(uv_last_error(uv_default_loop())); if (r) SetErrno(uv_last_error(uv_default_loop()));
return scope.Close(Integer::New(r)); return scope.Close(Integer::New(r, node_isolate));
} }
Handle<Value> StreamWrap::ReadStop(const Arguments& args) { Handle<Value> StreamWrap::ReadStop(const Arguments& args) {
HandleScope scope; HandleScope scope(node_isolate);
UNWRAP(StreamWrap) UNWRAP(StreamWrap)
@ -175,7 +175,7 @@ Handle<Value> StreamWrap::ReadStop(const Arguments& args) {
// Error starting the tcp. // Error starting the tcp.
if (r) SetErrno(uv_last_error(uv_default_loop())); if (r) SetErrno(uv_last_error(uv_default_loop()));
return scope.Close(Integer::New(r)); return scope.Close(Integer::New(r, node_isolate));
} }
@ -189,7 +189,7 @@ uv_buf_t StreamWrap::OnAlloc(uv_handle_t* handle, size_t suggested_size) {
template <class WrapType, class UVType> template <class WrapType, class UVType>
static Local<Object> AcceptHandle(uv_stream_t* pipe) { static Local<Object> AcceptHandle(uv_stream_t* pipe) {
HandleScope scope; HandleScope scope(node_isolate);
Local<Object> wrap_obj; Local<Object> wrap_obj;
WrapType* wrap; WrapType* wrap;
UVType* handle; UVType* handle;
@ -211,7 +211,7 @@ static Local<Object> AcceptHandle(uv_stream_t* pipe) {
void StreamWrap::OnReadCommon(uv_stream_t* handle, ssize_t nread, void StreamWrap::OnReadCommon(uv_stream_t* handle, ssize_t nread,
uv_buf_t buf, uv_handle_type pending) { uv_buf_t buf, uv_handle_type pending) {
HandleScope scope; HandleScope scope(node_isolate);
StreamWrap* wrap = static_cast<StreamWrap*>(handle->data); StreamWrap* wrap = static_cast<StreamWrap*>(handle->data);
@ -242,8 +242,8 @@ void StreamWrap::OnReadCommon(uv_stream_t* handle, ssize_t nread,
int argc = 3; int argc = 3;
Local<Value> argv[4] = { Local<Value> argv[4] = {
slab, slab,
Integer::NewFromUnsigned(buf.base - Buffer::Data(slab)), Integer::NewFromUnsigned(buf.base - Buffer::Data(slab), node_isolate),
Integer::NewFromUnsigned(nread) Integer::NewFromUnsigned(nread, node_isolate)
}; };
Local<Object> pending_obj; Local<Object> pending_obj;
@ -284,7 +284,7 @@ void StreamWrap::OnRead2(uv_pipe_t* handle, ssize_t nread, uv_buf_t buf,
Handle<Value> StreamWrap::WriteBuffer(const Arguments& args) { Handle<Value> StreamWrap::WriteBuffer(const Arguments& args) {
HandleScope scope; HandleScope scope(node_isolate);
UNWRAP(StreamWrap) UNWRAP(StreamWrap)
@ -310,7 +310,7 @@ Handle<Value> StreamWrap::WriteBuffer(const Arguments& args) {
req_wrap->Dispatched(); req_wrap->Dispatched();
req_wrap->object_->Set(bytes_sym, req_wrap->object_->Set(bytes_sym,
Integer::NewFromUnsigned(length)); Integer::NewFromUnsigned(length, node_isolate));
wrap->UpdateWriteQueueSize(); wrap->UpdateWriteQueueSize();
@ -318,7 +318,7 @@ Handle<Value> StreamWrap::WriteBuffer(const Arguments& args) {
SetErrno(uv_last_error(uv_default_loop())); SetErrno(uv_last_error(uv_default_loop()));
req_wrap->~WriteWrap(); req_wrap->~WriteWrap();
delete[] storage; delete[] storage;
return scope.Close(v8::Null()); return scope.Close(v8::Null(node_isolate));
} else { } else {
if (wrap->stream_->type == UV_TCP) { if (wrap->stream_->type == UV_TCP) {
NODE_COUNT_NET_BYTES_SENT(length); NODE_COUNT_NET_BYTES_SENT(length);
@ -333,7 +333,7 @@ Handle<Value> StreamWrap::WriteBuffer(const Arguments& args) {
template <WriteEncoding encoding> template <WriteEncoding encoding>
Handle<Value> StreamWrap::WriteStringImpl(const Arguments& args) { Handle<Value> StreamWrap::WriteStringImpl(const Arguments& args) {
HandleScope scope; HandleScope scope(node_isolate);
int r; int r;
UNWRAP(StreamWrap) UNWRAP(StreamWrap)
@ -381,7 +381,7 @@ Handle<Value> StreamWrap::WriteStringImpl(const Arguments& args) {
uv_err_t err; uv_err_t err;
err.code = UV_ENOBUFS; err.code = UV_ENOBUFS;
SetErrno(err); SetErrno(err);
return scope.Close(v8::Null()); return scope.Close(v8::Null(node_isolate));
} }
char* storage = new char[sizeof(WriteWrap) + storage_size + 15]; char* storage = new char[sizeof(WriteWrap) + storage_size + 15];
@ -465,7 +465,7 @@ Handle<Value> StreamWrap::WriteStringImpl(const Arguments& args) {
SetErrno(uv_last_error(uv_default_loop())); SetErrno(uv_last_error(uv_default_loop()));
req_wrap->~WriteWrap(); req_wrap->~WriteWrap();
delete[] storage; delete[] storage;
return scope.Close(v8::Null()); return scope.Close(v8::Null(node_isolate));
} else { } else {
if (wrap->stream_->type == UV_TCP) { if (wrap->stream_->type == UV_TCP) {
NODE_COUNT_NET_BYTES_SENT(buf.len); NODE_COUNT_NET_BYTES_SENT(buf.len);
@ -497,7 +497,7 @@ void StreamWrap::AfterWrite(uv_write_t* req, int status) {
WriteWrap* req_wrap = (WriteWrap*) req->data; WriteWrap* req_wrap = (WriteWrap*) req->data;
StreamWrap* wrap = (StreamWrap*) req->handle->data; StreamWrap* wrap = (StreamWrap*) req->handle->data;
HandleScope scope; HandleScope scope(node_isolate);
// The wrap and request objects should still be there. // The wrap and request objects should still be there.
assert(req_wrap->object_.IsEmpty() == false); assert(req_wrap->object_.IsEmpty() == false);
@ -515,9 +515,9 @@ void StreamWrap::AfterWrite(uv_write_t* req, int status) {
wrap->UpdateWriteQueueSize(); wrap->UpdateWriteQueueSize();
Local<Value> argv[] = { Local<Value> argv[] = {
Integer::New(status), Integer::New(status, node_isolate),
Local<Value>::New(wrap->object_), Local<Value>::New(node_isolate, wrap->object_),
Local<Value>::New(req_wrap->object_) Local<Value>::New(node_isolate, req_wrap->object_)
}; };
MakeCallback(req_wrap->object_, oncomplete_sym, ARRAY_SIZE(argv), argv); MakeCallback(req_wrap->object_, oncomplete_sym, ARRAY_SIZE(argv), argv);
@ -528,7 +528,7 @@ void StreamWrap::AfterWrite(uv_write_t* req, int status) {
Handle<Value> StreamWrap::Shutdown(const Arguments& args) { Handle<Value> StreamWrap::Shutdown(const Arguments& args) {
HandleScope scope; HandleScope scope(node_isolate);
UNWRAP(StreamWrap) UNWRAP(StreamWrap)
@ -541,7 +541,7 @@ Handle<Value> StreamWrap::Shutdown(const Arguments& args) {
if (r) { if (r) {
SetErrno(uv_last_error(uv_default_loop())); SetErrno(uv_last_error(uv_default_loop()));
delete req_wrap; delete req_wrap;
return scope.Close(v8::Null()); return scope.Close(v8::Null(node_isolate));
} else { } else {
return scope.Close(req_wrap->object_); return scope.Close(req_wrap->object_);
} }
@ -556,16 +556,16 @@ void StreamWrap::AfterShutdown(uv_shutdown_t* req, int status) {
assert(req_wrap->object_.IsEmpty() == false); assert(req_wrap->object_.IsEmpty() == false);
assert(wrap->object_.IsEmpty() == false); assert(wrap->object_.IsEmpty() == false);
HandleScope scope; HandleScope scope(node_isolate);
if (status) { if (status) {
SetErrno(uv_last_error(uv_default_loop())); SetErrno(uv_last_error(uv_default_loop()));
} }
Local<Value> argv[3] = { Local<Value> argv[3] = {
Integer::New(status), Integer::New(status, node_isolate),
Local<Value>::New(wrap->object_), Local<Value>::New(node_isolate, wrap->object_),
Local<Value>::New(req_wrap->object_) Local<Value>::New(node_isolate, req_wrap->object_)
}; };
MakeCallback(req_wrap->object_, oncomplete_sym, ARRAY_SIZE(argv), argv); MakeCallback(req_wrap->object_, oncomplete_sym, ARRAY_SIZE(argv), argv);

70
src/tcp_wrap.cc

@ -63,7 +63,7 @@ Local<Object> TCPWrap::Instantiate() {
// called yet. // called yet.
assert(tcpConstructor.IsEmpty() == false); assert(tcpConstructor.IsEmpty() == false);
HandleScope scope; HandleScope scope(node_isolate);
Local<Object> obj = tcpConstructor->NewInstance(); Local<Object> obj = tcpConstructor->NewInstance();
return scope.Close(obj); return scope.Close(obj);
@ -74,7 +74,7 @@ void TCPWrap::Initialize(Handle<Object> target) {
HandleWrap::Initialize(target); HandleWrap::Initialize(target);
StreamWrap::Initialize(target); StreamWrap::Initialize(target);
HandleScope scope; HandleScope scope(node_isolate);
Local<FunctionTemplate> t = FunctionTemplate::New(New); Local<FunctionTemplate> t = FunctionTemplate::New(New);
t->SetClassName(String::NewSymbol("TCP")); t->SetClassName(String::NewSymbol("TCP"));
@ -145,7 +145,7 @@ Handle<Value> TCPWrap::New(const Arguments& args) {
// normal function. // normal function.
assert(args.IsConstructCall()); assert(args.IsConstructCall());
HandleScope scope; HandleScope scope(node_isolate);
TCPWrap* wrap = new TCPWrap(args.This()); TCPWrap* wrap = new TCPWrap(args.This());
assert(wrap); assert(wrap);
@ -168,7 +168,7 @@ TCPWrap::~TCPWrap() {
Handle<Value> TCPWrap::GetSockName(const Arguments& args) { Handle<Value> TCPWrap::GetSockName(const Arguments& args) {
HandleScope scope; HandleScope scope(node_isolate);
struct sockaddr_storage address; struct sockaddr_storage address;
UNWRAP(TCPWrap) UNWRAP(TCPWrap)
@ -180,7 +180,7 @@ Handle<Value> TCPWrap::GetSockName(const Arguments& args) {
if (r) { if (r) {
SetErrno(uv_last_error(uv_default_loop())); SetErrno(uv_last_error(uv_default_loop()));
return Null(); return Null(node_isolate);
} }
const sockaddr* addr = reinterpret_cast<const sockaddr*>(&address); const sockaddr* addr = reinterpret_cast<const sockaddr*>(&address);
@ -189,7 +189,7 @@ Handle<Value> TCPWrap::GetSockName(const Arguments& args) {
Handle<Value> TCPWrap::GetPeerName(const Arguments& args) { Handle<Value> TCPWrap::GetPeerName(const Arguments& args) {
HandleScope scope; HandleScope scope(node_isolate);
struct sockaddr_storage address; struct sockaddr_storage address;
UNWRAP(TCPWrap) UNWRAP(TCPWrap)
@ -201,7 +201,7 @@ Handle<Value> TCPWrap::GetPeerName(const Arguments& args) {
if (r) { if (r) {
SetErrno(uv_last_error(uv_default_loop())); SetErrno(uv_last_error(uv_default_loop()));
return Null(); return Null(node_isolate);
} }
const sockaddr* addr = reinterpret_cast<const sockaddr*>(&address); const sockaddr* addr = reinterpret_cast<const sockaddr*>(&address);
@ -210,7 +210,7 @@ Handle<Value> TCPWrap::GetPeerName(const Arguments& args) {
Handle<Value> TCPWrap::SetNoDelay(const Arguments& args) { Handle<Value> TCPWrap::SetNoDelay(const Arguments& args) {
HandleScope scope; HandleScope scope(node_isolate);
UNWRAP(TCPWrap) UNWRAP(TCPWrap)
@ -219,12 +219,12 @@ Handle<Value> TCPWrap::SetNoDelay(const Arguments& args) {
if (r) if (r)
SetErrno(uv_last_error(uv_default_loop())); SetErrno(uv_last_error(uv_default_loop()));
return Undefined(); return Undefined(node_isolate);
} }
Handle<Value> TCPWrap::SetKeepAlive(const Arguments& args) { Handle<Value> TCPWrap::SetKeepAlive(const Arguments& args) {
HandleScope scope; HandleScope scope(node_isolate);
UNWRAP(TCPWrap) UNWRAP(TCPWrap)
@ -235,13 +235,13 @@ Handle<Value> TCPWrap::SetKeepAlive(const Arguments& args) {
if (r) if (r)
SetErrno(uv_last_error(uv_default_loop())); SetErrno(uv_last_error(uv_default_loop()));
return Undefined(); return Undefined(node_isolate);
} }
#ifdef _WIN32 #ifdef _WIN32
Handle<Value> TCPWrap::SetSimultaneousAccepts(const Arguments& args) { Handle<Value> TCPWrap::SetSimultaneousAccepts(const Arguments& args) {
HandleScope scope; HandleScope scope(node_isolate);
UNWRAP(TCPWrap) UNWRAP(TCPWrap)
@ -251,13 +251,13 @@ Handle<Value> TCPWrap::SetSimultaneousAccepts(const Arguments& args) {
if (r) if (r)
SetErrno(uv_last_error(uv_default_loop())); SetErrno(uv_last_error(uv_default_loop()));
return Undefined(); return Undefined(node_isolate);
} }
#endif #endif
Handle<Value> TCPWrap::Bind(const Arguments& args) { Handle<Value> TCPWrap::Bind(const Arguments& args) {
HandleScope scope; HandleScope scope(node_isolate);
UNWRAP(TCPWrap) UNWRAP(TCPWrap)
@ -270,12 +270,12 @@ Handle<Value> TCPWrap::Bind(const Arguments& args) {
// Error starting the tcp. // Error starting the tcp.
if (r) SetErrno(uv_last_error(uv_default_loop())); if (r) SetErrno(uv_last_error(uv_default_loop()));
return scope.Close(Integer::New(r)); return scope.Close(Integer::New(r, node_isolate));
} }
Handle<Value> TCPWrap::Bind6(const Arguments& args) { Handle<Value> TCPWrap::Bind6(const Arguments& args) {
HandleScope scope; HandleScope scope(node_isolate);
UNWRAP(TCPWrap) UNWRAP(TCPWrap)
@ -288,12 +288,12 @@ Handle<Value> TCPWrap::Bind6(const Arguments& args) {
// Error starting the tcp. // Error starting the tcp.
if (r) SetErrno(uv_last_error(uv_default_loop())); if (r) SetErrno(uv_last_error(uv_default_loop()));
return scope.Close(Integer::New(r)); return scope.Close(Integer::New(r, node_isolate));
} }
Handle<Value> TCPWrap::Listen(const Arguments& args) { Handle<Value> TCPWrap::Listen(const Arguments& args) {
HandleScope scope; HandleScope scope(node_isolate);
UNWRAP(TCPWrap) UNWRAP(TCPWrap)
@ -304,12 +304,12 @@ Handle<Value> TCPWrap::Listen(const Arguments& args) {
// Error starting the tcp. // Error starting the tcp.
if (r) SetErrno(uv_last_error(uv_default_loop())); if (r) SetErrno(uv_last_error(uv_default_loop()));
return scope.Close(Integer::New(r)); return scope.Close(Integer::New(r, node_isolate));
} }
void TCPWrap::OnConnection(uv_stream_t* handle, int status) { void TCPWrap::OnConnection(uv_stream_t* handle, int status) {
HandleScope scope; HandleScope scope(node_isolate);
TCPWrap* wrap = static_cast<TCPWrap*>(handle->data); TCPWrap* wrap = static_cast<TCPWrap*>(handle->data);
assert(&wrap->handle_ == (uv_tcp_t*)handle); assert(&wrap->handle_ == (uv_tcp_t*)handle);
@ -335,7 +335,7 @@ void TCPWrap::OnConnection(uv_stream_t* handle, int status) {
argv[0] = client_obj; argv[0] = client_obj;
} else { } else {
SetErrno(uv_last_error(uv_default_loop())); SetErrno(uv_last_error(uv_default_loop()));
argv[0] = Local<Value>::New(Null()); argv[0] = Local<Value>::New(node_isolate, Null(node_isolate));
} }
MakeCallback(wrap->object_, onconnection_sym, ARRAY_SIZE(argv), argv); MakeCallback(wrap->object_, onconnection_sym, ARRAY_SIZE(argv), argv);
@ -346,7 +346,7 @@ void TCPWrap::AfterConnect(uv_connect_t* req, int status) {
ConnectWrap* req_wrap = (ConnectWrap*) req->data; ConnectWrap* req_wrap = (ConnectWrap*) req->data;
TCPWrap* wrap = (TCPWrap*) req->handle->data; TCPWrap* wrap = (TCPWrap*) req->handle->data;
HandleScope scope; HandleScope scope(node_isolate);
// The wrap and request objects should still be there. // The wrap and request objects should still be there.
assert(req_wrap->object_.IsEmpty() == false); assert(req_wrap->object_.IsEmpty() == false);
@ -357,11 +357,11 @@ void TCPWrap::AfterConnect(uv_connect_t* req, int status) {
} }
Local<Value> argv[5] = { Local<Value> argv[5] = {
Integer::New(status), Integer::New(status, node_isolate),
Local<Value>::New(wrap->object_), Local<Value>::New(node_isolate, wrap->object_),
Local<Value>::New(req_wrap->object_), Local<Value>::New(node_isolate, req_wrap->object_),
Local<Value>::New(v8::True()), Local<Value>::New(node_isolate, v8::True(node_isolate)),
Local<Value>::New(v8::True()) Local<Value>::New(node_isolate, v8::True(node_isolate))
}; };
MakeCallback(req_wrap->object_, oncomplete_sym, ARRAY_SIZE(argv), argv); MakeCallback(req_wrap->object_, oncomplete_sym, ARRAY_SIZE(argv), argv);
@ -371,7 +371,7 @@ void TCPWrap::AfterConnect(uv_connect_t* req, int status) {
Handle<Value> TCPWrap::Connect(const Arguments& args) { Handle<Value> TCPWrap::Connect(const Arguments& args) {
HandleScope scope; HandleScope scope(node_isolate);
UNWRAP(TCPWrap) UNWRAP(TCPWrap)
@ -393,7 +393,7 @@ Handle<Value> TCPWrap::Connect(const Arguments& args) {
if (r) { if (r) {
SetErrno(uv_last_error(uv_default_loop())); SetErrno(uv_last_error(uv_default_loop()));
delete req_wrap; delete req_wrap;
return scope.Close(v8::Null()); return scope.Close(v8::Null(node_isolate));
} else { } else {
return scope.Close(req_wrap->object_); return scope.Close(req_wrap->object_);
} }
@ -401,7 +401,7 @@ Handle<Value> TCPWrap::Connect(const Arguments& args) {
Handle<Value> TCPWrap::Connect6(const Arguments& args) { Handle<Value> TCPWrap::Connect6(const Arguments& args) {
HandleScope scope; HandleScope scope(node_isolate);
UNWRAP(TCPWrap) UNWRAP(TCPWrap)
@ -420,7 +420,7 @@ Handle<Value> TCPWrap::Connect6(const Arguments& args) {
if (r) { if (r) {
SetErrno(uv_last_error(uv_default_loop())); SetErrno(uv_last_error(uv_default_loop()));
delete req_wrap; delete req_wrap;
return scope.Close(v8::Null()); return scope.Close(v8::Null(node_isolate));
} else { } else {
return scope.Close(req_wrap->object_); return scope.Close(req_wrap->object_);
} }
@ -435,7 +435,7 @@ Local<Object> AddressToJS(const sockaddr* addr) {
static Persistent<String> ipv4_sym; static Persistent<String> ipv4_sym;
static Persistent<String> ipv6_sym; static Persistent<String> ipv6_sym;
HandleScope scope; HandleScope scope(node_isolate);
char ip[INET6_ADDRSTRLEN]; char ip[INET6_ADDRSTRLEN];
const sockaddr_in *a4; const sockaddr_in *a4;
const sockaddr_in6 *a6; const sockaddr_in6 *a6;
@ -458,7 +458,7 @@ Local<Object> AddressToJS(const sockaddr* addr) {
port = ntohs(a6->sin6_port); port = ntohs(a6->sin6_port);
info->Set(address_sym, String::New(ip)); info->Set(address_sym, String::New(ip));
info->Set(family_sym, ipv6_sym); info->Set(family_sym, ipv6_sym);
info->Set(port_sym, Integer::New(port)); info->Set(port_sym, Integer::New(port, node_isolate));
break; break;
case AF_INET: case AF_INET:
@ -467,11 +467,11 @@ Local<Object> AddressToJS(const sockaddr* addr) {
port = ntohs(a4->sin_port); port = ntohs(a4->sin_port);
info->Set(address_sym, String::New(ip)); info->Set(address_sym, String::New(ip));
info->Set(family_sym, ipv4_sym); info->Set(family_sym, ipv4_sym);
info->Set(port_sym, Integer::New(port)); info->Set(port_sym, Integer::New(port, node_isolate));
break; break;
default: default:
info->Set(address_sym, String::Empty()); info->Set(address_sym, String::Empty(node_isolate));
} }
return scope.Close(info); return scope.Close(info);

28
src/timer_wrap.cc

@ -43,7 +43,7 @@ static Persistent<String> ontimeout_sym;
class TimerWrap : public HandleWrap { class TimerWrap : public HandleWrap {
public: public:
static void Initialize(Handle<Object> target) { static void Initialize(Handle<Object> target) {
HandleScope scope; HandleScope scope(node_isolate);
HandleWrap::Initialize(target); HandleWrap::Initialize(target);
@ -73,7 +73,7 @@ class TimerWrap : public HandleWrap {
// normal function. // normal function.
assert(args.IsConstructCall()); assert(args.IsConstructCall());
HandleScope scope; HandleScope scope(node_isolate);
TimerWrap *wrap = new TimerWrap(args.This()); TimerWrap *wrap = new TimerWrap(args.This());
assert(wrap); assert(wrap);
@ -91,7 +91,7 @@ class TimerWrap : public HandleWrap {
} }
static Handle<Value> Start(const Arguments& args) { static Handle<Value> Start(const Arguments& args) {
HandleScope scope; HandleScope scope(node_isolate);
UNWRAP(TimerWrap) UNWRAP(TimerWrap)
@ -102,11 +102,11 @@ class TimerWrap : public HandleWrap {
if (r) SetErrno(uv_last_error(uv_default_loop())); if (r) SetErrno(uv_last_error(uv_default_loop()));
return scope.Close(Integer::New(r)); return scope.Close(Integer::New(r, node_isolate));
} }
static Handle<Value> Stop(const Arguments& args) { static Handle<Value> Stop(const Arguments& args) {
HandleScope scope; HandleScope scope(node_isolate);
UNWRAP(TimerWrap) UNWRAP(TimerWrap)
@ -114,11 +114,11 @@ class TimerWrap : public HandleWrap {
if (r) SetErrno(uv_last_error(uv_default_loop())); if (r) SetErrno(uv_last_error(uv_default_loop()));
return scope.Close(Integer::New(r)); return scope.Close(Integer::New(r, node_isolate));
} }
static Handle<Value> Again(const Arguments& args) { static Handle<Value> Again(const Arguments& args) {
HandleScope scope; HandleScope scope(node_isolate);
UNWRAP(TimerWrap) UNWRAP(TimerWrap)
@ -126,11 +126,11 @@ class TimerWrap : public HandleWrap {
if (r) SetErrno(uv_last_error(uv_default_loop())); if (r) SetErrno(uv_last_error(uv_default_loop()));
return scope.Close(Integer::New(r)); return scope.Close(Integer::New(r, node_isolate));
} }
static Handle<Value> SetRepeat(const Arguments& args) { static Handle<Value> SetRepeat(const Arguments& args) {
HandleScope scope; HandleScope scope(node_isolate);
UNWRAP(TimerWrap) UNWRAP(TimerWrap)
@ -138,11 +138,11 @@ class TimerWrap : public HandleWrap {
uv_timer_set_repeat(&wrap->handle_, repeat); uv_timer_set_repeat(&wrap->handle_, repeat);
return scope.Close(Integer::New(0)); return scope.Close(Integer::New(0, node_isolate));
} }
static Handle<Value> GetRepeat(const Arguments& args) { static Handle<Value> GetRepeat(const Arguments& args) {
HandleScope scope; HandleScope scope(node_isolate);
UNWRAP(TimerWrap) UNWRAP(TimerWrap)
@ -150,16 +150,16 @@ class TimerWrap : public HandleWrap {
if (repeat < 0) SetErrno(uv_last_error(uv_default_loop())); if (repeat < 0) SetErrno(uv_last_error(uv_default_loop()));
return scope.Close(Integer::New(repeat)); return scope.Close(Integer::New(repeat, node_isolate));
} }
static void OnTimeout(uv_timer_t* handle, int status) { static void OnTimeout(uv_timer_t* handle, int status) {
HandleScope scope; HandleScope scope(node_isolate);
TimerWrap* wrap = static_cast<TimerWrap*>(handle->data); TimerWrap* wrap = static_cast<TimerWrap*>(handle->data);
assert(wrap); assert(wrap);
Local<Value> argv[1] = { Integer::New(status) }; Local<Value> argv[1] = { Integer::New(status, node_isolate) };
MakeCallback(wrap->object_, ontimeout_sym, ARRAY_SIZE(argv), argv); MakeCallback(wrap->object_, ontimeout_sym, ARRAY_SIZE(argv), argv);
} }

26
src/tty_wrap.cc

@ -48,7 +48,7 @@ using v8::Value;
void TTYWrap::Initialize(Handle<Object> target) { void TTYWrap::Initialize(Handle<Object> target) {
StreamWrap::Initialize(target); StreamWrap::Initialize(target);
HandleScope scope; HandleScope scope(node_isolate);
Local<FunctionTemplate> t = FunctionTemplate::New(New); Local<FunctionTemplate> t = FunctionTemplate::New(New);
t->SetClassName(String::NewSymbol("TTY")); t->SetClassName(String::NewSymbol("TTY"));
@ -98,7 +98,7 @@ uv_tty_t* TTYWrap::UVHandle() {
Handle<Value> TTYWrap::GuessHandleType(const Arguments& args) { Handle<Value> TTYWrap::GuessHandleType(const Arguments& args) {
HandleScope scope; HandleScope scope(node_isolate);
int fd = args[0]->Int32Value(); int fd = args[0]->Int32Value();
assert(fd >= 0); assert(fd >= 0);
@ -119,26 +119,26 @@ Handle<Value> TTYWrap::GuessHandleType(const Arguments& args) {
default: default:
assert(0); assert(0);
return v8::Undefined(); return v8::Undefined(node_isolate);
} }
} }
Handle<Value> TTYWrap::IsTTY(const Arguments& args) { Handle<Value> TTYWrap::IsTTY(const Arguments& args) {
HandleScope scope; HandleScope scope(node_isolate);
int fd = args[0]->Int32Value(); int fd = args[0]->Int32Value();
assert(fd >= 0); assert(fd >= 0);
if (uv_guess_handle(fd) == UV_TTY) { if (uv_guess_handle(fd) == UV_TTY) {
return v8::True(); return v8::True(node_isolate);
} }
return v8::False(); return v8::False(node_isolate);
} }
Handle<Value> TTYWrap::GetWindowSize(const Arguments& args) { Handle<Value> TTYWrap::GetWindowSize(const Arguments& args) {
HandleScope scope; HandleScope scope(node_isolate);
UNWRAP(TTYWrap) UNWRAP(TTYWrap)
@ -147,19 +147,19 @@ Handle<Value> TTYWrap::GetWindowSize(const Arguments& args) {
if (r) { if (r) {
SetErrno(uv_last_error(uv_default_loop())); SetErrno(uv_last_error(uv_default_loop()));
return v8::Undefined(); return v8::Undefined(node_isolate);
} }
Local<v8::Array> a = v8::Array::New(2); Local<v8::Array> a = v8::Array::New(2);
a->Set(0, Integer::New(width)); a->Set(0, Integer::New(width, node_isolate));
a->Set(1, Integer::New(height)); a->Set(1, Integer::New(height, node_isolate));
return scope.Close(a); return scope.Close(a);
} }
Handle<Value> TTYWrap::SetRawMode(const Arguments& args) { Handle<Value> TTYWrap::SetRawMode(const Arguments& args) {
HandleScope scope; HandleScope scope(node_isolate);
UNWRAP(TTYWrap) UNWRAP(TTYWrap)
@ -169,12 +169,12 @@ Handle<Value> TTYWrap::SetRawMode(const Arguments& args) {
SetErrno(uv_last_error(uv_default_loop())); SetErrno(uv_last_error(uv_default_loop()));
} }
return scope.Close(Integer::New(r)); return scope.Close(Integer::New(r, node_isolate));
} }
Handle<Value> TTYWrap::New(const Arguments& args) { Handle<Value> TTYWrap::New(const Arguments& args) {
HandleScope scope; HandleScope scope(node_isolate);
// This constructor should not be exposed to public javascript. // This constructor should not be exposed to public javascript.
// Therefore we assert that we are not trying to call this as a // Therefore we assert that we are not trying to call this as a

63
src/udp_wrap.cc

@ -35,19 +35,16 @@ namespace node {
using v8::AccessorInfo; using v8::AccessorInfo;
using v8::Arguments; using v8::Arguments;
using v8::False;
using v8::Function; using v8::Function;
using v8::FunctionTemplate; using v8::FunctionTemplate;
using v8::Handle; using v8::Handle;
using v8::HandleScope; using v8::HandleScope;
using v8::Integer; using v8::Integer;
using v8::Local; using v8::Local;
using v8::Null;
using v8::Object; using v8::Object;
using v8::Persistent; using v8::Persistent;
using v8::PropertyAttribute; using v8::PropertyAttribute;
using v8::String; using v8::String;
using v8::True;
using v8::Value; using v8::Value;
typedef ReqWrap<uv_udp_send_t> SendWrap; typedef ReqWrap<uv_udp_send_t> SendWrap;
@ -86,7 +83,7 @@ void UDPWrap::Initialize(Handle<Object> target) {
slab_allocator = new SlabAllocator(SLAB_SIZE); slab_allocator = new SlabAllocator(SLAB_SIZE);
AtExit(DeleteSlabAllocator, NULL); AtExit(DeleteSlabAllocator, NULL);
HandleScope scope; HandleScope scope(node_isolate);
buffer_sym = NODE_PSYMBOL("buffer"); buffer_sym = NODE_PSYMBOL("buffer");
oncomplete_sym = NODE_PSYMBOL("oncomplete"); oncomplete_sym = NODE_PSYMBOL("oncomplete");
@ -130,7 +127,7 @@ void UDPWrap::Initialize(Handle<Object> target) {
Handle<Value> UDPWrap::New(const Arguments& args) { Handle<Value> UDPWrap::New(const Arguments& args) {
HandleScope scope; HandleScope scope(node_isolate);
assert(args.IsConstructCall()); assert(args.IsConstructCall());
new UDPWrap(args.This()); new UDPWrap(args.This());
@ -141,18 +138,18 @@ Handle<Value> UDPWrap::New(const Arguments& args) {
Handle<Value> UDPWrap::GetFD(Local<String>, const AccessorInfo& args) { Handle<Value> UDPWrap::GetFD(Local<String>, const AccessorInfo& args) {
#if defined(_WIN32) #if defined(_WIN32)
return v8::Null(); return v8::Null(node_isolate);
#else #else
HandleScope scope; HandleScope scope(node_isolate);
UNWRAP(UDPWrap) UNWRAP(UDPWrap)
int fd = (wrap == NULL) ? -1 : wrap->handle_.io_watcher.fd; int fd = (wrap == NULL) ? -1 : wrap->handle_.io_watcher.fd;
return scope.Close(Integer::New(fd)); return scope.Close(Integer::New(fd, node_isolate));
#endif #endif
} }
Handle<Value> UDPWrap::DoBind(const Arguments& args, int family) { Handle<Value> UDPWrap::DoBind(const Arguments& args, int family) {
HandleScope scope; HandleScope scope(node_isolate);
int r; int r;
UNWRAP(UDPWrap) UNWRAP(UDPWrap)
@ -179,7 +176,7 @@ Handle<Value> UDPWrap::DoBind(const Arguments& args, int family) {
if (r) if (r)
SetErrno(uv_last_error(uv_default_loop())); SetErrno(uv_last_error(uv_default_loop()));
return scope.Close(Integer::New(r)); return scope.Close(Integer::New(r, node_isolate));
} }
@ -195,13 +192,13 @@ Handle<Value> UDPWrap::Bind6(const Arguments& args) {
#define X(name, fn) \ #define X(name, fn) \
Handle<Value> UDPWrap::name(const Arguments& args) { \ Handle<Value> UDPWrap::name(const Arguments& args) { \
HandleScope scope; \ HandleScope scope(node_isolate); \
UNWRAP(UDPWrap) \ UNWRAP(UDPWrap) \
assert(args.Length() == 1); \ assert(args.Length() == 1); \
int flag = args[0]->Int32Value(); \ int flag = args[0]->Int32Value(); \
int r = fn(&wrap->handle_, flag); \ int r = fn(&wrap->handle_, flag); \
if (r) SetErrno(uv_last_error(uv_default_loop())); \ if (r) SetErrno(uv_last_error(uv_default_loop())); \
return scope.Close(Integer::New(r)); \ return scope.Close(Integer::New(r, node_isolate)); \
} }
X(SetTTL, uv_udp_set_ttl) X(SetTTL, uv_udp_set_ttl)
@ -214,7 +211,7 @@ X(SetMulticastLoopback, uv_udp_set_multicast_loop)
Handle<Value> UDPWrap::SetMembership(const Arguments& args, Handle<Value> UDPWrap::SetMembership(const Arguments& args,
uv_membership membership) { uv_membership membership) {
HandleScope scope; HandleScope scope(node_isolate);
UNWRAP(UDPWrap) UNWRAP(UDPWrap)
assert(args.Length() == 2); assert(args.Length() == 2);
@ -233,7 +230,7 @@ Handle<Value> UDPWrap::SetMembership(const Arguments& args,
if (r) if (r)
SetErrno(uv_last_error(uv_default_loop())); SetErrno(uv_last_error(uv_default_loop()));
return scope.Close(Integer::New(r)); return scope.Close(Integer::New(r, node_isolate));
} }
@ -248,7 +245,7 @@ Handle<Value> UDPWrap::DropMembership(const Arguments& args) {
Handle<Value> UDPWrap::DoSend(const Arguments& args, int family) { Handle<Value> UDPWrap::DoSend(const Arguments& args, int family) {
HandleScope scope; HandleScope scope(node_isolate);
int r; int r;
// send(buffer, offset, length, port, address) // send(buffer, offset, length, port, address)
@ -292,7 +289,7 @@ Handle<Value> UDPWrap::DoSend(const Arguments& args, int family) {
if (r) { if (r) {
SetErrno(uv_last_error(uv_default_loop())); SetErrno(uv_last_error(uv_default_loop()));
delete req_wrap; delete req_wrap;
return Null(); return Null(node_isolate);
} }
else { else {
return scope.Close(req_wrap->object_); return scope.Close(req_wrap->object_);
@ -311,7 +308,7 @@ Handle<Value> UDPWrap::Send6(const Arguments& args) {
Handle<Value> UDPWrap::RecvStart(const Arguments& args) { Handle<Value> UDPWrap::RecvStart(const Arguments& args) {
HandleScope scope; HandleScope scope(node_isolate);
UNWRAP(UDPWrap) UNWRAP(UDPWrap)
@ -319,26 +316,26 @@ Handle<Value> UDPWrap::RecvStart(const Arguments& args) {
int r = uv_udp_recv_start(&wrap->handle_, OnAlloc, OnRecv); int r = uv_udp_recv_start(&wrap->handle_, OnAlloc, OnRecv);
if (r && uv_last_error(uv_default_loop()).code != UV_EALREADY) { if (r && uv_last_error(uv_default_loop()).code != UV_EALREADY) {
SetErrno(uv_last_error(uv_default_loop())); SetErrno(uv_last_error(uv_default_loop()));
return False(); return False(node_isolate);
} }
return True(); return True(node_isolate);
} }
Handle<Value> UDPWrap::RecvStop(const Arguments& args) { Handle<Value> UDPWrap::RecvStop(const Arguments& args) {
HandleScope scope; HandleScope scope(node_isolate);
UNWRAP(UDPWrap) UNWRAP(UDPWrap)
int r = uv_udp_recv_stop(&wrap->handle_); int r = uv_udp_recv_stop(&wrap->handle_);
return scope.Close(Integer::New(r)); return scope.Close(Integer::New(r, node_isolate));
} }
Handle<Value> UDPWrap::GetSockName(const Arguments& args) { Handle<Value> UDPWrap::GetSockName(const Arguments& args) {
HandleScope scope; HandleScope scope(node_isolate);
struct sockaddr_storage address; struct sockaddr_storage address;
UNWRAP(UDPWrap) UNWRAP(UDPWrap)
@ -350,7 +347,7 @@ Handle<Value> UDPWrap::GetSockName(const Arguments& args) {
if (r) { if (r) {
SetErrno(uv_last_error(uv_default_loop())); SetErrno(uv_last_error(uv_default_loop()));
return Null(); return Null(node_isolate);
} }
const sockaddr* addr = reinterpret_cast<const sockaddr*>(&address); const sockaddr* addr = reinterpret_cast<const sockaddr*>(&address);
@ -360,7 +357,7 @@ Handle<Value> UDPWrap::GetSockName(const Arguments& args) {
// TODO share with StreamWrap::AfterWrite() in stream_wrap.cc // TODO share with StreamWrap::AfterWrite() in stream_wrap.cc
void UDPWrap::OnSend(uv_udp_send_t* req, int status) { void UDPWrap::OnSend(uv_udp_send_t* req, int status) {
HandleScope scope; HandleScope scope(node_isolate);
assert(req != NULL); assert(req != NULL);
@ -375,9 +372,9 @@ void UDPWrap::OnSend(uv_udp_send_t* req, int status) {
} }
Local<Value> argv[4] = { Local<Value> argv[4] = {
Integer::New(status), Integer::New(status, node_isolate),
Local<Value>::New(wrap->object_), Local<Value>::New(node_isolate, wrap->object_),
Local<Value>::New(req_wrap->object_), Local<Value>::New(node_isolate, req_wrap->object_),
req_wrap->object_->GetHiddenValue(buffer_sym), req_wrap->object_->GetHiddenValue(buffer_sym),
}; };
@ -398,7 +395,7 @@ void UDPWrap::OnRecv(uv_udp_t* handle,
uv_buf_t buf, uv_buf_t buf,
struct sockaddr* addr, struct sockaddr* addr,
unsigned flags) { unsigned flags) {
HandleScope scope; HandleScope scope(node_isolate);
UDPWrap* wrap = reinterpret_cast<UDPWrap*>(handle->data); UDPWrap* wrap = reinterpret_cast<UDPWrap*>(handle->data);
Local<Object> slab = slab_allocator->Shrink(wrap->object_, Local<Object> slab = slab_allocator->Shrink(wrap->object_,
@ -407,17 +404,17 @@ void UDPWrap::OnRecv(uv_udp_t* handle,
if (nread == 0) return; if (nread == 0) return;
if (nread < 0) { if (nread < 0) {
Local<Value> argv[] = { Local<Object>::New(wrap->object_) }; Local<Value> argv[] = { Local<Object>::New(node_isolate, wrap->object_) };
SetErrno(uv_last_error(uv_default_loop())); SetErrno(uv_last_error(uv_default_loop()));
MakeCallback(wrap->object_, onmessage_sym, ARRAY_SIZE(argv), argv); MakeCallback(wrap->object_, onmessage_sym, ARRAY_SIZE(argv), argv);
return; return;
} }
Local<Value> argv[] = { Local<Value> argv[] = {
Local<Object>::New(wrap->object_), Local<Object>::New(node_isolate, wrap->object_),
slab, slab,
Integer::NewFromUnsigned(buf.base - Buffer::Data(slab)), Integer::NewFromUnsigned(buf.base - Buffer::Data(slab), node_isolate),
Integer::NewFromUnsigned(nread), Integer::NewFromUnsigned(nread, node_isolate),
AddressToJS(addr) AddressToJS(addr)
}; };
MakeCallback(wrap->object_, onmessage_sym, ARRAY_SIZE(argv), argv); MakeCallback(wrap->object_, onmessage_sym, ARRAY_SIZE(argv), argv);
@ -435,7 +432,7 @@ Local<Object> UDPWrap::Instantiate() {
// If this assert fires then Initialize hasn't been called yet. // If this assert fires then Initialize hasn't been called yet.
assert(constructor.IsEmpty() == false); assert(constructor.IsEmpty() == false);
HandleScope scope; HandleScope scope(node_isolate);
Local<Object> obj = constructor->NewInstance(); Local<Object> obj = constructor->NewInstance();
return scope.Close(obj); return scope.Close(obj);

68
src/v8_typed_array.cc

@ -47,7 +47,7 @@ class ArrayBuffer {
if (!ft_cache.IsEmpty()) if (!ft_cache.IsEmpty())
return ft_cache; return ft_cache;
v8::HandleScope scope; v8::HandleScope scope(node::node_isolate);
ft_cache = v8::Persistent<v8::FunctionTemplate>::New(node::node_isolate, ft_cache = v8::Persistent<v8::FunctionTemplate>::New(node::node_isolate,
v8::FunctionTemplate::New(&ArrayBuffer::V8New)); v8::FunctionTemplate::New(&ArrayBuffer::V8New));
ft_cache->SetClassName(v8::String::New("ArrayBuffer")); ft_cache->SetClassName(v8::String::New("ArrayBuffer"));
@ -113,7 +113,8 @@ class ArrayBuffer {
args.This()->SetAlignedPointerInInternalField(0, buf); args.This()->SetAlignedPointerInInternalField(0, buf);
args.This()->Set(v8::String::New("byteLength"), args.This()->Set(v8::String::New("byteLength"),
v8::Integer::NewFromUnsigned(num_bytes), v8::Integer::NewFromUnsigned(num_bytes,
node::node_isolate),
(v8::PropertyAttribute)(v8::ReadOnly|v8::DontDelete)); (v8::PropertyAttribute)(v8::ReadOnly|v8::DontDelete));
// NOTE(deanm): This is not in the spec, you shouldn't be able to index // NOTE(deanm): This is not in the spec, you shouldn't be able to index
@ -155,11 +156,12 @@ class ArrayBuffer {
unsigned int slice_length = end - begin; unsigned int slice_length = end - begin;
v8::Local<v8::Value> argv[] = { v8::Local<v8::Value> argv[] = {
v8::Integer::New(slice_length)}; v8::Integer::New(slice_length, node::node_isolate)};
v8::Local<v8::Object> buffer = ArrayBuffer::GetTemplate()-> v8::Local<v8::Object> buffer = ArrayBuffer::GetTemplate()->
GetFunction()->NewInstance(1, argv); GetFunction()->NewInstance(1, argv);
if (buffer.IsEmpty()) return v8::Undefined(); // constructor failed // constructor failed
if (buffer.IsEmpty()) return v8::Undefined(node::node_isolate);
void* src = args.This()->GetAlignedPointerFromInternalField(0); void* src = args.This()->GetAlignedPointerFromInternalField(0);
void* dest = buffer->GetAlignedPointerFromInternalField(0); void* dest = buffer->GetAlignedPointerFromInternalField(0);
@ -205,7 +207,7 @@ class TypedArray {
if (!ft_cache.IsEmpty()) if (!ft_cache.IsEmpty())
return ft_cache; return ft_cache;
v8::HandleScope scope; v8::HandleScope scope(node::node_isolate);
ft_cache = v8::Persistent<v8::FunctionTemplate>::New(node::node_isolate, ft_cache = v8::Persistent<v8::FunctionTemplate>::New(node::node_isolate,
v8::FunctionTemplate::New(&TypedArray<TBytes, TEAType>::V8New)); v8::FunctionTemplate::New(&TypedArray<TBytes, TEAType>::V8New));
ft_cache->SetClassName(v8::String::New(TEANameTrait<TEAType>::name)); ft_cache->SetClassName(v8::String::New(TEANameTrait<TEAType>::name));
@ -213,9 +215,9 @@ class TypedArray {
instance->SetInternalFieldCount(0); instance->SetInternalFieldCount(0);
ft_cache->Set(v8::String::New("BYTES_PER_ELEMENT"), ft_cache->Set(v8::String::New("BYTES_PER_ELEMENT"),
v8::Uint32::New(TBytes), v8::ReadOnly); v8::Uint32::New(TBytes, node::node_isolate), v8::ReadOnly);
instance->Set(v8::String::New("BYTES_PER_ELEMENT"), instance->Set(v8::String::New("BYTES_PER_ELEMENT"),
v8::Uint32::New(TBytes), v8::ReadOnly); v8::Uint32::New(TBytes, node::node_isolate), v8::ReadOnly);
v8::Local<v8::Signature> default_signature = v8::Signature::New(ft_cache); v8::Local<v8::Signature> default_signature = v8::Signature::New(ft_cache);
@ -295,10 +297,11 @@ class TypedArray {
// TODO(deanm): Handle integer overflow. // TODO(deanm): Handle integer overflow.
v8::Local<v8::Value> argv[1] = { v8::Local<v8::Value> argv[1] = {
v8::Integer::NewFromUnsigned(length * TBytes)}; v8::Integer::NewFromUnsigned(length * TBytes, node::node_isolate)};
buffer = ArrayBuffer::GetTemplate()-> buffer = ArrayBuffer::GetTemplate()->
GetFunction()->NewInstance(1, argv); GetFunction()->NewInstance(1, argv);
if (buffer.IsEmpty()) return v8::Undefined(); // constructor failed // constructor failed
if (buffer.IsEmpty()) return v8::Undefined(node::node_isolate);
void* buf = buffer->GetAlignedPointerFromInternalField(0); void* buf = buffer->GetAlignedPointerFromInternalField(0);
args.This()->SetIndexedPropertiesToExternalArrayData( args.This()->SetIndexedPropertiesToExternalArrayData(
@ -323,11 +326,12 @@ class TypedArray {
length = args[0]->Uint32Value(); length = args[0]->Uint32Value();
// TODO(deanm): Handle integer overflow. // TODO(deanm): Handle integer overflow.
v8::Local<v8::Value> argv[1] = { v8::Local<v8::Value> argv[1] = {
v8::Integer::NewFromUnsigned(length * TBytes)}; v8::Integer::NewFromUnsigned(length * TBytes, node::node_isolate)};
buffer = ArrayBuffer::GetTemplate()-> buffer = ArrayBuffer::GetTemplate()->
GetFunction()->NewInstance(1, argv); GetFunction()->NewInstance(1, argv);
if (buffer.IsEmpty()) return v8::Undefined(); // constructor failed // constructor failed
if (buffer.IsEmpty()) return v8::Undefined(node::node_isolate);
void* buf = buffer->GetAlignedPointerFromInternalField(0); void* buf = buffer->GetAlignedPointerFromInternalField(0);
args.This()->SetIndexedPropertiesToExternalArrayData( args.This()->SetIndexedPropertiesToExternalArrayData(
@ -339,13 +343,15 @@ class TypedArray {
buffer, buffer,
(v8::PropertyAttribute)(v8::ReadOnly|v8::DontDelete)); (v8::PropertyAttribute)(v8::ReadOnly|v8::DontDelete));
args.This()->Set(v8::String::New("length"), args.This()->Set(v8::String::New("length"),
v8::Integer::NewFromUnsigned(length), v8::Integer::NewFromUnsigned(length, node::node_isolate),
(v8::PropertyAttribute)(v8::ReadOnly|v8::DontDelete)); (v8::PropertyAttribute)(v8::ReadOnly|v8::DontDelete));
args.This()->Set(v8::String::New("byteOffset"), args.This()->Set(v8::String::New("byteOffset"),
v8::Integer::NewFromUnsigned(byte_offset), v8::Integer::NewFromUnsigned(byte_offset,
node::node_isolate),
(v8::PropertyAttribute)(v8::ReadOnly|v8::DontDelete)); (v8::PropertyAttribute)(v8::ReadOnly|v8::DontDelete));
args.This()->Set(v8::String::New("byteLength"), args.This()->Set(v8::String::New("byteLength"),
v8::Integer::NewFromUnsigned(length * TBytes), v8::Integer::NewFromUnsigned(length * TBytes,
node::node_isolate),
(v8::PropertyAttribute)(v8::ReadOnly|v8::DontDelete)); (v8::PropertyAttribute)(v8::ReadOnly|v8::DontDelete));
return args.This(); return args.This();
@ -358,7 +364,7 @@ class TypedArray {
if (args[0]->IsNumber()) if (args[0]->IsNumber())
return args.This()->Get(args[0]->Uint32Value()); return args.This()->Get(args[0]->Uint32Value());
return v8::Undefined(); return v8::Undefined(node::node_isolate);
} }
static v8::Handle<v8::Value> set(const v8::Arguments& args) { static v8::Handle<v8::Value> set(const v8::Arguments& args) {
@ -425,7 +431,7 @@ class TypedArray {
} }
} }
return v8::Undefined(); return v8::Undefined(node::node_isolate);
} }
static v8::Handle<v8::Value> subarray(const v8::Arguments& args) { static v8::Handle<v8::Value> subarray(const v8::Arguments& args) {
@ -454,8 +460,8 @@ class TypedArray {
// Call through to the ArrayBuffer, byteOffset, length constructor. // Call through to the ArrayBuffer, byteOffset, length constructor.
v8::Local<v8::Value> argv[] = { v8::Local<v8::Value> argv[] = {
args.This()->Get(v8::String::New("buffer")), args.This()->Get(v8::String::New("buffer")),
v8::Integer::New(byte_offset), v8::Integer::New(byte_offset, node::node_isolate),
v8::Integer::New(end - begin)}; v8::Integer::New(end - begin, node::node_isolate)};
return TypedArray<TBytes, TEAType>::GetTemplate()-> return TypedArray<TBytes, TEAType>::GetTemplate()->
GetFunction()->NewInstance(3, argv); GetFunction()->NewInstance(3, argv);
} }
@ -473,37 +479,37 @@ class Float64Array : public TypedArray<8, v8::kExternalDoubleArray> { };
template <typename T> template <typename T>
v8::Handle<v8::Value> cTypeToValue(T) { v8::Handle<v8::Value> cTypeToValue(T) {
return v8::Undefined(); return v8::Undefined(node::node_isolate);
} }
template <> template <>
v8::Handle<v8::Value> cTypeToValue(unsigned char val) { v8::Handle<v8::Value> cTypeToValue(unsigned char val) {
return v8::Integer::NewFromUnsigned(val); return v8::Integer::NewFromUnsigned(val, node::node_isolate);
} }
template <> template <>
v8::Handle<v8::Value> cTypeToValue(signed char val) { v8::Handle<v8::Value> cTypeToValue(signed char val) {
return v8::Integer::New(val); return v8::Integer::New(val, node::node_isolate);
} }
template <> template <>
v8::Handle<v8::Value> cTypeToValue(unsigned short val) { v8::Handle<v8::Value> cTypeToValue(unsigned short val) {
return v8::Integer::NewFromUnsigned(val); return v8::Integer::NewFromUnsigned(val, node::node_isolate);
} }
template <> template <>
v8::Handle<v8::Value> cTypeToValue(short val) { v8::Handle<v8::Value> cTypeToValue(short val) {
return v8::Integer::New(val); return v8::Integer::New(val, node::node_isolate);
} }
template <> template <>
v8::Handle<v8::Value> cTypeToValue(unsigned int val) { v8::Handle<v8::Value> cTypeToValue(unsigned int val) {
return v8::Integer::NewFromUnsigned(val); return v8::Integer::NewFromUnsigned(val, node::node_isolate);
} }
template <> template <>
v8::Handle<v8::Value> cTypeToValue(int val) { v8::Handle<v8::Value> cTypeToValue(int val) {
return v8::Integer::New(val); return v8::Integer::New(val, node::node_isolate);
} }
template <> template <>
@ -570,7 +576,7 @@ class DataView {
if (!ft_cache.IsEmpty()) if (!ft_cache.IsEmpty())
return ft_cache; return ft_cache;
v8::HandleScope scope; v8::HandleScope scope(node::node_isolate);
ft_cache = v8::Persistent<v8::FunctionTemplate>::New(node::node_isolate, ft_cache = v8::Persistent<v8::FunctionTemplate>::New(node::node_isolate,
v8::FunctionTemplate::New(&DataView::V8New)); v8::FunctionTemplate::New(&DataView::V8New));
ft_cache->SetClassName(v8::String::New("DataView")); ft_cache->SetClassName(v8::String::New("DataView"));
@ -659,10 +665,12 @@ class DataView {
buffer, buffer,
(v8::PropertyAttribute)(v8::ReadOnly|v8::DontDelete)); (v8::PropertyAttribute)(v8::ReadOnly|v8::DontDelete));
args.This()->Set(v8::String::New("byteOffset"), args.This()->Set(v8::String::New("byteOffset"),
v8::Integer::NewFromUnsigned(byte_offset), v8::Integer::NewFromUnsigned(byte_offset,
node::node_isolate),
(v8::PropertyAttribute)(v8::ReadOnly|v8::DontDelete)); (v8::PropertyAttribute)(v8::ReadOnly|v8::DontDelete));
args.This()->Set(v8::String::New("byteLength"), args.This()->Set(v8::String::New("byteLength"),
v8::Integer::NewFromUnsigned(byte_length), v8::Integer::NewFromUnsigned(byte_length,
node::node_isolate),
(v8::PropertyAttribute)(v8::ReadOnly|v8::DontDelete)); (v8::PropertyAttribute)(v8::ReadOnly|v8::DontDelete));
return args.This(); return args.This();
} }
@ -740,7 +748,7 @@ class DataView {
} else { } else {
memcpy(ptr, &val, sizeof(T)); memcpy(ptr, &val, sizeof(T));
} }
return v8::Undefined(); return v8::Undefined(node::node_isolate);
} }
static v8::Handle<v8::Value> getUint8(const v8::Arguments& args) { static v8::Handle<v8::Value> getUint8(const v8::Arguments& args) {
@ -814,7 +822,7 @@ class DataView {
namespace v8_typed_array { namespace v8_typed_array {
void AttachBindings(v8::Handle<v8::Object> obj) { void AttachBindings(v8::Handle<v8::Object> obj) {
v8::HandleScope scope; v8::HandleScope scope(node::node_isolate);
obj->Set(v8::String::New("ArrayBuffer"), obj->Set(v8::String::New("ArrayBuffer"),
ArrayBuffer::GetTemplate()->GetFunction()); ArrayBuffer::GetTemplate()->GetFunction());

Loading…
Cancel
Save