From: Cheng Zhao Date: Thu, 23 Jul 2015 05:46:34 +0000 (+0800) Subject: Use node::MakeCallback to emit events in C++ X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=eb92e9cdd80c518c2ac2bb87287cfdf9eb4dee0a;p=platform%2Fframework%2Fweb%2Fcrosswalk-tizen.git Use node::MakeCallback to emit events in C++ Fix #2165 --- diff --git a/atom/common/event_emitter_caller.cc b/atom/common/event_emitter_caller.cc index 85f56a2..3dbdc9d 100644 --- a/atom/common/event_emitter_caller.cc +++ b/atom/common/event_emitter_caller.cc @@ -4,6 +4,8 @@ #include "atom/common/event_emitter_caller.h" +#include "atom/common/node_includes.h" + namespace mate { namespace internal { @@ -11,21 +13,8 @@ namespace internal { v8::Local CallEmitWithArgs(v8::Isolate* isolate, v8::Local obj, ValueVector* args) { - v8::Local emit_name = StringToSymbol(isolate, "emit"); - v8::Local emit = obj->Get(emit_name); - if (emit.IsEmpty() || !emit->IsFunction()) { - isolate->ThrowException(v8::Exception::TypeError( - StringToV8(isolate, "\"emit\" is not a function"))); - return v8::Undefined(isolate); - } - - v8::MaybeLocal result = emit.As()->Call( - isolate->GetCurrentContext(), obj, args->size(), &args->front()); - if (result.IsEmpty()) { - return v8::Undefined(isolate); - } - - return result.ToLocalChecked(); + return node::MakeCallback( + isolate, obj, "emit", args->size(), &args->front()); } } // namespace internal