tizen beta release
[profile/ivi/webkit-efl.git] / DerivedSources / WebCore / JSFloat32Array.cpp
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 #include "JSFloat32Array.h"
23
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>
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 #if ENABLE(DFG_JIT)
45 #define INTRINSIC(intrinsic) , intrinsic
46 #else
47 #define INTRINSIC(intrinsic)
48 #endif
49
50 static const HashTableValue JSFloat32ArrayTableValues[] =
51 {
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) }
55 };
56
57 #undef THUNK_GENERATOR
58 static const HashTable JSFloat32ArrayTable = { 5, 3, JSFloat32ArrayTableValues, 0 };
59 /* Hash table for constructor */
60 #if ENABLE(JIT)
61 #define THUNK_GENERATOR(generator) , generator
62 #else
63 #define THUNK_GENERATOR(generator)
64 #endif
65 #if ENABLE(DFG_JIT)
66 #define INTRINSIC(intrinsic) , intrinsic
67 #else
68 #define INTRINSIC(intrinsic)
69 #endif
70
71 static const HashTableValue JSFloat32ArrayConstructorTableValues[] =
72 {
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) }
75 };
76
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) };
80
81 JSFloat32ArrayConstructor::JSFloat32ArrayConstructor(Structure* structure, JSDOMGlobalObject* globalObject)
82     : DOMConstructorObject(structure, globalObject)
83 {
84 }
85
86 void JSFloat32ArrayConstructor::finishCreation(ExecState* exec, JSDOMGlobalObject* globalObject)
87 {
88     Base::finishCreation(exec->globalData());
89     ASSERT(inherits(&s_info));
90     putDirect(exec->globalData(), exec->propertyNames().prototype, JSFloat32ArrayPrototype::self(exec, globalObject), DontDelete | ReadOnly);
91 }
92
93 bool JSFloat32ArrayConstructor::getOwnPropertySlot(JSCell* cell, ExecState* exec, const Identifier& propertyName, PropertySlot& slot)
94 {
95     return getStaticValueSlot<JSFloat32ArrayConstructor, JSDOMWrapper>(exec, &JSFloat32ArrayConstructorTable, static_cast<JSFloat32ArrayConstructor*>(cell), propertyName, slot);
96 }
97
98 bool JSFloat32ArrayConstructor::getOwnPropertyDescriptor(JSObject* object, ExecState* exec, const Identifier& propertyName, PropertyDescriptor& descriptor)
99 {
100     return getStaticValueDescriptor<JSFloat32ArrayConstructor, JSDOMWrapper>(exec, &JSFloat32ArrayConstructorTable, static_cast<JSFloat32ArrayConstructor*>(object), propertyName, descriptor);
101 }
102
103 ConstructType JSFloat32ArrayConstructor::getConstructData(JSCell*, ConstructData& constructData)
104 {
105     constructData.native.function = constructJSFloat32Array;
106     return ConstructTypeHost;
107 }
108
109 /* Hash table for prototype */
110 #if ENABLE(JIT)
111 #define THUNK_GENERATOR(generator) , generator
112 #else
113 #define THUNK_GENERATOR(generator)
114 #endif
115 #if ENABLE(DFG_JIT)
116 #define INTRINSIC(intrinsic) , intrinsic
117 #else
118 #define INTRINSIC(intrinsic)
119 #endif
120
121 static const HashTableValue JSFloat32ArrayPrototypeTableValues[] =
122 {
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) }
127 };
128
129 #undef THUNK_GENERATOR
130 static const HashTable JSFloat32ArrayPrototypeTable = { 8, 7, JSFloat32ArrayPrototypeTableValues, 0 };
131 static const HashTable* getJSFloat32ArrayPrototypeTable(ExecState* exec)
132 {
133     return getHashTableForGlobalData(exec->globalData(), &JSFloat32ArrayPrototypeTable);
134 }
135
136 const ClassInfo JSFloat32ArrayPrototype::s_info = { "Float32ArrayPrototype", &JSC::JSNonFinalObject::s_info, 0, getJSFloat32ArrayPrototypeTable, CREATE_METHOD_TABLE(JSFloat32ArrayPrototype) };
137
138 JSObject* JSFloat32ArrayPrototype::self(ExecState* exec, JSGlobalObject* globalObject)
139 {
140     return getDOMPrototype<JSFloat32Array>(exec, globalObject);
141 }
142
143 bool JSFloat32ArrayPrototype::getOwnPropertySlot(JSCell* cell, ExecState* exec, const Identifier& propertyName, PropertySlot& slot)
144 {
145     JSFloat32ArrayPrototype* thisObject = jsCast<JSFloat32ArrayPrototype*>(cell);
146     return getStaticPropertySlot<JSFloat32ArrayPrototype, JSObject>(exec, getJSFloat32ArrayPrototypeTable(exec), thisObject, propertyName, slot);
147 }
148
149 bool JSFloat32ArrayPrototype::getOwnPropertyDescriptor(JSObject* object, ExecState* exec, const Identifier& propertyName, PropertyDescriptor& descriptor)
150 {
151     JSFloat32ArrayPrototype* thisObject = jsCast<JSFloat32ArrayPrototype*>(object);
152     return getStaticPropertyDescriptor<JSFloat32ArrayPrototype, JSObject>(exec, getJSFloat32ArrayPrototypeTable(exec), thisObject, propertyName, descriptor);
153 }
154
155 static const HashTable* getJSFloat32ArrayTable(ExecState* exec)
156 {
157     return getHashTableForGlobalData(exec->globalData(), &JSFloat32ArrayTable);
158 }
159
160 const ClassInfo JSFloat32Array::s_info = { "Float32Array", &JSArrayBufferView::s_info, 0, getJSFloat32ArrayTable , CREATE_METHOD_TABLE(JSFloat32Array) };
161
162 JSFloat32Array::JSFloat32Array(Structure* structure, JSDOMGlobalObject* globalObject, PassRefPtr<Float32Array> impl)
163     : JSArrayBufferView(structure, globalObject, impl)
164 {
165 }
166
167 void JSFloat32Array::finishCreation(JSGlobalData& globalData)
168 {
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));
175 }
176
177 JSObject* JSFloat32Array::createPrototype(ExecState* exec, JSGlobalObject* globalObject)
178 {
179     return JSFloat32ArrayPrototype::create(exec->globalData(), globalObject, JSFloat32ArrayPrototype::createStructure(exec->globalData(), globalObject, JSArrayBufferViewPrototype::self(exec, globalObject)));
180 }
181
182 bool JSFloat32Array::getOwnPropertySlot(JSCell* cell, ExecState* exec, const Identifier& propertyName, PropertySlot& slot)
183 {
184     JSFloat32Array* thisObject = jsCast<JSFloat32Array*>(cell);
185     ASSERT_GC_OBJECT_INHERITS(thisObject, &s_info);
186     bool ok;
187     unsigned index = propertyName.toUInt32(ok);
188     if (ok && index < static_cast<Float32Array*>(thisObject->impl())->length()) {
189         slot.setValue(thisObject->getByIndex(exec, index));
190         return true;
191     }
192     return getStaticValueSlot<JSFloat32Array, Base>(exec, getJSFloat32ArrayTable(exec), thisObject, propertyName, slot);
193 }
194
195 bool JSFloat32Array::getOwnPropertyDescriptor(JSObject* object, ExecState* exec, const Identifier& propertyName, PropertyDescriptor& descriptor)
196 {
197     JSFloat32Array* thisObject = jsCast<JSFloat32Array*>(object);
198     ASSERT_GC_OBJECT_INHERITS(thisObject, &s_info);
199     bool ok;
200     unsigned index = propertyName.toUInt32(ok);
201     if (ok && index < static_cast<Float32Array*>(thisObject->impl())->length()) {
202         descriptor.setDescriptor(thisObject->getByIndex(exec, index), DontDelete);
203         return true;
204     }
205     return getStaticValueDescriptor<JSFloat32Array, Base>(exec, getJSFloat32ArrayTable(exec), thisObject, propertyName, descriptor);
206 }
207
208 bool JSFloat32Array::getOwnPropertySlotByIndex(JSCell* cell, ExecState* exec, unsigned propertyName, PropertySlot& slot)
209 {
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));
214         return true;
215     }
216     return thisObject->methodTable()->getOwnPropertySlot(thisObject, exec, Identifier::from(exec, propertyName), slot);
217 }
218
219 JSValue jsFloat32ArrayLength(ExecState* exec, JSValue slotBase, const Identifier&)
220 {
221     JSFloat32Array* castedThis = static_cast<JSFloat32Array*>(asObject(slotBase));
222     UNUSED_PARAM(exec);
223     Float32Array* imp = static_cast<Float32Array*>(castedThis->impl());
224     JSValue result = jsNumber(imp->length());
225     return result;
226 }
227
228
229 JSValue jsFloat32ArrayConstructor(ExecState* exec, JSValue slotBase, const Identifier&)
230 {
231     JSFloat32Array* domObject = static_cast<JSFloat32Array*>(asObject(slotBase));
232     return JSFloat32Array::getConstructor(exec, domObject->globalObject());
233 }
234
235 void JSFloat32Array::put(JSCell* cell, ExecState* exec, const Identifier& propertyName, JSValue value, PutPropertySlot& slot)
236 {
237     JSFloat32Array* thisObject = jsCast<JSFloat32Array*>(cell);
238     ASSERT_GC_OBJECT_INHERITS(thisObject, &s_info);
239     bool ok;
240     unsigned index = propertyName.toUInt32(ok);
241     if (ok) {
242         thisObject->indexSetter(exec, index, value);
243         return;
244     }
245     Base::put(thisObject, exec, propertyName, value, slot);
246 }
247
248 void JSFloat32Array::putByIndex(JSCell* cell, ExecState* exec, unsigned propertyName, JSValue value)
249 {
250     JSFloat32Array* thisObject = jsCast<JSFloat32Array*>(cell);
251     ASSERT_GC_OBJECT_INHERITS(thisObject, &s_info);
252     thisObject->indexSetter(exec, propertyName, value);
253     return;
254 }
255
256 void JSFloat32Array::getOwnPropertyNames(JSObject* object, ExecState* exec, PropertyNameArray& propertyNames, EnumerationMode mode)
257 {
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);
263 }
264
265 JSValue JSFloat32Array::getConstructor(ExecState* exec, JSGlobalObject* globalObject)
266 {
267     return getDOMConstructor<JSFloat32ArrayConstructor>(exec, static_cast<JSDOMGlobalObject*>(globalObject));
268 }
269
270 EncodedJSValue JSC_HOST_CALL jsFloat32ArrayPrototypeFunctionSubarray(ExecState* exec)
271 {
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());
281
282     size_t argsCount = exec->argumentCount();
283     if (argsCount <= 1) {
284
285         JSC::JSValue result = toJS(exec, castedThis->globalObject(), WTF::getPtr(imp->subarray(start)));
286         return JSValue::encode(result);
287     }
288
289     int end(MAYBE_MISSING_PARAMETER(exec, 1, MissingIsUndefined).toInt32(exec));
290     if (exec->hadException())
291         return JSValue::encode(jsUndefined());
292
293     JSC::JSValue result = toJS(exec, castedThis->globalObject(), WTF::getPtr(imp->subarray(start, end)));
294     return JSValue::encode(result);
295 }
296
297 EncodedJSValue JSC_HOST_CALL jsFloat32ArrayPrototypeFunctionSet(ExecState* exec)
298 {
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));
305 }
306
307 // Constant getters
308
309 JSValue jsFloat32ArrayBYTES_PER_ELEMENT(ExecState* exec, JSValue, const Identifier&)
310 {
311     UNUSED_PARAM(exec);
312     return jsNumber(static_cast<int>(4));
313 }
314
315
316 JSValue JSFloat32Array::getByIndex(ExecState*, unsigned index)
317 {
318     ASSERT_GC_OBJECT_INHERITS(this, &s_info);
319     double result = static_cast<Float32Array*>(impl())->item(index);
320     if (isnan(result))
321         return jsNaN();
322     return JSValue(result);
323 }
324
325 Float32Array* toFloat32Array(JSC::JSValue value)
326 {
327     return value.inherits(&JSFloat32Array::s_info) ? static_cast<JSFloat32Array*>(asObject(value))->impl() : 0;
328 }
329
330 }