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:
Cheng Zhao 2019-09-19 11:09:15 -04:00 committed by Shelley Vohr
parent 63f08fcdb0
commit 624ba4f642
39 changed files with 474 additions and 121 deletions

View file

@ -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_