electron/atom/common/api/atom_api_id_weak_map.h

45 lines
1.1 KiB
C
Raw Normal View History

// Copyright (c) 2013 GitHub, Inc.
2013-04-25 13:46:04 +00:00
// Copyright (c) 2012 Intel Corp. All rights reserved.
2014-04-25 09:49:37 +00:00
// Use of this source code is governed by the MIT license that can be
2013-04-25 13:46:04 +00:00
// found in the LICENSE file.
2013-04-29 12:40:59 +00:00
#ifndef ATOM_COMMON_API_ATOM_API_ID_WEAK_MAP_H_
#define ATOM_COMMON_API_ATOM_API_ID_WEAK_MAP_H_
2013-04-25 13:46:04 +00:00
#include <vector>
2013-04-25 13:46:04 +00:00
#include "atom/common/id_weak_map.h"
#include "native_mate/wrappable.h"
2013-04-25 13:46:04 +00:00
namespace atom {
namespace api {
2014-03-16 01:37:04 +00:00
// Like ES6's WeakMap, but the key is Integer and the value is Weak Pointer.
2014-04-16 03:58:48 +00:00
class IDWeakMap : public mate::Wrappable {
2013-04-25 13:46:04 +00:00
public:
IDWeakMap();
2014-04-16 03:58:48 +00:00
static void BuildPrototype(v8::Isolate* isolate,
2015-05-22 11:11:22 +00:00
v8::Local<v8::ObjectTemplate> prototype);
2013-04-25 13:46:04 +00:00
private:
virtual ~IDWeakMap();
2015-05-22 11:11:22 +00:00
int32_t Add(v8::Isolate* isolate, v8::Local<v8::Object> object);
v8::Local<v8::Value> Get(v8::Isolate* isolate, int32_t key);
bool Has(int32_t key) const;
std::vector<int32_t> Keys() const;
void Remove(int32_t key);
2013-04-25 13:46:04 +00:00
atom::IDWeakMap map_;
2013-04-25 13:46:04 +00:00
DISALLOW_COPY_AND_ASSIGN(IDWeakMap);
};
} // namespace api
} // namespace atom
2013-04-29 12:40:59 +00:00
#endif // ATOM_COMMON_API_ATOM_API_ID_WEAK_MAP_H_