1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295
|
/*
This file is part of the WebKit open source project.
This file has been generated by generate-bindings.pl. DO NOT MODIFY!
This library is free software; you can redistribute it and/or
modify it under the terms of the GNU Library General Public
License as published by the Free Software Foundation; either
version 2 of the License, or (at your option) any later version.
This library is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
Library General Public License for more details.
You should have received a copy of the GNU Library General Public License
along with this library; see the file COPYING.LIB. If not, write to
the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
Boston, MA 02110-1301, USA.
*/
#include "config.h"
#include "JSFloat64Array.h"
#include "ExceptionCode.h"
#include "JSArrayBufferViewHelper.h"
#include "JSDOMBinding.h"
#include "JSFloat32Array.h"
#include "JSInt32Array.h"
#include <runtime/Error.h>
#include <runtime/PropertyNameArray.h>
#include <wtf/Float64Array.h>
#include <wtf/GetPtr.h>
#include <wtf/Int32Array.h>
using namespace JSC;
namespace WebCore {
/* Hash table */
static const HashTableValue JSFloat64ArrayTableValues[] =
{
{ "constructor", DontEnum | ReadOnly, (intptr_t)static_cast<PropertySlot::GetValueFunc>(jsFloat64ArrayConstructor), (intptr_t)0, NoIntrinsic },
{ 0, 0, 0, 0, NoIntrinsic }
};
static const HashTable JSFloat64ArrayTable = { 2, 1, JSFloat64ArrayTableValues, 0 };
/* Hash table for constructor */
static const HashTableValue JSFloat64ArrayConstructorTableValues[] =
{
{ 0, 0, 0, 0, NoIntrinsic }
};
static const HashTable JSFloat64ArrayConstructorTable = { 1, 0, JSFloat64ArrayConstructorTableValues, 0 };
EncodedJSValue JSC_HOST_CALL JSFloat64ArrayConstructor::constructJSFloat64Array(ExecState* exec)
{
JSFloat64ArrayConstructor* jsConstructor = jsCast<JSFloat64ArrayConstructor*>(exec->callee());
RefPtr<Float64Array> array = constructArrayBufferView<Float64Array, double>(exec);
if (!array.get())
// Exception has already been thrown.
return JSValue::encode(JSValue());
return JSValue::encode(asObject(toJS(exec, jsConstructor->globalObject(), array.get())));
}
JSC::JSValue toJS(JSC::ExecState* exec, JSDOMGlobalObject* globalObject, Float64Array* object)
{
return toJSArrayBufferView<JSFloat64Array>(exec, globalObject, object);
}
void JSFloat64Array::indexSetter(JSC::ExecState* exec, unsigned index, JSC::JSValue value)
{
impl()->set(index, value.toNumber(exec));
}
static const HashTable* getJSFloat64ArrayConstructorTable(ExecState* exec)
{
return getHashTableForGlobalData(exec->vm(), &JSFloat64ArrayConstructorTable);
}
const ClassInfo JSFloat64ArrayConstructor::s_info = { "Float64ArrayConstructor", &Base::s_info, 0, getJSFloat64ArrayConstructorTable, CREATE_METHOD_TABLE(JSFloat64ArrayConstructor) };
JSFloat64ArrayConstructor::JSFloat64ArrayConstructor(Structure* structure, JSDOMGlobalObject* globalObject)
: DOMConstructorObject(structure, globalObject)
{
}
void JSFloat64ArrayConstructor::finishCreation(ExecState* exec, JSDOMGlobalObject* globalObject)
{
Base::finishCreation(exec->vm());
ASSERT(inherits(&s_info));
putDirect(exec->vm(), exec->propertyNames().prototype, JSFloat64ArrayPrototype::self(exec, globalObject), DontDelete | ReadOnly);
putDirect(exec->vm(), exec->propertyNames().length, jsNumber(1), ReadOnly | DontDelete | DontEnum);
}
bool JSFloat64ArrayConstructor::getOwnPropertySlot(JSCell* cell, ExecState* exec, PropertyName propertyName, PropertySlot& slot)
{
return getStaticValueSlot<JSFloat64ArrayConstructor, JSDOMWrapper>(exec, getJSFloat64ArrayConstructorTable(exec), jsCast<JSFloat64ArrayConstructor*>(cell), propertyName, slot);
}
bool JSFloat64ArrayConstructor::getOwnPropertyDescriptor(JSObject* object, ExecState* exec, PropertyName propertyName, PropertyDescriptor& descriptor)
{
return getStaticValueDescriptor<JSFloat64ArrayConstructor, JSDOMWrapper>(exec, getJSFloat64ArrayConstructorTable(exec), jsCast<JSFloat64ArrayConstructor*>(object), propertyName, descriptor);
}
ConstructType JSFloat64ArrayConstructor::getConstructData(JSCell*, ConstructData& constructData)
{
constructData.native.function = constructJSFloat64Array;
return ConstructTypeHost;
}
/* Hash table for prototype */
static const HashTableValue JSFloat64ArrayPrototypeTableValues[] =
{
{ "foo", DontDelete | JSC::Function, (intptr_t)static_cast<NativeFunction>(jsFloat64ArrayPrototypeFunctionFoo), (intptr_t)1, NoIntrinsic },
{ "set", DontDelete | JSC::Function, (intptr_t)static_cast<NativeFunction>(jsFloat64ArrayPrototypeFunctionSet), (intptr_t)0, NoIntrinsic },
{ 0, 0, 0, 0, NoIntrinsic }
};
static const HashTable JSFloat64ArrayPrototypeTable = { 4, 3, JSFloat64ArrayPrototypeTableValues, 0 };
static const HashTable* getJSFloat64ArrayPrototypeTable(ExecState* exec)
{
return getHashTableForGlobalData(exec->vm(), &JSFloat64ArrayPrototypeTable);
}
const ClassInfo JSFloat64ArrayPrototype::s_info = { "Float64ArrayPrototype", &Base::s_info, 0, getJSFloat64ArrayPrototypeTable, CREATE_METHOD_TABLE(JSFloat64ArrayPrototype) };
JSObject* JSFloat64ArrayPrototype::self(ExecState* exec, JSGlobalObject* globalObject)
{
return getDOMPrototype<JSFloat64Array>(exec, globalObject);
}
bool JSFloat64ArrayPrototype::getOwnPropertySlot(JSCell* cell, ExecState* exec, PropertyName propertyName, PropertySlot& slot)
{
JSFloat64ArrayPrototype* thisObject = jsCast<JSFloat64ArrayPrototype*>(cell);
return getStaticFunctionSlot<JSObject>(exec, getJSFloat64ArrayPrototypeTable(exec), thisObject, propertyName, slot);
}
bool JSFloat64ArrayPrototype::getOwnPropertyDescriptor(JSObject* object, ExecState* exec, PropertyName propertyName, PropertyDescriptor& descriptor)
{
JSFloat64ArrayPrototype* thisObject = jsCast<JSFloat64ArrayPrototype*>(object);
return getStaticFunctionDescriptor<JSObject>(exec, getJSFloat64ArrayPrototypeTable(exec), thisObject, propertyName, descriptor);
}
static const HashTable* getJSFloat64ArrayTable(ExecState* exec)
{
return getHashTableForGlobalData(exec->vm(), &JSFloat64ArrayTable);
}
const ClassInfo JSFloat64Array::s_info = { "Float64Array", &Base::s_info, 0, getJSFloat64ArrayTable , CREATE_METHOD_TABLE(JSFloat64Array) };
JSFloat64Array::JSFloat64Array(Structure* structure, JSDOMGlobalObject* globalObject, PassRefPtr<Float64Array> impl)
: JSArrayBufferView(structure, globalObject, impl)
{
}
void JSFloat64Array::finishCreation(VM& vm)
{
Base::finishCreation(vm);
TypedArrayDescriptor descriptor(&JSFloat64Array::s_info, OBJECT_OFFSETOF(JSFloat64Array, m_storage), OBJECT_OFFSETOF(JSFloat64Array, m_storageLength));
vm.registerTypedArrayDescriptor(impl(), descriptor);
m_storage = impl()->data();
m_storageLength = impl()->length();
ASSERT(inherits(&s_info));
}
JSObject* JSFloat64Array::createPrototype(ExecState* exec, JSGlobalObject* globalObject)
{
return JSFloat64ArrayPrototype::create(exec->vm(), globalObject, JSFloat64ArrayPrototype::createStructure(exec->vm(), globalObject, JSArrayBufferViewPrototype::self(exec, globalObject)));
}
bool JSFloat64Array::getOwnPropertySlot(JSCell* cell, ExecState* exec, PropertyName propertyName, PropertySlot& slot)
{
JSFloat64Array* thisObject = jsCast<JSFloat64Array*>(cell);
ASSERT_GC_OBJECT_INHERITS(thisObject, &s_info);
unsigned index = propertyName.asIndex();
if (index != PropertyName::NotAnIndex && index < static_cast<Float64Array*>(thisObject->impl())->length()) {
slot.setValue(thisObject->getByIndex(exec, index));
return true;
}
return getStaticValueSlot<JSFloat64Array, Base>(exec, getJSFloat64ArrayTable(exec), thisObject, propertyName, slot);
}
bool JSFloat64Array::getOwnPropertyDescriptor(JSObject* object, ExecState* exec, PropertyName propertyName, PropertyDescriptor& descriptor)
{
JSFloat64Array* thisObject = jsCast<JSFloat64Array*>(object);
ASSERT_GC_OBJECT_INHERITS(thisObject, &s_info);
unsigned index = propertyName.asIndex();
if (index != PropertyName::NotAnIndex && index < static_cast<Float64Array*>(thisObject->impl())->length()) {
descriptor.setDescriptor(thisObject->getByIndex(exec, index), DontDelete);
return true;
}
return getStaticValueDescriptor<JSFloat64Array, Base>(exec, getJSFloat64ArrayTable(exec), thisObject, propertyName, descriptor);
}
bool JSFloat64Array::getOwnPropertySlotByIndex(JSCell* cell, ExecState* exec, unsigned index, PropertySlot& slot)
{
JSFloat64Array* thisObject = jsCast<JSFloat64Array*>(cell);
ASSERT_GC_OBJECT_INHERITS(thisObject, &s_info);
if (index < static_cast<Float64Array*>(thisObject->impl())->length()) {
slot.setValue(thisObject->getByIndex(exec, index));
return true;
}
return Base::getOwnPropertySlotByIndex(thisObject, exec, index, slot);
}
JSValue jsFloat64ArrayConstructor(ExecState* exec, JSValue slotBase, PropertyName)
{
JSFloat64Array* domObject = jsCast<JSFloat64Array*>(asObject(slotBase));
return JSFloat64Array::getConstructor(exec, domObject->globalObject());
}
void JSFloat64Array::put(JSCell* cell, ExecState* exec, PropertyName propertyName, JSValue value, PutPropertySlot& slot)
{
JSFloat64Array* thisObject = jsCast<JSFloat64Array*>(cell);
ASSERT_GC_OBJECT_INHERITS(thisObject, &s_info);
unsigned index = propertyName.asIndex();
if (index != PropertyName::NotAnIndex) {
thisObject->indexSetter(exec, index, value);
return;
}
Base::put(thisObject, exec, propertyName, value, slot);
}
void JSFloat64Array::putByIndex(JSCell* cell, ExecState* exec, unsigned index, JSValue value, bool shouldThrow)
{
JSFloat64Array* thisObject = jsCast<JSFloat64Array*>(cell);
ASSERT_GC_OBJECT_INHERITS(thisObject, &s_info);
if (index <= MAX_ARRAY_INDEX) {
UNUSED_PARAM(shouldThrow);
thisObject->indexSetter(exec, index, value);
return;
}
Base::putByIndex(cell, exec, index, value, shouldThrow);
}
void JSFloat64Array::getOwnPropertyNames(JSObject* object, ExecState* exec, PropertyNameArray& propertyNames, EnumerationMode mode)
{
JSFloat64Array* thisObject = jsCast<JSFloat64Array*>(object);
ASSERT_GC_OBJECT_INHERITS(thisObject, &s_info);
for (unsigned i = 0; i < static_cast<Float64Array*>(thisObject->impl())->length(); ++i)
propertyNames.add(Identifier::from(exec, i));
Base::getOwnPropertyNames(thisObject, exec, propertyNames, mode);
}
JSValue JSFloat64Array::getConstructor(ExecState* exec, JSGlobalObject* globalObject)
{
return getDOMConstructor<JSFloat64ArrayConstructor>(exec, jsCast<JSDOMGlobalObject*>(globalObject));
}
EncodedJSValue JSC_HOST_CALL jsFloat64ArrayPrototypeFunctionFoo(ExecState* exec)
{
JSValue thisValue = exec->hostThisValue();
if (!thisValue.inherits(&JSFloat64Array::s_info))
return throwVMTypeError(exec);
JSFloat64Array* castedThis = jsCast<JSFloat64Array*>(asObject(thisValue));
ASSERT_GC_OBJECT_INHERITS(castedThis, &JSFloat64Array::s_info);
Float64Array* impl = static_cast<Float64Array*>(castedThis->impl());
if (exec->argumentCount() < 1)
return throwVMError(exec, createNotEnoughArgumentsError(exec));
Float32Array* array(toFloat32Array(exec->argument(0)));
if (exec->hadException())
return JSValue::encode(jsUndefined());
JSC::JSValue result = toJS(exec, castedThis->globalObject(), WTF::getPtr(impl->foo(array)));
return JSValue::encode(result);
}
EncodedJSValue JSC_HOST_CALL jsFloat64ArrayPrototypeFunctionSet(ExecState* exec)
{
JSValue thisValue = exec->hostThisValue();
if (!thisValue.inherits(&JSFloat64Array::s_info))
return throwVMTypeError(exec);
JSFloat64Array* castedThis = jsCast<JSFloat64Array*>(asObject(thisValue));
ASSERT_GC_OBJECT_INHERITS(castedThis, &JSFloat64Array::s_info);
return JSValue::encode(setWebGLArrayHelper<Float64Array, double>(exec, castedThis->impl()));
}
JSValue JSFloat64Array::getByIndex(ExecState*, unsigned index)
{
ASSERT_GC_OBJECT_INHERITS(this, &s_info);
double result = static_cast<Float64Array*>(impl())->item(index);
if (std::isnan(result))
return jsNaN();
return JSValue(result);
}
Float64Array* toFloat64Array(JSC::JSValue value)
{
return value.inherits(&JSFloat64Array::s_info) ? jsCast<JSFloat64Array*>(asObject(value))->impl() : 0;
}
}
|