-
Notifications
You must be signed in to change notification settings - Fork 7
Expand file tree
/
Copy pathSMJS_Event.h
More file actions
75 lines (59 loc) · 1.63 KB
/
SMJS_Event.h
File metadata and controls
75 lines (59 loc) · 1.63 KB
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
67
68
69
70
71
72
73
74
75
#ifndef _INCLUDE_SMJS_EVENT_H_
#define _INCLUDE_SMJS_EVENT_H_
#include "SMJS.h"
#include "SMJS_BaseWrapped.h"
#include "SMJS_Interfaces.h"
class SMJS_Event : public SMJS_BaseWrapped {
public:
bool broadcast;
bool blocked;
bool post;
IGameEvent *ev;
SMJS_Event(IGameEvent *ev, bool broadcast, bool post) :
ev(ev),
broadcast(broadcast),
blocked(false),
post(post)
{
};
void OnWrapperAttached(SMJS_Plugin *plugin, v8::Persistent<v8::Value> wrapper){
auto obj = wrapper->ToObject();
obj->Set(v8::String::New("name"), v8::String::New(ev->GetName()), v8::ReadOnly);
if(post){
obj->SetAccessor(v8::String::New("broadcast"), GetBroadcast);
}else{
obj->SetAccessor(v8::String::New("broadcast"), GetBroadcast, SetBroadcast);
}
}
FUNCTION_DECL(getBool);
FUNCTION_DECL(getInt);
FUNCTION_DECL(getFloat);
FUNCTION_DECL(getString);
FUNCTION_DECL(getUint64);
FUNCTION_DECL(setBool);
FUNCTION_DECL(setInt);
FUNCTION_DECL(setFloat);
FUNCTION_DECL(setString);
FUNCTION_DECL(setUint64);
FUNCTION_DECL(block);
WRAPPED_CLS(SMJS_Event, SMJS_BaseWrapped) {
temp->SetClassName(v8::String::New("Event"));
proto->Set("name", v8::Null());
WRAPPED_FUNC(getBool);
WRAPPED_FUNC(getInt);
WRAPPED_FUNC(getFloat);
WRAPPED_FUNC(getString);
WRAPPED_FUNC(getUint64);
WRAPPED_FUNC(setBool);
WRAPPED_FUNC(setInt);
WRAPPED_FUNC(setFloat);
WRAPPED_FUNC(setString);
WRAPPED_FUNC(setUint64);
WRAPPED_FUNC(block);
}
private:
SMJS_Event();
static Handle<Value> GetBroadcast(Local<String> prop, const AccessorInfo& info);
static void SetBroadcast(Local<String> prop, Local<Value> value, const AccessorInfo& info);
};
#endif