chore: remove native_mate (Part 5) (#20264)
* deprecate native_mate/native_mate/object_template_builder.h * add gin_helper/object_template_builder.h * add patch to avoid ambiguous error * remove usage of object_template_builder_deprecated.h in a few files * add note we should remove gin_helper/object_template_builder.h in future
This commit is contained in:
parent
63f08fcdb0
commit
624ba4f642
39 changed files with 474 additions and 121 deletions
|
@ -7,7 +7,7 @@
|
|||
#include <vector>
|
||||
|
||||
#include "native_mate/arguments.h"
|
||||
#include "native_mate/object_template_builder.h"
|
||||
#include "native_mate/object_template_builder_deprecated.h"
|
||||
#include "native_mate/wrappable.h"
|
||||
#include "shell/common/asar/archive.h"
|
||||
#include "shell/common/gin_converters/callback_converter.h"
|
||||
|
|
|
@ -6,8 +6,9 @@
|
|||
#define SHELL_COMMON_API_ATOM_API_KEY_WEAK_MAP_H_
|
||||
|
||||
#include "native_mate/handle.h"
|
||||
#include "native_mate/object_template_builder.h"
|
||||
#include "native_mate/wrappable.h"
|
||||
#include "shell/common/gin_converters/std_converter.h"
|
||||
#include "shell/common/gin_helper/object_template_builder.h"
|
||||
#include "shell/common/key_weak_map.h"
|
||||
|
||||
namespace electron {
|
||||
|
@ -23,8 +24,8 @@ class KeyWeakMap : public mate::Wrappable<KeyWeakMap<K>> {
|
|||
|
||||
static void BuildPrototype(v8::Isolate* isolate,
|
||||
v8::Local<v8::FunctionTemplate> prototype) {
|
||||
prototype->SetClassName(mate::StringToV8(isolate, "KeyWeakMap"));
|
||||
mate::ObjectTemplateBuilder(isolate, prototype->PrototypeTemplate())
|
||||
prototype->SetClassName(gin::StringToV8(isolate, "KeyWeakMap"));
|
||||
gin_helper::ObjectTemplateBuilder(isolate, prototype->PrototypeTemplate())
|
||||
.SetMethod("set", &KeyWeakMap<K>::Set)
|
||||
.SetMethod("get", &KeyWeakMap<K>::Get)
|
||||
.SetMethod("has", &KeyWeakMap<K>::Has)
|
||||
|
@ -60,4 +61,22 @@ class KeyWeakMap : public mate::Wrappable<KeyWeakMap<K>> {
|
|||
|
||||
} // namespace electron
|
||||
|
||||
namespace gin {
|
||||
|
||||
// TODO(zcbenz): Remove this after converting KeyWeakMap to gin::Wrapper.
|
||||
template <typename T>
|
||||
struct Converter<electron::api::KeyWeakMap<T>*> {
|
||||
static bool FromV8(v8::Isolate* isolate,
|
||||
v8::Local<v8::Value> val,
|
||||
electron::api::KeyWeakMap<T>** out) {
|
||||
return mate::ConvertFromV8(isolate, val, out);
|
||||
}
|
||||
static v8::Local<v8::Value> ToV8(v8::Isolate* isolate,
|
||||
electron::api::KeyWeakMap<T>* in) {
|
||||
return mate::ConvertToV8(isolate, in);
|
||||
}
|
||||
};
|
||||
|
||||
} // namespace gin
|
||||
|
||||
#endif // SHELL_COMMON_API_ATOM_API_KEY_WEAK_MAP_H_
|
||||
|
|
|
@ -13,7 +13,7 @@
|
|||
#include "base/strings/pattern.h"
|
||||
#include "base/strings/string_util.h"
|
||||
#include "base/threading/thread_restrictions.h"
|
||||
#include "native_mate/object_template_builder.h"
|
||||
#include "native_mate/object_template_builder_deprecated.h"
|
||||
#include "net/base/data_url.h"
|
||||
#include "shell/common/asar/asar_util.h"
|
||||
#include "shell/common/native_mate_converters/file_path_converter.h"
|
||||
|
|
|
@ -7,9 +7,9 @@
|
|||
|
||||
#include "base/hash/hash.h"
|
||||
#include "electron/buildflags/buildflags.h"
|
||||
#include "native_mate/dictionary.h"
|
||||
#include "shell/common/native_mate_converters/content_converter.h"
|
||||
#include "shell/common/native_mate_converters/gurl_converter.h"
|
||||
#include "shell/common/gin_converters/gurl_converter.h"
|
||||
#include "shell/common/gin_converters/native_mate_handle_converter.h"
|
||||
#include "shell/common/gin_helper/dictionary.h"
|
||||
#include "shell/common/node_includes.h"
|
||||
#include "url/origin.h"
|
||||
#include "v8/include/v8-profiler.h"
|
||||
|
@ -20,6 +20,10 @@
|
|||
#include "shell/common/api/remote/remote_object_freer.h"
|
||||
#endif
|
||||
|
||||
// TODO(zcbenz): Remove the includes after removing native_mate.
|
||||
#include "native_mate/dictionary.h"
|
||||
#include "shell/common/native_mate_converters/content_converter.h"
|
||||
|
||||
namespace std {
|
||||
|
||||
// The hash function used by DoubleIDWeakMap.
|
||||
|
@ -32,7 +36,7 @@ struct hash<std::pair<Type1, Type2>> {
|
|||
|
||||
} // namespace std
|
||||
|
||||
namespace mate {
|
||||
namespace gin {
|
||||
|
||||
template <typename Type1, typename Type2>
|
||||
struct Converter<std::pair<Type1, Type2>> {
|
||||
|
@ -54,7 +58,7 @@ struct Converter<std::pair<Type1, Type2>> {
|
|||
}
|
||||
};
|
||||
|
||||
} // namespace mate
|
||||
} // namespace gin
|
||||
|
||||
namespace {
|
||||
|
||||
|
@ -115,15 +119,18 @@ void Initialize(v8::Local<v8::Object> exports,
|
|||
v8::Local<v8::Value> unused,
|
||||
v8::Local<v8::Context> context,
|
||||
void* priv) {
|
||||
mate::Dictionary dict(context->GetIsolate(), exports);
|
||||
gin_helper::Dictionary dict(context->GetIsolate(), exports);
|
||||
dict.SetMethod("getHiddenValue", &GetHiddenValue);
|
||||
dict.SetMethod("setHiddenValue", &SetHiddenValue);
|
||||
dict.SetMethod("deleteHiddenValue", &DeleteHiddenValue);
|
||||
dict.SetMethod("getObjectHash", &GetObjectHash);
|
||||
dict.SetMethod("takeHeapSnapshot", &TakeHeapSnapshot);
|
||||
#if BUILDFLAG(ENABLE_REMOTE_MODULE)
|
||||
dict.SetMethod("setRemoteCallbackFreer",
|
||||
&electron::RemoteCallbackFreer::BindTo);
|
||||
// TODO(zcbenz): Use gin_helper::Dictionary when content_converter.h is moved
|
||||
// to gin.
|
||||
mate::Dictionary mdict(context->GetIsolate(), exports);
|
||||
mdict.SetMethod("setRemoteCallbackFreer",
|
||||
&electron::RemoteCallbackFreer::BindTo);
|
||||
dict.SetMethod("setRemoteObjectFreer", &electron::RemoteObjectFreer::BindTo);
|
||||
dict.SetMethod("addRemoteObjectRef", &electron::RemoteObjectFreer::AddRef);
|
||||
dict.SetMethod("createIDWeakMap",
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue