Skip to content
This repository was archived by the owner on Jun 20, 2019. It is now read-only.

Commit 1ab0a57

Browse files
committed
Added all other Typed Array types
1 parent 2d38652 commit 1ab0a57

25 files changed

+4153
-0
lines changed

JavaScriptCore/JavaScriptCore.xcodeproj/project.pbxproj

Lines changed: 144 additions & 0 deletions
Large diffs are not rendered by default.
Lines changed: 297 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,297 @@
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 "JSFloat64Array.h"
23+
24+
#include "ExceptionCode.h"
25+
#include "JSDOMBinding.h"
26+
#include "JSFloat64Array.h"
27+
#include <runtime/Error.h>
28+
#include <runtime/PropertyNameArray.h>
29+
#include <wtf/Float64Array.h>
30+
#include <wtf/GetPtr.h>
31+
32+
using namespace JSC;
33+
34+
namespace WebCore {
35+
36+
ASSERT_CLASS_FITS_IN_CELL(JSFloat64Array);
37+
/* Hash table */
38+
39+
static const HashTableValue JSFloat64ArrayTableValues[] =
40+
{
41+
{ "length", DontDelete | ReadOnly, (intptr_t)static_cast<PropertySlot::GetValueFunc>(jsFloat64ArrayLength), (intptr_t)0, NoIntrinsic },
42+
{ "constructor", DontEnum | ReadOnly, (intptr_t)static_cast<PropertySlot::GetValueFunc>(jsFloat64ArrayConstructor), (intptr_t)0, NoIntrinsic },
43+
{ 0, 0, 0, 0, NoIntrinsic }
44+
};
45+
46+
static const HashTable JSFloat64ArrayTable = { 5, 3, JSFloat64ArrayTableValues, 0 };
47+
/* Hash table for constructor */
48+
49+
static const HashTableValue JSFloat64ArrayConstructorTableValues[] =
50+
{
51+
{ "BYTES_PER_ELEMENT", DontDelete | ReadOnly, (intptr_t)static_cast<PropertySlot::GetValueFunc>(jsFloat64ArrayBYTES_PER_ELEMENT), (intptr_t)0, NoIntrinsic },
52+
{ 0, 0, 0, 0, NoIntrinsic }
53+
};
54+
55+
static const HashTable JSFloat64ArrayConstructorTable = { 2, 1, JSFloat64ArrayConstructorTableValues, 0 };
56+
const ClassInfo JSFloat64ArrayConstructor::s_info = { "Float64ArrayConstructor", &Base::s_info, &JSFloat64ArrayConstructorTable, 0, CREATE_METHOD_TABLE(JSFloat64ArrayConstructor) };
57+
58+
JSFloat64ArrayConstructor::JSFloat64ArrayConstructor(Structure* structure, JSDOMGlobalObject* globalObject)
59+
: DOMConstructorObject(structure, globalObject)
60+
{
61+
}
62+
63+
void JSFloat64ArrayConstructor::finishCreation(ExecState* exec, JSDOMGlobalObject* globalObject)
64+
{
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(1), ReadOnly | DontDelete | DontEnum);
69+
}
70+
71+
bool JSFloat64ArrayConstructor::getOwnPropertySlot(JSCell* cell, ExecState* exec, const Identifier& propertyName, PropertySlot& slot)
72+
{
73+
return getStaticValueSlot<JSFloat64ArrayConstructor, JSDOMWrapper>(exec, &JSFloat64ArrayConstructorTable, jsCast<JSFloat64ArrayConstructor*>(cell), propertyName, slot);
74+
}
75+
76+
bool JSFloat64ArrayConstructor::getOwnPropertyDescriptor(JSObject* object, ExecState* exec, const Identifier& propertyName, PropertyDescriptor& descriptor)
77+
{
78+
return getStaticValueDescriptor<JSFloat64ArrayConstructor, JSDOMWrapper>(exec, &JSFloat64ArrayConstructorTable, jsCast<JSFloat64ArrayConstructor*>(object), propertyName, descriptor);
79+
}
80+
81+
ConstructType JSFloat64ArrayConstructor::getConstructData(JSCell*, ConstructData& constructData)
82+
{
83+
constructData.native.function = constructJSFloat64Array;
84+
return ConstructTypeHost;
85+
}
86+
87+
/* Hash table for prototype */
88+
89+
static const HashTableValue JSFloat64ArrayPrototypeTableValues[] =
90+
{
91+
{ "BYTES_PER_ELEMENT", DontDelete | ReadOnly, (intptr_t)static_cast<PropertySlot::GetValueFunc>(jsFloat64ArrayBYTES_PER_ELEMENT), (intptr_t)0, NoIntrinsic },
92+
{ "subarray", DontDelete | JSC::Function, (intptr_t)static_cast<NativeFunction>(jsFloat64ArrayPrototypeFunctionSubarray), (intptr_t)2, NoIntrinsic },
93+
{ "set", DontDelete | JSC::Function, (intptr_t)static_cast<NativeFunction>(jsFloat64ArrayPrototypeFunctionSet), (intptr_t)0, NoIntrinsic },
94+
{ 0, 0, 0, 0, NoIntrinsic }
95+
};
96+
97+
static const HashTable JSFloat64ArrayPrototypeTable = { 8, 7, JSFloat64ArrayPrototypeTableValues, 0 };
98+
static const HashTable* getJSFloat64ArrayPrototypeTable(ExecState* exec)
99+
{
100+
return getHashTableForGlobalData(exec->globalData(), &JSFloat64ArrayPrototypeTable);
101+
}
102+
103+
const ClassInfo JSFloat64ArrayPrototype::s_info = { "Float64ArrayPrototype", &Base::s_info, 0, getJSFloat64ArrayPrototypeTable, CREATE_METHOD_TABLE(JSFloat64ArrayPrototype) };
104+
105+
JSObject* JSFloat64ArrayPrototype::self(ExecState* exec, JSGlobalObject* globalObject)
106+
{
107+
return getDOMPrototype<JSFloat64Array>(exec, globalObject);
108+
}
109+
110+
bool JSFloat64ArrayPrototype::getOwnPropertySlot(JSCell* cell, ExecState* exec, const Identifier& propertyName, PropertySlot& slot)
111+
{
112+
JSFloat64ArrayPrototype* thisObject = jsCast<JSFloat64ArrayPrototype*>(cell);
113+
return getStaticPropertySlot<JSFloat64ArrayPrototype, JSObject>(exec, getJSFloat64ArrayPrototypeTable(exec), thisObject, propertyName, slot);
114+
}
115+
116+
bool JSFloat64ArrayPrototype::getOwnPropertyDescriptor(JSObject* object, ExecState* exec, const Identifier& propertyName, PropertyDescriptor& descriptor)
117+
{
118+
JSFloat64ArrayPrototype* thisObject = jsCast<JSFloat64ArrayPrototype*>(object);
119+
return getStaticPropertyDescriptor<JSFloat64ArrayPrototype, JSObject>(exec, getJSFloat64ArrayPrototypeTable(exec), thisObject, propertyName, descriptor);
120+
}
121+
122+
static const HashTable* getJSFloat64ArrayTable(ExecState* exec)
123+
{
124+
return getHashTableForGlobalData(exec->globalData(), &JSFloat64ArrayTable);
125+
}
126+
127+
const ClassInfo JSFloat64Array::s_info = { "Float64Array", &Base::s_info, 0, getJSFloat64ArrayTable , CREATE_METHOD_TABLE(JSFloat64Array) };
128+
129+
JSFloat64Array::JSFloat64Array(Structure* structure, JSDOMGlobalObject* globalObject, PassRefPtr<Float64Array> impl)
130+
: JSArrayBufferView(structure, globalObject, impl)
131+
{
132+
}
133+
134+
void JSFloat64Array::finishCreation(JSGlobalData& globalData)
135+
{
136+
Base::finishCreation(globalData);
137+
TypedArrayDescriptor descriptor(&JSFloat64Array::s_info, OBJECT_OFFSETOF(JSFloat64Array, m_storage), OBJECT_OFFSETOF(JSFloat64Array, m_storageLength));
138+
globalData.registerTypedArrayDescriptor(impl(), descriptor);
139+
m_storage = impl()->data();
140+
m_storageLength = impl()->length();
141+
ASSERT(inherits(&s_info));
142+
}
143+
144+
JSObject* JSFloat64Array::createPrototype(ExecState* exec, JSGlobalObject* globalObject)
145+
{
146+
return JSFloat64ArrayPrototype::create(exec->globalData(), globalObject, JSFloat64ArrayPrototype::createStructure(exec->globalData(), globalObject, JSArrayBufferViewPrototype::self(exec, globalObject)));
147+
}
148+
149+
bool JSFloat64Array::getOwnPropertySlot(JSCell* cell, ExecState* exec, const Identifier& propertyName, PropertySlot& slot)
150+
{
151+
JSFloat64Array* thisObject = jsCast<JSFloat64Array*>(cell);
152+
ASSERT_GC_OBJECT_INHERITS(thisObject, &s_info);
153+
bool ok;
154+
unsigned index = propertyName.toUInt32(ok);
155+
if (ok && index < static_cast<Float64Array*>(thisObject->impl())->length()) {
156+
slot.setValue(thisObject->getByIndex(exec, index));
157+
return true;
158+
}
159+
return getStaticValueSlot<JSFloat64Array, Base>(exec, getJSFloat64ArrayTable(exec), thisObject, propertyName, slot);
160+
}
161+
162+
bool JSFloat64Array::getOwnPropertyDescriptor(JSObject* object, ExecState* exec, const Identifier& propertyName, PropertyDescriptor& descriptor)
163+
{
164+
JSFloat64Array* thisObject = jsCast<JSFloat64Array*>(object);
165+
ASSERT_GC_OBJECT_INHERITS(thisObject, &s_info);
166+
bool ok;
167+
unsigned index = propertyName.toUInt32(ok);
168+
if (ok && index < static_cast<Float64Array*>(thisObject->impl())->length()) {
169+
descriptor.setDescriptor(thisObject->getByIndex(exec, index), DontDelete);
170+
return true;
171+
}
172+
return getStaticValueDescriptor<JSFloat64Array, Base>(exec, getJSFloat64ArrayTable(exec), thisObject, propertyName, descriptor);
173+
}
174+
175+
bool JSFloat64Array::getOwnPropertySlotByIndex(JSCell* cell, ExecState* exec, unsigned propertyName, PropertySlot& slot)
176+
{
177+
JSFloat64Array* thisObject = jsCast<JSFloat64Array*>(cell);
178+
ASSERT_GC_OBJECT_INHERITS(thisObject, &s_info);
179+
if (propertyName < static_cast<Float64Array*>(thisObject->impl())->length()) {
180+
slot.setValue(thisObject->getByIndex(exec, propertyName));
181+
return true;
182+
}
183+
return thisObject->methodTable()->getOwnPropertySlot(thisObject, exec, Identifier::from(exec, propertyName), slot);
184+
}
185+
186+
JSValue jsFloat64ArrayLength(ExecState* exec, JSValue slotBase, const Identifier&)
187+
{
188+
JSFloat64Array* castedThis = jsCast<JSFloat64Array*>(asObject(slotBase));
189+
UNUSED_PARAM(exec);
190+
Float64Array* impl = static_cast<Float64Array*>(castedThis->impl());
191+
JSValue result = jsNumber(impl->length());
192+
return result;
193+
}
194+
195+
196+
JSValue jsFloat64ArrayConstructor(ExecState* exec, JSValue slotBase, const Identifier&)
197+
{
198+
JSFloat64Array* domObject = jsCast<JSFloat64Array*>(asObject(slotBase));
199+
return JSFloat64Array::getConstructor(exec, domObject->globalObject());
200+
}
201+
202+
void JSFloat64Array::put(JSCell* cell, ExecState* exec, const Identifier& propertyName, JSValue value, PutPropertySlot& slot)
203+
{
204+
JSFloat64Array* thisObject = jsCast<JSFloat64Array*>(cell);
205+
ASSERT_GC_OBJECT_INHERITS(thisObject, &s_info);
206+
bool ok;
207+
unsigned index = propertyName.toUInt32(ok);
208+
if (ok) {
209+
thisObject->indexSetter(exec, index, value);
210+
return;
211+
}
212+
Base::put(thisObject, exec, propertyName, value, slot);
213+
}
214+
215+
void JSFloat64Array::putByIndex(JSCell* cell, ExecState* exec, unsigned propertyName, JSValue value, bool)
216+
{
217+
JSFloat64Array* thisObject = jsCast<JSFloat64Array*>(cell);
218+
ASSERT_GC_OBJECT_INHERITS(thisObject, &s_info);
219+
thisObject->indexSetter(exec, propertyName, value);
220+
return;
221+
}
222+
223+
void JSFloat64Array::getOwnPropertyNames(JSObject* object, ExecState* exec, PropertyNameArray& propertyNames, EnumerationMode mode)
224+
{
225+
JSFloat64Array* thisObject = jsCast<JSFloat64Array*>(object);
226+
ASSERT_GC_OBJECT_INHERITS(thisObject, &s_info);
227+
for (unsigned i = 0; i < static_cast<Float64Array*>(thisObject->impl())->length(); ++i)
228+
propertyNames.add(Identifier::from(exec, i));
229+
Base::getOwnPropertyNames(thisObject, exec, propertyNames, mode);
230+
}
231+
232+
JSValue JSFloat64Array::getConstructor(ExecState* exec, JSGlobalObject* globalObject)
233+
{
234+
return getDOMConstructor<JSFloat64ArrayConstructor>(exec, jsCast<JSDOMGlobalObject*>(globalObject));
235+
}
236+
237+
EncodedJSValue JSC_HOST_CALL jsFloat64ArrayPrototypeFunctionSubarray(ExecState* exec)
238+
{
239+
JSValue thisValue = exec->hostThisValue();
240+
if (!thisValue.inherits(&JSFloat64Array::s_info))
241+
return throwVMTypeError(exec);
242+
JSFloat64Array* castedThis = jsCast<JSFloat64Array*>(asObject(thisValue));
243+
ASSERT_GC_OBJECT_INHERITS(castedThis, &JSFloat64Array::s_info);
244+
Float64Array* impl = static_cast<Float64Array*>(castedThis->impl());
245+
int start(MAYBE_MISSING_PARAMETER(exec, 0, DefaultIsUndefined).toInt32(exec));
246+
if (exec->hadException())
247+
return JSValue::encode(jsUndefined());
248+
249+
size_t argsCount = exec->argumentCount();
250+
if (argsCount <= 1) {
251+
252+
JSC::JSValue result = toJS(exec, castedThis->globalObject(), WTF::getPtr(impl->subarray(start)));
253+
return JSValue::encode(result);
254+
}
255+
256+
int end(MAYBE_MISSING_PARAMETER(exec, 1, DefaultIsUndefined).toInt32(exec));
257+
if (exec->hadException())
258+
return JSValue::encode(jsUndefined());
259+
260+
JSC::JSValue result = toJS(exec, castedThis->globalObject(), WTF::getPtr(impl->subarray(start, end)));
261+
return JSValue::encode(result);
262+
}
263+
264+
EncodedJSValue JSC_HOST_CALL jsFloat64ArrayPrototypeFunctionSet(ExecState* exec)
265+
{
266+
JSValue thisValue = exec->hostThisValue();
267+
if (!thisValue.inherits(&JSFloat64Array::s_info))
268+
return throwVMTypeError(exec);
269+
JSFloat64Array* castedThis = jsCast<JSFloat64Array*>(asObject(thisValue));
270+
ASSERT_GC_OBJECT_INHERITS(castedThis, &JSFloat64Array::s_info);
271+
return JSValue::encode(castedThis->set(exec));
272+
}
273+
274+
// Constant getters
275+
276+
JSValue jsFloat64ArrayBYTES_PER_ELEMENT(ExecState* exec, JSValue, const Identifier&)
277+
{
278+
UNUSED_PARAM(exec);
279+
return jsNumber(static_cast<int>(8));
280+
}
281+
282+
283+
JSValue JSFloat64Array::getByIndex(ExecState*, unsigned index)
284+
{
285+
ASSERT_GC_OBJECT_INHERITS(this, &s_info);
286+
double result = static_cast<Float64Array*>(impl())->item(index);
287+
if (isnan(result))
288+
return jsNaN();
289+
return JSValue(result);
290+
}
291+
292+
Float64Array* toFloat64Array(JSC::JSValue value)
293+
{
294+
return value.inherits(&JSFloat64Array::s_info) ? jsCast<JSFloat64Array*>(asObject(value))->impl() : 0;
295+
}
296+
297+
}

0 commit comments

Comments
 (0)