Browse Source

MakeCallback: Return the callback return value

v0.9.1-release
isaacs 13 years ago
parent
commit
ac1aaddc00
  1. 11
      src/node.cc
  2. 31
      src/node.h

11
src/node.cc

@ -972,7 +972,7 @@ Handle<Value> FromConstructorTemplate(Persistent<FunctionTemplate>& t,
//
// Maybe make this a method of a node::Handle super class
//
void
Handle<Value>
MakeCallback(const Handle<Object> object,
const char* method,
int argc,
@ -981,7 +981,7 @@ MakeCallback(const Handle<Object> object,
return scope.Close(MakeCallback(object, String::NewSymbol(method), argc, argv));
}
void
Handle<Value>
MakeCallback(const Handle<Object> object,
const Handle<String> symbol,
int argc,
@ -996,9 +996,10 @@ MakeCallback(const Handle<Object> object,
assert(callback_v->IsFunction());
Local<Function> callback = Local<Function>::Cast(callback_v);
return scope.Close(MakeCallback(object, callback, argc, argv));
}
void
Handle<Value>
MakeCallback(const Handle<Object> object,
const Handle<Function> callback,
int argc,
@ -1009,11 +1010,13 @@ MakeCallback(const Handle<Object> object,
TryCatch try_catch;
callback->Call(object, argc, argv);
Local<Value> ret = callback->Call(object, argc, argv);
if (try_catch.HasCaught()) {
FatalException(try_catch);
}
return scope.Close(ret);
}

31
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<v8::Object> object,
const char* method,
int argc,
v8::Handle<v8::Value> argv[]);
NODE_EXTERN void MakeCallback(const v8::Handle<v8::Object> object,
const v8::Handle<v8::String> symbol,
int argc,
v8::Handle<v8::Value> argv[]);
NODE_EXTERN void MakeCallback(const v8::Handle<v8::Object> object,
const v8::Handle<v8::Function> callback,
int argc,
v8::Handle<v8::Value> argv[]);
NODE_EXTERN v8::Handle<v8::Value>
MakeCallback(const v8::Handle<v8::Object> object,
const char* method,
int argc,
v8::Handle<v8::Value> argv[]);
NODE_EXTERN v8::Handle<v8::Value>
MakeCallback(const v8::Handle<v8::Object> object,
const v8::Handle<v8::String> symbol,
int argc,
v8::Handle<v8::Value> argv[]);
NODE_EXTERN v8::Handle<v8::Value>
MakeCallback(const v8::Handle<v8::Object> object,
const v8::Handle<v8::Function> callback,
int argc,
v8::Handle<v8::Value> argv[]);
} // namespace node
#endif // SRC_NODE_H_

Loading…
Cancel
Save