refactor: ginify desktopCapturer (#22746)
This commit is contained in:
parent
9aa27e1709
commit
a824e12275
5 changed files with 54 additions and 28 deletions
|
@ -9,6 +9,7 @@
|
|||
#include <vector>
|
||||
|
||||
#include "gin/converter.h"
|
||||
#include "gin/wrappable.h"
|
||||
|
||||
namespace gin_helper {
|
||||
|
||||
|
@ -63,6 +64,28 @@ v8::Local<v8::Value> CustomEmit(v8::Isolate* isolate,
|
|||
&converted_args);
|
||||
}
|
||||
|
||||
template <typename T, typename... Args>
|
||||
v8::Local<v8::Value> CallMethod(v8::Isolate* isolate,
|
||||
gin::Wrappable<T>* object,
|
||||
const char* method_name,
|
||||
Args&&... args) {
|
||||
v8::HandleScope 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)...);
|
||||
else
|
||||
return v8::Local<v8::Value>();
|
||||
}
|
||||
|
||||
template <typename T, typename... Args>
|
||||
v8::Local<v8::Value> CallMethod(gin::Wrappable<T>* object,
|
||||
const char* method_name,
|
||||
Args&&... args) {
|
||||
v8::Isolate* isolate = v8::Isolate::GetCurrent();
|
||||
return CallMethod(isolate, object, method_name, std::forward<Args>(args)...);
|
||||
}
|
||||
|
||||
} // namespace gin_helper
|
||||
|
||||
#endif // SHELL_COMMON_GIN_HELPER_EVENT_EMITTER_CALLER_H_
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue