parent
5a980497e8
commit
eb92e9cdd8
1 changed files with 4 additions and 15 deletions
|
@ -4,6 +4,8 @@
|
||||||
|
|
||||||
#include "atom/common/event_emitter_caller.h"
|
#include "atom/common/event_emitter_caller.h"
|
||||||
|
|
||||||
|
#include "atom/common/node_includes.h"
|
||||||
|
|
||||||
namespace mate {
|
namespace mate {
|
||||||
|
|
||||||
namespace internal {
|
namespace internal {
|
||||||
|
@ -11,21 +13,8 @@ namespace internal {
|
||||||
v8::Local<v8::Value> CallEmitWithArgs(v8::Isolate* isolate,
|
v8::Local<v8::Value> CallEmitWithArgs(v8::Isolate* isolate,
|
||||||
v8::Local<v8::Object> obj,
|
v8::Local<v8::Object> obj,
|
||||||
ValueVector* args) {
|
ValueVector* args) {
|
||||||
v8::Local<v8::String> emit_name = StringToSymbol(isolate, "emit");
|
return node::MakeCallback(
|
||||||
v8::Local<v8::Value> emit = obj->Get(emit_name);
|
isolate, obj, "emit", args->size(), &args->front());
|
||||||
if (emit.IsEmpty() || !emit->IsFunction()) {
|
|
||||||
isolate->ThrowException(v8::Exception::TypeError(
|
|
||||||
StringToV8(isolate, "\"emit\" is not a function")));
|
|
||||||
return v8::Undefined(isolate);
|
|
||||||
}
|
|
||||||
|
|
||||||
v8::MaybeLocal<v8::Value> result = emit.As<v8::Function>()->Call(
|
|
||||||
isolate->GetCurrentContext(), obj, args->size(), &args->front());
|
|
||||||
if (result.IsEmpty()) {
|
|
||||||
return v8::Undefined(isolate);
|
|
||||||
}
|
|
||||||
|
|
||||||
return result.ToLocalChecked();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
} // namespace internal
|
} // namespace internal
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue