blob: ce51887803e645de9c36dba9a1e8527e37264428 (
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
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
|
#include "V8ArrayBuffer.h"
namespace Arabica {
namespace DOM {
v8::Persistent<v8::FunctionTemplate> V8ArrayBuffer::Tmpl;
v8::Persistent<v8::FunctionTemplate> V8ArrayBuffer::Constr;
v8::Handle<v8::Value> V8ArrayBuffer::constructor(const v8::Arguments& args) {
if (!args.IsConstructCall())
return v8::ThrowException(v8::String::New("Cannot call constructor as function"));
uscxml::ArrayBuffer* localInstance = NULL;
if (false) {
} else if (args.Length() == 1 &&
args[0]->IsUint32()) {
unsigned long localLength = args[0]->ToNumber()->Uint32Value();
localInstance = new uscxml::ArrayBuffer(localLength);
}
if (!localInstance) {
throw V8Exception("Parameter mismatch while calling constructor for ArrayBuffer");
return v8::Undefined();
}
v8::Handle<v8::Function> retCtor = V8ArrayBuffer::getTmpl()->GetFunction();
v8::Persistent<v8::Object> retObj = v8::Persistent<v8::Object>::New(retCtor->NewInstance());
struct V8ArrayBuffer::V8ArrayBufferPrivate* retPrivData = new V8ArrayBuffer::V8ArrayBufferPrivate();
retPrivData->nativeObj = localInstance;
retObj->SetInternalField(0, V8DOM::toExternal(retPrivData));
retObj.MakeWeak(0, V8ArrayBuffer::jsDestructor);
return retObj;
}
v8::Handle<v8::Value> V8ArrayBuffer::byteLengthAttrGetter(v8::Local<v8::String> property, const v8::AccessorInfo& info) {
v8::Local<v8::Object> self = info.Holder();
struct V8ArrayBufferPrivate* privData = V8DOM::toClassPtr<V8ArrayBufferPrivate >(self->GetInternalField(0));
return v8::Integer::New(privData->nativeObj->getByteLength());
}
v8::Handle<v8::Value> V8ArrayBuffer::sliceCallback(const v8::Arguments& args) {
v8::Local<v8::Object> self = args.Holder();
struct V8ArrayBufferPrivate* privData = V8DOM::toClassPtr<V8ArrayBufferPrivate >(self->GetInternalField(0));
if (false) {
} else if (args.Length() == 2 &&
args[0]->IsInt32() &&
args[1]->IsInt32()) {
long localBegin = args[0]->ToNumber()->Int32Value();
long localEnd = args[1]->ToNumber()->Int32Value();
uscxml::ArrayBuffer* retVal = new uscxml::ArrayBuffer(privData->nativeObj->slice(localBegin, localEnd));
v8::Handle<v8::Function> retCtor = V8ArrayBuffer::getTmpl()->GetFunction();
v8::Persistent<v8::Object> retObj = v8::Persistent<v8::Object>::New(retCtor->NewInstance());
struct V8ArrayBuffer::V8ArrayBufferPrivate* retPrivData = new V8ArrayBuffer::V8ArrayBufferPrivate();
retPrivData->dom = privData->dom;
retPrivData->nativeObj = retVal;
retObj->SetInternalField(0, V8DOM::toExternal(retPrivData));
retObj.MakeWeak(0, V8ArrayBuffer::jsDestructor);
return retObj;
} else if (args.Length() == 1 &&
args[0]->IsInt32()) {
long localBegin = args[0]->ToNumber()->Int32Value();
uscxml::ArrayBuffer* retVal = new uscxml::ArrayBuffer(privData->nativeObj->slice(localBegin));
v8::Handle<v8::Function> retCtor = V8ArrayBuffer::getTmpl()->GetFunction();
v8::Persistent<v8::Object> retObj = v8::Persistent<v8::Object>::New(retCtor->NewInstance());
struct V8ArrayBuffer::V8ArrayBufferPrivate* retPrivData = new V8ArrayBuffer::V8ArrayBufferPrivate();
retPrivData->dom = privData->dom;
retPrivData->nativeObj = retVal;
retObj->SetInternalField(0, V8DOM::toExternal(retPrivData));
retObj.MakeWeak(0, V8ArrayBuffer::jsDestructor);
return retObj;
}
throw V8Exception("Parameter mismatch while calling slice");
return v8::Undefined();
}
v8::Handle<v8::Value> V8ArrayBuffer::isViewCallback(const v8::Arguments& args) {
v8::Local<v8::Object> self = args.Holder();
struct V8ArrayBufferPrivate* privData = V8DOM::toClassPtr<V8ArrayBufferPrivate >(self->GetInternalField(0));
if (false) {
} else if (args.Length() == 1 &&
true) {
void* localValue = v8::External::Unwrap(args[0]->ToObject()->GetInternalField(0));
bool retVal = privData->nativeObj->isView(localValue);
return v8::Boolean::New(retVal);
}
throw V8Exception("Parameter mismatch while calling isView");
return v8::Undefined();
}
bool V8ArrayBuffer::hasInstance(v8::Handle<v8::Value> value) {
return getTmpl()->HasInstance(value);
}
}
}
|