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
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
|
#include "V8ArrayBuffer.h"
#include "V8ArrayBufferView.h"
#include "V8Float64Array.h"
namespace Arabica {
namespace DOM {
v8::Persistent<v8::FunctionTemplate> V8Float64Array::Tmpl;
v8::Persistent<v8::FunctionTemplate> V8Float64Array::Constr;
v8::Handle<v8::Value> V8Float64Array::constructor(const v8::Arguments& args) {
if (!args.IsConstructCall())
return v8::ThrowException(v8::String::New("Cannot call constructor as function"));
uscxml::Float64Array* localInstance = NULL;
if (false) {
} else if (args.Length() == 3 &&
args[0]->IsObject() && V8ArrayBuffer::hasInstance(args[0]) &&
args[1]->IsUint32() &&
args[2]->IsUint32()) {
uscxml::ArrayBuffer* localBuffer = V8DOM::toClassPtr<V8ArrayBuffer::V8ArrayBufferPrivate >(args[0]->ToObject()->GetInternalField(0))->nativeObj;
unsigned long localByteOffset = args[1]->ToNumber()->Uint32Value();
unsigned long localLength = args[2]->ToNumber()->Uint32Value();
localInstance = new uscxml::Float64Array(localBuffer, localByteOffset, localLength);
} else if (args.Length() == 2 &&
args[0]->IsObject() && V8ArrayBuffer::hasInstance(args[0]) &&
args[1]->IsUint32()) {
uscxml::ArrayBuffer* localBuffer = V8DOM::toClassPtr<V8ArrayBuffer::V8ArrayBufferPrivate >(args[0]->ToObject()->GetInternalField(0))->nativeObj;
unsigned long localByteOffset = args[1]->ToNumber()->Uint32Value();
localInstance = new uscxml::Float64Array(localBuffer, localByteOffset);
} else if (args.Length() == 1 &&
args[0]->IsObject() && V8Float64Array::hasInstance(args[0])) {
uscxml::Float64Array* localArray = V8DOM::toClassPtr<V8Float64Array::V8Float64ArrayPrivate >(args[0]->ToObject()->GetInternalField(0))->nativeObj;
localInstance = new uscxml::Float64Array(localArray);
} else if (args.Length() == 1 &&
args[0]->IsObject() && V8ArrayBuffer::hasInstance(args[0])) {
uscxml::ArrayBuffer* localBuffer = V8DOM::toClassPtr<V8ArrayBuffer::V8ArrayBufferPrivate >(args[0]->ToObject()->GetInternalField(0))->nativeObj;
localInstance = new uscxml::Float64Array(localBuffer);
} else if (args.Length() == 1 &&
args[0]->IsUint32()) {
unsigned long localLength = args[0]->ToNumber()->Uint32Value();
localInstance = new uscxml::Float64Array(localLength);
} else if (args.Length() == 1 &&
args[0]->IsArray()) {
std::vector<double> localArray;
v8::Handle<v8::Array> localArrayArray(v8::Array::Cast(*args[0]));
for (int i = 0; i < localArrayArray->Length(); i++) {
localArray.push_back(localArrayArray->Get(i)->ToNumber()->Value());
}
localInstance = new uscxml::Float64Array(localArray);
}
if (!localInstance) {
throw V8Exception("Parameter mismatch while calling constructor for Float64Array");
return v8::Undefined();
}
v8::Handle<v8::Function> retCtor = V8Float64Array::getTmpl()->GetFunction();
v8::Persistent<v8::Object> retObj = v8::Persistent<v8::Object>::New(retCtor->NewInstance());
struct V8Float64Array::V8Float64ArrayPrivate* retPrivData = new V8Float64Array::V8Float64ArrayPrivate();
retPrivData->nativeObj = localInstance;
retObj->SetInternalField(0, V8DOM::toExternal(retPrivData));
retObj.MakeWeak(0, V8Float64Array::jsDestructor);
return retObj;
}
v8::Handle<v8::Value> V8Float64Array::lengthAttrGetter(v8::Local<v8::String> property, const v8::AccessorInfo& info) {
v8::Local<v8::Object> self = info.Holder();
struct V8Float64ArrayPrivate* privData = V8DOM::toClassPtr<V8Float64ArrayPrivate >(self->GetInternalField(0));
return v8::Integer::New(privData->nativeObj->getLength());
}
v8::Handle<v8::Value> V8Float64Array::getCallback(const v8::Arguments& args) {
v8::Local<v8::Object> self = args.Holder();
struct V8Float64ArrayPrivate* privData = V8DOM::toClassPtr<V8Float64ArrayPrivate >(self->GetInternalField(0));
if (false) {
} else if (args.Length() == 1 &&
args[0]->IsUint32()) {
unsigned long localIndex = args[0]->ToNumber()->Uint32Value();
double retVal = privData->nativeObj->get(localIndex);
return v8::Number::New(retVal);
}
throw V8Exception("Parameter mismatch while calling get");
return v8::Undefined();
}
v8::Handle<v8::Value> V8Float64Array::setCallback(const v8::Arguments& args) {
v8::Local<v8::Object> self = args.Holder();
struct V8Float64ArrayPrivate* privData = V8DOM::toClassPtr<V8Float64ArrayPrivate >(self->GetInternalField(0));
if (false) {
} else if (args.Length() == 2 &&
args[0]->IsObject() && V8Float64Array::hasInstance(args[0]) &&
args[1]->IsUint32()) {
uscxml::Float64Array* localArray = V8DOM::toClassPtr<V8Float64Array::V8Float64ArrayPrivate >(args[0]->ToObject()->GetInternalField(0))->nativeObj;
unsigned long localOffset = args[1]->ToNumber()->Uint32Value();
privData->nativeObj->set(localArray, localOffset);
return v8::Undefined();
} else if (args.Length() == 2 &&
args[0]->IsUint32() &&
args[1]->IsNumber()) {
unsigned long localIndex = args[0]->ToNumber()->Uint32Value();
double localValue = args[1]->ToNumber()->Value();
privData->nativeObj->set(localIndex, localValue);
return v8::Undefined();
} else if (args.Length() == 2 &&
args[0]->IsArray() &&
args[1]->IsUint32()) {
std::vector<double> localArray;
v8::Handle<v8::Array> localArrayArray(v8::Array::Cast(*args[0]));
for (int i = 0; i < localArrayArray->Length(); i++) {
localArray.push_back(localArrayArray->Get(i)->ToNumber()->Value());
}
unsigned long localOffset = args[1]->ToNumber()->Uint32Value();
privData->nativeObj->set(localArray, localOffset);
return v8::Undefined();
} else if (args.Length() == 1 &&
args[0]->IsObject() && V8Float64Array::hasInstance(args[0])) {
uscxml::Float64Array* localArray = V8DOM::toClassPtr<V8Float64Array::V8Float64ArrayPrivate >(args[0]->ToObject()->GetInternalField(0))->nativeObj;
privData->nativeObj->set(localArray);
return v8::Undefined();
} else if (args.Length() == 1 &&
args[0]->IsArray()) {
std::vector<double> localArray;
v8::Handle<v8::Array> localArrayArray(v8::Array::Cast(*args[0]));
for (int i = 0; i < localArrayArray->Length(); i++) {
localArray.push_back(localArrayArray->Get(i)->ToNumber()->Value());
}
privData->nativeObj->set(localArray);
return v8::Undefined();
}
throw V8Exception("Parameter mismatch while calling set");
return v8::Undefined();
}
v8::Handle<v8::Value> V8Float64Array::subarrayCallback(const v8::Arguments& args) {
v8::Local<v8::Object> self = args.Holder();
struct V8Float64ArrayPrivate* privData = V8DOM::toClassPtr<V8Float64ArrayPrivate >(self->GetInternalField(0));
if (false) {
} else if (args.Length() == 2 &&
args[0]->IsInt32() &&
args[1]->IsInt32()) {
long localStart = args[0]->ToNumber()->Int32Value();
long localEnd = args[1]->ToNumber()->Int32Value();
uscxml::Float64Array* retVal = new uscxml::Float64Array(privData->nativeObj->subarray(localStart, localEnd));
v8::Handle<v8::Function> retCtor = V8Float64Array::getTmpl()->GetFunction();
v8::Persistent<v8::Object> retObj = v8::Persistent<v8::Object>::New(retCtor->NewInstance());
struct V8Float64Array::V8Float64ArrayPrivate* retPrivData = new V8Float64Array::V8Float64ArrayPrivate();
retPrivData->dom = privData->dom;
retPrivData->nativeObj = retVal;
retObj->SetInternalField(0, V8DOM::toExternal(retPrivData));
retObj.MakeWeak(0, V8Float64Array::jsDestructor);
return retObj;
} else if (args.Length() == 1 &&
args[0]->IsInt32()) {
long localStart = args[0]->ToNumber()->Int32Value();
uscxml::Float64Array* retVal = new uscxml::Float64Array(privData->nativeObj->subarray(localStart));
v8::Handle<v8::Function> retCtor = V8Float64Array::getTmpl()->GetFunction();
v8::Persistent<v8::Object> retObj = v8::Persistent<v8::Object>::New(retCtor->NewInstance());
struct V8Float64Array::V8Float64ArrayPrivate* retPrivData = new V8Float64Array::V8Float64ArrayPrivate();
retPrivData->dom = privData->dom;
retPrivData->nativeObj = retVal;
retObj->SetInternalField(0, V8DOM::toExternal(retPrivData));
retObj.MakeWeak(0, V8Float64Array::jsDestructor);
return retObj;
}
throw V8Exception("Parameter mismatch while calling subarray");
return v8::Undefined();
}
bool V8Float64Array::hasInstance(v8::Handle<v8::Value> value) {
return getTmpl()->HasInstance(value);
}
}
}
|