Use create function instead of IDWeakMap constructor
This commit is contained in:
parent
c708ae8eb5
commit
04d59991b0
4 changed files with 14 additions and 18 deletions
|
@ -5,7 +5,6 @@
|
|||
#include "atom/common/api/atom_api_id_weak_map.h"
|
||||
|
||||
#include "atom/common/node_includes.h"
|
||||
#include "native_mate/constructor.h"
|
||||
#include "native_mate/dictionary.h"
|
||||
|
||||
namespace atom {
|
||||
|
@ -13,6 +12,7 @@ namespace atom {
|
|||
namespace api {
|
||||
|
||||
IDWeakMap::IDWeakMap(v8::Isolate* isolate) {
|
||||
Init(isolate);
|
||||
}
|
||||
|
||||
IDWeakMap::~IDWeakMap() {
|
||||
|
@ -47,8 +47,8 @@ void IDWeakMap::BuildPrototype(v8::Isolate* isolate,
|
|||
}
|
||||
|
||||
// static
|
||||
mate::WrappableBase* IDWeakMap::Create(v8::Isolate* isolate) {
|
||||
return new IDWeakMap(isolate);
|
||||
mate::Handle<IDWeakMap> IDWeakMap::Create(v8::Isolate* isolate) {
|
||||
return mate::CreateHandle(isolate, new IDWeakMap(isolate));
|
||||
}
|
||||
|
||||
} // namespace api
|
||||
|
@ -61,12 +61,8 @@ using atom::api::IDWeakMap;
|
|||
|
||||
void Initialize(v8::Local<v8::Object> exports, v8::Local<v8::Value> unused,
|
||||
v8::Local<v8::Context> context, void* priv) {
|
||||
v8::Isolate* isolate = context->GetIsolate();
|
||||
v8::Local<v8::Function> constructor = mate::CreateConstructor<IDWeakMap>(
|
||||
isolate, "IDWeakMap", base::Bind(&IDWeakMap::Create));
|
||||
mate::Dictionary id_weak_map(isolate, constructor);
|
||||
mate::Dictionary dict(isolate, exports);
|
||||
dict.Set("IDWeakMap", id_weak_map);
|
||||
mate::Dictionary dict(context->GetIsolate(), exports);
|
||||
dict.SetMethod("createIDWeakMap", &atom::api::IDWeakMap::Create);
|
||||
}
|
||||
|
||||
} // namespace
|
||||
|
|
|
@ -15,7 +15,7 @@ namespace api {
|
|||
|
||||
class IDWeakMap : public mate::Wrappable<IDWeakMap> {
|
||||
public:
|
||||
static mate::WrappableBase* Create(v8::Isolate* isolate);
|
||||
static mate::Handle<IDWeakMap> Create(v8::Isolate* isolate);
|
||||
|
||||
static void BuildPrototype(v8::Isolate* isolate,
|
||||
v8::Local<v8::ObjectTemplate> prototype);
|
||||
|
|
|
@ -1,10 +1,11 @@
|
|||
'use strict'
|
||||
|
||||
const electron = require('electron')
|
||||
const ipcMain = electron.ipcMain
|
||||
const objectsRegistry = require('./objects-registry')
|
||||
const v8Util = process.atomBinding('v8_util')
|
||||
const IDWeakMap = process.atomBinding('id_weak_map').IDWeakMap
|
||||
const {ipcMain} = electron
|
||||
const {createIDWeakMap} = process.atomBinding('id_weak_map')
|
||||
|
||||
const objectsRegistry = require('./objects-registry')
|
||||
|
||||
// The internal properties of Function.
|
||||
const FUNCTION_PROPERTIES = [
|
||||
|
@ -13,7 +14,7 @@ const FUNCTION_PROPERTIES = [
|
|||
|
||||
// The remote functions in renderer processes.
|
||||
// id => Function
|
||||
let rendererFunctions = new IDWeakMap()
|
||||
let rendererFunctions = createIDWeakMap()
|
||||
|
||||
// Merge two IDs together.
|
||||
let mergeIds = function (webContentsId, metaId) {
|
||||
|
|
|
@ -1,15 +1,14 @@
|
|||
'use strict'
|
||||
|
||||
const ipcRenderer = require('electron').ipcRenderer
|
||||
const CallbacksRegistry = require('electron').CallbacksRegistry
|
||||
const v8Util = process.atomBinding('v8_util')
|
||||
const IDWeakMap = process.atomBinding('id_weak_map').IDWeakMap
|
||||
const {ipcRenderer, CallbacksRegistry} = require('electron')
|
||||
const {createIDWeakMap} = process.atomBinding('id_weak_map')
|
||||
|
||||
const callbacksRegistry = new CallbacksRegistry()
|
||||
|
||||
var includes = [].includes
|
||||
|
||||
var remoteObjectCache = new IDWeakMap()
|
||||
var remoteObjectCache = createIDWeakMap()
|
||||
|
||||
// Check for circular reference.
|
||||
var isCircular = function (field, visited) {
|
||||
|
|
Loading…
Reference in a new issue