refactor: ginify Menu (#22916)
This commit is contained in:
parent
1d158399a6
commit
6159066c26
14 changed files with 241 additions and 150 deletions
|
@ -21,7 +21,7 @@ v8::Local<v8::Value> CallMethodWithArgs(v8::Isolate* isolate,
|
|||
// Use node::MakeCallback to call the callback, and it will also run pending
|
||||
// tasks in Node.js.
|
||||
v8::MaybeLocal<v8::Value> ret = node::MakeCallback(
|
||||
isolate, obj, method, args->size(), &args->front(), {0, 0});
|
||||
isolate, obj, method, args->size(), args->data(), {0, 0});
|
||||
// If the JS function throws an exception (doesn't return a value) the result
|
||||
// of MakeCallback will be empty and therefore ToLocal will be false, in this
|
||||
// case we need to return "false" as that indicates that the event emitter did
|
||||
|
|
|
@ -69,11 +69,11 @@ v8::Local<v8::Value> CallMethod(v8::Isolate* isolate,
|
|||
gin::Wrappable<T>* object,
|
||||
const char* method_name,
|
||||
Args&&... args) {
|
||||
v8::HandleScope scope(isolate);
|
||||
v8::EscapableHandleScope scope(isolate);
|
||||
v8::Local<v8::Object> v8_object;
|
||||
if (object->GetWrapper(isolate).ToLocal(&v8_object))
|
||||
return CustomEmit(isolate, v8_object, method_name,
|
||||
std::forward<Args>(args)...);
|
||||
return scope.Escape(CustomEmit(isolate, v8_object, method_name,
|
||||
std::forward<Args>(args)...));
|
||||
else
|
||||
return v8::Local<v8::Value>();
|
||||
}
|
||||
|
|
|
@ -25,7 +25,7 @@ class Wrappable : public WrappableBase {
|
|||
template <typename Sig>
|
||||
static void SetConstructor(v8::Isolate* isolate,
|
||||
const base::Callback<Sig>& constructor) {
|
||||
v8::Local<v8::FunctionTemplate> templ = CreateFunctionTemplate(
|
||||
v8::Local<v8::FunctionTemplate> templ = gin_helper::CreateFunctionTemplate(
|
||||
isolate, base::Bind(&internal::InvokeNew<Sig>, constructor));
|
||||
templ->InstanceTemplate()->SetInternalFieldCount(1);
|
||||
T::BuildPrototype(isolate, templ);
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue