blob: 54b05aacc496651cc1da607dd8599a8aa24ff9c1 (
plain)
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
|
#include "V8Uint32Array.h"
namespace Arabica {
namespace DOM {
v8::Persistent<v8::FunctionTemplate> V8Uint32Array::Tmpl;
v8::Handle<v8::Value> V8Uint32Array::lengthAttrGetter(v8::Local<v8::String> property, const v8::AccessorInfo& info) {
v8::Local<v8::Object> self = info.Holder();
struct V8Uint32ArrayPrivate* privData = V8DOM::toClassPtr<V8Uint32ArrayPrivate >(self->GetInternalField(0));
return v8::Integer::New(privData->nativeObj->getLength());
}
v8::Handle<v8::Value> V8Uint32Array::getCallback(const v8::Arguments& args) {
if (args.Length() < 1)
throw V8Exception("Wrong number of arguments in get");
v8::Local<v8::Object> self = args.Holder();
struct V8Uint32ArrayPrivate* privData = V8DOM::toClassPtr<V8Uint32ArrayPrivate >(self->GetInternalField(0));
unsigned long localIndex = args[0]->ToNumber()->Uint32Value();
unsigned long retVal = privData->nativeObj->get(localIndex);
return v8::Number::New(retVal);
}
v8::Handle<v8::Value> V8Uint32Array::setCallback(const v8::Arguments& args) {
if (args.Length() < 2)
throw V8Exception("Wrong number of arguments in set");
v8::Local<v8::Object> self = args.Holder();
struct V8Uint32ArrayPrivate* privData = V8DOM::toClassPtr<V8Uint32ArrayPrivate >(self->GetInternalField(0));
unsigned long localIndex = args[0]->ToNumber()->Uint32Value();
unsigned long localValue = args[1]->ToNumber()->Uint32Value();
privData->nativeObj->set(localIndex, localValue);
return v8::Undefined();
}
v8::Handle<v8::Value> V8Uint32Array::subarrayCallback(const v8::Arguments& args) {
if (args.Length() < 2)
throw V8Exception("Wrong number of arguments in subarray");
v8::Local<v8::Object> self = args.Holder();
struct V8Uint32ArrayPrivate* privData = V8DOM::toClassPtr<V8Uint32ArrayPrivate >(self->GetInternalField(0));
long localStart = args[0]->ToNumber()->Int32Value();
long localEnd = args[1]->ToNumber()->Int32Value();
uscxml::Uint32Array* retVal = new uscxml::Uint32Array(privData->nativeObj->subarray(localStart, localEnd));
v8::Handle<v8::Function> retCtor = V8Uint32Array::getTmpl()->GetFunction();
v8::Persistent<v8::Object> retObj = v8::Persistent<v8::Object>::New(retCtor->NewInstance());
struct V8Uint32Array::V8Uint32ArrayPrivate* retPrivData = new V8Uint32Array::V8Uint32ArrayPrivate();
retPrivData->dom = privData->dom;
retPrivData->nativeObj = retVal;
retObj->SetInternalField(0, V8DOM::toExternal(retPrivData));
retObj.MakeWeak(0, V8Uint32Array::jsDestructor);
return retObj;
}
bool V8Uint32Array::hasInstance(v8::Handle<v8::Value> value) {
return getTmpl()->HasInstance(value);
}
}
}
|