2015-06-23 11:46:37 +00:00
|
|
|
// Copyright (c) 2015 GitHub, Inc.
|
|
|
|
// Use of this source code is governed by the MIT license that can be
|
|
|
|
// found in the LICENSE file.
|
|
|
|
|
2015-08-07 11:34:00 +00:00
|
|
|
#include "atom/common/api/event_emitter_caller.h"
|
2015-06-23 11:46:37 +00:00
|
|
|
|
2015-08-07 11:34:00 +00:00
|
|
|
#include "atom/common/api/locker.h"
|
2015-09-07 08:29:54 +00:00
|
|
|
#include "atom/common/node_includes.h"
|
2015-08-07 07:18:33 +00:00
|
|
|
|
2015-06-23 11:46:37 +00:00
|
|
|
namespace mate {
|
|
|
|
|
|
|
|
namespace internal {
|
|
|
|
|
|
|
|
v8::Local<v8::Value> CallEmitWithArgs(v8::Isolate* isolate,
|
|
|
|
v8::Local<v8::Object> obj,
|
|
|
|
ValueVector* args) {
|
2015-08-07 07:18:33 +00:00
|
|
|
// Perform microtask checkpoint after running JavaScript.
|
2016-06-24 05:45:31 +00:00
|
|
|
v8::MicrotasksScope script_scope(
|
|
|
|
isolate, v8::MicrotasksScope::kRunMicrotasks);
|
2015-08-07 07:18:33 +00:00
|
|
|
// Use node::MakeCallback to call the callback, and it will also run pending
|
|
|
|
// tasks in Node.js.
|
2015-07-23 05:46:34 +00:00
|
|
|
return node::MakeCallback(
|
|
|
|
isolate, obj, "emit", args->size(), &args->front());
|
2015-06-23 11:46:37 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
} // namespace internal
|
|
|
|
|
|
|
|
} // namespace mate
|