chore: remove native_mate (Part 14) (#21365)
* chore: remove uses of mate::Dictionary and mate::Handle * chore: move CreateConstructor to gin_helper * chore: remove native_mate * chore: remove unneeded gin patch
This commit is contained in:
parent
113b47d871
commit
0a741670a9
74 changed files with 215 additions and 2120 deletions
|
@ -6,18 +6,18 @@
|
|||
|
||||
#include <vector>
|
||||
|
||||
#include "native_mate/wrappable.h"
|
||||
#include "shell/common/asar/archive.h"
|
||||
#include "shell/common/asar/asar_util.h"
|
||||
#include "shell/common/gin_converters/callback_converter.h"
|
||||
#include "shell/common/gin_converters/file_path_converter.h"
|
||||
#include "shell/common/gin_helper/dictionary.h"
|
||||
#include "shell/common/gin_helper/object_template_builder.h"
|
||||
#include "shell/common/gin_helper/wrappable.h"
|
||||
#include "shell/common/node_includes.h"
|
||||
#include "shell/common/node_util.h"
|
||||
namespace {
|
||||
|
||||
class Archive : public mate::Wrappable<Archive> {
|
||||
class Archive : public gin_helper::Wrappable<Archive> {
|
||||
public:
|
||||
static v8::Local<v8::Value> Create(v8::Isolate* isolate,
|
||||
const base::FilePath& path) {
|
||||
|
|
|
@ -5,10 +5,10 @@
|
|||
#ifndef SHELL_COMMON_API_ATOM_API_KEY_WEAK_MAP_H_
|
||||
#define SHELL_COMMON_API_ATOM_API_KEY_WEAK_MAP_H_
|
||||
|
||||
#include "native_mate/handle.h"
|
||||
#include "native_mate/wrappable.h"
|
||||
#include "gin/handle.h"
|
||||
#include "shell/common/gin_converters/std_converter.h"
|
||||
#include "shell/common/gin_helper/object_template_builder.h"
|
||||
#include "shell/common/gin_helper/wrappable.h"
|
||||
#include "shell/common/key_weak_map.h"
|
||||
|
||||
namespace electron {
|
||||
|
@ -16,10 +16,10 @@ namespace electron {
|
|||
namespace api {
|
||||
|
||||
template <typename K>
|
||||
class KeyWeakMap : public mate::Wrappable<KeyWeakMap<K>> {
|
||||
class KeyWeakMap : public gin_helper::Wrappable<KeyWeakMap<K>> {
|
||||
public:
|
||||
static mate::Handle<KeyWeakMap<K>> Create(v8::Isolate* isolate) {
|
||||
return mate::CreateHandle(isolate, new KeyWeakMap<K>(isolate));
|
||||
static gin::Handle<KeyWeakMap<K>> Create(v8::Isolate* isolate) {
|
||||
return gin::CreateHandle(isolate, new KeyWeakMap<K>(isolate));
|
||||
}
|
||||
|
||||
static void BuildPrototype(v8::Isolate* isolate,
|
||||
|
@ -34,7 +34,7 @@ class KeyWeakMap : public mate::Wrappable<KeyWeakMap<K>> {
|
|||
|
||||
protected:
|
||||
explicit KeyWeakMap(v8::Isolate* isolate) {
|
||||
mate::Wrappable<KeyWeakMap<K>>::Init(isolate);
|
||||
gin_helper::Wrappable<KeyWeakMap<K>>::Init(isolate);
|
||||
}
|
||||
~KeyWeakMap() override {}
|
||||
|
||||
|
|
|
@ -558,8 +558,8 @@ bool Converter<electron::api::NativeImage*>::FromV8(
|
|||
}
|
||||
|
||||
*out = static_cast<electron::api::NativeImage*>(
|
||||
static_cast<mate::WrappableBase*>(
|
||||
mate::internal::FromV8Impl(isolate, val)));
|
||||
static_cast<gin_helper::WrappableBase*>(
|
||||
gin_helper::internal::FromV8Impl(isolate, val)));
|
||||
return *out != nullptr;
|
||||
}
|
||||
|
||||
|
|
|
@ -10,8 +10,8 @@
|
|||
|
||||
#include "base/values.h"
|
||||
#include "gin/handle.h"
|
||||
#include "native_mate/wrappable.h"
|
||||
#include "shell/common/gin_helper/error_thrower.h"
|
||||
#include "shell/common/gin_helper/wrappable.h"
|
||||
#include "ui/gfx/image/image.h"
|
||||
|
||||
#if defined(OS_WIN)
|
||||
|
@ -38,7 +38,7 @@ namespace electron {
|
|||
|
||||
namespace api {
|
||||
|
||||
class NativeImage : public mate::Wrappable<NativeImage> {
|
||||
class NativeImage : public gin_helper::Wrappable<NativeImage> {
|
||||
public:
|
||||
static gin::Handle<NativeImage> CreateEmpty(v8::Isolate* isolate);
|
||||
static gin::Handle<NativeImage> Create(v8::Isolate* isolate,
|
||||
|
|
|
@ -1,34 +0,0 @@
|
|||
// Copyright (c) 2018 GitHub, Inc.
|
||||
// Use of this source code is governed by the MIT license that can be
|
||||
// found in the LICENSE file.
|
||||
|
||||
#ifndef SHELL_COMMON_API_CONSTRUCTOR_H_
|
||||
#define SHELL_COMMON_API_CONSTRUCTOR_H_
|
||||
|
||||
#include "native_mate/constructor.h"
|
||||
|
||||
namespace mate {
|
||||
|
||||
// Create a FunctionTemplate that can be "new"ed in JavaScript.
|
||||
// It is user's responsibility to ensure this function is called for one type
|
||||
// only ONCE in the program's whole lifetime, otherwise we would have memory
|
||||
// leak.
|
||||
template <typename T, typename Sig>
|
||||
v8::Local<v8::Function> CreateConstructor(
|
||||
v8::Isolate* isolate,
|
||||
const base::RepeatingCallback<Sig>& func) {
|
||||
#ifndef NDEBUG
|
||||
static bool called = false;
|
||||
CHECK(!called) << "CreateConstructor can only be called for one type once";
|
||||
called = true;
|
||||
#endif
|
||||
v8::Local<v8::FunctionTemplate> templ = CreateFunctionTemplate(
|
||||
isolate, base::BindRepeating(&mate::internal::InvokeNew<Sig>, func));
|
||||
templ->InstanceTemplate()->SetInternalFieldCount(1);
|
||||
T::BuildPrototype(isolate, templ);
|
||||
return templ->GetFunction(isolate->GetCurrentContext()).ToLocalChecked();
|
||||
}
|
||||
|
||||
} // namespace mate
|
||||
|
||||
#endif // SHELL_COMMON_API_CONSTRUCTOR_H_
|
|
@ -3,8 +3,8 @@
|
|||
// found in the LICENSE file.
|
||||
|
||||
#include "electron/buildflags/buildflags.h"
|
||||
#include "native_mate/dictionary.h"
|
||||
#include "printing/buildflags/buildflags.h"
|
||||
#include "shell/common/gin_helper/dictionary.h"
|
||||
#include "shell/common/node_includes.h"
|
||||
|
||||
namespace {
|
||||
|
@ -65,7 +65,7 @@ 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("isDesktopCapturerEnabled", &IsDesktopCapturerEnabled);
|
||||
dict.SetMethod("isOffscreenRenderingEnabled", &IsOffscreenRenderingEnabled);
|
||||
dict.SetMethod("isRemoteModuleEnabled", &IsRemoteModuleEnabled);
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue