|
1 /* |
|
2 This file is part of the WebKit open source project. |
|
3 This file has been generated by generate-bindings.pl. DO NOT MODIFY! |
|
4 |
|
5 This library is free software; you can redistribute it and/or |
|
6 modify it under the terms of the GNU Library General Public |
|
7 License as published by the Free Software Foundation; either |
|
8 version 2 of the License, or (at your option) any later version. |
|
9 |
|
10 This library is distributed in the hope that it will be useful, |
|
11 but WITHOUT ANY WARRANTY; without even the implied warranty of |
|
12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU |
|
13 Library General Public License for more details. |
|
14 |
|
15 You should have received a copy of the GNU Library General Public License |
|
16 along with this library; see the file COPYING.LIB. If not, write to |
|
17 the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, |
|
18 Boston, MA 02110-1301, USA. |
|
19 */ |
|
20 |
|
21 #include "config.h" |
|
22 |
|
23 #if ENABLE(3D_CANVAS) |
|
24 |
|
25 #include "JSFloat32Array.h" |
|
26 |
|
27 #include "Float32Array.h" |
|
28 #include <runtime/Error.h> |
|
29 #include <runtime/PropertyNameArray.h> |
|
30 #include <wtf/GetPtr.h> |
|
31 |
|
32 using namespace JSC; |
|
33 |
|
34 namespace WebCore { |
|
35 |
|
36 ASSERT_CLASS_FITS_IN_CELL(JSFloat32Array); |
|
37 |
|
38 /* Hash table */ |
|
39 #if ENABLE(JIT) |
|
40 #define THUNK_GENERATOR(generator) , generator |
|
41 #else |
|
42 #define THUNK_GENERATOR(generator) |
|
43 #endif |
|
44 |
|
45 static const HashTableValue JSFloat32ArrayTableValues[2] = |
|
46 { |
|
47 { "constructor", DontEnum | ReadOnly, (intptr_t)static_cast<PropertySlot::GetValueFunc>(jsFloat32ArrayConstructor), (intptr_t)0 THUNK_GENERATOR(0) }, |
|
48 { 0, 0, 0, 0 THUNK_GENERATOR(0) } |
|
49 }; |
|
50 |
|
51 #undef THUNK_GENERATOR |
|
52 static JSC_CONST_HASHTABLE HashTable JSFloat32ArrayTable = { 2, 1, JSFloat32ArrayTableValues, 0 }; |
|
53 /* Hash table for constructor */ |
|
54 #if ENABLE(JIT) |
|
55 #define THUNK_GENERATOR(generator) , generator |
|
56 #else |
|
57 #define THUNK_GENERATOR(generator) |
|
58 #endif |
|
59 |
|
60 static const HashTableValue JSFloat32ArrayConstructorTableValues[2] = |
|
61 { |
|
62 { "BYTES_PER_ELEMENT", DontDelete | ReadOnly, (intptr_t)static_cast<PropertySlot::GetValueFunc>(jsFloat32ArrayBYTES_PER_ELEMENT), (intptr_t)0 THUNK_GENERATOR(0) }, |
|
63 { 0, 0, 0, 0 THUNK_GENERATOR(0) } |
|
64 }; |
|
65 |
|
66 #undef THUNK_GENERATOR |
|
67 static JSC_CONST_HASHTABLE HashTable JSFloat32ArrayConstructorTable = { 2, 1, JSFloat32ArrayConstructorTableValues, 0 }; |
|
68 const ClassInfo JSFloat32ArrayConstructor::s_info = { "Float32ArrayConstructor", 0, &JSFloat32ArrayConstructorTable, 0 }; |
|
69 |
|
70 JSFloat32ArrayConstructor::JSFloat32ArrayConstructor(ExecState* exec, JSDOMGlobalObject* globalObject) |
|
71 : DOMConstructorObject(JSFloat32ArrayConstructor::createStructure(globalObject->objectPrototype()), globalObject) |
|
72 { |
|
73 putDirect(exec->propertyNames().prototype, JSFloat32ArrayPrototype::self(exec, globalObject), DontDelete | ReadOnly); |
|
74 } |
|
75 |
|
76 bool JSFloat32ArrayConstructor::getOwnPropertySlot(ExecState* exec, const Identifier& propertyName, PropertySlot& slot) |
|
77 { |
|
78 return getStaticValueSlot<JSFloat32ArrayConstructor, DOMObject>(exec, &JSFloat32ArrayConstructorTable, this, propertyName, slot); |
|
79 } |
|
80 |
|
81 bool JSFloat32ArrayConstructor::getOwnPropertyDescriptor(ExecState* exec, const Identifier& propertyName, PropertyDescriptor& descriptor) |
|
82 { |
|
83 return getStaticValueDescriptor<JSFloat32ArrayConstructor, DOMObject>(exec, &JSFloat32ArrayConstructorTable, this, propertyName, descriptor); |
|
84 } |
|
85 |
|
86 ConstructType JSFloat32ArrayConstructor::getConstructData(ConstructData& constructData) |
|
87 { |
|
88 constructData.native.function = constructJSFloat32Array; |
|
89 return ConstructTypeHost; |
|
90 } |
|
91 |
|
92 /* Hash table for prototype */ |
|
93 #if ENABLE(JIT) |
|
94 #define THUNK_GENERATOR(generator) , generator |
|
95 #else |
|
96 #define THUNK_GENERATOR(generator) |
|
97 #endif |
|
98 |
|
99 static const HashTableValue JSFloat32ArrayPrototypeTableValues[3] = |
|
100 { |
|
101 { "BYTES_PER_ELEMENT", DontDelete | ReadOnly, (intptr_t)static_cast<PropertySlot::GetValueFunc>(jsFloat32ArrayBYTES_PER_ELEMENT), (intptr_t)0 THUNK_GENERATOR(0) }, |
|
102 { "set", DontDelete | Function, (intptr_t)static_cast<NativeFunction>(jsFloat32ArrayPrototypeFunctionSet), (intptr_t)0 THUNK_GENERATOR(0) }, |
|
103 { 0, 0, 0, 0 THUNK_GENERATOR(0) } |
|
104 }; |
|
105 |
|
106 #undef THUNK_GENERATOR |
|
107 static JSC_CONST_HASHTABLE HashTable JSFloat32ArrayPrototypeTable = { 4, 3, JSFloat32ArrayPrototypeTableValues, 0 }; |
|
108 const ClassInfo JSFloat32ArrayPrototype::s_info = { "Float32ArrayPrototype", 0, &JSFloat32ArrayPrototypeTable, 0 }; |
|
109 |
|
110 JSObject* JSFloat32ArrayPrototype::self(ExecState* exec, JSGlobalObject* globalObject) |
|
111 { |
|
112 return getDOMPrototype<JSFloat32Array>(exec, globalObject); |
|
113 } |
|
114 |
|
115 bool JSFloat32ArrayPrototype::getOwnPropertySlot(ExecState* exec, const Identifier& propertyName, PropertySlot& slot) |
|
116 { |
|
117 return getStaticPropertySlot<JSFloat32ArrayPrototype, JSObject>(exec, &JSFloat32ArrayPrototypeTable, this, propertyName, slot); |
|
118 } |
|
119 |
|
120 bool JSFloat32ArrayPrototype::getOwnPropertyDescriptor(ExecState* exec, const Identifier& propertyName, PropertyDescriptor& descriptor) |
|
121 { |
|
122 return getStaticPropertyDescriptor<JSFloat32ArrayPrototype, JSObject>(exec, &JSFloat32ArrayPrototypeTable, this, propertyName, descriptor); |
|
123 } |
|
124 |
|
125 const ClassInfo JSFloat32Array::s_info = { "Float32Array", &JSArrayBufferView::s_info, &JSFloat32ArrayTable, 0 }; |
|
126 |
|
127 JSFloat32Array::JSFloat32Array(NonNullPassRefPtr<Structure> structure, JSDOMGlobalObject* globalObject, PassRefPtr<Float32Array> impl) |
|
128 : JSArrayBufferView(structure, globalObject, impl) |
|
129 { |
|
130 } |
|
131 |
|
132 JSObject* JSFloat32Array::createPrototype(ExecState* exec, JSGlobalObject* globalObject) |
|
133 { |
|
134 return new (exec) JSFloat32ArrayPrototype(globalObject, JSFloat32ArrayPrototype::createStructure(JSArrayBufferViewPrototype::self(exec, globalObject))); |
|
135 } |
|
136 |
|
137 bool JSFloat32Array::getOwnPropertySlot(ExecState* exec, const Identifier& propertyName, PropertySlot& slot) |
|
138 { |
|
139 bool ok; |
|
140 unsigned index = propertyName.toUInt32(&ok, false); |
|
141 if (ok && index < static_cast<Float32Array*>(impl())->length()) { |
|
142 slot.setValue(getByIndex(exec, index)); |
|
143 return true; |
|
144 } |
|
145 return getStaticValueSlot<JSFloat32Array, Base>(exec, &JSFloat32ArrayTable, this, propertyName, slot); |
|
146 } |
|
147 |
|
148 bool JSFloat32Array::getOwnPropertyDescriptor(ExecState* exec, const Identifier& propertyName, PropertyDescriptor& descriptor) |
|
149 { |
|
150 bool ok; |
|
151 unsigned index = propertyName.toUInt32(&ok, false); |
|
152 if (ok && index < static_cast<Float32Array*>(impl())->length()) { |
|
153 descriptor.setDescriptor(getByIndex(exec, index), DontDelete); |
|
154 return true; |
|
155 } |
|
156 return getStaticValueDescriptor<JSFloat32Array, Base>(exec, &JSFloat32ArrayTable, this, propertyName, descriptor); |
|
157 } |
|
158 |
|
159 bool JSFloat32Array::getOwnPropertySlot(ExecState* exec, unsigned propertyName, PropertySlot& slot) |
|
160 { |
|
161 if (propertyName < static_cast<Float32Array*>(impl())->length()) { |
|
162 slot.setValue(getByIndex(exec, propertyName)); |
|
163 return true; |
|
164 } |
|
165 return getOwnPropertySlot(exec, Identifier::from(exec, propertyName), slot); |
|
166 } |
|
167 |
|
168 JSValue jsFloat32ArrayConstructor(ExecState* exec, JSValue slotBase, const Identifier&) |
|
169 { |
|
170 JSFloat32Array* domObject = static_cast<JSFloat32Array*>(asObject(slotBase)); |
|
171 return JSFloat32Array::getConstructor(exec, domObject->globalObject()); |
|
172 } |
|
173 void JSFloat32Array::put(ExecState* exec, const Identifier& propertyName, JSValue value, PutPropertySlot& slot) |
|
174 { |
|
175 bool ok; |
|
176 unsigned index = propertyName.toUInt32(&ok, false); |
|
177 if (ok) { |
|
178 indexSetter(exec, index, value); |
|
179 return; |
|
180 } |
|
181 Base::put(exec, propertyName, value, slot); |
|
182 } |
|
183 |
|
184 void JSFloat32Array::put(ExecState* exec, unsigned propertyName, JSValue value) |
|
185 { |
|
186 indexSetter(exec, propertyName, value); |
|
187 return; |
|
188 } |
|
189 |
|
190 void JSFloat32Array::getOwnPropertyNames(ExecState* exec, PropertyNameArray& propertyNames, EnumerationMode mode) |
|
191 { |
|
192 for (unsigned i = 0; i < static_cast<Float32Array*>(impl())->length(); ++i) |
|
193 propertyNames.add(Identifier::from(exec, i)); |
|
194 Base::getOwnPropertyNames(exec, propertyNames, mode); |
|
195 } |
|
196 |
|
197 JSValue JSFloat32Array::getConstructor(ExecState* exec, JSGlobalObject* globalObject) |
|
198 { |
|
199 return getDOMConstructor<JSFloat32ArrayConstructor>(exec, static_cast<JSDOMGlobalObject*>(globalObject)); |
|
200 } |
|
201 |
|
202 EncodedJSValue JSC_HOST_CALL jsFloat32ArrayPrototypeFunctionSet(ExecState* exec) |
|
203 { |
|
204 JSValue thisValue = exec->hostThisValue(); |
|
205 if (!thisValue.inherits(&JSFloat32Array::s_info)) |
|
206 return throwVMTypeError(exec); |
|
207 JSFloat32Array* castedThis = static_cast<JSFloat32Array*>(asObject(thisValue)); |
|
208 return JSValue::encode(castedThis->set(exec)); |
|
209 } |
|
210 |
|
211 // Constant getters |
|
212 |
|
213 JSValue jsFloat32ArrayBYTES_PER_ELEMENT(ExecState* exec, JSValue, const Identifier&) |
|
214 { |
|
215 return jsNumber(exec, static_cast<int>(4)); |
|
216 } |
|
217 |
|
218 |
|
219 JSValue JSFloat32Array::getByIndex(ExecState* exec, unsigned index) |
|
220 { |
|
221 return jsNumber(exec, static_cast<Float32Array*>(impl())->item(index)); |
|
222 } |
|
223 Float32Array* toFloat32Array(JSC::JSValue value) |
|
224 { |
|
225 return value.inherits(&JSFloat32Array::s_info) ? static_cast<JSFloat32Array*>(asObject(value))->impl() : 0; |
|
226 } |
|
227 |
|
228 } |
|
229 |
|
230 #endif // ENABLE(3D_CANVAS) |