Navigation Menu

Skip to content
This repository has been archived by the owner on Apr 22, 2023. It is now read-only.

Commit

Permalink
src, test: downgrade to v8 3.14 api
Browse files Browse the repository at this point in the history
  • Loading branch information
bnoordhuis committed Feb 25, 2013
1 parent 03fe7fb commit 51f6e6a
Show file tree
Hide file tree
Showing 27 changed files with 382 additions and 396 deletions.
50 changes: 25 additions & 25 deletions src/cares_wrap.cc
Expand Up @@ -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, node_isolate), address); addresses->Set(Integer::New(i), address);
} }


return scope.Close(addresses); return scope.Close(addresses);
Expand All @@ -216,7 +216,7 @@ static Local<Array> HostentToNames(struct hostent* host) {


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, node_isolate), address); names->Set(Integer::New(i), address);
} }


return scope.Close(names); return scope.Close(names);
Expand Down Expand Up @@ -337,13 +337,13 @@ class QueryWrap {


void CallOnComplete(Local<Value> answer) { void CallOnComplete(Local<Value> answer) {
HandleScope scope; HandleScope scope;
Local<Value> argv[2] = { Integer::New(0, node_isolate), answer }; Local<Value> argv[2] = { Integer::New(0), 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;
Local<Value> argv[3] = { Integer::New(0, node_isolate), answer, family }; Local<Value> argv[3] = { Integer::New(0), answer, family };
MakeCallback(object_, oncomplete_sym, ARRAY_SIZE(argv), argv); MakeCallback(object_, oncomplete_sym, ARRAY_SIZE(argv), argv);
} }


Expand All @@ -352,7 +352,7 @@ class QueryWrap {
SetAresErrno(status); SetAresErrno(status);


HandleScope scope; HandleScope scope;
Local<Value> argv[1] = { Integer::New(-1, node_isolate) }; Local<Value> argv[1] = { Integer::New(-1) };
MakeCallback(object_, oncomplete_sym, ARRAY_SIZE(argv), argv); MakeCallback(object_, oncomplete_sym, ARRAY_SIZE(argv), argv);
} }


Expand Down Expand Up @@ -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, node_isolate)); Integer::New(mx_current->priority));
mx_records->Set(Integer::New(i++, node_isolate), mx_record); mx_records->Set(Integer::New(i++), mx_record);
} }


ares_free_data(mx_start); ares_free_data(mx_start);
Expand Down Expand Up @@ -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, node_isolate), txt); txt_records->Set(Integer::New(i), txt);
} }


ares_free_data(txt_out); ares_free_data(txt_out);
Expand Down Expand Up @@ -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, node_isolate)); Integer::New(srv_current->port));
srv_record->Set(priority_symbol, srv_record->Set(priority_symbol,
Integer::New(srv_current->priority, node_isolate)); Integer::New(srv_current->priority));
srv_record->Set(weight_symbol, srv_record->Set(weight_symbol,
Integer::New(srv_current->weight, node_isolate)); Integer::New(srv_current->weight));
srv_records->Set(Integer::New(i++, node_isolate), srv_record); srv_records->Set(Integer::New(i++), srv_record);
} }


ares_free_data(srv_start); ares_free_data(srv_start);
Expand Down Expand Up @@ -656,7 +656,7 @@ class GetHostByNameWrap: public QueryWrap {
HandleScope scope; HandleScope scope;


Local<Array> addresses = HostentToAddresses(host); Local<Array> addresses = HostentToAddresses(host);
Local<Integer> family = Integer::New(host->h_addrtype, node_isolate); Local<Integer> family = Integer::New(host->h_addrtype);


this->CallOnComplete(addresses, family); this->CallOnComplete(addresses, family);
} }
Expand All @@ -677,15 +677,15 @@ 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(node_isolate, wrap->GetObject()); Local<Object> object = Local<Object>::New(wrap->GetObject());


String::Utf8Value name(args[0]); String::Utf8Value name(args[0]);


int r = wrap->Send(*name); int r = wrap->Send(*name);
if (r) { if (r) {
SetAresErrno(r); SetAresErrno(r);
delete wrap; delete wrap;
return scope.Close(v8::Null(node_isolate)); return scope.Close(v8::Null());
} else { } else {
return scope.Close(object); return scope.Close(object);
} }
Expand All @@ -706,7 +706,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(node_isolate, wrap->GetObject()); Local<Object> object = Local<Object>::New(wrap->GetObject());


String::Utf8Value name(args[0]); String::Utf8Value name(args[0]);
int family = args[1]->Int32Value(); int family = args[1]->Int32Value();
Expand All @@ -715,7 +715,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(node_isolate)); return scope.Close(v8::Null());
} else { } else {
return scope.Close(object); return scope.Close(object);
} }
Expand All @@ -732,7 +732,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(node_isolate, Null(node_isolate)); argv[0] = Local<Value>::New(Null());
} else { } else {
// Success // Success
struct addrinfo *address; struct addrinfo *address;
Expand Down Expand Up @@ -824,14 +824,14 @@ static Handle<Value> IsIP(const Arguments& args) {
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, node_isolate)); return scope.Close(v8::Integer::New(4));
} }


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, node_isolate)); return scope.Close(v8::Integer::New(6));
} }


return scope.Close(v8::Integer::New(0, node_isolate)); return scope.Close(v8::Integer::New(0));
} }




Expand Down Expand Up @@ -871,7 +871,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(node_isolate)); return scope.Close(v8::Null());
} else { } else {
return scope.Close(req_wrap->object_); return scope.Close(req_wrap->object_);
} }
Expand Down Expand Up @@ -915,11 +915,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, node_isolate)); Integer::New(AF_INET));
target->Set(String::NewSymbol("AF_INET6"), target->Set(String::NewSymbol("AF_INET6"),
Integer::New(AF_INET6, node_isolate)); Integer::New(AF_INET6));
target->Set(String::NewSymbol("AF_UNSPEC"), target->Set(String::NewSymbol("AF_UNSPEC"),
Integer::New(AF_UNSPEC, node_isolate)); Integer::New(AF_UNSPEC));


oncomplete_sym = NODE_PSYMBOL("oncomplete"); oncomplete_sym = NODE_PSYMBOL("oncomplete");
} }
Expand Down
12 changes: 6 additions & 6 deletions src/fs_event_wrap.cc
Expand Up @@ -110,7 +110,7 @@ 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, node_isolate)); return scope.Close(Integer::New(r));
} }




Expand All @@ -136,7 +136,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(node_isolate); eventStr = String::Empty();
} }
else if (events & UV_RENAME) { else if (events & UV_RENAME) {
eventStr = String::New("rename"); eventStr = String::New("rename");
Expand All @@ -150,10 +150,10 @@ void FSEventWrap::OnEvent(uv_fs_event_t* handle, const char* filename,
} }


Local<Value> argv[3] = { Local<Value> argv[3] = {
Integer::New(status, node_isolate), Integer::New(status),
eventStr, eventStr,
filename ? static_cast<Local<Value> >(String::New(filename)) filename ? static_cast<Local<Value> >(String::New(filename))
: Local<Value>::New(node_isolate, v8::Null(node_isolate)) : Local<Value>::New(v8::Null())
}; };


if (onchange_sym.IsEmpty()) { if (onchange_sym.IsEmpty()) {
Expand All @@ -172,11 +172,11 @@ Handle<Value> FSEventWrap::Close(const Arguments& args) {
// and legal, HandleWrap::Close() deals with them the same way. // and legal, HandleWrap::Close() deals with them the same way.
assert(!args.Holder().IsEmpty()); assert(!args.Holder().IsEmpty());
assert(args.Holder()->InternalFieldCount() > 0); assert(args.Holder()->InternalFieldCount() > 0);
void* ptr = args.Holder()->GetAlignedPointerFromInternalField(0); void* ptr = args.Holder()->GetPointerFromInternalField(0);
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(node_isolate); return Undefined();
} }
wrap->initialized_ = false; wrap->initialized_ = false;


Expand Down
14 changes: 7 additions & 7 deletions src/handle_wrap.cc
Expand Up @@ -27,7 +27,7 @@
assert(!args.Holder().IsEmpty()); \ assert(!args.Holder().IsEmpty()); \
assert(args.Holder()->InternalFieldCount() > 0); \ assert(args.Holder()->InternalFieldCount() > 0); \
type* wrap = static_cast<type*>( \ type* wrap = static_cast<type*>( \
args.Holder()->GetAlignedPointerFromInternalField(0)); args.Holder()->GetPointerFromInternalField(0));


namespace node { namespace node {


Expand Down Expand Up @@ -66,7 +66,7 @@ Handle<Value> HandleWrap::Ref(const Arguments& args) {
wrap->unref_ = false; wrap->unref_ = false;
} }


return v8::Undefined(node_isolate); return v8::Undefined();
} }




Expand All @@ -80,15 +80,15 @@ Handle<Value> HandleWrap::Unref(const Arguments& args) {
wrap->unref_ = true; wrap->unref_ = true;
} }


return v8::Undefined(node_isolate); return v8::Undefined();
} }




Handle<Value> HandleWrap::Close(const Arguments& args) { Handle<Value> HandleWrap::Close(const Arguments& args) {
HandleScope scope; HandleScope scope;


HandleWrap *wrap = static_cast<HandleWrap*>( HandleWrap *wrap = static_cast<HandleWrap*>(
args.Holder()->GetAlignedPointerFromInternalField(0)); args.Holder()->GetPointerFromInternalField(0));


// guard against uninitialized handle or double close // guard against uninitialized handle or double close
if (wrap && wrap->handle__) { if (wrap && wrap->handle__) {
Expand All @@ -97,7 +97,7 @@ Handle<Value> HandleWrap::Close(const Arguments& args) {
wrap->handle__ = NULL; wrap->handle__ = NULL;
} }


return v8::Null(node_isolate); return v8::Null();
} }




Expand All @@ -112,7 +112,7 @@ HandleWrap::HandleWrap(Handle<Object> object, uv_handle_t* h) {
assert(object_.IsEmpty()); assert(object_.IsEmpty());
assert(object->InternalFieldCount() > 0); assert(object->InternalFieldCount() > 0);
object_ = v8::Persistent<v8::Object>::New(object); object_ = v8::Persistent<v8::Object>::New(object);
object_->SetAlignedPointerInInternalField(0, this); object_->SetPointerInInternalField(0, this);
ngx_queue_insert_tail(&handle_wrap_queue, &handle_wrap_queue_); ngx_queue_insert_tail(&handle_wrap_queue, &handle_wrap_queue_);
} }


Expand All @@ -138,7 +138,7 @@ void HandleWrap::OnClose(uv_handle_t* handle) {
// But the handle pointer should be gone. // But the handle pointer should be gone.
assert(wrap->handle__ == NULL); assert(wrap->handle__ == NULL);


wrap->object_->SetAlignedPointerInInternalField(0, NULL); wrap->object_->SetPointerInInternalField(0, NULL);
wrap->object_.Dispose(); wrap->object_.Dispose();
wrap->object_.Clear(); wrap->object_.Clear();


Expand Down

0 comments on commit 51f6e6a

Please sign in to comment.