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 {
|
|
|
|
|
2016-10-26 09:10:15 +00:00
|
|
|
v8::Local<v8::Value> CallMethodWithArgs(v8::Isolate* isolate,
|
|
|
|
v8::Local<v8::Object> obj,
|
|
|
|
const char* method,
|
|
|
|
ValueVector* args) {
|
2015-08-07 07:18:33 +00:00
|
|
|
// Perform microtask checkpoint after running JavaScript.
|
2016-10-26 09:10:15 +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.
|
2017-07-11 17:09:02 +00:00
|
|
|
return node::MakeCallback(isolate, obj, method, args->size(), &args->front(),
|
2017-08-28 07:17:33 +00:00
|
|
|
{0, 0}).ToLocalChecked();
|
2015-06-23 11:46:37 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
} // namespace internal
|
|
|
|
|
|
|
|
} // namespace mate
|