From ac1aaddc00103e7a2130d642fca90e0a5be18e16 Mon Sep 17 00:00:00 2001 From: isaacs Date: Fri, 13 Apr 2012 16:34:48 -0700 Subject: [PATCH] MakeCallback: Return the callback return value --- src/node.cc | 11 +++++++---- src/node.h | 31 +++++++++++++++++-------------- 2 files changed, 24 insertions(+), 18 deletions(-) diff --git a/src/node.cc b/src/node.cc index 4418eec998..26677eaeb6 100644 --- a/src/node.cc +++ b/src/node.cc @@ -972,7 +972,7 @@ Handle FromConstructorTemplate(Persistent& t, // // Maybe make this a method of a node::Handle super class // -void +Handle MakeCallback(const Handle object, const char* method, int argc, @@ -981,7 +981,7 @@ MakeCallback(const Handle object, return scope.Close(MakeCallback(object, String::NewSymbol(method), argc, argv)); } -void +Handle MakeCallback(const Handle object, const Handle symbol, int argc, @@ -996,9 +996,10 @@ MakeCallback(const Handle object, assert(callback_v->IsFunction()); Local callback = Local::Cast(callback_v); + return scope.Close(MakeCallback(object, callback, argc, argv)); } -void +Handle MakeCallback(const Handle object, const Handle callback, int argc, @@ -1009,11 +1010,13 @@ MakeCallback(const Handle object, TryCatch try_catch; - callback->Call(object, argc, argv); + Local ret = callback->Call(object, argc, argv); if (try_catch.HasCaught()) { FatalException(try_catch); } + + return scope.Close(ret); } diff --git a/src/node.h b/src/node.h index 7fb232b7c7..f7417c829f 100644 --- a/src/node.h +++ b/src/node.h @@ -243,19 +243,22 @@ node_module_struct* get_builtin_module(const char *name); extern "C" node::node_module_struct modname ## _module; NODE_EXTERN void SetErrno(uv_err_t err); -NODE_EXTERN void MakeCallback(const v8::Handle object, - const char* method, - int argc, - v8::Handle argv[]); - -NODE_EXTERN void MakeCallback(const v8::Handle object, - const v8::Handle symbol, - int argc, - v8::Handle argv[]); - -NODE_EXTERN void MakeCallback(const v8::Handle object, - const v8::Handle callback, - int argc, - v8::Handle argv[]); +NODE_EXTERN v8::Handle +MakeCallback(const v8::Handle object, + const char* method, + int argc, + v8::Handle argv[]); + +NODE_EXTERN v8::Handle +MakeCallback(const v8::Handle object, + const v8::Handle symbol, + int argc, + v8::Handle argv[]); + +NODE_EXTERN v8::Handle +MakeCallback(const v8::Handle object, + const v8::Handle callback, + int argc, + v8::Handle argv[]); } // namespace node #endif // SRC_NODE_H_