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
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
|
#include "globals.h"
#include "SkinOption_v8_wrapper.h"
#include <v8.h>
#include "SkinOption.h"
#include <utf8_helpers.h>
using namespace v8;
#ifdef UNICODE
# define V8_TCHAR uint16_t
#else
# define V8_TCHAR char
#endif
static Handle<Value> Get_SkinOption_description(Local<String> property, const AccessorInfo &info)
{
HandleScope scope;
Local<Object> self = info.Holder();
Local<External> wrap = Local<External>::Cast(self->GetInternalField(0));
if (wrap.IsEmpty())
return scope.Close( Undefined() );
SkinOption *tmp = (SkinOption *) wrap->Value();
if (tmp == NULL)
return scope.Close( Undefined() );
return scope.Close( String::New((const V8_TCHAR *) tmp->getDescription()) );
}
static void Set_SkinOption_description(Local<String> property, Local<Value> value, const AccessorInfo& info)
{
HandleScope scope;
Local<Object> self = info.Holder();
Local<External> wrap = Local<External>::Cast(self->GetInternalField(0));
if (wrap.IsEmpty())
return;
SkinOption *tmp = (SkinOption *) wrap->Value();
if (tmp == NULL)
return;
if (!value.IsEmpty() && value->IsString())
{
String::Utf8Value utf8_value(value);
tmp->setDescription(Utf8ToTchar(*utf8_value));
}
}
static Handle<Value> Get_SkinOption_min(Local<String> property, const AccessorInfo &info)
{
HandleScope scope;
Local<Object> self = info.Holder();
Local<External> wrap = Local<External>::Cast(self->GetInternalField(0));
if (wrap.IsEmpty())
return scope.Close( Undefined() );
SkinOption *tmp = (SkinOption *) wrap->Value();
if (tmp == NULL)
return scope.Close( Undefined() );
return scope.Close( Int32::New(tmp->getMin()) );
}
static void Set_SkinOption_min(Local<String> property, Local<Value> value, const AccessorInfo& info)
{
HandleScope scope;
Local<Object> self = info.Holder();
Local<External> wrap = Local<External>::Cast(self->GetInternalField(0));
if (wrap.IsEmpty())
return;
SkinOption *tmp = (SkinOption *) wrap->Value();
if (tmp == NULL)
return;
if (!value.IsEmpty() && value->IsNumber())
tmp->setMin(value->Int32Value());
}
static Handle<Value> Get_SkinOption_max(Local<String> property, const AccessorInfo &info)
{
HandleScope scope;
Local<Object> self = info.Holder();
Local<External> wrap = Local<External>::Cast(self->GetInternalField(0));
if (wrap.IsEmpty())
return scope.Close( Undefined() );
SkinOption *tmp = (SkinOption *) wrap->Value();
if (tmp == NULL)
return scope.Close( Undefined() );
return scope.Close( Int32::New(tmp->getMax()) );
}
static void Set_SkinOption_max(Local<String> property, Local<Value> value, const AccessorInfo& info)
{
HandleScope scope;
Local<Object> self = info.Holder();
Local<External> wrap = Local<External>::Cast(self->GetInternalField(0));
if (wrap.IsEmpty())
return;
SkinOption *tmp = (SkinOption *) wrap->Value();
if (tmp == NULL)
return;
if (!value.IsEmpty() && value->IsNumber())
tmp->setMax(value->Int32Value());
}
static Handle<Value> Get_SkinOption_type(Local<String> property, const AccessorInfo &info)
{
HandleScope scope;
Local<Object> self = info.Holder();
Local<External> wrap = Local<External>::Cast(self->GetInternalField(0));
if (wrap.IsEmpty())
return scope.Close( Undefined() );
SkinOption *tmp = (SkinOption *) wrap->Value();
if (tmp == NULL)
return scope.Close( Undefined() );
switch(tmp->getType())
{
case CHECKBOX: return scope.Close( String::New((const V8_TCHAR *) _T("CHECKBOX")) );
case NUMBER: return scope.Close( String::New((const V8_TCHAR *) _T("NUMBER")) );
case TEXT: return scope.Close( String::New((const V8_TCHAR *) _T("TEXT")) );
}
return scope.Close( Undefined() );
}
static void Set_SkinOption_type(Local<String> property, Local<Value> value, const AccessorInfo& info)
{
HandleScope scope;
Local<Object> self = info.Holder();
Local<External> wrap = Local<External>::Cast(self->GetInternalField(0));
if (wrap.IsEmpty())
return;
SkinOption *tmp = (SkinOption *) wrap->Value();
if (tmp == NULL)
return;
if (!value.IsEmpty() && value->IsString())
{
String::Utf8Value utf8_value(value);
Utf8ToTchar tval(*utf8_value);
if ( lstrcmpi(_T("CHECKBOX"), tval) == 0 )
tmp->setType(CHECKBOX);
else if ( lstrcmpi(_T("NUMBER"), tval) == 0 )
tmp->setType(NUMBER);
else if ( lstrcmpi(_T("TEXT"), tval) == 0 )
tmp->setType(TEXT);
}
}
void AddSkinOptionAcessors(Handle<ObjectTemplate> &templ)
{
HandleScope scope;
templ->SetAccessor(String::New("description"), Get_SkinOption_description, Set_SkinOption_description);
templ->SetAccessor(String::New("min"), Get_SkinOption_min, Set_SkinOption_min);
templ->SetAccessor(String::New("max"), Get_SkinOption_max, Set_SkinOption_max);
templ->SetAccessor(String::New("type"), Get_SkinOption_type, Set_SkinOption_type);
}
|