-
-
Notifications
You must be signed in to change notification settings - Fork 39
Expand file tree
/
Copy pathObjectManager.h
More file actions
31 lines (23 loc) · 995 Bytes
/
ObjectManager.h
File metadata and controls
31 lines (23 loc) · 995 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
#ifndef ObjectManager_h
#define ObjectManager_h
#include "Common.h"
namespace tns {
class ObjectManager;
struct ObjectWeakCallbackState {
ObjectWeakCallbackState(std::shared_ptr<v8::Persistent<v8::Value>> target) : target_(target) {
}
std::shared_ptr<v8::Persistent<v8::Value>> target_;
};
class ObjectManager {
public:
static void Init(v8::Isolate* isolate, v8::Local<v8::ObjectTemplate> globalTemplate);
static std::shared_ptr<v8::Persistent<v8::Value>> Register(v8::Local<v8::Context> context, const v8::Local<v8::Value> obj);
static void FinalizerCallback(const v8::WeakCallbackInfo<ObjectWeakCallbackState>& data);
static bool DisposeValue(v8::Isolate* isolate, v8::Local<v8::Value> value, bool isFinalDisposal = false);
private:
static void ReleaseNativeCounterpartCallback(const v8::FunctionCallbackInfo<v8::Value>& info);
static long GetRetainCount(id obj);
static bool IsInstanceOf(id obj, Class clazz);
};
}
#endif /* ObjectManager_h */