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 "JSFloat64Array.h"
24 #include "ExceptionCode.h"
25 #include "JSArrayBufferViewHelper.h"
26 #include "JSDOMBinding.h"
27 #include "JSFloat32Array.h"
28 #include "JSInt32Array.h"
29 #include <runtime/Error.h>
30 #include <runtime/PropertyNameArray.h>
31 #include <wtf/Float64Array.h>
32 #include <wtf/GetPtr.h>
33 #include <wtf/Int32Array.h>
41 static const HashTableValue JSFloat64ArrayTableValues[] =
43 { "constructor", DontEnum | ReadOnly, (intptr_t)static_cast<PropertySlot::GetValueFunc>(jsFloat64ArrayConstructor), (intptr_t)0, NoIntrinsic },
44 { 0, 0, 0, 0, NoIntrinsic }
47 static const HashTable JSFloat64ArrayTable = { 2, 1, JSFloat64ArrayTableValues, 0 };
48 /* Hash table for constructor */
50 static const HashTableValue JSFloat64ArrayConstructorTableValues[] =
52 { 0, 0, 0, 0, NoIntrinsic }
55 static const HashTable JSFloat64ArrayConstructorTable = { 1, 0, JSFloat64ArrayConstructorTableValues, 0 };
56 const ClassInfo JSFloat64ArrayConstructor::s_info = { "Float64ArrayConstructor", &Base::s_info, &JSFloat64ArrayConstructorTable, 0, CREATE_METHOD_TABLE(JSFloat64ArrayConstructor) };
58 JSFloat64ArrayConstructor::JSFloat64ArrayConstructor(Structure* structure, JSDOMGlobalObject* globalObject)
59 : DOMConstructorObject(structure, globalObject)
63 void JSFloat64ArrayConstructor::finishCreation(ExecState* exec, JSDOMGlobalObject* globalObject)
65 Base::finishCreation(exec->globalData());
66 ASSERT(inherits(&s_info));
67 putDirect(exec->globalData(), exec->propertyNames().prototype, JSFloat64ArrayPrototype::self(exec, globalObject), DontDelete | ReadOnly);
68 putDirect(exec->globalData(), exec->propertyNames().length, jsNumber(123), ReadOnly | DontDelete | DontEnum);
71 bool JSFloat64ArrayConstructor::getOwnPropertySlot(JSCell* cell, ExecState* exec, PropertyName propertyName, PropertySlot& slot)
73 return getStaticValueSlot<JSFloat64ArrayConstructor, JSDOMWrapper>(exec, &JSFloat64ArrayConstructorTable, jsCast<JSFloat64ArrayConstructor*>(cell), propertyName, slot);
76 bool JSFloat64ArrayConstructor::getOwnPropertyDescriptor(JSObject* object, ExecState* exec, PropertyName propertyName, PropertyDescriptor& descriptor)
78 return getStaticValueDescriptor<JSFloat64ArrayConstructor, JSDOMWrapper>(exec, &JSFloat64ArrayConstructorTable, jsCast<JSFloat64ArrayConstructor*>(object), propertyName, descriptor);
81 EncodedJSValue JSC_HOST_CALL JSFloat64ArrayConstructor::constructJSFloat64Array(ExecState* exec)
83 JSFloat64ArrayConstructor* jsConstructor = jsCast<JSFloat64ArrayConstructor*>(exec->callee());
84 RefPtr<Float64Array> array = constructArrayBufferView<Float64Array, double>(exec);
86 // Exception has already been thrown.
87 return JSValue::encode(JSValue());
88 return JSValue::encode(asObject(toJS(exec, jsConstructor->globalObject(), array.get())));
91 JSC::JSValue toJS(JSC::ExecState* exec, JSDOMGlobalObject* globalObject, Float64Array* object)
93 return toJSArrayBufferView<JSFloat64Array>(exec, globalObject, object);
96 void JSFloat64Array::indexSetter(JSC::ExecState* exec, unsigned index, JSC::JSValue value)
98 impl()->set(index, value.toNumber(exec));
101 ConstructType JSFloat64ArrayConstructor::getConstructData(JSCell*, ConstructData& constructData)
103 constructData.native.function = constructJSFloat64Array;
104 return ConstructTypeHost;
107 /* Hash table for prototype */
109 static const HashTableValue JSFloat64ArrayPrototypeTableValues[] =
111 { "foo", DontDelete | JSC::Function, (intptr_t)static_cast<NativeFunction>(jsFloat64ArrayPrototypeFunctionFoo), (intptr_t)1, NoIntrinsic },
112 { "set", DontDelete | JSC::Function, (intptr_t)static_cast<NativeFunction>(jsFloat64ArrayPrototypeFunctionSet), (intptr_t)0, NoIntrinsic },
113 { 0, 0, 0, 0, NoIntrinsic }
116 static const HashTable JSFloat64ArrayPrototypeTable = { 4, 3, JSFloat64ArrayPrototypeTableValues, 0 };
117 static const HashTable* getJSFloat64ArrayPrototypeTable(ExecState* exec)
119 return getHashTableForGlobalData(exec->globalData(), &JSFloat64ArrayPrototypeTable);
122 const ClassInfo JSFloat64ArrayPrototype::s_info = { "Float64ArrayPrototype", &Base::s_info, 0, getJSFloat64ArrayPrototypeTable, CREATE_METHOD_TABLE(JSFloat64ArrayPrototype) };
124 JSObject* JSFloat64ArrayPrototype::self(ExecState* exec, JSGlobalObject* globalObject)
126 return getDOMPrototype<JSFloat64Array>(exec, globalObject);
129 bool JSFloat64ArrayPrototype::getOwnPropertySlot(JSCell* cell, ExecState* exec, PropertyName propertyName, PropertySlot& slot)
131 JSFloat64ArrayPrototype* thisObject = jsCast<JSFloat64ArrayPrototype*>(cell);
132 return getStaticFunctionSlot<JSObject>(exec, getJSFloat64ArrayPrototypeTable(exec), thisObject, propertyName, slot);
135 bool JSFloat64ArrayPrototype::getOwnPropertyDescriptor(JSObject* object, ExecState* exec, PropertyName propertyName, PropertyDescriptor& descriptor)
137 JSFloat64ArrayPrototype* thisObject = jsCast<JSFloat64ArrayPrototype*>(object);
138 return getStaticFunctionDescriptor<JSObject>(exec, getJSFloat64ArrayPrototypeTable(exec), thisObject, propertyName, descriptor);
141 static const HashTable* getJSFloat64ArrayTable(ExecState* exec)
143 return getHashTableForGlobalData(exec->globalData(), &JSFloat64ArrayTable);
146 const ClassInfo JSFloat64Array::s_info = { "Float64Array", &Base::s_info, 0, getJSFloat64ArrayTable , CREATE_METHOD_TABLE(JSFloat64Array) };
148 JSFloat64Array::JSFloat64Array(Structure* structure, JSDOMGlobalObject* globalObject, PassRefPtr<Float64Array> impl)
149 : JSArrayBufferView(structure, globalObject, impl)
153 void JSFloat64Array::finishCreation(JSGlobalData& globalData)
155 Base::finishCreation(globalData);
156 TypedArrayDescriptor descriptor(&JSFloat64Array::s_info, OBJECT_OFFSETOF(JSFloat64Array, m_storage), OBJECT_OFFSETOF(JSFloat64Array, m_storageLength));
157 globalData.registerTypedArrayDescriptor(impl(), descriptor);
158 m_storage = impl()->data();
159 m_storageLength = impl()->length();
160 ASSERT(inherits(&s_info));
163 JSObject* JSFloat64Array::createPrototype(ExecState* exec, JSGlobalObject* globalObject)
165 return JSFloat64ArrayPrototype::create(exec->globalData(), globalObject, JSFloat64ArrayPrototype::createStructure(exec->globalData(), globalObject, JSArrayBufferViewPrototype::self(exec, globalObject)));
168 bool JSFloat64Array::getOwnPropertySlot(JSCell* cell, ExecState* exec, PropertyName propertyName, PropertySlot& slot)
170 JSFloat64Array* thisObject = jsCast<JSFloat64Array*>(cell);
171 ASSERT_GC_OBJECT_INHERITS(thisObject, &s_info);
172 unsigned index = propertyName.asIndex();
173 if (index != PropertyName::NotAnIndex && index < static_cast<Float64Array*>(thisObject->impl())->length()) {
174 slot.setValue(thisObject->getByIndex(exec, index));
177 return getStaticValueSlot<JSFloat64Array, Base>(exec, getJSFloat64ArrayTable(exec), thisObject, propertyName, slot);
180 bool JSFloat64Array::getOwnPropertyDescriptor(JSObject* object, ExecState* exec, PropertyName propertyName, PropertyDescriptor& descriptor)
182 JSFloat64Array* thisObject = jsCast<JSFloat64Array*>(object);
183 ASSERT_GC_OBJECT_INHERITS(thisObject, &s_info);
184 unsigned index = propertyName.asIndex();
185 if (index != PropertyName::NotAnIndex && index < static_cast<Float64Array*>(thisObject->impl())->length()) {
186 descriptor.setDescriptor(thisObject->getByIndex(exec, index), DontDelete);
189 return getStaticValueDescriptor<JSFloat64Array, Base>(exec, getJSFloat64ArrayTable(exec), thisObject, propertyName, descriptor);
192 bool JSFloat64Array::getOwnPropertySlotByIndex(JSCell* cell, ExecState* exec, unsigned index, PropertySlot& slot)
194 JSFloat64Array* thisObject = jsCast<JSFloat64Array*>(cell);
195 ASSERT_GC_OBJECT_INHERITS(thisObject, &s_info);
196 if (index < static_cast<Float64Array*>(thisObject->impl())->length()) {
197 slot.setValue(thisObject->getByIndex(exec, index));
200 return Base::getOwnPropertySlotByIndex(thisObject, exec, index, slot);
203 JSValue jsFloat64ArrayConstructor(ExecState* exec, JSValue slotBase, PropertyName)
205 JSFloat64Array* domObject = jsCast<JSFloat64Array*>(asObject(slotBase));
206 return JSFloat64Array::getConstructor(exec, domObject->globalObject());
209 void JSFloat64Array::put(JSCell* cell, ExecState* exec, PropertyName propertyName, JSValue value, PutPropertySlot& slot)
211 JSFloat64Array* thisObject = jsCast<JSFloat64Array*>(cell);
212 ASSERT_GC_OBJECT_INHERITS(thisObject, &s_info);
213 unsigned index = propertyName.asIndex();
214 if (index != PropertyName::NotAnIndex) {
215 thisObject->indexSetter(exec, index, value);
218 Base::put(thisObject, exec, propertyName, value, slot);
221 void JSFloat64Array::putByIndex(JSCell* cell, ExecState* exec, unsigned index, JSValue value, bool shouldThrow)
223 JSFloat64Array* thisObject = jsCast<JSFloat64Array*>(cell);
224 ASSERT_GC_OBJECT_INHERITS(thisObject, &s_info);
225 if (index <= MAX_ARRAY_INDEX) {
226 UNUSED_PARAM(shouldThrow);
227 thisObject->indexSetter(exec, index, value);
230 Base::putByIndex(cell, exec, index, value, shouldThrow);
233 void JSFloat64Array::getOwnPropertyNames(JSObject* object, ExecState* exec, PropertyNameArray& propertyNames, EnumerationMode mode)
235 JSFloat64Array* thisObject = jsCast<JSFloat64Array*>(object);
236 ASSERT_GC_OBJECT_INHERITS(thisObject, &s_info);
237 for (unsigned i = 0; i < static_cast<Float64Array*>(thisObject->impl())->length(); ++i)
238 propertyNames.add(Identifier::from(exec, i));
239 Base::getOwnPropertyNames(thisObject, exec, propertyNames, mode);
242 JSValue JSFloat64Array::getConstructor(ExecState* exec, JSGlobalObject* globalObject)
244 return getDOMConstructor<JSFloat64ArrayConstructor>(exec, jsCast<JSDOMGlobalObject*>(globalObject));
247 EncodedJSValue JSC_HOST_CALL jsFloat64ArrayPrototypeFunctionFoo(ExecState* exec)
249 JSValue thisValue = exec->hostThisValue();
250 if (!thisValue.inherits(&JSFloat64Array::s_info))
251 return throwVMTypeError(exec);
252 JSFloat64Array* castedThis = jsCast<JSFloat64Array*>(asObject(thisValue));
253 ASSERT_GC_OBJECT_INHERITS(castedThis, &JSFloat64Array::s_info);
254 Float64Array* impl = static_cast<Float64Array*>(castedThis->impl());
255 if (exec->argumentCount() < 1)
256 return throwVMError(exec, createNotEnoughArgumentsError(exec));
257 Float32Array* array(toFloat32Array(MAYBE_MISSING_PARAMETER(exec, 0, DefaultIsUndefined)));
258 if (exec->hadException())
259 return JSValue::encode(jsUndefined());
261 JSC::JSValue result = toJS(exec, castedThis->globalObject(), WTF::getPtr(impl->foo(array)));
262 return JSValue::encode(result);
265 EncodedJSValue JSC_HOST_CALL jsFloat64ArrayPrototypeFunctionSet(ExecState* exec)
267 JSValue thisValue = exec->hostThisValue();
268 if (!thisValue.inherits(&JSFloat64Array::s_info))
269 return throwVMTypeError(exec);
270 JSFloat64Array* castedThis = jsCast<JSFloat64Array*>(asObject(thisValue));
271 ASSERT_GC_OBJECT_INHERITS(castedThis, &JSFloat64Array::s_info);
272 return JSValue::encode(setWebGLArrayHelper<Float64Array, double>(exec, castedThis->impl()));
276 JSValue JSFloat64Array::getByIndex(ExecState*, unsigned index)
278 ASSERT_GC_OBJECT_INHERITS(this, &s_info);
279 double result = static_cast<Float64Array*>(impl())->item(index);
282 return JSValue(result);
285 Float64Array* toFloat64Array(JSC::JSValue value)
287 return value.inherits(&JSFloat64Array::s_info) ? jsCast<JSFloat64Array*>(asObject(value))->impl() : 0;