2 This file is part of the WebKit open source project.
3 This file has been generated by generate-bindings.pl. DO NOT MODIFY!
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.
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.
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.
22 #include "JSFloat32Array.h"
24 #include "ExceptionCode.h"
25 #include "JSDOMBinding.h"
26 #include "JSFloat32Array.h"
27 #include <runtime/Error.h>
28 #include <runtime/PropertyNameArray.h>
29 #include <wtf/Float32Array.h>
30 #include <wtf/GetPtr.h>
36 ASSERT_CLASS_FITS_IN_CELL(JSFloat32Array);
40 #define THUNK_GENERATOR(generator) , generator
42 #define THUNK_GENERATOR(generator)
45 #define INTRINSIC(intrinsic) , intrinsic
47 #define INTRINSIC(intrinsic)
50 static const HashTableValue JSFloat32ArrayTableValues[] =
52 { "length", DontDelete | ReadOnly, (intptr_t)static_cast<PropertySlot::GetValueFunc>(jsFloat32ArrayLength), (intptr_t)0 THUNK_GENERATOR(0) INTRINSIC(DFG::NoIntrinsic) },
53 { "constructor", DontEnum | ReadOnly, (intptr_t)static_cast<PropertySlot::GetValueFunc>(jsFloat32ArrayConstructor), (intptr_t)0 THUNK_GENERATOR(0) INTRINSIC(DFG::NoIntrinsic) },
54 { 0, 0, 0, 0 THUNK_GENERATOR(0) INTRINSIC(DFG::NoIntrinsic) }
57 #undef THUNK_GENERATOR
58 static const HashTable JSFloat32ArrayTable = { 5, 3, JSFloat32ArrayTableValues, 0 };
59 /* Hash table for constructor */
61 #define THUNK_GENERATOR(generator) , generator
63 #define THUNK_GENERATOR(generator)
66 #define INTRINSIC(intrinsic) , intrinsic
68 #define INTRINSIC(intrinsic)
71 static const HashTableValue JSFloat32ArrayConstructorTableValues[] =
73 { "BYTES_PER_ELEMENT", DontDelete | ReadOnly, (intptr_t)static_cast<PropertySlot::GetValueFunc>(jsFloat32ArrayBYTES_PER_ELEMENT), (intptr_t)0 THUNK_GENERATOR(0) INTRINSIC(DFG::NoIntrinsic) },
74 { 0, 0, 0, 0 THUNK_GENERATOR(0) INTRINSIC(DFG::NoIntrinsic) }
77 #undef THUNK_GENERATOR
78 static const HashTable JSFloat32ArrayConstructorTable = { 2, 1, JSFloat32ArrayConstructorTableValues, 0 };
79 const ClassInfo JSFloat32ArrayConstructor::s_info = { "Float32ArrayConstructor", &DOMConstructorObject::s_info, &JSFloat32ArrayConstructorTable, 0, CREATE_METHOD_TABLE(JSFloat32ArrayConstructor) };
81 JSFloat32ArrayConstructor::JSFloat32ArrayConstructor(Structure* structure, JSDOMGlobalObject* globalObject)
82 : DOMConstructorObject(structure, globalObject)
86 void JSFloat32ArrayConstructor::finishCreation(ExecState* exec, JSDOMGlobalObject* globalObject)
88 Base::finishCreation(exec->globalData());
89 ASSERT(inherits(&s_info));
90 putDirect(exec->globalData(), exec->propertyNames().prototype, JSFloat32ArrayPrototype::self(exec, globalObject), DontDelete | ReadOnly);
93 bool JSFloat32ArrayConstructor::getOwnPropertySlot(JSCell* cell, ExecState* exec, const Identifier& propertyName, PropertySlot& slot)
95 return getStaticValueSlot<JSFloat32ArrayConstructor, JSDOMWrapper>(exec, &JSFloat32ArrayConstructorTable, static_cast<JSFloat32ArrayConstructor*>(cell), propertyName, slot);
98 bool JSFloat32ArrayConstructor::getOwnPropertyDescriptor(JSObject* object, ExecState* exec, const Identifier& propertyName, PropertyDescriptor& descriptor)
100 return getStaticValueDescriptor<JSFloat32ArrayConstructor, JSDOMWrapper>(exec, &JSFloat32ArrayConstructorTable, static_cast<JSFloat32ArrayConstructor*>(object), propertyName, descriptor);
103 ConstructType JSFloat32ArrayConstructor::getConstructData(JSCell*, ConstructData& constructData)
105 constructData.native.function = constructJSFloat32Array;
106 return ConstructTypeHost;
109 /* Hash table for prototype */
111 #define THUNK_GENERATOR(generator) , generator
113 #define THUNK_GENERATOR(generator)
116 #define INTRINSIC(intrinsic) , intrinsic
118 #define INTRINSIC(intrinsic)
121 static const HashTableValue JSFloat32ArrayPrototypeTableValues[] =
123 { "BYTES_PER_ELEMENT", DontDelete | ReadOnly, (intptr_t)static_cast<PropertySlot::GetValueFunc>(jsFloat32ArrayBYTES_PER_ELEMENT), (intptr_t)0 THUNK_GENERATOR(0) INTRINSIC(DFG::NoIntrinsic) },
124 { "subarray", DontDelete | Function, (intptr_t)static_cast<NativeFunction>(jsFloat32ArrayPrototypeFunctionSubarray), (intptr_t)2 THUNK_GENERATOR(0) INTRINSIC(DFG::NoIntrinsic) },
125 { "set", DontDelete | Function, (intptr_t)static_cast<NativeFunction>(jsFloat32ArrayPrototypeFunctionSet), (intptr_t)0 THUNK_GENERATOR(0) INTRINSIC(DFG::NoIntrinsic) },
126 { 0, 0, 0, 0 THUNK_GENERATOR(0) INTRINSIC(DFG::NoIntrinsic) }
129 #undef THUNK_GENERATOR
130 static const HashTable JSFloat32ArrayPrototypeTable = { 8, 7, JSFloat32ArrayPrototypeTableValues, 0 };
131 static const HashTable* getJSFloat32ArrayPrototypeTable(ExecState* exec)
133 return getHashTableForGlobalData(exec->globalData(), &JSFloat32ArrayPrototypeTable);
136 const ClassInfo JSFloat32ArrayPrototype::s_info = { "Float32ArrayPrototype", &JSC::JSNonFinalObject::s_info, 0, getJSFloat32ArrayPrototypeTable, CREATE_METHOD_TABLE(JSFloat32ArrayPrototype) };
138 JSObject* JSFloat32ArrayPrototype::self(ExecState* exec, JSGlobalObject* globalObject)
140 return getDOMPrototype<JSFloat32Array>(exec, globalObject);
143 bool JSFloat32ArrayPrototype::getOwnPropertySlot(JSCell* cell, ExecState* exec, const Identifier& propertyName, PropertySlot& slot)
145 JSFloat32ArrayPrototype* thisObject = jsCast<JSFloat32ArrayPrototype*>(cell);
146 return getStaticPropertySlot<JSFloat32ArrayPrototype, JSObject>(exec, getJSFloat32ArrayPrototypeTable(exec), thisObject, propertyName, slot);
149 bool JSFloat32ArrayPrototype::getOwnPropertyDescriptor(JSObject* object, ExecState* exec, const Identifier& propertyName, PropertyDescriptor& descriptor)
151 JSFloat32ArrayPrototype* thisObject = jsCast<JSFloat32ArrayPrototype*>(object);
152 return getStaticPropertyDescriptor<JSFloat32ArrayPrototype, JSObject>(exec, getJSFloat32ArrayPrototypeTable(exec), thisObject, propertyName, descriptor);
155 static const HashTable* getJSFloat32ArrayTable(ExecState* exec)
157 return getHashTableForGlobalData(exec->globalData(), &JSFloat32ArrayTable);
160 const ClassInfo JSFloat32Array::s_info = { "Float32Array", &JSArrayBufferView::s_info, 0, getJSFloat32ArrayTable , CREATE_METHOD_TABLE(JSFloat32Array) };
162 JSFloat32Array::JSFloat32Array(Structure* structure, JSDOMGlobalObject* globalObject, PassRefPtr<Float32Array> impl)
163 : JSArrayBufferView(structure, globalObject, impl)
167 void JSFloat32Array::finishCreation(JSGlobalData& globalData)
169 Base::finishCreation(globalData);
170 TypedArrayDescriptor descriptor(vptr(), OBJECT_OFFSETOF(JSFloat32Array, m_storage), OBJECT_OFFSETOF(JSFloat32Array, m_storageLength));
171 globalData.registerTypedArrayDescriptor(impl(), descriptor);
172 m_storage = impl()->data();
173 m_storageLength = impl()->length();
174 ASSERT(inherits(&s_info));
177 JSObject* JSFloat32Array::createPrototype(ExecState* exec, JSGlobalObject* globalObject)
179 return JSFloat32ArrayPrototype::create(exec->globalData(), globalObject, JSFloat32ArrayPrototype::createStructure(exec->globalData(), globalObject, JSArrayBufferViewPrototype::self(exec, globalObject)));
182 bool JSFloat32Array::getOwnPropertySlot(JSCell* cell, ExecState* exec, const Identifier& propertyName, PropertySlot& slot)
184 JSFloat32Array* thisObject = jsCast<JSFloat32Array*>(cell);
185 ASSERT_GC_OBJECT_INHERITS(thisObject, &s_info);
187 unsigned index = propertyName.toUInt32(ok);
188 if (ok && index < static_cast<Float32Array*>(thisObject->impl())->length()) {
189 slot.setValue(thisObject->getByIndex(exec, index));
192 return getStaticValueSlot<JSFloat32Array, Base>(exec, getJSFloat32ArrayTable(exec), thisObject, propertyName, slot);
195 bool JSFloat32Array::getOwnPropertyDescriptor(JSObject* object, ExecState* exec, const Identifier& propertyName, PropertyDescriptor& descriptor)
197 JSFloat32Array* thisObject = jsCast<JSFloat32Array*>(object);
198 ASSERT_GC_OBJECT_INHERITS(thisObject, &s_info);
200 unsigned index = propertyName.toUInt32(ok);
201 if (ok && index < static_cast<Float32Array*>(thisObject->impl())->length()) {
202 descriptor.setDescriptor(thisObject->getByIndex(exec, index), DontDelete);
205 return getStaticValueDescriptor<JSFloat32Array, Base>(exec, getJSFloat32ArrayTable(exec), thisObject, propertyName, descriptor);
208 bool JSFloat32Array::getOwnPropertySlotByIndex(JSCell* cell, ExecState* exec, unsigned propertyName, PropertySlot& slot)
210 JSFloat32Array* thisObject = jsCast<JSFloat32Array*>(cell);
211 ASSERT_GC_OBJECT_INHERITS(thisObject, &s_info);
212 if (propertyName < static_cast<Float32Array*>(thisObject->impl())->length()) {
213 slot.setValue(thisObject->getByIndex(exec, propertyName));
216 return thisObject->methodTable()->getOwnPropertySlot(thisObject, exec, Identifier::from(exec, propertyName), slot);
219 JSValue jsFloat32ArrayLength(ExecState* exec, JSValue slotBase, const Identifier&)
221 JSFloat32Array* castedThis = static_cast<JSFloat32Array*>(asObject(slotBase));
223 Float32Array* imp = static_cast<Float32Array*>(castedThis->impl());
224 JSValue result = jsNumber(imp->length());
229 JSValue jsFloat32ArrayConstructor(ExecState* exec, JSValue slotBase, const Identifier&)
231 JSFloat32Array* domObject = static_cast<JSFloat32Array*>(asObject(slotBase));
232 return JSFloat32Array::getConstructor(exec, domObject->globalObject());
235 void JSFloat32Array::put(JSCell* cell, ExecState* exec, const Identifier& propertyName, JSValue value, PutPropertySlot& slot)
237 JSFloat32Array* thisObject = jsCast<JSFloat32Array*>(cell);
238 ASSERT_GC_OBJECT_INHERITS(thisObject, &s_info);
240 unsigned index = propertyName.toUInt32(ok);
242 thisObject->indexSetter(exec, index, value);
245 Base::put(thisObject, exec, propertyName, value, slot);
248 void JSFloat32Array::putByIndex(JSCell* cell, ExecState* exec, unsigned propertyName, JSValue value)
250 JSFloat32Array* thisObject = jsCast<JSFloat32Array*>(cell);
251 ASSERT_GC_OBJECT_INHERITS(thisObject, &s_info);
252 thisObject->indexSetter(exec, propertyName, value);
256 void JSFloat32Array::getOwnPropertyNames(JSObject* object, ExecState* exec, PropertyNameArray& propertyNames, EnumerationMode mode)
258 JSFloat32Array* thisObject = jsCast<JSFloat32Array*>(object);
259 ASSERT_GC_OBJECT_INHERITS(thisObject, &s_info);
260 for (unsigned i = 0; i < static_cast<Float32Array*>(thisObject->impl())->length(); ++i)
261 propertyNames.add(Identifier::from(exec, i));
262 Base::getOwnPropertyNames(thisObject, exec, propertyNames, mode);
265 JSValue JSFloat32Array::getConstructor(ExecState* exec, JSGlobalObject* globalObject)
267 return getDOMConstructor<JSFloat32ArrayConstructor>(exec, static_cast<JSDOMGlobalObject*>(globalObject));
270 EncodedJSValue JSC_HOST_CALL jsFloat32ArrayPrototypeFunctionSubarray(ExecState* exec)
272 JSValue thisValue = exec->hostThisValue();
273 if (!thisValue.inherits(&JSFloat32Array::s_info))
274 return throwVMTypeError(exec);
275 JSFloat32Array* castedThis = static_cast<JSFloat32Array*>(asObject(thisValue));
276 ASSERT_GC_OBJECT_INHERITS(castedThis, &JSFloat32Array::s_info);
277 Float32Array* imp = static_cast<Float32Array*>(castedThis->impl());
278 int start(MAYBE_MISSING_PARAMETER(exec, 0, MissingIsUndefined).toInt32(exec));
279 if (exec->hadException())
280 return JSValue::encode(jsUndefined());
282 size_t argsCount = exec->argumentCount();
283 if (argsCount <= 1) {
285 JSC::JSValue result = toJS(exec, castedThis->globalObject(), WTF::getPtr(imp->subarray(start)));
286 return JSValue::encode(result);
289 int end(MAYBE_MISSING_PARAMETER(exec, 1, MissingIsUndefined).toInt32(exec));
290 if (exec->hadException())
291 return JSValue::encode(jsUndefined());
293 JSC::JSValue result = toJS(exec, castedThis->globalObject(), WTF::getPtr(imp->subarray(start, end)));
294 return JSValue::encode(result);
297 EncodedJSValue JSC_HOST_CALL jsFloat32ArrayPrototypeFunctionSet(ExecState* exec)
299 JSValue thisValue = exec->hostThisValue();
300 if (!thisValue.inherits(&JSFloat32Array::s_info))
301 return throwVMTypeError(exec);
302 JSFloat32Array* castedThis = static_cast<JSFloat32Array*>(asObject(thisValue));
303 ASSERT_GC_OBJECT_INHERITS(castedThis, &JSFloat32Array::s_info);
304 return JSValue::encode(castedThis->set(exec));
309 JSValue jsFloat32ArrayBYTES_PER_ELEMENT(ExecState* exec, JSValue, const Identifier&)
312 return jsNumber(static_cast<int>(4));
316 JSValue JSFloat32Array::getByIndex(ExecState*, unsigned index)
318 ASSERT_GC_OBJECT_INHERITS(this, &s_info);
319 double result = static_cast<Float32Array*>(impl())->item(index);
322 return JSValue(result);
325 Float32Array* toFloat32Array(JSC::JSValue value)
327 return value.inherits(&JSFloat32Array::s_info) ? static_cast<JSFloat32Array*>(asObject(value))->impl() : 0;