-
Notifications
You must be signed in to change notification settings - Fork 2
/
Wrappable.h
66 lines (45 loc) · 1.8 KB
/
Wrappable.h
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
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
//
// Created by hyperandroid on 12/02/2016.
//
#ifndef HYPERCASINO_WRAPPABLE_H
#define HYPERCASINO_WRAPPABLE_H
#include <v8.h>
#include "Configuration.h"
using namespace Config;
class Wrappable {
public:
Wrappable() {};
virtual ~Wrappable();
virtual const WrapperTypeInfo *GetWrapperTypeInfo() const = 0;
virtual v8::Local<v8::Object> Wrap(v8::Isolate *,
v8::Local<v8::Context> creation_context);
virtual v8::Local<v8::Object> AssociateWithWrapper(
v8::Isolate *,
const WrapperTypeInfo *,
v8::Local<v8::Object> wrapper);
bool SetWrapper(v8::Isolate *isolate,
v8::Local<v8::Object>& wrapper,
const WrapperTypeInfo* wrapper_type_info);
void SetNativeInfo(const WrapperTypeInfo *wrapper_type_info,
v8::Local<v8::Object> wrapper );
bool IsEqualTo(v8::Isolate *isolate, const v8::Local<v8::Object> &other) const {
return wrapper_.Get(isolate) == other;
}
bool ContainsWrapper() const { return !wrapper_.IsEmpty(); }
v8::Local<v8::Object> GetWrapper(v8::Isolate *isolate) const {
return wrapper_.Get(isolate);
}
void SetWrapperClassId( uint16_t type ) {
wrapper_.SetWrapperClassId(type);
}
protected:
private:
v8::Persistent<v8::Object> wrapper_;
};
#define DEFINE_WRAPPERTYPEINFO() \
const WrapperTypeInfo* GetWrapperTypeInfo() const override { \
return &wrapperTypeInfo_; \
} \
private: \
static const WrapperTypeInfo& wrapperTypeInfo_
#endif //HYPERCASINO_WRAPPABLE_H