refactor: ginify Tray (#22822)

* refactor: ginify Tray

* lint

* improve argument parsing logic

* remove redundant imports from tray.js

* new Tray produces an instanceof Tray

* make Constructible generic

* lint

* clean up on exit
This commit is contained in:
Jeremy Apthorp 2020-03-29 18:32:02 -07:00 committed by GitHub
parent 76ae3b7ecb
commit a3e28788ce
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
16 changed files with 380 additions and 88 deletions

View file

@ -37,6 +37,24 @@ inline bool GetNextArgument(Arguments* args,
return true;
}
// Like gin::CreateFunctionTemplate, but doesn't remove the template's
// prototype.
template <typename Sig>
v8::Local<v8::FunctionTemplate> CreateConstructorFunctionTemplate(
v8::Isolate* isolate,
base::RepeatingCallback<Sig> callback,
InvokerOptions invoker_options = {}) {
typedef internal::CallbackHolder<Sig> HolderT;
HolderT* holder =
new HolderT(isolate, std::move(callback), std::move(invoker_options));
v8::Local<v8::FunctionTemplate> tmpl = v8::FunctionTemplate::New(
isolate, &internal::Dispatcher<Sig>::DispatchToCallback,
ConvertToV8<v8::Local<v8::External>>(isolate,
holder->GetHandle(isolate)));
return tmpl;
}
} // namespace gin
#endif // SHELL_COMMON_GIN_HELPER_FUNCTION_TEMPLATE_EXTENSIONS_H_