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
|
/**
* @file
* @author This file has been generated by generate-bindings.pl. DO NOT MODIFY!
* @copyright Simplified BSD
*
* @cond
* This program is free software: you can redistribute it and/or modify
* it under the terms of the FreeBSD license as published by the FreeBSD
* project.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
*
* You should have received a copy of the FreeBSD license along with this
* program. If not, see <http://www.opensource.org/licenses/bsd-license>.
* @endcond
*/
#include "JSCArrayBuffer.h"
namespace Arabica {
namespace DOM {
JSClassRef JSCArrayBuffer::Tmpl;
JSStaticValue JSCArrayBuffer::staticValues[] = {
{ "byteLength", byteLengthAttrGetter, 0, kJSPropertyAttributeDontDelete | kJSPropertyAttributeReadOnly },
{ 0, 0, 0, 0 }
};
JSStaticFunction JSCArrayBuffer::staticFunctions[] = {
{ "slice", sliceCallback, kJSPropertyAttributeDontDelete },
{ "isView", isViewCallback, kJSPropertyAttributeDontDelete },
{ 0, 0, 0 }
};
JSObjectRef JSCArrayBuffer::jsConstructor(JSContextRef ctx, JSObjectRef constructor, size_t argumentCount, const JSValueRef arguments[], JSValueRef* exception) {
uscxml::ArrayBuffer* localInstance = NULL;
if (false) {
} else if (argumentCount == 1 &&
JSValueIsNumber(ctx, arguments[0])) {
unsigned long localLength = (unsigned long)JSValueToNumber(ctx, arguments[0], exception);
localInstance = new uscxml::ArrayBuffer(localLength);
}
if (!localInstance) {
JSStringRef exceptionString = JSStringCreateWithUTF8CString("Parameter mismatch while calling constructor for ArrayBuffer");
*exception = JSValueMakeString(ctx, exceptionString);
JSStringRelease(exceptionString);
return (JSObjectRef)JSValueMakeNull(ctx);
}
JSClassRef retClass = JSCArrayBuffer::getTmpl();
struct JSCArrayBuffer::JSCArrayBufferPrivate* retPrivData = new JSCArrayBuffer::JSCArrayBufferPrivate();
retPrivData->nativeObj = localInstance;
JSObjectRef retObj = JSObjectMake(ctx, retClass, retPrivData);
return retObj;
}
JSValueRef JSCArrayBuffer::byteLengthAttrGetter(JSContextRef ctx, JSObjectRef object, JSStringRef propertyName, JSValueRef *exception) {
struct JSCArrayBufferPrivate* privData = (struct JSCArrayBufferPrivate*)JSObjectGetPrivate(object);
return JSValueMakeNumber(ctx, privData->nativeObj->getByteLength());
}
JSValueRef JSCArrayBuffer::sliceCallback(JSContextRef ctx, JSObjectRef function, JSObjectRef thisObj, size_t argumentCount, const JSValueRef* arguments, JSValueRef* exception) {
struct JSCArrayBufferPrivate* privData = (struct JSCArrayBufferPrivate*)JSObjectGetPrivate(thisObj);
if (false) {
} else if (argumentCount == 2 &&
JSValueIsNumber(ctx, arguments[0]) &&
JSValueIsNumber(ctx, arguments[1])) {
long localBegin = (long)JSValueToNumber(ctx, arguments[0], exception);
long localEnd = (long)JSValueToNumber(ctx, arguments[1], exception);
uscxml::ArrayBuffer* retVal = new uscxml::ArrayBuffer(privData->nativeObj->slice(localBegin, localEnd));
JSClassRef retClass = JSCArrayBuffer::getTmpl();
struct JSCArrayBuffer::JSCArrayBufferPrivate* retPrivData = new JSCArrayBuffer::JSCArrayBufferPrivate();
retPrivData->dom = privData->dom;
retPrivData->nativeObj = retVal;
JSObjectRef retObj = JSObjectMake(ctx, retClass, retPrivData);
return retObj;
} else if (argumentCount == 1 &&
JSValueIsNumber(ctx, arguments[0])) {
long localBegin = (long)JSValueToNumber(ctx, arguments[0], exception);
uscxml::ArrayBuffer* retVal = new uscxml::ArrayBuffer(privData->nativeObj->slice(localBegin));
JSClassRef retClass = JSCArrayBuffer::getTmpl();
struct JSCArrayBuffer::JSCArrayBufferPrivate* retPrivData = new JSCArrayBuffer::JSCArrayBufferPrivate();
retPrivData->dom = privData->dom;
retPrivData->nativeObj = retVal;
JSObjectRef retObj = JSObjectMake(ctx, retClass, retPrivData);
return retObj;
}
JSStringRef exceptionString = JSStringCreateWithUTF8CString("Parameter mismatch while calling slice");
*exception = JSValueMakeString(ctx, exceptionString);
JSStringRelease(exceptionString);
return JSValueMakeUndefined(ctx);
}
JSValueRef JSCArrayBuffer::isViewCallback(JSContextRef ctx, JSObjectRef function, JSObjectRef thisObj, size_t argumentCount, const JSValueRef* arguments, JSValueRef* exception) {
struct JSCArrayBufferPrivate* privData = (struct JSCArrayBufferPrivate*)JSObjectGetPrivate(thisObj);
if (false) {
} else if (argumentCount == 1 &&
true) {
void* localValue = JSObjectGetPrivate(JSValueToObject(ctx, arguments[0], exception));
bool retVal = privData->nativeObj->isView(localValue);
JSValueRef jscRetVal = JSValueMakeBoolean(ctx, retVal);
return jscRetVal;
}
JSStringRef exceptionString = JSStringCreateWithUTF8CString("Parameter mismatch while calling isView");
*exception = JSValueMakeString(ctx, exceptionString);
JSStringRelease(exceptionString);
return JSValueMakeUndefined(ctx);
}
}
}
|