2015-10-29 10:57:30 +00:00
|
|
|
// Copyright (c) 2015 GitHub, Inc.
|
|
|
|
// Use of this source code is governed by the MIT license that can be
|
|
|
|
// found in the LICENSE file.
|
|
|
|
|
2015-10-29 11:22:12 +00:00
|
|
|
#ifndef ATOM_COMMON_API_ATOM_API_ID_WEAK_MAP_H_
|
|
|
|
#define ATOM_COMMON_API_ATOM_API_ID_WEAK_MAP_H_
|
2015-10-29 10:57:30 +00:00
|
|
|
|
|
|
|
#include "atom/common/id_weak_map.h"
|
|
|
|
#include "native_mate/object_template_builder.h"
|
|
|
|
#include "native_mate/handle.h"
|
|
|
|
|
|
|
|
namespace atom {
|
|
|
|
|
|
|
|
namespace api {
|
|
|
|
|
2016-04-25 01:17:54 +00:00
|
|
|
class IDWeakMap : public mate::Wrappable<IDWeakMap> {
|
2015-10-29 10:57:30 +00:00
|
|
|
public:
|
2016-04-25 01:17:54 +00:00
|
|
|
static mate::WrappableBase* Create(v8::Isolate* isolate);
|
2015-10-29 10:57:30 +00:00
|
|
|
|
|
|
|
static void BuildPrototype(v8::Isolate* isolate,
|
|
|
|
v8::Local<v8::ObjectTemplate> prototype);
|
|
|
|
|
|
|
|
protected:
|
2016-04-25 01:17:54 +00:00
|
|
|
explicit IDWeakMap(v8::Isolate* isolate);
|
2015-10-30 03:04:40 +00:00
|
|
|
~IDWeakMap();
|
2015-10-29 10:57:30 +00:00
|
|
|
|
|
|
|
private:
|
|
|
|
// Api for IDWeakMap.
|
|
|
|
void Set(v8::Isolate* isolate, int32_t id, v8::Local<v8::Object> object);
|
|
|
|
v8::Local<v8::Object> Get(v8::Isolate* isolate, int32_t id);
|
|
|
|
bool Has(int32_t id);
|
|
|
|
void Remove(int32_t id);
|
2015-10-31 07:00:06 +00:00
|
|
|
void Clear();
|
2015-10-29 10:57:30 +00:00
|
|
|
|
2015-10-31 07:00:06 +00:00
|
|
|
atom::IDWeakMap id_weak_map_;
|
2015-10-29 10:57:30 +00:00
|
|
|
|
2015-10-29 11:22:12 +00:00
|
|
|
DISALLOW_COPY_AND_ASSIGN(IDWeakMap);
|
2015-10-29 10:57:30 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
} // namespace api
|
|
|
|
|
|
|
|
} // namespace atom
|
|
|
|
|
2015-10-29 11:22:12 +00:00
|
|
|
#endif // ATOM_COMMON_API_ATOM_API_ID_WEAK_MAP_H_
|