|
|
@ -109,6 +109,11 @@ static Persistent<String> listeners_symbol; |
|
|
|
static Persistent<String> uncaught_exception_symbol; |
|
|
|
static Persistent<String> emit_symbol; |
|
|
|
|
|
|
|
static Persistent<String> domain_symbol; |
|
|
|
static Persistent<String> enter_symbol; |
|
|
|
static Persistent<String> exit_symbol; |
|
|
|
static Persistent<String> disposed_symbol; |
|
|
|
|
|
|
|
|
|
|
|
static bool print_eval = false; |
|
|
|
static bool force_repl = false; |
|
|
@ -1017,10 +1022,47 @@ MakeCallback(const Handle<Object> object, |
|
|
|
|
|
|
|
TryCatch try_catch; |
|
|
|
|
|
|
|
if (domain_symbol.IsEmpty()) { |
|
|
|
domain_symbol = NODE_PSYMBOL("domain"); |
|
|
|
enter_symbol = NODE_PSYMBOL("enter"); |
|
|
|
exit_symbol = NODE_PSYMBOL("exit"); |
|
|
|
disposed_symbol = NODE_PSYMBOL("_disposed"); |
|
|
|
} |
|
|
|
|
|
|
|
Local<Value> domain_v = object->Get(domain_symbol); |
|
|
|
Local<Object> domain; |
|
|
|
Local<Function> enter; |
|
|
|
Local<Function> exit; |
|
|
|
if (!domain_v->IsUndefined()) { |
|
|
|
domain = domain_v->ToObject(); |
|
|
|
if (domain->Get(disposed_symbol)->BooleanValue()) { |
|
|
|
// domain has been disposed of.
|
|
|
|
return Undefined(); |
|
|
|
} |
|
|
|
enter = Local<Function>::Cast(domain->Get(enter_symbol)); |
|
|
|
enter->Call(domain, 0, NULL); |
|
|
|
} |
|
|
|
|
|
|
|
if (try_catch.HasCaught()) { |
|
|
|
FatalException(try_catch); |
|
|
|
return Undefined(); |
|
|
|
} |
|
|
|
|
|
|
|
Local<Value> ret = callback->Call(object, argc, argv); |
|
|
|
|
|
|
|
if (try_catch.HasCaught()) { |
|
|
|
FatalException(try_catch); |
|
|
|
return Undefined(); |
|
|
|
} |
|
|
|
|
|
|
|
if (!domain_v->IsUndefined()) { |
|
|
|
exit = Local<Function>::Cast(domain->Get(exit_symbol)); |
|
|
|
exit->Call(domain, 0, NULL); |
|
|
|
} |
|
|
|
|
|
|
|
if (try_catch.HasCaught()) { |
|
|
|
FatalException(try_catch); |
|
|
|
return Undefined(); |
|
|
|
} |
|
|
|
|
|
|
|
return scope.Close(ret); |
|
|
|