From: Cheng Zhao Date: Thu, 27 Aug 2015 11:48:55 +0000 (+0800) Subject: IDWeakMap is not used anly more in JS X-Git-Tag: v0.31.1~4^2~2 X-Git-Url: http://git.khamidou.com/?a=commitdiff_plain;h=63eb4b72e2afdb7c0467e52172b017c804453cf2;p=electron.git IDWeakMap is not used anly more in JS --- diff --git a/atom/common/api/atom_api_id_weak_map.cc b/atom/common/api/atom_api_id_weak_map.cc deleted file mode 100644 index c5fbf093..00000000 --- a/atom/common/api/atom_api_id_weak_map.cc +++ /dev/null @@ -1,80 +0,0 @@ -// Copyright (c) 2013 GitHub, Inc. -// Use of this source code is governed by the MIT license that can be -// found in the LICENSE file. - -#include "atom/common/api/atom_api_id_weak_map.h" - -#include "native_mate/constructor.h" -#include "native_mate/object_template_builder.h" - -#include "atom/common/node_includes.h" - -namespace atom { - -namespace api { - -IDWeakMap::IDWeakMap() { -} - -IDWeakMap::~IDWeakMap() { -} - -int32_t IDWeakMap::Add(v8::Isolate* isolate, v8::Local object) { - return map_.Add(isolate, object); -} - -v8::Local IDWeakMap::Get(v8::Isolate* isolate, int32_t key) { - v8::MaybeLocal result = map_.Get(isolate, key); - if (result.IsEmpty()) { - isolate->ThrowException(v8::Exception::Error( - mate::StringToV8(isolate, "Invalid key"))); - return v8::Undefined(isolate); - } else { - return result.ToLocalChecked(); - } -} - -bool IDWeakMap::Has(int32_t key) const { - return map_.Has(key); -} - -std::vector IDWeakMap::Keys() const { - return map_.Keys(); -} - -void IDWeakMap::Remove(int32_t key) { - map_.Remove(key); -} - -// static -void IDWeakMap::BuildPrototype(v8::Isolate* isolate, - v8::Local prototype) { - mate::ObjectTemplateBuilder(isolate, prototype) - .SetMethod("add", &IDWeakMap::Add) - .SetMethod("get", &IDWeakMap::Get) - .SetMethod("has", &IDWeakMap::Has) - .SetMethod("keys", &IDWeakMap::Keys) - .SetMethod("remove", &IDWeakMap::Remove); -} - -} // namespace api - -} // namespace atom - - -namespace { - -void Initialize(v8::Local exports, v8::Local unused, - v8::Local context, void* priv) { - using atom::api::IDWeakMap; - v8::Isolate* isolate = context->GetIsolate(); - v8::Local constructor = mate::CreateConstructor( - isolate, - "IDWeakMap", - base::Bind(&mate::NewOperatorFactory)); - exports->Set(mate::StringToSymbol(isolate, "IDWeakMap"), constructor); -} - -} // namespace - -NODE_MODULE_CONTEXT_AWARE_BUILTIN(atom_common_id_weak_map, Initialize) diff --git a/atom/common/api/atom_api_id_weak_map.h b/atom/common/api/atom_api_id_weak_map.h deleted file mode 100644 index 955bd830..00000000 --- a/atom/common/api/atom_api_id_weak_map.h +++ /dev/null @@ -1,44 +0,0 @@ -// Copyright (c) 2013 GitHub, Inc. -// Copyright (c) 2012 Intel Corp. All rights reserved. -// Use of this source code is governed by the MIT license that can be -// found in the LICENSE file. - -#ifndef ATOM_COMMON_API_ATOM_API_ID_WEAK_MAP_H_ -#define ATOM_COMMON_API_ATOM_API_ID_WEAK_MAP_H_ - -#include - -#include "atom/common/id_weak_map.h" -#include "native_mate/wrappable.h" - -namespace atom { - -namespace api { - -// Like ES6's WeakMap, but the key is Integer and the value is Weak Pointer. -class IDWeakMap : public mate::Wrappable { - public: - IDWeakMap(); - - static void BuildPrototype(v8::Isolate* isolate, - v8::Local prototype); - - private: - virtual ~IDWeakMap(); - - int32_t Add(v8::Isolate* isolate, v8::Local object); - v8::Local Get(v8::Isolate* isolate, int32_t key); - bool Has(int32_t key) const; - std::vector Keys() const; - void Remove(int32_t key); - - atom::IDWeakMap map_; - - DISALLOW_COPY_AND_ASSIGN(IDWeakMap); -}; - -} // namespace api - -} // namespace atom - -#endif // ATOM_COMMON_API_ATOM_API_ID_WEAK_MAP_H_ diff --git a/atom/common/node_bindings.cc b/atom/common/node_bindings.cc index 8c03f145..5aed5619 100644 --- a/atom/common/node_bindings.cc +++ b/atom/common/node_bindings.cc @@ -47,7 +47,6 @@ REFERENCE_MODULE(atom_browser_window); REFERENCE_MODULE(atom_common_asar); REFERENCE_MODULE(atom_common_clipboard); REFERENCE_MODULE(atom_common_crash_reporter); -REFERENCE_MODULE(atom_common_id_weak_map); REFERENCE_MODULE(atom_common_native_image); REFERENCE_MODULE(atom_common_screen); REFERENCE_MODULE(atom_common_shell); diff --git a/filenames.gypi b/filenames.gypi index feb35789..af0c56e1 100644 --- a/filenames.gypi +++ b/filenames.gypi @@ -235,8 +235,6 @@ 'atom/common/api/atom_api_asar.cc', 'atom/common/api/atom_api_clipboard.cc', 'atom/common/api/atom_api_crash_reporter.cc', - 'atom/common/api/atom_api_id_weak_map.cc', - 'atom/common/api/atom_api_id_weak_map.h', 'atom/common/api/atom_api_native_image.cc', 'atom/common/api/atom_api_native_image.h', 'atom/common/api/atom_api_native_image_mac.mm',