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

Commit

Permalink
node: revert removal of MakeCallback
Browse files Browse the repository at this point in the history
In 0168109 an implementation of MakeCallback was accidently removed. It
has been re-added.
  • Loading branch information
trevnorris authored and bnoordhuis committed Mar 17, 2013
1 parent f217b5e commit a0867e1
Showing 1 changed file with 25 additions and 15 deletions.
40 changes: 25 additions & 15 deletions src/node.cc
Original file line number Diff line number Diff line change
Expand Up @@ -901,9 +901,11 @@ Handle<Value> FromConstructorTemplate(Persistent<FunctionTemplate> t,

Handle<Value>
MakeDomainCallback(const Handle<Object> object,
const Handle<Function> callback,
int argc,
Handle<Value> argv[]) {
const Handle<Function> callback,
int argc,
Handle<Value> argv[]) {
// TODO Hook for long stack traces to be made here.

// lazy load _tickDomainCallback
if (process_tickDomainCallback.IsEmpty()) {
Local<Value> cb_v = process->Get(String::New("_tickDomainCallback"));
Expand Down Expand Up @@ -980,20 +982,11 @@ MakeDomainCallback(const Handle<Object> object,

Handle<Value>
MakeCallback(const Handle<Object> object,
const Handle<String> symbol,
const Handle<Function> callback,
int argc,
Handle<Value> argv[]) {
HandleScope scope;

Local<Function> callback = object->Get(symbol).As<Function>();
Local<Value> domain = object->Get(domain_symbol);

// TODO Hook for long stack traces to be made here.

// has domain, off with you
if (!domain->IsNull() && !domain->IsUndefined())
return scope.Close(MakeDomainCallback(object, callback, argc, argv));

// lazy load no domain next tick callbacks
if (process_tickCallback.IsEmpty()) {
Local<Value> cb_v = process->Get(String::New("_tickCallback"));
Expand All @@ -1017,7 +1010,7 @@ MakeCallback(const Handle<Object> object,
if (tick_infobox.length == 0) {
tick_infobox.index = 0;
tick_infobox.depth = 0;
return scope.Close(ret);
return ret;
}

// process nextTicks after call
Expand All @@ -1028,7 +1021,24 @@ MakeCallback(const Handle<Object> object,
return Undefined();
}

return scope.Close(ret);
return ret;
}


Handle<Value>
MakeCallback(const Handle<Object> object,
const Handle<String> symbol,
int argc,
Handle<Value> argv[]) {
HandleScope scope;

Local<Function> callback = object->Get(symbol).As<Function>();
Local<Value> domain = object->Get(domain_symbol);

// has domain, off with you
if (!domain->IsNull() && !domain->IsUndefined())
return scope.Close(MakeDomainCallback(object, callback, argc, argv));
return scope.Close(MakeCallback(object, callback, argc, argv));
}


Expand Down

0 comments on commit a0867e1

Please sign in to comment.