From 7940c54f8b6a302870aa1c956858f2d9715c4e7a Mon Sep 17 00:00:00 2001 From: Dominic Szablewski Date: Sat, 8 Dec 2012 01:04:40 +0100 Subject: [PATCH 01/30] Blindly added ArrayBuffer files --- .../JavaScriptCore.xcodeproj/project.pbxproj | 45 ++++ .../runtime/TypedArrays/JSArrayBuffer.cpp | 251 ++++++++++++++++++ .../runtime/TypedArrays/JSArrayBuffer.h | 149 +++++++++++ .../TypedArrays/JSArrayBufferCustom.cpp | 52 ++++ .../runtime/TypedArrays/JSArrayBufferView.cpp | 173 ++++++++++++ .../runtime/TypedArrays/JSArrayBufferView.h | 117 ++++++++ .../TypedArrays/JSArrayBufferViewHelper.h | 180 +++++++++++++ 7 files changed, 967 insertions(+) create mode 100644 JavaScriptCore/runtime/TypedArrays/JSArrayBuffer.cpp create mode 100644 JavaScriptCore/runtime/TypedArrays/JSArrayBuffer.h create mode 100644 JavaScriptCore/runtime/TypedArrays/JSArrayBufferCustom.cpp create mode 100644 JavaScriptCore/runtime/TypedArrays/JSArrayBufferView.cpp create mode 100644 JavaScriptCore/runtime/TypedArrays/JSArrayBufferView.h create mode 100644 JavaScriptCore/runtime/TypedArrays/JSArrayBufferViewHelper.h diff --git a/JavaScriptCore/JavaScriptCore.xcodeproj/project.pbxproj b/JavaScriptCore/JavaScriptCore.xcodeproj/project.pbxproj index e8533a2f..cdf0b8ae 100644 --- a/JavaScriptCore/JavaScriptCore.xcodeproj/project.pbxproj +++ b/JavaScriptCore/JavaScriptCore.xcodeproj/project.pbxproj @@ -537,6 +537,18 @@ A7FB60A4103F7DC20017A286 /* PropertyDescriptor.cpp in Sources */ = {isa = PBXBuildFile; fileRef = A7FB60A3103F7DC20017A286 /* PropertyDescriptor.cpp */; }; A7FB61001040C38B0017A286 /* PropertyDescriptor.h in Headers */ = {isa = PBXBuildFile; fileRef = A7FB604B103F5EAB0017A286 /* PropertyDescriptor.h */; settings = {ATTRIBUTES = (Private, ); }; }; A8A4748E151A8306004123FF /* libWTF.a in Frameworks */ = {isa = PBXBuildFile; fileRef = A8A4748D151A8306004123FF /* libWTF.a */; }; + B6D1882C166FA73400D1037C /* JSArrayBuffer.cpp in Sources */ = {isa = PBXBuildFile; fileRef = B6D18814166FA73400D1037C /* JSArrayBuffer.cpp */; }; + B6D1882D166FA73400D1037C /* JSArrayBuffer.cpp in Sources */ = {isa = PBXBuildFile; fileRef = B6D18814166FA73400D1037C /* JSArrayBuffer.cpp */; }; + B6D1882E166FA73400D1037C /* JSArrayBuffer.h in Headers */ = {isa = PBXBuildFile; fileRef = B6D18815166FA73400D1037C /* JSArrayBuffer.h */; }; + B6D1882F166FA73400D1037C /* JSArrayBuffer.h in Headers */ = {isa = PBXBuildFile; fileRef = B6D18815166FA73400D1037C /* JSArrayBuffer.h */; }; + B6D18830166FA73400D1037C /* JSArrayBufferCustom.cpp in Sources */ = {isa = PBXBuildFile; fileRef = B6D18816166FA73400D1037C /* JSArrayBufferCustom.cpp */; }; + B6D18831166FA73400D1037C /* JSArrayBufferCustom.cpp in Sources */ = {isa = PBXBuildFile; fileRef = B6D18816166FA73400D1037C /* JSArrayBufferCustom.cpp */; }; + B6D18832166FA73400D1037C /* JSArrayBufferView.cpp in Sources */ = {isa = PBXBuildFile; fileRef = B6D18817166FA73400D1037C /* JSArrayBufferView.cpp */; }; + B6D18833166FA73400D1037C /* JSArrayBufferView.cpp in Sources */ = {isa = PBXBuildFile; fileRef = B6D18817166FA73400D1037C /* JSArrayBufferView.cpp */; }; + B6D18834166FA73400D1037C /* JSArrayBufferView.h in Headers */ = {isa = PBXBuildFile; fileRef = B6D18818166FA73400D1037C /* JSArrayBufferView.h */; }; + B6D18835166FA73400D1037C /* JSArrayBufferView.h in Headers */ = {isa = PBXBuildFile; fileRef = B6D18818166FA73400D1037C /* JSArrayBufferView.h */; }; + B6D18836166FA73400D1037C /* JSArrayBufferViewHelper.h in Headers */ = {isa = PBXBuildFile; fileRef = B6D18819166FA73400D1037C /* JSArrayBufferViewHelper.h */; }; + B6D18837166FA73400D1037C /* JSArrayBufferViewHelper.h in Headers */ = {isa = PBXBuildFile; fileRef = B6D18819166FA73400D1037C /* JSArrayBufferViewHelper.h */; }; B6E69991166BD63D005EF4B1 /* AbstractMacroAssembler.h in Headers */ = {isa = PBXBuildFile; fileRef = 860161DF0F3A83C100F84710 /* AbstractMacroAssembler.h */; }; B6E69992166BD63D005EF4B1 /* APICast.h in Headers */ = {isa = PBXBuildFile; fileRef = 1482B78A0A4305AB00517CFC /* APICast.h */; settings = {ATTRIBUTES = (Private, ); }; }; B6E69993166BD63D005EF4B1 /* APIShims.h in Headers */ = {isa = PBXBuildFile; fileRef = 865F408710E7D56300947361 /* APIShims.h */; settings = {ATTRIBUTES = (Private, ); }; }; @@ -1804,6 +1816,12 @@ A8A4748D151A8306004123FF /* libWTF.a */ = {isa = PBXFileReference; lastKnownFileType = archive.ar; path = libWTF.a; sourceTree = BUILT_PRODUCTS_DIR; }; A8E894310CD0602400367179 /* JSCallbackObjectFunctions.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = JSCallbackObjectFunctions.h; sourceTree = ""; }; A8E894330CD0603F00367179 /* JSGlobalObject.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = JSGlobalObject.h; sourceTree = ""; }; + B6D18814166FA73400D1037C /* JSArrayBuffer.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = JSArrayBuffer.cpp; sourceTree = ""; }; + B6D18815166FA73400D1037C /* JSArrayBuffer.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = JSArrayBuffer.h; sourceTree = ""; }; + B6D18816166FA73400D1037C /* JSArrayBufferCustom.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = JSArrayBufferCustom.cpp; sourceTree = ""; }; + B6D18817166FA73400D1037C /* JSArrayBufferView.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = JSArrayBufferView.cpp; sourceTree = ""; }; + B6D18818166FA73400D1037C /* JSArrayBufferView.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = JSArrayBufferView.h; sourceTree = ""; }; + B6D18819166FA73400D1037C /* JSArrayBufferViewHelper.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = JSArrayBufferViewHelper.h; sourceTree = ""; }; B6E69BC4166BD63D005EF4B1 /* libJavaScriptCore.a */ = {isa = PBXFileReference; explicitFileType = archive.ar; includeInIndex = 0; path = libJavaScriptCore.a; sourceTree = BUILT_PRODUCTS_DIR; }; B6E69BDB166BD6C1005EF4B1 /* libJSCLLIntOffsetsExtractor.a */ = {isa = PBXFileReference; explicitFileType = archive.ar; includeInIndex = 0; path = libJSCLLIntOffsetsExtractor.a; sourceTree = BUILT_PRODUCTS_DIR; }; B6E69BFD166BDCE7005EF4B1 /* libWTF.a */ = {isa = PBXFileReference; lastKnownFileType = archive.ar; name = libWTF.a; path = ../Build/libWTF.a; sourceTree = ""; }; @@ -2419,6 +2437,7 @@ 7EF6E0BB0EB7A1EC0079AFAF /* runtime */ = { isa = PBXGroup; children = ( + B6D18813166FA73300D1037C /* TypedArrays */, 0F21C27914BE727300ADC64B /* CodeSpecializationKind.h */, 0F21C27A14BE727300ADC64B /* ExecutionHarness.h */, 0F15F15D14B7A73A005DE37D /* CommonSlowPaths.h */, @@ -2849,6 +2868,19 @@ path = bytecode; sourceTree = ""; }; + B6D18813166FA73300D1037C /* TypedArrays */ = { + isa = PBXGroup; + children = ( + B6D18814166FA73400D1037C /* JSArrayBuffer.cpp */, + B6D18815166FA73400D1037C /* JSArrayBuffer.h */, + B6D18816166FA73400D1037C /* JSArrayBufferCustom.cpp */, + B6D18817166FA73400D1037C /* JSArrayBufferView.cpp */, + B6D18818166FA73400D1037C /* JSArrayBufferView.h */, + B6D18819166FA73400D1037C /* JSArrayBufferViewHelper.h */, + ); + path = TypedArrays; + sourceTree = ""; + }; /* End PBXGroup section */ /* Begin PBXHeadersBuildPhase section */ @@ -3206,6 +3238,9 @@ 0F1E3A471534CBB9000F9456 /* DFGDoubleFormatState.h in Headers */, 14150133154BB13F005D8C98 /* WeakSetInlines.h in Headers */, 14816E1C154CC56C00B8054C /* BlockAllocator.h in Headers */, + B6D1882E166FA73400D1037C /* JSArrayBuffer.h in Headers */, + B6D18834166FA73400D1037C /* JSArrayBufferView.h in Headers */, + B6D18836166FA73400D1037C /* JSArrayBufferViewHelper.h in Headers */, ); runOnlyForDeploymentPostprocessing = 0; }; @@ -3551,6 +3586,9 @@ B6E69AE0166BD63D005EF4B1 /* DFGDoubleFormatState.h in Headers */, B6E69AE1166BD63D005EF4B1 /* WeakSetInlines.h in Headers */, B6E69AE2166BD63D005EF4B1 /* BlockAllocator.h in Headers */, + B6D1882F166FA73400D1037C /* JSArrayBuffer.h in Headers */, + B6D18835166FA73400D1037C /* JSArrayBufferView.h in Headers */, + B6D18837166FA73400D1037C /* JSArrayBufferViewHelper.h in Headers */, ); runOnlyForDeploymentPostprocessing = 0; }; @@ -4296,6 +4334,9 @@ 8642C512151C083D0046D4EF /* RegExpMatchesArray.cpp in Sources */, 863C6D9C1521111A00585E4E /* YarrCanonicalizeUCS2.cpp in Sources */, 14816E1B154CC56C00B8054C /* BlockAllocator.cpp in Sources */, + B6D1882C166FA73400D1037C /* JSArrayBuffer.cpp in Sources */, + B6D18830166FA73400D1037C /* JSArrayBufferCustom.cpp in Sources */, + B6D18832166FA73400D1037C /* JSArrayBufferView.cpp in Sources */, ); runOnlyForDeploymentPostprocessing = 0; }; @@ -4520,6 +4561,9 @@ B6E69BB2166BD63D005EF4B1 /* RegExpMatchesArray.cpp in Sources */, B6E69BB3166BD63D005EF4B1 /* YarrCanonicalizeUCS2.cpp in Sources */, B6E69BB4166BD63D005EF4B1 /* BlockAllocator.cpp in Sources */, + B6D1882D166FA73400D1037C /* JSArrayBuffer.cpp in Sources */, + B6D18831166FA73400D1037C /* JSArrayBufferCustom.cpp in Sources */, + B6D18833166FA73400D1037C /* JSArrayBufferView.cpp in Sources */, ); runOnlyForDeploymentPostprocessing = 0; }; @@ -5372,6 +5416,7 @@ B6E69C04166BDD18005EF4B1 /* Production */, ); defaultConfigurationIsVisible = 0; + defaultConfigurationName = Production; }; /* End XCConfigurationList section */ }; diff --git a/JavaScriptCore/runtime/TypedArrays/JSArrayBuffer.cpp b/JavaScriptCore/runtime/TypedArrays/JSArrayBuffer.cpp new file mode 100644 index 00000000..c7839d0d --- /dev/null +++ b/JavaScriptCore/runtime/TypedArrays/JSArrayBuffer.cpp @@ -0,0 +1,251 @@ +/* + 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 "JSArrayBuffer.h" + +#include "ExceptionCode.h" +#include "JSArrayBuffer.h" +#include "JSDOMBinding.h" +#include +#include +#include + +using namespace JSC; + +namespace WebCore { + +ASSERT_CLASS_FITS_IN_CELL(JSArrayBuffer); +/* Hash table */ + +static const HashTableValue JSArrayBufferTableValues[] = +{ + { "byteLength", DontDelete | ReadOnly, (intptr_t)static_cast(jsArrayBufferByteLength), (intptr_t)0, NoIntrinsic }, + { "constructor", DontEnum | ReadOnly, (intptr_t)static_cast(jsArrayBufferConstructor), (intptr_t)0, NoIntrinsic }, + { 0, 0, 0, 0, NoIntrinsic } +}; + +static const HashTable JSArrayBufferTable = { 5, 3, JSArrayBufferTableValues, 0 }; +/* Hash table for constructor */ + +static const HashTableValue JSArrayBufferConstructorTableValues[] = +{ + { 0, 0, 0, 0, NoIntrinsic } +}; + +static const HashTable JSArrayBufferConstructorTable = { 1, 0, JSArrayBufferConstructorTableValues, 0 }; +const ClassInfo JSArrayBufferConstructor::s_info = { "ArrayBufferConstructor", &Base::s_info, &JSArrayBufferConstructorTable, 0, CREATE_METHOD_TABLE(JSArrayBufferConstructor) }; + +JSArrayBufferConstructor::JSArrayBufferConstructor(Structure* structure, JSDOMGlobalObject* globalObject) + : DOMConstructorObject(structure, globalObject) +{ +} + +void JSArrayBufferConstructor::finishCreation(ExecState* exec, JSDOMGlobalObject* globalObject) +{ + Base::finishCreation(exec->globalData()); + ASSERT(inherits(&s_info)); + putDirect(exec->globalData(), exec->propertyNames().prototype, JSArrayBufferPrototype::self(exec, globalObject), DontDelete | ReadOnly); + putDirect(exec->globalData(), exec->propertyNames().length, jsNumber(1), ReadOnly | DontDelete | DontEnum); +} + +bool JSArrayBufferConstructor::getOwnPropertySlot(JSCell* cell, ExecState* exec, const Identifier& propertyName, PropertySlot& slot) +{ + return getStaticValueSlot(exec, &JSArrayBufferConstructorTable, jsCast(cell), propertyName, slot); +} + +bool JSArrayBufferConstructor::getOwnPropertyDescriptor(JSObject* object, ExecState* exec, const Identifier& propertyName, PropertyDescriptor& descriptor) +{ + return getStaticValueDescriptor(exec, &JSArrayBufferConstructorTable, jsCast(object), propertyName, descriptor); +} + +ConstructType JSArrayBufferConstructor::getConstructData(JSCell*, ConstructData& constructData) +{ + constructData.native.function = constructJSArrayBuffer; + return ConstructTypeHost; +} + +/* Hash table for prototype */ + +static const HashTableValue JSArrayBufferPrototypeTableValues[] = +{ + { "slice", DontDelete | JSC::Function, (intptr_t)static_cast(jsArrayBufferPrototypeFunctionSlice), (intptr_t)2, NoIntrinsic }, + { 0, 0, 0, 0, NoIntrinsic } +}; + +static const HashTable JSArrayBufferPrototypeTable = { 2, 1, JSArrayBufferPrototypeTableValues, 0 }; +static const HashTable* getJSArrayBufferPrototypeTable(ExecState* exec) +{ + return getHashTableForGlobalData(exec->globalData(), &JSArrayBufferPrototypeTable); +} + +const ClassInfo JSArrayBufferPrototype::s_info = { "ArrayBufferPrototype", &Base::s_info, 0, getJSArrayBufferPrototypeTable, CREATE_METHOD_TABLE(JSArrayBufferPrototype) }; + +JSObject* JSArrayBufferPrototype::self(ExecState* exec, JSGlobalObject* globalObject) +{ + return getDOMPrototype(exec, globalObject); +} + +bool JSArrayBufferPrototype::getOwnPropertySlot(JSCell* cell, ExecState* exec, const Identifier& propertyName, PropertySlot& slot) +{ + JSArrayBufferPrototype* thisObject = jsCast(cell); + return getStaticFunctionSlot(exec, getJSArrayBufferPrototypeTable(exec), thisObject, propertyName, slot); +} + +bool JSArrayBufferPrototype::getOwnPropertyDescriptor(JSObject* object, ExecState* exec, const Identifier& propertyName, PropertyDescriptor& descriptor) +{ + JSArrayBufferPrototype* thisObject = jsCast(object); + return getStaticFunctionDescriptor(exec, getJSArrayBufferPrototypeTable(exec), thisObject, propertyName, descriptor); +} + +static const HashTable* getJSArrayBufferTable(ExecState* exec) +{ + return getHashTableForGlobalData(exec->globalData(), &JSArrayBufferTable); +} + +const ClassInfo JSArrayBuffer::s_info = { "ArrayBuffer", &Base::s_info, 0, getJSArrayBufferTable , CREATE_METHOD_TABLE(JSArrayBuffer) }; + +JSArrayBuffer::JSArrayBuffer(Structure* structure, JSDOMGlobalObject* globalObject, PassRefPtr impl) + : JSDOMWrapper(structure, globalObject) + , m_impl(impl.leakRef()) +{ +} + +void JSArrayBuffer::finishCreation(JSGlobalData& globalData) +{ + Base::finishCreation(globalData); + ASSERT(inherits(&s_info)); +} + +JSObject* JSArrayBuffer::createPrototype(ExecState* exec, JSGlobalObject* globalObject) +{ + return JSArrayBufferPrototype::create(exec->globalData(), globalObject, JSArrayBufferPrototype::createStructure(globalObject->globalData(), globalObject, globalObject->objectPrototype())); +} + +void JSArrayBuffer::destroy(JSC::JSCell* cell) +{ + JSArrayBuffer* thisObject = jsCast(cell); + thisObject->JSArrayBuffer::~JSArrayBuffer(); +} + +JSArrayBuffer::~JSArrayBuffer() +{ + releaseImplIfNotNull(); +} + +bool JSArrayBuffer::getOwnPropertySlot(JSCell* cell, ExecState* exec, const Identifier& propertyName, PropertySlot& slot) +{ + JSArrayBuffer* thisObject = jsCast(cell); + ASSERT_GC_OBJECT_INHERITS(thisObject, &s_info); + return getStaticValueSlot(exec, getJSArrayBufferTable(exec), thisObject, propertyName, slot); +} + +bool JSArrayBuffer::getOwnPropertyDescriptor(JSObject* object, ExecState* exec, const Identifier& propertyName, PropertyDescriptor& descriptor) +{ + JSArrayBuffer* thisObject = jsCast(object); + ASSERT_GC_OBJECT_INHERITS(thisObject, &s_info); + return getStaticValueDescriptor(exec, getJSArrayBufferTable(exec), thisObject, propertyName, descriptor); +} + +JSValue jsArrayBufferByteLength(ExecState* exec, JSValue slotBase, const Identifier&) +{ + JSArrayBuffer* castedThis = jsCast(asObject(slotBase)); + UNUSED_PARAM(exec); + ArrayBuffer* impl = static_cast(castedThis->impl()); + JSValue result = jsNumber(impl->byteLength()); + return result; +} + + +JSValue jsArrayBufferConstructor(ExecState* exec, JSValue slotBase, const Identifier&) +{ + JSArrayBuffer* domObject = jsCast(asObject(slotBase)); + return JSArrayBuffer::getConstructor(exec, domObject->globalObject()); +} + +JSValue JSArrayBuffer::getConstructor(ExecState* exec, JSGlobalObject* globalObject) +{ + return getDOMConstructor(exec, jsCast(globalObject)); +} + +EncodedJSValue JSC_HOST_CALL jsArrayBufferPrototypeFunctionSlice(ExecState* exec) +{ + JSValue thisValue = exec->hostThisValue(); + if (!thisValue.inherits(&JSArrayBuffer::s_info)) + return throwVMTypeError(exec); + JSArrayBuffer* castedThis = jsCast(asObject(thisValue)); + ASSERT_GC_OBJECT_INHERITS(castedThis, &JSArrayBuffer::s_info); + ArrayBuffer* impl = static_cast(castedThis->impl()); + if (exec->argumentCount() < 1) + return throwVMError(exec, createNotEnoughArgumentsError(exec)); + int begin(MAYBE_MISSING_PARAMETER(exec, 0, DefaultIsUndefined).toInt32(exec)); + if (exec->hadException()) + return JSValue::encode(jsUndefined()); + + size_t argsCount = exec->argumentCount(); + if (argsCount <= 1) { + + JSC::JSValue result = toJS(exec, castedThis->globalObject(), WTF::getPtr(impl->slice(begin))); + return JSValue::encode(result); + } + + int end(MAYBE_MISSING_PARAMETER(exec, 1, DefaultIsUndefined).toInt32(exec)); + if (exec->hadException()) + return JSValue::encode(jsUndefined()); + + JSC::JSValue result = toJS(exec, castedThis->globalObject(), WTF::getPtr(impl->slice(begin, end))); + return JSValue::encode(result); +} + +static inline bool isObservable(JSArrayBuffer* jsArrayBuffer) +{ + if (jsArrayBuffer->hasCustomProperties()) + return true; + return false; +} + +bool JSArrayBufferOwner::isReachableFromOpaqueRoots(JSC::Handle handle, void*, SlotVisitor& visitor) +{ + JSArrayBuffer* jsArrayBuffer = jsCast(handle.get().asCell()); + if (!isObservable(jsArrayBuffer)) + return false; + ArrayBuffer* root = jsArrayBuffer->impl(); + return visitor.containsOpaqueRoot(root); +} + +void JSArrayBufferOwner::finalize(JSC::Handle handle, void* context) +{ + JSArrayBuffer* jsArrayBuffer = jsCast(handle.get().asCell()); + DOMWrapperWorld* world = static_cast(context); + uncacheWrapper(world, jsArrayBuffer->impl(), jsArrayBuffer); + jsArrayBuffer->releaseImpl(); +} + +JSC::JSValue toJS(JSC::ExecState* exec, JSDOMGlobalObject* globalObject, ArrayBuffer* impl) +{ + return wrap(exec, globalObject, impl); +} + +ArrayBuffer* toArrayBuffer(JSC::JSValue value) +{ + return value.inherits(&JSArrayBuffer::s_info) ? jsCast(asObject(value))->impl() : 0; +} + +} diff --git a/JavaScriptCore/runtime/TypedArrays/JSArrayBuffer.h b/JavaScriptCore/runtime/TypedArrays/JSArrayBuffer.h new file mode 100644 index 00000000..ef9f9ec5 --- /dev/null +++ b/JavaScriptCore/runtime/TypedArrays/JSArrayBuffer.h @@ -0,0 +1,149 @@ +/* + 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. +*/ + +#ifndef JSArrayBuffer_h +#define JSArrayBuffer_h + +#include "JSDOMBinding.h" +#include +#include +#include +#include + +namespace WebCore { + +class JSArrayBuffer : public JSDOMWrapper { +public: + typedef JSDOMWrapper Base; + static JSArrayBuffer* create(JSC::Structure* structure, JSDOMGlobalObject* globalObject, PassRefPtr impl) + { + JSArrayBuffer* ptr = new (NotNull, JSC::allocateCell(globalObject->globalData().heap)) JSArrayBuffer(structure, globalObject, impl); + ptr->finishCreation(globalObject->globalData()); + return ptr; + } + + static JSC::JSObject* createPrototype(JSC::ExecState*, JSC::JSGlobalObject*); + static bool getOwnPropertySlot(JSC::JSCell*, JSC::ExecState*, const JSC::Identifier& propertyName, JSC::PropertySlot&); + static bool getOwnPropertyDescriptor(JSC::JSObject*, JSC::ExecState*, const JSC::Identifier& propertyName, JSC::PropertyDescriptor&); + static void destroy(JSC::JSCell*); + ~JSArrayBuffer(); + static const JSC::ClassInfo s_info; + + static JSC::Structure* createStructure(JSC::JSGlobalData& globalData, JSC::JSGlobalObject* globalObject, JSC::JSValue prototype) + { + return JSC::Structure::create(globalData, globalObject, prototype, JSC::TypeInfo(JSC::ObjectType, StructureFlags), &s_info); + } + + static JSC::JSValue getConstructor(JSC::ExecState*, JSC::JSGlobalObject*); + ArrayBuffer* impl() const { return m_impl; } + void releaseImpl() { m_impl->deref(); m_impl = 0; } + + void releaseImplIfNotNull() { if (m_impl) { m_impl->deref(); m_impl = 0; } } + +private: + ArrayBuffer* m_impl; +protected: + JSArrayBuffer(JSC::Structure*, JSDOMGlobalObject*, PassRefPtr); + void finishCreation(JSC::JSGlobalData&); + static const unsigned StructureFlags = JSC::OverridesGetOwnPropertySlot | Base::StructureFlags; +}; + +class JSArrayBufferOwner : public JSC::WeakHandleOwner { + virtual bool isReachableFromOpaqueRoots(JSC::Handle, void* context, JSC::SlotVisitor&); + virtual void finalize(JSC::Handle, void* context); +}; + +inline JSC::WeakHandleOwner* wrapperOwner(DOMWrapperWorld*, ArrayBuffer*) +{ + DEFINE_STATIC_LOCAL(JSArrayBufferOwner, jsArrayBufferOwner, ()); + return &jsArrayBufferOwner; +} + +inline void* wrapperContext(DOMWrapperWorld* world, ArrayBuffer*) +{ + return world; +} + +JSC::JSValue toJS(JSC::ExecState*, JSDOMGlobalObject*, ArrayBuffer*); +ArrayBuffer* toArrayBuffer(JSC::JSValue); + +class JSArrayBufferPrototype : public JSC::JSNonFinalObject { +public: + typedef JSC::JSNonFinalObject Base; + static JSC::JSObject* self(JSC::ExecState*, JSC::JSGlobalObject*); + static JSArrayBufferPrototype* create(JSC::JSGlobalData& globalData, JSC::JSGlobalObject* globalObject, JSC::Structure* structure) + { + JSArrayBufferPrototype* ptr = new (NotNull, JSC::allocateCell(globalData.heap)) JSArrayBufferPrototype(globalData, globalObject, structure); + ptr->finishCreation(globalData); + return ptr; + } + + static const JSC::ClassInfo s_info; + static bool getOwnPropertySlot(JSC::JSCell*, JSC::ExecState*, const JSC::Identifier&, JSC::PropertySlot&); + static bool getOwnPropertyDescriptor(JSC::JSObject*, JSC::ExecState*, const JSC::Identifier&, JSC::PropertyDescriptor&); + static JSC::Structure* createStructure(JSC::JSGlobalData& globalData, JSC::JSGlobalObject* globalObject, JSC::JSValue prototype) + { + return JSC::Structure::create(globalData, globalObject, prototype, JSC::TypeInfo(JSC::ObjectType, StructureFlags), &s_info); + } + +private: + JSArrayBufferPrototype(JSC::JSGlobalData& globalData, JSC::JSGlobalObject*, JSC::Structure* structure) : JSC::JSNonFinalObject(globalData, structure) { } +protected: + static const unsigned StructureFlags = JSC::OverridesGetOwnPropertySlot | Base::StructureFlags; +}; + +class JSArrayBufferConstructor : public DOMConstructorObject { +private: + JSArrayBufferConstructor(JSC::Structure*, JSDOMGlobalObject*); + void finishCreation(JSC::ExecState*, JSDOMGlobalObject*); + +public: + typedef DOMConstructorObject Base; + static JSArrayBufferConstructor* create(JSC::ExecState* exec, JSC::Structure* structure, JSDOMGlobalObject* globalObject) + { + JSArrayBufferConstructor* ptr = new (NotNull, JSC::allocateCell(*exec->heap())) JSArrayBufferConstructor(structure, globalObject); + ptr->finishCreation(exec, globalObject); + return ptr; + } + + static bool getOwnPropertySlot(JSC::JSCell*, JSC::ExecState*, const JSC::Identifier&, JSC::PropertySlot&); + static bool getOwnPropertyDescriptor(JSC::JSObject*, JSC::ExecState*, const JSC::Identifier&, JSC::PropertyDescriptor&); + static const JSC::ClassInfo s_info; + static JSC::Structure* createStructure(JSC::JSGlobalData& globalData, JSC::JSGlobalObject* globalObject, JSC::JSValue prototype) + { + return JSC::Structure::create(globalData, globalObject, prototype, JSC::TypeInfo(JSC::ObjectType, StructureFlags), &s_info); + } +protected: + static const unsigned StructureFlags = JSC::OverridesGetOwnPropertySlot | JSC::ImplementsHasInstance | DOMConstructorObject::StructureFlags; + static JSC::EncodedJSValue JSC_HOST_CALL constructJSArrayBuffer(JSC::ExecState*); + static JSC::ConstructType getConstructData(JSC::JSCell*, JSC::ConstructData&); +}; + +// Functions + +JSC::EncodedJSValue JSC_HOST_CALL jsArrayBufferPrototypeFunctionSlice(JSC::ExecState*); +// Attributes + +JSC::JSValue jsArrayBufferByteLength(JSC::ExecState*, JSC::JSValue, const JSC::Identifier&); +JSC::JSValue jsArrayBufferConstructor(JSC::ExecState*, JSC::JSValue, const JSC::Identifier&); + +} // namespace WebCore + +#endif diff --git a/JavaScriptCore/runtime/TypedArrays/JSArrayBufferCustom.cpp b/JavaScriptCore/runtime/TypedArrays/JSArrayBufferCustom.cpp new file mode 100644 index 00000000..2fa306a9 --- /dev/null +++ b/JavaScriptCore/runtime/TypedArrays/JSArrayBufferCustom.cpp @@ -0,0 +1,52 @@ +/* + * Copyright (C) 2009 Apple Inc. All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY APPLE COMPUTER, INC. ``AS IS'' AND ANY + * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR + * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE COMPUTER, INC. OR + * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, + * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, + * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR + * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY + * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE + * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + */ + +#include "config.h" +#include "JSArrayBuffer.h" + +#include "ExceptionCode.h" +#include +#include + +namespace WebCore { + +using namespace JSC; + +EncodedJSValue JSC_HOST_CALL JSArrayBufferConstructor::constructJSArrayBuffer(ExecState* exec) +{ + JSArrayBufferConstructor* jsConstructor = jsCast(exec->callee()); + + int length = 0; + if (exec->argumentCount() > 0) + length = exec->argument(0).toInt32(exec); // NaN/+inf/-inf returns 0, this is intended by WebIDL + RefPtr buffer; + if (length >= 0) + buffer = ArrayBuffer::create(static_cast(length), 1); + if (!buffer.get()) + return throwVMError(exec, createRangeError(exec, "ArrayBuffer size is not a small enough positive integer.")); + return JSValue::encode(asObject(toJS(exec, jsConstructor->globalObject(), buffer.get()))); +} + +} // namespace WebCore diff --git a/JavaScriptCore/runtime/TypedArrays/JSArrayBufferView.cpp b/JavaScriptCore/runtime/TypedArrays/JSArrayBufferView.cpp new file mode 100644 index 00000000..ef075daf --- /dev/null +++ b/JavaScriptCore/runtime/TypedArrays/JSArrayBufferView.cpp @@ -0,0 +1,173 @@ +/* + 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 "JSArrayBufferView.h" + +#include "JSArrayBuffer.h" +#include +#include +#include + +using namespace JSC; + +namespace WebCore { + +ASSERT_CLASS_FITS_IN_CELL(JSArrayBufferView); +/* Hash table */ + +static const HashTableValue JSArrayBufferViewTableValues[] = +{ + { "buffer", DontDelete | ReadOnly, (intptr_t)static_cast(jsArrayBufferViewBuffer), (intptr_t)0, NoIntrinsic }, + { "byteOffset", DontDelete | ReadOnly, (intptr_t)static_cast(jsArrayBufferViewByteOffset), (intptr_t)0, NoIntrinsic }, + { "byteLength", DontDelete | ReadOnly, (intptr_t)static_cast(jsArrayBufferViewByteLength), (intptr_t)0, NoIntrinsic }, + { 0, 0, 0, 0, NoIntrinsic } +}; + +static const HashTable JSArrayBufferViewTable = { 8, 7, JSArrayBufferViewTableValues, 0 }; +/* Hash table for prototype */ + +static const HashTableValue JSArrayBufferViewPrototypeTableValues[] = +{ + { 0, 0, 0, 0, NoIntrinsic } +}; + +static const HashTable JSArrayBufferViewPrototypeTable = { 1, 0, JSArrayBufferViewPrototypeTableValues, 0 }; +static const HashTable* getJSArrayBufferViewPrototypeTable(ExecState* exec) +{ + return getHashTableForGlobalData(exec->globalData(), &JSArrayBufferViewPrototypeTable); +} + +const ClassInfo JSArrayBufferViewPrototype::s_info = { "ArrayBufferViewPrototype", &Base::s_info, 0, getJSArrayBufferViewPrototypeTable, CREATE_METHOD_TABLE(JSArrayBufferViewPrototype) }; + +JSObject* JSArrayBufferViewPrototype::self(ExecState* exec, JSGlobalObject* globalObject) +{ + return getDOMPrototype(exec, globalObject); +} + +static const HashTable* getJSArrayBufferViewTable(ExecState* exec) +{ + return getHashTableForGlobalData(exec->globalData(), &JSArrayBufferViewTable); +} + +const ClassInfo JSArrayBufferView::s_info = { "ArrayBufferView", &Base::s_info, 0, getJSArrayBufferViewTable , CREATE_METHOD_TABLE(JSArrayBufferView) }; + +JSArrayBufferView::JSArrayBufferView(Structure* structure, JSDOMGlobalObject* globalObject, PassRefPtr impl) + : JSDOMWrapper(structure, globalObject) + , m_impl(impl.leakRef()) +{ +} + +void JSArrayBufferView::finishCreation(JSGlobalData& globalData) +{ + Base::finishCreation(globalData); + ASSERT(inherits(&s_info)); +} + +JSObject* JSArrayBufferView::createPrototype(ExecState* exec, JSGlobalObject* globalObject) +{ + return JSArrayBufferViewPrototype::create(exec->globalData(), globalObject, JSArrayBufferViewPrototype::createStructure(globalObject->globalData(), globalObject, globalObject->objectPrototype())); +} + +void JSArrayBufferView::destroy(JSC::JSCell* cell) +{ + JSArrayBufferView* thisObject = jsCast(cell); + thisObject->JSArrayBufferView::~JSArrayBufferView(); +} + +JSArrayBufferView::~JSArrayBufferView() +{ + releaseImplIfNotNull(); +} + +bool JSArrayBufferView::getOwnPropertySlot(JSCell* cell, ExecState* exec, const Identifier& propertyName, PropertySlot& slot) +{ + JSArrayBufferView* thisObject = jsCast(cell); + ASSERT_GC_OBJECT_INHERITS(thisObject, &s_info); + return getStaticValueSlot(exec, getJSArrayBufferViewTable(exec), thisObject, propertyName, slot); +} + +bool JSArrayBufferView::getOwnPropertyDescriptor(JSObject* object, ExecState* exec, const Identifier& propertyName, PropertyDescriptor& descriptor) +{ + JSArrayBufferView* thisObject = jsCast(object); + ASSERT_GC_OBJECT_INHERITS(thisObject, &s_info); + return getStaticValueDescriptor(exec, getJSArrayBufferViewTable(exec), thisObject, propertyName, descriptor); +} + +JSValue jsArrayBufferViewBuffer(ExecState* exec, JSValue slotBase, const Identifier&) +{ + JSArrayBufferView* castedThis = jsCast(asObject(slotBase)); + UNUSED_PARAM(exec); + ArrayBufferView* impl = static_cast(castedThis->impl()); + JSValue result = toJS(exec, castedThis->globalObject(), WTF::getPtr(impl->buffer())); + return result; +} + + +JSValue jsArrayBufferViewByteOffset(ExecState* exec, JSValue slotBase, const Identifier&) +{ + JSArrayBufferView* castedThis = jsCast(asObject(slotBase)); + UNUSED_PARAM(exec); + ArrayBufferView* impl = static_cast(castedThis->impl()); + JSValue result = jsNumber(impl->byteOffset()); + return result; +} + + +JSValue jsArrayBufferViewByteLength(ExecState* exec, JSValue slotBase, const Identifier&) +{ + JSArrayBufferView* castedThis = jsCast(asObject(slotBase)); + UNUSED_PARAM(exec); + ArrayBufferView* impl = static_cast(castedThis->impl()); + JSValue result = jsNumber(impl->byteLength()); + return result; +} + + +static inline bool isObservable(JSArrayBufferView* jsArrayBufferView) +{ + if (jsArrayBufferView->hasCustomProperties()) + return true; + return false; +} + +bool JSArrayBufferViewOwner::isReachableFromOpaqueRoots(JSC::Handle handle, void*, SlotVisitor& visitor) +{ + JSArrayBufferView* jsArrayBufferView = jsCast(handle.get().asCell()); + if (!isObservable(jsArrayBufferView)) + return false; + UNUSED_PARAM(visitor); + return false; +} + +void JSArrayBufferViewOwner::finalize(JSC::Handle handle, void* context) +{ + JSArrayBufferView* jsArrayBufferView = jsCast(handle.get().asCell()); + DOMWrapperWorld* world = static_cast(context); + uncacheWrapper(world, jsArrayBufferView->impl(), jsArrayBufferView); + jsArrayBufferView->releaseImpl(); +} + +ArrayBufferView* toArrayBufferView(JSC::JSValue value) +{ + return value.inherits(&JSArrayBufferView::s_info) ? jsCast(asObject(value))->impl() : 0; +} + +} diff --git a/JavaScriptCore/runtime/TypedArrays/JSArrayBufferView.h b/JavaScriptCore/runtime/TypedArrays/JSArrayBufferView.h new file mode 100644 index 00000000..6171bd4c --- /dev/null +++ b/JavaScriptCore/runtime/TypedArrays/JSArrayBufferView.h @@ -0,0 +1,117 @@ +/* + 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. +*/ + +#ifndef JSArrayBufferView_h +#define JSArrayBufferView_h + +#include "JSDOMBinding.h" +#include +#include +#include +#include + +namespace WebCore { + +class JSArrayBufferView : public JSDOMWrapper { +public: + typedef JSDOMWrapper Base; + static JSArrayBufferView* create(JSC::Structure* structure, JSDOMGlobalObject* globalObject, PassRefPtr impl) + { + JSArrayBufferView* ptr = new (NotNull, JSC::allocateCell(globalObject->globalData().heap)) JSArrayBufferView(structure, globalObject, impl); + ptr->finishCreation(globalObject->globalData()); + return ptr; + } + + static JSC::JSObject* createPrototype(JSC::ExecState*, JSC::JSGlobalObject*); + static bool getOwnPropertySlot(JSC::JSCell*, JSC::ExecState*, const JSC::Identifier& propertyName, JSC::PropertySlot&); + static bool getOwnPropertyDescriptor(JSC::JSObject*, JSC::ExecState*, const JSC::Identifier& propertyName, JSC::PropertyDescriptor&); + static void destroy(JSC::JSCell*); + ~JSArrayBufferView(); + static const JSC::ClassInfo s_info; + + static JSC::Structure* createStructure(JSC::JSGlobalData& globalData, JSC::JSGlobalObject* globalObject, JSC::JSValue prototype) + { + return JSC::Structure::create(globalData, globalObject, prototype, JSC::TypeInfo(JSC::ObjectType, StructureFlags), &s_info); + } + + ArrayBufferView* impl() const { return m_impl; } + void releaseImpl() { m_impl->deref(); m_impl = 0; } + + void releaseImplIfNotNull() { if (m_impl) { m_impl->deref(); m_impl = 0; } } + +private: + ArrayBufferView* m_impl; +protected: + JSArrayBufferView(JSC::Structure*, JSDOMGlobalObject*, PassRefPtr); + void finishCreation(JSC::JSGlobalData&); + static const unsigned StructureFlags = JSC::OverridesGetOwnPropertySlot | Base::StructureFlags; +}; + +class JSArrayBufferViewOwner : public JSC::WeakHandleOwner { + virtual bool isReachableFromOpaqueRoots(JSC::Handle, void* context, JSC::SlotVisitor&); + virtual void finalize(JSC::Handle, void* context); +}; + +inline JSC::WeakHandleOwner* wrapperOwner(DOMWrapperWorld*, ArrayBufferView*) +{ + DEFINE_STATIC_LOCAL(JSArrayBufferViewOwner, jsArrayBufferViewOwner, ()); + return &jsArrayBufferViewOwner; +} + +inline void* wrapperContext(DOMWrapperWorld* world, ArrayBufferView*) +{ + return world; +} + +JSC::JSValue toJS(JSC::ExecState*, JSDOMGlobalObject*, ArrayBufferView*); +ArrayBufferView* toArrayBufferView(JSC::JSValue); + +class JSArrayBufferViewPrototype : public JSC::JSNonFinalObject { +public: + typedef JSC::JSNonFinalObject Base; + static JSC::JSObject* self(JSC::ExecState*, JSC::JSGlobalObject*); + static JSArrayBufferViewPrototype* create(JSC::JSGlobalData& globalData, JSC::JSGlobalObject* globalObject, JSC::Structure* structure) + { + JSArrayBufferViewPrototype* ptr = new (NotNull, JSC::allocateCell(globalData.heap)) JSArrayBufferViewPrototype(globalData, globalObject, structure); + ptr->finishCreation(globalData); + return ptr; + } + + static const JSC::ClassInfo s_info; + static JSC::Structure* createStructure(JSC::JSGlobalData& globalData, JSC::JSGlobalObject* globalObject, JSC::JSValue prototype) + { + return JSC::Structure::create(globalData, globalObject, prototype, JSC::TypeInfo(JSC::ObjectType, StructureFlags), &s_info); + } + +private: + JSArrayBufferViewPrototype(JSC::JSGlobalData& globalData, JSC::JSGlobalObject*, JSC::Structure* structure) : JSC::JSNonFinalObject(globalData, structure) { } +protected: + static const unsigned StructureFlags = Base::StructureFlags; +}; + +// Attributes + +JSC::JSValue jsArrayBufferViewBuffer(JSC::ExecState*, JSC::JSValue, const JSC::Identifier&); +JSC::JSValue jsArrayBufferViewByteOffset(JSC::ExecState*, JSC::JSValue, const JSC::Identifier&); +JSC::JSValue jsArrayBufferViewByteLength(JSC::ExecState*, JSC::JSValue, const JSC::Identifier&); + +} // namespace WebCore + +#endif diff --git a/JavaScriptCore/runtime/TypedArrays/JSArrayBufferViewHelper.h b/JavaScriptCore/runtime/TypedArrays/JSArrayBufferViewHelper.h new file mode 100644 index 00000000..df9e4390 --- /dev/null +++ b/JavaScriptCore/runtime/TypedArrays/JSArrayBufferViewHelper.h @@ -0,0 +1,180 @@ +/* + * Copyright (C) 2009 Apple Inc. All rights reserved. + * Copyright (C) 2009 Google Inc. All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY APPLE INC. ``AS IS'' AND ANY + * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR + * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE COMPUTER, INC. OR + * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, + * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, + * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR + * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY + * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE + * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + */ + +#ifndef JSArrayBufferViewHelper_h +#define JSArrayBufferViewHelper_h + +#include "ExceptionCode.h" +#include "JSArrayBuffer.h" +#include "JSDOMBinding.h" +#include +#include +#include +#include +#include +#include + +namespace WebCore { + +template +JSC::JSValue setWebGLArrayHelper(JSC::ExecState* exec, T* impl, T* (*conversionFunc)(JSC::JSValue)) +{ + if (exec->argumentCount() < 1) + return JSC::throwSyntaxError(exec); + + T* array = (*conversionFunc)(exec->argument(0)); + if (array) { + // void set(in WebGLArray array, [Optional] in unsigned long offset); + unsigned offset = 0; + if (exec->argumentCount() == 2) + offset = exec->argument(1).toInt32(exec); + if (!impl->set(array, offset)) + setDOMException(exec, INDEX_SIZE_ERR); + + return JSC::jsUndefined(); + } + + if (exec->argument(0).isObject()) { + // void set(in sequence array, [Optional] in unsigned long offset); + JSC::JSObject* array = JSC::asObject(exec->argument(0)); + uint32_t offset = 0; + if (exec->argumentCount() == 2) + offset = exec->argument(1).toInt32(exec); + uint32_t length = array->get(exec, JSC::Identifier(exec, "length")).toInt32(exec); + if (offset > impl->length() + || offset + length > impl->length() + || offset + length < offset) + setDOMException(exec, INDEX_SIZE_ERR); + else { + for (uint32_t i = 0; i < length; i++) { + JSC::JSValue v = array->get(exec, i); + if (exec->hadException()) + return JSC::jsUndefined(); + impl->set(i + offset, v.toNumber(exec)); + } + } + + return JSC::jsUndefined(); + } + + return JSC::throwSyntaxError(exec); +} + +// Template function used by XXXArrayConstructors. +// If this returns 0, it will already have thrown a JavaScript exception. +template +PassRefPtr constructArrayBufferViewWithArrayBufferArgument(JSC::ExecState* exec) +{ + RefPtr buffer = toArrayBuffer(exec->argument(0)); + if (!buffer) + return 0; + + unsigned offset = (exec->argumentCount() > 1) ? exec->argument(1).toUInt32(exec) : 0; + unsigned int length = 0; + if (exec->argumentCount() > 2) + length = exec->argument(2).toUInt32(exec); + else { + if ((buffer->byteLength() - offset) % sizeof(T)) { + throwError(exec, createRangeError(exec, "ArrayBuffer length minus the byteOffset is not a multiple of the element size.")); + return 0; + } + length = (buffer->byteLength() - offset) / sizeof(T); + } + RefPtr array = C::create(buffer, offset, length); + if (!array) + setDOMException(exec, INDEX_SIZE_ERR); + return array; +} + +template +PassRefPtr constructArrayBufferView(JSC::ExecState* exec) +{ + // There are 3 constructors: + // + // 1) (in int size) + // 2) (in ArrayBuffer buffer, [Optional] in int offset, [Optional] in unsigned int length) + // 3) (in sequence) - This ends up being a JS "array-like" object + // + // For the 0 args case, just create a zero-length view. We could + // consider raising a SyntaxError for this case, but not all + // JavaScript DOM bindings can distinguish between "new + // Array()" and what occurs when a previously-constructed + // ArrayBufferView is returned to JavaScript; e.g., from + // "array.subset()". + if (exec->argumentCount() < 1) + return C::create(0); + + if (exec->argument(0).isNull()) { + // Invalid first argument + throwTypeError(exec); + return 0; + } + + if (exec->argument(0).isObject()) { + RefPtr view = constructArrayBufferViewWithArrayBufferArgument(exec); + if (view) + return view; + + JSC::JSObject* srcArray = asObject(exec->argument(0)); + uint32_t length = srcArray->get(exec, JSC::Identifier(exec, "length")).toUInt32(exec); + RefPtr array = C::create(length); + if (!array) { + setDOMException(exec, INDEX_SIZE_ERR); + return array; + } + + for (unsigned i = 0; i < length; ++i) { + JSC::JSValue v = srcArray->get(exec, i); + array->set(i, v.toNumber(exec)); + } + return array; + } + + int length = exec->argument(0).toInt32(exec); + RefPtr result; + if (length >= 0) + result = C::create(static_cast(length)); + if (!result) + throwError(exec, createRangeError(exec, "ArrayBufferView size is not a small enough positive integer.")); + return result; +} + +template +static JSC::JSValue toJSArrayBufferView(JSC::ExecState* exec, JSDOMGlobalObject* globalObject, WebCoreType* object) +{ + if (!object) + return JSC::jsNull(); + + if (JSDOMWrapper* wrapper = getCachedWrapper(currentWorld(exec), object)) + return wrapper; + + exec->heap()->reportExtraMemoryCost(object->byteLength()); + return createWrapper(exec, globalObject, object); +} + +} // namespace WebCore + +#endif // JSArrayBufferViewHelper_h From 2695b7a2171d45131c330bb0bae130eff847e0bd Mon Sep 17 00:00:00 2001 From: Dominic Szablewski Date: Sat, 8 Dec 2012 03:38:49 +0100 Subject: [PATCH 02/30] Removed all Webcore/DOM references; made it compile --- .../runtime/TypedArrays/JSArrayBuffer.cpp | 61 +++++++++++++------ .../runtime/TypedArrays/JSArrayBuffer.h | 32 +++++----- .../TypedArrays/JSArrayBufferCustom.cpp | 5 +- .../runtime/TypedArrays/JSArrayBufferView.cpp | 27 +++++--- .../runtime/TypedArrays/JSArrayBufferView.h | 16 ++--- .../TypedArrays/JSArrayBufferViewHelper.h | 2 +- 6 files changed, 89 insertions(+), 54 deletions(-) diff --git a/JavaScriptCore/runtime/TypedArrays/JSArrayBuffer.cpp b/JavaScriptCore/runtime/TypedArrays/JSArrayBuffer.cpp index c7839d0d..6274783f 100644 --- a/JavaScriptCore/runtime/TypedArrays/JSArrayBuffer.cpp +++ b/JavaScriptCore/runtime/TypedArrays/JSArrayBuffer.cpp @@ -21,16 +21,23 @@ #include "config.h" #include "JSArrayBuffer.h" -#include "ExceptionCode.h" #include "JSArrayBuffer.h" -#include "JSDOMBinding.h" +#include "Lookup.h" #include #include #include using namespace JSC; -namespace WebCore { +namespace JSC { + +enum ParameterDefaultPolicy { + DefaultIsUndefined, + DefaultIsNullString +}; + +#define MAYBE_MISSING_PARAMETER(exec, index, policy) (((policy) == DefaultIsNullString && (index) >= (exec)->argumentCount()) ? (JSValue()) : ((exec)->argument(index))) + ASSERT_CLASS_FITS_IN_CELL(JSArrayBuffer); /* Hash table */ @@ -53,27 +60,28 @@ static const HashTableValue JSArrayBufferConstructorTableValues[] = static const HashTable JSArrayBufferConstructorTable = { 1, 0, JSArrayBufferConstructorTableValues, 0 }; const ClassInfo JSArrayBufferConstructor::s_info = { "ArrayBufferConstructor", &Base::s_info, &JSArrayBufferConstructorTable, 0, CREATE_METHOD_TABLE(JSArrayBufferConstructor) }; -JSArrayBufferConstructor::JSArrayBufferConstructor(Structure* structure, JSDOMGlobalObject* globalObject) - : DOMConstructorObject(structure, globalObject) +JSArrayBufferConstructor::JSArrayBufferConstructor(JSGlobalObject* globalObject, Structure* structure) + : InternalFunction(globalObject, structure) { } -void JSArrayBufferConstructor::finishCreation(ExecState* exec, JSDOMGlobalObject* globalObject) +void JSArrayBufferConstructor::finishCreation(ExecState* exec, JSGlobalObject* globalObject) { - Base::finishCreation(exec->globalData()); + JSC::JSObject * proto = JSArrayBufferPrototype::self(exec, globalObject); + Base::finishCreation(exec->globalData(), Identifier(exec, proto->classInfo()->className)); ASSERT(inherits(&s_info)); - putDirect(exec->globalData(), exec->propertyNames().prototype, JSArrayBufferPrototype::self(exec, globalObject), DontDelete | ReadOnly); + putDirect(exec->globalData(), exec->propertyNames().prototype, proto, DontDelete | ReadOnly); putDirect(exec->globalData(), exec->propertyNames().length, jsNumber(1), ReadOnly | DontDelete | DontEnum); } bool JSArrayBufferConstructor::getOwnPropertySlot(JSCell* cell, ExecState* exec, const Identifier& propertyName, PropertySlot& slot) { - return getStaticValueSlot(exec, &JSArrayBufferConstructorTable, jsCast(cell), propertyName, slot); + return getStaticFunctionSlot(exec, &JSArrayBufferConstructorTable, jsCast(cell), propertyName, slot); } bool JSArrayBufferConstructor::getOwnPropertyDescriptor(JSObject* object, ExecState* exec, const Identifier& propertyName, PropertyDescriptor& descriptor) { - return getStaticValueDescriptor(exec, &JSArrayBufferConstructorTable, jsCast(object), propertyName, descriptor); + return getStaticFunctionDescriptor(exec, &JSArrayBufferConstructorTable, jsCast(object), propertyName, descriptor); } ConstructType JSArrayBufferConstructor::getConstructData(JSCell*, ConstructData& constructData) @@ -93,14 +101,20 @@ static const HashTableValue JSArrayBufferPrototypeTableValues[] = static const HashTable JSArrayBufferPrototypeTable = { 2, 1, JSArrayBufferPrototypeTableValues, 0 }; static const HashTable* getJSArrayBufferPrototypeTable(ExecState* exec) { - return getHashTableForGlobalData(exec->globalData(), &JSArrayBufferPrototypeTable); + ASSERT_UNUSED(exec, exec); + return &JSArrayBufferPrototypeTable; // PL FIXME: should be one instance per global data, not super global } const ClassInfo JSArrayBufferPrototype::s_info = { "ArrayBufferPrototype", &Base::s_info, 0, getJSArrayBufferPrototypeTable, CREATE_METHOD_TABLE(JSArrayBufferPrototype) }; +static JSObject * globalProto = NULL; JSObject* JSArrayBufferPrototype::self(ExecState* exec, JSGlobalObject* globalObject) { - return getDOMPrototype(exec, globalObject); + // PL FIXME: dirty hack to provide one global prototype + if( !globalProto ) { + globalProto = JSArrayBuffer::createPrototype(exec, globalObject); + } + return globalProto; } bool JSArrayBufferPrototype::getOwnPropertySlot(JSCell* cell, ExecState* exec, const Identifier& propertyName, PropertySlot& slot) @@ -117,13 +131,14 @@ bool JSArrayBufferPrototype::getOwnPropertyDescriptor(JSObject* object, ExecStat static const HashTable* getJSArrayBufferTable(ExecState* exec) { - return getHashTableForGlobalData(exec->globalData(), &JSArrayBufferTable); + ASSERT_UNUSED(exec, exec); + return &JSArrayBufferTable; } const ClassInfo JSArrayBuffer::s_info = { "ArrayBuffer", &Base::s_info, 0, getJSArrayBufferTable , CREATE_METHOD_TABLE(JSArrayBuffer) }; -JSArrayBuffer::JSArrayBuffer(Structure* structure, JSDOMGlobalObject* globalObject, PassRefPtr impl) - : JSDOMWrapper(structure, globalObject) +JSArrayBuffer::JSArrayBuffer(Structure* structure, JSGlobalObject* globalObject, PassRefPtr impl) + : JSNonFinalObject(globalObject->globalData(), structure) , m_impl(impl.leakRef()) { } @@ -180,9 +195,14 @@ JSValue jsArrayBufferConstructor(ExecState* exec, JSValue slotBase, const Identi return JSArrayBuffer::getConstructor(exec, domObject->globalObject()); } +static JSObject * globalConstructor; JSValue JSArrayBuffer::getConstructor(ExecState* exec, JSGlobalObject* globalObject) { - return getDOMConstructor(exec, jsCast(globalObject)); + if( !globalConstructor ) { + JSArrayBufferConstructor * constructor = JSArrayBufferConstructor::create(exec, JSArrayBufferConstructor::createStructure(exec->globalData(), globalObject, globalObject->objectPrototype()), globalObject); + globalConstructor = constructor; + } + return globalConstructor; } EncodedJSValue JSC_HOST_CALL jsArrayBufferPrototypeFunctionSlice(ExecState* exec) @@ -232,15 +252,16 @@ bool JSArrayBufferOwner::isReachableFromOpaqueRoots(JSC::Handle ha void JSArrayBufferOwner::finalize(JSC::Handle handle, void* context) { + ASSERT_UNUSED(context, context); JSArrayBuffer* jsArrayBuffer = jsCast(handle.get().asCell()); - DOMWrapperWorld* world = static_cast(context); - uncacheWrapper(world, jsArrayBuffer->impl(), jsArrayBuffer); jsArrayBuffer->releaseImpl(); } -JSC::JSValue toJS(JSC::ExecState* exec, JSDOMGlobalObject* globalObject, ArrayBuffer* impl) +JSC::JSValue toJS(JSC::ExecState* exec, JSGlobalObject* globalObject, ArrayBuffer* impl) { - return wrap(exec, globalObject, impl); + JSArrayBuffer * buf = JSArrayBuffer::create( JSArrayBuffer::createStructure(exec->globalData(), globalObject, JSArrayBufferPrototype::self(exec, globalObject)), globalObject, impl); + JSC::JSCell* jsCell = reinterpret_cast(buf); + return jsCell; } ArrayBuffer* toArrayBuffer(JSC::JSValue value) diff --git a/JavaScriptCore/runtime/TypedArrays/JSArrayBuffer.h b/JavaScriptCore/runtime/TypedArrays/JSArrayBuffer.h index ef9f9ec5..10ac9d55 100644 --- a/JavaScriptCore/runtime/TypedArrays/JSArrayBuffer.h +++ b/JavaScriptCore/runtime/TypedArrays/JSArrayBuffer.h @@ -21,18 +21,20 @@ #ifndef JSArrayBuffer_h #define JSArrayBuffer_h -#include "JSDOMBinding.h" +#include "JSObject.h" +#include "InternalFunction.h" + #include #include #include #include -namespace WebCore { +namespace JSC { -class JSArrayBuffer : public JSDOMWrapper { +class JSArrayBuffer : public JSNonFinalObject { public: - typedef JSDOMWrapper Base; - static JSArrayBuffer* create(JSC::Structure* structure, JSDOMGlobalObject* globalObject, PassRefPtr impl) + typedef JSNonFinalObject Base; + static JSArrayBuffer* create(JSC::Structure* structure, JSGlobalObject* globalObject, PassRefPtr impl) { JSArrayBuffer* ptr = new (NotNull, JSC::allocateCell(globalObject->globalData().heap)) JSArrayBuffer(structure, globalObject, impl); ptr->finishCreation(globalObject->globalData()); @@ -60,7 +62,7 @@ class JSArrayBuffer : public JSDOMWrapper { private: ArrayBuffer* m_impl; protected: - JSArrayBuffer(JSC::Structure*, JSDOMGlobalObject*, PassRefPtr); + JSArrayBuffer(JSC::Structure*, JSGlobalObject*, PassRefPtr); void finishCreation(JSC::JSGlobalData&); static const unsigned StructureFlags = JSC::OverridesGetOwnPropertySlot | Base::StructureFlags; }; @@ -70,6 +72,7 @@ class JSArrayBufferOwner : public JSC::WeakHandleOwner { virtual void finalize(JSC::Handle, void* context); }; +/* inline JSC::WeakHandleOwner* wrapperOwner(DOMWrapperWorld*, ArrayBuffer*) { DEFINE_STATIC_LOCAL(JSArrayBufferOwner, jsArrayBufferOwner, ()); @@ -80,8 +83,9 @@ inline void* wrapperContext(DOMWrapperWorld* world, ArrayBuffer*) { return world; } +*/ -JSC::JSValue toJS(JSC::ExecState*, JSDOMGlobalObject*, ArrayBuffer*); +JSC::JSValue toJS(JSC::ExecState*, JSGlobalObject*, ArrayBuffer*); ArrayBuffer* toArrayBuffer(JSC::JSValue); class JSArrayBufferPrototype : public JSC::JSNonFinalObject { @@ -109,16 +113,16 @@ class JSArrayBufferPrototype : public JSC::JSNonFinalObject { static const unsigned StructureFlags = JSC::OverridesGetOwnPropertySlot | Base::StructureFlags; }; -class JSArrayBufferConstructor : public DOMConstructorObject { +class JSArrayBufferConstructor : public InternalFunction { private: - JSArrayBufferConstructor(JSC::Structure*, JSDOMGlobalObject*); - void finishCreation(JSC::ExecState*, JSDOMGlobalObject*); + JSArrayBufferConstructor(JSGlobalObject* globalObject, Structure* structure); + void finishCreation(JSC::ExecState*, JSGlobalObject*); public: - typedef DOMConstructorObject Base; - static JSArrayBufferConstructor* create(JSC::ExecState* exec, JSC::Structure* structure, JSDOMGlobalObject* globalObject) + typedef InternalFunction Base; + static JSArrayBufferConstructor* create(JSC::ExecState* exec, JSC::Structure* structure, JSGlobalObject* globalObject) { - JSArrayBufferConstructor* ptr = new (NotNull, JSC::allocateCell(*exec->heap())) JSArrayBufferConstructor(structure, globalObject); + JSArrayBufferConstructor* ptr = new (NotNull, JSC::allocateCell(*exec->heap())) JSArrayBufferConstructor(globalObject, structure); ptr->finishCreation(exec, globalObject); return ptr; } @@ -131,7 +135,7 @@ class JSArrayBufferConstructor : public DOMConstructorObject { return JSC::Structure::create(globalData, globalObject, prototype, JSC::TypeInfo(JSC::ObjectType, StructureFlags), &s_info); } protected: - static const unsigned StructureFlags = JSC::OverridesGetOwnPropertySlot | JSC::ImplementsHasInstance | DOMConstructorObject::StructureFlags; + static const unsigned StructureFlags = JSC::OverridesGetOwnPropertySlot | JSC::ImplementsHasInstance | InternalFunction::StructureFlags; static JSC::EncodedJSValue JSC_HOST_CALL constructJSArrayBuffer(JSC::ExecState*); static JSC::ConstructType getConstructData(JSC::JSCell*, JSC::ConstructData&); }; diff --git a/JavaScriptCore/runtime/TypedArrays/JSArrayBufferCustom.cpp b/JavaScriptCore/runtime/TypedArrays/JSArrayBufferCustom.cpp index 2fa306a9..e5b76700 100644 --- a/JavaScriptCore/runtime/TypedArrays/JSArrayBufferCustom.cpp +++ b/JavaScriptCore/runtime/TypedArrays/JSArrayBufferCustom.cpp @@ -26,13 +26,10 @@ #include "config.h" #include "JSArrayBuffer.h" -#include "ExceptionCode.h" #include #include -namespace WebCore { - -using namespace JSC; +namespace JSC { EncodedJSValue JSC_HOST_CALL JSArrayBufferConstructor::constructJSArrayBuffer(ExecState* exec) { diff --git a/JavaScriptCore/runtime/TypedArrays/JSArrayBufferView.cpp b/JavaScriptCore/runtime/TypedArrays/JSArrayBufferView.cpp index ef075daf..130c5e32 100644 --- a/JavaScriptCore/runtime/TypedArrays/JSArrayBufferView.cpp +++ b/JavaScriptCore/runtime/TypedArrays/JSArrayBufferView.cpp @@ -21,6 +21,7 @@ #include "config.h" #include "JSArrayBufferView.h" +#include "Lookup.h" #include "JSArrayBuffer.h" #include #include @@ -28,7 +29,7 @@ using namespace JSC; -namespace WebCore { +namespace JSC { ASSERT_CLASS_FITS_IN_CELL(JSArrayBufferView); /* Hash table */ @@ -52,25 +53,36 @@ static const HashTableValue JSArrayBufferViewPrototypeTableValues[] = static const HashTable JSArrayBufferViewPrototypeTable = { 1, 0, JSArrayBufferViewPrototypeTableValues, 0 }; static const HashTable* getJSArrayBufferViewPrototypeTable(ExecState* exec) { - return getHashTableForGlobalData(exec->globalData(), &JSArrayBufferViewPrototypeTable); + ASSERT_UNUSED(exec, exec); + return &JSArrayBufferViewPrototypeTable; // PL FIXME: should be one instance per global data, not super global } const ClassInfo JSArrayBufferViewPrototype::s_info = { "ArrayBufferViewPrototype", &Base::s_info, 0, getJSArrayBufferViewPrototypeTable, CREATE_METHOD_TABLE(JSArrayBufferViewPrototype) }; + +static JSObject * globalProto = NULL; JSObject* JSArrayBufferViewPrototype::self(ExecState* exec, JSGlobalObject* globalObject) { - return getDOMPrototype(exec, globalObject); + // PL FIXME: dirty hack to provide one global prototype + if( !globalProto ) { + JSGlobalData &data = exec->globalData(); + globalProto = JSArrayBufferViewPrototype::create(data, globalObject, + JSArrayBufferViewPrototype::createStructure(data, globalObject, + globalObject->objectPrototype())); + } + return globalProto; } static const HashTable* getJSArrayBufferViewTable(ExecState* exec) { - return getHashTableForGlobalData(exec->globalData(), &JSArrayBufferViewTable); + ASSERT_UNUSED(exec, exec); + return &JSArrayBufferViewTable; } const ClassInfo JSArrayBufferView::s_info = { "ArrayBufferView", &Base::s_info, 0, getJSArrayBufferViewTable , CREATE_METHOD_TABLE(JSArrayBufferView) }; -JSArrayBufferView::JSArrayBufferView(Structure* structure, JSDOMGlobalObject* globalObject, PassRefPtr impl) - : JSDOMWrapper(structure, globalObject) +JSArrayBufferView::JSArrayBufferView(Structure* structure, JSGlobalObject* globalObject, PassRefPtr impl) + : JSNonFinalObject(globalObject->globalData(), structure) , m_impl(impl.leakRef()) { } @@ -159,9 +171,8 @@ bool JSArrayBufferViewOwner::isReachableFromOpaqueRoots(JSC::Handle handle, void* context) { + ASSERT_UNUSED(context, context); JSArrayBufferView* jsArrayBufferView = jsCast(handle.get().asCell()); - DOMWrapperWorld* world = static_cast(context); - uncacheWrapper(world, jsArrayBufferView->impl(), jsArrayBufferView); jsArrayBufferView->releaseImpl(); } diff --git a/JavaScriptCore/runtime/TypedArrays/JSArrayBufferView.h b/JavaScriptCore/runtime/TypedArrays/JSArrayBufferView.h index 6171bd4c..01b1df93 100644 --- a/JavaScriptCore/runtime/TypedArrays/JSArrayBufferView.h +++ b/JavaScriptCore/runtime/TypedArrays/JSArrayBufferView.h @@ -21,18 +21,17 @@ #ifndef JSArrayBufferView_h #define JSArrayBufferView_h -#include "JSDOMBinding.h" #include #include #include #include -namespace WebCore { +namespace JSC { -class JSArrayBufferView : public JSDOMWrapper { +class JSArrayBufferView : public JSNonFinalObject { public: - typedef JSDOMWrapper Base; - static JSArrayBufferView* create(JSC::Structure* structure, JSDOMGlobalObject* globalObject, PassRefPtr impl) + typedef JSNonFinalObject Base; + static JSArrayBufferView* create(JSC::Structure* structure, JSGlobalObject* globalObject, PassRefPtr impl) { JSArrayBufferView* ptr = new (NotNull, JSC::allocateCell(globalObject->globalData().heap)) JSArrayBufferView(structure, globalObject, impl); ptr->finishCreation(globalObject->globalData()); @@ -59,7 +58,7 @@ class JSArrayBufferView : public JSDOMWrapper { private: ArrayBufferView* m_impl; protected: - JSArrayBufferView(JSC::Structure*, JSDOMGlobalObject*, PassRefPtr); + JSArrayBufferView(JSC::Structure*, JSGlobalObject*, PassRefPtr); void finishCreation(JSC::JSGlobalData&); static const unsigned StructureFlags = JSC::OverridesGetOwnPropertySlot | Base::StructureFlags; }; @@ -69,18 +68,21 @@ class JSArrayBufferViewOwner : public JSC::WeakHandleOwner { virtual void finalize(JSC::Handle, void* context); }; +/* inline JSC::WeakHandleOwner* wrapperOwner(DOMWrapperWorld*, ArrayBufferView*) { DEFINE_STATIC_LOCAL(JSArrayBufferViewOwner, jsArrayBufferViewOwner, ()); return &jsArrayBufferViewOwner; } + inline void* wrapperContext(DOMWrapperWorld* world, ArrayBufferView*) { return world; } +*/ -JSC::JSValue toJS(JSC::ExecState*, JSDOMGlobalObject*, ArrayBufferView*); +JSC::JSValue toJS(JSC::ExecState*, JSGlobalObject*, ArrayBufferView*); ArrayBufferView* toArrayBufferView(JSC::JSValue); class JSArrayBufferViewPrototype : public JSC::JSNonFinalObject { diff --git a/JavaScriptCore/runtime/TypedArrays/JSArrayBufferViewHelper.h b/JavaScriptCore/runtime/TypedArrays/JSArrayBufferViewHelper.h index df9e4390..b9e84bc2 100644 --- a/JavaScriptCore/runtime/TypedArrays/JSArrayBufferViewHelper.h +++ b/JavaScriptCore/runtime/TypedArrays/JSArrayBufferViewHelper.h @@ -37,7 +37,7 @@ #include #include -namespace WebCore { +namespace JSC { template JSC::JSValue setWebGLArrayHelper(JSC::ExecState* exec, T* impl, T* (*conversionFunc)(JSC::JSValue)) From 281f45e76864eebca952bc9a9c8cf4f32bd2b00b Mon Sep 17 00:00:00 2001 From: Dominic Szablewski Date: Sat, 8 Dec 2012 13:44:11 +0100 Subject: [PATCH 03/30] Move ArrayBuffer back to WebCore namespace --- .../runtime/TypedArrays/JSArrayBuffer.cpp | 2 +- .../runtime/TypedArrays/JSArrayBuffer.h | 24 +++++++++---------- .../TypedArrays/JSArrayBufferCustom.cpp | 10 ++++---- .../runtime/TypedArrays/JSArrayBufferView.cpp | 2 +- .../runtime/TypedArrays/JSArrayBufferView.h | 10 ++++---- 5 files changed, 24 insertions(+), 24 deletions(-) diff --git a/JavaScriptCore/runtime/TypedArrays/JSArrayBuffer.cpp b/JavaScriptCore/runtime/TypedArrays/JSArrayBuffer.cpp index 6274783f..e15a95c3 100644 --- a/JavaScriptCore/runtime/TypedArrays/JSArrayBuffer.cpp +++ b/JavaScriptCore/runtime/TypedArrays/JSArrayBuffer.cpp @@ -29,7 +29,7 @@ using namespace JSC; -namespace JSC { +namespace WebCore { enum ParameterDefaultPolicy { DefaultIsUndefined, diff --git a/JavaScriptCore/runtime/TypedArrays/JSArrayBuffer.h b/JavaScriptCore/runtime/TypedArrays/JSArrayBuffer.h index 10ac9d55..e15ac881 100644 --- a/JavaScriptCore/runtime/TypedArrays/JSArrayBuffer.h +++ b/JavaScriptCore/runtime/TypedArrays/JSArrayBuffer.h @@ -29,12 +29,12 @@ #include #include -namespace JSC { +namespace WebCore { -class JSArrayBuffer : public JSNonFinalObject { +class JSArrayBuffer : public JSC::JSNonFinalObject { public: - typedef JSNonFinalObject Base; - static JSArrayBuffer* create(JSC::Structure* structure, JSGlobalObject* globalObject, PassRefPtr impl) + typedef JSC::JSNonFinalObject Base; + static JSArrayBuffer* create(JSC::Structure* structure, JSC::JSGlobalObject* globalObject, PassRefPtr impl) { JSArrayBuffer* ptr = new (NotNull, JSC::allocateCell(globalObject->globalData().heap)) JSArrayBuffer(structure, globalObject, impl); ptr->finishCreation(globalObject->globalData()); @@ -62,7 +62,7 @@ class JSArrayBuffer : public JSNonFinalObject { private: ArrayBuffer* m_impl; protected: - JSArrayBuffer(JSC::Structure*, JSGlobalObject*, PassRefPtr); + JSArrayBuffer(JSC::Structure*, JSC::JSGlobalObject*, PassRefPtr); void finishCreation(JSC::JSGlobalData&); static const unsigned StructureFlags = JSC::OverridesGetOwnPropertySlot | Base::StructureFlags; }; @@ -85,7 +85,7 @@ inline void* wrapperContext(DOMWrapperWorld* world, ArrayBuffer*) } */ -JSC::JSValue toJS(JSC::ExecState*, JSGlobalObject*, ArrayBuffer*); +JSC::JSValue toJS(JSC::ExecState*, JSC::JSGlobalObject*, ArrayBuffer*); ArrayBuffer* toArrayBuffer(JSC::JSValue); class JSArrayBufferPrototype : public JSC::JSNonFinalObject { @@ -113,14 +113,14 @@ class JSArrayBufferPrototype : public JSC::JSNonFinalObject { static const unsigned StructureFlags = JSC::OverridesGetOwnPropertySlot | Base::StructureFlags; }; -class JSArrayBufferConstructor : public InternalFunction { +class JSArrayBufferConstructor : public JSC::InternalFunction { private: - JSArrayBufferConstructor(JSGlobalObject* globalObject, Structure* structure); - void finishCreation(JSC::ExecState*, JSGlobalObject*); + JSArrayBufferConstructor(JSC::JSGlobalObject* globalObject, JSC::Structure* structure); + void finishCreation(JSC::ExecState*, JSC::JSGlobalObject*); public: - typedef InternalFunction Base; - static JSArrayBufferConstructor* create(JSC::ExecState* exec, JSC::Structure* structure, JSGlobalObject* globalObject) + typedef JSC::InternalFunction Base; + static JSArrayBufferConstructor* create(JSC::ExecState* exec, JSC::Structure* structure, JSC::JSGlobalObject* globalObject) { JSArrayBufferConstructor* ptr = new (NotNull, JSC::allocateCell(*exec->heap())) JSArrayBufferConstructor(globalObject, structure); ptr->finishCreation(exec, globalObject); @@ -135,7 +135,7 @@ class JSArrayBufferConstructor : public InternalFunction { return JSC::Structure::create(globalData, globalObject, prototype, JSC::TypeInfo(JSC::ObjectType, StructureFlags), &s_info); } protected: - static const unsigned StructureFlags = JSC::OverridesGetOwnPropertySlot | JSC::ImplementsHasInstance | InternalFunction::StructureFlags; + static const unsigned StructureFlags = JSC::OverridesGetOwnPropertySlot | JSC::ImplementsHasInstance | JSC::InternalFunction::StructureFlags; static JSC::EncodedJSValue JSC_HOST_CALL constructJSArrayBuffer(JSC::ExecState*); static JSC::ConstructType getConstructData(JSC::JSCell*, JSC::ConstructData&); }; diff --git a/JavaScriptCore/runtime/TypedArrays/JSArrayBufferCustom.cpp b/JavaScriptCore/runtime/TypedArrays/JSArrayBufferCustom.cpp index e5b76700..a5784027 100644 --- a/JavaScriptCore/runtime/TypedArrays/JSArrayBufferCustom.cpp +++ b/JavaScriptCore/runtime/TypedArrays/JSArrayBufferCustom.cpp @@ -29,11 +29,11 @@ #include #include -namespace JSC { +namespace WebCore { -EncodedJSValue JSC_HOST_CALL JSArrayBufferConstructor::constructJSArrayBuffer(ExecState* exec) +JSC::EncodedJSValue JSC_HOST_CALL JSArrayBufferConstructor::constructJSArrayBuffer(JSC::ExecState* exec) { - JSArrayBufferConstructor* jsConstructor = jsCast(exec->callee()); + JSArrayBufferConstructor* jsConstructor = JSC::jsCast(exec->callee()); int length = 0; if (exec->argumentCount() > 0) @@ -42,8 +42,8 @@ EncodedJSValue JSC_HOST_CALL JSArrayBufferConstructor::constructJSArrayBuffer(Ex if (length >= 0) buffer = ArrayBuffer::create(static_cast(length), 1); if (!buffer.get()) - return throwVMError(exec, createRangeError(exec, "ArrayBuffer size is not a small enough positive integer.")); - return JSValue::encode(asObject(toJS(exec, jsConstructor->globalObject(), buffer.get()))); + return JSC::throwVMError(exec, JSC::createRangeError(exec, "ArrayBuffer size is not a small enough positive integer.")); + return JSC::JSValue::encode(asObject(toJS(exec, jsConstructor->globalObject(), buffer.get()))); } } // namespace WebCore diff --git a/JavaScriptCore/runtime/TypedArrays/JSArrayBufferView.cpp b/JavaScriptCore/runtime/TypedArrays/JSArrayBufferView.cpp index 130c5e32..45ba6666 100644 --- a/JavaScriptCore/runtime/TypedArrays/JSArrayBufferView.cpp +++ b/JavaScriptCore/runtime/TypedArrays/JSArrayBufferView.cpp @@ -29,7 +29,7 @@ using namespace JSC; -namespace JSC { +namespace WebCore { ASSERT_CLASS_FITS_IN_CELL(JSArrayBufferView); /* Hash table */ diff --git a/JavaScriptCore/runtime/TypedArrays/JSArrayBufferView.h b/JavaScriptCore/runtime/TypedArrays/JSArrayBufferView.h index 01b1df93..0303b8bc 100644 --- a/JavaScriptCore/runtime/TypedArrays/JSArrayBufferView.h +++ b/JavaScriptCore/runtime/TypedArrays/JSArrayBufferView.h @@ -26,12 +26,12 @@ #include #include -namespace JSC { +namespace WebCore { -class JSArrayBufferView : public JSNonFinalObject { +class JSArrayBufferView : public JSC::JSNonFinalObject { public: typedef JSNonFinalObject Base; - static JSArrayBufferView* create(JSC::Structure* structure, JSGlobalObject* globalObject, PassRefPtr impl) + static JSArrayBufferView* create(JSC::Structure* structure, JSC::JSGlobalObject* globalObject, PassRefPtr impl) { JSArrayBufferView* ptr = new (NotNull, JSC::allocateCell(globalObject->globalData().heap)) JSArrayBufferView(structure, globalObject, impl); ptr->finishCreation(globalObject->globalData()); @@ -58,7 +58,7 @@ class JSArrayBufferView : public JSNonFinalObject { private: ArrayBufferView* m_impl; protected: - JSArrayBufferView(JSC::Structure*, JSGlobalObject*, PassRefPtr); + JSArrayBufferView(JSC::Structure*, JSC::JSGlobalObject*, PassRefPtr); void finishCreation(JSC::JSGlobalData&); static const unsigned StructureFlags = JSC::OverridesGetOwnPropertySlot | Base::StructureFlags; }; @@ -82,7 +82,7 @@ inline void* wrapperContext(DOMWrapperWorld* world, ArrayBufferView*) } */ -JSC::JSValue toJS(JSC::ExecState*, JSGlobalObject*, ArrayBufferView*); +JSC::JSValue toJS(JSC::ExecState*, JSC::JSGlobalObject*, ArrayBufferView*); ArrayBufferView* toArrayBufferView(JSC::JSValue); class JSArrayBufferViewPrototype : public JSC::JSNonFinalObject { From 8c56723156f44e9fbf3b536081e4bc84a3870f65 Mon Sep 17 00:00:00 2001 From: Dominic Szablewski Date: Sat, 8 Dec 2012 14:05:00 +0100 Subject: [PATCH 04/30] Added Float32Array --- .../JavaScriptCore.xcodeproj/project.pbxproj | 12 + .../runtime/TypedArrays/JSFloat32Array.cpp | 297 ++++++++++++++++++ .../runtime/TypedArrays/JSFloat32Array.h | 143 +++++++++ 3 files changed, 452 insertions(+) create mode 100644 JavaScriptCore/runtime/TypedArrays/JSFloat32Array.cpp create mode 100644 JavaScriptCore/runtime/TypedArrays/JSFloat32Array.h diff --git a/JavaScriptCore/JavaScriptCore.xcodeproj/project.pbxproj b/JavaScriptCore/JavaScriptCore.xcodeproj/project.pbxproj index cdf0b8ae..f9d78a4b 100644 --- a/JavaScriptCore/JavaScriptCore.xcodeproj/project.pbxproj +++ b/JavaScriptCore/JavaScriptCore.xcodeproj/project.pbxproj @@ -549,6 +549,10 @@ B6D18835166FA73400D1037C /* JSArrayBufferView.h in Headers */ = {isa = PBXBuildFile; fileRef = B6D18818166FA73400D1037C /* JSArrayBufferView.h */; }; B6D18836166FA73400D1037C /* JSArrayBufferViewHelper.h in Headers */ = {isa = PBXBuildFile; fileRef = B6D18819166FA73400D1037C /* JSArrayBufferViewHelper.h */; }; B6D18837166FA73400D1037C /* JSArrayBufferViewHelper.h in Headers */ = {isa = PBXBuildFile; fileRef = B6D18819166FA73400D1037C /* JSArrayBufferViewHelper.h */; }; + B6D188701672DFE800D1037C /* JSFloat32Array.cpp in Sources */ = {isa = PBXBuildFile; fileRef = B6D1886E1672DFE700D1037C /* JSFloat32Array.cpp */; }; + B6D188711672DFE800D1037C /* JSFloat32Array.cpp in Sources */ = {isa = PBXBuildFile; fileRef = B6D1886E1672DFE700D1037C /* JSFloat32Array.cpp */; }; + B6D188721672DFE800D1037C /* JSFloat32Array.h in Headers */ = {isa = PBXBuildFile; fileRef = B6D1886F1672DFE700D1037C /* JSFloat32Array.h */; }; + B6D188731672DFE800D1037C /* JSFloat32Array.h in Headers */ = {isa = PBXBuildFile; fileRef = B6D1886F1672DFE700D1037C /* JSFloat32Array.h */; }; B6E69991166BD63D005EF4B1 /* AbstractMacroAssembler.h in Headers */ = {isa = PBXBuildFile; fileRef = 860161DF0F3A83C100F84710 /* AbstractMacroAssembler.h */; }; B6E69992166BD63D005EF4B1 /* APICast.h in Headers */ = {isa = PBXBuildFile; fileRef = 1482B78A0A4305AB00517CFC /* APICast.h */; settings = {ATTRIBUTES = (Private, ); }; }; B6E69993166BD63D005EF4B1 /* APIShims.h in Headers */ = {isa = PBXBuildFile; fileRef = 865F408710E7D56300947361 /* APIShims.h */; settings = {ATTRIBUTES = (Private, ); }; }; @@ -1822,6 +1826,8 @@ B6D18817166FA73400D1037C /* JSArrayBufferView.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = JSArrayBufferView.cpp; sourceTree = ""; }; B6D18818166FA73400D1037C /* JSArrayBufferView.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = JSArrayBufferView.h; sourceTree = ""; }; B6D18819166FA73400D1037C /* JSArrayBufferViewHelper.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = JSArrayBufferViewHelper.h; sourceTree = ""; }; + B6D1886E1672DFE700D1037C /* JSFloat32Array.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = JSFloat32Array.cpp; sourceTree = ""; }; + B6D1886F1672DFE700D1037C /* JSFloat32Array.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = JSFloat32Array.h; sourceTree = ""; }; B6E69BC4166BD63D005EF4B1 /* libJavaScriptCore.a */ = {isa = PBXFileReference; explicitFileType = archive.ar; includeInIndex = 0; path = libJavaScriptCore.a; sourceTree = BUILT_PRODUCTS_DIR; }; B6E69BDB166BD6C1005EF4B1 /* libJSCLLIntOffsetsExtractor.a */ = {isa = PBXFileReference; explicitFileType = archive.ar; includeInIndex = 0; path = libJSCLLIntOffsetsExtractor.a; sourceTree = BUILT_PRODUCTS_DIR; }; B6E69BFD166BDCE7005EF4B1 /* libWTF.a */ = {isa = PBXFileReference; lastKnownFileType = archive.ar; name = libWTF.a; path = ../Build/libWTF.a; sourceTree = ""; }; @@ -2877,6 +2883,8 @@ B6D18817166FA73400D1037C /* JSArrayBufferView.cpp */, B6D18818166FA73400D1037C /* JSArrayBufferView.h */, B6D18819166FA73400D1037C /* JSArrayBufferViewHelper.h */, + B6D1886E1672DFE700D1037C /* JSFloat32Array.cpp */, + B6D1886F1672DFE700D1037C /* JSFloat32Array.h */, ); path = TypedArrays; sourceTree = ""; @@ -3241,6 +3249,7 @@ B6D1882E166FA73400D1037C /* JSArrayBuffer.h in Headers */, B6D18834166FA73400D1037C /* JSArrayBufferView.h in Headers */, B6D18836166FA73400D1037C /* JSArrayBufferViewHelper.h in Headers */, + B6D188721672DFE800D1037C /* JSFloat32Array.h in Headers */, ); runOnlyForDeploymentPostprocessing = 0; }; @@ -3589,6 +3598,7 @@ B6D1882F166FA73400D1037C /* JSArrayBuffer.h in Headers */, B6D18835166FA73400D1037C /* JSArrayBufferView.h in Headers */, B6D18837166FA73400D1037C /* JSArrayBufferViewHelper.h in Headers */, + B6D188731672DFE800D1037C /* JSFloat32Array.h in Headers */, ); runOnlyForDeploymentPostprocessing = 0; }; @@ -4337,6 +4347,7 @@ B6D1882C166FA73400D1037C /* JSArrayBuffer.cpp in Sources */, B6D18830166FA73400D1037C /* JSArrayBufferCustom.cpp in Sources */, B6D18832166FA73400D1037C /* JSArrayBufferView.cpp in Sources */, + B6D188701672DFE800D1037C /* JSFloat32Array.cpp in Sources */, ); runOnlyForDeploymentPostprocessing = 0; }; @@ -4564,6 +4575,7 @@ B6D1882D166FA73400D1037C /* JSArrayBuffer.cpp in Sources */, B6D18831166FA73400D1037C /* JSArrayBufferCustom.cpp in Sources */, B6D18833166FA73400D1037C /* JSArrayBufferView.cpp in Sources */, + B6D188711672DFE800D1037C /* JSFloat32Array.cpp in Sources */, ); runOnlyForDeploymentPostprocessing = 0; }; diff --git a/JavaScriptCore/runtime/TypedArrays/JSFloat32Array.cpp b/JavaScriptCore/runtime/TypedArrays/JSFloat32Array.cpp new file mode 100644 index 00000000..ace53168 --- /dev/null +++ b/JavaScriptCore/runtime/TypedArrays/JSFloat32Array.cpp @@ -0,0 +1,297 @@ +/* + 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 "JSFloat32Array.h" + +#include "ExceptionCode.h" +#include "JSDOMBinding.h" +#include "JSFloat32Array.h" +#include +#include +#include +#include + +using namespace JSC; + +namespace WebCore { + +ASSERT_CLASS_FITS_IN_CELL(JSFloat32Array); +/* Hash table */ + +static const HashTableValue JSFloat32ArrayTableValues[] = +{ + { "length", DontDelete | ReadOnly, (intptr_t)static_cast(jsFloat32ArrayLength), (intptr_t)0, NoIntrinsic }, + { "constructor", DontEnum | ReadOnly, (intptr_t)static_cast(jsFloat32ArrayConstructor), (intptr_t)0, NoIntrinsic }, + { 0, 0, 0, 0, NoIntrinsic } +}; + +static const HashTable JSFloat32ArrayTable = { 5, 3, JSFloat32ArrayTableValues, 0 }; +/* Hash table for constructor */ + +static const HashTableValue JSFloat32ArrayConstructorTableValues[] = +{ + { "BYTES_PER_ELEMENT", DontDelete | ReadOnly, (intptr_t)static_cast(jsFloat32ArrayBYTES_PER_ELEMENT), (intptr_t)0, NoIntrinsic }, + { 0, 0, 0, 0, NoIntrinsic } +}; + +static const HashTable JSFloat32ArrayConstructorTable = { 2, 1, JSFloat32ArrayConstructorTableValues, 0 }; +const ClassInfo JSFloat32ArrayConstructor::s_info = { "Float32ArrayConstructor", &Base::s_info, &JSFloat32ArrayConstructorTable, 0, CREATE_METHOD_TABLE(JSFloat32ArrayConstructor) }; + +JSFloat32ArrayConstructor::JSFloat32ArrayConstructor(Structure* structure, JSDOMGlobalObject* globalObject) + : DOMConstructorObject(structure, globalObject) +{ +} + +void JSFloat32ArrayConstructor::finishCreation(ExecState* exec, JSDOMGlobalObject* globalObject) +{ + Base::finishCreation(exec->globalData()); + ASSERT(inherits(&s_info)); + putDirect(exec->globalData(), exec->propertyNames().prototype, JSFloat32ArrayPrototype::self(exec, globalObject), DontDelete | ReadOnly); + putDirect(exec->globalData(), exec->propertyNames().length, jsNumber(1), ReadOnly | DontDelete | DontEnum); +} + +bool JSFloat32ArrayConstructor::getOwnPropertySlot(JSCell* cell, ExecState* exec, const Identifier& propertyName, PropertySlot& slot) +{ + return getStaticValueSlot(exec, &JSFloat32ArrayConstructorTable, jsCast(cell), propertyName, slot); +} + +bool JSFloat32ArrayConstructor::getOwnPropertyDescriptor(JSObject* object, ExecState* exec, const Identifier& propertyName, PropertyDescriptor& descriptor) +{ + return getStaticValueDescriptor(exec, &JSFloat32ArrayConstructorTable, jsCast(object), propertyName, descriptor); +} + +ConstructType JSFloat32ArrayConstructor::getConstructData(JSCell*, ConstructData& constructData) +{ + constructData.native.function = constructJSFloat32Array; + return ConstructTypeHost; +} + +/* Hash table for prototype */ + +static const HashTableValue JSFloat32ArrayPrototypeTableValues[] = +{ + { "BYTES_PER_ELEMENT", DontDelete | ReadOnly, (intptr_t)static_cast(jsFloat32ArrayBYTES_PER_ELEMENT), (intptr_t)0, NoIntrinsic }, + { "subarray", DontDelete | JSC::Function, (intptr_t)static_cast(jsFloat32ArrayPrototypeFunctionSubarray), (intptr_t)2, NoIntrinsic }, + { "set", DontDelete | JSC::Function, (intptr_t)static_cast(jsFloat32ArrayPrototypeFunctionSet), (intptr_t)0, NoIntrinsic }, + { 0, 0, 0, 0, NoIntrinsic } +}; + +static const HashTable JSFloat32ArrayPrototypeTable = { 8, 7, JSFloat32ArrayPrototypeTableValues, 0 }; +static const HashTable* getJSFloat32ArrayPrototypeTable(ExecState* exec) +{ + return getHashTableForGlobalData(exec->globalData(), &JSFloat32ArrayPrototypeTable); +} + +const ClassInfo JSFloat32ArrayPrototype::s_info = { "Float32ArrayPrototype", &Base::s_info, 0, getJSFloat32ArrayPrototypeTable, CREATE_METHOD_TABLE(JSFloat32ArrayPrototype) }; + +JSObject* JSFloat32ArrayPrototype::self(ExecState* exec, JSGlobalObject* globalObject) +{ + return getDOMPrototype(exec, globalObject); +} + +bool JSFloat32ArrayPrototype::getOwnPropertySlot(JSCell* cell, ExecState* exec, const Identifier& propertyName, PropertySlot& slot) +{ + JSFloat32ArrayPrototype* thisObject = jsCast(cell); + return getStaticPropertySlot(exec, getJSFloat32ArrayPrototypeTable(exec), thisObject, propertyName, slot); +} + +bool JSFloat32ArrayPrototype::getOwnPropertyDescriptor(JSObject* object, ExecState* exec, const Identifier& propertyName, PropertyDescriptor& descriptor) +{ + JSFloat32ArrayPrototype* thisObject = jsCast(object); + return getStaticPropertyDescriptor(exec, getJSFloat32ArrayPrototypeTable(exec), thisObject, propertyName, descriptor); +} + +static const HashTable* getJSFloat32ArrayTable(ExecState* exec) +{ + return getHashTableForGlobalData(exec->globalData(), &JSFloat32ArrayTable); +} + +const ClassInfo JSFloat32Array::s_info = { "Float32Array", &Base::s_info, 0, getJSFloat32ArrayTable , CREATE_METHOD_TABLE(JSFloat32Array) }; + +JSFloat32Array::JSFloat32Array(Structure* structure, JSDOMGlobalObject* globalObject, PassRefPtr impl) + : JSArrayBufferView(structure, globalObject, impl) +{ +} + +void JSFloat32Array::finishCreation(JSGlobalData& globalData) +{ + Base::finishCreation(globalData); + TypedArrayDescriptor descriptor(&JSFloat32Array::s_info, OBJECT_OFFSETOF(JSFloat32Array, m_storage), OBJECT_OFFSETOF(JSFloat32Array, m_storageLength)); + globalData.registerTypedArrayDescriptor(impl(), descriptor); + m_storage = impl()->data(); + m_storageLength = impl()->length(); + ASSERT(inherits(&s_info)); +} + +JSObject* JSFloat32Array::createPrototype(ExecState* exec, JSGlobalObject* globalObject) +{ + return JSFloat32ArrayPrototype::create(exec->globalData(), globalObject, JSFloat32ArrayPrototype::createStructure(exec->globalData(), globalObject, JSArrayBufferViewPrototype::self(exec, globalObject))); +} + +bool JSFloat32Array::getOwnPropertySlot(JSCell* cell, ExecState* exec, const Identifier& propertyName, PropertySlot& slot) +{ + JSFloat32Array* thisObject = jsCast(cell); + ASSERT_GC_OBJECT_INHERITS(thisObject, &s_info); + bool ok; + unsigned index = propertyName.toUInt32(ok); + if (ok && index < static_cast(thisObject->impl())->length()) { + slot.setValue(thisObject->getByIndex(exec, index)); + return true; + } + return getStaticValueSlot(exec, getJSFloat32ArrayTable(exec), thisObject, propertyName, slot); +} + +bool JSFloat32Array::getOwnPropertyDescriptor(JSObject* object, ExecState* exec, const Identifier& propertyName, PropertyDescriptor& descriptor) +{ + JSFloat32Array* thisObject = jsCast(object); + ASSERT_GC_OBJECT_INHERITS(thisObject, &s_info); + bool ok; + unsigned index = propertyName.toUInt32(ok); + if (ok && index < static_cast(thisObject->impl())->length()) { + descriptor.setDescriptor(thisObject->getByIndex(exec, index), DontDelete); + return true; + } + return getStaticValueDescriptor(exec, getJSFloat32ArrayTable(exec), thisObject, propertyName, descriptor); +} + +bool JSFloat32Array::getOwnPropertySlotByIndex(JSCell* cell, ExecState* exec, unsigned propertyName, PropertySlot& slot) +{ + JSFloat32Array* thisObject = jsCast(cell); + ASSERT_GC_OBJECT_INHERITS(thisObject, &s_info); + if (propertyName < static_cast(thisObject->impl())->length()) { + slot.setValue(thisObject->getByIndex(exec, propertyName)); + return true; + } + return thisObject->methodTable()->getOwnPropertySlot(thisObject, exec, Identifier::from(exec, propertyName), slot); +} + +JSValue jsFloat32ArrayLength(ExecState* exec, JSValue slotBase, const Identifier&) +{ + JSFloat32Array* castedThis = jsCast(asObject(slotBase)); + UNUSED_PARAM(exec); + Float32Array* impl = static_cast(castedThis->impl()); + JSValue result = jsNumber(impl->length()); + return result; +} + + +JSValue jsFloat32ArrayConstructor(ExecState* exec, JSValue slotBase, const Identifier&) +{ + JSFloat32Array* domObject = jsCast(asObject(slotBase)); + return JSFloat32Array::getConstructor(exec, domObject->globalObject()); +} + +void JSFloat32Array::put(JSCell* cell, ExecState* exec, const Identifier& propertyName, JSValue value, PutPropertySlot& slot) +{ + JSFloat32Array* thisObject = jsCast(cell); + ASSERT_GC_OBJECT_INHERITS(thisObject, &s_info); + bool ok; + unsigned index = propertyName.toUInt32(ok); + if (ok) { + thisObject->indexSetter(exec, index, value); + return; + } + Base::put(thisObject, exec, propertyName, value, slot); +} + +void JSFloat32Array::putByIndex(JSCell* cell, ExecState* exec, unsigned propertyName, JSValue value, bool) +{ + JSFloat32Array* thisObject = jsCast(cell); + ASSERT_GC_OBJECT_INHERITS(thisObject, &s_info); + thisObject->indexSetter(exec, propertyName, value); + return; +} + +void JSFloat32Array::getOwnPropertyNames(JSObject* object, ExecState* exec, PropertyNameArray& propertyNames, EnumerationMode mode) +{ + JSFloat32Array* thisObject = jsCast(object); + ASSERT_GC_OBJECT_INHERITS(thisObject, &s_info); + for (unsigned i = 0; i < static_cast(thisObject->impl())->length(); ++i) + propertyNames.add(Identifier::from(exec, i)); + Base::getOwnPropertyNames(thisObject, exec, propertyNames, mode); +} + +JSValue JSFloat32Array::getConstructor(ExecState* exec, JSGlobalObject* globalObject) +{ + return getDOMConstructor(exec, jsCast(globalObject)); +} + +EncodedJSValue JSC_HOST_CALL jsFloat32ArrayPrototypeFunctionSubarray(ExecState* exec) +{ + JSValue thisValue = exec->hostThisValue(); + if (!thisValue.inherits(&JSFloat32Array::s_info)) + return throwVMTypeError(exec); + JSFloat32Array* castedThis = jsCast(asObject(thisValue)); + ASSERT_GC_OBJECT_INHERITS(castedThis, &JSFloat32Array::s_info); + Float32Array* impl = static_cast(castedThis->impl()); + int start(MAYBE_MISSING_PARAMETER(exec, 0, DefaultIsUndefined).toInt32(exec)); + if (exec->hadException()) + return JSValue::encode(jsUndefined()); + + size_t argsCount = exec->argumentCount(); + if (argsCount <= 1) { + + JSC::JSValue result = toJS(exec, castedThis->globalObject(), WTF::getPtr(impl->subarray(start))); + return JSValue::encode(result); + } + + int end(MAYBE_MISSING_PARAMETER(exec, 1, DefaultIsUndefined).toInt32(exec)); + if (exec->hadException()) + return JSValue::encode(jsUndefined()); + + JSC::JSValue result = toJS(exec, castedThis->globalObject(), WTF::getPtr(impl->subarray(start, end))); + return JSValue::encode(result); +} + +EncodedJSValue JSC_HOST_CALL jsFloat32ArrayPrototypeFunctionSet(ExecState* exec) +{ + JSValue thisValue = exec->hostThisValue(); + if (!thisValue.inherits(&JSFloat32Array::s_info)) + return throwVMTypeError(exec); + JSFloat32Array* castedThis = jsCast(asObject(thisValue)); + ASSERT_GC_OBJECT_INHERITS(castedThis, &JSFloat32Array::s_info); + return JSValue::encode(castedThis->set(exec)); +} + +// Constant getters + +JSValue jsFloat32ArrayBYTES_PER_ELEMENT(ExecState* exec, JSValue, const Identifier&) +{ + UNUSED_PARAM(exec); + return jsNumber(static_cast(4)); +} + + +JSValue JSFloat32Array::getByIndex(ExecState*, unsigned index) +{ + ASSERT_GC_OBJECT_INHERITS(this, &s_info); + double result = static_cast(impl())->item(index); + if (isnan(result)) + return jsNaN(); + return JSValue(result); +} + +Float32Array* toFloat32Array(JSC::JSValue value) +{ + return value.inherits(&JSFloat32Array::s_info) ? jsCast(asObject(value))->impl() : 0; +} + +} diff --git a/JavaScriptCore/runtime/TypedArrays/JSFloat32Array.h b/JavaScriptCore/runtime/TypedArrays/JSFloat32Array.h new file mode 100644 index 00000000..eb734c60 --- /dev/null +++ b/JavaScriptCore/runtime/TypedArrays/JSFloat32Array.h @@ -0,0 +1,143 @@ +/* + 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. +*/ + +#ifndef JSFloat32Array_h +#define JSFloat32Array_h + +#include "JSArrayBufferView.h" +#include "JSDOMBinding.h" +#include +#include + +namespace WebCore { + +class JSFloat32Array : public JSArrayBufferView { +public: + typedef JSArrayBufferView Base; + static JSFloat32Array* create(JSC::Structure* structure, JSDOMGlobalObject* globalObject, PassRefPtr impl) + { + JSFloat32Array* ptr = new (NotNull, JSC::allocateCell(globalObject->globalData().heap)) JSFloat32Array(structure, globalObject, impl); + ptr->finishCreation(globalObject->globalData()); + return ptr; + } + + static JSC::JSObject* createPrototype(JSC::ExecState*, JSC::JSGlobalObject*); + static bool getOwnPropertySlot(JSC::JSCell*, JSC::ExecState*, const JSC::Identifier& propertyName, JSC::PropertySlot&); + static bool getOwnPropertyDescriptor(JSC::JSObject*, JSC::ExecState*, const JSC::Identifier& propertyName, JSC::PropertyDescriptor&); + static bool getOwnPropertySlotByIndex(JSC::JSCell*, JSC::ExecState*, unsigned propertyName, JSC::PropertySlot&); + static void put(JSC::JSCell*, JSC::ExecState*, const JSC::Identifier& propertyName, JSC::JSValue, JSC::PutPropertySlot&); + static void putByIndex(JSC::JSCell*, JSC::ExecState*, unsigned propertyName, JSC::JSValue, bool shouldThrow); + static const JSC::ClassInfo s_info; + + static JSC::Structure* createStructure(JSC::JSGlobalData& globalData, JSC::JSGlobalObject* globalObject, JSC::JSValue prototype) + { + return JSC::Structure::create(globalData, globalObject, prototype, JSC::TypeInfo(JSC::ObjectType, StructureFlags), &s_info); + } + + static void getOwnPropertyNames(JSC::JSObject*, JSC::ExecState*, JSC::PropertyNameArray&, JSC::EnumerationMode mode = JSC::ExcludeDontEnumProperties); + static JSC::JSValue getConstructor(JSC::ExecState*, JSC::JSGlobalObject*); + + // Custom functions + JSC::JSValue set(JSC::ExecState*); + Float32Array* impl() const + { + return static_cast(Base::impl()); + } + static const JSC::TypedArrayType TypedArrayStorageType = JSC::TypedArrayFloat32; + intptr_t m_storageLength; + void* m_storage; +protected: + JSFloat32Array(JSC::Structure*, JSDOMGlobalObject*, PassRefPtr); + void finishCreation(JSC::JSGlobalData&); + static const unsigned StructureFlags = JSC::OverridesGetPropertyNames | JSC::OverridesGetOwnPropertySlot | Base::StructureFlags; + JSC::JSValue getByIndex(JSC::ExecState*, unsigned index); + void indexSetter(JSC::ExecState*, unsigned index, JSC::JSValue); +}; + +JSC::JSValue toJS(JSC::ExecState*, JSDOMGlobalObject*, Float32Array*); +Float32Array* toFloat32Array(JSC::JSValue); + +class JSFloat32ArrayPrototype : public JSC::JSNonFinalObject { +public: + typedef JSC::JSNonFinalObject Base; + static JSC::JSObject* self(JSC::ExecState*, JSC::JSGlobalObject*); + static JSFloat32ArrayPrototype* create(JSC::JSGlobalData& globalData, JSC::JSGlobalObject* globalObject, JSC::Structure* structure) + { + JSFloat32ArrayPrototype* ptr = new (NotNull, JSC::allocateCell(globalData.heap)) JSFloat32ArrayPrototype(globalData, globalObject, structure); + ptr->finishCreation(globalData); + return ptr; + } + + static const JSC::ClassInfo s_info; + static bool getOwnPropertySlot(JSC::JSCell*, JSC::ExecState*, const JSC::Identifier&, JSC::PropertySlot&); + static bool getOwnPropertyDescriptor(JSC::JSObject*, JSC::ExecState*, const JSC::Identifier&, JSC::PropertyDescriptor&); + static JSC::Structure* createStructure(JSC::JSGlobalData& globalData, JSC::JSGlobalObject* globalObject, JSC::JSValue prototype) + { + return JSC::Structure::create(globalData, globalObject, prototype, JSC::TypeInfo(JSC::ObjectType, StructureFlags), &s_info); + } + +private: + JSFloat32ArrayPrototype(JSC::JSGlobalData& globalData, JSC::JSGlobalObject*, JSC::Structure* structure) : JSC::JSNonFinalObject(globalData, structure) { } +protected: + static const unsigned StructureFlags = JSC::OverridesGetOwnPropertySlot | Base::StructureFlags; +}; + +class JSFloat32ArrayConstructor : public DOMConstructorObject { +private: + JSFloat32ArrayConstructor(JSC::Structure*, JSDOMGlobalObject*); + void finishCreation(JSC::ExecState*, JSDOMGlobalObject*); + +public: + typedef DOMConstructorObject Base; + static JSFloat32ArrayConstructor* create(JSC::ExecState* exec, JSC::Structure* structure, JSDOMGlobalObject* globalObject) + { + JSFloat32ArrayConstructor* ptr = new (NotNull, JSC::allocateCell(*exec->heap())) JSFloat32ArrayConstructor(structure, globalObject); + ptr->finishCreation(exec, globalObject); + return ptr; + } + + static bool getOwnPropertySlot(JSC::JSCell*, JSC::ExecState*, const JSC::Identifier&, JSC::PropertySlot&); + static bool getOwnPropertyDescriptor(JSC::JSObject*, JSC::ExecState*, const JSC::Identifier&, JSC::PropertyDescriptor&); + static const JSC::ClassInfo s_info; + static JSC::Structure* createStructure(JSC::JSGlobalData& globalData, JSC::JSGlobalObject* globalObject, JSC::JSValue prototype) + { + return JSC::Structure::create(globalData, globalObject, prototype, JSC::TypeInfo(JSC::ObjectType, StructureFlags), &s_info); + } +protected: + static const unsigned StructureFlags = JSC::OverridesGetOwnPropertySlot | JSC::ImplementsHasInstance | DOMConstructorObject::StructureFlags; + static JSC::EncodedJSValue JSC_HOST_CALL constructJSFloat32Array(JSC::ExecState*); + static JSC::ConstructType getConstructData(JSC::JSCell*, JSC::ConstructData&); +}; + +// Functions + +JSC::EncodedJSValue JSC_HOST_CALL jsFloat32ArrayPrototypeFunctionSubarray(JSC::ExecState*); +JSC::EncodedJSValue JSC_HOST_CALL jsFloat32ArrayPrototypeFunctionSet(JSC::ExecState*); +// Attributes + +JSC::JSValue jsFloat32ArrayLength(JSC::ExecState*, JSC::JSValue, const JSC::Identifier&); +JSC::JSValue jsFloat32ArrayConstructor(JSC::ExecState*, JSC::JSValue, const JSC::Identifier&); +// Constants + +JSC::JSValue jsFloat32ArrayBYTES_PER_ELEMENT(JSC::ExecState*, JSC::JSValue, const JSC::Identifier&); + +} // namespace WebCore + +#endif From 98721f3442e55177b2584ae4131c6671fe1f5074 Mon Sep 17 00:00:00 2001 From: Dominic Szablewski Date: Sat, 8 Dec 2012 14:59:34 +0100 Subject: [PATCH 05/30] Added GlobalDataHelper for getting constructors/prototypes --- .../JavaScriptCore.xcodeproj/project.pbxproj | 6 ++ .../runtime/TypedArrays/GlobalDataHelper.h | 59 +++++++++++++++++++ .../runtime/TypedArrays/JSArrayBuffer.cpp | 16 +---- .../runtime/TypedArrays/JSArrayBufferView.cpp | 15 ++--- .../runtime/TypedArrays/JSFloat32Array.cpp | 24 ++++---- .../runtime/TypedArrays/JSFloat32Array.h | 20 +++---- 6 files changed, 95 insertions(+), 45 deletions(-) create mode 100644 JavaScriptCore/runtime/TypedArrays/GlobalDataHelper.h diff --git a/JavaScriptCore/JavaScriptCore.xcodeproj/project.pbxproj b/JavaScriptCore/JavaScriptCore.xcodeproj/project.pbxproj index f9d78a4b..a6500b95 100644 --- a/JavaScriptCore/JavaScriptCore.xcodeproj/project.pbxproj +++ b/JavaScriptCore/JavaScriptCore.xcodeproj/project.pbxproj @@ -553,6 +553,8 @@ B6D188711672DFE800D1037C /* JSFloat32Array.cpp in Sources */ = {isa = PBXBuildFile; fileRef = B6D1886E1672DFE700D1037C /* JSFloat32Array.cpp */; }; B6D188721672DFE800D1037C /* JSFloat32Array.h in Headers */ = {isa = PBXBuildFile; fileRef = B6D1886F1672DFE700D1037C /* JSFloat32Array.h */; }; B6D188731672DFE800D1037C /* JSFloat32Array.h in Headers */ = {isa = PBXBuildFile; fileRef = B6D1886F1672DFE700D1037C /* JSFloat32Array.h */; }; + B6D1888B1673751400D1037C /* GlobalDataHelper.h in Headers */ = {isa = PBXBuildFile; fileRef = B6D188881673751400D1037C /* GlobalDataHelper.h */; }; + B6D1888C1673751400D1037C /* GlobalDataHelper.h in Headers */ = {isa = PBXBuildFile; fileRef = B6D188881673751400D1037C /* GlobalDataHelper.h */; }; B6E69991166BD63D005EF4B1 /* AbstractMacroAssembler.h in Headers */ = {isa = PBXBuildFile; fileRef = 860161DF0F3A83C100F84710 /* AbstractMacroAssembler.h */; }; B6E69992166BD63D005EF4B1 /* APICast.h in Headers */ = {isa = PBXBuildFile; fileRef = 1482B78A0A4305AB00517CFC /* APICast.h */; settings = {ATTRIBUTES = (Private, ); }; }; B6E69993166BD63D005EF4B1 /* APIShims.h in Headers */ = {isa = PBXBuildFile; fileRef = 865F408710E7D56300947361 /* APIShims.h */; settings = {ATTRIBUTES = (Private, ); }; }; @@ -1828,6 +1830,7 @@ B6D18819166FA73400D1037C /* JSArrayBufferViewHelper.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = JSArrayBufferViewHelper.h; sourceTree = ""; }; B6D1886E1672DFE700D1037C /* JSFloat32Array.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = JSFloat32Array.cpp; sourceTree = ""; }; B6D1886F1672DFE700D1037C /* JSFloat32Array.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = JSFloat32Array.h; sourceTree = ""; }; + B6D188881673751400D1037C /* GlobalDataHelper.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = GlobalDataHelper.h; sourceTree = ""; }; B6E69BC4166BD63D005EF4B1 /* libJavaScriptCore.a */ = {isa = PBXFileReference; explicitFileType = archive.ar; includeInIndex = 0; path = libJavaScriptCore.a; sourceTree = BUILT_PRODUCTS_DIR; }; B6E69BDB166BD6C1005EF4B1 /* libJSCLLIntOffsetsExtractor.a */ = {isa = PBXFileReference; explicitFileType = archive.ar; includeInIndex = 0; path = libJSCLLIntOffsetsExtractor.a; sourceTree = BUILT_PRODUCTS_DIR; }; B6E69BFD166BDCE7005EF4B1 /* libWTF.a */ = {isa = PBXFileReference; lastKnownFileType = archive.ar; name = libWTF.a; path = ../Build/libWTF.a; sourceTree = ""; }; @@ -2885,6 +2888,7 @@ B6D18819166FA73400D1037C /* JSArrayBufferViewHelper.h */, B6D1886E1672DFE700D1037C /* JSFloat32Array.cpp */, B6D1886F1672DFE700D1037C /* JSFloat32Array.h */, + B6D188881673751400D1037C /* GlobalDataHelper.h */, ); path = TypedArrays; sourceTree = ""; @@ -3250,6 +3254,7 @@ B6D18834166FA73400D1037C /* JSArrayBufferView.h in Headers */, B6D18836166FA73400D1037C /* JSArrayBufferViewHelper.h in Headers */, B6D188721672DFE800D1037C /* JSFloat32Array.h in Headers */, + B6D1888B1673751400D1037C /* GlobalDataHelper.h in Headers */, ); runOnlyForDeploymentPostprocessing = 0; }; @@ -3599,6 +3604,7 @@ B6D18835166FA73400D1037C /* JSArrayBufferView.h in Headers */, B6D18837166FA73400D1037C /* JSArrayBufferViewHelper.h in Headers */, B6D188731672DFE800D1037C /* JSFloat32Array.h in Headers */, + B6D1888C1673751400D1037C /* GlobalDataHelper.h in Headers */, ); runOnlyForDeploymentPostprocessing = 0; }; diff --git a/JavaScriptCore/runtime/TypedArrays/GlobalDataHelper.h b/JavaScriptCore/runtime/TypedArrays/GlobalDataHelper.h new file mode 100644 index 00000000..1db4ae37 --- /dev/null +++ b/JavaScriptCore/runtime/TypedArrays/GlobalDataHelper.h @@ -0,0 +1,59 @@ +#ifndef __JavaScriptCore__GlobalDataHelper__ +#define __JavaScriptCore__GlobalDataHelper__ + +#include +#include "Lookup.h" + +#include "JSObject.h" +#include "InternalFunction.h" + +#include +#include +#include +#include + +namespace WebCore { + +enum ParameterDefaultPolicy { + DefaultIsUndefined, + DefaultIsNullString +}; + + +#define MAYBE_MISSING_PARAMETER(exec, index, policy) (((policy) == DefaultIsNullString && (index) >= (exec)->argumentCount()) ? (JSValue()) : ((exec)->argument(index))) + +static inline const JSC::HashTable* getHashTableForGlobalData(JSC::JSGlobalData& globalData, const JSC::HashTable* staticTable) { + ASSERT_UNUSED(&globalData, &globalData); + // PL FIXME: this should return a copy per globalData. I think. + return staticTable; +} + + +template +static inline JSC::JSObject* getDOMConstructor(JSC::ExecState* exec, JSC::JSGlobalObject* globalObject) +{ + static ConstructorClass * globalConstructor; + if( !globalConstructor ) { + globalConstructor = ConstructorClass::create(exec, ConstructorClass::createStructure(exec->globalData(), globalObject, globalObject->objectPrototype()), globalObject); + } + return (JSC::JSObject *)globalConstructor; +} + + +template +static inline JSC::JSObject* getDOMPrototype(JSC::ExecState* exec, JSC::JSGlobalObject* globalObject) +{ + static PrototypeClass * globalPrototype; + if( !globalPrototype ) { + JSC::JSGlobalData &data = exec->globalData(); + + globalPrototype = PrototypeClass::create(data, globalObject, + PrototypeClass::createStructure(data, globalObject, globalObject->objectPrototype())); + } + return (JSC::JSObject *)globalPrototype; +} + + +} + +#endif /* defined(__JavaScriptCore__GlobalDataHelper__) */ diff --git a/JavaScriptCore/runtime/TypedArrays/JSArrayBuffer.cpp b/JavaScriptCore/runtime/TypedArrays/JSArrayBuffer.cpp index e15a95c3..1d17bc45 100644 --- a/JavaScriptCore/runtime/TypedArrays/JSArrayBuffer.cpp +++ b/JavaScriptCore/runtime/TypedArrays/JSArrayBuffer.cpp @@ -27,17 +27,12 @@ #include #include +#include "GlobalDataHelper.h" + using namespace JSC; namespace WebCore { -enum ParameterDefaultPolicy { - DefaultIsUndefined, - DefaultIsNullString -}; - -#define MAYBE_MISSING_PARAMETER(exec, index, policy) (((policy) == DefaultIsNullString && (index) >= (exec)->argumentCount()) ? (JSValue()) : ((exec)->argument(index))) - ASSERT_CLASS_FITS_IN_CELL(JSArrayBuffer); /* Hash table */ @@ -195,14 +190,9 @@ JSValue jsArrayBufferConstructor(ExecState* exec, JSValue slotBase, const Identi return JSArrayBuffer::getConstructor(exec, domObject->globalObject()); } -static JSObject * globalConstructor; JSValue JSArrayBuffer::getConstructor(ExecState* exec, JSGlobalObject* globalObject) { - if( !globalConstructor ) { - JSArrayBufferConstructor * constructor = JSArrayBufferConstructor::create(exec, JSArrayBufferConstructor::createStructure(exec->globalData(), globalObject, globalObject->objectPrototype()), globalObject); - globalConstructor = constructor; - } - return globalConstructor; + return getDOMConstructor(exec, jsCast(globalObject)); } EncodedJSValue JSC_HOST_CALL jsArrayBufferPrototypeFunctionSlice(ExecState* exec) diff --git a/JavaScriptCore/runtime/TypedArrays/JSArrayBufferView.cpp b/JavaScriptCore/runtime/TypedArrays/JSArrayBufferView.cpp index 45ba6666..0dd663aa 100644 --- a/JavaScriptCore/runtime/TypedArrays/JSArrayBufferView.cpp +++ b/JavaScriptCore/runtime/TypedArrays/JSArrayBufferView.cpp @@ -27,6 +27,8 @@ #include #include +#include "GlobalDataHelper.h" + using namespace JSC; namespace WebCore { @@ -60,23 +62,14 @@ static const HashTable* getJSArrayBufferViewPrototypeTable(ExecState* exec) const ClassInfo JSArrayBufferViewPrototype::s_info = { "ArrayBufferViewPrototype", &Base::s_info, 0, getJSArrayBufferViewPrototypeTable, CREATE_METHOD_TABLE(JSArrayBufferViewPrototype) }; -static JSObject * globalProto = NULL; JSObject* JSArrayBufferViewPrototype::self(ExecState* exec, JSGlobalObject* globalObject) { - // PL FIXME: dirty hack to provide one global prototype - if( !globalProto ) { - JSGlobalData &data = exec->globalData(); - globalProto = JSArrayBufferViewPrototype::create(data, globalObject, - JSArrayBufferViewPrototype::createStructure(data, globalObject, - globalObject->objectPrototype())); - } - return globalProto; + return getDOMPrototype(exec, globalObject); } static const HashTable* getJSArrayBufferViewTable(ExecState* exec) { - ASSERT_UNUSED(exec, exec); - return &JSArrayBufferViewTable; + return getHashTableForGlobalData(exec->globalData(), &JSArrayBufferViewTable); } const ClassInfo JSArrayBufferView::s_info = { "ArrayBufferView", &Base::s_info, 0, getJSArrayBufferViewTable , CREATE_METHOD_TABLE(JSArrayBufferView) }; diff --git a/JavaScriptCore/runtime/TypedArrays/JSFloat32Array.cpp b/JavaScriptCore/runtime/TypedArrays/JSFloat32Array.cpp index ace53168..00f1422b 100644 --- a/JavaScriptCore/runtime/TypedArrays/JSFloat32Array.cpp +++ b/JavaScriptCore/runtime/TypedArrays/JSFloat32Array.cpp @@ -21,8 +21,9 @@ #include "config.h" #include "JSFloat32Array.h" -#include "ExceptionCode.h" -#include "JSDOMBinding.h" +#include "Lookup.h" +#include "GlobalDataHelper.h" + #include "JSFloat32Array.h" #include #include @@ -55,14 +56,15 @@ static const HashTableValue JSFloat32ArrayConstructorTableValues[] = static const HashTable JSFloat32ArrayConstructorTable = { 2, 1, JSFloat32ArrayConstructorTableValues, 0 }; const ClassInfo JSFloat32ArrayConstructor::s_info = { "Float32ArrayConstructor", &Base::s_info, &JSFloat32ArrayConstructorTable, 0, CREATE_METHOD_TABLE(JSFloat32ArrayConstructor) }; -JSFloat32ArrayConstructor::JSFloat32ArrayConstructor(Structure* structure, JSDOMGlobalObject* globalObject) - : DOMConstructorObject(structure, globalObject) +JSFloat32ArrayConstructor::JSFloat32ArrayConstructor(Structure* structure, JSGlobalObject* globalObject) + : InternalFunction(globalObject, structure) { } -void JSFloat32ArrayConstructor::finishCreation(ExecState* exec, JSDOMGlobalObject* globalObject) +void JSFloat32ArrayConstructor::finishCreation(ExecState* exec, JSGlobalObject* globalObject) { - Base::finishCreation(exec->globalData()); + JSC::JSObject * proto = JSFloat32ArrayPrototype::self(exec, globalObject); + Base::finishCreation(exec->globalData(), Identifier(exec, proto->classInfo()->className)); ASSERT(inherits(&s_info)); putDirect(exec->globalData(), exec->propertyNames().prototype, JSFloat32ArrayPrototype::self(exec, globalObject), DontDelete | ReadOnly); putDirect(exec->globalData(), exec->propertyNames().length, jsNumber(1), ReadOnly | DontDelete | DontEnum); @@ -70,12 +72,12 @@ void JSFloat32ArrayConstructor::finishCreation(ExecState* exec, JSDOMGlobalObjec bool JSFloat32ArrayConstructor::getOwnPropertySlot(JSCell* cell, ExecState* exec, const Identifier& propertyName, PropertySlot& slot) { - return getStaticValueSlot(exec, &JSFloat32ArrayConstructorTable, jsCast(cell), propertyName, slot); + return getStaticFunctionSlot(exec, &JSFloat32ArrayConstructorTable, jsCast(cell), propertyName, slot); } bool JSFloat32ArrayConstructor::getOwnPropertyDescriptor(JSObject* object, ExecState* exec, const Identifier& propertyName, PropertyDescriptor& descriptor) { - return getStaticValueDescriptor(exec, &JSFloat32ArrayConstructorTable, jsCast(object), propertyName, descriptor); + return getStaticFunctionDescriptor(exec, &JSFloat32ArrayConstructorTable, jsCast(object), propertyName, descriptor); } ConstructType JSFloat32ArrayConstructor::getConstructData(JSCell*, ConstructData& constructData) @@ -104,7 +106,7 @@ const ClassInfo JSFloat32ArrayPrototype::s_info = { "Float32ArrayPrototype", &Ba JSObject* JSFloat32ArrayPrototype::self(ExecState* exec, JSGlobalObject* globalObject) { - return getDOMPrototype(exec, globalObject); + return getDOMPrototype(exec, globalObject); } bool JSFloat32ArrayPrototype::getOwnPropertySlot(JSCell* cell, ExecState* exec, const Identifier& propertyName, PropertySlot& slot) @@ -126,7 +128,7 @@ static const HashTable* getJSFloat32ArrayTable(ExecState* exec) const ClassInfo JSFloat32Array::s_info = { "Float32Array", &Base::s_info, 0, getJSFloat32ArrayTable , CREATE_METHOD_TABLE(JSFloat32Array) }; -JSFloat32Array::JSFloat32Array(Structure* structure, JSDOMGlobalObject* globalObject, PassRefPtr impl) +JSFloat32Array::JSFloat32Array(Structure* structure, JSGlobalObject* globalObject, PassRefPtr impl) : JSArrayBufferView(structure, globalObject, impl) { } @@ -231,7 +233,7 @@ void JSFloat32Array::getOwnPropertyNames(JSObject* object, ExecState* exec, Prop JSValue JSFloat32Array::getConstructor(ExecState* exec, JSGlobalObject* globalObject) { - return getDOMConstructor(exec, jsCast(globalObject)); + return getDOMConstructor(exec, jsCast(globalObject)); } EncodedJSValue JSC_HOST_CALL jsFloat32ArrayPrototypeFunctionSubarray(ExecState* exec) diff --git a/JavaScriptCore/runtime/TypedArrays/JSFloat32Array.h b/JavaScriptCore/runtime/TypedArrays/JSFloat32Array.h index eb734c60..eac460f6 100644 --- a/JavaScriptCore/runtime/TypedArrays/JSFloat32Array.h +++ b/JavaScriptCore/runtime/TypedArrays/JSFloat32Array.h @@ -22,7 +22,7 @@ #define JSFloat32Array_h #include "JSArrayBufferView.h" -#include "JSDOMBinding.h" +#include "InternalFunction.h" #include #include @@ -31,7 +31,7 @@ namespace WebCore { class JSFloat32Array : public JSArrayBufferView { public: typedef JSArrayBufferView Base; - static JSFloat32Array* create(JSC::Structure* structure, JSDOMGlobalObject* globalObject, PassRefPtr impl) + static JSFloat32Array* create(JSC::Structure* structure, JSC::JSGlobalObject* globalObject, PassRefPtr impl) { JSFloat32Array* ptr = new (NotNull, JSC::allocateCell(globalObject->globalData().heap)) JSFloat32Array(structure, globalObject, impl); ptr->finishCreation(globalObject->globalData()); @@ -64,14 +64,14 @@ class JSFloat32Array : public JSArrayBufferView { intptr_t m_storageLength; void* m_storage; protected: - JSFloat32Array(JSC::Structure*, JSDOMGlobalObject*, PassRefPtr); + JSFloat32Array(JSC::Structure*, JSC::JSGlobalObject*, PassRefPtr); void finishCreation(JSC::JSGlobalData&); static const unsigned StructureFlags = JSC::OverridesGetPropertyNames | JSC::OverridesGetOwnPropertySlot | Base::StructureFlags; JSC::JSValue getByIndex(JSC::ExecState*, unsigned index); void indexSetter(JSC::ExecState*, unsigned index, JSC::JSValue); }; -JSC::JSValue toJS(JSC::ExecState*, JSDOMGlobalObject*, Float32Array*); +JSC::JSValue toJS(JSC::ExecState*, JSC::JSGlobalObject*, Float32Array*); Float32Array* toFloat32Array(JSC::JSValue); class JSFloat32ArrayPrototype : public JSC::JSNonFinalObject { @@ -99,14 +99,14 @@ class JSFloat32ArrayPrototype : public JSC::JSNonFinalObject { static const unsigned StructureFlags = JSC::OverridesGetOwnPropertySlot | Base::StructureFlags; }; -class JSFloat32ArrayConstructor : public DOMConstructorObject { +class JSFloat32ArrayConstructor : public JSC::InternalFunction { private: - JSFloat32ArrayConstructor(JSC::Structure*, JSDOMGlobalObject*); - void finishCreation(JSC::ExecState*, JSDOMGlobalObject*); + JSFloat32ArrayConstructor(JSC::Structure*, JSC::JSGlobalObject*); + void finishCreation(JSC::ExecState*, JSC::JSGlobalObject*); public: - typedef DOMConstructorObject Base; - static JSFloat32ArrayConstructor* create(JSC::ExecState* exec, JSC::Structure* structure, JSDOMGlobalObject* globalObject) + typedef JSC::InternalFunction Base; + static JSFloat32ArrayConstructor* create(JSC::ExecState* exec, JSC::Structure* structure, JSC::JSGlobalObject* globalObject) { JSFloat32ArrayConstructor* ptr = new (NotNull, JSC::allocateCell(*exec->heap())) JSFloat32ArrayConstructor(structure, globalObject); ptr->finishCreation(exec, globalObject); @@ -121,7 +121,7 @@ class JSFloat32ArrayConstructor : public DOMConstructorObject { return JSC::Structure::create(globalData, globalObject, prototype, JSC::TypeInfo(JSC::ObjectType, StructureFlags), &s_info); } protected: - static const unsigned StructureFlags = JSC::OverridesGetOwnPropertySlot | JSC::ImplementsHasInstance | DOMConstructorObject::StructureFlags; + static const unsigned StructureFlags = JSC::OverridesGetOwnPropertySlot | JSC::ImplementsHasInstance | InternalFunction::StructureFlags; static JSC::EncodedJSValue JSC_HOST_CALL constructJSFloat32Array(JSC::ExecState*); static JSC::ConstructType getConstructData(JSC::JSCell*, JSC::ConstructData&); }; From 8bc3be012887d8e071fcd2f07d92e8a7ae197754 Mon Sep 17 00:00:00 2001 From: Dominic Szablewski Date: Sat, 8 Dec 2012 15:47:54 +0100 Subject: [PATCH 06/30] Added JSFloat32ArrayCustom.cpp - not sure if we need this --- .../JavaScriptCore.xcodeproj/project.pbxproj | 6 ++ .../TypedArrays/JSArrayBufferViewHelper.h | 25 ++++---- .../TypedArrays/JSFloat32ArrayCustom.cpp | 61 +++++++++++++++++++ 3 files changed, 78 insertions(+), 14 deletions(-) create mode 100644 JavaScriptCore/runtime/TypedArrays/JSFloat32ArrayCustom.cpp diff --git a/JavaScriptCore/JavaScriptCore.xcodeproj/project.pbxproj b/JavaScriptCore/JavaScriptCore.xcodeproj/project.pbxproj index a6500b95..dae5a4e0 100644 --- a/JavaScriptCore/JavaScriptCore.xcodeproj/project.pbxproj +++ b/JavaScriptCore/JavaScriptCore.xcodeproj/project.pbxproj @@ -555,6 +555,8 @@ B6D188731672DFE800D1037C /* JSFloat32Array.h in Headers */ = {isa = PBXBuildFile; fileRef = B6D1886F1672DFE700D1037C /* JSFloat32Array.h */; }; B6D1888B1673751400D1037C /* GlobalDataHelper.h in Headers */ = {isa = PBXBuildFile; fileRef = B6D188881673751400D1037C /* GlobalDataHelper.h */; }; B6D1888C1673751400D1037C /* GlobalDataHelper.h in Headers */ = {isa = PBXBuildFile; fileRef = B6D188881673751400D1037C /* GlobalDataHelper.h */; }; + B6D1888E167381A400D1037C /* JSFloat32ArrayCustom.cpp in Sources */ = {isa = PBXBuildFile; fileRef = B6D1888D167381A300D1037C /* JSFloat32ArrayCustom.cpp */; }; + B6D1888F167381A400D1037C /* JSFloat32ArrayCustom.cpp in Sources */ = {isa = PBXBuildFile; fileRef = B6D1888D167381A300D1037C /* JSFloat32ArrayCustom.cpp */; }; B6E69991166BD63D005EF4B1 /* AbstractMacroAssembler.h in Headers */ = {isa = PBXBuildFile; fileRef = 860161DF0F3A83C100F84710 /* AbstractMacroAssembler.h */; }; B6E69992166BD63D005EF4B1 /* APICast.h in Headers */ = {isa = PBXBuildFile; fileRef = 1482B78A0A4305AB00517CFC /* APICast.h */; settings = {ATTRIBUTES = (Private, ); }; }; B6E69993166BD63D005EF4B1 /* APIShims.h in Headers */ = {isa = PBXBuildFile; fileRef = 865F408710E7D56300947361 /* APIShims.h */; settings = {ATTRIBUTES = (Private, ); }; }; @@ -1831,6 +1833,7 @@ B6D1886E1672DFE700D1037C /* JSFloat32Array.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = JSFloat32Array.cpp; sourceTree = ""; }; B6D1886F1672DFE700D1037C /* JSFloat32Array.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = JSFloat32Array.h; sourceTree = ""; }; B6D188881673751400D1037C /* GlobalDataHelper.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = GlobalDataHelper.h; sourceTree = ""; }; + B6D1888D167381A300D1037C /* JSFloat32ArrayCustom.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = JSFloat32ArrayCustom.cpp; sourceTree = ""; }; B6E69BC4166BD63D005EF4B1 /* libJavaScriptCore.a */ = {isa = PBXFileReference; explicitFileType = archive.ar; includeInIndex = 0; path = libJavaScriptCore.a; sourceTree = BUILT_PRODUCTS_DIR; }; B6E69BDB166BD6C1005EF4B1 /* libJSCLLIntOffsetsExtractor.a */ = {isa = PBXFileReference; explicitFileType = archive.ar; includeInIndex = 0; path = libJSCLLIntOffsetsExtractor.a; sourceTree = BUILT_PRODUCTS_DIR; }; B6E69BFD166BDCE7005EF4B1 /* libWTF.a */ = {isa = PBXFileReference; lastKnownFileType = archive.ar; name = libWTF.a; path = ../Build/libWTF.a; sourceTree = ""; }; @@ -2886,6 +2889,7 @@ B6D18817166FA73400D1037C /* JSArrayBufferView.cpp */, B6D18818166FA73400D1037C /* JSArrayBufferView.h */, B6D18819166FA73400D1037C /* JSArrayBufferViewHelper.h */, + B6D1888D167381A300D1037C /* JSFloat32ArrayCustom.cpp */, B6D1886E1672DFE700D1037C /* JSFloat32Array.cpp */, B6D1886F1672DFE700D1037C /* JSFloat32Array.h */, B6D188881673751400D1037C /* GlobalDataHelper.h */, @@ -4354,6 +4358,7 @@ B6D18830166FA73400D1037C /* JSArrayBufferCustom.cpp in Sources */, B6D18832166FA73400D1037C /* JSArrayBufferView.cpp in Sources */, B6D188701672DFE800D1037C /* JSFloat32Array.cpp in Sources */, + B6D1888E167381A400D1037C /* JSFloat32ArrayCustom.cpp in Sources */, ); runOnlyForDeploymentPostprocessing = 0; }; @@ -4582,6 +4587,7 @@ B6D18831166FA73400D1037C /* JSArrayBufferCustom.cpp in Sources */, B6D18833166FA73400D1037C /* JSArrayBufferView.cpp in Sources */, B6D188711672DFE800D1037C /* JSFloat32Array.cpp in Sources */, + B6D1888F167381A400D1037C /* JSFloat32ArrayCustom.cpp in Sources */, ); runOnlyForDeploymentPostprocessing = 0; }; diff --git a/JavaScriptCore/runtime/TypedArrays/JSArrayBufferViewHelper.h b/JavaScriptCore/runtime/TypedArrays/JSArrayBufferViewHelper.h index b9e84bc2..ec87abe6 100644 --- a/JavaScriptCore/runtime/TypedArrays/JSArrayBufferViewHelper.h +++ b/JavaScriptCore/runtime/TypedArrays/JSArrayBufferViewHelper.h @@ -27,9 +27,7 @@ #ifndef JSArrayBufferViewHelper_h #define JSArrayBufferViewHelper_h -#include "ExceptionCode.h" #include "JSArrayBuffer.h" -#include "JSDOMBinding.h" #include #include #include @@ -37,7 +35,7 @@ #include #include -namespace JSC { +namespace WebCore { template JSC::JSValue setWebGLArrayHelper(JSC::ExecState* exec, T* impl, T* (*conversionFunc)(JSC::JSValue)) @@ -52,7 +50,7 @@ JSC::JSValue setWebGLArrayHelper(JSC::ExecState* exec, T* impl, T* (*conversionF if (exec->argumentCount() == 2) offset = exec->argument(1).toInt32(exec); if (!impl->set(array, offset)) - setDOMException(exec, INDEX_SIZE_ERR); + throwTypeError(exec); return JSC::jsUndefined(); } @@ -67,7 +65,7 @@ JSC::JSValue setWebGLArrayHelper(JSC::ExecState* exec, T* impl, T* (*conversionF if (offset > impl->length() || offset + length > impl->length() || offset + length < offset) - setDOMException(exec, INDEX_SIZE_ERR); + throwTypeError(exec); else { for (uint32_t i = 0; i < length; i++) { JSC::JSValue v = array->get(exec, i); @@ -105,7 +103,7 @@ PassRefPtr constructArrayBufferViewWithArrayBufferArgument(JSC::ExecState* ex } RefPtr array = C::create(buffer, offset, length); if (!array) - setDOMException(exec, INDEX_SIZE_ERR); + throwTypeError(exec); return array; } @@ -142,7 +140,7 @@ PassRefPtr constructArrayBufferView(JSC::ExecState* exec) uint32_t length = srcArray->get(exec, JSC::Identifier(exec, "length")).toUInt32(exec); RefPtr array = C::create(length); if (!array) { - setDOMException(exec, INDEX_SIZE_ERR); + throwTypeError(exec); return array; } @@ -163,16 +161,15 @@ PassRefPtr constructArrayBufferView(JSC::ExecState* exec) } template -static JSC::JSValue toJSArrayBufferView(JSC::ExecState* exec, JSDOMGlobalObject* globalObject, WebCoreType* object) +static JSC::JSValue toJSArrayBufferView(JSC::ExecState* exec, JSC::JSGlobalObject* globalObject, WebCoreType* object) { + ASSERT_UNUSED(globalObject, globalObject); if (!object) return JSC::jsNull(); - - if (JSDOMWrapper* wrapper = getCachedWrapper(currentWorld(exec), object)) - return wrapper; - - exec->heap()->reportExtraMemoryCost(object->byteLength()); - return createWrapper(exec, globalObject, object); + + exec->heap()->reportExtraMemoryCost(object->byteLength()); + JSC::JSCell* jsCell = reinterpret_cast(object); + return jsCell; } } // namespace WebCore diff --git a/JavaScriptCore/runtime/TypedArrays/JSFloat32ArrayCustom.cpp b/JavaScriptCore/runtime/TypedArrays/JSFloat32ArrayCustom.cpp new file mode 100644 index 00000000..84188fb9 --- /dev/null +++ b/JavaScriptCore/runtime/TypedArrays/JSFloat32ArrayCustom.cpp @@ -0,0 +1,61 @@ +/* + * Copyright (C) 2009 Apple Inc. All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY APPLE COMPUTER, INC. ``AS IS'' AND ANY + * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR + * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE COMPUTER, INC. OR + * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, + * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, + * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR + * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY + * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE + * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + */ + +#include "config.h" +#include "JSFloat32Array.h" + +#include "JSArrayBufferViewHelper.h" +#include + +using namespace JSC; + +namespace WebCore { + +void JSFloat32Array::indexSetter(JSC::ExecState* exec, unsigned index, JSC::JSValue value) +{ + impl()->set(index, static_cast(value.toNumber(exec))); +} + +JSC::JSValue toJS(JSC::ExecState* exec, JSGlobalObject* globalObject, Float32Array* object) +{ + return toJSArrayBufferView(exec, globalObject, object); +} + +JSC::JSValue JSFloat32Array::set(JSC::ExecState* exec) +{ + return setWebGLArrayHelper(exec, impl(), toFloat32Array); +} + +EncodedJSValue JSC_HOST_CALL JSFloat32ArrayConstructor::constructJSFloat32Array(ExecState* exec) +{ + JSFloat32ArrayConstructor* jsConstructor = jsCast(exec->callee()); + RefPtr array = constructArrayBufferView(exec); + if (!array.get()) + // Exception has already been thrown. + return JSValue::encode(JSValue()); + return JSValue::encode(asObject(toJS(exec, jsConstructor->globalObject(), array.get()))); +} + +} // namespace WebCore From 4cc58ec88a4eb65b0e3cbbd41fbd0db68d88be3a Mon Sep 17 00:00:00 2001 From: Dominic Szablewski Date: Sat, 8 Dec 2012 15:48:20 +0100 Subject: [PATCH 07/30] Added Float32Array to GlobalObject --- JavaScriptCore/runtime/JSGlobalObject.cpp | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/JavaScriptCore/runtime/JSGlobalObject.cpp b/JavaScriptCore/runtime/JSGlobalObject.cpp index 4e273153..33143790 100644 --- a/JavaScriptCore/runtime/JSGlobalObject.cpp +++ b/JavaScriptCore/runtime/JSGlobalObject.cpp @@ -72,6 +72,10 @@ #include "StringPrototype.h" #include "Debugger.h" +// PL Typed Arrays + +#include "JSFloat32Array.h" + #include "JSGlobalObject.lut.h" namespace JSC { @@ -290,6 +294,12 @@ void JSGlobalObject::reset(JSValue prototype) putDirectWithoutTransition(exec->globalData(), Identifier(exec, "SyntaxError"), m_syntaxErrorConstructor.get(), DontEnum); putDirectWithoutTransition(exec->globalData(), Identifier(exec, "TypeError"), m_typeErrorConstructor.get(), DontEnum); putDirectWithoutTransition(exec->globalData(), Identifier(exec, "URIError"), m_URIErrorConstructor.get(), DontEnum); + + + // PL Typed Arrays + putDirectWithoutTransition(exec->globalData(), Identifier(exec, WebCore::JSFloat32Array::s_info.className), + WebCore::JSFloat32Array::getConstructor(exec, this), DontEnum); + m_evalFunction.set(exec->globalData(), this, JSFunction::create(exec, this, 1, exec->propertyNames().eval, globalFuncEval)); putDirectWithoutTransition(exec->globalData(), exec->propertyNames().eval, m_evalFunction.get(), DontEnum); From 2d38652698b872d296237c2266919bfa329f13c8 Mon Sep 17 00:00:00 2001 From: Dominic Szablewski Date: Sat, 8 Dec 2012 18:30:51 +0100 Subject: [PATCH 08/30] Fixed toJSArrayBufferView to return properly constructed JSObject --- JavaScriptCore/JavaScriptCore.xcodeproj/project.pbxproj | 2 +- JavaScriptCore/runtime/TypedArrays/JSArrayBufferViewHelper.h | 3 +-- 2 files changed, 2 insertions(+), 3 deletions(-) diff --git a/JavaScriptCore/JavaScriptCore.xcodeproj/project.pbxproj b/JavaScriptCore/JavaScriptCore.xcodeproj/project.pbxproj index dae5a4e0..874d8205 100644 --- a/JavaScriptCore/JavaScriptCore.xcodeproj/project.pbxproj +++ b/JavaScriptCore/JavaScriptCore.xcodeproj/project.pbxproj @@ -2883,6 +2883,7 @@ B6D18813166FA73300D1037C /* TypedArrays */ = { isa = PBXGroup; children = ( + B6D188881673751400D1037C /* GlobalDataHelper.h */, B6D18814166FA73400D1037C /* JSArrayBuffer.cpp */, B6D18815166FA73400D1037C /* JSArrayBuffer.h */, B6D18816166FA73400D1037C /* JSArrayBufferCustom.cpp */, @@ -2892,7 +2893,6 @@ B6D1888D167381A300D1037C /* JSFloat32ArrayCustom.cpp */, B6D1886E1672DFE700D1037C /* JSFloat32Array.cpp */, B6D1886F1672DFE700D1037C /* JSFloat32Array.h */, - B6D188881673751400D1037C /* GlobalDataHelper.h */, ); path = TypedArrays; sourceTree = ""; diff --git a/JavaScriptCore/runtime/TypedArrays/JSArrayBufferViewHelper.h b/JavaScriptCore/runtime/TypedArrays/JSArrayBufferViewHelper.h index ec87abe6..a46f90ba 100644 --- a/JavaScriptCore/runtime/TypedArrays/JSArrayBufferViewHelper.h +++ b/JavaScriptCore/runtime/TypedArrays/JSArrayBufferViewHelper.h @@ -163,12 +163,11 @@ PassRefPtr constructArrayBufferView(JSC::ExecState* exec) template static JSC::JSValue toJSArrayBufferView(JSC::ExecState* exec, JSC::JSGlobalObject* globalObject, WebCoreType* object) { - ASSERT_UNUSED(globalObject, globalObject); if (!object) return JSC::jsNull(); exec->heap()->reportExtraMemoryCost(object->byteLength()); - JSC::JSCell* jsCell = reinterpret_cast(object); + JSC::JSCell * jsCell = JSType::create(JSType::createStructure(exec->globalData(), globalObject,JSType::createPrototype(exec, globalObject)), globalObject, object); return jsCell; } From 1ab0a5720420f70d0b19596aef93f6fe4618c97f Mon Sep 17 00:00:00 2001 From: Dominic Szablewski Date: Sat, 8 Dec 2012 18:32:53 +0100 Subject: [PATCH 09/30] Added all other Typed Array types --- .../JavaScriptCore.xcodeproj/project.pbxproj | 144 +++++++++ .../runtime/TypedArrays/JSFloat64Array.cpp | 297 ++++++++++++++++++ .../runtime/TypedArrays/JSFloat64Array.h | 143 +++++++++ .../TypedArrays/JSFloat64ArrayCustom.cpp | 61 ++++ .../runtime/TypedArrays/JSInt16Array.cpp | 297 ++++++++++++++++++ .../runtime/TypedArrays/JSInt16Array.h | 143 +++++++++ .../TypedArrays/JSInt16ArrayCustom.cpp | 61 ++++ .../runtime/TypedArrays/JSInt32Array.cpp | 297 ++++++++++++++++++ .../runtime/TypedArrays/JSInt32Array.h | 143 +++++++++ .../TypedArrays/JSInt32ArrayCustom.cpp | 61 ++++ .../runtime/TypedArrays/JSInt8Array.cpp | 297 ++++++++++++++++++ .../runtime/TypedArrays/JSInt8Array.h | 143 +++++++++ .../runtime/TypedArrays/JSInt8ArrayCustom.cpp | 62 ++++ .../runtime/TypedArrays/JSUint16Array.cpp | 297 ++++++++++++++++++ .../runtime/TypedArrays/JSUint16Array.h | 143 +++++++++ .../TypedArrays/JSUint16ArrayCustom.cpp | 61 ++++ .../runtime/TypedArrays/JSUint32Array.cpp | 297 ++++++++++++++++++ .../runtime/TypedArrays/JSUint32Array.h | 143 +++++++++ .../TypedArrays/JSUint32ArrayCustom.cpp | 61 ++++ .../runtime/TypedArrays/JSUint8Array.cpp | 297 ++++++++++++++++++ .../runtime/TypedArrays/JSUint8Array.h | 143 +++++++++ .../TypedArrays/JSUint8ArrayCustom.cpp | 61 ++++ .../TypedArrays/JSUint8ClampedArray.cpp | 297 ++++++++++++++++++ .../runtime/TypedArrays/JSUint8ClampedArray.h | 143 +++++++++ .../TypedArrays/JSUint8ClampedArrayCustom.cpp | 61 ++++ 25 files changed, 4153 insertions(+) create mode 100644 JavaScriptCore/runtime/TypedArrays/JSFloat64Array.cpp create mode 100644 JavaScriptCore/runtime/TypedArrays/JSFloat64Array.h create mode 100644 JavaScriptCore/runtime/TypedArrays/JSFloat64ArrayCustom.cpp create mode 100644 JavaScriptCore/runtime/TypedArrays/JSInt16Array.cpp create mode 100644 JavaScriptCore/runtime/TypedArrays/JSInt16Array.h create mode 100644 JavaScriptCore/runtime/TypedArrays/JSInt16ArrayCustom.cpp create mode 100644 JavaScriptCore/runtime/TypedArrays/JSInt32Array.cpp create mode 100644 JavaScriptCore/runtime/TypedArrays/JSInt32Array.h create mode 100644 JavaScriptCore/runtime/TypedArrays/JSInt32ArrayCustom.cpp create mode 100644 JavaScriptCore/runtime/TypedArrays/JSInt8Array.cpp create mode 100644 JavaScriptCore/runtime/TypedArrays/JSInt8Array.h create mode 100644 JavaScriptCore/runtime/TypedArrays/JSInt8ArrayCustom.cpp create mode 100644 JavaScriptCore/runtime/TypedArrays/JSUint16Array.cpp create mode 100644 JavaScriptCore/runtime/TypedArrays/JSUint16Array.h create mode 100644 JavaScriptCore/runtime/TypedArrays/JSUint16ArrayCustom.cpp create mode 100644 JavaScriptCore/runtime/TypedArrays/JSUint32Array.cpp create mode 100644 JavaScriptCore/runtime/TypedArrays/JSUint32Array.h create mode 100644 JavaScriptCore/runtime/TypedArrays/JSUint32ArrayCustom.cpp create mode 100644 JavaScriptCore/runtime/TypedArrays/JSUint8Array.cpp create mode 100644 JavaScriptCore/runtime/TypedArrays/JSUint8Array.h create mode 100644 JavaScriptCore/runtime/TypedArrays/JSUint8ArrayCustom.cpp create mode 100644 JavaScriptCore/runtime/TypedArrays/JSUint8ClampedArray.cpp create mode 100644 JavaScriptCore/runtime/TypedArrays/JSUint8ClampedArray.h create mode 100644 JavaScriptCore/runtime/TypedArrays/JSUint8ClampedArrayCustom.cpp diff --git a/JavaScriptCore/JavaScriptCore.xcodeproj/project.pbxproj b/JavaScriptCore/JavaScriptCore.xcodeproj/project.pbxproj index 874d8205..2d0f6601 100644 --- a/JavaScriptCore/JavaScriptCore.xcodeproj/project.pbxproj +++ b/JavaScriptCore/JavaScriptCore.xcodeproj/project.pbxproj @@ -1110,6 +1110,54 @@ B6E69BB9166BD63D005EF4B1 /* libobjc.dylib in Frameworks */ = {isa = PBXBuildFile; fileRef = 51F0EC0705C86C9A00E6DF1B /* libobjc.dylib */; }; B6E69BD4166BD6C1005EF4B1 /* LLIntOffsetsExtractor.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 0F4680A114BA7F8200BFE272 /* LLIntOffsetsExtractor.cpp */; }; B6E69BFE166BDCE7005EF4B1 /* libWTF.a in Frameworks */ = {isa = PBXBuildFile; fileRef = B6E69BFD166BDCE7005EF4B1 /* libWTF.a */; }; + B6F114931673B116001F1324 /* JSFloat64Array.cpp in Sources */ = {isa = PBXBuildFile; fileRef = B6F1147B1673B115001F1324 /* JSFloat64Array.cpp */; }; + B6F114941673B116001F1324 /* JSFloat64Array.cpp in Sources */ = {isa = PBXBuildFile; fileRef = B6F1147B1673B115001F1324 /* JSFloat64Array.cpp */; }; + B6F114951673B116001F1324 /* JSFloat64Array.h in Headers */ = {isa = PBXBuildFile; fileRef = B6F1147C1673B115001F1324 /* JSFloat64Array.h */; }; + B6F114961673B116001F1324 /* JSFloat64Array.h in Headers */ = {isa = PBXBuildFile; fileRef = B6F1147C1673B115001F1324 /* JSFloat64Array.h */; }; + B6F114971673B116001F1324 /* JSFloat64ArrayCustom.cpp in Sources */ = {isa = PBXBuildFile; fileRef = B6F1147D1673B115001F1324 /* JSFloat64ArrayCustom.cpp */; }; + B6F114981673B116001F1324 /* JSFloat64ArrayCustom.cpp in Sources */ = {isa = PBXBuildFile; fileRef = B6F1147D1673B115001F1324 /* JSFloat64ArrayCustom.cpp */; }; + B6F114991673B116001F1324 /* JSInt8Array.cpp in Sources */ = {isa = PBXBuildFile; fileRef = B6F1147E1673B115001F1324 /* JSInt8Array.cpp */; }; + B6F1149A1673B116001F1324 /* JSInt8Array.cpp in Sources */ = {isa = PBXBuildFile; fileRef = B6F1147E1673B115001F1324 /* JSInt8Array.cpp */; }; + B6F1149B1673B116001F1324 /* JSInt8Array.h in Headers */ = {isa = PBXBuildFile; fileRef = B6F1147F1673B115001F1324 /* JSInt8Array.h */; }; + B6F1149C1673B116001F1324 /* JSInt8Array.h in Headers */ = {isa = PBXBuildFile; fileRef = B6F1147F1673B115001F1324 /* JSInt8Array.h */; }; + B6F1149D1673B116001F1324 /* JSInt8ArrayCustom.cpp in Sources */ = {isa = PBXBuildFile; fileRef = B6F114801673B115001F1324 /* JSInt8ArrayCustom.cpp */; }; + B6F1149E1673B116001F1324 /* JSInt8ArrayCustom.cpp in Sources */ = {isa = PBXBuildFile; fileRef = B6F114801673B115001F1324 /* JSInt8ArrayCustom.cpp */; }; + B6F1149F1673B116001F1324 /* JSInt16Array.cpp in Sources */ = {isa = PBXBuildFile; fileRef = B6F114811673B115001F1324 /* JSInt16Array.cpp */; }; + B6F114A01673B116001F1324 /* JSInt16Array.cpp in Sources */ = {isa = PBXBuildFile; fileRef = B6F114811673B115001F1324 /* JSInt16Array.cpp */; }; + B6F114A11673B116001F1324 /* JSInt16Array.h in Headers */ = {isa = PBXBuildFile; fileRef = B6F114821673B115001F1324 /* JSInt16Array.h */; }; + B6F114A21673B116001F1324 /* JSInt16Array.h in Headers */ = {isa = PBXBuildFile; fileRef = B6F114821673B115001F1324 /* JSInt16Array.h */; }; + B6F114A31673B116001F1324 /* JSInt16ArrayCustom.cpp in Sources */ = {isa = PBXBuildFile; fileRef = B6F114831673B115001F1324 /* JSInt16ArrayCustom.cpp */; }; + B6F114A41673B116001F1324 /* JSInt16ArrayCustom.cpp in Sources */ = {isa = PBXBuildFile; fileRef = B6F114831673B115001F1324 /* JSInt16ArrayCustom.cpp */; }; + B6F114A51673B116001F1324 /* JSInt32Array.cpp in Sources */ = {isa = PBXBuildFile; fileRef = B6F114841673B115001F1324 /* JSInt32Array.cpp */; }; + B6F114A61673B116001F1324 /* JSInt32Array.cpp in Sources */ = {isa = PBXBuildFile; fileRef = B6F114841673B115001F1324 /* JSInt32Array.cpp */; }; + B6F114A71673B116001F1324 /* JSInt32Array.h in Headers */ = {isa = PBXBuildFile; fileRef = B6F114851673B115001F1324 /* JSInt32Array.h */; }; + B6F114A81673B116001F1324 /* JSInt32Array.h in Headers */ = {isa = PBXBuildFile; fileRef = B6F114851673B115001F1324 /* JSInt32Array.h */; }; + B6F114A91673B116001F1324 /* JSInt32ArrayCustom.cpp in Sources */ = {isa = PBXBuildFile; fileRef = B6F114861673B115001F1324 /* JSInt32ArrayCustom.cpp */; }; + B6F114AA1673B116001F1324 /* JSInt32ArrayCustom.cpp in Sources */ = {isa = PBXBuildFile; fileRef = B6F114861673B115001F1324 /* JSInt32ArrayCustom.cpp */; }; + B6F114AB1673B116001F1324 /* JSUint8Array.cpp in Sources */ = {isa = PBXBuildFile; fileRef = B6F114871673B115001F1324 /* JSUint8Array.cpp */; }; + B6F114AC1673B116001F1324 /* JSUint8Array.cpp in Sources */ = {isa = PBXBuildFile; fileRef = B6F114871673B115001F1324 /* JSUint8Array.cpp */; }; + B6F114AD1673B116001F1324 /* JSUint8Array.h in Headers */ = {isa = PBXBuildFile; fileRef = B6F114881673B115001F1324 /* JSUint8Array.h */; }; + B6F114AE1673B116001F1324 /* JSUint8Array.h in Headers */ = {isa = PBXBuildFile; fileRef = B6F114881673B115001F1324 /* JSUint8Array.h */; }; + B6F114AF1673B116001F1324 /* JSUint8ArrayCustom.cpp in Sources */ = {isa = PBXBuildFile; fileRef = B6F114891673B115001F1324 /* JSUint8ArrayCustom.cpp */; }; + B6F114B01673B116001F1324 /* JSUint8ArrayCustom.cpp in Sources */ = {isa = PBXBuildFile; fileRef = B6F114891673B115001F1324 /* JSUint8ArrayCustom.cpp */; }; + B6F114B11673B116001F1324 /* JSUint8ClampedArray.cpp in Sources */ = {isa = PBXBuildFile; fileRef = B6F1148A1673B115001F1324 /* JSUint8ClampedArray.cpp */; }; + B6F114B21673B116001F1324 /* JSUint8ClampedArray.cpp in Sources */ = {isa = PBXBuildFile; fileRef = B6F1148A1673B115001F1324 /* JSUint8ClampedArray.cpp */; }; + B6F114B31673B116001F1324 /* JSUint8ClampedArray.h in Headers */ = {isa = PBXBuildFile; fileRef = B6F1148B1673B115001F1324 /* JSUint8ClampedArray.h */; }; + B6F114B41673B116001F1324 /* JSUint8ClampedArray.h in Headers */ = {isa = PBXBuildFile; fileRef = B6F1148B1673B115001F1324 /* JSUint8ClampedArray.h */; }; + B6F114B51673B116001F1324 /* JSUint8ClampedArrayCustom.cpp in Sources */ = {isa = PBXBuildFile; fileRef = B6F1148C1673B115001F1324 /* JSUint8ClampedArrayCustom.cpp */; }; + B6F114B61673B116001F1324 /* JSUint8ClampedArrayCustom.cpp in Sources */ = {isa = PBXBuildFile; fileRef = B6F1148C1673B115001F1324 /* JSUint8ClampedArrayCustom.cpp */; }; + B6F114B71673B116001F1324 /* JSUint16Array.cpp in Sources */ = {isa = PBXBuildFile; fileRef = B6F1148D1673B115001F1324 /* JSUint16Array.cpp */; }; + B6F114B81673B116001F1324 /* JSUint16Array.cpp in Sources */ = {isa = PBXBuildFile; fileRef = B6F1148D1673B115001F1324 /* JSUint16Array.cpp */; }; + B6F114B91673B116001F1324 /* JSUint16Array.h in Headers */ = {isa = PBXBuildFile; fileRef = B6F1148E1673B115001F1324 /* JSUint16Array.h */; }; + B6F114BA1673B116001F1324 /* JSUint16Array.h in Headers */ = {isa = PBXBuildFile; fileRef = B6F1148E1673B115001F1324 /* JSUint16Array.h */; }; + B6F114BB1673B116001F1324 /* JSUint16ArrayCustom.cpp in Sources */ = {isa = PBXBuildFile; fileRef = B6F1148F1673B115001F1324 /* JSUint16ArrayCustom.cpp */; }; + B6F114BC1673B116001F1324 /* JSUint16ArrayCustom.cpp in Sources */ = {isa = PBXBuildFile; fileRef = B6F1148F1673B115001F1324 /* JSUint16ArrayCustom.cpp */; }; + B6F114BD1673B116001F1324 /* JSUint32Array.cpp in Sources */ = {isa = PBXBuildFile; fileRef = B6F114901673B115001F1324 /* JSUint32Array.cpp */; }; + B6F114BE1673B116001F1324 /* JSUint32Array.cpp in Sources */ = {isa = PBXBuildFile; fileRef = B6F114901673B115001F1324 /* JSUint32Array.cpp */; }; + B6F114BF1673B116001F1324 /* JSUint32Array.h in Headers */ = {isa = PBXBuildFile; fileRef = B6F114911673B115001F1324 /* JSUint32Array.h */; }; + B6F114C01673B116001F1324 /* JSUint32Array.h in Headers */ = {isa = PBXBuildFile; fileRef = B6F114911673B115001F1324 /* JSUint32Array.h */; }; + B6F114C11673B116001F1324 /* JSUint32ArrayCustom.cpp in Sources */ = {isa = PBXBuildFile; fileRef = B6F114921673B115001F1324 /* JSUint32ArrayCustom.cpp */; }; + B6F114C21673B116001F1324 /* JSUint32ArrayCustom.cpp in Sources */ = {isa = PBXBuildFile; fileRef = B6F114921673B115001F1324 /* JSUint32ArrayCustom.cpp */; }; BC02E90D0E1839DB000F9297 /* ErrorConstructor.h in Headers */ = {isa = PBXBuildFile; fileRef = BC02E9050E1839DB000F9297 /* ErrorConstructor.h */; }; BC02E90F0E1839DB000F9297 /* ErrorPrototype.h in Headers */ = {isa = PBXBuildFile; fileRef = BC02E9070E1839DB000F9297 /* ErrorPrototype.h */; }; BC02E9110E1839DB000F9297 /* NativeErrorConstructor.h in Headers */ = {isa = PBXBuildFile; fileRef = BC02E9090E1839DB000F9297 /* NativeErrorConstructor.h */; }; @@ -1837,6 +1885,30 @@ B6E69BC4166BD63D005EF4B1 /* libJavaScriptCore.a */ = {isa = PBXFileReference; explicitFileType = archive.ar; includeInIndex = 0; path = libJavaScriptCore.a; sourceTree = BUILT_PRODUCTS_DIR; }; B6E69BDB166BD6C1005EF4B1 /* libJSCLLIntOffsetsExtractor.a */ = {isa = PBXFileReference; explicitFileType = archive.ar; includeInIndex = 0; path = libJSCLLIntOffsetsExtractor.a; sourceTree = BUILT_PRODUCTS_DIR; }; B6E69BFD166BDCE7005EF4B1 /* libWTF.a */ = {isa = PBXFileReference; lastKnownFileType = archive.ar; name = libWTF.a; path = ../Build/libWTF.a; sourceTree = ""; }; + B6F1147B1673B115001F1324 /* JSFloat64Array.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = JSFloat64Array.cpp; sourceTree = ""; }; + B6F1147C1673B115001F1324 /* JSFloat64Array.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = JSFloat64Array.h; sourceTree = ""; }; + B6F1147D1673B115001F1324 /* JSFloat64ArrayCustom.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = JSFloat64ArrayCustom.cpp; sourceTree = ""; }; + B6F1147E1673B115001F1324 /* JSInt8Array.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = JSInt8Array.cpp; sourceTree = ""; }; + B6F1147F1673B115001F1324 /* JSInt8Array.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = JSInt8Array.h; sourceTree = ""; }; + B6F114801673B115001F1324 /* JSInt8ArrayCustom.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = JSInt8ArrayCustom.cpp; sourceTree = ""; }; + B6F114811673B115001F1324 /* JSInt16Array.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = JSInt16Array.cpp; sourceTree = ""; }; + B6F114821673B115001F1324 /* JSInt16Array.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = JSInt16Array.h; sourceTree = ""; }; + B6F114831673B115001F1324 /* JSInt16ArrayCustom.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = JSInt16ArrayCustom.cpp; sourceTree = ""; }; + B6F114841673B115001F1324 /* JSInt32Array.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = JSInt32Array.cpp; sourceTree = ""; }; + B6F114851673B115001F1324 /* JSInt32Array.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = JSInt32Array.h; sourceTree = ""; }; + B6F114861673B115001F1324 /* JSInt32ArrayCustom.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = JSInt32ArrayCustom.cpp; sourceTree = ""; }; + B6F114871673B115001F1324 /* JSUint8Array.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = JSUint8Array.cpp; sourceTree = ""; }; + B6F114881673B115001F1324 /* JSUint8Array.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = JSUint8Array.h; sourceTree = ""; }; + B6F114891673B115001F1324 /* JSUint8ArrayCustom.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = JSUint8ArrayCustom.cpp; sourceTree = ""; }; + B6F1148A1673B115001F1324 /* JSUint8ClampedArray.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = JSUint8ClampedArray.cpp; sourceTree = ""; }; + B6F1148B1673B115001F1324 /* JSUint8ClampedArray.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = JSUint8ClampedArray.h; sourceTree = ""; }; + B6F1148C1673B115001F1324 /* JSUint8ClampedArrayCustom.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = JSUint8ClampedArrayCustom.cpp; sourceTree = ""; }; + B6F1148D1673B115001F1324 /* JSUint16Array.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = JSUint16Array.cpp; sourceTree = ""; }; + B6F1148E1673B115001F1324 /* JSUint16Array.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = JSUint16Array.h; sourceTree = ""; }; + B6F1148F1673B115001F1324 /* JSUint16ArrayCustom.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = JSUint16ArrayCustom.cpp; sourceTree = ""; }; + B6F114901673B115001F1324 /* JSUint32Array.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = JSUint32Array.cpp; sourceTree = ""; }; + B6F114911673B115001F1324 /* JSUint32Array.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = JSUint32Array.h; sourceTree = ""; }; + B6F114921673B115001F1324 /* JSUint32ArrayCustom.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = JSUint32ArrayCustom.cpp; sourceTree = ""; }; BC021BF1136900C300FC5467 /* CompilerVersion.xcconfig */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.xcconfig; path = CompilerVersion.xcconfig; sourceTree = ""; }; BC021BF2136900C300FC5467 /* ToolExecutable.xcconfig */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.xcconfig; path = ToolExecutable.xcconfig; sourceTree = ""; }; BC02E9040E1839DB000F9297 /* ErrorConstructor.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = ErrorConstructor.cpp; sourceTree = ""; }; @@ -2893,6 +2965,30 @@ B6D1888D167381A300D1037C /* JSFloat32ArrayCustom.cpp */, B6D1886E1672DFE700D1037C /* JSFloat32Array.cpp */, B6D1886F1672DFE700D1037C /* JSFloat32Array.h */, + B6F1147B1673B115001F1324 /* JSFloat64Array.cpp */, + B6F1147C1673B115001F1324 /* JSFloat64Array.h */, + B6F1147D1673B115001F1324 /* JSFloat64ArrayCustom.cpp */, + B6F1147E1673B115001F1324 /* JSInt8Array.cpp */, + B6F1147F1673B115001F1324 /* JSInt8Array.h */, + B6F114801673B115001F1324 /* JSInt8ArrayCustom.cpp */, + B6F114811673B115001F1324 /* JSInt16Array.cpp */, + B6F114821673B115001F1324 /* JSInt16Array.h */, + B6F114831673B115001F1324 /* JSInt16ArrayCustom.cpp */, + B6F114841673B115001F1324 /* JSInt32Array.cpp */, + B6F114851673B115001F1324 /* JSInt32Array.h */, + B6F114861673B115001F1324 /* JSInt32ArrayCustom.cpp */, + B6F114871673B115001F1324 /* JSUint8Array.cpp */, + B6F114881673B115001F1324 /* JSUint8Array.h */, + B6F114891673B115001F1324 /* JSUint8ArrayCustom.cpp */, + B6F1148A1673B115001F1324 /* JSUint8ClampedArray.cpp */, + B6F1148B1673B115001F1324 /* JSUint8ClampedArray.h */, + B6F1148C1673B115001F1324 /* JSUint8ClampedArrayCustom.cpp */, + B6F1148D1673B115001F1324 /* JSUint16Array.cpp */, + B6F1148E1673B115001F1324 /* JSUint16Array.h */, + B6F1148F1673B115001F1324 /* JSUint16ArrayCustom.cpp */, + B6F114901673B115001F1324 /* JSUint32Array.cpp */, + B6F114911673B115001F1324 /* JSUint32Array.h */, + B6F114921673B115001F1324 /* JSUint32ArrayCustom.cpp */, ); path = TypedArrays; sourceTree = ""; @@ -3259,6 +3355,14 @@ B6D18836166FA73400D1037C /* JSArrayBufferViewHelper.h in Headers */, B6D188721672DFE800D1037C /* JSFloat32Array.h in Headers */, B6D1888B1673751400D1037C /* GlobalDataHelper.h in Headers */, + B6F114951673B116001F1324 /* JSFloat64Array.h in Headers */, + B6F1149B1673B116001F1324 /* JSInt8Array.h in Headers */, + B6F114A11673B116001F1324 /* JSInt16Array.h in Headers */, + B6F114A71673B116001F1324 /* JSInt32Array.h in Headers */, + B6F114AD1673B116001F1324 /* JSUint8Array.h in Headers */, + B6F114B31673B116001F1324 /* JSUint8ClampedArray.h in Headers */, + B6F114B91673B116001F1324 /* JSUint16Array.h in Headers */, + B6F114BF1673B116001F1324 /* JSUint32Array.h in Headers */, ); runOnlyForDeploymentPostprocessing = 0; }; @@ -3609,6 +3713,14 @@ B6D18837166FA73400D1037C /* JSArrayBufferViewHelper.h in Headers */, B6D188731672DFE800D1037C /* JSFloat32Array.h in Headers */, B6D1888C1673751400D1037C /* GlobalDataHelper.h in Headers */, + B6F114961673B116001F1324 /* JSFloat64Array.h in Headers */, + B6F1149C1673B116001F1324 /* JSInt8Array.h in Headers */, + B6F114A21673B116001F1324 /* JSInt16Array.h in Headers */, + B6F114A81673B116001F1324 /* JSInt32Array.h in Headers */, + B6F114AE1673B116001F1324 /* JSUint8Array.h in Headers */, + B6F114B41673B116001F1324 /* JSUint8ClampedArray.h in Headers */, + B6F114BA1673B116001F1324 /* JSUint16Array.h in Headers */, + B6F114C01673B116001F1324 /* JSUint32Array.h in Headers */, ); runOnlyForDeploymentPostprocessing = 0; }; @@ -4359,6 +4471,22 @@ B6D18832166FA73400D1037C /* JSArrayBufferView.cpp in Sources */, B6D188701672DFE800D1037C /* JSFloat32Array.cpp in Sources */, B6D1888E167381A400D1037C /* JSFloat32ArrayCustom.cpp in Sources */, + B6F114931673B116001F1324 /* JSFloat64Array.cpp in Sources */, + B6F114971673B116001F1324 /* JSFloat64ArrayCustom.cpp in Sources */, + B6F114991673B116001F1324 /* JSInt8Array.cpp in Sources */, + B6F1149D1673B116001F1324 /* JSInt8ArrayCustom.cpp in Sources */, + B6F1149F1673B116001F1324 /* JSInt16Array.cpp in Sources */, + B6F114A31673B116001F1324 /* JSInt16ArrayCustom.cpp in Sources */, + B6F114A51673B116001F1324 /* JSInt32Array.cpp in Sources */, + B6F114A91673B116001F1324 /* JSInt32ArrayCustom.cpp in Sources */, + B6F114AB1673B116001F1324 /* JSUint8Array.cpp in Sources */, + B6F114AF1673B116001F1324 /* JSUint8ArrayCustom.cpp in Sources */, + B6F114B11673B116001F1324 /* JSUint8ClampedArray.cpp in Sources */, + B6F114B51673B116001F1324 /* JSUint8ClampedArrayCustom.cpp in Sources */, + B6F114B71673B116001F1324 /* JSUint16Array.cpp in Sources */, + B6F114BB1673B116001F1324 /* JSUint16ArrayCustom.cpp in Sources */, + B6F114BD1673B116001F1324 /* JSUint32Array.cpp in Sources */, + B6F114C11673B116001F1324 /* JSUint32ArrayCustom.cpp in Sources */, ); runOnlyForDeploymentPostprocessing = 0; }; @@ -4588,6 +4716,22 @@ B6D18833166FA73400D1037C /* JSArrayBufferView.cpp in Sources */, B6D188711672DFE800D1037C /* JSFloat32Array.cpp in Sources */, B6D1888F167381A400D1037C /* JSFloat32ArrayCustom.cpp in Sources */, + B6F114941673B116001F1324 /* JSFloat64Array.cpp in Sources */, + B6F114981673B116001F1324 /* JSFloat64ArrayCustom.cpp in Sources */, + B6F1149A1673B116001F1324 /* JSInt8Array.cpp in Sources */, + B6F1149E1673B116001F1324 /* JSInt8ArrayCustom.cpp in Sources */, + B6F114A01673B116001F1324 /* JSInt16Array.cpp in Sources */, + B6F114A41673B116001F1324 /* JSInt16ArrayCustom.cpp in Sources */, + B6F114A61673B116001F1324 /* JSInt32Array.cpp in Sources */, + B6F114AA1673B116001F1324 /* JSInt32ArrayCustom.cpp in Sources */, + B6F114AC1673B116001F1324 /* JSUint8Array.cpp in Sources */, + B6F114B01673B116001F1324 /* JSUint8ArrayCustom.cpp in Sources */, + B6F114B21673B116001F1324 /* JSUint8ClampedArray.cpp in Sources */, + B6F114B61673B116001F1324 /* JSUint8ClampedArrayCustom.cpp in Sources */, + B6F114B81673B116001F1324 /* JSUint16Array.cpp in Sources */, + B6F114BC1673B116001F1324 /* JSUint16ArrayCustom.cpp in Sources */, + B6F114BE1673B116001F1324 /* JSUint32Array.cpp in Sources */, + B6F114C21673B116001F1324 /* JSUint32ArrayCustom.cpp in Sources */, ); runOnlyForDeploymentPostprocessing = 0; }; diff --git a/JavaScriptCore/runtime/TypedArrays/JSFloat64Array.cpp b/JavaScriptCore/runtime/TypedArrays/JSFloat64Array.cpp new file mode 100644 index 00000000..178efb63 --- /dev/null +++ b/JavaScriptCore/runtime/TypedArrays/JSFloat64Array.cpp @@ -0,0 +1,297 @@ +/* + 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 "JSDOMBinding.h" +#include "JSFloat64Array.h" +#include +#include +#include +#include + +using namespace JSC; + +namespace WebCore { + +ASSERT_CLASS_FITS_IN_CELL(JSFloat64Array); +/* Hash table */ + +static const HashTableValue JSFloat64ArrayTableValues[] = +{ + { "length", DontDelete | ReadOnly, (intptr_t)static_cast(jsFloat64ArrayLength), (intptr_t)0, NoIntrinsic }, + { "constructor", DontEnum | ReadOnly, (intptr_t)static_cast(jsFloat64ArrayConstructor), (intptr_t)0, NoIntrinsic }, + { 0, 0, 0, 0, NoIntrinsic } +}; + +static const HashTable JSFloat64ArrayTable = { 5, 3, JSFloat64ArrayTableValues, 0 }; +/* Hash table for constructor */ + +static const HashTableValue JSFloat64ArrayConstructorTableValues[] = +{ + { "BYTES_PER_ELEMENT", DontDelete | ReadOnly, (intptr_t)static_cast(jsFloat64ArrayBYTES_PER_ELEMENT), (intptr_t)0, NoIntrinsic }, + { 0, 0, 0, 0, NoIntrinsic } +}; + +static const HashTable JSFloat64ArrayConstructorTable = { 2, 1, JSFloat64ArrayConstructorTableValues, 0 }; +const ClassInfo JSFloat64ArrayConstructor::s_info = { "Float64ArrayConstructor", &Base::s_info, &JSFloat64ArrayConstructorTable, 0, CREATE_METHOD_TABLE(JSFloat64ArrayConstructor) }; + +JSFloat64ArrayConstructor::JSFloat64ArrayConstructor(Structure* structure, JSDOMGlobalObject* globalObject) + : DOMConstructorObject(structure, globalObject) +{ +} + +void JSFloat64ArrayConstructor::finishCreation(ExecState* exec, JSDOMGlobalObject* globalObject) +{ + Base::finishCreation(exec->globalData()); + ASSERT(inherits(&s_info)); + putDirect(exec->globalData(), exec->propertyNames().prototype, JSFloat64ArrayPrototype::self(exec, globalObject), DontDelete | ReadOnly); + putDirect(exec->globalData(), exec->propertyNames().length, jsNumber(1), ReadOnly | DontDelete | DontEnum); +} + +bool JSFloat64ArrayConstructor::getOwnPropertySlot(JSCell* cell, ExecState* exec, const Identifier& propertyName, PropertySlot& slot) +{ + return getStaticValueSlot(exec, &JSFloat64ArrayConstructorTable, jsCast(cell), propertyName, slot); +} + +bool JSFloat64ArrayConstructor::getOwnPropertyDescriptor(JSObject* object, ExecState* exec, const Identifier& propertyName, PropertyDescriptor& descriptor) +{ + return getStaticValueDescriptor(exec, &JSFloat64ArrayConstructorTable, jsCast(object), propertyName, descriptor); +} + +ConstructType JSFloat64ArrayConstructor::getConstructData(JSCell*, ConstructData& constructData) +{ + constructData.native.function = constructJSFloat64Array; + return ConstructTypeHost; +} + +/* Hash table for prototype */ + +static const HashTableValue JSFloat64ArrayPrototypeTableValues[] = +{ + { "BYTES_PER_ELEMENT", DontDelete | ReadOnly, (intptr_t)static_cast(jsFloat64ArrayBYTES_PER_ELEMENT), (intptr_t)0, NoIntrinsic }, + { "subarray", DontDelete | JSC::Function, (intptr_t)static_cast(jsFloat64ArrayPrototypeFunctionSubarray), (intptr_t)2, NoIntrinsic }, + { "set", DontDelete | JSC::Function, (intptr_t)static_cast(jsFloat64ArrayPrototypeFunctionSet), (intptr_t)0, NoIntrinsic }, + { 0, 0, 0, 0, NoIntrinsic } +}; + +static const HashTable JSFloat64ArrayPrototypeTable = { 8, 7, JSFloat64ArrayPrototypeTableValues, 0 }; +static const HashTable* getJSFloat64ArrayPrototypeTable(ExecState* exec) +{ + return getHashTableForGlobalData(exec->globalData(), &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(exec, globalObject); +} + +bool JSFloat64ArrayPrototype::getOwnPropertySlot(JSCell* cell, ExecState* exec, const Identifier& propertyName, PropertySlot& slot) +{ + JSFloat64ArrayPrototype* thisObject = jsCast(cell); + return getStaticPropertySlot(exec, getJSFloat64ArrayPrototypeTable(exec), thisObject, propertyName, slot); +} + +bool JSFloat64ArrayPrototype::getOwnPropertyDescriptor(JSObject* object, ExecState* exec, const Identifier& propertyName, PropertyDescriptor& descriptor) +{ + JSFloat64ArrayPrototype* thisObject = jsCast(object); + return getStaticPropertyDescriptor(exec, getJSFloat64ArrayPrototypeTable(exec), thisObject, propertyName, descriptor); +} + +static const HashTable* getJSFloat64ArrayTable(ExecState* exec) +{ + return getHashTableForGlobalData(exec->globalData(), &JSFloat64ArrayTable); +} + +const ClassInfo JSFloat64Array::s_info = { "Float64Array", &Base::s_info, 0, getJSFloat64ArrayTable , CREATE_METHOD_TABLE(JSFloat64Array) }; + +JSFloat64Array::JSFloat64Array(Structure* structure, JSDOMGlobalObject* globalObject, PassRefPtr impl) + : JSArrayBufferView(structure, globalObject, impl) +{ +} + +void JSFloat64Array::finishCreation(JSGlobalData& globalData) +{ + Base::finishCreation(globalData); + TypedArrayDescriptor descriptor(&JSFloat64Array::s_info, OBJECT_OFFSETOF(JSFloat64Array, m_storage), OBJECT_OFFSETOF(JSFloat64Array, m_storageLength)); + globalData.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->globalData(), globalObject, JSFloat64ArrayPrototype::createStructure(exec->globalData(), globalObject, JSArrayBufferViewPrototype::self(exec, globalObject))); +} + +bool JSFloat64Array::getOwnPropertySlot(JSCell* cell, ExecState* exec, const Identifier& propertyName, PropertySlot& slot) +{ + JSFloat64Array* thisObject = jsCast(cell); + ASSERT_GC_OBJECT_INHERITS(thisObject, &s_info); + bool ok; + unsigned index = propertyName.toUInt32(ok); + if (ok && index < static_cast(thisObject->impl())->length()) { + slot.setValue(thisObject->getByIndex(exec, index)); + return true; + } + return getStaticValueSlot(exec, getJSFloat64ArrayTable(exec), thisObject, propertyName, slot); +} + +bool JSFloat64Array::getOwnPropertyDescriptor(JSObject* object, ExecState* exec, const Identifier& propertyName, PropertyDescriptor& descriptor) +{ + JSFloat64Array* thisObject = jsCast(object); + ASSERT_GC_OBJECT_INHERITS(thisObject, &s_info); + bool ok; + unsigned index = propertyName.toUInt32(ok); + if (ok && index < static_cast(thisObject->impl())->length()) { + descriptor.setDescriptor(thisObject->getByIndex(exec, index), DontDelete); + return true; + } + return getStaticValueDescriptor(exec, getJSFloat64ArrayTable(exec), thisObject, propertyName, descriptor); +} + +bool JSFloat64Array::getOwnPropertySlotByIndex(JSCell* cell, ExecState* exec, unsigned propertyName, PropertySlot& slot) +{ + JSFloat64Array* thisObject = jsCast(cell); + ASSERT_GC_OBJECT_INHERITS(thisObject, &s_info); + if (propertyName < static_cast(thisObject->impl())->length()) { + slot.setValue(thisObject->getByIndex(exec, propertyName)); + return true; + } + return thisObject->methodTable()->getOwnPropertySlot(thisObject, exec, Identifier::from(exec, propertyName), slot); +} + +JSValue jsFloat64ArrayLength(ExecState* exec, JSValue slotBase, const Identifier&) +{ + JSFloat64Array* castedThis = jsCast(asObject(slotBase)); + UNUSED_PARAM(exec); + Float64Array* impl = static_cast(castedThis->impl()); + JSValue result = jsNumber(impl->length()); + return result; +} + + +JSValue jsFloat64ArrayConstructor(ExecState* exec, JSValue slotBase, const Identifier&) +{ + JSFloat64Array* domObject = jsCast(asObject(slotBase)); + return JSFloat64Array::getConstructor(exec, domObject->globalObject()); +} + +void JSFloat64Array::put(JSCell* cell, ExecState* exec, const Identifier& propertyName, JSValue value, PutPropertySlot& slot) +{ + JSFloat64Array* thisObject = jsCast(cell); + ASSERT_GC_OBJECT_INHERITS(thisObject, &s_info); + bool ok; + unsigned index = propertyName.toUInt32(ok); + if (ok) { + thisObject->indexSetter(exec, index, value); + return; + } + Base::put(thisObject, exec, propertyName, value, slot); +} + +void JSFloat64Array::putByIndex(JSCell* cell, ExecState* exec, unsigned propertyName, JSValue value, bool) +{ + JSFloat64Array* thisObject = jsCast(cell); + ASSERT_GC_OBJECT_INHERITS(thisObject, &s_info); + thisObject->indexSetter(exec, propertyName, value); + return; +} + +void JSFloat64Array::getOwnPropertyNames(JSObject* object, ExecState* exec, PropertyNameArray& propertyNames, EnumerationMode mode) +{ + JSFloat64Array* thisObject = jsCast(object); + ASSERT_GC_OBJECT_INHERITS(thisObject, &s_info); + for (unsigned i = 0; i < static_cast(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(exec, jsCast(globalObject)); +} + +EncodedJSValue JSC_HOST_CALL jsFloat64ArrayPrototypeFunctionSubarray(ExecState* exec) +{ + JSValue thisValue = exec->hostThisValue(); + if (!thisValue.inherits(&JSFloat64Array::s_info)) + return throwVMTypeError(exec); + JSFloat64Array* castedThis = jsCast(asObject(thisValue)); + ASSERT_GC_OBJECT_INHERITS(castedThis, &JSFloat64Array::s_info); + Float64Array* impl = static_cast(castedThis->impl()); + int start(MAYBE_MISSING_PARAMETER(exec, 0, DefaultIsUndefined).toInt32(exec)); + if (exec->hadException()) + return JSValue::encode(jsUndefined()); + + size_t argsCount = exec->argumentCount(); + if (argsCount <= 1) { + + JSC::JSValue result = toJS(exec, castedThis->globalObject(), WTF::getPtr(impl->subarray(start))); + return JSValue::encode(result); + } + + int end(MAYBE_MISSING_PARAMETER(exec, 1, DefaultIsUndefined).toInt32(exec)); + if (exec->hadException()) + return JSValue::encode(jsUndefined()); + + JSC::JSValue result = toJS(exec, castedThis->globalObject(), WTF::getPtr(impl->subarray(start, end))); + 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(asObject(thisValue)); + ASSERT_GC_OBJECT_INHERITS(castedThis, &JSFloat64Array::s_info); + return JSValue::encode(castedThis->set(exec)); +} + +// Constant getters + +JSValue jsFloat64ArrayBYTES_PER_ELEMENT(ExecState* exec, JSValue, const Identifier&) +{ + UNUSED_PARAM(exec); + return jsNumber(static_cast(8)); +} + + +JSValue JSFloat64Array::getByIndex(ExecState*, unsigned index) +{ + ASSERT_GC_OBJECT_INHERITS(this, &s_info); + double result = static_cast(impl())->item(index); + if (isnan(result)) + return jsNaN(); + return JSValue(result); +} + +Float64Array* toFloat64Array(JSC::JSValue value) +{ + return value.inherits(&JSFloat64Array::s_info) ? jsCast(asObject(value))->impl() : 0; +} + +} diff --git a/JavaScriptCore/runtime/TypedArrays/JSFloat64Array.h b/JavaScriptCore/runtime/TypedArrays/JSFloat64Array.h new file mode 100644 index 00000000..4b9cfe4b --- /dev/null +++ b/JavaScriptCore/runtime/TypedArrays/JSFloat64Array.h @@ -0,0 +1,143 @@ +/* + 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. +*/ + +#ifndef JSFloat64Array_h +#define JSFloat64Array_h + +#include "JSArrayBufferView.h" +#include "JSDOMBinding.h" +#include +#include + +namespace WebCore { + +class JSFloat64Array : public JSArrayBufferView { +public: + typedef JSArrayBufferView Base; + static JSFloat64Array* create(JSC::Structure* structure, JSDOMGlobalObject* globalObject, PassRefPtr impl) + { + JSFloat64Array* ptr = new (NotNull, JSC::allocateCell(globalObject->globalData().heap)) JSFloat64Array(structure, globalObject, impl); + ptr->finishCreation(globalObject->globalData()); + return ptr; + } + + static JSC::JSObject* createPrototype(JSC::ExecState*, JSC::JSGlobalObject*); + static bool getOwnPropertySlot(JSC::JSCell*, JSC::ExecState*, const JSC::Identifier& propertyName, JSC::PropertySlot&); + static bool getOwnPropertyDescriptor(JSC::JSObject*, JSC::ExecState*, const JSC::Identifier& propertyName, JSC::PropertyDescriptor&); + static bool getOwnPropertySlotByIndex(JSC::JSCell*, JSC::ExecState*, unsigned propertyName, JSC::PropertySlot&); + static void put(JSC::JSCell*, JSC::ExecState*, const JSC::Identifier& propertyName, JSC::JSValue, JSC::PutPropertySlot&); + static void putByIndex(JSC::JSCell*, JSC::ExecState*, unsigned propertyName, JSC::JSValue, bool shouldThrow); + static const JSC::ClassInfo s_info; + + static JSC::Structure* createStructure(JSC::JSGlobalData& globalData, JSC::JSGlobalObject* globalObject, JSC::JSValue prototype) + { + return JSC::Structure::create(globalData, globalObject, prototype, JSC::TypeInfo(JSC::ObjectType, StructureFlags), &s_info); + } + + static void getOwnPropertyNames(JSC::JSObject*, JSC::ExecState*, JSC::PropertyNameArray&, JSC::EnumerationMode mode = JSC::ExcludeDontEnumProperties); + static JSC::JSValue getConstructor(JSC::ExecState*, JSC::JSGlobalObject*); + + // Custom functions + JSC::JSValue set(JSC::ExecState*); + Float64Array* impl() const + { + return static_cast(Base::impl()); + } + static const JSC::TypedArrayType TypedArrayStorageType = JSC::TypedArrayFloat64; + intptr_t m_storageLength; + void* m_storage; +protected: + JSFloat64Array(JSC::Structure*, JSDOMGlobalObject*, PassRefPtr); + void finishCreation(JSC::JSGlobalData&); + static const unsigned StructureFlags = JSC::OverridesGetPropertyNames | JSC::OverridesGetOwnPropertySlot | Base::StructureFlags; + JSC::JSValue getByIndex(JSC::ExecState*, unsigned index); + void indexSetter(JSC::ExecState*, unsigned index, JSC::JSValue); +}; + +JSC::JSValue toJS(JSC::ExecState*, JSDOMGlobalObject*, Float64Array*); +Float64Array* toFloat64Array(JSC::JSValue); + +class JSFloat64ArrayPrototype : public JSC::JSNonFinalObject { +public: + typedef JSC::JSNonFinalObject Base; + static JSC::JSObject* self(JSC::ExecState*, JSC::JSGlobalObject*); + static JSFloat64ArrayPrototype* create(JSC::JSGlobalData& globalData, JSC::JSGlobalObject* globalObject, JSC::Structure* structure) + { + JSFloat64ArrayPrototype* ptr = new (NotNull, JSC::allocateCell(globalData.heap)) JSFloat64ArrayPrototype(globalData, globalObject, structure); + ptr->finishCreation(globalData); + return ptr; + } + + static const JSC::ClassInfo s_info; + static bool getOwnPropertySlot(JSC::JSCell*, JSC::ExecState*, const JSC::Identifier&, JSC::PropertySlot&); + static bool getOwnPropertyDescriptor(JSC::JSObject*, JSC::ExecState*, const JSC::Identifier&, JSC::PropertyDescriptor&); + static JSC::Structure* createStructure(JSC::JSGlobalData& globalData, JSC::JSGlobalObject* globalObject, JSC::JSValue prototype) + { + return JSC::Structure::create(globalData, globalObject, prototype, JSC::TypeInfo(JSC::ObjectType, StructureFlags), &s_info); + } + +private: + JSFloat64ArrayPrototype(JSC::JSGlobalData& globalData, JSC::JSGlobalObject*, JSC::Structure* structure) : JSC::JSNonFinalObject(globalData, structure) { } +protected: + static const unsigned StructureFlags = JSC::OverridesGetOwnPropertySlot | Base::StructureFlags; +}; + +class JSFloat64ArrayConstructor : public DOMConstructorObject { +private: + JSFloat64ArrayConstructor(JSC::Structure*, JSDOMGlobalObject*); + void finishCreation(JSC::ExecState*, JSDOMGlobalObject*); + +public: + typedef DOMConstructorObject Base; + static JSFloat64ArrayConstructor* create(JSC::ExecState* exec, JSC::Structure* structure, JSDOMGlobalObject* globalObject) + { + JSFloat64ArrayConstructor* ptr = new (NotNull, JSC::allocateCell(*exec->heap())) JSFloat64ArrayConstructor(structure, globalObject); + ptr->finishCreation(exec, globalObject); + return ptr; + } + + static bool getOwnPropertySlot(JSC::JSCell*, JSC::ExecState*, const JSC::Identifier&, JSC::PropertySlot&); + static bool getOwnPropertyDescriptor(JSC::JSObject*, JSC::ExecState*, const JSC::Identifier&, JSC::PropertyDescriptor&); + static const JSC::ClassInfo s_info; + static JSC::Structure* createStructure(JSC::JSGlobalData& globalData, JSC::JSGlobalObject* globalObject, JSC::JSValue prototype) + { + return JSC::Structure::create(globalData, globalObject, prototype, JSC::TypeInfo(JSC::ObjectType, StructureFlags), &s_info); + } +protected: + static const unsigned StructureFlags = JSC::OverridesGetOwnPropertySlot | JSC::ImplementsHasInstance | DOMConstructorObject::StructureFlags; + static JSC::EncodedJSValue JSC_HOST_CALL constructJSFloat64Array(JSC::ExecState*); + static JSC::ConstructType getConstructData(JSC::JSCell*, JSC::ConstructData&); +}; + +// Functions + +JSC::EncodedJSValue JSC_HOST_CALL jsFloat64ArrayPrototypeFunctionSubarray(JSC::ExecState*); +JSC::EncodedJSValue JSC_HOST_CALL jsFloat64ArrayPrototypeFunctionSet(JSC::ExecState*); +// Attributes + +JSC::JSValue jsFloat64ArrayLength(JSC::ExecState*, JSC::JSValue, const JSC::Identifier&); +JSC::JSValue jsFloat64ArrayConstructor(JSC::ExecState*, JSC::JSValue, const JSC::Identifier&); +// Constants + +JSC::JSValue jsFloat64ArrayBYTES_PER_ELEMENT(JSC::ExecState*, JSC::JSValue, const JSC::Identifier&); + +} // namespace WebCore + +#endif diff --git a/JavaScriptCore/runtime/TypedArrays/JSFloat64ArrayCustom.cpp b/JavaScriptCore/runtime/TypedArrays/JSFloat64ArrayCustom.cpp new file mode 100644 index 00000000..15619e32 --- /dev/null +++ b/JavaScriptCore/runtime/TypedArrays/JSFloat64ArrayCustom.cpp @@ -0,0 +1,61 @@ +/* + * Copyright (C) 2011 Apple Inc. All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY APPLE COMPUTER, INC. ``AS IS'' AND ANY + * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR + * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE COMPUTER, INC. OR + * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, + * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, + * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR + * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY + * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE + * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + */ + +#include "config.h" +#include "JSFloat64Array.h" + +#include "JSArrayBufferViewHelper.h" +#include + +using namespace JSC; + +namespace WebCore { + +void JSFloat64Array::indexSetter(JSC::ExecState* exec, unsigned index, JSC::JSValue value) +{ + impl()->set(index, value.toNumber(exec)); +} + +JSC::JSValue toJS(JSC::ExecState* exec, JSDOMGlobalObject* globalObject, Float64Array* object) +{ + return toJSArrayBufferView(exec, globalObject, object); +} + +JSC::JSValue JSFloat64Array::set(JSC::ExecState* exec) +{ + return setWebGLArrayHelper(exec, impl(), toFloat64Array); +} + +EncodedJSValue JSC_HOST_CALL JSFloat64ArrayConstructor::constructJSFloat64Array(ExecState* exec) +{ + JSFloat64ArrayConstructor* jsConstructor = jsCast(exec->callee()); + RefPtr array = constructArrayBufferView(exec); + if (!array.get()) + // Exception has already been thrown. + return JSValue::encode(JSValue()); + return JSValue::encode(asObject(toJS(exec, jsConstructor->globalObject(), array.get()))); +} + +} // namespace WebCore diff --git a/JavaScriptCore/runtime/TypedArrays/JSInt16Array.cpp b/JavaScriptCore/runtime/TypedArrays/JSInt16Array.cpp new file mode 100644 index 00000000..e1fcd69d --- /dev/null +++ b/JavaScriptCore/runtime/TypedArrays/JSInt16Array.cpp @@ -0,0 +1,297 @@ +/* + 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 "JSInt16Array.h" + +#include "ExceptionCode.h" +#include "JSDOMBinding.h" +#include "JSInt16Array.h" +#include +#include +#include +#include + +using namespace JSC; + +namespace WebCore { + +ASSERT_CLASS_FITS_IN_CELL(JSInt16Array); +/* Hash table */ + +static const HashTableValue JSInt16ArrayTableValues[] = +{ + { "length", DontDelete | ReadOnly, (intptr_t)static_cast(jsInt16ArrayLength), (intptr_t)0, NoIntrinsic }, + { "constructor", DontEnum | ReadOnly, (intptr_t)static_cast(jsInt16ArrayConstructor), (intptr_t)0, NoIntrinsic }, + { 0, 0, 0, 0, NoIntrinsic } +}; + +static const HashTable JSInt16ArrayTable = { 5, 3, JSInt16ArrayTableValues, 0 }; +/* Hash table for constructor */ + +static const HashTableValue JSInt16ArrayConstructorTableValues[] = +{ + { "BYTES_PER_ELEMENT", DontDelete | ReadOnly, (intptr_t)static_cast(jsInt16ArrayBYTES_PER_ELEMENT), (intptr_t)0, NoIntrinsic }, + { 0, 0, 0, 0, NoIntrinsic } +}; + +static const HashTable JSInt16ArrayConstructorTable = { 2, 1, JSInt16ArrayConstructorTableValues, 0 }; +const ClassInfo JSInt16ArrayConstructor::s_info = { "Int16ArrayConstructor", &Base::s_info, &JSInt16ArrayConstructorTable, 0, CREATE_METHOD_TABLE(JSInt16ArrayConstructor) }; + +JSInt16ArrayConstructor::JSInt16ArrayConstructor(Structure* structure, JSDOMGlobalObject* globalObject) + : DOMConstructorObject(structure, globalObject) +{ +} + +void JSInt16ArrayConstructor::finishCreation(ExecState* exec, JSDOMGlobalObject* globalObject) +{ + Base::finishCreation(exec->globalData()); + ASSERT(inherits(&s_info)); + putDirect(exec->globalData(), exec->propertyNames().prototype, JSInt16ArrayPrototype::self(exec, globalObject), DontDelete | ReadOnly); + putDirect(exec->globalData(), exec->propertyNames().length, jsNumber(1), ReadOnly | DontDelete | DontEnum); +} + +bool JSInt16ArrayConstructor::getOwnPropertySlot(JSCell* cell, ExecState* exec, const Identifier& propertyName, PropertySlot& slot) +{ + return getStaticValueSlot(exec, &JSInt16ArrayConstructorTable, jsCast(cell), propertyName, slot); +} + +bool JSInt16ArrayConstructor::getOwnPropertyDescriptor(JSObject* object, ExecState* exec, const Identifier& propertyName, PropertyDescriptor& descriptor) +{ + return getStaticValueDescriptor(exec, &JSInt16ArrayConstructorTable, jsCast(object), propertyName, descriptor); +} + +ConstructType JSInt16ArrayConstructor::getConstructData(JSCell*, ConstructData& constructData) +{ + constructData.native.function = constructJSInt16Array; + return ConstructTypeHost; +} + +/* Hash table for prototype */ + +static const HashTableValue JSInt16ArrayPrototypeTableValues[] = +{ + { "BYTES_PER_ELEMENT", DontDelete | ReadOnly, (intptr_t)static_cast(jsInt16ArrayBYTES_PER_ELEMENT), (intptr_t)0, NoIntrinsic }, + { "subarray", DontDelete | JSC::Function, (intptr_t)static_cast(jsInt16ArrayPrototypeFunctionSubarray), (intptr_t)2, NoIntrinsic }, + { "set", DontDelete | JSC::Function, (intptr_t)static_cast(jsInt16ArrayPrototypeFunctionSet), (intptr_t)0, NoIntrinsic }, + { 0, 0, 0, 0, NoIntrinsic } +}; + +static const HashTable JSInt16ArrayPrototypeTable = { 8, 7, JSInt16ArrayPrototypeTableValues, 0 }; +static const HashTable* getJSInt16ArrayPrototypeTable(ExecState* exec) +{ + return getHashTableForGlobalData(exec->globalData(), &JSInt16ArrayPrototypeTable); +} + +const ClassInfo JSInt16ArrayPrototype::s_info = { "Int16ArrayPrototype", &Base::s_info, 0, getJSInt16ArrayPrototypeTable, CREATE_METHOD_TABLE(JSInt16ArrayPrototype) }; + +JSObject* JSInt16ArrayPrototype::self(ExecState* exec, JSGlobalObject* globalObject) +{ + return getDOMPrototype(exec, globalObject); +} + +bool JSInt16ArrayPrototype::getOwnPropertySlot(JSCell* cell, ExecState* exec, const Identifier& propertyName, PropertySlot& slot) +{ + JSInt16ArrayPrototype* thisObject = jsCast(cell); + return getStaticPropertySlot(exec, getJSInt16ArrayPrototypeTable(exec), thisObject, propertyName, slot); +} + +bool JSInt16ArrayPrototype::getOwnPropertyDescriptor(JSObject* object, ExecState* exec, const Identifier& propertyName, PropertyDescriptor& descriptor) +{ + JSInt16ArrayPrototype* thisObject = jsCast(object); + return getStaticPropertyDescriptor(exec, getJSInt16ArrayPrototypeTable(exec), thisObject, propertyName, descriptor); +} + +static const HashTable* getJSInt16ArrayTable(ExecState* exec) +{ + return getHashTableForGlobalData(exec->globalData(), &JSInt16ArrayTable); +} + +const ClassInfo JSInt16Array::s_info = { "Int16Array", &Base::s_info, 0, getJSInt16ArrayTable , CREATE_METHOD_TABLE(JSInt16Array) }; + +JSInt16Array::JSInt16Array(Structure* structure, JSDOMGlobalObject* globalObject, PassRefPtr impl) + : JSArrayBufferView(structure, globalObject, impl) +{ +} + +void JSInt16Array::finishCreation(JSGlobalData& globalData) +{ + Base::finishCreation(globalData); + TypedArrayDescriptor descriptor(&JSInt16Array::s_info, OBJECT_OFFSETOF(JSInt16Array, m_storage), OBJECT_OFFSETOF(JSInt16Array, m_storageLength)); + globalData.registerTypedArrayDescriptor(impl(), descriptor); + m_storage = impl()->data(); + m_storageLength = impl()->length(); + ASSERT(inherits(&s_info)); +} + +JSObject* JSInt16Array::createPrototype(ExecState* exec, JSGlobalObject* globalObject) +{ + return JSInt16ArrayPrototype::create(exec->globalData(), globalObject, JSInt16ArrayPrototype::createStructure(exec->globalData(), globalObject, JSArrayBufferViewPrototype::self(exec, globalObject))); +} + +bool JSInt16Array::getOwnPropertySlot(JSCell* cell, ExecState* exec, const Identifier& propertyName, PropertySlot& slot) +{ + JSInt16Array* thisObject = jsCast(cell); + ASSERT_GC_OBJECT_INHERITS(thisObject, &s_info); + bool ok; + unsigned index = propertyName.toUInt32(ok); + if (ok && index < static_cast(thisObject->impl())->length()) { + slot.setValue(thisObject->getByIndex(exec, index)); + return true; + } + return getStaticValueSlot(exec, getJSInt16ArrayTable(exec), thisObject, propertyName, slot); +} + +bool JSInt16Array::getOwnPropertyDescriptor(JSObject* object, ExecState* exec, const Identifier& propertyName, PropertyDescriptor& descriptor) +{ + JSInt16Array* thisObject = jsCast(object); + ASSERT_GC_OBJECT_INHERITS(thisObject, &s_info); + bool ok; + unsigned index = propertyName.toUInt32(ok); + if (ok && index < static_cast(thisObject->impl())->length()) { + descriptor.setDescriptor(thisObject->getByIndex(exec, index), DontDelete); + return true; + } + return getStaticValueDescriptor(exec, getJSInt16ArrayTable(exec), thisObject, propertyName, descriptor); +} + +bool JSInt16Array::getOwnPropertySlotByIndex(JSCell* cell, ExecState* exec, unsigned propertyName, PropertySlot& slot) +{ + JSInt16Array* thisObject = jsCast(cell); + ASSERT_GC_OBJECT_INHERITS(thisObject, &s_info); + if (propertyName < static_cast(thisObject->impl())->length()) { + slot.setValue(thisObject->getByIndex(exec, propertyName)); + return true; + } + return thisObject->methodTable()->getOwnPropertySlot(thisObject, exec, Identifier::from(exec, propertyName), slot); +} + +JSValue jsInt16ArrayLength(ExecState* exec, JSValue slotBase, const Identifier&) +{ + JSInt16Array* castedThis = jsCast(asObject(slotBase)); + UNUSED_PARAM(exec); + Int16Array* impl = static_cast(castedThis->impl()); + JSValue result = jsNumber(impl->length()); + return result; +} + + +JSValue jsInt16ArrayConstructor(ExecState* exec, JSValue slotBase, const Identifier&) +{ + JSInt16Array* domObject = jsCast(asObject(slotBase)); + return JSInt16Array::getConstructor(exec, domObject->globalObject()); +} + +void JSInt16Array::put(JSCell* cell, ExecState* exec, const Identifier& propertyName, JSValue value, PutPropertySlot& slot) +{ + JSInt16Array* thisObject = jsCast(cell); + ASSERT_GC_OBJECT_INHERITS(thisObject, &s_info); + bool ok; + unsigned index = propertyName.toUInt32(ok); + if (ok) { + thisObject->indexSetter(exec, index, value); + return; + } + Base::put(thisObject, exec, propertyName, value, slot); +} + +void JSInt16Array::putByIndex(JSCell* cell, ExecState* exec, unsigned propertyName, JSValue value, bool) +{ + JSInt16Array* thisObject = jsCast(cell); + ASSERT_GC_OBJECT_INHERITS(thisObject, &s_info); + thisObject->indexSetter(exec, propertyName, value); + return; +} + +void JSInt16Array::getOwnPropertyNames(JSObject* object, ExecState* exec, PropertyNameArray& propertyNames, EnumerationMode mode) +{ + JSInt16Array* thisObject = jsCast(object); + ASSERT_GC_OBJECT_INHERITS(thisObject, &s_info); + for (unsigned i = 0; i < static_cast(thisObject->impl())->length(); ++i) + propertyNames.add(Identifier::from(exec, i)); + Base::getOwnPropertyNames(thisObject, exec, propertyNames, mode); +} + +JSValue JSInt16Array::getConstructor(ExecState* exec, JSGlobalObject* globalObject) +{ + return getDOMConstructor(exec, jsCast(globalObject)); +} + +EncodedJSValue JSC_HOST_CALL jsInt16ArrayPrototypeFunctionSubarray(ExecState* exec) +{ + JSValue thisValue = exec->hostThisValue(); + if (!thisValue.inherits(&JSInt16Array::s_info)) + return throwVMTypeError(exec); + JSInt16Array* castedThis = jsCast(asObject(thisValue)); + ASSERT_GC_OBJECT_INHERITS(castedThis, &JSInt16Array::s_info); + Int16Array* impl = static_cast(castedThis->impl()); + int start(MAYBE_MISSING_PARAMETER(exec, 0, DefaultIsUndefined).toInt32(exec)); + if (exec->hadException()) + return JSValue::encode(jsUndefined()); + + size_t argsCount = exec->argumentCount(); + if (argsCount <= 1) { + + JSC::JSValue result = toJS(exec, castedThis->globalObject(), WTF::getPtr(impl->subarray(start))); + return JSValue::encode(result); + } + + int end(MAYBE_MISSING_PARAMETER(exec, 1, DefaultIsUndefined).toInt32(exec)); + if (exec->hadException()) + return JSValue::encode(jsUndefined()); + + JSC::JSValue result = toJS(exec, castedThis->globalObject(), WTF::getPtr(impl->subarray(start, end))); + return JSValue::encode(result); +} + +EncodedJSValue JSC_HOST_CALL jsInt16ArrayPrototypeFunctionSet(ExecState* exec) +{ + JSValue thisValue = exec->hostThisValue(); + if (!thisValue.inherits(&JSInt16Array::s_info)) + return throwVMTypeError(exec); + JSInt16Array* castedThis = jsCast(asObject(thisValue)); + ASSERT_GC_OBJECT_INHERITS(castedThis, &JSInt16Array::s_info); + return JSValue::encode(castedThis->set(exec)); +} + +// Constant getters + +JSValue jsInt16ArrayBYTES_PER_ELEMENT(ExecState* exec, JSValue, const Identifier&) +{ + UNUSED_PARAM(exec); + return jsNumber(static_cast(2)); +} + + +JSValue JSInt16Array::getByIndex(ExecState*, unsigned index) +{ + ASSERT_GC_OBJECT_INHERITS(this, &s_info); + double result = static_cast(impl())->item(index); + if (isnan(result)) + return jsNaN(); + return JSValue(result); +} + +Int16Array* toInt16Array(JSC::JSValue value) +{ + return value.inherits(&JSInt16Array::s_info) ? jsCast(asObject(value))->impl() : 0; +} + +} diff --git a/JavaScriptCore/runtime/TypedArrays/JSInt16Array.h b/JavaScriptCore/runtime/TypedArrays/JSInt16Array.h new file mode 100644 index 00000000..077dfc98 --- /dev/null +++ b/JavaScriptCore/runtime/TypedArrays/JSInt16Array.h @@ -0,0 +1,143 @@ +/* + 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. +*/ + +#ifndef JSInt16Array_h +#define JSInt16Array_h + +#include "JSArrayBufferView.h" +#include "JSDOMBinding.h" +#include +#include + +namespace WebCore { + +class JSInt16Array : public JSArrayBufferView { +public: + typedef JSArrayBufferView Base; + static JSInt16Array* create(JSC::Structure* structure, JSDOMGlobalObject* globalObject, PassRefPtr impl) + { + JSInt16Array* ptr = new (NotNull, JSC::allocateCell(globalObject->globalData().heap)) JSInt16Array(structure, globalObject, impl); + ptr->finishCreation(globalObject->globalData()); + return ptr; + } + + static JSC::JSObject* createPrototype(JSC::ExecState*, JSC::JSGlobalObject*); + static bool getOwnPropertySlot(JSC::JSCell*, JSC::ExecState*, const JSC::Identifier& propertyName, JSC::PropertySlot&); + static bool getOwnPropertyDescriptor(JSC::JSObject*, JSC::ExecState*, const JSC::Identifier& propertyName, JSC::PropertyDescriptor&); + static bool getOwnPropertySlotByIndex(JSC::JSCell*, JSC::ExecState*, unsigned propertyName, JSC::PropertySlot&); + static void put(JSC::JSCell*, JSC::ExecState*, const JSC::Identifier& propertyName, JSC::JSValue, JSC::PutPropertySlot&); + static void putByIndex(JSC::JSCell*, JSC::ExecState*, unsigned propertyName, JSC::JSValue, bool shouldThrow); + static const JSC::ClassInfo s_info; + + static JSC::Structure* createStructure(JSC::JSGlobalData& globalData, JSC::JSGlobalObject* globalObject, JSC::JSValue prototype) + { + return JSC::Structure::create(globalData, globalObject, prototype, JSC::TypeInfo(JSC::ObjectType, StructureFlags), &s_info); + } + + static void getOwnPropertyNames(JSC::JSObject*, JSC::ExecState*, JSC::PropertyNameArray&, JSC::EnumerationMode mode = JSC::ExcludeDontEnumProperties); + static JSC::JSValue getConstructor(JSC::ExecState*, JSC::JSGlobalObject*); + + // Custom functions + JSC::JSValue set(JSC::ExecState*); + Int16Array* impl() const + { + return static_cast(Base::impl()); + } + static const JSC::TypedArrayType TypedArrayStorageType = JSC::TypedArrayInt16; + intptr_t m_storageLength; + void* m_storage; +protected: + JSInt16Array(JSC::Structure*, JSDOMGlobalObject*, PassRefPtr); + void finishCreation(JSC::JSGlobalData&); + static const unsigned StructureFlags = JSC::OverridesGetPropertyNames | JSC::OverridesGetOwnPropertySlot | Base::StructureFlags; + JSC::JSValue getByIndex(JSC::ExecState*, unsigned index); + void indexSetter(JSC::ExecState*, unsigned index, JSC::JSValue); +}; + +JSC::JSValue toJS(JSC::ExecState*, JSDOMGlobalObject*, Int16Array*); +Int16Array* toInt16Array(JSC::JSValue); + +class JSInt16ArrayPrototype : public JSC::JSNonFinalObject { +public: + typedef JSC::JSNonFinalObject Base; + static JSC::JSObject* self(JSC::ExecState*, JSC::JSGlobalObject*); + static JSInt16ArrayPrototype* create(JSC::JSGlobalData& globalData, JSC::JSGlobalObject* globalObject, JSC::Structure* structure) + { + JSInt16ArrayPrototype* ptr = new (NotNull, JSC::allocateCell(globalData.heap)) JSInt16ArrayPrototype(globalData, globalObject, structure); + ptr->finishCreation(globalData); + return ptr; + } + + static const JSC::ClassInfo s_info; + static bool getOwnPropertySlot(JSC::JSCell*, JSC::ExecState*, const JSC::Identifier&, JSC::PropertySlot&); + static bool getOwnPropertyDescriptor(JSC::JSObject*, JSC::ExecState*, const JSC::Identifier&, JSC::PropertyDescriptor&); + static JSC::Structure* createStructure(JSC::JSGlobalData& globalData, JSC::JSGlobalObject* globalObject, JSC::JSValue prototype) + { + return JSC::Structure::create(globalData, globalObject, prototype, JSC::TypeInfo(JSC::ObjectType, StructureFlags), &s_info); + } + +private: + JSInt16ArrayPrototype(JSC::JSGlobalData& globalData, JSC::JSGlobalObject*, JSC::Structure* structure) : JSC::JSNonFinalObject(globalData, structure) { } +protected: + static const unsigned StructureFlags = JSC::OverridesGetOwnPropertySlot | Base::StructureFlags; +}; + +class JSInt16ArrayConstructor : public DOMConstructorObject { +private: + JSInt16ArrayConstructor(JSC::Structure*, JSDOMGlobalObject*); + void finishCreation(JSC::ExecState*, JSDOMGlobalObject*); + +public: + typedef DOMConstructorObject Base; + static JSInt16ArrayConstructor* create(JSC::ExecState* exec, JSC::Structure* structure, JSDOMGlobalObject* globalObject) + { + JSInt16ArrayConstructor* ptr = new (NotNull, JSC::allocateCell(*exec->heap())) JSInt16ArrayConstructor(structure, globalObject); + ptr->finishCreation(exec, globalObject); + return ptr; + } + + static bool getOwnPropertySlot(JSC::JSCell*, JSC::ExecState*, const JSC::Identifier&, JSC::PropertySlot&); + static bool getOwnPropertyDescriptor(JSC::JSObject*, JSC::ExecState*, const JSC::Identifier&, JSC::PropertyDescriptor&); + static const JSC::ClassInfo s_info; + static JSC::Structure* createStructure(JSC::JSGlobalData& globalData, JSC::JSGlobalObject* globalObject, JSC::JSValue prototype) + { + return JSC::Structure::create(globalData, globalObject, prototype, JSC::TypeInfo(JSC::ObjectType, StructureFlags), &s_info); + } +protected: + static const unsigned StructureFlags = JSC::OverridesGetOwnPropertySlot | JSC::ImplementsHasInstance | DOMConstructorObject::StructureFlags; + static JSC::EncodedJSValue JSC_HOST_CALL constructJSInt16Array(JSC::ExecState*); + static JSC::ConstructType getConstructData(JSC::JSCell*, JSC::ConstructData&); +}; + +// Functions + +JSC::EncodedJSValue JSC_HOST_CALL jsInt16ArrayPrototypeFunctionSubarray(JSC::ExecState*); +JSC::EncodedJSValue JSC_HOST_CALL jsInt16ArrayPrototypeFunctionSet(JSC::ExecState*); +// Attributes + +JSC::JSValue jsInt16ArrayLength(JSC::ExecState*, JSC::JSValue, const JSC::Identifier&); +JSC::JSValue jsInt16ArrayConstructor(JSC::ExecState*, JSC::JSValue, const JSC::Identifier&); +// Constants + +JSC::JSValue jsInt16ArrayBYTES_PER_ELEMENT(JSC::ExecState*, JSC::JSValue, const JSC::Identifier&); + +} // namespace WebCore + +#endif diff --git a/JavaScriptCore/runtime/TypedArrays/JSInt16ArrayCustom.cpp b/JavaScriptCore/runtime/TypedArrays/JSInt16ArrayCustom.cpp new file mode 100644 index 00000000..bc77a6d2 --- /dev/null +++ b/JavaScriptCore/runtime/TypedArrays/JSInt16ArrayCustom.cpp @@ -0,0 +1,61 @@ +/* + * Copyright (C) 2009 Apple Inc. All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY APPLE COMPUTER, INC. ``AS IS'' AND ANY + * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR + * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE COMPUTER, INC. OR + * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, + * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, + * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR + * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY + * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE + * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + */ + +#include "config.h" +#include "JSInt16Array.h" + +#include "JSArrayBufferViewHelper.h" +#include + +using namespace JSC; + +namespace WebCore { + +void JSInt16Array::indexSetter(JSC::ExecState* exec, unsigned index, JSC::JSValue value) +{ + impl()->set(index, static_cast(value.toInt32(exec))); +} + +JSC::JSValue toJS(JSC::ExecState* exec, JSDOMGlobalObject* globalObject, Int16Array* object) +{ + return toJSArrayBufferView(exec, globalObject, object); +} + +JSC::JSValue JSInt16Array::set(JSC::ExecState* exec) +{ + return setWebGLArrayHelper(exec, impl(), toInt16Array); +} + +EncodedJSValue JSC_HOST_CALL JSInt16ArrayConstructor::constructJSInt16Array(ExecState* exec) +{ + JSInt16ArrayConstructor* jsConstructor = jsCast(exec->callee()); + RefPtr array = constructArrayBufferView(exec); + if (!array.get()) + // Exception has already been thrown. + return JSValue::encode(JSValue()); + return JSValue::encode(asObject(toJS(exec, jsConstructor->globalObject(), array.get()))); +} + +} // namespace WebCore diff --git a/JavaScriptCore/runtime/TypedArrays/JSInt32Array.cpp b/JavaScriptCore/runtime/TypedArrays/JSInt32Array.cpp new file mode 100644 index 00000000..653480c7 --- /dev/null +++ b/JavaScriptCore/runtime/TypedArrays/JSInt32Array.cpp @@ -0,0 +1,297 @@ +/* + 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 "JSInt32Array.h" + +#include "ExceptionCode.h" +#include "JSDOMBinding.h" +#include "JSInt32Array.h" +#include +#include +#include +#include + +using namespace JSC; + +namespace WebCore { + +ASSERT_CLASS_FITS_IN_CELL(JSInt32Array); +/* Hash table */ + +static const HashTableValue JSInt32ArrayTableValues[] = +{ + { "length", DontDelete | ReadOnly, (intptr_t)static_cast(jsInt32ArrayLength), (intptr_t)0, NoIntrinsic }, + { "constructor", DontEnum | ReadOnly, (intptr_t)static_cast(jsInt32ArrayConstructor), (intptr_t)0, NoIntrinsic }, + { 0, 0, 0, 0, NoIntrinsic } +}; + +static const HashTable JSInt32ArrayTable = { 5, 3, JSInt32ArrayTableValues, 0 }; +/* Hash table for constructor */ + +static const HashTableValue JSInt32ArrayConstructorTableValues[] = +{ + { "BYTES_PER_ELEMENT", DontDelete | ReadOnly, (intptr_t)static_cast(jsInt32ArrayBYTES_PER_ELEMENT), (intptr_t)0, NoIntrinsic }, + { 0, 0, 0, 0, NoIntrinsic } +}; + +static const HashTable JSInt32ArrayConstructorTable = { 2, 1, JSInt32ArrayConstructorTableValues, 0 }; +const ClassInfo JSInt32ArrayConstructor::s_info = { "Int32ArrayConstructor", &Base::s_info, &JSInt32ArrayConstructorTable, 0, CREATE_METHOD_TABLE(JSInt32ArrayConstructor) }; + +JSInt32ArrayConstructor::JSInt32ArrayConstructor(Structure* structure, JSDOMGlobalObject* globalObject) + : DOMConstructorObject(structure, globalObject) +{ +} + +void JSInt32ArrayConstructor::finishCreation(ExecState* exec, JSDOMGlobalObject* globalObject) +{ + Base::finishCreation(exec->globalData()); + ASSERT(inherits(&s_info)); + putDirect(exec->globalData(), exec->propertyNames().prototype, JSInt32ArrayPrototype::self(exec, globalObject), DontDelete | ReadOnly); + putDirect(exec->globalData(), exec->propertyNames().length, jsNumber(1), ReadOnly | DontDelete | DontEnum); +} + +bool JSInt32ArrayConstructor::getOwnPropertySlot(JSCell* cell, ExecState* exec, const Identifier& propertyName, PropertySlot& slot) +{ + return getStaticValueSlot(exec, &JSInt32ArrayConstructorTable, jsCast(cell), propertyName, slot); +} + +bool JSInt32ArrayConstructor::getOwnPropertyDescriptor(JSObject* object, ExecState* exec, const Identifier& propertyName, PropertyDescriptor& descriptor) +{ + return getStaticValueDescriptor(exec, &JSInt32ArrayConstructorTable, jsCast(object), propertyName, descriptor); +} + +ConstructType JSInt32ArrayConstructor::getConstructData(JSCell*, ConstructData& constructData) +{ + constructData.native.function = constructJSInt32Array; + return ConstructTypeHost; +} + +/* Hash table for prototype */ + +static const HashTableValue JSInt32ArrayPrototypeTableValues[] = +{ + { "BYTES_PER_ELEMENT", DontDelete | ReadOnly, (intptr_t)static_cast(jsInt32ArrayBYTES_PER_ELEMENT), (intptr_t)0, NoIntrinsic }, + { "subarray", DontDelete | JSC::Function, (intptr_t)static_cast(jsInt32ArrayPrototypeFunctionSubarray), (intptr_t)2, NoIntrinsic }, + { "set", DontDelete | JSC::Function, (intptr_t)static_cast(jsInt32ArrayPrototypeFunctionSet), (intptr_t)0, NoIntrinsic }, + { 0, 0, 0, 0, NoIntrinsic } +}; + +static const HashTable JSInt32ArrayPrototypeTable = { 8, 7, JSInt32ArrayPrototypeTableValues, 0 }; +static const HashTable* getJSInt32ArrayPrototypeTable(ExecState* exec) +{ + return getHashTableForGlobalData(exec->globalData(), &JSInt32ArrayPrototypeTable); +} + +const ClassInfo JSInt32ArrayPrototype::s_info = { "Int32ArrayPrototype", &Base::s_info, 0, getJSInt32ArrayPrototypeTable, CREATE_METHOD_TABLE(JSInt32ArrayPrototype) }; + +JSObject* JSInt32ArrayPrototype::self(ExecState* exec, JSGlobalObject* globalObject) +{ + return getDOMPrototype(exec, globalObject); +} + +bool JSInt32ArrayPrototype::getOwnPropertySlot(JSCell* cell, ExecState* exec, const Identifier& propertyName, PropertySlot& slot) +{ + JSInt32ArrayPrototype* thisObject = jsCast(cell); + return getStaticPropertySlot(exec, getJSInt32ArrayPrototypeTable(exec), thisObject, propertyName, slot); +} + +bool JSInt32ArrayPrototype::getOwnPropertyDescriptor(JSObject* object, ExecState* exec, const Identifier& propertyName, PropertyDescriptor& descriptor) +{ + JSInt32ArrayPrototype* thisObject = jsCast(object); + return getStaticPropertyDescriptor(exec, getJSInt32ArrayPrototypeTable(exec), thisObject, propertyName, descriptor); +} + +static const HashTable* getJSInt32ArrayTable(ExecState* exec) +{ + return getHashTableForGlobalData(exec->globalData(), &JSInt32ArrayTable); +} + +const ClassInfo JSInt32Array::s_info = { "Int32Array", &Base::s_info, 0, getJSInt32ArrayTable , CREATE_METHOD_TABLE(JSInt32Array) }; + +JSInt32Array::JSInt32Array(Structure* structure, JSDOMGlobalObject* globalObject, PassRefPtr impl) + : JSArrayBufferView(structure, globalObject, impl) +{ +} + +void JSInt32Array::finishCreation(JSGlobalData& globalData) +{ + Base::finishCreation(globalData); + TypedArrayDescriptor descriptor(&JSInt32Array::s_info, OBJECT_OFFSETOF(JSInt32Array, m_storage), OBJECT_OFFSETOF(JSInt32Array, m_storageLength)); + globalData.registerTypedArrayDescriptor(impl(), descriptor); + m_storage = impl()->data(); + m_storageLength = impl()->length(); + ASSERT(inherits(&s_info)); +} + +JSObject* JSInt32Array::createPrototype(ExecState* exec, JSGlobalObject* globalObject) +{ + return JSInt32ArrayPrototype::create(exec->globalData(), globalObject, JSInt32ArrayPrototype::createStructure(exec->globalData(), globalObject, JSArrayBufferViewPrototype::self(exec, globalObject))); +} + +bool JSInt32Array::getOwnPropertySlot(JSCell* cell, ExecState* exec, const Identifier& propertyName, PropertySlot& slot) +{ + JSInt32Array* thisObject = jsCast(cell); + ASSERT_GC_OBJECT_INHERITS(thisObject, &s_info); + bool ok; + unsigned index = propertyName.toUInt32(ok); + if (ok && index < static_cast(thisObject->impl())->length()) { + slot.setValue(thisObject->getByIndex(exec, index)); + return true; + } + return getStaticValueSlot(exec, getJSInt32ArrayTable(exec), thisObject, propertyName, slot); +} + +bool JSInt32Array::getOwnPropertyDescriptor(JSObject* object, ExecState* exec, const Identifier& propertyName, PropertyDescriptor& descriptor) +{ + JSInt32Array* thisObject = jsCast(object); + ASSERT_GC_OBJECT_INHERITS(thisObject, &s_info); + bool ok; + unsigned index = propertyName.toUInt32(ok); + if (ok && index < static_cast(thisObject->impl())->length()) { + descriptor.setDescriptor(thisObject->getByIndex(exec, index), DontDelete); + return true; + } + return getStaticValueDescriptor(exec, getJSInt32ArrayTable(exec), thisObject, propertyName, descriptor); +} + +bool JSInt32Array::getOwnPropertySlotByIndex(JSCell* cell, ExecState* exec, unsigned propertyName, PropertySlot& slot) +{ + JSInt32Array* thisObject = jsCast(cell); + ASSERT_GC_OBJECT_INHERITS(thisObject, &s_info); + if (propertyName < static_cast(thisObject->impl())->length()) { + slot.setValue(thisObject->getByIndex(exec, propertyName)); + return true; + } + return thisObject->methodTable()->getOwnPropertySlot(thisObject, exec, Identifier::from(exec, propertyName), slot); +} + +JSValue jsInt32ArrayLength(ExecState* exec, JSValue slotBase, const Identifier&) +{ + JSInt32Array* castedThis = jsCast(asObject(slotBase)); + UNUSED_PARAM(exec); + Int32Array* impl = static_cast(castedThis->impl()); + JSValue result = jsNumber(impl->length()); + return result; +} + + +JSValue jsInt32ArrayConstructor(ExecState* exec, JSValue slotBase, const Identifier&) +{ + JSInt32Array* domObject = jsCast(asObject(slotBase)); + return JSInt32Array::getConstructor(exec, domObject->globalObject()); +} + +void JSInt32Array::put(JSCell* cell, ExecState* exec, const Identifier& propertyName, JSValue value, PutPropertySlot& slot) +{ + JSInt32Array* thisObject = jsCast(cell); + ASSERT_GC_OBJECT_INHERITS(thisObject, &s_info); + bool ok; + unsigned index = propertyName.toUInt32(ok); + if (ok) { + thisObject->indexSetter(exec, index, value); + return; + } + Base::put(thisObject, exec, propertyName, value, slot); +} + +void JSInt32Array::putByIndex(JSCell* cell, ExecState* exec, unsigned propertyName, JSValue value, bool) +{ + JSInt32Array* thisObject = jsCast(cell); + ASSERT_GC_OBJECT_INHERITS(thisObject, &s_info); + thisObject->indexSetter(exec, propertyName, value); + return; +} + +void JSInt32Array::getOwnPropertyNames(JSObject* object, ExecState* exec, PropertyNameArray& propertyNames, EnumerationMode mode) +{ + JSInt32Array* thisObject = jsCast(object); + ASSERT_GC_OBJECT_INHERITS(thisObject, &s_info); + for (unsigned i = 0; i < static_cast(thisObject->impl())->length(); ++i) + propertyNames.add(Identifier::from(exec, i)); + Base::getOwnPropertyNames(thisObject, exec, propertyNames, mode); +} + +JSValue JSInt32Array::getConstructor(ExecState* exec, JSGlobalObject* globalObject) +{ + return getDOMConstructor(exec, jsCast(globalObject)); +} + +EncodedJSValue JSC_HOST_CALL jsInt32ArrayPrototypeFunctionSubarray(ExecState* exec) +{ + JSValue thisValue = exec->hostThisValue(); + if (!thisValue.inherits(&JSInt32Array::s_info)) + return throwVMTypeError(exec); + JSInt32Array* castedThis = jsCast(asObject(thisValue)); + ASSERT_GC_OBJECT_INHERITS(castedThis, &JSInt32Array::s_info); + Int32Array* impl = static_cast(castedThis->impl()); + int start(MAYBE_MISSING_PARAMETER(exec, 0, DefaultIsUndefined).toInt32(exec)); + if (exec->hadException()) + return JSValue::encode(jsUndefined()); + + size_t argsCount = exec->argumentCount(); + if (argsCount <= 1) { + + JSC::JSValue result = toJS(exec, castedThis->globalObject(), WTF::getPtr(impl->subarray(start))); + return JSValue::encode(result); + } + + int end(MAYBE_MISSING_PARAMETER(exec, 1, DefaultIsUndefined).toInt32(exec)); + if (exec->hadException()) + return JSValue::encode(jsUndefined()); + + JSC::JSValue result = toJS(exec, castedThis->globalObject(), WTF::getPtr(impl->subarray(start, end))); + return JSValue::encode(result); +} + +EncodedJSValue JSC_HOST_CALL jsInt32ArrayPrototypeFunctionSet(ExecState* exec) +{ + JSValue thisValue = exec->hostThisValue(); + if (!thisValue.inherits(&JSInt32Array::s_info)) + return throwVMTypeError(exec); + JSInt32Array* castedThis = jsCast(asObject(thisValue)); + ASSERT_GC_OBJECT_INHERITS(castedThis, &JSInt32Array::s_info); + return JSValue::encode(castedThis->set(exec)); +} + +// Constant getters + +JSValue jsInt32ArrayBYTES_PER_ELEMENT(ExecState* exec, JSValue, const Identifier&) +{ + UNUSED_PARAM(exec); + return jsNumber(static_cast(4)); +} + + +JSValue JSInt32Array::getByIndex(ExecState*, unsigned index) +{ + ASSERT_GC_OBJECT_INHERITS(this, &s_info); + double result = static_cast(impl())->item(index); + if (isnan(result)) + return jsNaN(); + return JSValue(result); +} + +Int32Array* toInt32Array(JSC::JSValue value) +{ + return value.inherits(&JSInt32Array::s_info) ? jsCast(asObject(value))->impl() : 0; +} + +} diff --git a/JavaScriptCore/runtime/TypedArrays/JSInt32Array.h b/JavaScriptCore/runtime/TypedArrays/JSInt32Array.h new file mode 100644 index 00000000..b6cc3d90 --- /dev/null +++ b/JavaScriptCore/runtime/TypedArrays/JSInt32Array.h @@ -0,0 +1,143 @@ +/* + 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. +*/ + +#ifndef JSInt32Array_h +#define JSInt32Array_h + +#include "JSArrayBufferView.h" +#include "JSDOMBinding.h" +#include +#include + +namespace WebCore { + +class JSInt32Array : public JSArrayBufferView { +public: + typedef JSArrayBufferView Base; + static JSInt32Array* create(JSC::Structure* structure, JSDOMGlobalObject* globalObject, PassRefPtr impl) + { + JSInt32Array* ptr = new (NotNull, JSC::allocateCell(globalObject->globalData().heap)) JSInt32Array(structure, globalObject, impl); + ptr->finishCreation(globalObject->globalData()); + return ptr; + } + + static JSC::JSObject* createPrototype(JSC::ExecState*, JSC::JSGlobalObject*); + static bool getOwnPropertySlot(JSC::JSCell*, JSC::ExecState*, const JSC::Identifier& propertyName, JSC::PropertySlot&); + static bool getOwnPropertyDescriptor(JSC::JSObject*, JSC::ExecState*, const JSC::Identifier& propertyName, JSC::PropertyDescriptor&); + static bool getOwnPropertySlotByIndex(JSC::JSCell*, JSC::ExecState*, unsigned propertyName, JSC::PropertySlot&); + static void put(JSC::JSCell*, JSC::ExecState*, const JSC::Identifier& propertyName, JSC::JSValue, JSC::PutPropertySlot&); + static void putByIndex(JSC::JSCell*, JSC::ExecState*, unsigned propertyName, JSC::JSValue, bool shouldThrow); + static const JSC::ClassInfo s_info; + + static JSC::Structure* createStructure(JSC::JSGlobalData& globalData, JSC::JSGlobalObject* globalObject, JSC::JSValue prototype) + { + return JSC::Structure::create(globalData, globalObject, prototype, JSC::TypeInfo(JSC::ObjectType, StructureFlags), &s_info); + } + + static void getOwnPropertyNames(JSC::JSObject*, JSC::ExecState*, JSC::PropertyNameArray&, JSC::EnumerationMode mode = JSC::ExcludeDontEnumProperties); + static JSC::JSValue getConstructor(JSC::ExecState*, JSC::JSGlobalObject*); + + // Custom functions + JSC::JSValue set(JSC::ExecState*); + Int32Array* impl() const + { + return static_cast(Base::impl()); + } + static const JSC::TypedArrayType TypedArrayStorageType = JSC::TypedArrayInt32; + intptr_t m_storageLength; + void* m_storage; +protected: + JSInt32Array(JSC::Structure*, JSDOMGlobalObject*, PassRefPtr); + void finishCreation(JSC::JSGlobalData&); + static const unsigned StructureFlags = JSC::OverridesGetPropertyNames | JSC::OverridesGetOwnPropertySlot | Base::StructureFlags; + JSC::JSValue getByIndex(JSC::ExecState*, unsigned index); + void indexSetter(JSC::ExecState*, unsigned index, JSC::JSValue); +}; + +JSC::JSValue toJS(JSC::ExecState*, JSDOMGlobalObject*, Int32Array*); +Int32Array* toInt32Array(JSC::JSValue); + +class JSInt32ArrayPrototype : public JSC::JSNonFinalObject { +public: + typedef JSC::JSNonFinalObject Base; + static JSC::JSObject* self(JSC::ExecState*, JSC::JSGlobalObject*); + static JSInt32ArrayPrototype* create(JSC::JSGlobalData& globalData, JSC::JSGlobalObject* globalObject, JSC::Structure* structure) + { + JSInt32ArrayPrototype* ptr = new (NotNull, JSC::allocateCell(globalData.heap)) JSInt32ArrayPrototype(globalData, globalObject, structure); + ptr->finishCreation(globalData); + return ptr; + } + + static const JSC::ClassInfo s_info; + static bool getOwnPropertySlot(JSC::JSCell*, JSC::ExecState*, const JSC::Identifier&, JSC::PropertySlot&); + static bool getOwnPropertyDescriptor(JSC::JSObject*, JSC::ExecState*, const JSC::Identifier&, JSC::PropertyDescriptor&); + static JSC::Structure* createStructure(JSC::JSGlobalData& globalData, JSC::JSGlobalObject* globalObject, JSC::JSValue prototype) + { + return JSC::Structure::create(globalData, globalObject, prototype, JSC::TypeInfo(JSC::ObjectType, StructureFlags), &s_info); + } + +private: + JSInt32ArrayPrototype(JSC::JSGlobalData& globalData, JSC::JSGlobalObject*, JSC::Structure* structure) : JSC::JSNonFinalObject(globalData, structure) { } +protected: + static const unsigned StructureFlags = JSC::OverridesGetOwnPropertySlot | Base::StructureFlags; +}; + +class JSInt32ArrayConstructor : public DOMConstructorObject { +private: + JSInt32ArrayConstructor(JSC::Structure*, JSDOMGlobalObject*); + void finishCreation(JSC::ExecState*, JSDOMGlobalObject*); + +public: + typedef DOMConstructorObject Base; + static JSInt32ArrayConstructor* create(JSC::ExecState* exec, JSC::Structure* structure, JSDOMGlobalObject* globalObject) + { + JSInt32ArrayConstructor* ptr = new (NotNull, JSC::allocateCell(*exec->heap())) JSInt32ArrayConstructor(structure, globalObject); + ptr->finishCreation(exec, globalObject); + return ptr; + } + + static bool getOwnPropertySlot(JSC::JSCell*, JSC::ExecState*, const JSC::Identifier&, JSC::PropertySlot&); + static bool getOwnPropertyDescriptor(JSC::JSObject*, JSC::ExecState*, const JSC::Identifier&, JSC::PropertyDescriptor&); + static const JSC::ClassInfo s_info; + static JSC::Structure* createStructure(JSC::JSGlobalData& globalData, JSC::JSGlobalObject* globalObject, JSC::JSValue prototype) + { + return JSC::Structure::create(globalData, globalObject, prototype, JSC::TypeInfo(JSC::ObjectType, StructureFlags), &s_info); + } +protected: + static const unsigned StructureFlags = JSC::OverridesGetOwnPropertySlot | JSC::ImplementsHasInstance | DOMConstructorObject::StructureFlags; + static JSC::EncodedJSValue JSC_HOST_CALL constructJSInt32Array(JSC::ExecState*); + static JSC::ConstructType getConstructData(JSC::JSCell*, JSC::ConstructData&); +}; + +// Functions + +JSC::EncodedJSValue JSC_HOST_CALL jsInt32ArrayPrototypeFunctionSubarray(JSC::ExecState*); +JSC::EncodedJSValue JSC_HOST_CALL jsInt32ArrayPrototypeFunctionSet(JSC::ExecState*); +// Attributes + +JSC::JSValue jsInt32ArrayLength(JSC::ExecState*, JSC::JSValue, const JSC::Identifier&); +JSC::JSValue jsInt32ArrayConstructor(JSC::ExecState*, JSC::JSValue, const JSC::Identifier&); +// Constants + +JSC::JSValue jsInt32ArrayBYTES_PER_ELEMENT(JSC::ExecState*, JSC::JSValue, const JSC::Identifier&); + +} // namespace WebCore + +#endif diff --git a/JavaScriptCore/runtime/TypedArrays/JSInt32ArrayCustom.cpp b/JavaScriptCore/runtime/TypedArrays/JSInt32ArrayCustom.cpp new file mode 100644 index 00000000..d85287f4 --- /dev/null +++ b/JavaScriptCore/runtime/TypedArrays/JSInt32ArrayCustom.cpp @@ -0,0 +1,61 @@ +/* + * Copyright (C) 2009 Apple Inc. All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY APPLE COMPUTER, INC. ``AS IS'' AND ANY + * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR + * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE COMPUTER, INC. OR + * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, + * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, + * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR + * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY + * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE + * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + */ + +#include "config.h" +#include "JSInt32Array.h" + +#include "JSArrayBufferViewHelper.h" +#include + +using namespace JSC; + +namespace WebCore { + +void JSInt32Array::indexSetter(JSC::ExecState* exec, unsigned index, JSC::JSValue value) +{ + impl()->set(index, static_cast(value.toInt32(exec))); +} + +JSC::JSValue toJS(JSC::ExecState* exec, JSDOMGlobalObject* globalObject, Int32Array* object) +{ + return toJSArrayBufferView(exec, globalObject, object); +} + +JSC::JSValue JSInt32Array::set(JSC::ExecState* exec) +{ + return setWebGLArrayHelper(exec, impl(), toInt32Array); +} + +EncodedJSValue JSC_HOST_CALL JSInt32ArrayConstructor::constructJSInt32Array(ExecState* exec) +{ + JSInt32ArrayConstructor* jsConstructor = jsCast(exec->callee()); + RefPtr array = constructArrayBufferView(exec); + if (!array.get()) + // Exception has already been thrown. + return JSValue::encode(JSValue()); + return JSValue::encode(asObject(toJS(exec, jsConstructor->globalObject(), array.get()))); +} + +} // namespace WebCore diff --git a/JavaScriptCore/runtime/TypedArrays/JSInt8Array.cpp b/JavaScriptCore/runtime/TypedArrays/JSInt8Array.cpp new file mode 100644 index 00000000..53b6b642 --- /dev/null +++ b/JavaScriptCore/runtime/TypedArrays/JSInt8Array.cpp @@ -0,0 +1,297 @@ +/* + 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 "JSInt8Array.h" + +#include "ExceptionCode.h" +#include "JSDOMBinding.h" +#include "JSInt8Array.h" +#include +#include +#include +#include + +using namespace JSC; + +namespace WebCore { + +ASSERT_CLASS_FITS_IN_CELL(JSInt8Array); +/* Hash table */ + +static const HashTableValue JSInt8ArrayTableValues[] = +{ + { "length", DontDelete | ReadOnly, (intptr_t)static_cast(jsInt8ArrayLength), (intptr_t)0, NoIntrinsic }, + { "constructor", DontEnum | ReadOnly, (intptr_t)static_cast(jsInt8ArrayConstructor), (intptr_t)0, NoIntrinsic }, + { 0, 0, 0, 0, NoIntrinsic } +}; + +static const HashTable JSInt8ArrayTable = { 5, 3, JSInt8ArrayTableValues, 0 }; +/* Hash table for constructor */ + +static const HashTableValue JSInt8ArrayConstructorTableValues[] = +{ + { "BYTES_PER_ELEMENT", DontDelete | ReadOnly, (intptr_t)static_cast(jsInt8ArrayBYTES_PER_ELEMENT), (intptr_t)0, NoIntrinsic }, + { 0, 0, 0, 0, NoIntrinsic } +}; + +static const HashTable JSInt8ArrayConstructorTable = { 2, 1, JSInt8ArrayConstructorTableValues, 0 }; +const ClassInfo JSInt8ArrayConstructor::s_info = { "Int8ArrayConstructor", &Base::s_info, &JSInt8ArrayConstructorTable, 0, CREATE_METHOD_TABLE(JSInt8ArrayConstructor) }; + +JSInt8ArrayConstructor::JSInt8ArrayConstructor(Structure* structure, JSDOMGlobalObject* globalObject) + : DOMConstructorObject(structure, globalObject) +{ +} + +void JSInt8ArrayConstructor::finishCreation(ExecState* exec, JSDOMGlobalObject* globalObject) +{ + Base::finishCreation(exec->globalData()); + ASSERT(inherits(&s_info)); + putDirect(exec->globalData(), exec->propertyNames().prototype, JSInt8ArrayPrototype::self(exec, globalObject), DontDelete | ReadOnly); + putDirect(exec->globalData(), exec->propertyNames().length, jsNumber(1), ReadOnly | DontDelete | DontEnum); +} + +bool JSInt8ArrayConstructor::getOwnPropertySlot(JSCell* cell, ExecState* exec, const Identifier& propertyName, PropertySlot& slot) +{ + return getStaticValueSlot(exec, &JSInt8ArrayConstructorTable, jsCast(cell), propertyName, slot); +} + +bool JSInt8ArrayConstructor::getOwnPropertyDescriptor(JSObject* object, ExecState* exec, const Identifier& propertyName, PropertyDescriptor& descriptor) +{ + return getStaticValueDescriptor(exec, &JSInt8ArrayConstructorTable, jsCast(object), propertyName, descriptor); +} + +ConstructType JSInt8ArrayConstructor::getConstructData(JSCell*, ConstructData& constructData) +{ + constructData.native.function = constructJSInt8Array; + return ConstructTypeHost; +} + +/* Hash table for prototype */ + +static const HashTableValue JSInt8ArrayPrototypeTableValues[] = +{ + { "BYTES_PER_ELEMENT", DontDelete | ReadOnly, (intptr_t)static_cast(jsInt8ArrayBYTES_PER_ELEMENT), (intptr_t)0, NoIntrinsic }, + { "subarray", DontDelete | JSC::Function, (intptr_t)static_cast(jsInt8ArrayPrototypeFunctionSubarray), (intptr_t)2, NoIntrinsic }, + { "set", DontDelete | JSC::Function, (intptr_t)static_cast(jsInt8ArrayPrototypeFunctionSet), (intptr_t)0, NoIntrinsic }, + { 0, 0, 0, 0, NoIntrinsic } +}; + +static const HashTable JSInt8ArrayPrototypeTable = { 8, 7, JSInt8ArrayPrototypeTableValues, 0 }; +static const HashTable* getJSInt8ArrayPrototypeTable(ExecState* exec) +{ + return getHashTableForGlobalData(exec->globalData(), &JSInt8ArrayPrototypeTable); +} + +const ClassInfo JSInt8ArrayPrototype::s_info = { "Int8ArrayPrototype", &Base::s_info, 0, getJSInt8ArrayPrototypeTable, CREATE_METHOD_TABLE(JSInt8ArrayPrototype) }; + +JSObject* JSInt8ArrayPrototype::self(ExecState* exec, JSGlobalObject* globalObject) +{ + return getDOMPrototype(exec, globalObject); +} + +bool JSInt8ArrayPrototype::getOwnPropertySlot(JSCell* cell, ExecState* exec, const Identifier& propertyName, PropertySlot& slot) +{ + JSInt8ArrayPrototype* thisObject = jsCast(cell); + return getStaticPropertySlot(exec, getJSInt8ArrayPrototypeTable(exec), thisObject, propertyName, slot); +} + +bool JSInt8ArrayPrototype::getOwnPropertyDescriptor(JSObject* object, ExecState* exec, const Identifier& propertyName, PropertyDescriptor& descriptor) +{ + JSInt8ArrayPrototype* thisObject = jsCast(object); + return getStaticPropertyDescriptor(exec, getJSInt8ArrayPrototypeTable(exec), thisObject, propertyName, descriptor); +} + +static const HashTable* getJSInt8ArrayTable(ExecState* exec) +{ + return getHashTableForGlobalData(exec->globalData(), &JSInt8ArrayTable); +} + +const ClassInfo JSInt8Array::s_info = { "Int8Array", &Base::s_info, 0, getJSInt8ArrayTable , CREATE_METHOD_TABLE(JSInt8Array) }; + +JSInt8Array::JSInt8Array(Structure* structure, JSDOMGlobalObject* globalObject, PassRefPtr impl) + : JSArrayBufferView(structure, globalObject, impl) +{ +} + +void JSInt8Array::finishCreation(JSGlobalData& globalData) +{ + Base::finishCreation(globalData); + TypedArrayDescriptor descriptor(&JSInt8Array::s_info, OBJECT_OFFSETOF(JSInt8Array, m_storage), OBJECT_OFFSETOF(JSInt8Array, m_storageLength)); + globalData.registerTypedArrayDescriptor(impl(), descriptor); + m_storage = impl()->data(); + m_storageLength = impl()->length(); + ASSERT(inherits(&s_info)); +} + +JSObject* JSInt8Array::createPrototype(ExecState* exec, JSGlobalObject* globalObject) +{ + return JSInt8ArrayPrototype::create(exec->globalData(), globalObject, JSInt8ArrayPrototype::createStructure(exec->globalData(), globalObject, JSArrayBufferViewPrototype::self(exec, globalObject))); +} + +bool JSInt8Array::getOwnPropertySlot(JSCell* cell, ExecState* exec, const Identifier& propertyName, PropertySlot& slot) +{ + JSInt8Array* thisObject = jsCast(cell); + ASSERT_GC_OBJECT_INHERITS(thisObject, &s_info); + bool ok; + unsigned index = propertyName.toUInt32(ok); + if (ok && index < static_cast(thisObject->impl())->length()) { + slot.setValue(thisObject->getByIndex(exec, index)); + return true; + } + return getStaticValueSlot(exec, getJSInt8ArrayTable(exec), thisObject, propertyName, slot); +} + +bool JSInt8Array::getOwnPropertyDescriptor(JSObject* object, ExecState* exec, const Identifier& propertyName, PropertyDescriptor& descriptor) +{ + JSInt8Array* thisObject = jsCast(object); + ASSERT_GC_OBJECT_INHERITS(thisObject, &s_info); + bool ok; + unsigned index = propertyName.toUInt32(ok); + if (ok && index < static_cast(thisObject->impl())->length()) { + descriptor.setDescriptor(thisObject->getByIndex(exec, index), DontDelete); + return true; + } + return getStaticValueDescriptor(exec, getJSInt8ArrayTable(exec), thisObject, propertyName, descriptor); +} + +bool JSInt8Array::getOwnPropertySlotByIndex(JSCell* cell, ExecState* exec, unsigned propertyName, PropertySlot& slot) +{ + JSInt8Array* thisObject = jsCast(cell); + ASSERT_GC_OBJECT_INHERITS(thisObject, &s_info); + if (propertyName < static_cast(thisObject->impl())->length()) { + slot.setValue(thisObject->getByIndex(exec, propertyName)); + return true; + } + return thisObject->methodTable()->getOwnPropertySlot(thisObject, exec, Identifier::from(exec, propertyName), slot); +} + +JSValue jsInt8ArrayLength(ExecState* exec, JSValue slotBase, const Identifier&) +{ + JSInt8Array* castedThis = jsCast(asObject(slotBase)); + UNUSED_PARAM(exec); + Int8Array* impl = static_cast(castedThis->impl()); + JSValue result = jsNumber(impl->length()); + return result; +} + + +JSValue jsInt8ArrayConstructor(ExecState* exec, JSValue slotBase, const Identifier&) +{ + JSInt8Array* domObject = jsCast(asObject(slotBase)); + return JSInt8Array::getConstructor(exec, domObject->globalObject()); +} + +void JSInt8Array::put(JSCell* cell, ExecState* exec, const Identifier& propertyName, JSValue value, PutPropertySlot& slot) +{ + JSInt8Array* thisObject = jsCast(cell); + ASSERT_GC_OBJECT_INHERITS(thisObject, &s_info); + bool ok; + unsigned index = propertyName.toUInt32(ok); + if (ok) { + thisObject->indexSetter(exec, index, value); + return; + } + Base::put(thisObject, exec, propertyName, value, slot); +} + +void JSInt8Array::putByIndex(JSCell* cell, ExecState* exec, unsigned propertyName, JSValue value, bool) +{ + JSInt8Array* thisObject = jsCast(cell); + ASSERT_GC_OBJECT_INHERITS(thisObject, &s_info); + thisObject->indexSetter(exec, propertyName, value); + return; +} + +void JSInt8Array::getOwnPropertyNames(JSObject* object, ExecState* exec, PropertyNameArray& propertyNames, EnumerationMode mode) +{ + JSInt8Array* thisObject = jsCast(object); + ASSERT_GC_OBJECT_INHERITS(thisObject, &s_info); + for (unsigned i = 0; i < static_cast(thisObject->impl())->length(); ++i) + propertyNames.add(Identifier::from(exec, i)); + Base::getOwnPropertyNames(thisObject, exec, propertyNames, mode); +} + +JSValue JSInt8Array::getConstructor(ExecState* exec, JSGlobalObject* globalObject) +{ + return getDOMConstructor(exec, jsCast(globalObject)); +} + +EncodedJSValue JSC_HOST_CALL jsInt8ArrayPrototypeFunctionSubarray(ExecState* exec) +{ + JSValue thisValue = exec->hostThisValue(); + if (!thisValue.inherits(&JSInt8Array::s_info)) + return throwVMTypeError(exec); + JSInt8Array* castedThis = jsCast(asObject(thisValue)); + ASSERT_GC_OBJECT_INHERITS(castedThis, &JSInt8Array::s_info); + Int8Array* impl = static_cast(castedThis->impl()); + int start(MAYBE_MISSING_PARAMETER(exec, 0, DefaultIsUndefined).toInt32(exec)); + if (exec->hadException()) + return JSValue::encode(jsUndefined()); + + size_t argsCount = exec->argumentCount(); + if (argsCount <= 1) { + + JSC::JSValue result = toJS(exec, castedThis->globalObject(), WTF::getPtr(impl->subarray(start))); + return JSValue::encode(result); + } + + int end(MAYBE_MISSING_PARAMETER(exec, 1, DefaultIsUndefined).toInt32(exec)); + if (exec->hadException()) + return JSValue::encode(jsUndefined()); + + JSC::JSValue result = toJS(exec, castedThis->globalObject(), WTF::getPtr(impl->subarray(start, end))); + return JSValue::encode(result); +} + +EncodedJSValue JSC_HOST_CALL jsInt8ArrayPrototypeFunctionSet(ExecState* exec) +{ + JSValue thisValue = exec->hostThisValue(); + if (!thisValue.inherits(&JSInt8Array::s_info)) + return throwVMTypeError(exec); + JSInt8Array* castedThis = jsCast(asObject(thisValue)); + ASSERT_GC_OBJECT_INHERITS(castedThis, &JSInt8Array::s_info); + return JSValue::encode(castedThis->set(exec)); +} + +// Constant getters + +JSValue jsInt8ArrayBYTES_PER_ELEMENT(ExecState* exec, JSValue, const Identifier&) +{ + UNUSED_PARAM(exec); + return jsNumber(static_cast(1)); +} + + +JSValue JSInt8Array::getByIndex(ExecState*, unsigned index) +{ + ASSERT_GC_OBJECT_INHERITS(this, &s_info); + double result = static_cast(impl())->item(index); + if (isnan(result)) + return jsNaN(); + return JSValue(result); +} + +Int8Array* toInt8Array(JSC::JSValue value) +{ + return value.inherits(&JSInt8Array::s_info) ? jsCast(asObject(value))->impl() : 0; +} + +} diff --git a/JavaScriptCore/runtime/TypedArrays/JSInt8Array.h b/JavaScriptCore/runtime/TypedArrays/JSInt8Array.h new file mode 100644 index 00000000..12d94bcc --- /dev/null +++ b/JavaScriptCore/runtime/TypedArrays/JSInt8Array.h @@ -0,0 +1,143 @@ +/* + 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. +*/ + +#ifndef JSInt8Array_h +#define JSInt8Array_h + +#include "JSArrayBufferView.h" +#include "JSDOMBinding.h" +#include +#include + +namespace WebCore { + +class JSInt8Array : public JSArrayBufferView { +public: + typedef JSArrayBufferView Base; + static JSInt8Array* create(JSC::Structure* structure, JSDOMGlobalObject* globalObject, PassRefPtr impl) + { + JSInt8Array* ptr = new (NotNull, JSC::allocateCell(globalObject->globalData().heap)) JSInt8Array(structure, globalObject, impl); + ptr->finishCreation(globalObject->globalData()); + return ptr; + } + + static JSC::JSObject* createPrototype(JSC::ExecState*, JSC::JSGlobalObject*); + static bool getOwnPropertySlot(JSC::JSCell*, JSC::ExecState*, const JSC::Identifier& propertyName, JSC::PropertySlot&); + static bool getOwnPropertyDescriptor(JSC::JSObject*, JSC::ExecState*, const JSC::Identifier& propertyName, JSC::PropertyDescriptor&); + static bool getOwnPropertySlotByIndex(JSC::JSCell*, JSC::ExecState*, unsigned propertyName, JSC::PropertySlot&); + static void put(JSC::JSCell*, JSC::ExecState*, const JSC::Identifier& propertyName, JSC::JSValue, JSC::PutPropertySlot&); + static void putByIndex(JSC::JSCell*, JSC::ExecState*, unsigned propertyName, JSC::JSValue, bool shouldThrow); + static const JSC::ClassInfo s_info; + + static JSC::Structure* createStructure(JSC::JSGlobalData& globalData, JSC::JSGlobalObject* globalObject, JSC::JSValue prototype) + { + return JSC::Structure::create(globalData, globalObject, prototype, JSC::TypeInfo(JSC::ObjectType, StructureFlags), &s_info); + } + + static void getOwnPropertyNames(JSC::JSObject*, JSC::ExecState*, JSC::PropertyNameArray&, JSC::EnumerationMode mode = JSC::ExcludeDontEnumProperties); + static JSC::JSValue getConstructor(JSC::ExecState*, JSC::JSGlobalObject*); + + // Custom functions + JSC::JSValue set(JSC::ExecState*); + Int8Array* impl() const + { + return static_cast(Base::impl()); + } + static const JSC::TypedArrayType TypedArrayStorageType = JSC::TypedArrayInt8; + intptr_t m_storageLength; + void* m_storage; +protected: + JSInt8Array(JSC::Structure*, JSDOMGlobalObject*, PassRefPtr); + void finishCreation(JSC::JSGlobalData&); + static const unsigned StructureFlags = JSC::OverridesGetPropertyNames | JSC::OverridesGetOwnPropertySlot | Base::StructureFlags; + JSC::JSValue getByIndex(JSC::ExecState*, unsigned index); + void indexSetter(JSC::ExecState*, unsigned index, JSC::JSValue); +}; + +JSC::JSValue toJS(JSC::ExecState*, JSDOMGlobalObject*, Int8Array*); +Int8Array* toInt8Array(JSC::JSValue); + +class JSInt8ArrayPrototype : public JSC::JSNonFinalObject { +public: + typedef JSC::JSNonFinalObject Base; + static JSC::JSObject* self(JSC::ExecState*, JSC::JSGlobalObject*); + static JSInt8ArrayPrototype* create(JSC::JSGlobalData& globalData, JSC::JSGlobalObject* globalObject, JSC::Structure* structure) + { + JSInt8ArrayPrototype* ptr = new (NotNull, JSC::allocateCell(globalData.heap)) JSInt8ArrayPrototype(globalData, globalObject, structure); + ptr->finishCreation(globalData); + return ptr; + } + + static const JSC::ClassInfo s_info; + static bool getOwnPropertySlot(JSC::JSCell*, JSC::ExecState*, const JSC::Identifier&, JSC::PropertySlot&); + static bool getOwnPropertyDescriptor(JSC::JSObject*, JSC::ExecState*, const JSC::Identifier&, JSC::PropertyDescriptor&); + static JSC::Structure* createStructure(JSC::JSGlobalData& globalData, JSC::JSGlobalObject* globalObject, JSC::JSValue prototype) + { + return JSC::Structure::create(globalData, globalObject, prototype, JSC::TypeInfo(JSC::ObjectType, StructureFlags), &s_info); + } + +private: + JSInt8ArrayPrototype(JSC::JSGlobalData& globalData, JSC::JSGlobalObject*, JSC::Structure* structure) : JSC::JSNonFinalObject(globalData, structure) { } +protected: + static const unsigned StructureFlags = JSC::OverridesGetOwnPropertySlot | Base::StructureFlags; +}; + +class JSInt8ArrayConstructor : public DOMConstructorObject { +private: + JSInt8ArrayConstructor(JSC::Structure*, JSDOMGlobalObject*); + void finishCreation(JSC::ExecState*, JSDOMGlobalObject*); + +public: + typedef DOMConstructorObject Base; + static JSInt8ArrayConstructor* create(JSC::ExecState* exec, JSC::Structure* structure, JSDOMGlobalObject* globalObject) + { + JSInt8ArrayConstructor* ptr = new (NotNull, JSC::allocateCell(*exec->heap())) JSInt8ArrayConstructor(structure, globalObject); + ptr->finishCreation(exec, globalObject); + return ptr; + } + + static bool getOwnPropertySlot(JSC::JSCell*, JSC::ExecState*, const JSC::Identifier&, JSC::PropertySlot&); + static bool getOwnPropertyDescriptor(JSC::JSObject*, JSC::ExecState*, const JSC::Identifier&, JSC::PropertyDescriptor&); + static const JSC::ClassInfo s_info; + static JSC::Structure* createStructure(JSC::JSGlobalData& globalData, JSC::JSGlobalObject* globalObject, JSC::JSValue prototype) + { + return JSC::Structure::create(globalData, globalObject, prototype, JSC::TypeInfo(JSC::ObjectType, StructureFlags), &s_info); + } +protected: + static const unsigned StructureFlags = JSC::OverridesGetOwnPropertySlot | JSC::ImplementsHasInstance | DOMConstructorObject::StructureFlags; + static JSC::EncodedJSValue JSC_HOST_CALL constructJSInt8Array(JSC::ExecState*); + static JSC::ConstructType getConstructData(JSC::JSCell*, JSC::ConstructData&); +}; + +// Functions + +JSC::EncodedJSValue JSC_HOST_CALL jsInt8ArrayPrototypeFunctionSubarray(JSC::ExecState*); +JSC::EncodedJSValue JSC_HOST_CALL jsInt8ArrayPrototypeFunctionSet(JSC::ExecState*); +// Attributes + +JSC::JSValue jsInt8ArrayLength(JSC::ExecState*, JSC::JSValue, const JSC::Identifier&); +JSC::JSValue jsInt8ArrayConstructor(JSC::ExecState*, JSC::JSValue, const JSC::Identifier&); +// Constants + +JSC::JSValue jsInt8ArrayBYTES_PER_ELEMENT(JSC::ExecState*, JSC::JSValue, const JSC::Identifier&); + +} // namespace WebCore + +#endif diff --git a/JavaScriptCore/runtime/TypedArrays/JSInt8ArrayCustom.cpp b/JavaScriptCore/runtime/TypedArrays/JSInt8ArrayCustom.cpp new file mode 100644 index 00000000..b6e15076 --- /dev/null +++ b/JavaScriptCore/runtime/TypedArrays/JSInt8ArrayCustom.cpp @@ -0,0 +1,62 @@ +/* + * Copyright (C) 2009 Apple Inc. All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY APPLE COMPUTER, INC. ``AS IS'' AND ANY + * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR + * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE COMPUTER, INC. OR + * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, + * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, + * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR + * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY + * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE + * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + */ + +#include "config.h" +#include "JSInt8Array.h" + +#include "JSArrayBufferViewHelper.h" +#include +#include + +using namespace JSC; + +namespace WebCore { + +void JSInt8Array::indexSetter(JSC::ExecState* exec, unsigned index, JSC::JSValue value) +{ + impl()->set(index, static_cast(value.toInt32(exec))); +} + +JSC::JSValue toJS(JSC::ExecState* exec, JSDOMGlobalObject* globalObject, Int8Array* object) +{ + return toJSArrayBufferView(exec, globalObject, object); +} + +JSC::JSValue JSInt8Array::set(JSC::ExecState* exec) +{ + return setWebGLArrayHelper(exec, impl(), toInt8Array); +} + +EncodedJSValue JSC_HOST_CALL JSInt8ArrayConstructor::constructJSInt8Array(ExecState* exec) +{ + JSInt8ArrayConstructor* jsConstructor = jsCast(exec->callee()); + RefPtr array = constructArrayBufferView(exec); + if (!array.get()) + // Exception has already been thrown. + return JSValue::encode(JSValue()); + return JSValue::encode(asObject(toJS(exec, jsConstructor->globalObject(), array.get()))); +} + +} // namespace WebCore diff --git a/JavaScriptCore/runtime/TypedArrays/JSUint16Array.cpp b/JavaScriptCore/runtime/TypedArrays/JSUint16Array.cpp new file mode 100644 index 00000000..0261e90f --- /dev/null +++ b/JavaScriptCore/runtime/TypedArrays/JSUint16Array.cpp @@ -0,0 +1,297 @@ +/* + 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 "JSUint16Array.h" + +#include "ExceptionCode.h" +#include "JSDOMBinding.h" +#include "JSUint16Array.h" +#include +#include +#include +#include + +using namespace JSC; + +namespace WebCore { + +ASSERT_CLASS_FITS_IN_CELL(JSUint16Array); +/* Hash table */ + +static const HashTableValue JSUint16ArrayTableValues[] = +{ + { "length", DontDelete | ReadOnly, (intptr_t)static_cast(jsUint16ArrayLength), (intptr_t)0, NoIntrinsic }, + { "constructor", DontEnum | ReadOnly, (intptr_t)static_cast(jsUint16ArrayConstructor), (intptr_t)0, NoIntrinsic }, + { 0, 0, 0, 0, NoIntrinsic } +}; + +static const HashTable JSUint16ArrayTable = { 5, 3, JSUint16ArrayTableValues, 0 }; +/* Hash table for constructor */ + +static const HashTableValue JSUint16ArrayConstructorTableValues[] = +{ + { "BYTES_PER_ELEMENT", DontDelete | ReadOnly, (intptr_t)static_cast(jsUint16ArrayBYTES_PER_ELEMENT), (intptr_t)0, NoIntrinsic }, + { 0, 0, 0, 0, NoIntrinsic } +}; + +static const HashTable JSUint16ArrayConstructorTable = { 2, 1, JSUint16ArrayConstructorTableValues, 0 }; +const ClassInfo JSUint16ArrayConstructor::s_info = { "Uint16ArrayConstructor", &Base::s_info, &JSUint16ArrayConstructorTable, 0, CREATE_METHOD_TABLE(JSUint16ArrayConstructor) }; + +JSUint16ArrayConstructor::JSUint16ArrayConstructor(Structure* structure, JSDOMGlobalObject* globalObject) + : DOMConstructorObject(structure, globalObject) +{ +} + +void JSUint16ArrayConstructor::finishCreation(ExecState* exec, JSDOMGlobalObject* globalObject) +{ + Base::finishCreation(exec->globalData()); + ASSERT(inherits(&s_info)); + putDirect(exec->globalData(), exec->propertyNames().prototype, JSUint16ArrayPrototype::self(exec, globalObject), DontDelete | ReadOnly); + putDirect(exec->globalData(), exec->propertyNames().length, jsNumber(1), ReadOnly | DontDelete | DontEnum); +} + +bool JSUint16ArrayConstructor::getOwnPropertySlot(JSCell* cell, ExecState* exec, const Identifier& propertyName, PropertySlot& slot) +{ + return getStaticValueSlot(exec, &JSUint16ArrayConstructorTable, jsCast(cell), propertyName, slot); +} + +bool JSUint16ArrayConstructor::getOwnPropertyDescriptor(JSObject* object, ExecState* exec, const Identifier& propertyName, PropertyDescriptor& descriptor) +{ + return getStaticValueDescriptor(exec, &JSUint16ArrayConstructorTable, jsCast(object), propertyName, descriptor); +} + +ConstructType JSUint16ArrayConstructor::getConstructData(JSCell*, ConstructData& constructData) +{ + constructData.native.function = constructJSUint16Array; + return ConstructTypeHost; +} + +/* Hash table for prototype */ + +static const HashTableValue JSUint16ArrayPrototypeTableValues[] = +{ + { "BYTES_PER_ELEMENT", DontDelete | ReadOnly, (intptr_t)static_cast(jsUint16ArrayBYTES_PER_ELEMENT), (intptr_t)0, NoIntrinsic }, + { "subarray", DontDelete | JSC::Function, (intptr_t)static_cast(jsUint16ArrayPrototypeFunctionSubarray), (intptr_t)2, NoIntrinsic }, + { "set", DontDelete | JSC::Function, (intptr_t)static_cast(jsUint16ArrayPrototypeFunctionSet), (intptr_t)0, NoIntrinsic }, + { 0, 0, 0, 0, NoIntrinsic } +}; + +static const HashTable JSUint16ArrayPrototypeTable = { 8, 7, JSUint16ArrayPrototypeTableValues, 0 }; +static const HashTable* getJSUint16ArrayPrototypeTable(ExecState* exec) +{ + return getHashTableForGlobalData(exec->globalData(), &JSUint16ArrayPrototypeTable); +} + +const ClassInfo JSUint16ArrayPrototype::s_info = { "Uint16ArrayPrototype", &Base::s_info, 0, getJSUint16ArrayPrototypeTable, CREATE_METHOD_TABLE(JSUint16ArrayPrototype) }; + +JSObject* JSUint16ArrayPrototype::self(ExecState* exec, JSGlobalObject* globalObject) +{ + return getDOMPrototype(exec, globalObject); +} + +bool JSUint16ArrayPrototype::getOwnPropertySlot(JSCell* cell, ExecState* exec, const Identifier& propertyName, PropertySlot& slot) +{ + JSUint16ArrayPrototype* thisObject = jsCast(cell); + return getStaticPropertySlot(exec, getJSUint16ArrayPrototypeTable(exec), thisObject, propertyName, slot); +} + +bool JSUint16ArrayPrototype::getOwnPropertyDescriptor(JSObject* object, ExecState* exec, const Identifier& propertyName, PropertyDescriptor& descriptor) +{ + JSUint16ArrayPrototype* thisObject = jsCast(object); + return getStaticPropertyDescriptor(exec, getJSUint16ArrayPrototypeTable(exec), thisObject, propertyName, descriptor); +} + +static const HashTable* getJSUint16ArrayTable(ExecState* exec) +{ + return getHashTableForGlobalData(exec->globalData(), &JSUint16ArrayTable); +} + +const ClassInfo JSUint16Array::s_info = { "Uint16Array", &Base::s_info, 0, getJSUint16ArrayTable , CREATE_METHOD_TABLE(JSUint16Array) }; + +JSUint16Array::JSUint16Array(Structure* structure, JSDOMGlobalObject* globalObject, PassRefPtr impl) + : JSArrayBufferView(structure, globalObject, impl) +{ +} + +void JSUint16Array::finishCreation(JSGlobalData& globalData) +{ + Base::finishCreation(globalData); + TypedArrayDescriptor descriptor(&JSUint16Array::s_info, OBJECT_OFFSETOF(JSUint16Array, m_storage), OBJECT_OFFSETOF(JSUint16Array, m_storageLength)); + globalData.registerTypedArrayDescriptor(impl(), descriptor); + m_storage = impl()->data(); + m_storageLength = impl()->length(); + ASSERT(inherits(&s_info)); +} + +JSObject* JSUint16Array::createPrototype(ExecState* exec, JSGlobalObject* globalObject) +{ + return JSUint16ArrayPrototype::create(exec->globalData(), globalObject, JSUint16ArrayPrototype::createStructure(exec->globalData(), globalObject, JSArrayBufferViewPrototype::self(exec, globalObject))); +} + +bool JSUint16Array::getOwnPropertySlot(JSCell* cell, ExecState* exec, const Identifier& propertyName, PropertySlot& slot) +{ + JSUint16Array* thisObject = jsCast(cell); + ASSERT_GC_OBJECT_INHERITS(thisObject, &s_info); + bool ok; + unsigned index = propertyName.toUInt32(ok); + if (ok && index < static_cast(thisObject->impl())->length()) { + slot.setValue(thisObject->getByIndex(exec, index)); + return true; + } + return getStaticValueSlot(exec, getJSUint16ArrayTable(exec), thisObject, propertyName, slot); +} + +bool JSUint16Array::getOwnPropertyDescriptor(JSObject* object, ExecState* exec, const Identifier& propertyName, PropertyDescriptor& descriptor) +{ + JSUint16Array* thisObject = jsCast(object); + ASSERT_GC_OBJECT_INHERITS(thisObject, &s_info); + bool ok; + unsigned index = propertyName.toUInt32(ok); + if (ok && index < static_cast(thisObject->impl())->length()) { + descriptor.setDescriptor(thisObject->getByIndex(exec, index), DontDelete); + return true; + } + return getStaticValueDescriptor(exec, getJSUint16ArrayTable(exec), thisObject, propertyName, descriptor); +} + +bool JSUint16Array::getOwnPropertySlotByIndex(JSCell* cell, ExecState* exec, unsigned propertyName, PropertySlot& slot) +{ + JSUint16Array* thisObject = jsCast(cell); + ASSERT_GC_OBJECT_INHERITS(thisObject, &s_info); + if (propertyName < static_cast(thisObject->impl())->length()) { + slot.setValue(thisObject->getByIndex(exec, propertyName)); + return true; + } + return thisObject->methodTable()->getOwnPropertySlot(thisObject, exec, Identifier::from(exec, propertyName), slot); +} + +JSValue jsUint16ArrayLength(ExecState* exec, JSValue slotBase, const Identifier&) +{ + JSUint16Array* castedThis = jsCast(asObject(slotBase)); + UNUSED_PARAM(exec); + Uint16Array* impl = static_cast(castedThis->impl()); + JSValue result = jsNumber(impl->length()); + return result; +} + + +JSValue jsUint16ArrayConstructor(ExecState* exec, JSValue slotBase, const Identifier&) +{ + JSUint16Array* domObject = jsCast(asObject(slotBase)); + return JSUint16Array::getConstructor(exec, domObject->globalObject()); +} + +void JSUint16Array::put(JSCell* cell, ExecState* exec, const Identifier& propertyName, JSValue value, PutPropertySlot& slot) +{ + JSUint16Array* thisObject = jsCast(cell); + ASSERT_GC_OBJECT_INHERITS(thisObject, &s_info); + bool ok; + unsigned index = propertyName.toUInt32(ok); + if (ok) { + thisObject->indexSetter(exec, index, value); + return; + } + Base::put(thisObject, exec, propertyName, value, slot); +} + +void JSUint16Array::putByIndex(JSCell* cell, ExecState* exec, unsigned propertyName, JSValue value, bool) +{ + JSUint16Array* thisObject = jsCast(cell); + ASSERT_GC_OBJECT_INHERITS(thisObject, &s_info); + thisObject->indexSetter(exec, propertyName, value); + return; +} + +void JSUint16Array::getOwnPropertyNames(JSObject* object, ExecState* exec, PropertyNameArray& propertyNames, EnumerationMode mode) +{ + JSUint16Array* thisObject = jsCast(object); + ASSERT_GC_OBJECT_INHERITS(thisObject, &s_info); + for (unsigned i = 0; i < static_cast(thisObject->impl())->length(); ++i) + propertyNames.add(Identifier::from(exec, i)); + Base::getOwnPropertyNames(thisObject, exec, propertyNames, mode); +} + +JSValue JSUint16Array::getConstructor(ExecState* exec, JSGlobalObject* globalObject) +{ + return getDOMConstructor(exec, jsCast(globalObject)); +} + +EncodedJSValue JSC_HOST_CALL jsUint16ArrayPrototypeFunctionSubarray(ExecState* exec) +{ + JSValue thisValue = exec->hostThisValue(); + if (!thisValue.inherits(&JSUint16Array::s_info)) + return throwVMTypeError(exec); + JSUint16Array* castedThis = jsCast(asObject(thisValue)); + ASSERT_GC_OBJECT_INHERITS(castedThis, &JSUint16Array::s_info); + Uint16Array* impl = static_cast(castedThis->impl()); + int start(MAYBE_MISSING_PARAMETER(exec, 0, DefaultIsUndefined).toInt32(exec)); + if (exec->hadException()) + return JSValue::encode(jsUndefined()); + + size_t argsCount = exec->argumentCount(); + if (argsCount <= 1) { + + JSC::JSValue result = toJS(exec, castedThis->globalObject(), WTF::getPtr(impl->subarray(start))); + return JSValue::encode(result); + } + + int end(MAYBE_MISSING_PARAMETER(exec, 1, DefaultIsUndefined).toInt32(exec)); + if (exec->hadException()) + return JSValue::encode(jsUndefined()); + + JSC::JSValue result = toJS(exec, castedThis->globalObject(), WTF::getPtr(impl->subarray(start, end))); + return JSValue::encode(result); +} + +EncodedJSValue JSC_HOST_CALL jsUint16ArrayPrototypeFunctionSet(ExecState* exec) +{ + JSValue thisValue = exec->hostThisValue(); + if (!thisValue.inherits(&JSUint16Array::s_info)) + return throwVMTypeError(exec); + JSUint16Array* castedThis = jsCast(asObject(thisValue)); + ASSERT_GC_OBJECT_INHERITS(castedThis, &JSUint16Array::s_info); + return JSValue::encode(castedThis->set(exec)); +} + +// Constant getters + +JSValue jsUint16ArrayBYTES_PER_ELEMENT(ExecState* exec, JSValue, const Identifier&) +{ + UNUSED_PARAM(exec); + return jsNumber(static_cast(2)); +} + + +JSValue JSUint16Array::getByIndex(ExecState*, unsigned index) +{ + ASSERT_GC_OBJECT_INHERITS(this, &s_info); + double result = static_cast(impl())->item(index); + if (isnan(result)) + return jsNaN(); + return JSValue(result); +} + +Uint16Array* toUint16Array(JSC::JSValue value) +{ + return value.inherits(&JSUint16Array::s_info) ? jsCast(asObject(value))->impl() : 0; +} + +} diff --git a/JavaScriptCore/runtime/TypedArrays/JSUint16Array.h b/JavaScriptCore/runtime/TypedArrays/JSUint16Array.h new file mode 100644 index 00000000..b70f9af3 --- /dev/null +++ b/JavaScriptCore/runtime/TypedArrays/JSUint16Array.h @@ -0,0 +1,143 @@ +/* + 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. +*/ + +#ifndef JSUint16Array_h +#define JSUint16Array_h + +#include "JSArrayBufferView.h" +#include "JSDOMBinding.h" +#include +#include + +namespace WebCore { + +class JSUint16Array : public JSArrayBufferView { +public: + typedef JSArrayBufferView Base; + static JSUint16Array* create(JSC::Structure* structure, JSDOMGlobalObject* globalObject, PassRefPtr impl) + { + JSUint16Array* ptr = new (NotNull, JSC::allocateCell(globalObject->globalData().heap)) JSUint16Array(structure, globalObject, impl); + ptr->finishCreation(globalObject->globalData()); + return ptr; + } + + static JSC::JSObject* createPrototype(JSC::ExecState*, JSC::JSGlobalObject*); + static bool getOwnPropertySlot(JSC::JSCell*, JSC::ExecState*, const JSC::Identifier& propertyName, JSC::PropertySlot&); + static bool getOwnPropertyDescriptor(JSC::JSObject*, JSC::ExecState*, const JSC::Identifier& propertyName, JSC::PropertyDescriptor&); + static bool getOwnPropertySlotByIndex(JSC::JSCell*, JSC::ExecState*, unsigned propertyName, JSC::PropertySlot&); + static void put(JSC::JSCell*, JSC::ExecState*, const JSC::Identifier& propertyName, JSC::JSValue, JSC::PutPropertySlot&); + static void putByIndex(JSC::JSCell*, JSC::ExecState*, unsigned propertyName, JSC::JSValue, bool shouldThrow); + static const JSC::ClassInfo s_info; + + static JSC::Structure* createStructure(JSC::JSGlobalData& globalData, JSC::JSGlobalObject* globalObject, JSC::JSValue prototype) + { + return JSC::Structure::create(globalData, globalObject, prototype, JSC::TypeInfo(JSC::ObjectType, StructureFlags), &s_info); + } + + static void getOwnPropertyNames(JSC::JSObject*, JSC::ExecState*, JSC::PropertyNameArray&, JSC::EnumerationMode mode = JSC::ExcludeDontEnumProperties); + static JSC::JSValue getConstructor(JSC::ExecState*, JSC::JSGlobalObject*); + + // Custom functions + JSC::JSValue set(JSC::ExecState*); + Uint16Array* impl() const + { + return static_cast(Base::impl()); + } + static const JSC::TypedArrayType TypedArrayStorageType = JSC::TypedArrayUint16; + intptr_t m_storageLength; + void* m_storage; +protected: + JSUint16Array(JSC::Structure*, JSDOMGlobalObject*, PassRefPtr); + void finishCreation(JSC::JSGlobalData&); + static const unsigned StructureFlags = JSC::OverridesGetPropertyNames | JSC::OverridesGetOwnPropertySlot | Base::StructureFlags; + JSC::JSValue getByIndex(JSC::ExecState*, unsigned index); + void indexSetter(JSC::ExecState*, unsigned index, JSC::JSValue); +}; + +JSC::JSValue toJS(JSC::ExecState*, JSDOMGlobalObject*, Uint16Array*); +Uint16Array* toUint16Array(JSC::JSValue); + +class JSUint16ArrayPrototype : public JSC::JSNonFinalObject { +public: + typedef JSC::JSNonFinalObject Base; + static JSC::JSObject* self(JSC::ExecState*, JSC::JSGlobalObject*); + static JSUint16ArrayPrototype* create(JSC::JSGlobalData& globalData, JSC::JSGlobalObject* globalObject, JSC::Structure* structure) + { + JSUint16ArrayPrototype* ptr = new (NotNull, JSC::allocateCell(globalData.heap)) JSUint16ArrayPrototype(globalData, globalObject, structure); + ptr->finishCreation(globalData); + return ptr; + } + + static const JSC::ClassInfo s_info; + static bool getOwnPropertySlot(JSC::JSCell*, JSC::ExecState*, const JSC::Identifier&, JSC::PropertySlot&); + static bool getOwnPropertyDescriptor(JSC::JSObject*, JSC::ExecState*, const JSC::Identifier&, JSC::PropertyDescriptor&); + static JSC::Structure* createStructure(JSC::JSGlobalData& globalData, JSC::JSGlobalObject* globalObject, JSC::JSValue prototype) + { + return JSC::Structure::create(globalData, globalObject, prototype, JSC::TypeInfo(JSC::ObjectType, StructureFlags), &s_info); + } + +private: + JSUint16ArrayPrototype(JSC::JSGlobalData& globalData, JSC::JSGlobalObject*, JSC::Structure* structure) : JSC::JSNonFinalObject(globalData, structure) { } +protected: + static const unsigned StructureFlags = JSC::OverridesGetOwnPropertySlot | Base::StructureFlags; +}; + +class JSUint16ArrayConstructor : public DOMConstructorObject { +private: + JSUint16ArrayConstructor(JSC::Structure*, JSDOMGlobalObject*); + void finishCreation(JSC::ExecState*, JSDOMGlobalObject*); + +public: + typedef DOMConstructorObject Base; + static JSUint16ArrayConstructor* create(JSC::ExecState* exec, JSC::Structure* structure, JSDOMGlobalObject* globalObject) + { + JSUint16ArrayConstructor* ptr = new (NotNull, JSC::allocateCell(*exec->heap())) JSUint16ArrayConstructor(structure, globalObject); + ptr->finishCreation(exec, globalObject); + return ptr; + } + + static bool getOwnPropertySlot(JSC::JSCell*, JSC::ExecState*, const JSC::Identifier&, JSC::PropertySlot&); + static bool getOwnPropertyDescriptor(JSC::JSObject*, JSC::ExecState*, const JSC::Identifier&, JSC::PropertyDescriptor&); + static const JSC::ClassInfo s_info; + static JSC::Structure* createStructure(JSC::JSGlobalData& globalData, JSC::JSGlobalObject* globalObject, JSC::JSValue prototype) + { + return JSC::Structure::create(globalData, globalObject, prototype, JSC::TypeInfo(JSC::ObjectType, StructureFlags), &s_info); + } +protected: + static const unsigned StructureFlags = JSC::OverridesGetOwnPropertySlot | JSC::ImplementsHasInstance | DOMConstructorObject::StructureFlags; + static JSC::EncodedJSValue JSC_HOST_CALL constructJSUint16Array(JSC::ExecState*); + static JSC::ConstructType getConstructData(JSC::JSCell*, JSC::ConstructData&); +}; + +// Functions + +JSC::EncodedJSValue JSC_HOST_CALL jsUint16ArrayPrototypeFunctionSubarray(JSC::ExecState*); +JSC::EncodedJSValue JSC_HOST_CALL jsUint16ArrayPrototypeFunctionSet(JSC::ExecState*); +// Attributes + +JSC::JSValue jsUint16ArrayLength(JSC::ExecState*, JSC::JSValue, const JSC::Identifier&); +JSC::JSValue jsUint16ArrayConstructor(JSC::ExecState*, JSC::JSValue, const JSC::Identifier&); +// Constants + +JSC::JSValue jsUint16ArrayBYTES_PER_ELEMENT(JSC::ExecState*, JSC::JSValue, const JSC::Identifier&); + +} // namespace WebCore + +#endif diff --git a/JavaScriptCore/runtime/TypedArrays/JSUint16ArrayCustom.cpp b/JavaScriptCore/runtime/TypedArrays/JSUint16ArrayCustom.cpp new file mode 100644 index 00000000..47b4402b --- /dev/null +++ b/JavaScriptCore/runtime/TypedArrays/JSUint16ArrayCustom.cpp @@ -0,0 +1,61 @@ +/* + * Copyright (C) 2009 Apple Inc. All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY APPLE COMPUTER, INC. ``AS IS'' AND ANY + * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR + * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE COMPUTER, INC. OR + * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, + * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, + * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR + * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY + * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE + * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + */ + +#include "config.h" +#include "JSUint16Array.h" + +#include "JSArrayBufferViewHelper.h" +#include + +using namespace JSC; + +namespace WebCore { + +void JSUint16Array::indexSetter(JSC::ExecState* exec, unsigned index, JSC::JSValue value) +{ + impl()->set(index, static_cast(value.toInt32(exec))); +} + +JSC::JSValue toJS(JSC::ExecState* exec, JSDOMGlobalObject* globalObject, Uint16Array* object) +{ + return toJSArrayBufferView(exec, globalObject, object); +} + +JSC::JSValue JSUint16Array::set(JSC::ExecState* exec) +{ + return setWebGLArrayHelper(exec, impl(), toUint16Array); +} + +EncodedJSValue JSC_HOST_CALL JSUint16ArrayConstructor::constructJSUint16Array(ExecState* exec) +{ + JSUint16ArrayConstructor* jsConstructor = jsCast(exec->callee()); + RefPtr array = constructArrayBufferView(exec); + if (!array.get()) + // Exception has already been thrown. + return JSValue::encode(JSValue()); + return JSValue::encode(asObject(toJS(exec, jsConstructor->globalObject(), array.get()))); +} + +} // namespace WebCore diff --git a/JavaScriptCore/runtime/TypedArrays/JSUint32Array.cpp b/JavaScriptCore/runtime/TypedArrays/JSUint32Array.cpp new file mode 100644 index 00000000..5e8b9555 --- /dev/null +++ b/JavaScriptCore/runtime/TypedArrays/JSUint32Array.cpp @@ -0,0 +1,297 @@ +/* + 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 "JSUint32Array.h" + +#include "ExceptionCode.h" +#include "JSDOMBinding.h" +#include "JSUint32Array.h" +#include +#include +#include +#include + +using namespace JSC; + +namespace WebCore { + +ASSERT_CLASS_FITS_IN_CELL(JSUint32Array); +/* Hash table */ + +static const HashTableValue JSUint32ArrayTableValues[] = +{ + { "length", DontDelete | ReadOnly, (intptr_t)static_cast(jsUint32ArrayLength), (intptr_t)0, NoIntrinsic }, + { "constructor", DontEnum | ReadOnly, (intptr_t)static_cast(jsUint32ArrayConstructor), (intptr_t)0, NoIntrinsic }, + { 0, 0, 0, 0, NoIntrinsic } +}; + +static const HashTable JSUint32ArrayTable = { 5, 3, JSUint32ArrayTableValues, 0 }; +/* Hash table for constructor */ + +static const HashTableValue JSUint32ArrayConstructorTableValues[] = +{ + { "BYTES_PER_ELEMENT", DontDelete | ReadOnly, (intptr_t)static_cast(jsUint32ArrayBYTES_PER_ELEMENT), (intptr_t)0, NoIntrinsic }, + { 0, 0, 0, 0, NoIntrinsic } +}; + +static const HashTable JSUint32ArrayConstructorTable = { 2, 1, JSUint32ArrayConstructorTableValues, 0 }; +const ClassInfo JSUint32ArrayConstructor::s_info = { "Uint32ArrayConstructor", &Base::s_info, &JSUint32ArrayConstructorTable, 0, CREATE_METHOD_TABLE(JSUint32ArrayConstructor) }; + +JSUint32ArrayConstructor::JSUint32ArrayConstructor(Structure* structure, JSDOMGlobalObject* globalObject) + : DOMConstructorObject(structure, globalObject) +{ +} + +void JSUint32ArrayConstructor::finishCreation(ExecState* exec, JSDOMGlobalObject* globalObject) +{ + Base::finishCreation(exec->globalData()); + ASSERT(inherits(&s_info)); + putDirect(exec->globalData(), exec->propertyNames().prototype, JSUint32ArrayPrototype::self(exec, globalObject), DontDelete | ReadOnly); + putDirect(exec->globalData(), exec->propertyNames().length, jsNumber(1), ReadOnly | DontDelete | DontEnum); +} + +bool JSUint32ArrayConstructor::getOwnPropertySlot(JSCell* cell, ExecState* exec, const Identifier& propertyName, PropertySlot& slot) +{ + return getStaticValueSlot(exec, &JSUint32ArrayConstructorTable, jsCast(cell), propertyName, slot); +} + +bool JSUint32ArrayConstructor::getOwnPropertyDescriptor(JSObject* object, ExecState* exec, const Identifier& propertyName, PropertyDescriptor& descriptor) +{ + return getStaticValueDescriptor(exec, &JSUint32ArrayConstructorTable, jsCast(object), propertyName, descriptor); +} + +ConstructType JSUint32ArrayConstructor::getConstructData(JSCell*, ConstructData& constructData) +{ + constructData.native.function = constructJSUint32Array; + return ConstructTypeHost; +} + +/* Hash table for prototype */ + +static const HashTableValue JSUint32ArrayPrototypeTableValues[] = +{ + { "BYTES_PER_ELEMENT", DontDelete | ReadOnly, (intptr_t)static_cast(jsUint32ArrayBYTES_PER_ELEMENT), (intptr_t)0, NoIntrinsic }, + { "subarray", DontDelete | JSC::Function, (intptr_t)static_cast(jsUint32ArrayPrototypeFunctionSubarray), (intptr_t)2, NoIntrinsic }, + { "set", DontDelete | JSC::Function, (intptr_t)static_cast(jsUint32ArrayPrototypeFunctionSet), (intptr_t)0, NoIntrinsic }, + { 0, 0, 0, 0, NoIntrinsic } +}; + +static const HashTable JSUint32ArrayPrototypeTable = { 8, 7, JSUint32ArrayPrototypeTableValues, 0 }; +static const HashTable* getJSUint32ArrayPrototypeTable(ExecState* exec) +{ + return getHashTableForGlobalData(exec->globalData(), &JSUint32ArrayPrototypeTable); +} + +const ClassInfo JSUint32ArrayPrototype::s_info = { "Uint32ArrayPrototype", &Base::s_info, 0, getJSUint32ArrayPrototypeTable, CREATE_METHOD_TABLE(JSUint32ArrayPrototype) }; + +JSObject* JSUint32ArrayPrototype::self(ExecState* exec, JSGlobalObject* globalObject) +{ + return getDOMPrototype(exec, globalObject); +} + +bool JSUint32ArrayPrototype::getOwnPropertySlot(JSCell* cell, ExecState* exec, const Identifier& propertyName, PropertySlot& slot) +{ + JSUint32ArrayPrototype* thisObject = jsCast(cell); + return getStaticPropertySlot(exec, getJSUint32ArrayPrototypeTable(exec), thisObject, propertyName, slot); +} + +bool JSUint32ArrayPrototype::getOwnPropertyDescriptor(JSObject* object, ExecState* exec, const Identifier& propertyName, PropertyDescriptor& descriptor) +{ + JSUint32ArrayPrototype* thisObject = jsCast(object); + return getStaticPropertyDescriptor(exec, getJSUint32ArrayPrototypeTable(exec), thisObject, propertyName, descriptor); +} + +static const HashTable* getJSUint32ArrayTable(ExecState* exec) +{ + return getHashTableForGlobalData(exec->globalData(), &JSUint32ArrayTable); +} + +const ClassInfo JSUint32Array::s_info = { "Uint32Array", &Base::s_info, 0, getJSUint32ArrayTable , CREATE_METHOD_TABLE(JSUint32Array) }; + +JSUint32Array::JSUint32Array(Structure* structure, JSDOMGlobalObject* globalObject, PassRefPtr impl) + : JSArrayBufferView(structure, globalObject, impl) +{ +} + +void JSUint32Array::finishCreation(JSGlobalData& globalData) +{ + Base::finishCreation(globalData); + TypedArrayDescriptor descriptor(&JSUint32Array::s_info, OBJECT_OFFSETOF(JSUint32Array, m_storage), OBJECT_OFFSETOF(JSUint32Array, m_storageLength)); + globalData.registerTypedArrayDescriptor(impl(), descriptor); + m_storage = impl()->data(); + m_storageLength = impl()->length(); + ASSERT(inherits(&s_info)); +} + +JSObject* JSUint32Array::createPrototype(ExecState* exec, JSGlobalObject* globalObject) +{ + return JSUint32ArrayPrototype::create(exec->globalData(), globalObject, JSUint32ArrayPrototype::createStructure(exec->globalData(), globalObject, JSArrayBufferViewPrototype::self(exec, globalObject))); +} + +bool JSUint32Array::getOwnPropertySlot(JSCell* cell, ExecState* exec, const Identifier& propertyName, PropertySlot& slot) +{ + JSUint32Array* thisObject = jsCast(cell); + ASSERT_GC_OBJECT_INHERITS(thisObject, &s_info); + bool ok; + unsigned index = propertyName.toUInt32(ok); + if (ok && index < static_cast(thisObject->impl())->length()) { + slot.setValue(thisObject->getByIndex(exec, index)); + return true; + } + return getStaticValueSlot(exec, getJSUint32ArrayTable(exec), thisObject, propertyName, slot); +} + +bool JSUint32Array::getOwnPropertyDescriptor(JSObject* object, ExecState* exec, const Identifier& propertyName, PropertyDescriptor& descriptor) +{ + JSUint32Array* thisObject = jsCast(object); + ASSERT_GC_OBJECT_INHERITS(thisObject, &s_info); + bool ok; + unsigned index = propertyName.toUInt32(ok); + if (ok && index < static_cast(thisObject->impl())->length()) { + descriptor.setDescriptor(thisObject->getByIndex(exec, index), DontDelete); + return true; + } + return getStaticValueDescriptor(exec, getJSUint32ArrayTable(exec), thisObject, propertyName, descriptor); +} + +bool JSUint32Array::getOwnPropertySlotByIndex(JSCell* cell, ExecState* exec, unsigned propertyName, PropertySlot& slot) +{ + JSUint32Array* thisObject = jsCast(cell); + ASSERT_GC_OBJECT_INHERITS(thisObject, &s_info); + if (propertyName < static_cast(thisObject->impl())->length()) { + slot.setValue(thisObject->getByIndex(exec, propertyName)); + return true; + } + return thisObject->methodTable()->getOwnPropertySlot(thisObject, exec, Identifier::from(exec, propertyName), slot); +} + +JSValue jsUint32ArrayLength(ExecState* exec, JSValue slotBase, const Identifier&) +{ + JSUint32Array* castedThis = jsCast(asObject(slotBase)); + UNUSED_PARAM(exec); + Uint32Array* impl = static_cast(castedThis->impl()); + JSValue result = jsNumber(impl->length()); + return result; +} + + +JSValue jsUint32ArrayConstructor(ExecState* exec, JSValue slotBase, const Identifier&) +{ + JSUint32Array* domObject = jsCast(asObject(slotBase)); + return JSUint32Array::getConstructor(exec, domObject->globalObject()); +} + +void JSUint32Array::put(JSCell* cell, ExecState* exec, const Identifier& propertyName, JSValue value, PutPropertySlot& slot) +{ + JSUint32Array* thisObject = jsCast(cell); + ASSERT_GC_OBJECT_INHERITS(thisObject, &s_info); + bool ok; + unsigned index = propertyName.toUInt32(ok); + if (ok) { + thisObject->indexSetter(exec, index, value); + return; + } + Base::put(thisObject, exec, propertyName, value, slot); +} + +void JSUint32Array::putByIndex(JSCell* cell, ExecState* exec, unsigned propertyName, JSValue value, bool) +{ + JSUint32Array* thisObject = jsCast(cell); + ASSERT_GC_OBJECT_INHERITS(thisObject, &s_info); + thisObject->indexSetter(exec, propertyName, value); + return; +} + +void JSUint32Array::getOwnPropertyNames(JSObject* object, ExecState* exec, PropertyNameArray& propertyNames, EnumerationMode mode) +{ + JSUint32Array* thisObject = jsCast(object); + ASSERT_GC_OBJECT_INHERITS(thisObject, &s_info); + for (unsigned i = 0; i < static_cast(thisObject->impl())->length(); ++i) + propertyNames.add(Identifier::from(exec, i)); + Base::getOwnPropertyNames(thisObject, exec, propertyNames, mode); +} + +JSValue JSUint32Array::getConstructor(ExecState* exec, JSGlobalObject* globalObject) +{ + return getDOMConstructor(exec, jsCast(globalObject)); +} + +EncodedJSValue JSC_HOST_CALL jsUint32ArrayPrototypeFunctionSubarray(ExecState* exec) +{ + JSValue thisValue = exec->hostThisValue(); + if (!thisValue.inherits(&JSUint32Array::s_info)) + return throwVMTypeError(exec); + JSUint32Array* castedThis = jsCast(asObject(thisValue)); + ASSERT_GC_OBJECT_INHERITS(castedThis, &JSUint32Array::s_info); + Uint32Array* impl = static_cast(castedThis->impl()); + int start(MAYBE_MISSING_PARAMETER(exec, 0, DefaultIsUndefined).toInt32(exec)); + if (exec->hadException()) + return JSValue::encode(jsUndefined()); + + size_t argsCount = exec->argumentCount(); + if (argsCount <= 1) { + + JSC::JSValue result = toJS(exec, castedThis->globalObject(), WTF::getPtr(impl->subarray(start))); + return JSValue::encode(result); + } + + int end(MAYBE_MISSING_PARAMETER(exec, 1, DefaultIsUndefined).toInt32(exec)); + if (exec->hadException()) + return JSValue::encode(jsUndefined()); + + JSC::JSValue result = toJS(exec, castedThis->globalObject(), WTF::getPtr(impl->subarray(start, end))); + return JSValue::encode(result); +} + +EncodedJSValue JSC_HOST_CALL jsUint32ArrayPrototypeFunctionSet(ExecState* exec) +{ + JSValue thisValue = exec->hostThisValue(); + if (!thisValue.inherits(&JSUint32Array::s_info)) + return throwVMTypeError(exec); + JSUint32Array* castedThis = jsCast(asObject(thisValue)); + ASSERT_GC_OBJECT_INHERITS(castedThis, &JSUint32Array::s_info); + return JSValue::encode(castedThis->set(exec)); +} + +// Constant getters + +JSValue jsUint32ArrayBYTES_PER_ELEMENT(ExecState* exec, JSValue, const Identifier&) +{ + UNUSED_PARAM(exec); + return jsNumber(static_cast(4)); +} + + +JSValue JSUint32Array::getByIndex(ExecState*, unsigned index) +{ + ASSERT_GC_OBJECT_INHERITS(this, &s_info); + double result = static_cast(impl())->item(index); + if (isnan(result)) + return jsNaN(); + return JSValue(result); +} + +Uint32Array* toUint32Array(JSC::JSValue value) +{ + return value.inherits(&JSUint32Array::s_info) ? jsCast(asObject(value))->impl() : 0; +} + +} diff --git a/JavaScriptCore/runtime/TypedArrays/JSUint32Array.h b/JavaScriptCore/runtime/TypedArrays/JSUint32Array.h new file mode 100644 index 00000000..f905e540 --- /dev/null +++ b/JavaScriptCore/runtime/TypedArrays/JSUint32Array.h @@ -0,0 +1,143 @@ +/* + 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. +*/ + +#ifndef JSUint32Array_h +#define JSUint32Array_h + +#include "JSArrayBufferView.h" +#include "JSDOMBinding.h" +#include +#include + +namespace WebCore { + +class JSUint32Array : public JSArrayBufferView { +public: + typedef JSArrayBufferView Base; + static JSUint32Array* create(JSC::Structure* structure, JSDOMGlobalObject* globalObject, PassRefPtr impl) + { + JSUint32Array* ptr = new (NotNull, JSC::allocateCell(globalObject->globalData().heap)) JSUint32Array(structure, globalObject, impl); + ptr->finishCreation(globalObject->globalData()); + return ptr; + } + + static JSC::JSObject* createPrototype(JSC::ExecState*, JSC::JSGlobalObject*); + static bool getOwnPropertySlot(JSC::JSCell*, JSC::ExecState*, const JSC::Identifier& propertyName, JSC::PropertySlot&); + static bool getOwnPropertyDescriptor(JSC::JSObject*, JSC::ExecState*, const JSC::Identifier& propertyName, JSC::PropertyDescriptor&); + static bool getOwnPropertySlotByIndex(JSC::JSCell*, JSC::ExecState*, unsigned propertyName, JSC::PropertySlot&); + static void put(JSC::JSCell*, JSC::ExecState*, const JSC::Identifier& propertyName, JSC::JSValue, JSC::PutPropertySlot&); + static void putByIndex(JSC::JSCell*, JSC::ExecState*, unsigned propertyName, JSC::JSValue, bool shouldThrow); + static const JSC::ClassInfo s_info; + + static JSC::Structure* createStructure(JSC::JSGlobalData& globalData, JSC::JSGlobalObject* globalObject, JSC::JSValue prototype) + { + return JSC::Structure::create(globalData, globalObject, prototype, JSC::TypeInfo(JSC::ObjectType, StructureFlags), &s_info); + } + + static void getOwnPropertyNames(JSC::JSObject*, JSC::ExecState*, JSC::PropertyNameArray&, JSC::EnumerationMode mode = JSC::ExcludeDontEnumProperties); + static JSC::JSValue getConstructor(JSC::ExecState*, JSC::JSGlobalObject*); + + // Custom functions + JSC::JSValue set(JSC::ExecState*); + Uint32Array* impl() const + { + return static_cast(Base::impl()); + } + static const JSC::TypedArrayType TypedArrayStorageType = JSC::TypedArrayUint32; + intptr_t m_storageLength; + void* m_storage; +protected: + JSUint32Array(JSC::Structure*, JSDOMGlobalObject*, PassRefPtr); + void finishCreation(JSC::JSGlobalData&); + static const unsigned StructureFlags = JSC::OverridesGetPropertyNames | JSC::OverridesGetOwnPropertySlot | Base::StructureFlags; + JSC::JSValue getByIndex(JSC::ExecState*, unsigned index); + void indexSetter(JSC::ExecState*, unsigned index, JSC::JSValue); +}; + +JSC::JSValue toJS(JSC::ExecState*, JSDOMGlobalObject*, Uint32Array*); +Uint32Array* toUint32Array(JSC::JSValue); + +class JSUint32ArrayPrototype : public JSC::JSNonFinalObject { +public: + typedef JSC::JSNonFinalObject Base; + static JSC::JSObject* self(JSC::ExecState*, JSC::JSGlobalObject*); + static JSUint32ArrayPrototype* create(JSC::JSGlobalData& globalData, JSC::JSGlobalObject* globalObject, JSC::Structure* structure) + { + JSUint32ArrayPrototype* ptr = new (NotNull, JSC::allocateCell(globalData.heap)) JSUint32ArrayPrototype(globalData, globalObject, structure); + ptr->finishCreation(globalData); + return ptr; + } + + static const JSC::ClassInfo s_info; + static bool getOwnPropertySlot(JSC::JSCell*, JSC::ExecState*, const JSC::Identifier&, JSC::PropertySlot&); + static bool getOwnPropertyDescriptor(JSC::JSObject*, JSC::ExecState*, const JSC::Identifier&, JSC::PropertyDescriptor&); + static JSC::Structure* createStructure(JSC::JSGlobalData& globalData, JSC::JSGlobalObject* globalObject, JSC::JSValue prototype) + { + return JSC::Structure::create(globalData, globalObject, prototype, JSC::TypeInfo(JSC::ObjectType, StructureFlags), &s_info); + } + +private: + JSUint32ArrayPrototype(JSC::JSGlobalData& globalData, JSC::JSGlobalObject*, JSC::Structure* structure) : JSC::JSNonFinalObject(globalData, structure) { } +protected: + static const unsigned StructureFlags = JSC::OverridesGetOwnPropertySlot | Base::StructureFlags; +}; + +class JSUint32ArrayConstructor : public DOMConstructorObject { +private: + JSUint32ArrayConstructor(JSC::Structure*, JSDOMGlobalObject*); + void finishCreation(JSC::ExecState*, JSDOMGlobalObject*); + +public: + typedef DOMConstructorObject Base; + static JSUint32ArrayConstructor* create(JSC::ExecState* exec, JSC::Structure* structure, JSDOMGlobalObject* globalObject) + { + JSUint32ArrayConstructor* ptr = new (NotNull, JSC::allocateCell(*exec->heap())) JSUint32ArrayConstructor(structure, globalObject); + ptr->finishCreation(exec, globalObject); + return ptr; + } + + static bool getOwnPropertySlot(JSC::JSCell*, JSC::ExecState*, const JSC::Identifier&, JSC::PropertySlot&); + static bool getOwnPropertyDescriptor(JSC::JSObject*, JSC::ExecState*, const JSC::Identifier&, JSC::PropertyDescriptor&); + static const JSC::ClassInfo s_info; + static JSC::Structure* createStructure(JSC::JSGlobalData& globalData, JSC::JSGlobalObject* globalObject, JSC::JSValue prototype) + { + return JSC::Structure::create(globalData, globalObject, prototype, JSC::TypeInfo(JSC::ObjectType, StructureFlags), &s_info); + } +protected: + static const unsigned StructureFlags = JSC::OverridesGetOwnPropertySlot | JSC::ImplementsHasInstance | DOMConstructorObject::StructureFlags; + static JSC::EncodedJSValue JSC_HOST_CALL constructJSUint32Array(JSC::ExecState*); + static JSC::ConstructType getConstructData(JSC::JSCell*, JSC::ConstructData&); +}; + +// Functions + +JSC::EncodedJSValue JSC_HOST_CALL jsUint32ArrayPrototypeFunctionSubarray(JSC::ExecState*); +JSC::EncodedJSValue JSC_HOST_CALL jsUint32ArrayPrototypeFunctionSet(JSC::ExecState*); +// Attributes + +JSC::JSValue jsUint32ArrayLength(JSC::ExecState*, JSC::JSValue, const JSC::Identifier&); +JSC::JSValue jsUint32ArrayConstructor(JSC::ExecState*, JSC::JSValue, const JSC::Identifier&); +// Constants + +JSC::JSValue jsUint32ArrayBYTES_PER_ELEMENT(JSC::ExecState*, JSC::JSValue, const JSC::Identifier&); + +} // namespace WebCore + +#endif diff --git a/JavaScriptCore/runtime/TypedArrays/JSUint32ArrayCustom.cpp b/JavaScriptCore/runtime/TypedArrays/JSUint32ArrayCustom.cpp new file mode 100644 index 00000000..aa8b8267 --- /dev/null +++ b/JavaScriptCore/runtime/TypedArrays/JSUint32ArrayCustom.cpp @@ -0,0 +1,61 @@ +/* + * Copyright (C) 2009 Apple Inc. All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY APPLE COMPUTER, INC. ``AS IS'' AND ANY + * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR + * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE COMPUTER, INC. OR + * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, + * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, + * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR + * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY + * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE + * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + */ + +#include "config.h" +#include "JSUint32Array.h" + +#include "JSArrayBufferViewHelper.h" +#include + +using namespace JSC; + +namespace WebCore { + +void JSUint32Array::indexSetter(JSC::ExecState* exec, unsigned index, JSC::JSValue value) +{ + impl()->set(index, static_cast(value.toUInt32(exec))); +} + +JSC::JSValue toJS(JSC::ExecState* exec, JSDOMGlobalObject* globalObject, Uint32Array* object) +{ + return toJSArrayBufferView(exec, globalObject, object); +} + +JSC::JSValue JSUint32Array::set(JSC::ExecState* exec) +{ + return setWebGLArrayHelper(exec, impl(), toUint32Array); +} + +EncodedJSValue JSC_HOST_CALL JSUint32ArrayConstructor::constructJSUint32Array(ExecState* exec) +{ + JSUint32ArrayConstructor* jsConstructor = jsCast(exec->callee()); + RefPtr array = constructArrayBufferView(exec); + if (!array.get()) + // Exception has already been thrown. + return JSValue::encode(JSValue()); + return JSValue::encode(asObject(toJS(exec, jsConstructor->globalObject(), array.get()))); +} + +} // namespace WebCore diff --git a/JavaScriptCore/runtime/TypedArrays/JSUint8Array.cpp b/JavaScriptCore/runtime/TypedArrays/JSUint8Array.cpp new file mode 100644 index 00000000..e62ac06d --- /dev/null +++ b/JavaScriptCore/runtime/TypedArrays/JSUint8Array.cpp @@ -0,0 +1,297 @@ +/* + 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 "JSUint8Array.h" + +#include "ExceptionCode.h" +#include "JSDOMBinding.h" +#include "JSUint8Array.h" +#include +#include +#include +#include + +using namespace JSC; + +namespace WebCore { + +ASSERT_CLASS_FITS_IN_CELL(JSUint8Array); +/* Hash table */ + +static const HashTableValue JSUint8ArrayTableValues[] = +{ + { "length", DontDelete | ReadOnly, (intptr_t)static_cast(jsUint8ArrayLength), (intptr_t)0, NoIntrinsic }, + { "constructor", DontEnum | ReadOnly, (intptr_t)static_cast(jsUint8ArrayConstructor), (intptr_t)0, NoIntrinsic }, + { 0, 0, 0, 0, NoIntrinsic } +}; + +static const HashTable JSUint8ArrayTable = { 5, 3, JSUint8ArrayTableValues, 0 }; +/* Hash table for constructor */ + +static const HashTableValue JSUint8ArrayConstructorTableValues[] = +{ + { "BYTES_PER_ELEMENT", DontDelete | ReadOnly, (intptr_t)static_cast(jsUint8ArrayBYTES_PER_ELEMENT), (intptr_t)0, NoIntrinsic }, + { 0, 0, 0, 0, NoIntrinsic } +}; + +static const HashTable JSUint8ArrayConstructorTable = { 2, 1, JSUint8ArrayConstructorTableValues, 0 }; +const ClassInfo JSUint8ArrayConstructor::s_info = { "Uint8ArrayConstructor", &Base::s_info, &JSUint8ArrayConstructorTable, 0, CREATE_METHOD_TABLE(JSUint8ArrayConstructor) }; + +JSUint8ArrayConstructor::JSUint8ArrayConstructor(Structure* structure, JSDOMGlobalObject* globalObject) + : DOMConstructorObject(structure, globalObject) +{ +} + +void JSUint8ArrayConstructor::finishCreation(ExecState* exec, JSDOMGlobalObject* globalObject) +{ + Base::finishCreation(exec->globalData()); + ASSERT(inherits(&s_info)); + putDirect(exec->globalData(), exec->propertyNames().prototype, JSUint8ArrayPrototype::self(exec, globalObject), DontDelete | ReadOnly); + putDirect(exec->globalData(), exec->propertyNames().length, jsNumber(1), ReadOnly | DontDelete | DontEnum); +} + +bool JSUint8ArrayConstructor::getOwnPropertySlot(JSCell* cell, ExecState* exec, const Identifier& propertyName, PropertySlot& slot) +{ + return getStaticValueSlot(exec, &JSUint8ArrayConstructorTable, jsCast(cell), propertyName, slot); +} + +bool JSUint8ArrayConstructor::getOwnPropertyDescriptor(JSObject* object, ExecState* exec, const Identifier& propertyName, PropertyDescriptor& descriptor) +{ + return getStaticValueDescriptor(exec, &JSUint8ArrayConstructorTable, jsCast(object), propertyName, descriptor); +} + +ConstructType JSUint8ArrayConstructor::getConstructData(JSCell*, ConstructData& constructData) +{ + constructData.native.function = constructJSUint8Array; + return ConstructTypeHost; +} + +/* Hash table for prototype */ + +static const HashTableValue JSUint8ArrayPrototypeTableValues[] = +{ + { "BYTES_PER_ELEMENT", DontDelete | ReadOnly, (intptr_t)static_cast(jsUint8ArrayBYTES_PER_ELEMENT), (intptr_t)0, NoIntrinsic }, + { "subarray", DontDelete | JSC::Function, (intptr_t)static_cast(jsUint8ArrayPrototypeFunctionSubarray), (intptr_t)2, NoIntrinsic }, + { "set", DontDelete | JSC::Function, (intptr_t)static_cast(jsUint8ArrayPrototypeFunctionSet), (intptr_t)0, NoIntrinsic }, + { 0, 0, 0, 0, NoIntrinsic } +}; + +static const HashTable JSUint8ArrayPrototypeTable = { 8, 7, JSUint8ArrayPrototypeTableValues, 0 }; +static const HashTable* getJSUint8ArrayPrototypeTable(ExecState* exec) +{ + return getHashTableForGlobalData(exec->globalData(), &JSUint8ArrayPrototypeTable); +} + +const ClassInfo JSUint8ArrayPrototype::s_info = { "Uint8ArrayPrototype", &Base::s_info, 0, getJSUint8ArrayPrototypeTable, CREATE_METHOD_TABLE(JSUint8ArrayPrototype) }; + +JSObject* JSUint8ArrayPrototype::self(ExecState* exec, JSGlobalObject* globalObject) +{ + return getDOMPrototype(exec, globalObject); +} + +bool JSUint8ArrayPrototype::getOwnPropertySlot(JSCell* cell, ExecState* exec, const Identifier& propertyName, PropertySlot& slot) +{ + JSUint8ArrayPrototype* thisObject = jsCast(cell); + return getStaticPropertySlot(exec, getJSUint8ArrayPrototypeTable(exec), thisObject, propertyName, slot); +} + +bool JSUint8ArrayPrototype::getOwnPropertyDescriptor(JSObject* object, ExecState* exec, const Identifier& propertyName, PropertyDescriptor& descriptor) +{ + JSUint8ArrayPrototype* thisObject = jsCast(object); + return getStaticPropertyDescriptor(exec, getJSUint8ArrayPrototypeTable(exec), thisObject, propertyName, descriptor); +} + +static const HashTable* getJSUint8ArrayTable(ExecState* exec) +{ + return getHashTableForGlobalData(exec->globalData(), &JSUint8ArrayTable); +} + +const ClassInfo JSUint8Array::s_info = { "Uint8Array", &Base::s_info, 0, getJSUint8ArrayTable , CREATE_METHOD_TABLE(JSUint8Array) }; + +JSUint8Array::JSUint8Array(Structure* structure, JSDOMGlobalObject* globalObject, PassRefPtr impl) + : JSArrayBufferView(structure, globalObject, impl) +{ +} + +void JSUint8Array::finishCreation(JSGlobalData& globalData) +{ + Base::finishCreation(globalData); + TypedArrayDescriptor descriptor(&JSUint8Array::s_info, OBJECT_OFFSETOF(JSUint8Array, m_storage), OBJECT_OFFSETOF(JSUint8Array, m_storageLength)); + globalData.registerTypedArrayDescriptor(impl(), descriptor); + m_storage = impl()->data(); + m_storageLength = impl()->length(); + ASSERT(inherits(&s_info)); +} + +JSObject* JSUint8Array::createPrototype(ExecState* exec, JSGlobalObject* globalObject) +{ + return JSUint8ArrayPrototype::create(exec->globalData(), globalObject, JSUint8ArrayPrototype::createStructure(exec->globalData(), globalObject, JSArrayBufferViewPrototype::self(exec, globalObject))); +} + +bool JSUint8Array::getOwnPropertySlot(JSCell* cell, ExecState* exec, const Identifier& propertyName, PropertySlot& slot) +{ + JSUint8Array* thisObject = jsCast(cell); + ASSERT_GC_OBJECT_INHERITS(thisObject, &s_info); + bool ok; + unsigned index = propertyName.toUInt32(ok); + if (ok && index < static_cast(thisObject->impl())->length()) { + slot.setValue(thisObject->getByIndex(exec, index)); + return true; + } + return getStaticValueSlot(exec, getJSUint8ArrayTable(exec), thisObject, propertyName, slot); +} + +bool JSUint8Array::getOwnPropertyDescriptor(JSObject* object, ExecState* exec, const Identifier& propertyName, PropertyDescriptor& descriptor) +{ + JSUint8Array* thisObject = jsCast(object); + ASSERT_GC_OBJECT_INHERITS(thisObject, &s_info); + bool ok; + unsigned index = propertyName.toUInt32(ok); + if (ok && index < static_cast(thisObject->impl())->length()) { + descriptor.setDescriptor(thisObject->getByIndex(exec, index), DontDelete); + return true; + } + return getStaticValueDescriptor(exec, getJSUint8ArrayTable(exec), thisObject, propertyName, descriptor); +} + +bool JSUint8Array::getOwnPropertySlotByIndex(JSCell* cell, ExecState* exec, unsigned propertyName, PropertySlot& slot) +{ + JSUint8Array* thisObject = jsCast(cell); + ASSERT_GC_OBJECT_INHERITS(thisObject, &s_info); + if (propertyName < static_cast(thisObject->impl())->length()) { + slot.setValue(thisObject->getByIndex(exec, propertyName)); + return true; + } + return thisObject->methodTable()->getOwnPropertySlot(thisObject, exec, Identifier::from(exec, propertyName), slot); +} + +JSValue jsUint8ArrayLength(ExecState* exec, JSValue slotBase, const Identifier&) +{ + JSUint8Array* castedThis = jsCast(asObject(slotBase)); + UNUSED_PARAM(exec); + Uint8Array* impl = static_cast(castedThis->impl()); + JSValue result = jsNumber(impl->length()); + return result; +} + + +JSValue jsUint8ArrayConstructor(ExecState* exec, JSValue slotBase, const Identifier&) +{ + JSUint8Array* domObject = jsCast(asObject(slotBase)); + return JSUint8Array::getConstructor(exec, domObject->globalObject()); +} + +void JSUint8Array::put(JSCell* cell, ExecState* exec, const Identifier& propertyName, JSValue value, PutPropertySlot& slot) +{ + JSUint8Array* thisObject = jsCast(cell); + ASSERT_GC_OBJECT_INHERITS(thisObject, &s_info); + bool ok; + unsigned index = propertyName.toUInt32(ok); + if (ok) { + thisObject->indexSetter(exec, index, value); + return; + } + Base::put(thisObject, exec, propertyName, value, slot); +} + +void JSUint8Array::putByIndex(JSCell* cell, ExecState* exec, unsigned propertyName, JSValue value, bool) +{ + JSUint8Array* thisObject = jsCast(cell); + ASSERT_GC_OBJECT_INHERITS(thisObject, &s_info); + thisObject->indexSetter(exec, propertyName, value); + return; +} + +void JSUint8Array::getOwnPropertyNames(JSObject* object, ExecState* exec, PropertyNameArray& propertyNames, EnumerationMode mode) +{ + JSUint8Array* thisObject = jsCast(object); + ASSERT_GC_OBJECT_INHERITS(thisObject, &s_info); + for (unsigned i = 0; i < static_cast(thisObject->impl())->length(); ++i) + propertyNames.add(Identifier::from(exec, i)); + Base::getOwnPropertyNames(thisObject, exec, propertyNames, mode); +} + +JSValue JSUint8Array::getConstructor(ExecState* exec, JSGlobalObject* globalObject) +{ + return getDOMConstructor(exec, jsCast(globalObject)); +} + +EncodedJSValue JSC_HOST_CALL jsUint8ArrayPrototypeFunctionSubarray(ExecState* exec) +{ + JSValue thisValue = exec->hostThisValue(); + if (!thisValue.inherits(&JSUint8Array::s_info)) + return throwVMTypeError(exec); + JSUint8Array* castedThis = jsCast(asObject(thisValue)); + ASSERT_GC_OBJECT_INHERITS(castedThis, &JSUint8Array::s_info); + Uint8Array* impl = static_cast(castedThis->impl()); + int start(MAYBE_MISSING_PARAMETER(exec, 0, DefaultIsUndefined).toInt32(exec)); + if (exec->hadException()) + return JSValue::encode(jsUndefined()); + + size_t argsCount = exec->argumentCount(); + if (argsCount <= 1) { + + JSC::JSValue result = toJS(exec, castedThis->globalObject(), WTF::getPtr(impl->subarray(start))); + return JSValue::encode(result); + } + + int end(MAYBE_MISSING_PARAMETER(exec, 1, DefaultIsUndefined).toInt32(exec)); + if (exec->hadException()) + return JSValue::encode(jsUndefined()); + + JSC::JSValue result = toJS(exec, castedThis->globalObject(), WTF::getPtr(impl->subarray(start, end))); + return JSValue::encode(result); +} + +EncodedJSValue JSC_HOST_CALL jsUint8ArrayPrototypeFunctionSet(ExecState* exec) +{ + JSValue thisValue = exec->hostThisValue(); + if (!thisValue.inherits(&JSUint8Array::s_info)) + return throwVMTypeError(exec); + JSUint8Array* castedThis = jsCast(asObject(thisValue)); + ASSERT_GC_OBJECT_INHERITS(castedThis, &JSUint8Array::s_info); + return JSValue::encode(castedThis->set(exec)); +} + +// Constant getters + +JSValue jsUint8ArrayBYTES_PER_ELEMENT(ExecState* exec, JSValue, const Identifier&) +{ + UNUSED_PARAM(exec); + return jsNumber(static_cast(1)); +} + + +JSValue JSUint8Array::getByIndex(ExecState*, unsigned index) +{ + ASSERT_GC_OBJECT_INHERITS(this, &s_info); + double result = static_cast(impl())->item(index); + if (isnan(result)) + return jsNaN(); + return JSValue(result); +} + +Uint8Array* toUint8Array(JSC::JSValue value) +{ + return value.inherits(&JSUint8Array::s_info) ? jsCast(asObject(value))->impl() : 0; +} + +} diff --git a/JavaScriptCore/runtime/TypedArrays/JSUint8Array.h b/JavaScriptCore/runtime/TypedArrays/JSUint8Array.h new file mode 100644 index 00000000..0972b146 --- /dev/null +++ b/JavaScriptCore/runtime/TypedArrays/JSUint8Array.h @@ -0,0 +1,143 @@ +/* + 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. +*/ + +#ifndef JSUint8Array_h +#define JSUint8Array_h + +#include "JSArrayBufferView.h" +#include "JSDOMBinding.h" +#include +#include + +namespace WebCore { + +class JSUint8Array : public JSArrayBufferView { +public: + typedef JSArrayBufferView Base; + static JSUint8Array* create(JSC::Structure* structure, JSDOMGlobalObject* globalObject, PassRefPtr impl) + { + JSUint8Array* ptr = new (NotNull, JSC::allocateCell(globalObject->globalData().heap)) JSUint8Array(structure, globalObject, impl); + ptr->finishCreation(globalObject->globalData()); + return ptr; + } + + static JSC::JSObject* createPrototype(JSC::ExecState*, JSC::JSGlobalObject*); + static bool getOwnPropertySlot(JSC::JSCell*, JSC::ExecState*, const JSC::Identifier& propertyName, JSC::PropertySlot&); + static bool getOwnPropertyDescriptor(JSC::JSObject*, JSC::ExecState*, const JSC::Identifier& propertyName, JSC::PropertyDescriptor&); + static bool getOwnPropertySlotByIndex(JSC::JSCell*, JSC::ExecState*, unsigned propertyName, JSC::PropertySlot&); + static void put(JSC::JSCell*, JSC::ExecState*, const JSC::Identifier& propertyName, JSC::JSValue, JSC::PutPropertySlot&); + static void putByIndex(JSC::JSCell*, JSC::ExecState*, unsigned propertyName, JSC::JSValue, bool shouldThrow); + static const JSC::ClassInfo s_info; + + static JSC::Structure* createStructure(JSC::JSGlobalData& globalData, JSC::JSGlobalObject* globalObject, JSC::JSValue prototype) + { + return JSC::Structure::create(globalData, globalObject, prototype, JSC::TypeInfo(JSC::ObjectType, StructureFlags), &s_info); + } + + static void getOwnPropertyNames(JSC::JSObject*, JSC::ExecState*, JSC::PropertyNameArray&, JSC::EnumerationMode mode = JSC::ExcludeDontEnumProperties); + static JSC::JSValue getConstructor(JSC::ExecState*, JSC::JSGlobalObject*); + + // Custom functions + JSC::JSValue set(JSC::ExecState*); + Uint8Array* impl() const + { + return static_cast(Base::impl()); + } + static const JSC::TypedArrayType TypedArrayStorageType = JSC::TypedArrayUint8; + intptr_t m_storageLength; + void* m_storage; +protected: + JSUint8Array(JSC::Structure*, JSDOMGlobalObject*, PassRefPtr); + void finishCreation(JSC::JSGlobalData&); + static const unsigned StructureFlags = JSC::OverridesGetPropertyNames | JSC::OverridesGetOwnPropertySlot | Base::StructureFlags; + JSC::JSValue getByIndex(JSC::ExecState*, unsigned index); + void indexSetter(JSC::ExecState*, unsigned index, JSC::JSValue); +}; + +JSC::JSValue toJS(JSC::ExecState*, JSDOMGlobalObject*, Uint8Array*); +Uint8Array* toUint8Array(JSC::JSValue); + +class JSUint8ArrayPrototype : public JSC::JSNonFinalObject { +public: + typedef JSC::JSNonFinalObject Base; + static JSC::JSObject* self(JSC::ExecState*, JSC::JSGlobalObject*); + static JSUint8ArrayPrototype* create(JSC::JSGlobalData& globalData, JSC::JSGlobalObject* globalObject, JSC::Structure* structure) + { + JSUint8ArrayPrototype* ptr = new (NotNull, JSC::allocateCell(globalData.heap)) JSUint8ArrayPrototype(globalData, globalObject, structure); + ptr->finishCreation(globalData); + return ptr; + } + + static const JSC::ClassInfo s_info; + static bool getOwnPropertySlot(JSC::JSCell*, JSC::ExecState*, const JSC::Identifier&, JSC::PropertySlot&); + static bool getOwnPropertyDescriptor(JSC::JSObject*, JSC::ExecState*, const JSC::Identifier&, JSC::PropertyDescriptor&); + static JSC::Structure* createStructure(JSC::JSGlobalData& globalData, JSC::JSGlobalObject* globalObject, JSC::JSValue prototype) + { + return JSC::Structure::create(globalData, globalObject, prototype, JSC::TypeInfo(JSC::ObjectType, StructureFlags), &s_info); + } + +private: + JSUint8ArrayPrototype(JSC::JSGlobalData& globalData, JSC::JSGlobalObject*, JSC::Structure* structure) : JSC::JSNonFinalObject(globalData, structure) { } +protected: + static const unsigned StructureFlags = JSC::OverridesGetOwnPropertySlot | Base::StructureFlags; +}; + +class JSUint8ArrayConstructor : public DOMConstructorObject { +private: + JSUint8ArrayConstructor(JSC::Structure*, JSDOMGlobalObject*); + void finishCreation(JSC::ExecState*, JSDOMGlobalObject*); + +public: + typedef DOMConstructorObject Base; + static JSUint8ArrayConstructor* create(JSC::ExecState* exec, JSC::Structure* structure, JSDOMGlobalObject* globalObject) + { + JSUint8ArrayConstructor* ptr = new (NotNull, JSC::allocateCell(*exec->heap())) JSUint8ArrayConstructor(structure, globalObject); + ptr->finishCreation(exec, globalObject); + return ptr; + } + + static bool getOwnPropertySlot(JSC::JSCell*, JSC::ExecState*, const JSC::Identifier&, JSC::PropertySlot&); + static bool getOwnPropertyDescriptor(JSC::JSObject*, JSC::ExecState*, const JSC::Identifier&, JSC::PropertyDescriptor&); + static const JSC::ClassInfo s_info; + static JSC::Structure* createStructure(JSC::JSGlobalData& globalData, JSC::JSGlobalObject* globalObject, JSC::JSValue prototype) + { + return JSC::Structure::create(globalData, globalObject, prototype, JSC::TypeInfo(JSC::ObjectType, StructureFlags), &s_info); + } +protected: + static const unsigned StructureFlags = JSC::OverridesGetOwnPropertySlot | JSC::ImplementsHasInstance | DOMConstructorObject::StructureFlags; + static JSC::EncodedJSValue JSC_HOST_CALL constructJSUint8Array(JSC::ExecState*); + static JSC::ConstructType getConstructData(JSC::JSCell*, JSC::ConstructData&); +}; + +// Functions + +JSC::EncodedJSValue JSC_HOST_CALL jsUint8ArrayPrototypeFunctionSubarray(JSC::ExecState*); +JSC::EncodedJSValue JSC_HOST_CALL jsUint8ArrayPrototypeFunctionSet(JSC::ExecState*); +// Attributes + +JSC::JSValue jsUint8ArrayLength(JSC::ExecState*, JSC::JSValue, const JSC::Identifier&); +JSC::JSValue jsUint8ArrayConstructor(JSC::ExecState*, JSC::JSValue, const JSC::Identifier&); +// Constants + +JSC::JSValue jsUint8ArrayBYTES_PER_ELEMENT(JSC::ExecState*, JSC::JSValue, const JSC::Identifier&); + +} // namespace WebCore + +#endif diff --git a/JavaScriptCore/runtime/TypedArrays/JSUint8ArrayCustom.cpp b/JavaScriptCore/runtime/TypedArrays/JSUint8ArrayCustom.cpp new file mode 100644 index 00000000..6a4fa1df --- /dev/null +++ b/JavaScriptCore/runtime/TypedArrays/JSUint8ArrayCustom.cpp @@ -0,0 +1,61 @@ +/* + * Copyright (C) 2009 Apple Inc. All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY APPLE COMPUTER, INC. ``AS IS'' AND ANY + * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR + * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE COMPUTER, INC. OR + * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, + * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, + * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR + * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY + * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE + * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + */ + +#include "config.h" +#include "JSUint8Array.h" + +#include "JSArrayBufferViewHelper.h" +#include + +using namespace JSC; + +namespace WebCore { + +void JSUint8Array::indexSetter(JSC::ExecState* exec, unsigned index, JSC::JSValue value) +{ + impl()->set(index, static_cast(value.toInt32(exec))); +} + +JSC::JSValue toJS(JSC::ExecState* exec, JSDOMGlobalObject* globalObject, Uint8Array* object) +{ + return toJSArrayBufferView(exec, globalObject, object); +} + +JSC::JSValue JSUint8Array::set(JSC::ExecState* exec) +{ + return setWebGLArrayHelper(exec, impl(), toUint8Array); +} + +EncodedJSValue JSC_HOST_CALL JSUint8ArrayConstructor::constructJSUint8Array(ExecState* exec) +{ + JSUint8ArrayConstructor* jsConstructor = jsCast(exec->callee()); + RefPtr array = constructArrayBufferView(exec); + if (!array.get()) + // Exception has already been thrown. + return JSValue::encode(JSValue()); + return JSValue::encode(asObject(toJS(exec, jsConstructor->globalObject(), array.get()))); +} + +} // namespace WebCore diff --git a/JavaScriptCore/runtime/TypedArrays/JSUint8ClampedArray.cpp b/JavaScriptCore/runtime/TypedArrays/JSUint8ClampedArray.cpp new file mode 100644 index 00000000..e0b16c3d --- /dev/null +++ b/JavaScriptCore/runtime/TypedArrays/JSUint8ClampedArray.cpp @@ -0,0 +1,297 @@ +/* + 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 "JSUint8ClampedArray.h" + +#include "ExceptionCode.h" +#include "JSDOMBinding.h" +#include "JSUint8ClampedArray.h" +#include +#include +#include +#include + +using namespace JSC; + +namespace WebCore { + +ASSERT_CLASS_FITS_IN_CELL(JSUint8ClampedArray); +/* Hash table */ + +static const HashTableValue JSUint8ClampedArrayTableValues[] = +{ + { "length", DontDelete | ReadOnly, (intptr_t)static_cast(jsUint8ClampedArrayLength), (intptr_t)0, NoIntrinsic }, + { "constructor", DontEnum | ReadOnly, (intptr_t)static_cast(jsUint8ClampedArrayConstructor), (intptr_t)0, NoIntrinsic }, + { 0, 0, 0, 0, NoIntrinsic } +}; + +static const HashTable JSUint8ClampedArrayTable = { 5, 3, JSUint8ClampedArrayTableValues, 0 }; +/* Hash table for constructor */ + +static const HashTableValue JSUint8ClampedArrayConstructorTableValues[] = +{ + { "BYTES_PER_ELEMENT", DontDelete | ReadOnly, (intptr_t)static_cast(jsUint8ClampedArrayBYTES_PER_ELEMENT), (intptr_t)0, NoIntrinsic }, + { 0, 0, 0, 0, NoIntrinsic } +}; + +static const HashTable JSUint8ClampedArrayConstructorTable = { 2, 1, JSUint8ClampedArrayConstructorTableValues, 0 }; +const ClassInfo JSUint8ClampedArrayConstructor::s_info = { "Uint8ClampedArrayConstructor", &Base::s_info, &JSUint8ClampedArrayConstructorTable, 0, CREATE_METHOD_TABLE(JSUint8ClampedArrayConstructor) }; + +JSUint8ClampedArrayConstructor::JSUint8ClampedArrayConstructor(Structure* structure, JSDOMGlobalObject* globalObject) + : DOMConstructorObject(structure, globalObject) +{ +} + +void JSUint8ClampedArrayConstructor::finishCreation(ExecState* exec, JSDOMGlobalObject* globalObject) +{ + Base::finishCreation(exec->globalData()); + ASSERT(inherits(&s_info)); + putDirect(exec->globalData(), exec->propertyNames().prototype, JSUint8ClampedArrayPrototype::self(exec, globalObject), DontDelete | ReadOnly); + putDirect(exec->globalData(), exec->propertyNames().length, jsNumber(1), ReadOnly | DontDelete | DontEnum); +} + +bool JSUint8ClampedArrayConstructor::getOwnPropertySlot(JSCell* cell, ExecState* exec, const Identifier& propertyName, PropertySlot& slot) +{ + return getStaticValueSlot(exec, &JSUint8ClampedArrayConstructorTable, jsCast(cell), propertyName, slot); +} + +bool JSUint8ClampedArrayConstructor::getOwnPropertyDescriptor(JSObject* object, ExecState* exec, const Identifier& propertyName, PropertyDescriptor& descriptor) +{ + return getStaticValueDescriptor(exec, &JSUint8ClampedArrayConstructorTable, jsCast(object), propertyName, descriptor); +} + +ConstructType JSUint8ClampedArrayConstructor::getConstructData(JSCell*, ConstructData& constructData) +{ + constructData.native.function = constructJSUint8ClampedArray; + return ConstructTypeHost; +} + +/* Hash table for prototype */ + +static const HashTableValue JSUint8ClampedArrayPrototypeTableValues[] = +{ + { "BYTES_PER_ELEMENT", DontDelete | ReadOnly, (intptr_t)static_cast(jsUint8ClampedArrayBYTES_PER_ELEMENT), (intptr_t)0, NoIntrinsic }, + { "subarray", DontDelete | JSC::Function, (intptr_t)static_cast(jsUint8ClampedArrayPrototypeFunctionSubarray), (intptr_t)2, NoIntrinsic }, + { "set", DontDelete | JSC::Function, (intptr_t)static_cast(jsUint8ClampedArrayPrototypeFunctionSet), (intptr_t)0, NoIntrinsic }, + { 0, 0, 0, 0, NoIntrinsic } +}; + +static const HashTable JSUint8ClampedArrayPrototypeTable = { 8, 7, JSUint8ClampedArrayPrototypeTableValues, 0 }; +static const HashTable* getJSUint8ClampedArrayPrototypeTable(ExecState* exec) +{ + return getHashTableForGlobalData(exec->globalData(), &JSUint8ClampedArrayPrototypeTable); +} + +const ClassInfo JSUint8ClampedArrayPrototype::s_info = { "Uint8ClampedArrayPrototype", &Base::s_info, 0, getJSUint8ClampedArrayPrototypeTable, CREATE_METHOD_TABLE(JSUint8ClampedArrayPrototype) }; + +JSObject* JSUint8ClampedArrayPrototype::self(ExecState* exec, JSGlobalObject* globalObject) +{ + return getDOMPrototype(exec, globalObject); +} + +bool JSUint8ClampedArrayPrototype::getOwnPropertySlot(JSCell* cell, ExecState* exec, const Identifier& propertyName, PropertySlot& slot) +{ + JSUint8ClampedArrayPrototype* thisObject = jsCast(cell); + return getStaticPropertySlot(exec, getJSUint8ClampedArrayPrototypeTable(exec), thisObject, propertyName, slot); +} + +bool JSUint8ClampedArrayPrototype::getOwnPropertyDescriptor(JSObject* object, ExecState* exec, const Identifier& propertyName, PropertyDescriptor& descriptor) +{ + JSUint8ClampedArrayPrototype* thisObject = jsCast(object); + return getStaticPropertyDescriptor(exec, getJSUint8ClampedArrayPrototypeTable(exec), thisObject, propertyName, descriptor); +} + +static const HashTable* getJSUint8ClampedArrayTable(ExecState* exec) +{ + return getHashTableForGlobalData(exec->globalData(), &JSUint8ClampedArrayTable); +} + +const ClassInfo JSUint8ClampedArray::s_info = { "Uint8ClampedArray", &Base::s_info, 0, getJSUint8ClampedArrayTable , CREATE_METHOD_TABLE(JSUint8ClampedArray) }; + +JSUint8ClampedArray::JSUint8ClampedArray(Structure* structure, JSDOMGlobalObject* globalObject, PassRefPtr impl) + : JSUint8Array(structure, globalObject, impl) +{ +} + +void JSUint8ClampedArray::finishCreation(JSGlobalData& globalData) +{ + Base::finishCreation(globalData); + TypedArrayDescriptor descriptor(&JSUint8ClampedArray::s_info, OBJECT_OFFSETOF(JSUint8ClampedArray, m_storage), OBJECT_OFFSETOF(JSUint8ClampedArray, m_storageLength)); + globalData.registerTypedArrayDescriptor(impl(), descriptor); + m_storage = impl()->data(); + m_storageLength = impl()->length(); + ASSERT(inherits(&s_info)); +} + +JSObject* JSUint8ClampedArray::createPrototype(ExecState* exec, JSGlobalObject* globalObject) +{ + return JSUint8ClampedArrayPrototype::create(exec->globalData(), globalObject, JSUint8ClampedArrayPrototype::createStructure(exec->globalData(), globalObject, JSUint8ArrayPrototype::self(exec, globalObject))); +} + +bool JSUint8ClampedArray::getOwnPropertySlot(JSCell* cell, ExecState* exec, const Identifier& propertyName, PropertySlot& slot) +{ + JSUint8ClampedArray* thisObject = jsCast(cell); + ASSERT_GC_OBJECT_INHERITS(thisObject, &s_info); + bool ok; + unsigned index = propertyName.toUInt32(ok); + if (ok && index < static_cast(thisObject->impl())->length()) { + slot.setValue(thisObject->getByIndex(exec, index)); + return true; + } + return getStaticValueSlot(exec, getJSUint8ClampedArrayTable(exec), thisObject, propertyName, slot); +} + +bool JSUint8ClampedArray::getOwnPropertyDescriptor(JSObject* object, ExecState* exec, const Identifier& propertyName, PropertyDescriptor& descriptor) +{ + JSUint8ClampedArray* thisObject = jsCast(object); + ASSERT_GC_OBJECT_INHERITS(thisObject, &s_info); + bool ok; + unsigned index = propertyName.toUInt32(ok); + if (ok && index < static_cast(thisObject->impl())->length()) { + descriptor.setDescriptor(thisObject->getByIndex(exec, index), DontDelete); + return true; + } + return getStaticValueDescriptor(exec, getJSUint8ClampedArrayTable(exec), thisObject, propertyName, descriptor); +} + +bool JSUint8ClampedArray::getOwnPropertySlotByIndex(JSCell* cell, ExecState* exec, unsigned propertyName, PropertySlot& slot) +{ + JSUint8ClampedArray* thisObject = jsCast(cell); + ASSERT_GC_OBJECT_INHERITS(thisObject, &s_info); + if (propertyName < static_cast(thisObject->impl())->length()) { + slot.setValue(thisObject->getByIndex(exec, propertyName)); + return true; + } + return thisObject->methodTable()->getOwnPropertySlot(thisObject, exec, Identifier::from(exec, propertyName), slot); +} + +JSValue jsUint8ClampedArrayLength(ExecState* exec, JSValue slotBase, const Identifier&) +{ + JSUint8ClampedArray* castedThis = jsCast(asObject(slotBase)); + UNUSED_PARAM(exec); + Uint8ClampedArray* impl = static_cast(castedThis->impl()); + JSValue result = jsNumber(impl->length()); + return result; +} + + +JSValue jsUint8ClampedArrayConstructor(ExecState* exec, JSValue slotBase, const Identifier&) +{ + JSUint8ClampedArray* domObject = jsCast(asObject(slotBase)); + return JSUint8ClampedArray::getConstructor(exec, domObject->globalObject()); +} + +void JSUint8ClampedArray::put(JSCell* cell, ExecState* exec, const Identifier& propertyName, JSValue value, PutPropertySlot& slot) +{ + JSUint8ClampedArray* thisObject = jsCast(cell); + ASSERT_GC_OBJECT_INHERITS(thisObject, &s_info); + bool ok; + unsigned index = propertyName.toUInt32(ok); + if (ok) { + thisObject->indexSetter(exec, index, value); + return; + } + Base::put(thisObject, exec, propertyName, value, slot); +} + +void JSUint8ClampedArray::putByIndex(JSCell* cell, ExecState* exec, unsigned propertyName, JSValue value, bool) +{ + JSUint8ClampedArray* thisObject = jsCast(cell); + ASSERT_GC_OBJECT_INHERITS(thisObject, &s_info); + thisObject->indexSetter(exec, propertyName, value); + return; +} + +void JSUint8ClampedArray::getOwnPropertyNames(JSObject* object, ExecState* exec, PropertyNameArray& propertyNames, EnumerationMode mode) +{ + JSUint8ClampedArray* thisObject = jsCast(object); + ASSERT_GC_OBJECT_INHERITS(thisObject, &s_info); + for (unsigned i = 0; i < static_cast(thisObject->impl())->length(); ++i) + propertyNames.add(Identifier::from(exec, i)); + Base::getOwnPropertyNames(thisObject, exec, propertyNames, mode); +} + +JSValue JSUint8ClampedArray::getConstructor(ExecState* exec, JSGlobalObject* globalObject) +{ + return getDOMConstructor(exec, jsCast(globalObject)); +} + +EncodedJSValue JSC_HOST_CALL jsUint8ClampedArrayPrototypeFunctionSubarray(ExecState* exec) +{ + JSValue thisValue = exec->hostThisValue(); + if (!thisValue.inherits(&JSUint8ClampedArray::s_info)) + return throwVMTypeError(exec); + JSUint8ClampedArray* castedThis = jsCast(asObject(thisValue)); + ASSERT_GC_OBJECT_INHERITS(castedThis, &JSUint8ClampedArray::s_info); + Uint8ClampedArray* impl = static_cast(castedThis->impl()); + int start(MAYBE_MISSING_PARAMETER(exec, 0, DefaultIsUndefined).toInt32(exec)); + if (exec->hadException()) + return JSValue::encode(jsUndefined()); + + size_t argsCount = exec->argumentCount(); + if (argsCount <= 1) { + + JSC::JSValue result = toJS(exec, castedThis->globalObject(), WTF::getPtr(impl->subarray(start))); + return JSValue::encode(result); + } + + int end(MAYBE_MISSING_PARAMETER(exec, 1, DefaultIsUndefined).toInt32(exec)); + if (exec->hadException()) + return JSValue::encode(jsUndefined()); + + JSC::JSValue result = toJS(exec, castedThis->globalObject(), WTF::getPtr(impl->subarray(start, end))); + return JSValue::encode(result); +} + +EncodedJSValue JSC_HOST_CALL jsUint8ClampedArrayPrototypeFunctionSet(ExecState* exec) +{ + JSValue thisValue = exec->hostThisValue(); + if (!thisValue.inherits(&JSUint8ClampedArray::s_info)) + return throwVMTypeError(exec); + JSUint8ClampedArray* castedThis = jsCast(asObject(thisValue)); + ASSERT_GC_OBJECT_INHERITS(castedThis, &JSUint8ClampedArray::s_info); + return JSValue::encode(castedThis->set(exec)); +} + +// Constant getters + +JSValue jsUint8ClampedArrayBYTES_PER_ELEMENT(ExecState* exec, JSValue, const Identifier&) +{ + UNUSED_PARAM(exec); + return jsNumber(static_cast(1)); +} + + +JSValue JSUint8ClampedArray::getByIndex(ExecState*, unsigned index) +{ + ASSERT_GC_OBJECT_INHERITS(this, &s_info); + double result = static_cast(impl())->item(index); + if (isnan(result)) + return jsNaN(); + return JSValue(result); +} + +Uint8ClampedArray* toUint8ClampedArray(JSC::JSValue value) +{ + return value.inherits(&JSUint8ClampedArray::s_info) ? jsCast(asObject(value))->impl() : 0; +} + +} diff --git a/JavaScriptCore/runtime/TypedArrays/JSUint8ClampedArray.h b/JavaScriptCore/runtime/TypedArrays/JSUint8ClampedArray.h new file mode 100644 index 00000000..31296398 --- /dev/null +++ b/JavaScriptCore/runtime/TypedArrays/JSUint8ClampedArray.h @@ -0,0 +1,143 @@ +/* + 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. +*/ + +#ifndef JSUint8ClampedArray_h +#define JSUint8ClampedArray_h + +#include "JSDOMBinding.h" +#include "JSUint8Array.h" +#include +#include + +namespace WebCore { + +class JSUint8ClampedArray : public JSUint8Array { +public: + typedef JSUint8Array Base; + static JSUint8ClampedArray* create(JSC::Structure* structure, JSDOMGlobalObject* globalObject, PassRefPtr impl) + { + JSUint8ClampedArray* ptr = new (NotNull, JSC::allocateCell(globalObject->globalData().heap)) JSUint8ClampedArray(structure, globalObject, impl); + ptr->finishCreation(globalObject->globalData()); + return ptr; + } + + static JSC::JSObject* createPrototype(JSC::ExecState*, JSC::JSGlobalObject*); + static bool getOwnPropertySlot(JSC::JSCell*, JSC::ExecState*, const JSC::Identifier& propertyName, JSC::PropertySlot&); + static bool getOwnPropertyDescriptor(JSC::JSObject*, JSC::ExecState*, const JSC::Identifier& propertyName, JSC::PropertyDescriptor&); + static bool getOwnPropertySlotByIndex(JSC::JSCell*, JSC::ExecState*, unsigned propertyName, JSC::PropertySlot&); + static void put(JSC::JSCell*, JSC::ExecState*, const JSC::Identifier& propertyName, JSC::JSValue, JSC::PutPropertySlot&); + static void putByIndex(JSC::JSCell*, JSC::ExecState*, unsigned propertyName, JSC::JSValue, bool shouldThrow); + static const JSC::ClassInfo s_info; + + static JSC::Structure* createStructure(JSC::JSGlobalData& globalData, JSC::JSGlobalObject* globalObject, JSC::JSValue prototype) + { + return JSC::Structure::create(globalData, globalObject, prototype, JSC::TypeInfo(JSC::ObjectType, StructureFlags), &s_info); + } + + static void getOwnPropertyNames(JSC::JSObject*, JSC::ExecState*, JSC::PropertyNameArray&, JSC::EnumerationMode mode = JSC::ExcludeDontEnumProperties); + static JSC::JSValue getConstructor(JSC::ExecState*, JSC::JSGlobalObject*); + + // Custom functions + JSC::JSValue set(JSC::ExecState*); + Uint8ClampedArray* impl() const + { + return static_cast(Base::impl()); + } + static const JSC::TypedArrayType TypedArrayStorageType = JSC::TypedArrayUint8Clamped; + intptr_t m_storageLength; + void* m_storage; +protected: + JSUint8ClampedArray(JSC::Structure*, JSDOMGlobalObject*, PassRefPtr); + void finishCreation(JSC::JSGlobalData&); + static const unsigned StructureFlags = JSC::OverridesGetPropertyNames | JSC::OverridesGetOwnPropertySlot | Base::StructureFlags; + JSC::JSValue getByIndex(JSC::ExecState*, unsigned index); + void indexSetter(JSC::ExecState*, unsigned index, JSC::JSValue); +}; + +JSC::JSValue toJS(JSC::ExecState*, JSDOMGlobalObject*, Uint8ClampedArray*); +Uint8ClampedArray* toUint8ClampedArray(JSC::JSValue); + +class JSUint8ClampedArrayPrototype : public JSC::JSNonFinalObject { +public: + typedef JSC::JSNonFinalObject Base; + static JSC::JSObject* self(JSC::ExecState*, JSC::JSGlobalObject*); + static JSUint8ClampedArrayPrototype* create(JSC::JSGlobalData& globalData, JSC::JSGlobalObject* globalObject, JSC::Structure* structure) + { + JSUint8ClampedArrayPrototype* ptr = new (NotNull, JSC::allocateCell(globalData.heap)) JSUint8ClampedArrayPrototype(globalData, globalObject, structure); + ptr->finishCreation(globalData); + return ptr; + } + + static const JSC::ClassInfo s_info; + static bool getOwnPropertySlot(JSC::JSCell*, JSC::ExecState*, const JSC::Identifier&, JSC::PropertySlot&); + static bool getOwnPropertyDescriptor(JSC::JSObject*, JSC::ExecState*, const JSC::Identifier&, JSC::PropertyDescriptor&); + static JSC::Structure* createStructure(JSC::JSGlobalData& globalData, JSC::JSGlobalObject* globalObject, JSC::JSValue prototype) + { + return JSC::Structure::create(globalData, globalObject, prototype, JSC::TypeInfo(JSC::ObjectType, StructureFlags), &s_info); + } + +private: + JSUint8ClampedArrayPrototype(JSC::JSGlobalData& globalData, JSC::JSGlobalObject*, JSC::Structure* structure) : JSC::JSNonFinalObject(globalData, structure) { } +protected: + static const unsigned StructureFlags = JSC::OverridesGetOwnPropertySlot | Base::StructureFlags; +}; + +class JSUint8ClampedArrayConstructor : public DOMConstructorObject { +private: + JSUint8ClampedArrayConstructor(JSC::Structure*, JSDOMGlobalObject*); + void finishCreation(JSC::ExecState*, JSDOMGlobalObject*); + +public: + typedef DOMConstructorObject Base; + static JSUint8ClampedArrayConstructor* create(JSC::ExecState* exec, JSC::Structure* structure, JSDOMGlobalObject* globalObject) + { + JSUint8ClampedArrayConstructor* ptr = new (NotNull, JSC::allocateCell(*exec->heap())) JSUint8ClampedArrayConstructor(structure, globalObject); + ptr->finishCreation(exec, globalObject); + return ptr; + } + + static bool getOwnPropertySlot(JSC::JSCell*, JSC::ExecState*, const JSC::Identifier&, JSC::PropertySlot&); + static bool getOwnPropertyDescriptor(JSC::JSObject*, JSC::ExecState*, const JSC::Identifier&, JSC::PropertyDescriptor&); + static const JSC::ClassInfo s_info; + static JSC::Structure* createStructure(JSC::JSGlobalData& globalData, JSC::JSGlobalObject* globalObject, JSC::JSValue prototype) + { + return JSC::Structure::create(globalData, globalObject, prototype, JSC::TypeInfo(JSC::ObjectType, StructureFlags), &s_info); + } +protected: + static const unsigned StructureFlags = JSC::OverridesGetOwnPropertySlot | JSC::ImplementsHasInstance | DOMConstructorObject::StructureFlags; + static JSC::EncodedJSValue JSC_HOST_CALL constructJSUint8ClampedArray(JSC::ExecState*); + static JSC::ConstructType getConstructData(JSC::JSCell*, JSC::ConstructData&); +}; + +// Functions + +JSC::EncodedJSValue JSC_HOST_CALL jsUint8ClampedArrayPrototypeFunctionSubarray(JSC::ExecState*); +JSC::EncodedJSValue JSC_HOST_CALL jsUint8ClampedArrayPrototypeFunctionSet(JSC::ExecState*); +// Attributes + +JSC::JSValue jsUint8ClampedArrayLength(JSC::ExecState*, JSC::JSValue, const JSC::Identifier&); +JSC::JSValue jsUint8ClampedArrayConstructor(JSC::ExecState*, JSC::JSValue, const JSC::Identifier&); +// Constants + +JSC::JSValue jsUint8ClampedArrayBYTES_PER_ELEMENT(JSC::ExecState*, JSC::JSValue, const JSC::Identifier&); + +} // namespace WebCore + +#endif diff --git a/JavaScriptCore/runtime/TypedArrays/JSUint8ClampedArrayCustom.cpp b/JavaScriptCore/runtime/TypedArrays/JSUint8ClampedArrayCustom.cpp new file mode 100644 index 00000000..2d5ca785 --- /dev/null +++ b/JavaScriptCore/runtime/TypedArrays/JSUint8ClampedArrayCustom.cpp @@ -0,0 +1,61 @@ +/* + * Copyright (C) 2009 Apple Inc. All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY APPLE COMPUTER, INC. ``AS IS'' AND ANY + * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR + * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE COMPUTER, INC. OR + * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, + * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, + * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR + * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY + * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE + * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + */ + +#include "config.h" +#include "JSUint8ClampedArray.h" + +#include "JSArrayBufferViewHelper.h" +#include + +using namespace JSC; + +namespace WebCore { + +void JSUint8ClampedArray::indexSetter(JSC::ExecState* exec, unsigned index, JSC::JSValue value) +{ + impl()->set(index, value.toNumber(exec)); +} + +JSC::JSValue toJS(JSC::ExecState* exec, JSDOMGlobalObject* globalObject, Uint8ClampedArray* object) +{ + return toJSArrayBufferView(exec, globalObject, object); +} + +JSC::JSValue JSUint8ClampedArray::set(JSC::ExecState* exec) +{ + return setWebGLArrayHelper(exec, impl(), toUint8ClampedArray); +} + +EncodedJSValue JSC_HOST_CALL JSUint8ClampedArrayConstructor::constructJSUint8ClampedArray(ExecState* exec) +{ + JSUint8ClampedArrayConstructor* jsConstructor = jsCast(exec->callee()); + RefPtr array = constructArrayBufferView(exec); + if (!array.get()) + // Exception has already been thrown. + return JSValue::encode(JSValue()); + return JSValue::encode(asObject(toJS(exec, jsConstructor->globalObject(), array.get()))); +} + +} // namespace WebCore From d24a0d99b879f333f604c5a873b775646254ada4 Mon Sep 17 00:00:00 2001 From: Dominic Szablewski Date: Mon, 10 Dec 2012 00:15:17 +0100 Subject: [PATCH 10/30] Cosmetics: use proto object previously obtained --- JavaScriptCore/runtime/TypedArrays/JSFloat32Array.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/JavaScriptCore/runtime/TypedArrays/JSFloat32Array.cpp b/JavaScriptCore/runtime/TypedArrays/JSFloat32Array.cpp index 00f1422b..4117a307 100644 --- a/JavaScriptCore/runtime/TypedArrays/JSFloat32Array.cpp +++ b/JavaScriptCore/runtime/TypedArrays/JSFloat32Array.cpp @@ -66,7 +66,7 @@ void JSFloat32ArrayConstructor::finishCreation(ExecState* exec, JSGlobalObject* JSC::JSObject * proto = JSFloat32ArrayPrototype::self(exec, globalObject); Base::finishCreation(exec->globalData(), Identifier(exec, proto->classInfo()->className)); ASSERT(inherits(&s_info)); - putDirect(exec->globalData(), exec->propertyNames().prototype, JSFloat32ArrayPrototype::self(exec, globalObject), DontDelete | ReadOnly); + putDirect(exec->globalData(), exec->propertyNames().prototype, proto, DontDelete | ReadOnly); putDirect(exec->globalData(), exec->propertyNames().length, jsNumber(1), ReadOnly | DontDelete | DontEnum); } From 03f5e79fb6460cec809a3da71dcc4e73f21ef5dc Mon Sep 17 00:00:00 2001 From: Dominic Szablewski Date: Mon, 10 Dec 2012 00:20:54 +0100 Subject: [PATCH 11/30] Fixed up all Array types to use GlobalDataHelper.h; removed missing WebCore references --- .../runtime/TypedArrays/JSFloat64Array.cpp | 26 +++++++++-------- .../runtime/TypedArrays/JSFloat64Array.h | 20 ++++++------- .../TypedArrays/JSFloat64ArrayCustom.cpp | 2 +- .../runtime/TypedArrays/JSInt16Array.cpp | 26 +++++++++-------- .../runtime/TypedArrays/JSInt16Array.h | 20 ++++++------- .../TypedArrays/JSInt16ArrayCustom.cpp | 2 +- .../runtime/TypedArrays/JSInt32Array.cpp | 26 +++++++++-------- .../runtime/TypedArrays/JSInt32Array.h | 20 ++++++------- .../TypedArrays/JSInt32ArrayCustom.cpp | 2 +- .../runtime/TypedArrays/JSInt8Array.cpp | 28 ++++++++++--------- .../runtime/TypedArrays/JSInt8Array.h | 20 ++++++------- .../runtime/TypedArrays/JSInt8ArrayCustom.cpp | 2 +- .../runtime/TypedArrays/JSUint16Array.cpp | 26 +++++++++-------- .../runtime/TypedArrays/JSUint16Array.h | 20 ++++++------- .../TypedArrays/JSUint16ArrayCustom.cpp | 2 +- .../runtime/TypedArrays/JSUint32Array.cpp | 26 +++++++++-------- .../runtime/TypedArrays/JSUint32Array.h | 20 ++++++------- .../TypedArrays/JSUint32ArrayCustom.cpp | 2 +- .../runtime/TypedArrays/JSUint8Array.cpp | 26 +++++++++-------- .../runtime/TypedArrays/JSUint8Array.h | 20 ++++++------- .../TypedArrays/JSUint8ArrayCustom.cpp | 2 +- .../TypedArrays/JSUint8ClampedArray.cpp | 26 +++++++++-------- .../runtime/TypedArrays/JSUint8ClampedArray.h | 20 ++++++------- .../TypedArrays/JSUint8ClampedArrayCustom.cpp | 2 +- 24 files changed, 201 insertions(+), 185 deletions(-) diff --git a/JavaScriptCore/runtime/TypedArrays/JSFloat64Array.cpp b/JavaScriptCore/runtime/TypedArrays/JSFloat64Array.cpp index 178efb63..f3c3f3be 100644 --- a/JavaScriptCore/runtime/TypedArrays/JSFloat64Array.cpp +++ b/JavaScriptCore/runtime/TypedArrays/JSFloat64Array.cpp @@ -21,8 +21,9 @@ #include "config.h" #include "JSFloat64Array.h" -#include "ExceptionCode.h" -#include "JSDOMBinding.h" +#include "Lookup.h" +#include "GlobalDataHelper.h" + #include "JSFloat64Array.h" #include #include @@ -55,27 +56,28 @@ static const HashTableValue JSFloat64ArrayConstructorTableValues[] = static const HashTable JSFloat64ArrayConstructorTable = { 2, 1, JSFloat64ArrayConstructorTableValues, 0 }; const ClassInfo JSFloat64ArrayConstructor::s_info = { "Float64ArrayConstructor", &Base::s_info, &JSFloat64ArrayConstructorTable, 0, CREATE_METHOD_TABLE(JSFloat64ArrayConstructor) }; -JSFloat64ArrayConstructor::JSFloat64ArrayConstructor(Structure* structure, JSDOMGlobalObject* globalObject) - : DOMConstructorObject(structure, globalObject) +JSFloat64ArrayConstructor::JSFloat64ArrayConstructor(Structure* structure, JSC::JSGlobalObject* globalObject) + : InternalFunction(globalObject, structure) { } -void JSFloat64ArrayConstructor::finishCreation(ExecState* exec, JSDOMGlobalObject* globalObject) +void JSFloat64ArrayConstructor::finishCreation(ExecState* exec, JSC::JSGlobalObject* globalObject) { - Base::finishCreation(exec->globalData()); + JSC::JSObject * proto = JSFloat64ArrayPrototype::self(exec, globalObject); + Base::finishCreation(exec->globalData(), Identifier(exec, proto->classInfo()->className)); ASSERT(inherits(&s_info)); - putDirect(exec->globalData(), exec->propertyNames().prototype, JSFloat64ArrayPrototype::self(exec, globalObject), DontDelete | ReadOnly); + putDirect(exec->globalData(), exec->propertyNames().prototype, proto, DontDelete | ReadOnly); putDirect(exec->globalData(), exec->propertyNames().length, jsNumber(1), ReadOnly | DontDelete | DontEnum); } bool JSFloat64ArrayConstructor::getOwnPropertySlot(JSCell* cell, ExecState* exec, const Identifier& propertyName, PropertySlot& slot) { - return getStaticValueSlot(exec, &JSFloat64ArrayConstructorTable, jsCast(cell), propertyName, slot); + return getStaticFunctionSlot(exec, &JSFloat64ArrayConstructorTable, jsCast(cell), propertyName, slot); } bool JSFloat64ArrayConstructor::getOwnPropertyDescriptor(JSObject* object, ExecState* exec, const Identifier& propertyName, PropertyDescriptor& descriptor) { - return getStaticValueDescriptor(exec, &JSFloat64ArrayConstructorTable, jsCast(object), propertyName, descriptor); + return getStaticFunctionDescriptor(exec, &JSFloat64ArrayConstructorTable, jsCast(object), propertyName, descriptor); } ConstructType JSFloat64ArrayConstructor::getConstructData(JSCell*, ConstructData& constructData) @@ -104,7 +106,7 @@ const ClassInfo JSFloat64ArrayPrototype::s_info = { "Float64ArrayPrototype", &Ba JSObject* JSFloat64ArrayPrototype::self(ExecState* exec, JSGlobalObject* globalObject) { - return getDOMPrototype(exec, globalObject); + return getDOMPrototype(exec, globalObject); } bool JSFloat64ArrayPrototype::getOwnPropertySlot(JSCell* cell, ExecState* exec, const Identifier& propertyName, PropertySlot& slot) @@ -126,7 +128,7 @@ static const HashTable* getJSFloat64ArrayTable(ExecState* exec) const ClassInfo JSFloat64Array::s_info = { "Float64Array", &Base::s_info, 0, getJSFloat64ArrayTable , CREATE_METHOD_TABLE(JSFloat64Array) }; -JSFloat64Array::JSFloat64Array(Structure* structure, JSDOMGlobalObject* globalObject, PassRefPtr impl) +JSFloat64Array::JSFloat64Array(Structure* structure, JSGlobalObject* globalObject, PassRefPtr impl) : JSArrayBufferView(structure, globalObject, impl) { } @@ -231,7 +233,7 @@ void JSFloat64Array::getOwnPropertyNames(JSObject* object, ExecState* exec, Prop JSValue JSFloat64Array::getConstructor(ExecState* exec, JSGlobalObject* globalObject) { - return getDOMConstructor(exec, jsCast(globalObject)); + return getDOMConstructor(exec, jsCast(globalObject)); } EncodedJSValue JSC_HOST_CALL jsFloat64ArrayPrototypeFunctionSubarray(ExecState* exec) diff --git a/JavaScriptCore/runtime/TypedArrays/JSFloat64Array.h b/JavaScriptCore/runtime/TypedArrays/JSFloat64Array.h index 4b9cfe4b..3b8c0484 100644 --- a/JavaScriptCore/runtime/TypedArrays/JSFloat64Array.h +++ b/JavaScriptCore/runtime/TypedArrays/JSFloat64Array.h @@ -22,7 +22,7 @@ #define JSFloat64Array_h #include "JSArrayBufferView.h" -#include "JSDOMBinding.h" +#include "InternalFunction.h" #include #include @@ -31,7 +31,7 @@ namespace WebCore { class JSFloat64Array : public JSArrayBufferView { public: typedef JSArrayBufferView Base; - static JSFloat64Array* create(JSC::Structure* structure, JSDOMGlobalObject* globalObject, PassRefPtr impl) + static JSFloat64Array* create(JSC::Structure* structure, JSC::JSGlobalObject* globalObject, PassRefPtr impl) { JSFloat64Array* ptr = new (NotNull, JSC::allocateCell(globalObject->globalData().heap)) JSFloat64Array(structure, globalObject, impl); ptr->finishCreation(globalObject->globalData()); @@ -64,14 +64,14 @@ class JSFloat64Array : public JSArrayBufferView { intptr_t m_storageLength; void* m_storage; protected: - JSFloat64Array(JSC::Structure*, JSDOMGlobalObject*, PassRefPtr); + JSFloat64Array(JSC::Structure*, JSC::JSGlobalObject*, PassRefPtr); void finishCreation(JSC::JSGlobalData&); static const unsigned StructureFlags = JSC::OverridesGetPropertyNames | JSC::OverridesGetOwnPropertySlot | Base::StructureFlags; JSC::JSValue getByIndex(JSC::ExecState*, unsigned index); void indexSetter(JSC::ExecState*, unsigned index, JSC::JSValue); }; -JSC::JSValue toJS(JSC::ExecState*, JSDOMGlobalObject*, Float64Array*); +JSC::JSValue toJS(JSC::ExecState*, JSC::JSGlobalObject*, Float64Array*); Float64Array* toFloat64Array(JSC::JSValue); class JSFloat64ArrayPrototype : public JSC::JSNonFinalObject { @@ -99,14 +99,14 @@ class JSFloat64ArrayPrototype : public JSC::JSNonFinalObject { static const unsigned StructureFlags = JSC::OverridesGetOwnPropertySlot | Base::StructureFlags; }; -class JSFloat64ArrayConstructor : public DOMConstructorObject { +class JSFloat64ArrayConstructor : public JSC::InternalFunction { private: - JSFloat64ArrayConstructor(JSC::Structure*, JSDOMGlobalObject*); - void finishCreation(JSC::ExecState*, JSDOMGlobalObject*); + JSFloat64ArrayConstructor(JSC::Structure*, JSC::JSGlobalObject*); + void finishCreation(JSC::ExecState*, JSC::JSGlobalObject*); public: - typedef DOMConstructorObject Base; - static JSFloat64ArrayConstructor* create(JSC::ExecState* exec, JSC::Structure* structure, JSDOMGlobalObject* globalObject) + typedef JSC::InternalFunction Base; + static JSFloat64ArrayConstructor* create(JSC::ExecState* exec, JSC::Structure* structure, JSC::JSGlobalObject* globalObject) { JSFloat64ArrayConstructor* ptr = new (NotNull, JSC::allocateCell(*exec->heap())) JSFloat64ArrayConstructor(structure, globalObject); ptr->finishCreation(exec, globalObject); @@ -121,7 +121,7 @@ class JSFloat64ArrayConstructor : public DOMConstructorObject { return JSC::Structure::create(globalData, globalObject, prototype, JSC::TypeInfo(JSC::ObjectType, StructureFlags), &s_info); } protected: - static const unsigned StructureFlags = JSC::OverridesGetOwnPropertySlot | JSC::ImplementsHasInstance | DOMConstructorObject::StructureFlags; + static const unsigned StructureFlags = JSC::OverridesGetOwnPropertySlot | JSC::ImplementsHasInstance | JSC::InternalFunction::StructureFlags; static JSC::EncodedJSValue JSC_HOST_CALL constructJSFloat64Array(JSC::ExecState*); static JSC::ConstructType getConstructData(JSC::JSCell*, JSC::ConstructData&); }; diff --git a/JavaScriptCore/runtime/TypedArrays/JSFloat64ArrayCustom.cpp b/JavaScriptCore/runtime/TypedArrays/JSFloat64ArrayCustom.cpp index 15619e32..8c05ae91 100644 --- a/JavaScriptCore/runtime/TypedArrays/JSFloat64ArrayCustom.cpp +++ b/JavaScriptCore/runtime/TypedArrays/JSFloat64ArrayCustom.cpp @@ -38,7 +38,7 @@ void JSFloat64Array::indexSetter(JSC::ExecState* exec, unsigned index, JSC::JSVa impl()->set(index, value.toNumber(exec)); } -JSC::JSValue toJS(JSC::ExecState* exec, JSDOMGlobalObject* globalObject, Float64Array* object) +JSC::JSValue toJS(JSC::ExecState* exec, JSGlobalObject* globalObject, Float64Array* object) { return toJSArrayBufferView(exec, globalObject, object); } diff --git a/JavaScriptCore/runtime/TypedArrays/JSInt16Array.cpp b/JavaScriptCore/runtime/TypedArrays/JSInt16Array.cpp index e1fcd69d..bc21ec7c 100644 --- a/JavaScriptCore/runtime/TypedArrays/JSInt16Array.cpp +++ b/JavaScriptCore/runtime/TypedArrays/JSInt16Array.cpp @@ -21,8 +21,9 @@ #include "config.h" #include "JSInt16Array.h" -#include "ExceptionCode.h" -#include "JSDOMBinding.h" +#include "Lookup.h" +#include "GlobalDataHelper.h" + #include "JSInt16Array.h" #include #include @@ -55,27 +56,28 @@ static const HashTableValue JSInt16ArrayConstructorTableValues[] = static const HashTable JSInt16ArrayConstructorTable = { 2, 1, JSInt16ArrayConstructorTableValues, 0 }; const ClassInfo JSInt16ArrayConstructor::s_info = { "Int16ArrayConstructor", &Base::s_info, &JSInt16ArrayConstructorTable, 0, CREATE_METHOD_TABLE(JSInt16ArrayConstructor) }; -JSInt16ArrayConstructor::JSInt16ArrayConstructor(Structure* structure, JSDOMGlobalObject* globalObject) - : DOMConstructorObject(structure, globalObject) +JSInt16ArrayConstructor::JSInt16ArrayConstructor(Structure* structure, JSGlobalObject* globalObject) + : InternalFunction(globalObject, structure) { } -void JSInt16ArrayConstructor::finishCreation(ExecState* exec, JSDOMGlobalObject* globalObject) +void JSInt16ArrayConstructor::finishCreation(ExecState* exec, JSGlobalObject* globalObject) { - Base::finishCreation(exec->globalData()); + JSC::JSObject * proto = JSInt16ArrayPrototype::self(exec, globalObject); + Base::finishCreation(exec->globalData(), Identifier(exec, proto->classInfo()->className)); ASSERT(inherits(&s_info)); - putDirect(exec->globalData(), exec->propertyNames().prototype, JSInt16ArrayPrototype::self(exec, globalObject), DontDelete | ReadOnly); + putDirect(exec->globalData(), exec->propertyNames().prototype, proto, DontDelete | ReadOnly); putDirect(exec->globalData(), exec->propertyNames().length, jsNumber(1), ReadOnly | DontDelete | DontEnum); } bool JSInt16ArrayConstructor::getOwnPropertySlot(JSCell* cell, ExecState* exec, const Identifier& propertyName, PropertySlot& slot) { - return getStaticValueSlot(exec, &JSInt16ArrayConstructorTable, jsCast(cell), propertyName, slot); + return getStaticFunctionSlot(exec, &JSInt16ArrayConstructorTable, jsCast(cell), propertyName, slot); } bool JSInt16ArrayConstructor::getOwnPropertyDescriptor(JSObject* object, ExecState* exec, const Identifier& propertyName, PropertyDescriptor& descriptor) { - return getStaticValueDescriptor(exec, &JSInt16ArrayConstructorTable, jsCast(object), propertyName, descriptor); + return getStaticFunctionDescriptor(exec, &JSInt16ArrayConstructorTable, jsCast(object), propertyName, descriptor); } ConstructType JSInt16ArrayConstructor::getConstructData(JSCell*, ConstructData& constructData) @@ -104,7 +106,7 @@ const ClassInfo JSInt16ArrayPrototype::s_info = { "Int16ArrayPrototype", &Base:: JSObject* JSInt16ArrayPrototype::self(ExecState* exec, JSGlobalObject* globalObject) { - return getDOMPrototype(exec, globalObject); + return getDOMPrototype(exec, globalObject); } bool JSInt16ArrayPrototype::getOwnPropertySlot(JSCell* cell, ExecState* exec, const Identifier& propertyName, PropertySlot& slot) @@ -126,7 +128,7 @@ static const HashTable* getJSInt16ArrayTable(ExecState* exec) const ClassInfo JSInt16Array::s_info = { "Int16Array", &Base::s_info, 0, getJSInt16ArrayTable , CREATE_METHOD_TABLE(JSInt16Array) }; -JSInt16Array::JSInt16Array(Structure* structure, JSDOMGlobalObject* globalObject, PassRefPtr impl) +JSInt16Array::JSInt16Array(Structure* structure, JSGlobalObject* globalObject, PassRefPtr impl) : JSArrayBufferView(structure, globalObject, impl) { } @@ -231,7 +233,7 @@ void JSInt16Array::getOwnPropertyNames(JSObject* object, ExecState* exec, Proper JSValue JSInt16Array::getConstructor(ExecState* exec, JSGlobalObject* globalObject) { - return getDOMConstructor(exec, jsCast(globalObject)); + return getDOMConstructor(exec, jsCast(globalObject)); } EncodedJSValue JSC_HOST_CALL jsInt16ArrayPrototypeFunctionSubarray(ExecState* exec) diff --git a/JavaScriptCore/runtime/TypedArrays/JSInt16Array.h b/JavaScriptCore/runtime/TypedArrays/JSInt16Array.h index 077dfc98..b0c8f18d 100644 --- a/JavaScriptCore/runtime/TypedArrays/JSInt16Array.h +++ b/JavaScriptCore/runtime/TypedArrays/JSInt16Array.h @@ -22,7 +22,7 @@ #define JSInt16Array_h #include "JSArrayBufferView.h" -#include "JSDOMBinding.h" +#include "InternalFunction.h" #include #include @@ -31,7 +31,7 @@ namespace WebCore { class JSInt16Array : public JSArrayBufferView { public: typedef JSArrayBufferView Base; - static JSInt16Array* create(JSC::Structure* structure, JSDOMGlobalObject* globalObject, PassRefPtr impl) + static JSInt16Array* create(JSC::Structure* structure, JSC::JSGlobalObject* globalObject, PassRefPtr impl) { JSInt16Array* ptr = new (NotNull, JSC::allocateCell(globalObject->globalData().heap)) JSInt16Array(structure, globalObject, impl); ptr->finishCreation(globalObject->globalData()); @@ -64,14 +64,14 @@ class JSInt16Array : public JSArrayBufferView { intptr_t m_storageLength; void* m_storage; protected: - JSInt16Array(JSC::Structure*, JSDOMGlobalObject*, PassRefPtr); + JSInt16Array(JSC::Structure*, JSC::JSGlobalObject*, PassRefPtr); void finishCreation(JSC::JSGlobalData&); static const unsigned StructureFlags = JSC::OverridesGetPropertyNames | JSC::OverridesGetOwnPropertySlot | Base::StructureFlags; JSC::JSValue getByIndex(JSC::ExecState*, unsigned index); void indexSetter(JSC::ExecState*, unsigned index, JSC::JSValue); }; -JSC::JSValue toJS(JSC::ExecState*, JSDOMGlobalObject*, Int16Array*); +JSC::JSValue toJS(JSC::ExecState*, JSC::JSGlobalObject*, Int16Array*); Int16Array* toInt16Array(JSC::JSValue); class JSInt16ArrayPrototype : public JSC::JSNonFinalObject { @@ -99,14 +99,14 @@ class JSInt16ArrayPrototype : public JSC::JSNonFinalObject { static const unsigned StructureFlags = JSC::OverridesGetOwnPropertySlot | Base::StructureFlags; }; -class JSInt16ArrayConstructor : public DOMConstructorObject { +class JSInt16ArrayConstructor : public JSC::InternalFunction { private: - JSInt16ArrayConstructor(JSC::Structure*, JSDOMGlobalObject*); - void finishCreation(JSC::ExecState*, JSDOMGlobalObject*); + JSInt16ArrayConstructor(JSC::Structure*, JSC::JSGlobalObject*); + void finishCreation(JSC::ExecState*, JSC::JSGlobalObject*); public: - typedef DOMConstructorObject Base; - static JSInt16ArrayConstructor* create(JSC::ExecState* exec, JSC::Structure* structure, JSDOMGlobalObject* globalObject) + typedef JSC::InternalFunction Base; + static JSInt16ArrayConstructor* create(JSC::ExecState* exec, JSC::Structure* structure, JSC::JSGlobalObject* globalObject) { JSInt16ArrayConstructor* ptr = new (NotNull, JSC::allocateCell(*exec->heap())) JSInt16ArrayConstructor(structure, globalObject); ptr->finishCreation(exec, globalObject); @@ -121,7 +121,7 @@ class JSInt16ArrayConstructor : public DOMConstructorObject { return JSC::Structure::create(globalData, globalObject, prototype, JSC::TypeInfo(JSC::ObjectType, StructureFlags), &s_info); } protected: - static const unsigned StructureFlags = JSC::OverridesGetOwnPropertySlot | JSC::ImplementsHasInstance | DOMConstructorObject::StructureFlags; + static const unsigned StructureFlags = JSC::OverridesGetOwnPropertySlot | JSC::ImplementsHasInstance | JSC::InternalFunction::StructureFlags; static JSC::EncodedJSValue JSC_HOST_CALL constructJSInt16Array(JSC::ExecState*); static JSC::ConstructType getConstructData(JSC::JSCell*, JSC::ConstructData&); }; diff --git a/JavaScriptCore/runtime/TypedArrays/JSInt16ArrayCustom.cpp b/JavaScriptCore/runtime/TypedArrays/JSInt16ArrayCustom.cpp index bc77a6d2..1c6c50b6 100644 --- a/JavaScriptCore/runtime/TypedArrays/JSInt16ArrayCustom.cpp +++ b/JavaScriptCore/runtime/TypedArrays/JSInt16ArrayCustom.cpp @@ -38,7 +38,7 @@ void JSInt16Array::indexSetter(JSC::ExecState* exec, unsigned index, JSC::JSValu impl()->set(index, static_cast(value.toInt32(exec))); } -JSC::JSValue toJS(JSC::ExecState* exec, JSDOMGlobalObject* globalObject, Int16Array* object) +JSC::JSValue toJS(JSC::ExecState* exec, JSGlobalObject* globalObject, Int16Array* object) { return toJSArrayBufferView(exec, globalObject, object); } diff --git a/JavaScriptCore/runtime/TypedArrays/JSInt32Array.cpp b/JavaScriptCore/runtime/TypedArrays/JSInt32Array.cpp index 653480c7..ee908966 100644 --- a/JavaScriptCore/runtime/TypedArrays/JSInt32Array.cpp +++ b/JavaScriptCore/runtime/TypedArrays/JSInt32Array.cpp @@ -21,8 +21,9 @@ #include "config.h" #include "JSInt32Array.h" -#include "ExceptionCode.h" -#include "JSDOMBinding.h" +#include "Lookup.h" +#include "GlobalDataHelper.h" + #include "JSInt32Array.h" #include #include @@ -55,27 +56,28 @@ static const HashTableValue JSInt32ArrayConstructorTableValues[] = static const HashTable JSInt32ArrayConstructorTable = { 2, 1, JSInt32ArrayConstructorTableValues, 0 }; const ClassInfo JSInt32ArrayConstructor::s_info = { "Int32ArrayConstructor", &Base::s_info, &JSInt32ArrayConstructorTable, 0, CREATE_METHOD_TABLE(JSInt32ArrayConstructor) }; -JSInt32ArrayConstructor::JSInt32ArrayConstructor(Structure* structure, JSDOMGlobalObject* globalObject) - : DOMConstructorObject(structure, globalObject) +JSInt32ArrayConstructor::JSInt32ArrayConstructor(Structure* structure, JSGlobalObject* globalObject) + : InternalFunction(globalObject, structure) { } -void JSInt32ArrayConstructor::finishCreation(ExecState* exec, JSDOMGlobalObject* globalObject) +void JSInt32ArrayConstructor::finishCreation(ExecState* exec, JSGlobalObject* globalObject) { - Base::finishCreation(exec->globalData()); + JSC::JSObject * proto = JSInt32ArrayPrototype::self(exec, globalObject); + Base::finishCreation(exec->globalData(), Identifier(exec, proto->classInfo()->className)); ASSERT(inherits(&s_info)); - putDirect(exec->globalData(), exec->propertyNames().prototype, JSInt32ArrayPrototype::self(exec, globalObject), DontDelete | ReadOnly); + putDirect(exec->globalData(), exec->propertyNames().prototype, proto, DontDelete | ReadOnly); putDirect(exec->globalData(), exec->propertyNames().length, jsNumber(1), ReadOnly | DontDelete | DontEnum); } bool JSInt32ArrayConstructor::getOwnPropertySlot(JSCell* cell, ExecState* exec, const Identifier& propertyName, PropertySlot& slot) { - return getStaticValueSlot(exec, &JSInt32ArrayConstructorTable, jsCast(cell), propertyName, slot); + return getStaticFunctionSlot(exec, &JSInt32ArrayConstructorTable, jsCast(cell), propertyName, slot); } bool JSInt32ArrayConstructor::getOwnPropertyDescriptor(JSObject* object, ExecState* exec, const Identifier& propertyName, PropertyDescriptor& descriptor) { - return getStaticValueDescriptor(exec, &JSInt32ArrayConstructorTable, jsCast(object), propertyName, descriptor); + return getStaticFunctionDescriptor(exec, &JSInt32ArrayConstructorTable, jsCast(object), propertyName, descriptor); } ConstructType JSInt32ArrayConstructor::getConstructData(JSCell*, ConstructData& constructData) @@ -104,7 +106,7 @@ const ClassInfo JSInt32ArrayPrototype::s_info = { "Int32ArrayPrototype", &Base:: JSObject* JSInt32ArrayPrototype::self(ExecState* exec, JSGlobalObject* globalObject) { - return getDOMPrototype(exec, globalObject); + return getDOMPrototype(exec, globalObject); } bool JSInt32ArrayPrototype::getOwnPropertySlot(JSCell* cell, ExecState* exec, const Identifier& propertyName, PropertySlot& slot) @@ -126,7 +128,7 @@ static const HashTable* getJSInt32ArrayTable(ExecState* exec) const ClassInfo JSInt32Array::s_info = { "Int32Array", &Base::s_info, 0, getJSInt32ArrayTable , CREATE_METHOD_TABLE(JSInt32Array) }; -JSInt32Array::JSInt32Array(Structure* structure, JSDOMGlobalObject* globalObject, PassRefPtr impl) +JSInt32Array::JSInt32Array(Structure* structure, JSGlobalObject* globalObject, PassRefPtr impl) : JSArrayBufferView(structure, globalObject, impl) { } @@ -231,7 +233,7 @@ void JSInt32Array::getOwnPropertyNames(JSObject* object, ExecState* exec, Proper JSValue JSInt32Array::getConstructor(ExecState* exec, JSGlobalObject* globalObject) { - return getDOMConstructor(exec, jsCast(globalObject)); + return getDOMConstructor(exec, jsCast(globalObject)); } EncodedJSValue JSC_HOST_CALL jsInt32ArrayPrototypeFunctionSubarray(ExecState* exec) diff --git a/JavaScriptCore/runtime/TypedArrays/JSInt32Array.h b/JavaScriptCore/runtime/TypedArrays/JSInt32Array.h index b6cc3d90..dc8ee7c9 100644 --- a/JavaScriptCore/runtime/TypedArrays/JSInt32Array.h +++ b/JavaScriptCore/runtime/TypedArrays/JSInt32Array.h @@ -22,7 +22,7 @@ #define JSInt32Array_h #include "JSArrayBufferView.h" -#include "JSDOMBinding.h" +#include "InternalFunction.h" #include #include @@ -31,7 +31,7 @@ namespace WebCore { class JSInt32Array : public JSArrayBufferView { public: typedef JSArrayBufferView Base; - static JSInt32Array* create(JSC::Structure* structure, JSDOMGlobalObject* globalObject, PassRefPtr impl) + static JSInt32Array* create(JSC::Structure* structure, JSC::JSGlobalObject* globalObject, PassRefPtr impl) { JSInt32Array* ptr = new (NotNull, JSC::allocateCell(globalObject->globalData().heap)) JSInt32Array(structure, globalObject, impl); ptr->finishCreation(globalObject->globalData()); @@ -64,14 +64,14 @@ class JSInt32Array : public JSArrayBufferView { intptr_t m_storageLength; void* m_storage; protected: - JSInt32Array(JSC::Structure*, JSDOMGlobalObject*, PassRefPtr); + JSInt32Array(JSC::Structure*, JSC::JSGlobalObject*, PassRefPtr); void finishCreation(JSC::JSGlobalData&); static const unsigned StructureFlags = JSC::OverridesGetPropertyNames | JSC::OverridesGetOwnPropertySlot | Base::StructureFlags; JSC::JSValue getByIndex(JSC::ExecState*, unsigned index); void indexSetter(JSC::ExecState*, unsigned index, JSC::JSValue); }; -JSC::JSValue toJS(JSC::ExecState*, JSDOMGlobalObject*, Int32Array*); +JSC::JSValue toJS(JSC::ExecState*, JSC::JSGlobalObject*, Int32Array*); Int32Array* toInt32Array(JSC::JSValue); class JSInt32ArrayPrototype : public JSC::JSNonFinalObject { @@ -99,14 +99,14 @@ class JSInt32ArrayPrototype : public JSC::JSNonFinalObject { static const unsigned StructureFlags = JSC::OverridesGetOwnPropertySlot | Base::StructureFlags; }; -class JSInt32ArrayConstructor : public DOMConstructorObject { +class JSInt32ArrayConstructor : public JSC::InternalFunction { private: - JSInt32ArrayConstructor(JSC::Structure*, JSDOMGlobalObject*); - void finishCreation(JSC::ExecState*, JSDOMGlobalObject*); + JSInt32ArrayConstructor(JSC::Structure*, JSC::JSGlobalObject*); + void finishCreation(JSC::ExecState*, JSC::JSGlobalObject*); public: - typedef DOMConstructorObject Base; - static JSInt32ArrayConstructor* create(JSC::ExecState* exec, JSC::Structure* structure, JSDOMGlobalObject* globalObject) + typedef JSC::InternalFunction Base; + static JSInt32ArrayConstructor* create(JSC::ExecState* exec, JSC::Structure* structure, JSC::JSGlobalObject* globalObject) { JSInt32ArrayConstructor* ptr = new (NotNull, JSC::allocateCell(*exec->heap())) JSInt32ArrayConstructor(structure, globalObject); ptr->finishCreation(exec, globalObject); @@ -121,7 +121,7 @@ class JSInt32ArrayConstructor : public DOMConstructorObject { return JSC::Structure::create(globalData, globalObject, prototype, JSC::TypeInfo(JSC::ObjectType, StructureFlags), &s_info); } protected: - static const unsigned StructureFlags = JSC::OverridesGetOwnPropertySlot | JSC::ImplementsHasInstance | DOMConstructorObject::StructureFlags; + static const unsigned StructureFlags = JSC::OverridesGetOwnPropertySlot | JSC::ImplementsHasInstance | JSC::InternalFunction::StructureFlags; static JSC::EncodedJSValue JSC_HOST_CALL constructJSInt32Array(JSC::ExecState*); static JSC::ConstructType getConstructData(JSC::JSCell*, JSC::ConstructData&); }; diff --git a/JavaScriptCore/runtime/TypedArrays/JSInt32ArrayCustom.cpp b/JavaScriptCore/runtime/TypedArrays/JSInt32ArrayCustom.cpp index d85287f4..cf0d8907 100644 --- a/JavaScriptCore/runtime/TypedArrays/JSInt32ArrayCustom.cpp +++ b/JavaScriptCore/runtime/TypedArrays/JSInt32ArrayCustom.cpp @@ -38,7 +38,7 @@ void JSInt32Array::indexSetter(JSC::ExecState* exec, unsigned index, JSC::JSValu impl()->set(index, static_cast(value.toInt32(exec))); } -JSC::JSValue toJS(JSC::ExecState* exec, JSDOMGlobalObject* globalObject, Int32Array* object) +JSC::JSValue toJS(JSC::ExecState* exec, JSGlobalObject* globalObject, Int32Array* object) { return toJSArrayBufferView(exec, globalObject, object); } diff --git a/JavaScriptCore/runtime/TypedArrays/JSInt8Array.cpp b/JavaScriptCore/runtime/TypedArrays/JSInt8Array.cpp index 53b6b642..eff327f4 100644 --- a/JavaScriptCore/runtime/TypedArrays/JSInt8Array.cpp +++ b/JavaScriptCore/runtime/TypedArrays/JSInt8Array.cpp @@ -21,8 +21,9 @@ #include "config.h" #include "JSInt8Array.h" -#include "ExceptionCode.h" -#include "JSDOMBinding.h" +#include "Lookup.h" +#include "GlobalDataHelper.h" + #include "JSInt8Array.h" #include #include @@ -55,27 +56,28 @@ static const HashTableValue JSInt8ArrayConstructorTableValues[] = static const HashTable JSInt8ArrayConstructorTable = { 2, 1, JSInt8ArrayConstructorTableValues, 0 }; const ClassInfo JSInt8ArrayConstructor::s_info = { "Int8ArrayConstructor", &Base::s_info, &JSInt8ArrayConstructorTable, 0, CREATE_METHOD_TABLE(JSInt8ArrayConstructor) }; -JSInt8ArrayConstructor::JSInt8ArrayConstructor(Structure* structure, JSDOMGlobalObject* globalObject) - : DOMConstructorObject(structure, globalObject) +JSInt8ArrayConstructor::JSInt8ArrayConstructor(Structure* structure, JSGlobalObject* globalObject) + : InternalFunction(globalObject, structure) { } -void JSInt8ArrayConstructor::finishCreation(ExecState* exec, JSDOMGlobalObject* globalObject) +void JSInt8ArrayConstructor::finishCreation(ExecState* exec, JSGlobalObject* globalObject) { - Base::finishCreation(exec->globalData()); + JSC::JSObject * proto = JSInt8ArrayPrototype::self(exec, globalObject); + Base::finishCreation(exec->globalData(), Identifier(exec, proto->classInfo()->className)); ASSERT(inherits(&s_info)); - putDirect(exec->globalData(), exec->propertyNames().prototype, JSInt8ArrayPrototype::self(exec, globalObject), DontDelete | ReadOnly); - putDirect(exec->globalData(), exec->propertyNames().length, jsNumber(1), ReadOnly | DontDelete | DontEnum); + putDirect(exec->globalData(), exec->propertyNames().prototype, proto, DontDelete | ReadOnly); + putDirect(exec->globalData(), exec->propertyNames().length, jsNumber(1), ReadOnly | DontDelete | DontEnum); } bool JSInt8ArrayConstructor::getOwnPropertySlot(JSCell* cell, ExecState* exec, const Identifier& propertyName, PropertySlot& slot) { - return getStaticValueSlot(exec, &JSInt8ArrayConstructorTable, jsCast(cell), propertyName, slot); + return getStaticFunctionSlot(exec, &JSInt8ArrayConstructorTable, jsCast(cell), propertyName, slot); } bool JSInt8ArrayConstructor::getOwnPropertyDescriptor(JSObject* object, ExecState* exec, const Identifier& propertyName, PropertyDescriptor& descriptor) { - return getStaticValueDescriptor(exec, &JSInt8ArrayConstructorTable, jsCast(object), propertyName, descriptor); + return getStaticFunctionDescriptor(exec, &JSInt8ArrayConstructorTable, jsCast(object), propertyName, descriptor); } ConstructType JSInt8ArrayConstructor::getConstructData(JSCell*, ConstructData& constructData) @@ -104,7 +106,7 @@ const ClassInfo JSInt8ArrayPrototype::s_info = { "Int8ArrayPrototype", &Base::s_ JSObject* JSInt8ArrayPrototype::self(ExecState* exec, JSGlobalObject* globalObject) { - return getDOMPrototype(exec, globalObject); + return getDOMPrototype(exec, globalObject); } bool JSInt8ArrayPrototype::getOwnPropertySlot(JSCell* cell, ExecState* exec, const Identifier& propertyName, PropertySlot& slot) @@ -126,7 +128,7 @@ static const HashTable* getJSInt8ArrayTable(ExecState* exec) const ClassInfo JSInt8Array::s_info = { "Int8Array", &Base::s_info, 0, getJSInt8ArrayTable , CREATE_METHOD_TABLE(JSInt8Array) }; -JSInt8Array::JSInt8Array(Structure* structure, JSDOMGlobalObject* globalObject, PassRefPtr impl) +JSInt8Array::JSInt8Array(Structure* structure, JSGlobalObject* globalObject, PassRefPtr impl) : JSArrayBufferView(structure, globalObject, impl) { } @@ -231,7 +233,7 @@ void JSInt8Array::getOwnPropertyNames(JSObject* object, ExecState* exec, Propert JSValue JSInt8Array::getConstructor(ExecState* exec, JSGlobalObject* globalObject) { - return getDOMConstructor(exec, jsCast(globalObject)); + return getDOMConstructor(exec, jsCast(globalObject)); } EncodedJSValue JSC_HOST_CALL jsInt8ArrayPrototypeFunctionSubarray(ExecState* exec) diff --git a/JavaScriptCore/runtime/TypedArrays/JSInt8Array.h b/JavaScriptCore/runtime/TypedArrays/JSInt8Array.h index 12d94bcc..42eae1a1 100644 --- a/JavaScriptCore/runtime/TypedArrays/JSInt8Array.h +++ b/JavaScriptCore/runtime/TypedArrays/JSInt8Array.h @@ -21,8 +21,8 @@ #ifndef JSInt8Array_h #define JSInt8Array_h +#include "InternalFunction.h" #include "JSArrayBufferView.h" -#include "JSDOMBinding.h" #include #include @@ -31,7 +31,7 @@ namespace WebCore { class JSInt8Array : public JSArrayBufferView { public: typedef JSArrayBufferView Base; - static JSInt8Array* create(JSC::Structure* structure, JSDOMGlobalObject* globalObject, PassRefPtr impl) + static JSInt8Array* create(JSC::Structure* structure, JSC::JSGlobalObject* globalObject, PassRefPtr impl) { JSInt8Array* ptr = new (NotNull, JSC::allocateCell(globalObject->globalData().heap)) JSInt8Array(structure, globalObject, impl); ptr->finishCreation(globalObject->globalData()); @@ -64,14 +64,14 @@ class JSInt8Array : public JSArrayBufferView { intptr_t m_storageLength; void* m_storage; protected: - JSInt8Array(JSC::Structure*, JSDOMGlobalObject*, PassRefPtr); + JSInt8Array(JSC::Structure*, JSC::JSGlobalObject*, PassRefPtr); void finishCreation(JSC::JSGlobalData&); static const unsigned StructureFlags = JSC::OverridesGetPropertyNames | JSC::OverridesGetOwnPropertySlot | Base::StructureFlags; JSC::JSValue getByIndex(JSC::ExecState*, unsigned index); void indexSetter(JSC::ExecState*, unsigned index, JSC::JSValue); }; -JSC::JSValue toJS(JSC::ExecState*, JSDOMGlobalObject*, Int8Array*); +JSC::JSValue toJS(JSC::ExecState*, JSC::JSGlobalObject*, Int8Array*); Int8Array* toInt8Array(JSC::JSValue); class JSInt8ArrayPrototype : public JSC::JSNonFinalObject { @@ -99,14 +99,14 @@ class JSInt8ArrayPrototype : public JSC::JSNonFinalObject { static const unsigned StructureFlags = JSC::OverridesGetOwnPropertySlot | Base::StructureFlags; }; -class JSInt8ArrayConstructor : public DOMConstructorObject { +class JSInt8ArrayConstructor : public JSC::InternalFunction { private: - JSInt8ArrayConstructor(JSC::Structure*, JSDOMGlobalObject*); - void finishCreation(JSC::ExecState*, JSDOMGlobalObject*); + JSInt8ArrayConstructor(JSC::Structure*, JSC::JSGlobalObject*); + void finishCreation(JSC::ExecState*, JSC::JSGlobalObject*); public: - typedef DOMConstructorObject Base; - static JSInt8ArrayConstructor* create(JSC::ExecState* exec, JSC::Structure* structure, JSDOMGlobalObject* globalObject) + typedef JSC::InternalFunction Base; + static JSInt8ArrayConstructor* create(JSC::ExecState* exec, JSC::Structure* structure, JSC::JSGlobalObject* globalObject) { JSInt8ArrayConstructor* ptr = new (NotNull, JSC::allocateCell(*exec->heap())) JSInt8ArrayConstructor(structure, globalObject); ptr->finishCreation(exec, globalObject); @@ -121,7 +121,7 @@ class JSInt8ArrayConstructor : public DOMConstructorObject { return JSC::Structure::create(globalData, globalObject, prototype, JSC::TypeInfo(JSC::ObjectType, StructureFlags), &s_info); } protected: - static const unsigned StructureFlags = JSC::OverridesGetOwnPropertySlot | JSC::ImplementsHasInstance | DOMConstructorObject::StructureFlags; + static const unsigned StructureFlags = JSC::OverridesGetOwnPropertySlot | JSC::ImplementsHasInstance | JSC::InternalFunction::StructureFlags; static JSC::EncodedJSValue JSC_HOST_CALL constructJSInt8Array(JSC::ExecState*); static JSC::ConstructType getConstructData(JSC::JSCell*, JSC::ConstructData&); }; diff --git a/JavaScriptCore/runtime/TypedArrays/JSInt8ArrayCustom.cpp b/JavaScriptCore/runtime/TypedArrays/JSInt8ArrayCustom.cpp index b6e15076..e424615a 100644 --- a/JavaScriptCore/runtime/TypedArrays/JSInt8ArrayCustom.cpp +++ b/JavaScriptCore/runtime/TypedArrays/JSInt8ArrayCustom.cpp @@ -39,7 +39,7 @@ void JSInt8Array::indexSetter(JSC::ExecState* exec, unsigned index, JSC::JSValue impl()->set(index, static_cast(value.toInt32(exec))); } -JSC::JSValue toJS(JSC::ExecState* exec, JSDOMGlobalObject* globalObject, Int8Array* object) +JSC::JSValue toJS(JSC::ExecState* exec, JSGlobalObject* globalObject, Int8Array* object) { return toJSArrayBufferView(exec, globalObject, object); } diff --git a/JavaScriptCore/runtime/TypedArrays/JSUint16Array.cpp b/JavaScriptCore/runtime/TypedArrays/JSUint16Array.cpp index 0261e90f..2ffbcb2d 100644 --- a/JavaScriptCore/runtime/TypedArrays/JSUint16Array.cpp +++ b/JavaScriptCore/runtime/TypedArrays/JSUint16Array.cpp @@ -21,8 +21,9 @@ #include "config.h" #include "JSUint16Array.h" -#include "ExceptionCode.h" -#include "JSDOMBinding.h" +#include "Lookup.h" +#include "GlobalDataHelper.h" + #include "JSUint16Array.h" #include #include @@ -55,27 +56,28 @@ static const HashTableValue JSUint16ArrayConstructorTableValues[] = static const HashTable JSUint16ArrayConstructorTable = { 2, 1, JSUint16ArrayConstructorTableValues, 0 }; const ClassInfo JSUint16ArrayConstructor::s_info = { "Uint16ArrayConstructor", &Base::s_info, &JSUint16ArrayConstructorTable, 0, CREATE_METHOD_TABLE(JSUint16ArrayConstructor) }; -JSUint16ArrayConstructor::JSUint16ArrayConstructor(Structure* structure, JSDOMGlobalObject* globalObject) - : DOMConstructorObject(structure, globalObject) +JSUint16ArrayConstructor::JSUint16ArrayConstructor(Structure* structure, JSGlobalObject* globalObject) + : InternalFunction(globalObject, structure) { } -void JSUint16ArrayConstructor::finishCreation(ExecState* exec, JSDOMGlobalObject* globalObject) +void JSUint16ArrayConstructor::finishCreation(ExecState* exec, JSGlobalObject* globalObject) { - Base::finishCreation(exec->globalData()); + JSC::JSObject * proto = JSUint16ArrayPrototype::self(exec, globalObject); + Base::finishCreation(exec->globalData(), Identifier(exec, proto->classInfo()->className)); ASSERT(inherits(&s_info)); - putDirect(exec->globalData(), exec->propertyNames().prototype, JSUint16ArrayPrototype::self(exec, globalObject), DontDelete | ReadOnly); + putDirect(exec->globalData(), exec->propertyNames().prototype, proto, DontDelete | ReadOnly); putDirect(exec->globalData(), exec->propertyNames().length, jsNumber(1), ReadOnly | DontDelete | DontEnum); } bool JSUint16ArrayConstructor::getOwnPropertySlot(JSCell* cell, ExecState* exec, const Identifier& propertyName, PropertySlot& slot) { - return getStaticValueSlot(exec, &JSUint16ArrayConstructorTable, jsCast(cell), propertyName, slot); + return getStaticFunctionSlot(exec, &JSUint16ArrayConstructorTable, jsCast(cell), propertyName, slot); } bool JSUint16ArrayConstructor::getOwnPropertyDescriptor(JSObject* object, ExecState* exec, const Identifier& propertyName, PropertyDescriptor& descriptor) { - return getStaticValueDescriptor(exec, &JSUint16ArrayConstructorTable, jsCast(object), propertyName, descriptor); + return getStaticFunctionDescriptor(exec, &JSUint16ArrayConstructorTable, jsCast(object), propertyName, descriptor); } ConstructType JSUint16ArrayConstructor::getConstructData(JSCell*, ConstructData& constructData) @@ -104,7 +106,7 @@ const ClassInfo JSUint16ArrayPrototype::s_info = { "Uint16ArrayPrototype", &Base JSObject* JSUint16ArrayPrototype::self(ExecState* exec, JSGlobalObject* globalObject) { - return getDOMPrototype(exec, globalObject); + return getDOMPrototype(exec, globalObject); } bool JSUint16ArrayPrototype::getOwnPropertySlot(JSCell* cell, ExecState* exec, const Identifier& propertyName, PropertySlot& slot) @@ -126,7 +128,7 @@ static const HashTable* getJSUint16ArrayTable(ExecState* exec) const ClassInfo JSUint16Array::s_info = { "Uint16Array", &Base::s_info, 0, getJSUint16ArrayTable , CREATE_METHOD_TABLE(JSUint16Array) }; -JSUint16Array::JSUint16Array(Structure* structure, JSDOMGlobalObject* globalObject, PassRefPtr impl) +JSUint16Array::JSUint16Array(Structure* structure, JSGlobalObject* globalObject, PassRefPtr impl) : JSArrayBufferView(structure, globalObject, impl) { } @@ -231,7 +233,7 @@ void JSUint16Array::getOwnPropertyNames(JSObject* object, ExecState* exec, Prope JSValue JSUint16Array::getConstructor(ExecState* exec, JSGlobalObject* globalObject) { - return getDOMConstructor(exec, jsCast(globalObject)); + return getDOMConstructor(exec, jsCast(globalObject)); } EncodedJSValue JSC_HOST_CALL jsUint16ArrayPrototypeFunctionSubarray(ExecState* exec) diff --git a/JavaScriptCore/runtime/TypedArrays/JSUint16Array.h b/JavaScriptCore/runtime/TypedArrays/JSUint16Array.h index b70f9af3..522e5ad5 100644 --- a/JavaScriptCore/runtime/TypedArrays/JSUint16Array.h +++ b/JavaScriptCore/runtime/TypedArrays/JSUint16Array.h @@ -22,7 +22,7 @@ #define JSUint16Array_h #include "JSArrayBufferView.h" -#include "JSDOMBinding.h" +#include "InternalFunction.h" #include #include @@ -31,7 +31,7 @@ namespace WebCore { class JSUint16Array : public JSArrayBufferView { public: typedef JSArrayBufferView Base; - static JSUint16Array* create(JSC::Structure* structure, JSDOMGlobalObject* globalObject, PassRefPtr impl) + static JSUint16Array* create(JSC::Structure* structure, JSC::JSGlobalObject* globalObject, PassRefPtr impl) { JSUint16Array* ptr = new (NotNull, JSC::allocateCell(globalObject->globalData().heap)) JSUint16Array(structure, globalObject, impl); ptr->finishCreation(globalObject->globalData()); @@ -64,14 +64,14 @@ class JSUint16Array : public JSArrayBufferView { intptr_t m_storageLength; void* m_storage; protected: - JSUint16Array(JSC::Structure*, JSDOMGlobalObject*, PassRefPtr); + JSUint16Array(JSC::Structure*, JSC::JSGlobalObject*, PassRefPtr); void finishCreation(JSC::JSGlobalData&); static const unsigned StructureFlags = JSC::OverridesGetPropertyNames | JSC::OverridesGetOwnPropertySlot | Base::StructureFlags; JSC::JSValue getByIndex(JSC::ExecState*, unsigned index); void indexSetter(JSC::ExecState*, unsigned index, JSC::JSValue); }; -JSC::JSValue toJS(JSC::ExecState*, JSDOMGlobalObject*, Uint16Array*); +JSC::JSValue toJS(JSC::ExecState*, JSC::JSGlobalObject*, Uint16Array*); Uint16Array* toUint16Array(JSC::JSValue); class JSUint16ArrayPrototype : public JSC::JSNonFinalObject { @@ -99,14 +99,14 @@ class JSUint16ArrayPrototype : public JSC::JSNonFinalObject { static const unsigned StructureFlags = JSC::OverridesGetOwnPropertySlot | Base::StructureFlags; }; -class JSUint16ArrayConstructor : public DOMConstructorObject { +class JSUint16ArrayConstructor : public JSC::InternalFunction { private: - JSUint16ArrayConstructor(JSC::Structure*, JSDOMGlobalObject*); - void finishCreation(JSC::ExecState*, JSDOMGlobalObject*); + JSUint16ArrayConstructor(JSC::Structure*, JSC::JSGlobalObject*); + void finishCreation(JSC::ExecState*, JSC::JSGlobalObject*); public: - typedef DOMConstructorObject Base; - static JSUint16ArrayConstructor* create(JSC::ExecState* exec, JSC::Structure* structure, JSDOMGlobalObject* globalObject) + typedef JSC::InternalFunction Base; + static JSUint16ArrayConstructor* create(JSC::ExecState* exec, JSC::Structure* structure, JSC::JSGlobalObject* globalObject) { JSUint16ArrayConstructor* ptr = new (NotNull, JSC::allocateCell(*exec->heap())) JSUint16ArrayConstructor(structure, globalObject); ptr->finishCreation(exec, globalObject); @@ -121,7 +121,7 @@ class JSUint16ArrayConstructor : public DOMConstructorObject { return JSC::Structure::create(globalData, globalObject, prototype, JSC::TypeInfo(JSC::ObjectType, StructureFlags), &s_info); } protected: - static const unsigned StructureFlags = JSC::OverridesGetOwnPropertySlot | JSC::ImplementsHasInstance | DOMConstructorObject::StructureFlags; + static const unsigned StructureFlags = JSC::OverridesGetOwnPropertySlot | JSC::ImplementsHasInstance | JSC::InternalFunction::StructureFlags; static JSC::EncodedJSValue JSC_HOST_CALL constructJSUint16Array(JSC::ExecState*); static JSC::ConstructType getConstructData(JSC::JSCell*, JSC::ConstructData&); }; diff --git a/JavaScriptCore/runtime/TypedArrays/JSUint16ArrayCustom.cpp b/JavaScriptCore/runtime/TypedArrays/JSUint16ArrayCustom.cpp index 47b4402b..14fda1bf 100644 --- a/JavaScriptCore/runtime/TypedArrays/JSUint16ArrayCustom.cpp +++ b/JavaScriptCore/runtime/TypedArrays/JSUint16ArrayCustom.cpp @@ -38,7 +38,7 @@ void JSUint16Array::indexSetter(JSC::ExecState* exec, unsigned index, JSC::JSVal impl()->set(index, static_cast(value.toInt32(exec))); } -JSC::JSValue toJS(JSC::ExecState* exec, JSDOMGlobalObject* globalObject, Uint16Array* object) +JSC::JSValue toJS(JSC::ExecState* exec, JSGlobalObject* globalObject, Uint16Array* object) { return toJSArrayBufferView(exec, globalObject, object); } diff --git a/JavaScriptCore/runtime/TypedArrays/JSUint32Array.cpp b/JavaScriptCore/runtime/TypedArrays/JSUint32Array.cpp index 5e8b9555..252fbf1c 100644 --- a/JavaScriptCore/runtime/TypedArrays/JSUint32Array.cpp +++ b/JavaScriptCore/runtime/TypedArrays/JSUint32Array.cpp @@ -21,8 +21,9 @@ #include "config.h" #include "JSUint32Array.h" -#include "ExceptionCode.h" -#include "JSDOMBinding.h" +#include "Lookup.h" +#include "GlobalDataHelper.h" + #include "JSUint32Array.h" #include #include @@ -55,27 +56,28 @@ static const HashTableValue JSUint32ArrayConstructorTableValues[] = static const HashTable JSUint32ArrayConstructorTable = { 2, 1, JSUint32ArrayConstructorTableValues, 0 }; const ClassInfo JSUint32ArrayConstructor::s_info = { "Uint32ArrayConstructor", &Base::s_info, &JSUint32ArrayConstructorTable, 0, CREATE_METHOD_TABLE(JSUint32ArrayConstructor) }; -JSUint32ArrayConstructor::JSUint32ArrayConstructor(Structure* structure, JSDOMGlobalObject* globalObject) - : DOMConstructorObject(structure, globalObject) +JSUint32ArrayConstructor::JSUint32ArrayConstructor(Structure* structure, JSGlobalObject* globalObject) + : InternalFunction(globalObject, structure) { } -void JSUint32ArrayConstructor::finishCreation(ExecState* exec, JSDOMGlobalObject* globalObject) +void JSUint32ArrayConstructor::finishCreation(ExecState* exec, JSGlobalObject* globalObject) { - Base::finishCreation(exec->globalData()); + JSC::JSObject * proto = JSUint32ArrayPrototype::self(exec, globalObject); + Base::finishCreation(exec->globalData(), Identifier(exec, proto->classInfo()->className)); ASSERT(inherits(&s_info)); - putDirect(exec->globalData(), exec->propertyNames().prototype, JSUint32ArrayPrototype::self(exec, globalObject), DontDelete | ReadOnly); + putDirect(exec->globalData(), exec->propertyNames().prototype, proto, DontDelete | ReadOnly); putDirect(exec->globalData(), exec->propertyNames().length, jsNumber(1), ReadOnly | DontDelete | DontEnum); } bool JSUint32ArrayConstructor::getOwnPropertySlot(JSCell* cell, ExecState* exec, const Identifier& propertyName, PropertySlot& slot) { - return getStaticValueSlot(exec, &JSUint32ArrayConstructorTable, jsCast(cell), propertyName, slot); + return getStaticFunctionSlot(exec, &JSUint32ArrayConstructorTable, jsCast(cell), propertyName, slot); } bool JSUint32ArrayConstructor::getOwnPropertyDescriptor(JSObject* object, ExecState* exec, const Identifier& propertyName, PropertyDescriptor& descriptor) { - return getStaticValueDescriptor(exec, &JSUint32ArrayConstructorTable, jsCast(object), propertyName, descriptor); + return getStaticFunctionDescriptor(exec, &JSUint32ArrayConstructorTable, jsCast(object), propertyName, descriptor); } ConstructType JSUint32ArrayConstructor::getConstructData(JSCell*, ConstructData& constructData) @@ -104,7 +106,7 @@ const ClassInfo JSUint32ArrayPrototype::s_info = { "Uint32ArrayPrototype", &Base JSObject* JSUint32ArrayPrototype::self(ExecState* exec, JSGlobalObject* globalObject) { - return getDOMPrototype(exec, globalObject); + return getDOMPrototype(exec, globalObject); } bool JSUint32ArrayPrototype::getOwnPropertySlot(JSCell* cell, ExecState* exec, const Identifier& propertyName, PropertySlot& slot) @@ -126,7 +128,7 @@ static const HashTable* getJSUint32ArrayTable(ExecState* exec) const ClassInfo JSUint32Array::s_info = { "Uint32Array", &Base::s_info, 0, getJSUint32ArrayTable , CREATE_METHOD_TABLE(JSUint32Array) }; -JSUint32Array::JSUint32Array(Structure* structure, JSDOMGlobalObject* globalObject, PassRefPtr impl) +JSUint32Array::JSUint32Array(Structure* structure, JSGlobalObject* globalObject, PassRefPtr impl) : JSArrayBufferView(structure, globalObject, impl) { } @@ -231,7 +233,7 @@ void JSUint32Array::getOwnPropertyNames(JSObject* object, ExecState* exec, Prope JSValue JSUint32Array::getConstructor(ExecState* exec, JSGlobalObject* globalObject) { - return getDOMConstructor(exec, jsCast(globalObject)); + return getDOMConstructor(exec, jsCast(globalObject)); } EncodedJSValue JSC_HOST_CALL jsUint32ArrayPrototypeFunctionSubarray(ExecState* exec) diff --git a/JavaScriptCore/runtime/TypedArrays/JSUint32Array.h b/JavaScriptCore/runtime/TypedArrays/JSUint32Array.h index f905e540..e59e8066 100644 --- a/JavaScriptCore/runtime/TypedArrays/JSUint32Array.h +++ b/JavaScriptCore/runtime/TypedArrays/JSUint32Array.h @@ -22,7 +22,7 @@ #define JSUint32Array_h #include "JSArrayBufferView.h" -#include "JSDOMBinding.h" +#include "InternalFunction.h" #include #include @@ -31,7 +31,7 @@ namespace WebCore { class JSUint32Array : public JSArrayBufferView { public: typedef JSArrayBufferView Base; - static JSUint32Array* create(JSC::Structure* structure, JSDOMGlobalObject* globalObject, PassRefPtr impl) + static JSUint32Array* create(JSC::Structure* structure, JSC::JSGlobalObject* globalObject, PassRefPtr impl) { JSUint32Array* ptr = new (NotNull, JSC::allocateCell(globalObject->globalData().heap)) JSUint32Array(structure, globalObject, impl); ptr->finishCreation(globalObject->globalData()); @@ -64,14 +64,14 @@ class JSUint32Array : public JSArrayBufferView { intptr_t m_storageLength; void* m_storage; protected: - JSUint32Array(JSC::Structure*, JSDOMGlobalObject*, PassRefPtr); + JSUint32Array(JSC::Structure*, JSC::JSGlobalObject*, PassRefPtr); void finishCreation(JSC::JSGlobalData&); static const unsigned StructureFlags = JSC::OverridesGetPropertyNames | JSC::OverridesGetOwnPropertySlot | Base::StructureFlags; JSC::JSValue getByIndex(JSC::ExecState*, unsigned index); void indexSetter(JSC::ExecState*, unsigned index, JSC::JSValue); }; -JSC::JSValue toJS(JSC::ExecState*, JSDOMGlobalObject*, Uint32Array*); +JSC::JSValue toJS(JSC::ExecState*, JSC::JSGlobalObject*, Uint32Array*); Uint32Array* toUint32Array(JSC::JSValue); class JSUint32ArrayPrototype : public JSC::JSNonFinalObject { @@ -99,14 +99,14 @@ class JSUint32ArrayPrototype : public JSC::JSNonFinalObject { static const unsigned StructureFlags = JSC::OverridesGetOwnPropertySlot | Base::StructureFlags; }; -class JSUint32ArrayConstructor : public DOMConstructorObject { +class JSUint32ArrayConstructor : public JSC::InternalFunction { private: - JSUint32ArrayConstructor(JSC::Structure*, JSDOMGlobalObject*); - void finishCreation(JSC::ExecState*, JSDOMGlobalObject*); + JSUint32ArrayConstructor(JSC::Structure*, JSC::JSGlobalObject*); + void finishCreation(JSC::ExecState*, JSC::JSGlobalObject*); public: - typedef DOMConstructorObject Base; - static JSUint32ArrayConstructor* create(JSC::ExecState* exec, JSC::Structure* structure, JSDOMGlobalObject* globalObject) + typedef JSC::InternalFunction Base; + static JSUint32ArrayConstructor* create(JSC::ExecState* exec, JSC::Structure* structure, JSC::JSGlobalObject* globalObject) { JSUint32ArrayConstructor* ptr = new (NotNull, JSC::allocateCell(*exec->heap())) JSUint32ArrayConstructor(structure, globalObject); ptr->finishCreation(exec, globalObject); @@ -121,7 +121,7 @@ class JSUint32ArrayConstructor : public DOMConstructorObject { return JSC::Structure::create(globalData, globalObject, prototype, JSC::TypeInfo(JSC::ObjectType, StructureFlags), &s_info); } protected: - static const unsigned StructureFlags = JSC::OverridesGetOwnPropertySlot | JSC::ImplementsHasInstance | DOMConstructorObject::StructureFlags; + static const unsigned StructureFlags = JSC::OverridesGetOwnPropertySlot | JSC::ImplementsHasInstance | JSC::InternalFunction::StructureFlags; static JSC::EncodedJSValue JSC_HOST_CALL constructJSUint32Array(JSC::ExecState*); static JSC::ConstructType getConstructData(JSC::JSCell*, JSC::ConstructData&); }; diff --git a/JavaScriptCore/runtime/TypedArrays/JSUint32ArrayCustom.cpp b/JavaScriptCore/runtime/TypedArrays/JSUint32ArrayCustom.cpp index aa8b8267..d44d812f 100644 --- a/JavaScriptCore/runtime/TypedArrays/JSUint32ArrayCustom.cpp +++ b/JavaScriptCore/runtime/TypedArrays/JSUint32ArrayCustom.cpp @@ -38,7 +38,7 @@ void JSUint32Array::indexSetter(JSC::ExecState* exec, unsigned index, JSC::JSVal impl()->set(index, static_cast(value.toUInt32(exec))); } -JSC::JSValue toJS(JSC::ExecState* exec, JSDOMGlobalObject* globalObject, Uint32Array* object) +JSC::JSValue toJS(JSC::ExecState* exec, JSGlobalObject* globalObject, Uint32Array* object) { return toJSArrayBufferView(exec, globalObject, object); } diff --git a/JavaScriptCore/runtime/TypedArrays/JSUint8Array.cpp b/JavaScriptCore/runtime/TypedArrays/JSUint8Array.cpp index e62ac06d..180c4348 100644 --- a/JavaScriptCore/runtime/TypedArrays/JSUint8Array.cpp +++ b/JavaScriptCore/runtime/TypedArrays/JSUint8Array.cpp @@ -21,8 +21,9 @@ #include "config.h" #include "JSUint8Array.h" -#include "ExceptionCode.h" -#include "JSDOMBinding.h" +#include "Lookup.h" +#include "GlobalDataHelper.h" + #include "JSUint8Array.h" #include #include @@ -55,27 +56,28 @@ static const HashTableValue JSUint8ArrayConstructorTableValues[] = static const HashTable JSUint8ArrayConstructorTable = { 2, 1, JSUint8ArrayConstructorTableValues, 0 }; const ClassInfo JSUint8ArrayConstructor::s_info = { "Uint8ArrayConstructor", &Base::s_info, &JSUint8ArrayConstructorTable, 0, CREATE_METHOD_TABLE(JSUint8ArrayConstructor) }; -JSUint8ArrayConstructor::JSUint8ArrayConstructor(Structure* structure, JSDOMGlobalObject* globalObject) - : DOMConstructorObject(structure, globalObject) +JSUint8ArrayConstructor::JSUint8ArrayConstructor(Structure* structure, JSGlobalObject* globalObject) + : InternalFunction(globalObject, structure) { } -void JSUint8ArrayConstructor::finishCreation(ExecState* exec, JSDOMGlobalObject* globalObject) +void JSUint8ArrayConstructor::finishCreation(ExecState* exec, JSGlobalObject* globalObject) { - Base::finishCreation(exec->globalData()); + JSC::JSObject * proto = JSUint8ArrayPrototype::self(exec, globalObject); + Base::finishCreation(exec->globalData(), Identifier(exec, proto->classInfo()->className)); ASSERT(inherits(&s_info)); - putDirect(exec->globalData(), exec->propertyNames().prototype, JSUint8ArrayPrototype::self(exec, globalObject), DontDelete | ReadOnly); + putDirect(exec->globalData(), exec->propertyNames().prototype, proto, DontDelete | ReadOnly); putDirect(exec->globalData(), exec->propertyNames().length, jsNumber(1), ReadOnly | DontDelete | DontEnum); } bool JSUint8ArrayConstructor::getOwnPropertySlot(JSCell* cell, ExecState* exec, const Identifier& propertyName, PropertySlot& slot) { - return getStaticValueSlot(exec, &JSUint8ArrayConstructorTable, jsCast(cell), propertyName, slot); + return getStaticFunctionSlot(exec, &JSUint8ArrayConstructorTable, jsCast(cell), propertyName, slot); } bool JSUint8ArrayConstructor::getOwnPropertyDescriptor(JSObject* object, ExecState* exec, const Identifier& propertyName, PropertyDescriptor& descriptor) { - return getStaticValueDescriptor(exec, &JSUint8ArrayConstructorTable, jsCast(object), propertyName, descriptor); + return getStaticFunctionDescriptor(exec, &JSUint8ArrayConstructorTable, jsCast(object), propertyName, descriptor); } ConstructType JSUint8ArrayConstructor::getConstructData(JSCell*, ConstructData& constructData) @@ -104,7 +106,7 @@ const ClassInfo JSUint8ArrayPrototype::s_info = { "Uint8ArrayPrototype", &Base:: JSObject* JSUint8ArrayPrototype::self(ExecState* exec, JSGlobalObject* globalObject) { - return getDOMPrototype(exec, globalObject); + return getDOMPrototype(exec, globalObject); } bool JSUint8ArrayPrototype::getOwnPropertySlot(JSCell* cell, ExecState* exec, const Identifier& propertyName, PropertySlot& slot) @@ -126,7 +128,7 @@ static const HashTable* getJSUint8ArrayTable(ExecState* exec) const ClassInfo JSUint8Array::s_info = { "Uint8Array", &Base::s_info, 0, getJSUint8ArrayTable , CREATE_METHOD_TABLE(JSUint8Array) }; -JSUint8Array::JSUint8Array(Structure* structure, JSDOMGlobalObject* globalObject, PassRefPtr impl) +JSUint8Array::JSUint8Array(Structure* structure, JSGlobalObject* globalObject, PassRefPtr impl) : JSArrayBufferView(structure, globalObject, impl) { } @@ -231,7 +233,7 @@ void JSUint8Array::getOwnPropertyNames(JSObject* object, ExecState* exec, Proper JSValue JSUint8Array::getConstructor(ExecState* exec, JSGlobalObject* globalObject) { - return getDOMConstructor(exec, jsCast(globalObject)); + return getDOMConstructor(exec, jsCast(globalObject)); } EncodedJSValue JSC_HOST_CALL jsUint8ArrayPrototypeFunctionSubarray(ExecState* exec) diff --git a/JavaScriptCore/runtime/TypedArrays/JSUint8Array.h b/JavaScriptCore/runtime/TypedArrays/JSUint8Array.h index 0972b146..98f501a4 100644 --- a/JavaScriptCore/runtime/TypedArrays/JSUint8Array.h +++ b/JavaScriptCore/runtime/TypedArrays/JSUint8Array.h @@ -22,7 +22,7 @@ #define JSUint8Array_h #include "JSArrayBufferView.h" -#include "JSDOMBinding.h" +#include "InternalFunction.h" #include #include @@ -31,7 +31,7 @@ namespace WebCore { class JSUint8Array : public JSArrayBufferView { public: typedef JSArrayBufferView Base; - static JSUint8Array* create(JSC::Structure* structure, JSDOMGlobalObject* globalObject, PassRefPtr impl) + static JSUint8Array* create(JSC::Structure* structure, JSC::JSGlobalObject* globalObject, PassRefPtr impl) { JSUint8Array* ptr = new (NotNull, JSC::allocateCell(globalObject->globalData().heap)) JSUint8Array(structure, globalObject, impl); ptr->finishCreation(globalObject->globalData()); @@ -64,14 +64,14 @@ class JSUint8Array : public JSArrayBufferView { intptr_t m_storageLength; void* m_storage; protected: - JSUint8Array(JSC::Structure*, JSDOMGlobalObject*, PassRefPtr); + JSUint8Array(JSC::Structure*, JSC::JSGlobalObject*, PassRefPtr); void finishCreation(JSC::JSGlobalData&); static const unsigned StructureFlags = JSC::OverridesGetPropertyNames | JSC::OverridesGetOwnPropertySlot | Base::StructureFlags; JSC::JSValue getByIndex(JSC::ExecState*, unsigned index); void indexSetter(JSC::ExecState*, unsigned index, JSC::JSValue); }; -JSC::JSValue toJS(JSC::ExecState*, JSDOMGlobalObject*, Uint8Array*); +JSC::JSValue toJS(JSC::ExecState*, JSC::JSGlobalObject*, Uint8Array*); Uint8Array* toUint8Array(JSC::JSValue); class JSUint8ArrayPrototype : public JSC::JSNonFinalObject { @@ -99,14 +99,14 @@ class JSUint8ArrayPrototype : public JSC::JSNonFinalObject { static const unsigned StructureFlags = JSC::OverridesGetOwnPropertySlot | Base::StructureFlags; }; -class JSUint8ArrayConstructor : public DOMConstructorObject { +class JSUint8ArrayConstructor : public JSC::InternalFunction { private: - JSUint8ArrayConstructor(JSC::Structure*, JSDOMGlobalObject*); - void finishCreation(JSC::ExecState*, JSDOMGlobalObject*); + JSUint8ArrayConstructor(JSC::Structure*, JSC::JSGlobalObject*); + void finishCreation(JSC::ExecState*, JSC::JSGlobalObject*); public: - typedef DOMConstructorObject Base; - static JSUint8ArrayConstructor* create(JSC::ExecState* exec, JSC::Structure* structure, JSDOMGlobalObject* globalObject) + typedef JSC::InternalFunction Base; + static JSUint8ArrayConstructor* create(JSC::ExecState* exec, JSC::Structure* structure, JSC::JSGlobalObject* globalObject) { JSUint8ArrayConstructor* ptr = new (NotNull, JSC::allocateCell(*exec->heap())) JSUint8ArrayConstructor(structure, globalObject); ptr->finishCreation(exec, globalObject); @@ -121,7 +121,7 @@ class JSUint8ArrayConstructor : public DOMConstructorObject { return JSC::Structure::create(globalData, globalObject, prototype, JSC::TypeInfo(JSC::ObjectType, StructureFlags), &s_info); } protected: - static const unsigned StructureFlags = JSC::OverridesGetOwnPropertySlot | JSC::ImplementsHasInstance | DOMConstructorObject::StructureFlags; + static const unsigned StructureFlags = JSC::OverridesGetOwnPropertySlot | JSC::ImplementsHasInstance | JSC::InternalFunction::StructureFlags; static JSC::EncodedJSValue JSC_HOST_CALL constructJSUint8Array(JSC::ExecState*); static JSC::ConstructType getConstructData(JSC::JSCell*, JSC::ConstructData&); }; diff --git a/JavaScriptCore/runtime/TypedArrays/JSUint8ArrayCustom.cpp b/JavaScriptCore/runtime/TypedArrays/JSUint8ArrayCustom.cpp index 6a4fa1df..4a769738 100644 --- a/JavaScriptCore/runtime/TypedArrays/JSUint8ArrayCustom.cpp +++ b/JavaScriptCore/runtime/TypedArrays/JSUint8ArrayCustom.cpp @@ -38,7 +38,7 @@ void JSUint8Array::indexSetter(JSC::ExecState* exec, unsigned index, JSC::JSValu impl()->set(index, static_cast(value.toInt32(exec))); } -JSC::JSValue toJS(JSC::ExecState* exec, JSDOMGlobalObject* globalObject, Uint8Array* object) +JSC::JSValue toJS(JSC::ExecState* exec, JSGlobalObject* globalObject, Uint8Array* object) { return toJSArrayBufferView(exec, globalObject, object); } diff --git a/JavaScriptCore/runtime/TypedArrays/JSUint8ClampedArray.cpp b/JavaScriptCore/runtime/TypedArrays/JSUint8ClampedArray.cpp index e0b16c3d..2f90bd5c 100644 --- a/JavaScriptCore/runtime/TypedArrays/JSUint8ClampedArray.cpp +++ b/JavaScriptCore/runtime/TypedArrays/JSUint8ClampedArray.cpp @@ -21,8 +21,9 @@ #include "config.h" #include "JSUint8ClampedArray.h" -#include "ExceptionCode.h" -#include "JSDOMBinding.h" +#include "Lookup.h" +#include "GlobalDataHelper.h" + #include "JSUint8ClampedArray.h" #include #include @@ -55,27 +56,28 @@ static const HashTableValue JSUint8ClampedArrayConstructorTableValues[] = static const HashTable JSUint8ClampedArrayConstructorTable = { 2, 1, JSUint8ClampedArrayConstructorTableValues, 0 }; const ClassInfo JSUint8ClampedArrayConstructor::s_info = { "Uint8ClampedArrayConstructor", &Base::s_info, &JSUint8ClampedArrayConstructorTable, 0, CREATE_METHOD_TABLE(JSUint8ClampedArrayConstructor) }; -JSUint8ClampedArrayConstructor::JSUint8ClampedArrayConstructor(Structure* structure, JSDOMGlobalObject* globalObject) - : DOMConstructorObject(structure, globalObject) +JSUint8ClampedArrayConstructor::JSUint8ClampedArrayConstructor(Structure* structure, JSGlobalObject* globalObject) + : InternalFunction(globalObject, structure) { } -void JSUint8ClampedArrayConstructor::finishCreation(ExecState* exec, JSDOMGlobalObject* globalObject) +void JSUint8ClampedArrayConstructor::finishCreation(ExecState* exec, JSGlobalObject* globalObject) { - Base::finishCreation(exec->globalData()); + JSC::JSObject * proto = JSUint8ClampedArrayPrototype::self(exec, globalObject); + Base::finishCreation(exec->globalData(), Identifier(exec, proto->classInfo()->className)); ASSERT(inherits(&s_info)); - putDirect(exec->globalData(), exec->propertyNames().prototype, JSUint8ClampedArrayPrototype::self(exec, globalObject), DontDelete | ReadOnly); + putDirect(exec->globalData(), exec->propertyNames().prototype, proto, DontDelete | ReadOnly); putDirect(exec->globalData(), exec->propertyNames().length, jsNumber(1), ReadOnly | DontDelete | DontEnum); } bool JSUint8ClampedArrayConstructor::getOwnPropertySlot(JSCell* cell, ExecState* exec, const Identifier& propertyName, PropertySlot& slot) { - return getStaticValueSlot(exec, &JSUint8ClampedArrayConstructorTable, jsCast(cell), propertyName, slot); + return getStaticFunctionSlot(exec, &JSUint8ClampedArrayConstructorTable, jsCast(cell), propertyName, slot); } bool JSUint8ClampedArrayConstructor::getOwnPropertyDescriptor(JSObject* object, ExecState* exec, const Identifier& propertyName, PropertyDescriptor& descriptor) { - return getStaticValueDescriptor(exec, &JSUint8ClampedArrayConstructorTable, jsCast(object), propertyName, descriptor); + return getStaticFunctionDescriptor(exec, &JSUint8ClampedArrayConstructorTable, jsCast(object), propertyName, descriptor); } ConstructType JSUint8ClampedArrayConstructor::getConstructData(JSCell*, ConstructData& constructData) @@ -104,7 +106,7 @@ const ClassInfo JSUint8ClampedArrayPrototype::s_info = { "Uint8ClampedArrayProto JSObject* JSUint8ClampedArrayPrototype::self(ExecState* exec, JSGlobalObject* globalObject) { - return getDOMPrototype(exec, globalObject); + return getDOMPrototype(exec, globalObject); } bool JSUint8ClampedArrayPrototype::getOwnPropertySlot(JSCell* cell, ExecState* exec, const Identifier& propertyName, PropertySlot& slot) @@ -126,7 +128,7 @@ static const HashTable* getJSUint8ClampedArrayTable(ExecState* exec) const ClassInfo JSUint8ClampedArray::s_info = { "Uint8ClampedArray", &Base::s_info, 0, getJSUint8ClampedArrayTable , CREATE_METHOD_TABLE(JSUint8ClampedArray) }; -JSUint8ClampedArray::JSUint8ClampedArray(Structure* structure, JSDOMGlobalObject* globalObject, PassRefPtr impl) +JSUint8ClampedArray::JSUint8ClampedArray(Structure* structure, JSGlobalObject* globalObject, PassRefPtr impl) : JSUint8Array(structure, globalObject, impl) { } @@ -231,7 +233,7 @@ void JSUint8ClampedArray::getOwnPropertyNames(JSObject* object, ExecState* exec, JSValue JSUint8ClampedArray::getConstructor(ExecState* exec, JSGlobalObject* globalObject) { - return getDOMConstructor(exec, jsCast(globalObject)); + return getDOMConstructor(exec, jsCast(globalObject)); } EncodedJSValue JSC_HOST_CALL jsUint8ClampedArrayPrototypeFunctionSubarray(ExecState* exec) diff --git a/JavaScriptCore/runtime/TypedArrays/JSUint8ClampedArray.h b/JavaScriptCore/runtime/TypedArrays/JSUint8ClampedArray.h index 31296398..7c430c74 100644 --- a/JavaScriptCore/runtime/TypedArrays/JSUint8ClampedArray.h +++ b/JavaScriptCore/runtime/TypedArrays/JSUint8ClampedArray.h @@ -21,7 +21,7 @@ #ifndef JSUint8ClampedArray_h #define JSUint8ClampedArray_h -#include "JSDOMBinding.h" +#include "InternalFunction.h" #include "JSUint8Array.h" #include #include @@ -31,7 +31,7 @@ namespace WebCore { class JSUint8ClampedArray : public JSUint8Array { public: typedef JSUint8Array Base; - static JSUint8ClampedArray* create(JSC::Structure* structure, JSDOMGlobalObject* globalObject, PassRefPtr impl) + static JSUint8ClampedArray* create(JSC::Structure* structure, JSC::JSGlobalObject* globalObject, PassRefPtr impl) { JSUint8ClampedArray* ptr = new (NotNull, JSC::allocateCell(globalObject->globalData().heap)) JSUint8ClampedArray(structure, globalObject, impl); ptr->finishCreation(globalObject->globalData()); @@ -64,14 +64,14 @@ class JSUint8ClampedArray : public JSUint8Array { intptr_t m_storageLength; void* m_storage; protected: - JSUint8ClampedArray(JSC::Structure*, JSDOMGlobalObject*, PassRefPtr); + JSUint8ClampedArray(JSC::Structure*, JSC::JSGlobalObject*, PassRefPtr); void finishCreation(JSC::JSGlobalData&); static const unsigned StructureFlags = JSC::OverridesGetPropertyNames | JSC::OverridesGetOwnPropertySlot | Base::StructureFlags; JSC::JSValue getByIndex(JSC::ExecState*, unsigned index); void indexSetter(JSC::ExecState*, unsigned index, JSC::JSValue); }; -JSC::JSValue toJS(JSC::ExecState*, JSDOMGlobalObject*, Uint8ClampedArray*); +JSC::JSValue toJS(JSC::ExecState*, JSC::JSGlobalObject*, Uint8ClampedArray*); Uint8ClampedArray* toUint8ClampedArray(JSC::JSValue); class JSUint8ClampedArrayPrototype : public JSC::JSNonFinalObject { @@ -99,14 +99,14 @@ class JSUint8ClampedArrayPrototype : public JSC::JSNonFinalObject { static const unsigned StructureFlags = JSC::OverridesGetOwnPropertySlot | Base::StructureFlags; }; -class JSUint8ClampedArrayConstructor : public DOMConstructorObject { +class JSUint8ClampedArrayConstructor : public JSC::InternalFunction { private: - JSUint8ClampedArrayConstructor(JSC::Structure*, JSDOMGlobalObject*); - void finishCreation(JSC::ExecState*, JSDOMGlobalObject*); + JSUint8ClampedArrayConstructor(JSC::Structure*, JSC::JSGlobalObject*); + void finishCreation(JSC::ExecState*, JSC::JSGlobalObject*); public: - typedef DOMConstructorObject Base; - static JSUint8ClampedArrayConstructor* create(JSC::ExecState* exec, JSC::Structure* structure, JSDOMGlobalObject* globalObject) + typedef JSC::InternalFunction Base; + static JSUint8ClampedArrayConstructor* create(JSC::ExecState* exec, JSC::Structure* structure, JSC::JSGlobalObject* globalObject) { JSUint8ClampedArrayConstructor* ptr = new (NotNull, JSC::allocateCell(*exec->heap())) JSUint8ClampedArrayConstructor(structure, globalObject); ptr->finishCreation(exec, globalObject); @@ -121,7 +121,7 @@ class JSUint8ClampedArrayConstructor : public DOMConstructorObject { return JSC::Structure::create(globalData, globalObject, prototype, JSC::TypeInfo(JSC::ObjectType, StructureFlags), &s_info); } protected: - static const unsigned StructureFlags = JSC::OverridesGetOwnPropertySlot | JSC::ImplementsHasInstance | DOMConstructorObject::StructureFlags; + static const unsigned StructureFlags = JSC::OverridesGetOwnPropertySlot | JSC::ImplementsHasInstance | JSC::InternalFunction::StructureFlags; static JSC::EncodedJSValue JSC_HOST_CALL constructJSUint8ClampedArray(JSC::ExecState*); static JSC::ConstructType getConstructData(JSC::JSCell*, JSC::ConstructData&); }; diff --git a/JavaScriptCore/runtime/TypedArrays/JSUint8ClampedArrayCustom.cpp b/JavaScriptCore/runtime/TypedArrays/JSUint8ClampedArrayCustom.cpp index 2d5ca785..1b36c53f 100644 --- a/JavaScriptCore/runtime/TypedArrays/JSUint8ClampedArrayCustom.cpp +++ b/JavaScriptCore/runtime/TypedArrays/JSUint8ClampedArrayCustom.cpp @@ -38,7 +38,7 @@ void JSUint8ClampedArray::indexSetter(JSC::ExecState* exec, unsigned index, JSC: impl()->set(index, value.toNumber(exec)); } -JSC::JSValue toJS(JSC::ExecState* exec, JSDOMGlobalObject* globalObject, Uint8ClampedArray* object) +JSC::JSValue toJS(JSC::ExecState* exec, JSGlobalObject* globalObject, Uint8ClampedArray* object) { return toJSArrayBufferView(exec, globalObject, object); } From 867e19518a5ec44be7cb6c792f272497d0cf49fd Mon Sep 17 00:00:00 2001 From: Dominic Szablewski Date: Mon, 10 Dec 2012 00:31:13 +0100 Subject: [PATCH 12/30] Added Arrays and ArrayBuffer to GlobalObject --- JavaScriptCore/runtime/JSGlobalObject.cpp | 41 ++++++++++++++++++++++- 1 file changed, 40 insertions(+), 1 deletion(-) diff --git a/JavaScriptCore/runtime/JSGlobalObject.cpp b/JavaScriptCore/runtime/JSGlobalObject.cpp index 33143790..93884e5c 100644 --- a/JavaScriptCore/runtime/JSGlobalObject.cpp +++ b/JavaScriptCore/runtime/JSGlobalObject.cpp @@ -74,7 +74,16 @@ // PL Typed Arrays +#include "JSArrayBuffer.h" #include "JSFloat32Array.h" +#include "JSFloat64Array.h" +#include "JSInt8Array.h" +#include "JSInt16Array.h" +#include "JSInt32Array.h" +#include "JSUint8ClampedArray.h" +#include "JSUint8Array.h" +#include "JSUint16Array.h" +#include "JSUint32Array.h" #include "JSGlobalObject.lut.h" @@ -297,8 +306,38 @@ void JSGlobalObject::reset(JSValue prototype) // PL Typed Arrays + putDirectWithoutTransition(exec->globalData(), Identifier(exec, WebCore::JSArrayBuffer::s_info.className), + WebCore::JSArrayBuffer::getConstructor(exec, this), DontEnum); + putDirectWithoutTransition(exec->globalData(), Identifier(exec, WebCore::JSFloat32Array::s_info.className), - WebCore::JSFloat32Array::getConstructor(exec, this), DontEnum); + WebCore::JSFloat32Array::getConstructor(exec, this), DontEnum); + + putDirectWithoutTransition(exec->globalData(), Identifier(exec, WebCore::JSFloat32Array::s_info.className), + WebCore::JSFloat32Array::getConstructor(exec, this), DontEnum); + + putDirectWithoutTransition(exec->globalData(), Identifier(exec, WebCore::JSFloat64Array::s_info.className), + WebCore::JSFloat64Array::getConstructor(exec, this), DontEnum); + + putDirectWithoutTransition(exec->globalData(), Identifier(exec, WebCore::JSInt8Array::s_info.className), + WebCore::JSInt8Array::getConstructor(exec, this), DontEnum); + + putDirectWithoutTransition(exec->globalData(), Identifier(exec, WebCore::JSInt16Array::s_info.className), + WebCore::JSInt16Array::getConstructor(exec, this), DontEnum); + + putDirectWithoutTransition(exec->globalData(), Identifier(exec, WebCore::JSInt32Array::s_info.className), + WebCore::JSInt32Array::getConstructor(exec, this), DontEnum); + + putDirectWithoutTransition(exec->globalData(), Identifier(exec, WebCore::JSUint8ClampedArray::s_info.className), + WebCore::JSUint8ClampedArray::getConstructor(exec, this), DontEnum); + + putDirectWithoutTransition(exec->globalData(), Identifier(exec, WebCore::JSUint8Array::s_info.className), + WebCore::JSUint8Array::getConstructor(exec, this), DontEnum); + + putDirectWithoutTransition(exec->globalData(), Identifier(exec, WebCore::JSUint16Array::s_info.className), + WebCore::JSUint16Array::getConstructor(exec, this), DontEnum); + + putDirectWithoutTransition(exec->globalData(), Identifier(exec, WebCore::JSUint32Array::s_info.className), + WebCore::JSFloat32Array::getConstructor(exec, this), DontEnum); m_evalFunction.set(exec->globalData(), this, JSFunction::create(exec, this, 1, exec->propertyNames().eval, globalFuncEval)); From e659470f41c1142000e269325801831b21181345 Mon Sep 17 00:00:00 2001 From: Dominic Szablewski Date: Mon, 10 Dec 2012 14:39:08 +0100 Subject: [PATCH 13/30] Added API methods to work with Typed Arrays --- JavaScriptCore/API/JSTypedArray.cpp | 107 ++++++++++++++++++ JavaScriptCore/API/JSTypedArray.h | 33 ++++++ .../JavaScriptCore.xcodeproj/project.pbxproj | 12 ++ 3 files changed, 152 insertions(+) create mode 100644 JavaScriptCore/API/JSTypedArray.cpp create mode 100644 JavaScriptCore/API/JSTypedArray.h diff --git a/JavaScriptCore/API/JSTypedArray.cpp b/JavaScriptCore/API/JSTypedArray.cpp new file mode 100644 index 00000000..462d1dbe --- /dev/null +++ b/JavaScriptCore/API/JSTypedArray.cpp @@ -0,0 +1,107 @@ + +#include "config.h" + +#include "JSTypedArray.h" + +#include "JSObjectRef.h" +#include "APICast.h" +#include "InitializeThreading.h" +#include "JSCallbackObject.h" +#include "JSClassRef.h" +#include "JSGlobalObject.h" + +#include "JSArrayBuffer.h" +#include "JSFloat32Array.h" +#include "JSFloat64Array.h" +#include "JSInt8Array.h" +#include "JSInt16Array.h" +#include "JSInt32Array.h" +#include "JSUint8ClampedArray.h" +#include "JSUint8Array.h" +#include "JSUint16Array.h" +#include "JSUint32Array.h" + + +using namespace JSC; +using namespace WebCore; + +// Better be safe than sorry! +const JSTypedArrayType TypedArrayTypes[] = { + [TypedArrayNone] = kJSTypedArrayTypeNone, + [TypedArrayInt8] = kJSTypedArrayTypeInt8Array, + [TypedArrayInt16] = kJSTypedArrayTypeInt16Array, + [TypedArrayInt32] = kJSTypedArrayTypeInt32Array, + [TypedArrayUint8] = kJSTypedArrayTypeUint8Array, + [TypedArrayUint8Clamped] = kJSTypedArrayTypeUint8ClampedArray, + [TypedArrayUint16] = kJSTypedArrayTypeUint16Array, + [TypedArrayUint32] = kJSTypedArrayTypeUint32Array, + [TypedArrayFloat32] = kJSTypedArrayTypeFloat32Array, + [TypedArrayFloat64] = kJSTypedArrayTypeFloat64Array +}; + + +template JSObject * CreateTypedArray(JSC::ExecState* exec, size_t length) { + RefPtr array = ArrayType::create(length); + if( !array.get() ) { + return NULL; + } + return asObject(toJS(exec, exec->lexicalGlobalObject(), array.get())); +} + +typedef JSObject*(*CreateTypedArrayFuncPtr)(JSC::ExecState*, size_t); +const CreateTypedArrayFuncPtr CreateTypedArrayFunc[] = { + [kJSTypedArrayTypeNone] = NULL, + [kJSTypedArrayTypeInt8Array] = CreateTypedArray, + [kJSTypedArrayTypeInt16Array] = CreateTypedArray, + [kJSTypedArrayTypeInt32Array] = CreateTypedArray, + [kJSTypedArrayTypeUint8Array] = CreateTypedArray, + [kJSTypedArrayTypeUint8ClampedArray] = CreateTypedArray, + [kJSTypedArrayTypeUint16Array] = CreateTypedArray, + [kJSTypedArrayTypeUint32Array] = CreateTypedArray, + [kJSTypedArrayTypeFloat32Array] = CreateTypedArray, + [kJSTypedArrayTypeFloat64Array] = CreateTypedArray +}; + + + + +JSTypedArrayType JSTypedArrayGetType(JSContextRef ctx, JSValueRef value) { + ExecState* exec = toJS(ctx); + APIEntryShim entryShim(exec); + + JSValue jsValue = toJS(exec, value); + if( JSObject* object = jsValue.getObject() ) { + return TypedArrayTypes[object->classInfo()->typedArrayStorageType]; + } + return kJSTypedArrayTypeNone; +} + +JSValueRef JSTypedArrayMake(JSContextRef ctx, JSTypedArrayType arrayType, size_t numElements) { + ExecState* exec = toJS(ctx); + APIEntryShim entryShim(exec); + + JSObject* result; + if( arrayType > kJSTypedArrayTypeNone && arrayType < kJSTypedArrayTypeLast ) { + result = CreateTypedArrayFunc[arrayType]( exec, numElements ); + } + + return toRef(result); +} + +void * JSTypedArrayGetDataPtr(JSContextRef ctx, JSValueRef value, size_t * byteLength) { + ExecState* exec = toJS(ctx); + APIEntryShim entryShim(exec); + + JSValue jsValue = toJS(exec, value); + if( ArrayBufferView * view = toArrayBufferView(jsValue) ) { + if( byteLength ) { + *byteLength = view->byteLength(); + } + return view->baseAddress(); + } + + return NULL; +} + + + diff --git a/JavaScriptCore/API/JSTypedArray.h b/JavaScriptCore/API/JSTypedArray.h new file mode 100644 index 00000000..9e2e8744 --- /dev/null +++ b/JavaScriptCore/API/JSTypedArray.h @@ -0,0 +1,33 @@ +#ifndef JSTypedArray_h +#define JSTypedArray_h + +#include + +typedef enum { + kJSTypedArrayTypeNone, + kJSTypedArrayTypeInt8Array, + kJSTypedArrayTypeInt16Array, + kJSTypedArrayTypeInt32Array, + kJSTypedArrayTypeUint8Array, + kJSTypedArrayTypeUint8ClampedArray, + kJSTypedArrayTypeUint16Array, + kJSTypedArrayTypeUint32Array, + kJSTypedArrayTypeFloat32Array, + kJSTypedArrayTypeFloat64Array, + kJSTypedArrayTypeLast +} JSTypedArrayType; + + +#ifdef __cplusplus +extern "C" { +#endif + +JS_EXPORT JSTypedArrayType JSTypedArrayGetType(JSContextRef ctx, JSValueRef array); +JS_EXPORT JSValueRef JSTypedArrayMake(JSContextRef ctx, JSTypedArrayType arrayClass, size_t numElements); +JS_EXPORT void * JSTypedArrayGetDataPtr(JSContextRef ctx, JSValueRef array, size_t * byteLength); + +#ifdef __cplusplus +} +#endif + +#endif /* JSTypedArray_h */ diff --git a/JavaScriptCore/JavaScriptCore.xcodeproj/project.pbxproj b/JavaScriptCore/JavaScriptCore.xcodeproj/project.pbxproj index 2d0f6601..1f7ea8bd 100644 --- a/JavaScriptCore/JavaScriptCore.xcodeproj/project.pbxproj +++ b/JavaScriptCore/JavaScriptCore.xcodeproj/project.pbxproj @@ -1158,6 +1158,10 @@ B6F114C01673B116001F1324 /* JSUint32Array.h in Headers */ = {isa = PBXBuildFile; fileRef = B6F114911673B115001F1324 /* JSUint32Array.h */; }; B6F114C11673B116001F1324 /* JSUint32ArrayCustom.cpp in Sources */ = {isa = PBXBuildFile; fileRef = B6F114921673B115001F1324 /* JSUint32ArrayCustom.cpp */; }; B6F114C21673B116001F1324 /* JSUint32ArrayCustom.cpp in Sources */ = {isa = PBXBuildFile; fileRef = B6F114921673B115001F1324 /* JSUint32ArrayCustom.cpp */; }; + B6F114C816755F98001F1324 /* JSTypedArray.cpp in Sources */ = {isa = PBXBuildFile; fileRef = B6F114C616755F97001F1324 /* JSTypedArray.cpp */; }; + B6F114C916755F98001F1324 /* JSTypedArray.cpp in Sources */ = {isa = PBXBuildFile; fileRef = B6F114C616755F97001F1324 /* JSTypedArray.cpp */; }; + B6F114CA16755F98001F1324 /* JSTypedArray.h in Headers */ = {isa = PBXBuildFile; fileRef = B6F114C716755F97001F1324 /* JSTypedArray.h */; }; + B6F114CB16755F98001F1324 /* JSTypedArray.h in Headers */ = {isa = PBXBuildFile; fileRef = B6F114C716755F97001F1324 /* JSTypedArray.h */; }; BC02E90D0E1839DB000F9297 /* ErrorConstructor.h in Headers */ = {isa = PBXBuildFile; fileRef = BC02E9050E1839DB000F9297 /* ErrorConstructor.h */; }; BC02E90F0E1839DB000F9297 /* ErrorPrototype.h in Headers */ = {isa = PBXBuildFile; fileRef = BC02E9070E1839DB000F9297 /* ErrorPrototype.h */; }; BC02E9110E1839DB000F9297 /* NativeErrorConstructor.h in Headers */ = {isa = PBXBuildFile; fileRef = BC02E9090E1839DB000F9297 /* NativeErrorConstructor.h */; }; @@ -1909,6 +1913,8 @@ B6F114901673B115001F1324 /* JSUint32Array.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = JSUint32Array.cpp; sourceTree = ""; }; B6F114911673B115001F1324 /* JSUint32Array.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = JSUint32Array.h; sourceTree = ""; }; B6F114921673B115001F1324 /* JSUint32ArrayCustom.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = JSUint32ArrayCustom.cpp; sourceTree = ""; }; + B6F114C616755F97001F1324 /* JSTypedArray.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = JSTypedArray.cpp; sourceTree = ""; }; + B6F114C716755F97001F1324 /* JSTypedArray.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = JSTypedArray.h; sourceTree = ""; }; BC021BF1136900C300FC5467 /* CompilerVersion.xcconfig */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.xcconfig; path = CompilerVersion.xcconfig; sourceTree = ""; }; BC021BF2136900C300FC5467 /* ToolExecutable.xcconfig */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.xcconfig; path = ToolExecutable.xcconfig; sourceTree = ""; }; BC02E9040E1839DB000F9297 /* ErrorConstructor.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = ErrorConstructor.cpp; sourceTree = ""; }; @@ -2393,6 +2399,8 @@ 1482B74B0A43032800517CFC /* JSStringRef.h */, 146AAB370B66A94400E55F16 /* JSStringRefCF.cpp */, 146AAB2A0B66A84900E55F16 /* JSStringRefCF.h */, + B6F114C616755F97001F1324 /* JSTypedArray.cpp */, + B6F114C716755F97001F1324 /* JSTypedArray.h */, 14BD5A2B0A3E91F600BAF59C /* JSValueRef.cpp */, 1482B6EA0A4300B300517CFC /* JSValueRef.h */, A7482E37116A697B003B0712 /* JSWeakObjectMapRefInternal.h */, @@ -3363,6 +3371,7 @@ B6F114B31673B116001F1324 /* JSUint8ClampedArray.h in Headers */, B6F114B91673B116001F1324 /* JSUint16Array.h in Headers */, B6F114BF1673B116001F1324 /* JSUint32Array.h in Headers */, + B6F114CA16755F98001F1324 /* JSTypedArray.h in Headers */, ); runOnlyForDeploymentPostprocessing = 0; }; @@ -3721,6 +3730,7 @@ B6F114B41673B116001F1324 /* JSUint8ClampedArray.h in Headers */, B6F114BA1673B116001F1324 /* JSUint16Array.h in Headers */, B6F114C01673B116001F1324 /* JSUint32Array.h in Headers */, + B6F114CB16755F98001F1324 /* JSTypedArray.h in Headers */, ); runOnlyForDeploymentPostprocessing = 0; }; @@ -4487,6 +4497,7 @@ B6F114BB1673B116001F1324 /* JSUint16ArrayCustom.cpp in Sources */, B6F114BD1673B116001F1324 /* JSUint32Array.cpp in Sources */, B6F114C11673B116001F1324 /* JSUint32ArrayCustom.cpp in Sources */, + B6F114C816755F98001F1324 /* JSTypedArray.cpp in Sources */, ); runOnlyForDeploymentPostprocessing = 0; }; @@ -4732,6 +4743,7 @@ B6F114BC1673B116001F1324 /* JSUint16ArrayCustom.cpp in Sources */, B6F114BE1673B116001F1324 /* JSUint32Array.cpp in Sources */, B6F114C21673B116001F1324 /* JSUint32ArrayCustom.cpp in Sources */, + B6F114C916755F98001F1324 /* JSTypedArray.cpp in Sources */, ); runOnlyForDeploymentPostprocessing = 0; }; From 0957269e67c59183db56c2867cf0379c4d5b32f7 Mon Sep 17 00:00:00 2001 From: Dominic Szablewski Date: Mon, 10 Dec 2012 14:56:59 +0100 Subject: [PATCH 14/30] Added documentation for the TypedArray API --- JavaScriptCore/API/JSTypedArray.h | 51 +++++++++++++++++++++++++++---- 1 file changed, 45 insertions(+), 6 deletions(-) diff --git a/JavaScriptCore/API/JSTypedArray.h b/JavaScriptCore/API/JSTypedArray.h index 9e2e8744..24d66e8b 100644 --- a/JavaScriptCore/API/JSTypedArray.h +++ b/JavaScriptCore/API/JSTypedArray.h @@ -3,6 +3,24 @@ #include +#ifdef __cplusplus +extern "C" { +#endif + +/*! +@enum JSType +@abstract A constant identifying the Typed Array type of a JSValue. +@constant kJSTypedArrayTypeNone Not a Typed Array. +@constant kJSTypedArrayTypeInt8Array Int8Array +@constant kJSTypedArrayTypeInt16Array Int16Array +@constant kJSTypedArrayTypeInt32Array Int32Array +@constant kJSTypedArrayTypeUint8Array Int8Array +@constant kJSTypedArrayTypeUint8ClampedArray Int8ClampedArray +@constant kJSTypedArrayTypeUint16Array Uint16Array +@constant kJSTypedArrayTypeUint32Array Uint32Array +@constant kJSTypedArrayTypeFloat32Array Float32Array +@constant kJSTypedArrayTypeFloat64Array Float64Array +*/ typedef enum { kJSTypedArrayTypeNone, kJSTypedArrayTypeInt8Array, @@ -17,14 +35,35 @@ typedef enum { kJSTypedArrayTypeLast } JSTypedArrayType; +/*! +@function +@abstract Returns a JavaScript value's Typed Array type +@param ctx The execution context to use. +@param value The JSValue whose Typed Array type you want to obtain. +@result A value of type JSTypedArrayType that identifies value's Typed Array type. +*/ +JS_EXPORT JSTypedArrayType JSTypedArrayGetType(JSContextRef ctx, JSValueRef value); -#ifdef __cplusplus -extern "C" { -#endif - -JS_EXPORT JSTypedArrayType JSTypedArrayGetType(JSContextRef ctx, JSValueRef array); +/*! +@function +@abstract Creates a JavaScript Typed Array with the given number of elements +@param ctx The execution context to use. +@param arrayClass A value of type JSTypedArrayType identifying the type of array you want to create +@param numElements The number of elements for the array. +@result A JSValueRef that is a Typed Array or NULL if there was an error +*/ JS_EXPORT JSValueRef JSTypedArrayMake(JSContextRef ctx, JSTypedArrayType arrayClass, size_t numElements); -JS_EXPORT void * JSTypedArrayGetDataPtr(JSContextRef ctx, JSValueRef array, size_t * byteLength); + +/*! +@function +@abstract Returns a pointer to a Typed Array's data in memory +@param ctx The execution context to use. +@param value The JSValue whose Typed Array type data pointer you want to obtain. +@param byteLength A pointer to a size_t in which to store the byte length of the Typed Array +@result A pointer to the Typed Array's data or NULL if the JSValue is not a Typed Array +*/ +JS_EXPORT void * JSTypedArrayGetDataPtr(JSContextRef ctx, JSValueRef value, size_t * byteLength); + #ifdef __cplusplus } From d60e17ae2a21e29d8b62df1678943e7904afacfb Mon Sep 17 00:00:00 2001 From: Dominic Szablewski Date: Mon, 10 Dec 2012 14:58:47 +0100 Subject: [PATCH 15/30] Moved kJSTypedArrayTypeLast out of the header --- JavaScriptCore/API/JSTypedArray.cpp | 4 +++- JavaScriptCore/API/JSTypedArray.h | 3 +-- 2 files changed, 4 insertions(+), 3 deletions(-) diff --git a/JavaScriptCore/API/JSTypedArray.cpp b/JavaScriptCore/API/JSTypedArray.cpp index 462d1dbe..708b02d1 100644 --- a/JavaScriptCore/API/JSTypedArray.cpp +++ b/JavaScriptCore/API/JSTypedArray.cpp @@ -39,6 +39,8 @@ const JSTypedArrayType TypedArrayTypes[] = { [TypedArrayFloat64] = kJSTypedArrayTypeFloat64Array }; +const int kJSTypedArrayTypeLast = kJSTypedArrayTypeFloat64Array; + template JSObject * CreateTypedArray(JSC::ExecState* exec, size_t length) { RefPtr array = ArrayType::create(length); @@ -81,7 +83,7 @@ JSValueRef JSTypedArrayMake(JSContextRef ctx, JSTypedArrayType arrayType, size_t APIEntryShim entryShim(exec); JSObject* result; - if( arrayType > kJSTypedArrayTypeNone && arrayType < kJSTypedArrayTypeLast ) { + if( arrayType > kJSTypedArrayTypeNone && arrayType <= kJSTypedArrayTypeLast ) { result = CreateTypedArrayFunc[arrayType]( exec, numElements ); } diff --git a/JavaScriptCore/API/JSTypedArray.h b/JavaScriptCore/API/JSTypedArray.h index 24d66e8b..46663e0b 100644 --- a/JavaScriptCore/API/JSTypedArray.h +++ b/JavaScriptCore/API/JSTypedArray.h @@ -31,8 +31,7 @@ typedef enum { kJSTypedArrayTypeUint16Array, kJSTypedArrayTypeUint32Array, kJSTypedArrayTypeFloat32Array, - kJSTypedArrayTypeFloat64Array, - kJSTypedArrayTypeLast + kJSTypedArrayTypeFloat64Array } JSTypedArrayType; /*! From 34fcba173d25f802ec7ed84d7b7e9381c2ed64f8 Mon Sep 17 00:00:00 2001 From: Dominic Szablewski Date: Mon, 10 Dec 2012 15:06:27 +0100 Subject: [PATCH 16/30] Set byteLength to 0 if we return NULL --- JavaScriptCore/API/JSTypedArray.cpp | 3 +++ 1 file changed, 3 insertions(+) diff --git a/JavaScriptCore/API/JSTypedArray.cpp b/JavaScriptCore/API/JSTypedArray.cpp index 708b02d1..dbfbee36 100644 --- a/JavaScriptCore/API/JSTypedArray.cpp +++ b/JavaScriptCore/API/JSTypedArray.cpp @@ -102,6 +102,9 @@ void * JSTypedArrayGetDataPtr(JSContextRef ctx, JSValueRef value, size_t * byteL return view->baseAddress(); } + if( byteLength ) { + *byteLength = 0; + } return NULL; } From f745e4caee2545c68e57c9b92cb1c34985a3f878 Mon Sep 17 00:00:00 2001 From: Dominic Szablewski Date: Mon, 10 Dec 2012 15:11:28 +0100 Subject: [PATCH 17/30] Cosmetics --- JavaScriptCore/API/JSTypedArray.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/JavaScriptCore/API/JSTypedArray.h b/JavaScriptCore/API/JSTypedArray.h index 46663e0b..063ea8ee 100644 --- a/JavaScriptCore/API/JSTypedArray.h +++ b/JavaScriptCore/API/JSTypedArray.h @@ -51,7 +51,7 @@ JS_EXPORT JSTypedArrayType JSTypedArrayGetType(JSContextRef ctx, JSValueRef valu @param numElements The number of elements for the array. @result A JSValueRef that is a Typed Array or NULL if there was an error */ -JS_EXPORT JSValueRef JSTypedArrayMake(JSContextRef ctx, JSTypedArrayType arrayClass, size_t numElements); +JS_EXPORT JSValueRef JSTypedArrayMake(JSContextRef ctx, JSTypedArrayType arrayType, size_t numElements); /*! @function From baa6b95e36b42a0ccd9ca343c9496e11d2c5c7ca Mon Sep 17 00:00:00 2001 From: Dominic Szablewski Date: Mon, 10 Dec 2012 15:14:47 +0100 Subject: [PATCH 18/30] Changed JSTypedArrayMake to return a JSObjectRef --- JavaScriptCore/API/JSTypedArray.cpp | 2 +- JavaScriptCore/API/JSTypedArray.h | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/JavaScriptCore/API/JSTypedArray.cpp b/JavaScriptCore/API/JSTypedArray.cpp index dbfbee36..bd72eabf 100644 --- a/JavaScriptCore/API/JSTypedArray.cpp +++ b/JavaScriptCore/API/JSTypedArray.cpp @@ -78,7 +78,7 @@ JSTypedArrayType JSTypedArrayGetType(JSContextRef ctx, JSValueRef value) { return kJSTypedArrayTypeNone; } -JSValueRef JSTypedArrayMake(JSContextRef ctx, JSTypedArrayType arrayType, size_t numElements) { +JSObjectRef JSTypedArrayMake(JSContextRef ctx, JSTypedArrayType arrayType, size_t numElements) { ExecState* exec = toJS(ctx); APIEntryShim entryShim(exec); diff --git a/JavaScriptCore/API/JSTypedArray.h b/JavaScriptCore/API/JSTypedArray.h index 063ea8ee..16ee6a76 100644 --- a/JavaScriptCore/API/JSTypedArray.h +++ b/JavaScriptCore/API/JSTypedArray.h @@ -49,9 +49,9 @@ JS_EXPORT JSTypedArrayType JSTypedArrayGetType(JSContextRef ctx, JSValueRef valu @param ctx The execution context to use. @param arrayClass A value of type JSTypedArrayType identifying the type of array you want to create @param numElements The number of elements for the array. -@result A JSValueRef that is a Typed Array or NULL if there was an error +@result A JSObjectRef that is a Typed Array or NULL if there was an error */ -JS_EXPORT JSValueRef JSTypedArrayMake(JSContextRef ctx, JSTypedArrayType arrayType, size_t numElements); +JS_EXPORT JSObjectRef JSTypedArrayMake(JSContextRef ctx, JSTypedArrayType arrayType, size_t numElements); /*! @function From e438078ce33b76c97d87cbeaa38adef7d0665bc4 Mon Sep 17 00:00:00 2001 From: Dominic Szablewski Date: Mon, 10 Dec 2012 15:28:45 +0100 Subject: [PATCH 19/30] Updated README for Typed Arrays --- README.md | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/README.md b/README.md index bd23122b..25ceeb95 100644 --- a/README.md +++ b/README.md @@ -6,9 +6,13 @@ This repo aims to re-produce the missing iOS targets while staying on a somewhat Currently, the [Safari 6.0.2 release](https://svn.webkit.org/repository/webkit/releases/Apple/Safari%206.0.2/) is used as the basis. With the current settings, the WTF and JavaScriptCore libraries can be compiled for armv7 and x86 (for the iOS simulator). It will be compiled without Unicode collation support, because Apple claims [ICU](http://site.icu-project.org/) is a private framework on iOS. It should be AppStore compatible this way. -## Binaries +## Typed Array Branch -A compiled version of the `libJavaScriptCore.a` for armv7 and the Simulator can be found in the [source tree](https://github.com/phoboslab/Ejecta/tree/master/Source/lib) of the [Ejecta project](https://github.com/phoboslab/Ejecta). +This branch enables support for JavaScript's Typed Arrays which are normally a part of WebKit, not of JavaScriptCore. + +The compiled .idl files of the WebCore project were adapted to work directly in JavaScriptCore; all DOM references were removed or replaced. As far as I can tell everything works. However, I took some shortcuts for defining the Array's prototypes and constructors: they're all shared across all JSC Contexts - so it will probably explode in your face when you use several Contexts _and_ modify the prototypes in JavaScript. + +I also wrote some new API methods to work with Typed Arrays in native code. Have a lookt at the `API/JSTypedArray.h`, it declares three new API functions. The documentation for these functoins can be found in this header file as well. ## How to Compile From f480ea39d31c3cc7587901c20080a1e8c26b8b36 Mon Sep 17 00:00:00 2001 From: Dominic Szablewski Date: Mon, 10 Dec 2012 15:37:42 +0100 Subject: [PATCH 20/30] Added download link for the Binaries --- README.md | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/README.md b/README.md index 25ceeb95..8a4b3eca 100644 --- a/README.md +++ b/README.md @@ -14,6 +14,12 @@ The compiled .idl files of the WebCore project were adapted to work directly in I also wrote some new API methods to work with Typed Arrays in native code. Have a lookt at the `API/JSTypedArray.h`, it declares three new API functions. The documentation for these functoins can be found in this header file as well. +## Binaries + +A binary version of the libJavaScriptCore.a that includes Typed Array support can be found here; don't expect this to be up to date, though: + +http://phoboslab.org/crap/libJavaScriptCore-TypedArrays.zip + ## How to Compile 1. Create a `Build/` directory in the top level of this repo. The combined `libWTF.a` and `JavaScriptCore.a` will be placed here From 82f9014c89066ae38009212b67c55d14bed01eda Mon Sep 17 00:00:00 2001 From: Dominic Szablewski Date: Sat, 22 Dec 2012 19:51:56 +0100 Subject: [PATCH 21/30] Updated validated project settings --- .../JavaScriptCore.xcodeproj/project.pbxproj | 26 ++++++++++++++++++- 1 file changed, 25 insertions(+), 1 deletion(-) diff --git a/JavaScriptCore/JavaScriptCore.xcodeproj/project.pbxproj b/JavaScriptCore/JavaScriptCore.xcodeproj/project.pbxproj index 1f7ea8bd..d78e9f74 100644 --- a/JavaScriptCore/JavaScriptCore.xcodeproj/project.pbxproj +++ b/JavaScriptCore/JavaScriptCore.xcodeproj/project.pbxproj @@ -3899,7 +3899,7 @@ isa = PBXProject; attributes = { BuildIndependentTargetsInParallel = YES; - LastUpgradeCheck = 0440; + LastUpgradeCheck = 0450; }; buildConfigurationList = 149C277108902AFE008A9EFC /* Build configuration list for PBXProject "JavaScriptCore" */; compatibilityVersion = "Xcode 3.2"; @@ -4824,6 +4824,7 @@ 0F4680AD14BA7FD900BFE272 /* Debug */ = { isa = XCBuildConfiguration; buildSettings = { + COMBINE_HIDPI_IMAGES = YES; PRODUCT_NAME = "Derived Sources copy"; }; name = Debug; @@ -4831,6 +4832,7 @@ 0F4680AE14BA7FD900BFE272 /* Release */ = { isa = XCBuildConfiguration; buildSettings = { + COMBINE_HIDPI_IMAGES = YES; PRODUCT_NAME = "Derived Sources copy"; }; name = Release; @@ -4838,6 +4840,7 @@ 0F4680AF14BA7FD900BFE272 /* Profiling */ = { isa = XCBuildConfiguration; buildSettings = { + COMBINE_HIDPI_IMAGES = YES; PRODUCT_NAME = "Derived Sources copy"; }; name = Profiling; @@ -4845,6 +4848,7 @@ 0F4680B014BA7FD900BFE272 /* Production */ = { isa = XCBuildConfiguration; buildSettings = { + COMBINE_HIDPI_IMAGES = YES; PRODUCT_NAME = "Derived Sources copy"; }; name = Production; @@ -4902,6 +4906,7 @@ isa = XCBuildConfiguration; baseConfigurationReference = 1C9051430BA9E8A70081E9D0 /* JavaScriptCore.xcconfig */; buildSettings = { + COMBINE_HIDPI_IMAGES = YES; INSTALL_PATH = "$(BUILT_PRODUCTS_DIR)"; }; name = Debug; @@ -4910,6 +4915,7 @@ isa = XCBuildConfiguration; baseConfigurationReference = 1C9051430BA9E8A70081E9D0 /* JavaScriptCore.xcconfig */; buildSettings = { + COMBINE_HIDPI_IMAGES = YES; INSTALL_PATH = "$(BUILT_PRODUCTS_DIR)"; }; name = Release; @@ -4919,6 +4925,7 @@ baseConfigurationReference = 1C9051430BA9E8A70081E9D0 /* JavaScriptCore.xcconfig */; buildSettings = { BUILD_VARIANTS = normal; + COMBINE_HIDPI_IMAGES = YES; }; name = Production; }; @@ -4946,6 +4953,7 @@ 149C276D08902AFE008A9EFC /* Debug */ = { isa = XCBuildConfiguration; buildSettings = { + COMBINE_HIDPI_IMAGES = YES; PRODUCT_NAME = All; }; name = Debug; @@ -4953,6 +4961,7 @@ 149C276E08902AFE008A9EFC /* Release */ = { isa = XCBuildConfiguration; buildSettings = { + COMBINE_HIDPI_IMAGES = YES; PRODUCT_NAME = All; }; name = Release; @@ -4960,6 +4969,7 @@ 149C277008902AFE008A9EFC /* Production */ = { isa = XCBuildConfiguration; buildSettings = { + COMBINE_HIDPI_IMAGES = YES; PRODUCT_NAME = All; }; name = Production; @@ -5014,6 +5024,7 @@ 5D6B2A48152B9E17005231DE /* Debug */ = { isa = XCBuildConfiguration; buildSettings = { + COMBINE_HIDPI_IMAGES = YES; PRODUCT_NAME = "$(TARGET_NAME)"; }; name = Debug; @@ -5021,6 +5032,7 @@ 5D6B2A49152B9E17005231DE /* Release */ = { isa = XCBuildConfiguration; buildSettings = { + COMBINE_HIDPI_IMAGES = YES; PRODUCT_NAME = "$(TARGET_NAME)"; }; name = Release; @@ -5028,6 +5040,7 @@ 5D6B2A4A152B9E17005231DE /* Profiling */ = { isa = XCBuildConfiguration; buildSettings = { + COMBINE_HIDPI_IMAGES = YES; PRODUCT_NAME = "$(TARGET_NAME)"; }; name = Profiling; @@ -5035,6 +5048,7 @@ 5D6B2A4B152B9E17005231DE /* Production */ = { isa = XCBuildConfiguration; buildSettings = { + COMBINE_HIDPI_IMAGES = YES; PRODUCT_NAME = "$(TARGET_NAME)"; }; name = Production; @@ -5070,6 +5084,7 @@ 65FB3F7809D11EBD00F49DEB /* Debug */ = { isa = XCBuildConfiguration; buildSettings = { + COMBINE_HIDPI_IMAGES = YES; PRODUCT_NAME = "Generate Derived Sources"; }; name = Debug; @@ -5077,6 +5092,7 @@ 65FB3F7909D11EBD00F49DEB /* Release */ = { isa = XCBuildConfiguration; buildSettings = { + COMBINE_HIDPI_IMAGES = YES; PRODUCT_NAME = "Generate Derived Sources"; }; name = Release; @@ -5084,6 +5100,7 @@ 65FB3F7A09D11EBD00F49DEB /* Production */ = { isa = XCBuildConfiguration; buildSettings = { + COMBINE_HIDPI_IMAGES = YES; PRODUCT_NAME = "Generate Derived Sources"; }; name = Production; @@ -5099,6 +5116,7 @@ A761483E0E6402F700E357FA /* Profiling */ = { isa = XCBuildConfiguration; buildSettings = { + COMBINE_HIDPI_IMAGES = YES; PRODUCT_NAME = All; }; name = Profiling; @@ -5107,6 +5125,7 @@ isa = XCBuildConfiguration; baseConfigurationReference = 1C9051430BA9E8A70081E9D0 /* JavaScriptCore.xcconfig */; buildSettings = { + COMBINE_HIDPI_IMAGES = YES; INSTALL_PATH = "$(BUILT_PRODUCTS_DIR)"; }; name = Profiling; @@ -5114,6 +5133,7 @@ A76148400E6402F700E357FA /* Profiling */ = { isa = XCBuildConfiguration; buildSettings = { + COMBINE_HIDPI_IMAGES = YES; PRODUCT_NAME = "Generate Derived Sources"; }; name = Profiling; @@ -5394,6 +5414,7 @@ B6E69C01166BDD18005EF4B1 /* Debug */ = { isa = XCBuildConfiguration; buildSettings = { + COMBINE_HIDPI_IMAGES = YES; PRODUCT_NAME = "$(TARGET_NAME)"; }; name = Debug; @@ -5401,6 +5422,7 @@ B6E69C02166BDD18005EF4B1 /* Release */ = { isa = XCBuildConfiguration; buildSettings = { + COMBINE_HIDPI_IMAGES = YES; PRODUCT_NAME = "$(TARGET_NAME)"; }; name = Release; @@ -5408,6 +5430,7 @@ B6E69C03166BDD18005EF4B1 /* Profiling */ = { isa = XCBuildConfiguration; buildSettings = { + COMBINE_HIDPI_IMAGES = YES; PRODUCT_NAME = "$(TARGET_NAME)"; }; name = Profiling; @@ -5415,6 +5438,7 @@ B6E69C04166BDD18005EF4B1 /* Production */ = { isa = XCBuildConfiguration; buildSettings = { + COMBINE_HIDPI_IMAGES = YES; PRODUCT_NAME = "$(TARGET_NAME)"; }; name = Production; From 88d519846e24c2d41a4d49e8656a214d78114450 Mon Sep 17 00:00:00 2001 From: Dominic Szablewski Date: Sat, 22 Dec 2012 19:52:16 +0100 Subject: [PATCH 22/30] Added API for ArrayBuffer --- JavaScriptCore/API/JSTypedArray.cpp | 33 +++++++++++++++++++++++------ JavaScriptCore/API/JSTypedArray.h | 3 ++- 2 files changed, 29 insertions(+), 7 deletions(-) diff --git a/JavaScriptCore/API/JSTypedArray.cpp b/JavaScriptCore/API/JSTypedArray.cpp index bd72eabf..89014f94 100644 --- a/JavaScriptCore/API/JSTypedArray.cpp +++ b/JavaScriptCore/API/JSTypedArray.cpp @@ -36,10 +36,11 @@ const JSTypedArrayType TypedArrayTypes[] = { [TypedArrayUint16] = kJSTypedArrayTypeUint16Array, [TypedArrayUint32] = kJSTypedArrayTypeUint32Array, [TypedArrayFloat32] = kJSTypedArrayTypeFloat32Array, - [TypedArrayFloat64] = kJSTypedArrayTypeFloat64Array + [TypedArrayFloat64] = kJSTypedArrayTypeFloat64Array, + /* not a TypedArray */ kJSTypedArrayTypeArrayBuffer }; -const int kJSTypedArrayTypeLast = kJSTypedArrayTypeFloat64Array; +const int kJSTypedArrayTypeLast = kJSTypedArrayTypeArrayBuffer; template JSObject * CreateTypedArray(JSC::ExecState* exec, size_t length) { @@ -50,6 +51,14 @@ template JSObject * CreateTypedArray(JSC::ExecState* exec, s return asObject(toJS(exec, exec->lexicalGlobalObject(), array.get())); } +template JSObject * CreateArrayBuffer(JSC::ExecState* exec, size_t length) { + RefPtr array = BufferType::create(length, 1); + if( !array.get() ) { + return NULL; + } + return asObject(toJS(exec, exec->lexicalGlobalObject(), array.get())); +} + typedef JSObject*(*CreateTypedArrayFuncPtr)(JSC::ExecState*, size_t); const CreateTypedArrayFuncPtr CreateTypedArrayFunc[] = { [kJSTypedArrayTypeNone] = NULL, @@ -61,7 +70,8 @@ const CreateTypedArrayFuncPtr CreateTypedArrayFunc[] = { [kJSTypedArrayTypeUint16Array] = CreateTypedArray, [kJSTypedArrayTypeUint32Array] = CreateTypedArray, [kJSTypedArrayTypeFloat32Array] = CreateTypedArray, - [kJSTypedArrayTypeFloat64Array] = CreateTypedArray + [kJSTypedArrayTypeFloat64Array] = CreateTypedArray, + [kJSTypedArrayTypeArrayBuffer] = CreateArrayBuffer, }; @@ -72,10 +82,15 @@ JSTypedArrayType JSTypedArrayGetType(JSContextRef ctx, JSValueRef value) { APIEntryShim entryShim(exec); JSValue jsValue = toJS(exec, value); - if( JSObject* object = jsValue.getObject() ) { - return TypedArrayTypes[object->classInfo()->typedArrayStorageType]; + JSTypedArrayType type = kJSTypedArrayTypeNone; + if( jsValue.inherits(&JSArrayBufferView::s_info) ) { + JSObject* object = jsValue.getObject(); + type = TypedArrayTypes[object->classInfo()->typedArrayStorageType]; + } + else if( jsValue.inherits(&JSArrayBuffer::s_info) ) { + type = kJSTypedArrayTypeArrayBuffer; } - return kJSTypedArrayTypeNone; + return type; } JSObjectRef JSTypedArrayMake(JSContextRef ctx, JSTypedArrayType arrayType, size_t numElements) { @@ -101,6 +116,12 @@ void * JSTypedArrayGetDataPtr(JSContextRef ctx, JSValueRef value, size_t * byteL } return view->baseAddress(); } + else if( ArrayBuffer * buffer = toArrayBuffer(jsValue) ) { + if( byteLength ) { + *byteLength = buffer->byteLength(); + } + return buffer->data(); + } if( byteLength ) { *byteLength = 0; diff --git a/JavaScriptCore/API/JSTypedArray.h b/JavaScriptCore/API/JSTypedArray.h index 16ee6a76..20a34f18 100644 --- a/JavaScriptCore/API/JSTypedArray.h +++ b/JavaScriptCore/API/JSTypedArray.h @@ -31,7 +31,8 @@ typedef enum { kJSTypedArrayTypeUint16Array, kJSTypedArrayTypeUint32Array, kJSTypedArrayTypeFloat32Array, - kJSTypedArrayTypeFloat64Array + kJSTypedArrayTypeFloat64Array, + kJSTypedArrayTypeArrayBuffer } JSTypedArrayType; /*! From 51e15049eb425e09efb8ff33770e5c0beddd4ec0 Mon Sep 17 00:00:00 2001 From: Dominic Szablewski Date: Sat, 29 Dec 2012 15:13:05 +0100 Subject: [PATCH 23/30] Updated comments for ArrayBuffer API --- JavaScriptCore/API/JSTypedArray.h | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/JavaScriptCore/API/JSTypedArray.h b/JavaScriptCore/API/JSTypedArray.h index 20a34f18..ea7f30a6 100644 --- a/JavaScriptCore/API/JSTypedArray.h +++ b/JavaScriptCore/API/JSTypedArray.h @@ -20,6 +20,7 @@ extern "C" { @constant kJSTypedArrayTypeUint32Array Uint32Array @constant kJSTypedArrayTypeFloat32Array Float32Array @constant kJSTypedArrayTypeFloat64Array Float64Array +@constant kJSTypedArrayTypeArrayBuffer ArrayBuffer */ typedef enum { kJSTypedArrayTypeNone, @@ -48,7 +49,7 @@ JS_EXPORT JSTypedArrayType JSTypedArrayGetType(JSContextRef ctx, JSValueRef valu @function @abstract Creates a JavaScript Typed Array with the given number of elements @param ctx The execution context to use. -@param arrayClass A value of type JSTypedArrayType identifying the type of array you want to create +@param arrayType A value of type JSTypedArrayType identifying the type of array you want to create @param numElements The number of elements for the array. @result A JSObjectRef that is a Typed Array or NULL if there was an error */ From ad14fcef10bcea1859b52efd78cc4990b63b824e Mon Sep 17 00:00:00 2001 From: Dominic Szablewski Date: Sat, 29 Dec 2012 15:13:50 +0100 Subject: [PATCH 24/30] Fixed Uint32Array constructor creating a Float32Array --- JavaScriptCore/runtime/JSGlobalObject.cpp | 5 +---- 1 file changed, 1 insertion(+), 4 deletions(-) diff --git a/JavaScriptCore/runtime/JSGlobalObject.cpp b/JavaScriptCore/runtime/JSGlobalObject.cpp index 93884e5c..4b08aeca 100644 --- a/JavaScriptCore/runtime/JSGlobalObject.cpp +++ b/JavaScriptCore/runtime/JSGlobalObject.cpp @@ -312,9 +312,6 @@ void JSGlobalObject::reset(JSValue prototype) putDirectWithoutTransition(exec->globalData(), Identifier(exec, WebCore::JSFloat32Array::s_info.className), WebCore::JSFloat32Array::getConstructor(exec, this), DontEnum); - putDirectWithoutTransition(exec->globalData(), Identifier(exec, WebCore::JSFloat32Array::s_info.className), - WebCore::JSFloat32Array::getConstructor(exec, this), DontEnum); - putDirectWithoutTransition(exec->globalData(), Identifier(exec, WebCore::JSFloat64Array::s_info.className), WebCore::JSFloat64Array::getConstructor(exec, this), DontEnum); @@ -337,7 +334,7 @@ void JSGlobalObject::reset(JSValue prototype) WebCore::JSUint16Array::getConstructor(exec, this), DontEnum); putDirectWithoutTransition(exec->globalData(), Identifier(exec, WebCore::JSUint32Array::s_info.className), - WebCore::JSFloat32Array::getConstructor(exec, this), DontEnum); + WebCore::JSUint32Array::getConstructor(exec, this), DontEnum); m_evalFunction.set(exec->globalData(), this, JSFunction::create(exec, this, 1, exec->propertyNames().eval, globalFuncEval)); From f3eb0a16167588e9e111acd307c316345cd75df8 Mon Sep 17 00:00:00 2001 From: Dominic Szablewski Date: Sat, 29 Dec 2012 17:37:31 +0100 Subject: [PATCH 25/30] Fixed TypedArray.BYTES_PER_ELEMENT to be value instead of function --- JavaScriptCore/runtime/TypedArrays/JSArrayBuffer.cpp | 4 ++-- JavaScriptCore/runtime/TypedArrays/JSFloat32Array.cpp | 4 ++-- JavaScriptCore/runtime/TypedArrays/JSFloat64Array.cpp | 4 ++-- JavaScriptCore/runtime/TypedArrays/JSInt16Array.cpp | 4 ++-- JavaScriptCore/runtime/TypedArrays/JSInt32Array.cpp | 4 ++-- JavaScriptCore/runtime/TypedArrays/JSInt8Array.cpp | 4 ++-- JavaScriptCore/runtime/TypedArrays/JSUint16Array.cpp | 4 ++-- JavaScriptCore/runtime/TypedArrays/JSUint32Array.cpp | 4 ++-- JavaScriptCore/runtime/TypedArrays/JSUint8Array.cpp | 4 ++-- JavaScriptCore/runtime/TypedArrays/JSUint8ClampedArray.cpp | 4 ++-- 10 files changed, 20 insertions(+), 20 deletions(-) diff --git a/JavaScriptCore/runtime/TypedArrays/JSArrayBuffer.cpp b/JavaScriptCore/runtime/TypedArrays/JSArrayBuffer.cpp index 1d17bc45..7f5452d1 100644 --- a/JavaScriptCore/runtime/TypedArrays/JSArrayBuffer.cpp +++ b/JavaScriptCore/runtime/TypedArrays/JSArrayBuffer.cpp @@ -71,12 +71,12 @@ void JSArrayBufferConstructor::finishCreation(ExecState* exec, JSGlobalObject* g bool JSArrayBufferConstructor::getOwnPropertySlot(JSCell* cell, ExecState* exec, const Identifier& propertyName, PropertySlot& slot) { - return getStaticFunctionSlot(exec, &JSArrayBufferConstructorTable, jsCast(cell), propertyName, slot); + return getStaticValueSlot(exec, &JSArrayBufferConstructorTable, jsCast(cell), propertyName, slot); } bool JSArrayBufferConstructor::getOwnPropertyDescriptor(JSObject* object, ExecState* exec, const Identifier& propertyName, PropertyDescriptor& descriptor) { - return getStaticFunctionDescriptor(exec, &JSArrayBufferConstructorTable, jsCast(object), propertyName, descriptor); + return getStaticValueDescriptor(exec, &JSArrayBufferConstructorTable, jsCast(object), propertyName, descriptor); } ConstructType JSArrayBufferConstructor::getConstructData(JSCell*, ConstructData& constructData) diff --git a/JavaScriptCore/runtime/TypedArrays/JSFloat32Array.cpp b/JavaScriptCore/runtime/TypedArrays/JSFloat32Array.cpp index 4117a307..08e360d9 100644 --- a/JavaScriptCore/runtime/TypedArrays/JSFloat32Array.cpp +++ b/JavaScriptCore/runtime/TypedArrays/JSFloat32Array.cpp @@ -72,12 +72,12 @@ void JSFloat32ArrayConstructor::finishCreation(ExecState* exec, JSGlobalObject* bool JSFloat32ArrayConstructor::getOwnPropertySlot(JSCell* cell, ExecState* exec, const Identifier& propertyName, PropertySlot& slot) { - return getStaticFunctionSlot(exec, &JSFloat32ArrayConstructorTable, jsCast(cell), propertyName, slot); + return getStaticValueSlot(exec, &JSFloat32ArrayConstructorTable, jsCast(cell), propertyName, slot); } bool JSFloat32ArrayConstructor::getOwnPropertyDescriptor(JSObject* object, ExecState* exec, const Identifier& propertyName, PropertyDescriptor& descriptor) { - return getStaticFunctionDescriptor(exec, &JSFloat32ArrayConstructorTable, jsCast(object), propertyName, descriptor); + return getStaticValueDescriptor(exec, &JSFloat32ArrayConstructorTable, jsCast(object), propertyName, descriptor); } ConstructType JSFloat32ArrayConstructor::getConstructData(JSCell*, ConstructData& constructData) diff --git a/JavaScriptCore/runtime/TypedArrays/JSFloat64Array.cpp b/JavaScriptCore/runtime/TypedArrays/JSFloat64Array.cpp index f3c3f3be..b449eccf 100644 --- a/JavaScriptCore/runtime/TypedArrays/JSFloat64Array.cpp +++ b/JavaScriptCore/runtime/TypedArrays/JSFloat64Array.cpp @@ -72,12 +72,12 @@ void JSFloat64ArrayConstructor::finishCreation(ExecState* exec, JSC::JSGlobalObj bool JSFloat64ArrayConstructor::getOwnPropertySlot(JSCell* cell, ExecState* exec, const Identifier& propertyName, PropertySlot& slot) { - return getStaticFunctionSlot(exec, &JSFloat64ArrayConstructorTable, jsCast(cell), propertyName, slot); + return getStaticValueSlot(exec, &JSFloat64ArrayConstructorTable, jsCast(cell), propertyName, slot); } bool JSFloat64ArrayConstructor::getOwnPropertyDescriptor(JSObject* object, ExecState* exec, const Identifier& propertyName, PropertyDescriptor& descriptor) { - return getStaticFunctionDescriptor(exec, &JSFloat64ArrayConstructorTable, jsCast(object), propertyName, descriptor); + return getStaticValueDescriptor(exec, &JSFloat64ArrayConstructorTable, jsCast(object), propertyName, descriptor); } ConstructType JSFloat64ArrayConstructor::getConstructData(JSCell*, ConstructData& constructData) diff --git a/JavaScriptCore/runtime/TypedArrays/JSInt16Array.cpp b/JavaScriptCore/runtime/TypedArrays/JSInt16Array.cpp index bc21ec7c..3f1d0162 100644 --- a/JavaScriptCore/runtime/TypedArrays/JSInt16Array.cpp +++ b/JavaScriptCore/runtime/TypedArrays/JSInt16Array.cpp @@ -72,12 +72,12 @@ void JSInt16ArrayConstructor::finishCreation(ExecState* exec, JSGlobalObject* gl bool JSInt16ArrayConstructor::getOwnPropertySlot(JSCell* cell, ExecState* exec, const Identifier& propertyName, PropertySlot& slot) { - return getStaticFunctionSlot(exec, &JSInt16ArrayConstructorTable, jsCast(cell), propertyName, slot); + return getStaticValueSlot(exec, &JSInt16ArrayConstructorTable, jsCast(cell), propertyName, slot); } bool JSInt16ArrayConstructor::getOwnPropertyDescriptor(JSObject* object, ExecState* exec, const Identifier& propertyName, PropertyDescriptor& descriptor) { - return getStaticFunctionDescriptor(exec, &JSInt16ArrayConstructorTable, jsCast(object), propertyName, descriptor); + return getStaticValueDescriptor(exec, &JSInt16ArrayConstructorTable, jsCast(object), propertyName, descriptor); } ConstructType JSInt16ArrayConstructor::getConstructData(JSCell*, ConstructData& constructData) diff --git a/JavaScriptCore/runtime/TypedArrays/JSInt32Array.cpp b/JavaScriptCore/runtime/TypedArrays/JSInt32Array.cpp index ee908966..b6c3bea3 100644 --- a/JavaScriptCore/runtime/TypedArrays/JSInt32Array.cpp +++ b/JavaScriptCore/runtime/TypedArrays/JSInt32Array.cpp @@ -72,12 +72,12 @@ void JSInt32ArrayConstructor::finishCreation(ExecState* exec, JSGlobalObject* gl bool JSInt32ArrayConstructor::getOwnPropertySlot(JSCell* cell, ExecState* exec, const Identifier& propertyName, PropertySlot& slot) { - return getStaticFunctionSlot(exec, &JSInt32ArrayConstructorTable, jsCast(cell), propertyName, slot); + return getStaticValueSlot(exec, &JSInt32ArrayConstructorTable, jsCast(cell), propertyName, slot); } bool JSInt32ArrayConstructor::getOwnPropertyDescriptor(JSObject* object, ExecState* exec, const Identifier& propertyName, PropertyDescriptor& descriptor) { - return getStaticFunctionDescriptor(exec, &JSInt32ArrayConstructorTable, jsCast(object), propertyName, descriptor); + return getStaticValueDescriptor(exec, &JSInt32ArrayConstructorTable, jsCast(object), propertyName, descriptor); } ConstructType JSInt32ArrayConstructor::getConstructData(JSCell*, ConstructData& constructData) diff --git a/JavaScriptCore/runtime/TypedArrays/JSInt8Array.cpp b/JavaScriptCore/runtime/TypedArrays/JSInt8Array.cpp index eff327f4..e0fb24bc 100644 --- a/JavaScriptCore/runtime/TypedArrays/JSInt8Array.cpp +++ b/JavaScriptCore/runtime/TypedArrays/JSInt8Array.cpp @@ -72,12 +72,12 @@ void JSInt8ArrayConstructor::finishCreation(ExecState* exec, JSGlobalObject* glo bool JSInt8ArrayConstructor::getOwnPropertySlot(JSCell* cell, ExecState* exec, const Identifier& propertyName, PropertySlot& slot) { - return getStaticFunctionSlot(exec, &JSInt8ArrayConstructorTable, jsCast(cell), propertyName, slot); + return getStaticValueSlot(exec, &JSInt8ArrayConstructorTable, jsCast(cell), propertyName, slot); } bool JSInt8ArrayConstructor::getOwnPropertyDescriptor(JSObject* object, ExecState* exec, const Identifier& propertyName, PropertyDescriptor& descriptor) { - return getStaticFunctionDescriptor(exec, &JSInt8ArrayConstructorTable, jsCast(object), propertyName, descriptor); + return getStaticValueDescriptor(exec, &JSInt8ArrayConstructorTable, jsCast(object), propertyName, descriptor); } ConstructType JSInt8ArrayConstructor::getConstructData(JSCell*, ConstructData& constructData) diff --git a/JavaScriptCore/runtime/TypedArrays/JSUint16Array.cpp b/JavaScriptCore/runtime/TypedArrays/JSUint16Array.cpp index 2ffbcb2d..dafb6429 100644 --- a/JavaScriptCore/runtime/TypedArrays/JSUint16Array.cpp +++ b/JavaScriptCore/runtime/TypedArrays/JSUint16Array.cpp @@ -72,12 +72,12 @@ void JSUint16ArrayConstructor::finishCreation(ExecState* exec, JSGlobalObject* g bool JSUint16ArrayConstructor::getOwnPropertySlot(JSCell* cell, ExecState* exec, const Identifier& propertyName, PropertySlot& slot) { - return getStaticFunctionSlot(exec, &JSUint16ArrayConstructorTable, jsCast(cell), propertyName, slot); + return getStaticValueSlot(exec, &JSUint16ArrayConstructorTable, jsCast(cell), propertyName, slot); } bool JSUint16ArrayConstructor::getOwnPropertyDescriptor(JSObject* object, ExecState* exec, const Identifier& propertyName, PropertyDescriptor& descriptor) { - return getStaticFunctionDescriptor(exec, &JSUint16ArrayConstructorTable, jsCast(object), propertyName, descriptor); + return getStaticValueDescriptor(exec, &JSUint16ArrayConstructorTable, jsCast(object), propertyName, descriptor); } ConstructType JSUint16ArrayConstructor::getConstructData(JSCell*, ConstructData& constructData) diff --git a/JavaScriptCore/runtime/TypedArrays/JSUint32Array.cpp b/JavaScriptCore/runtime/TypedArrays/JSUint32Array.cpp index 252fbf1c..235b1292 100644 --- a/JavaScriptCore/runtime/TypedArrays/JSUint32Array.cpp +++ b/JavaScriptCore/runtime/TypedArrays/JSUint32Array.cpp @@ -72,12 +72,12 @@ void JSUint32ArrayConstructor::finishCreation(ExecState* exec, JSGlobalObject* g bool JSUint32ArrayConstructor::getOwnPropertySlot(JSCell* cell, ExecState* exec, const Identifier& propertyName, PropertySlot& slot) { - return getStaticFunctionSlot(exec, &JSUint32ArrayConstructorTable, jsCast(cell), propertyName, slot); + return getStaticValueSlot(exec, &JSUint32ArrayConstructorTable, jsCast(cell), propertyName, slot); } bool JSUint32ArrayConstructor::getOwnPropertyDescriptor(JSObject* object, ExecState* exec, const Identifier& propertyName, PropertyDescriptor& descriptor) { - return getStaticFunctionDescriptor(exec, &JSUint32ArrayConstructorTable, jsCast(object), propertyName, descriptor); + return getStaticValueDescriptor(exec, &JSUint32ArrayConstructorTable, jsCast(object), propertyName, descriptor); } ConstructType JSUint32ArrayConstructor::getConstructData(JSCell*, ConstructData& constructData) diff --git a/JavaScriptCore/runtime/TypedArrays/JSUint8Array.cpp b/JavaScriptCore/runtime/TypedArrays/JSUint8Array.cpp index 180c4348..fcb418d2 100644 --- a/JavaScriptCore/runtime/TypedArrays/JSUint8Array.cpp +++ b/JavaScriptCore/runtime/TypedArrays/JSUint8Array.cpp @@ -72,12 +72,12 @@ void JSUint8ArrayConstructor::finishCreation(ExecState* exec, JSGlobalObject* gl bool JSUint8ArrayConstructor::getOwnPropertySlot(JSCell* cell, ExecState* exec, const Identifier& propertyName, PropertySlot& slot) { - return getStaticFunctionSlot(exec, &JSUint8ArrayConstructorTable, jsCast(cell), propertyName, slot); + return getStaticValueSlot(exec, &JSUint8ArrayConstructorTable, jsCast(cell), propertyName, slot); } bool JSUint8ArrayConstructor::getOwnPropertyDescriptor(JSObject* object, ExecState* exec, const Identifier& propertyName, PropertyDescriptor& descriptor) { - return getStaticFunctionDescriptor(exec, &JSUint8ArrayConstructorTable, jsCast(object), propertyName, descriptor); + return getStaticValueDescriptor(exec, &JSUint8ArrayConstructorTable, jsCast(object), propertyName, descriptor); } ConstructType JSUint8ArrayConstructor::getConstructData(JSCell*, ConstructData& constructData) diff --git a/JavaScriptCore/runtime/TypedArrays/JSUint8ClampedArray.cpp b/JavaScriptCore/runtime/TypedArrays/JSUint8ClampedArray.cpp index 2f90bd5c..a96c574f 100644 --- a/JavaScriptCore/runtime/TypedArrays/JSUint8ClampedArray.cpp +++ b/JavaScriptCore/runtime/TypedArrays/JSUint8ClampedArray.cpp @@ -72,12 +72,12 @@ void JSUint8ClampedArrayConstructor::finishCreation(ExecState* exec, JSGlobalObj bool JSUint8ClampedArrayConstructor::getOwnPropertySlot(JSCell* cell, ExecState* exec, const Identifier& propertyName, PropertySlot& slot) { - return getStaticFunctionSlot(exec, &JSUint8ClampedArrayConstructorTable, jsCast(cell), propertyName, slot); + return getStaticValueSlot(exec, &JSUint8ClampedArrayConstructorTable, jsCast(cell), propertyName, slot); } bool JSUint8ClampedArrayConstructor::getOwnPropertyDescriptor(JSObject* object, ExecState* exec, const Identifier& propertyName, PropertyDescriptor& descriptor) { - return getStaticFunctionDescriptor(exec, &JSUint8ClampedArrayConstructorTable, jsCast(object), propertyName, descriptor); + return getStaticValueDescriptor(exec, &JSUint8ClampedArrayConstructorTable, jsCast(object), propertyName, descriptor); } ConstructType JSUint8ClampedArrayConstructor::getConstructData(JSCell*, ConstructData& constructData) From 2573cbcd68f0c4129bef943a2c3e2fa6bd1e06f8 Mon Sep 17 00:00:00 2001 From: Dominic Szablewski Date: Sat, 5 Jan 2013 23:50:07 +0100 Subject: [PATCH 26/30] Use DBL_MIN as Number.MIN_VALUE if denormal numbers are not available --- JavaScriptCore/runtime/NumberConstructor.cpp | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/JavaScriptCore/runtime/NumberConstructor.cpp b/JavaScriptCore/runtime/NumberConstructor.cpp index e1ff62f3..9b2c9f50 100644 --- a/JavaScriptCore/runtime/NumberConstructor.cpp +++ b/JavaScriptCore/runtime/NumberConstructor.cpp @@ -61,6 +61,8 @@ NumberConstructor::NumberConstructor(JSGlobalObject* globalObject, Structure* st { } +static double MinValueAccountingForDenormals = DBL_MIN; + void NumberConstructor::finishCreation(ExecState* exec, NumberPrototype* numberPrototype) { Base::finishCreation(exec->globalData(), Identifier(exec, numberPrototype->s_info.className)); @@ -71,6 +73,14 @@ void NumberConstructor::finishCreation(ExecState* exec, NumberPrototype* numberP // no. of arguments for constructor putDirectWithoutTransition(exec->globalData(), exec->propertyNames().length, jsNumber(1), ReadOnly | DontEnum | DontDelete); + + // Test for denormal support. Use 5E-324 as MIN_VALUE if we have denormals + // Careful: this test gets easily optimized away by the compiler, hence + // the assignment to another var. + double denormalTest = MinValueAccountingForDenormals / 2; + if( denormalTest != 0 ) { + MinValueAccountingForDenormals = 5E-324; + } } bool NumberConstructor::getOwnPropertySlot(JSCell* cell, ExecState* exec, const Identifier& propertyName, PropertySlot& slot) @@ -110,7 +120,7 @@ static JSValue numberConstructorMaxValue(ExecState*, JSValue, const Identifier&) static JSValue numberConstructorMinValue(ExecState*, JSValue, const Identifier&) { - return jsNumber(5E-324); + return jsNumber(MinValueAccountingForDenormals); } // ECMA 15.7.1 From fc39bbdd403c61d90cf438ce09c100b6e3e5837c Mon Sep 17 00:00:00 2001 From: Dominic Szablewski Date: Mon, 18 Feb 2013 00:14:08 +0100 Subject: [PATCH 27/30] Disable "treat warnings as errors"; new xcode version is quite strict --- JavaScriptCore/JavaScriptCore.xcodeproj/project.pbxproj | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/JavaScriptCore/JavaScriptCore.xcodeproj/project.pbxproj b/JavaScriptCore/JavaScriptCore.xcodeproj/project.pbxproj index d78e9f74..bec8b304 100644 --- a/JavaScriptCore/JavaScriptCore.xcodeproj/project.pbxproj +++ b/JavaScriptCore/JavaScriptCore.xcodeproj/project.pbxproj @@ -4981,6 +4981,7 @@ DEAD_CODE_STRIPPING = "$(DEAD_CODE_STRIPPING_debug)"; DEBUG_DEFINES = "$(DEBUG_DEFINES_debug)"; GCC_OPTIMIZATION_LEVEL = "$(GCC_OPTIMIZATION_LEVEL_debug)"; + GCC_TREAT_WARNINGS_AS_ERRORS = NO; STRIP_INSTALLED_PRODUCT = "$(STRIP_INSTALLED_PRODUCT_debug)"; }; name = Debug; @@ -4989,6 +4990,7 @@ isa = XCBuildConfiguration; baseConfigurationReference = 1C9051440BA9E8A70081E9D0 /* DebugRelease.xcconfig */; buildSettings = { + GCC_TREAT_WARNINGS_AS_ERRORS = NO; STRIP_INSTALLED_PRODUCT = NO; }; name = Release; @@ -4997,6 +4999,7 @@ isa = XCBuildConfiguration; baseConfigurationReference = 1C9051450BA9E8A70081E9D0 /* Base.xcconfig */; buildSettings = { + GCC_TREAT_WARNINGS_AS_ERRORS = NO; }; name = Production; }; @@ -5109,6 +5112,7 @@ isa = XCBuildConfiguration; baseConfigurationReference = 1C9051440BA9E8A70081E9D0 /* DebugRelease.xcconfig */; buildSettings = { + GCC_TREAT_WARNINGS_AS_ERRORS = NO; STRIP_INSTALLED_PRODUCT = NO; }; name = Profiling; From 2a7b2b55046a4d9e88865da79292d451a0df75a4 Mon Sep 17 00:00:00 2001 From: Dominic Szablewski Date: Mon, 18 Feb 2013 00:16:36 +0100 Subject: [PATCH 28/30] Fixed memory leaks and crashes related to global TypedArra constructors and prototypes --- .../JavaScriptCore.xcodeproj/project.pbxproj | 12 +++++ JavaScriptCore/runtime/JSGlobalData.h | 5 ++ JavaScriptCore/runtime/JSGlobalObject.h | 5 ++ .../runtime/TypedArrays/GlobalDataHelper.h | 41 +++++++++-------- .../runtime/TypedArrays/JSArrayBuffer.cpp | 9 +--- .../runtime/TypedArrays/JSArrayBufferView.cpp | 3 +- .../TypedArrays/TypedArrayHashTableMap.cpp | 41 +++++++++++++++++ .../TypedArrays/TypedArrayHashTableMap.h | 46 +++++++++++++++++++ 8 files changed, 133 insertions(+), 29 deletions(-) create mode 100644 JavaScriptCore/runtime/TypedArrays/TypedArrayHashTableMap.cpp create mode 100644 JavaScriptCore/runtime/TypedArrays/TypedArrayHashTableMap.h diff --git a/JavaScriptCore/JavaScriptCore.xcodeproj/project.pbxproj b/JavaScriptCore/JavaScriptCore.xcodeproj/project.pbxproj index bec8b304..470a7c40 100644 --- a/JavaScriptCore/JavaScriptCore.xcodeproj/project.pbxproj +++ b/JavaScriptCore/JavaScriptCore.xcodeproj/project.pbxproj @@ -557,6 +557,10 @@ B6D1888C1673751400D1037C /* GlobalDataHelper.h in Headers */ = {isa = PBXBuildFile; fileRef = B6D188881673751400D1037C /* GlobalDataHelper.h */; }; B6D1888E167381A400D1037C /* JSFloat32ArrayCustom.cpp in Sources */ = {isa = PBXBuildFile; fileRef = B6D1888D167381A300D1037C /* JSFloat32ArrayCustom.cpp */; }; B6D1888F167381A400D1037C /* JSFloat32ArrayCustom.cpp in Sources */ = {isa = PBXBuildFile; fileRef = B6D1888D167381A300D1037C /* JSFloat32ArrayCustom.cpp */; }; + B6E02BB916D1666300616925 /* TypedArrayHashTableMap.h in Headers */ = {isa = PBXBuildFile; fileRef = B6E02BB616D1666300616925 /* TypedArrayHashTableMap.h */; }; + B6E02BBA16D1666300616925 /* TypedArrayHashTableMap.h in Headers */ = {isa = PBXBuildFile; fileRef = B6E02BB616D1666300616925 /* TypedArrayHashTableMap.h */; }; + B6E02BBC16D17CC400616925 /* TypedArrayHashTableMap.cpp in Sources */ = {isa = PBXBuildFile; fileRef = B6E02BBB16D17CC400616925 /* TypedArrayHashTableMap.cpp */; }; + B6E02BBD16D17CC400616925 /* TypedArrayHashTableMap.cpp in Sources */ = {isa = PBXBuildFile; fileRef = B6E02BBB16D17CC400616925 /* TypedArrayHashTableMap.cpp */; }; B6E69991166BD63D005EF4B1 /* AbstractMacroAssembler.h in Headers */ = {isa = PBXBuildFile; fileRef = 860161DF0F3A83C100F84710 /* AbstractMacroAssembler.h */; }; B6E69992166BD63D005EF4B1 /* APICast.h in Headers */ = {isa = PBXBuildFile; fileRef = 1482B78A0A4305AB00517CFC /* APICast.h */; settings = {ATTRIBUTES = (Private, ); }; }; B6E69993166BD63D005EF4B1 /* APIShims.h in Headers */ = {isa = PBXBuildFile; fileRef = 865F408710E7D56300947361 /* APIShims.h */; settings = {ATTRIBUTES = (Private, ); }; }; @@ -1886,6 +1890,8 @@ B6D1886F1672DFE700D1037C /* JSFloat32Array.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = JSFloat32Array.h; sourceTree = ""; }; B6D188881673751400D1037C /* GlobalDataHelper.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = GlobalDataHelper.h; sourceTree = ""; }; B6D1888D167381A300D1037C /* JSFloat32ArrayCustom.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = JSFloat32ArrayCustom.cpp; sourceTree = ""; }; + B6E02BB616D1666300616925 /* TypedArrayHashTableMap.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = TypedArrayHashTableMap.h; sourceTree = ""; }; + B6E02BBB16D17CC400616925 /* TypedArrayHashTableMap.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = TypedArrayHashTableMap.cpp; sourceTree = ""; }; B6E69BC4166BD63D005EF4B1 /* libJavaScriptCore.a */ = {isa = PBXFileReference; explicitFileType = archive.ar; includeInIndex = 0; path = libJavaScriptCore.a; sourceTree = BUILT_PRODUCTS_DIR; }; B6E69BDB166BD6C1005EF4B1 /* libJSCLLIntOffsetsExtractor.a */ = {isa = PBXFileReference; explicitFileType = archive.ar; includeInIndex = 0; path = libJSCLLIntOffsetsExtractor.a; sourceTree = BUILT_PRODUCTS_DIR; }; B6E69BFD166BDCE7005EF4B1 /* libWTF.a */ = {isa = PBXFileReference; lastKnownFileType = archive.ar; name = libWTF.a; path = ../Build/libWTF.a; sourceTree = ""; }; @@ -2964,6 +2970,8 @@ isa = PBXGroup; children = ( B6D188881673751400D1037C /* GlobalDataHelper.h */, + B6E02BBB16D17CC400616925 /* TypedArrayHashTableMap.cpp */, + B6E02BB616D1666300616925 /* TypedArrayHashTableMap.h */, B6D18814166FA73400D1037C /* JSArrayBuffer.cpp */, B6D18815166FA73400D1037C /* JSArrayBuffer.h */, B6D18816166FA73400D1037C /* JSArrayBufferCustom.cpp */, @@ -3372,6 +3380,7 @@ B6F114B91673B116001F1324 /* JSUint16Array.h in Headers */, B6F114BF1673B116001F1324 /* JSUint32Array.h in Headers */, B6F114CA16755F98001F1324 /* JSTypedArray.h in Headers */, + B6E02BB916D1666300616925 /* TypedArrayHashTableMap.h in Headers */, ); runOnlyForDeploymentPostprocessing = 0; }; @@ -3731,6 +3740,7 @@ B6F114BA1673B116001F1324 /* JSUint16Array.h in Headers */, B6F114C01673B116001F1324 /* JSUint32Array.h in Headers */, B6F114CB16755F98001F1324 /* JSTypedArray.h in Headers */, + B6E02BBA16D1666300616925 /* TypedArrayHashTableMap.h in Headers */, ); runOnlyForDeploymentPostprocessing = 0; }; @@ -4498,6 +4508,7 @@ B6F114BD1673B116001F1324 /* JSUint32Array.cpp in Sources */, B6F114C11673B116001F1324 /* JSUint32ArrayCustom.cpp in Sources */, B6F114C816755F98001F1324 /* JSTypedArray.cpp in Sources */, + B6E02BBC16D17CC400616925 /* TypedArrayHashTableMap.cpp in Sources */, ); runOnlyForDeploymentPostprocessing = 0; }; @@ -4744,6 +4755,7 @@ B6F114BE1673B116001F1324 /* JSUint32Array.cpp in Sources */, B6F114C21673B116001F1324 /* JSUint32ArrayCustom.cpp in Sources */, B6F114C916755F98001F1324 /* JSTypedArray.cpp in Sources */, + B6E02BBD16D17CC400616925 /* TypedArrayHashTableMap.cpp in Sources */, ); runOnlyForDeploymentPostprocessing = 0; }; diff --git a/JavaScriptCore/runtime/JSGlobalData.h b/JavaScriptCore/runtime/JSGlobalData.h index d594e184..c593e06b 100644 --- a/JavaScriptCore/runtime/JSGlobalData.h +++ b/JavaScriptCore/runtime/JSGlobalData.h @@ -55,6 +55,8 @@ #include #endif +#include "TypedArrayHashTableMap.h" + struct OpaqueJSClass; struct OpaqueJSClassContextData; @@ -405,6 +407,9 @@ namespace JSC { registerTypedArrayFunction(float32, Float32); registerTypedArrayFunction(float64, Float64); #undef registerTypedArrayFunction + + WebCore::TypedArrayHashTableMap typedArrayHashTableMap; + JSLock& apiLock() { return m_apiLock; } diff --git a/JavaScriptCore/runtime/JSGlobalObject.h b/JavaScriptCore/runtime/JSGlobalObject.h index d9fc81dc..de9a138c 100644 --- a/JavaScriptCore/runtime/JSGlobalObject.h +++ b/JavaScriptCore/runtime/JSGlobalObject.h @@ -34,6 +34,8 @@ #include #include +#include "WriteBarrier.h" + namespace JSC { class ArrayPrototype; @@ -167,6 +169,9 @@ namespace JSC { } static JS_EXPORTDATA const ClassInfo s_info; + + HashMap > typedArrayConstructorMap; + HashMap > typedArrayPrototypeMap; protected: explicit JSGlobalObject(JSGlobalData& globalData, Structure* structure, const GlobalObjectMethodTable* globalObjectMethodTable = 0) diff --git a/JavaScriptCore/runtime/TypedArrays/GlobalDataHelper.h b/JavaScriptCore/runtime/TypedArrays/GlobalDataHelper.h index 1db4ae37..6bd8f686 100644 --- a/JavaScriptCore/runtime/TypedArrays/GlobalDataHelper.h +++ b/JavaScriptCore/runtime/TypedArrays/GlobalDataHelper.h @@ -23,37 +23,38 @@ enum ParameterDefaultPolicy { #define MAYBE_MISSING_PARAMETER(exec, index, policy) (((policy) == DefaultIsNullString && (index) >= (exec)->argumentCount()) ? (JSValue()) : ((exec)->argument(index))) static inline const JSC::HashTable* getHashTableForGlobalData(JSC::JSGlobalData& globalData, const JSC::HashTable* staticTable) { - ASSERT_UNUSED(&globalData, &globalData); - // PL FIXME: this should return a copy per globalData. I think. - return staticTable; + return globalData.typedArrayHashTableMap.get(staticTable); } - template -static inline JSC::JSObject* getDOMConstructor(JSC::ExecState* exec, JSC::JSGlobalObject* globalObject) +inline JSC::JSObject* getDOMConstructor(JSC::ExecState* exec, JSC::JSGlobalObject* globalObject) { - static ConstructorClass * globalConstructor; - if( !globalConstructor ) { - globalConstructor = ConstructorClass::create(exec, ConstructorClass::createStructure(exec->globalData(), globalObject, globalObject->objectPrototype()), globalObject); - } - return (JSC::JSObject *)globalConstructor; + if (JSC::JSObject* constructor = globalObject->typedArrayConstructorMap.get(&ConstructorClass::s_info).get()) + return constructor; + + JSC::JSObject* constructor = ConstructorClass::create(exec, ConstructorClass::createStructure(exec->globalData(), globalObject, globalObject->objectPrototype()), globalObject); + + ASSERT(!globalObject->typedArrayConstructorMap.contains(&ConstructorClass::s_info)); + JSC::WriteBarrier temp; + globalObject->typedArrayConstructorMap.add(&ConstructorClass::s_info, temp).iterator->second.set(exec->globalData(), globalObject, constructor); + return constructor; } - template -static inline JSC::JSObject* getDOMPrototype(JSC::ExecState* exec, JSC::JSGlobalObject* globalObject) +inline JSC::JSObject* getDOMPrototype(JSC::ExecState* exec, JSC::JSGlobalObject* globalObject) { - static PrototypeClass * globalPrototype; - if( !globalPrototype ) { - JSC::JSGlobalData &data = exec->globalData(); + if (JSC::JSObject* prototype = globalObject->typedArrayPrototypeMap.get(&PrototypeClass::s_info).get()) + return prototype; - globalPrototype = PrototypeClass::create(data, globalObject, - PrototypeClass::createStructure(data, globalObject, globalObject->objectPrototype())); - } - return (JSC::JSObject *)globalPrototype; + JSC::JSObject* prototype = PrototypeClass::create(exec->globalData(), globalObject, + PrototypeClass::createStructure(exec->globalData(), globalObject, globalObject->objectPrototype())); + + ASSERT(!globalObject->typedArrayPrototypeMap.contains(&PrototypeClass::s_info)); + JSC::WriteBarrier temp; + globalObject->typedArrayPrototypeMap.add(&PrototypeClass::s_info, temp).iterator->second.set(exec->globalData(), globalObject, prototype); + return prototype; } - } #endif /* defined(__JavaScriptCore__GlobalDataHelper__) */ diff --git a/JavaScriptCore/runtime/TypedArrays/JSArrayBuffer.cpp b/JavaScriptCore/runtime/TypedArrays/JSArrayBuffer.cpp index 7f5452d1..4810a3af 100644 --- a/JavaScriptCore/runtime/TypedArrays/JSArrayBuffer.cpp +++ b/JavaScriptCore/runtime/TypedArrays/JSArrayBuffer.cpp @@ -96,8 +96,7 @@ static const HashTableValue JSArrayBufferPrototypeTableValues[] = static const HashTable JSArrayBufferPrototypeTable = { 2, 1, JSArrayBufferPrototypeTableValues, 0 }; static const HashTable* getJSArrayBufferPrototypeTable(ExecState* exec) { - ASSERT_UNUSED(exec, exec); - return &JSArrayBufferPrototypeTable; // PL FIXME: should be one instance per global data, not super global + return getHashTableForGlobalData(exec->globalData(), &JSArrayBufferPrototypeTable); } const ClassInfo JSArrayBufferPrototype::s_info = { "ArrayBufferPrototype", &Base::s_info, 0, getJSArrayBufferPrototypeTable, CREATE_METHOD_TABLE(JSArrayBufferPrototype) }; @@ -105,11 +104,7 @@ const ClassInfo JSArrayBufferPrototype::s_info = { "ArrayBufferPrototype", &Base static JSObject * globalProto = NULL; JSObject* JSArrayBufferPrototype::self(ExecState* exec, JSGlobalObject* globalObject) { - // PL FIXME: dirty hack to provide one global prototype - if( !globalProto ) { - globalProto = JSArrayBuffer::createPrototype(exec, globalObject); - } - return globalProto; + return getDOMPrototype(exec, globalObject); } bool JSArrayBufferPrototype::getOwnPropertySlot(JSCell* cell, ExecState* exec, const Identifier& propertyName, PropertySlot& slot) diff --git a/JavaScriptCore/runtime/TypedArrays/JSArrayBufferView.cpp b/JavaScriptCore/runtime/TypedArrays/JSArrayBufferView.cpp index 0dd663aa..54deb723 100644 --- a/JavaScriptCore/runtime/TypedArrays/JSArrayBufferView.cpp +++ b/JavaScriptCore/runtime/TypedArrays/JSArrayBufferView.cpp @@ -55,8 +55,7 @@ static const HashTableValue JSArrayBufferViewPrototypeTableValues[] = static const HashTable JSArrayBufferViewPrototypeTable = { 1, 0, JSArrayBufferViewPrototypeTableValues, 0 }; static const HashTable* getJSArrayBufferViewPrototypeTable(ExecState* exec) { - ASSERT_UNUSED(exec, exec); - return &JSArrayBufferViewPrototypeTable; // PL FIXME: should be one instance per global data, not super global + return getHashTableForGlobalData(exec->globalData(), &JSArrayBufferViewPrototypeTable); } const ClassInfo JSArrayBufferViewPrototype::s_info = { "ArrayBufferViewPrototype", &Base::s_info, 0, getJSArrayBufferViewPrototypeTable, CREATE_METHOD_TABLE(JSArrayBufferViewPrototype) }; diff --git a/JavaScriptCore/runtime/TypedArrays/TypedArrayHashTableMap.cpp b/JavaScriptCore/runtime/TypedArrays/TypedArrayHashTableMap.cpp new file mode 100644 index 00000000..77c20207 --- /dev/null +++ b/JavaScriptCore/runtime/TypedArrays/TypedArrayHashTableMap.cpp @@ -0,0 +1,41 @@ +/* + * Copyright (C) 1999-2001 Harri Porten (porten@kde.org) + * Copyright (C) 2004, 2005, 2006, 2007, 2008, 2009 Apple Inc. All rights reserved. + * Copyright (C) 2007 Samuel Weinig + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser 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 + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA + */ + +#include "config.h" +#include "TypedArrayHashTableMap.h" +#include "Lookup.h" + +namespace WebCore{ + +TypedArrayHashTableMap::~TypedArrayHashTableMap() +{ + for (HashMap::iterator iter = m_map.begin(); iter != m_map.end(); ++iter) + iter->second.deleteTable(); +} + +const JSC::HashTable* TypedArrayHashTableMap::get(const JSC::HashTable* staticTable) +{ + HashMap::iterator iter = m_map.find(staticTable); + if (iter != m_map.end()) + return &iter->second; + return &m_map.set(staticTable, JSC::HashTable(*staticTable)).iterator->second; +} + +} // namespace WebCore diff --git a/JavaScriptCore/runtime/TypedArrays/TypedArrayHashTableMap.h b/JavaScriptCore/runtime/TypedArrays/TypedArrayHashTableMap.h new file mode 100644 index 00000000..9468a964 --- /dev/null +++ b/JavaScriptCore/runtime/TypedArrays/TypedArrayHashTableMap.h @@ -0,0 +1,46 @@ +/* + * Copyright (C) 1999-2001 Harri Porten (porten@kde.org) + * Copyright (C) 2003, 2004, 2005, 2006, 2008, 2009 Apple Inc. All rights reserved. + * Copyright (C) 2007 Samuel Weinig + * Copyright (C) 2009 Google, Inc. All rights reserved. + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser 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 + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA + */ + +#ifndef TypedArrayHashTableMap_h +#define TypedArrayHashTableMap_h + +#include + + +namespace JSC { +class JSGlobalData; +struct HashTable; +} + +namespace WebCore { + +// Map from static HashTable instances to per-GlobalData ones. +class TypedArrayHashTableMap { +public: + ~TypedArrayHashTableMap(); + const JSC::HashTable* get(const JSC::HashTable* staticTable); +private: + HashMap m_map; +}; + +} // namespace JSC + +#endif // TypedArrayHashTableMap_h From 41e47bc49beb90f5c434dd439116aa8f9dcf1190 Mon Sep 17 00:00:00 2001 From: Dominic Szablewski Date: Tue, 14 May 2013 10:13:00 +0200 Subject: [PATCH 29/30] Fix TypedArray prototype caching issues. Close #6 --- JavaScriptCore/runtime/JSGlobalObject.cpp | 14 +++++++++ JavaScriptCore/runtime/JSGlobalObject.h | 9 ++++-- .../runtime/TypedArrays/GlobalDataHelper.h | 31 ++++++++++++------- .../runtime/TypedArrays/JSArrayBuffer.cpp | 4 +-- .../runtime/TypedArrays/JSArrayBufferView.cpp | 2 +- .../TypedArrays/JSArrayBufferViewHelper.h | 4 +-- .../runtime/TypedArrays/JSFloat32Array.cpp | 2 +- .../runtime/TypedArrays/JSFloat64Array.cpp | 2 +- .../runtime/TypedArrays/JSInt16Array.cpp | 2 +- .../runtime/TypedArrays/JSInt32Array.cpp | 2 +- .../runtime/TypedArrays/JSInt8Array.cpp | 2 +- .../runtime/TypedArrays/JSUint16Array.cpp | 2 +- .../runtime/TypedArrays/JSUint32Array.cpp | 2 +- .../runtime/TypedArrays/JSUint8Array.cpp | 2 +- .../TypedArrays/JSUint8ClampedArray.cpp | 2 +- 15 files changed, 54 insertions(+), 28 deletions(-) diff --git a/JavaScriptCore/runtime/JSGlobalObject.cpp b/JavaScriptCore/runtime/JSGlobalObject.cpp index 4b08aeca..0e6f238b 100644 --- a/JavaScriptCore/runtime/JSGlobalObject.cpp +++ b/JavaScriptCore/runtime/JSGlobalObject.cpp @@ -425,6 +425,20 @@ void JSGlobalObject::visitChildren(JSCell* cell, SlotVisitor& visitor) visitIfNeeded(visitor, &thisObject->m_regExpStructure); visitIfNeeded(visitor, &thisObject->m_stringObjectStructure); visitIfNeeded(visitor, &thisObject->m_internalFunctionStructure); + + + // PL: Visit Typed Array Constructors + JSObjectMap::iterator cEnd = thisObject->typedArrayConstructorMap.end(); + for( JSObjectMap::iterator it = thisObject->typedArrayConstructorMap.begin(); it != cEnd; ++it ) { + visitIfNeeded(visitor, &it->second); + } + + // PL: Visit Typed Array Structures + JSStructureMap::iterator sEnd = thisObject->typedArrayStructureMap.end(); + for( JSStructureMap::iterator it = thisObject->typedArrayStructureMap.begin(); it != sEnd; ++it ) { + visitIfNeeded(visitor, &it->second); + } + if (thisObject->m_registerArray) { // Outside the execution of global code, when our variables are torn off, diff --git a/JavaScriptCore/runtime/JSGlobalObject.h b/JavaScriptCore/runtime/JSGlobalObject.h index de9a138c..19dc3594 100644 --- a/JavaScriptCore/runtime/JSGlobalObject.h +++ b/JavaScriptCore/runtime/JSGlobalObject.h @@ -169,9 +169,12 @@ namespace JSC { } static JS_EXPORTDATA const ClassInfo s_info; - - HashMap > typedArrayConstructorMap; - HashMap > typedArrayPrototypeMap; + + typedef HashMap > JSObjectMap; + typedef HashMap > JSStructureMap; + + JSObjectMap typedArrayConstructorMap; + JSStructureMap typedArrayStructureMap; protected: explicit JSGlobalObject(JSGlobalData& globalData, Structure* structure, const GlobalObjectMethodTable* globalObjectMethodTable = 0) diff --git a/JavaScriptCore/runtime/TypedArrays/GlobalDataHelper.h b/JavaScriptCore/runtime/TypedArrays/GlobalDataHelper.h index 6bd8f686..e0fbd3c3 100644 --- a/JavaScriptCore/runtime/TypedArrays/GlobalDataHelper.h +++ b/JavaScriptCore/runtime/TypedArrays/GlobalDataHelper.h @@ -40,19 +40,28 @@ inline JSC::JSObject* getDOMConstructor(JSC::ExecState* exec, JSC::JSGlobalObjec return constructor; } -template -inline JSC::JSObject* getDOMPrototype(JSC::ExecState* exec, JSC::JSGlobalObject* globalObject) +template +inline JSC::Structure* getDOMStructure(JSC::ExecState* exec, JSC::JSGlobalObject* globalObject) { - if (JSC::JSObject* prototype = globalObject->typedArrayPrototypeMap.get(&PrototypeClass::s_info).get()) - return prototype; - - JSC::JSObject* prototype = PrototypeClass::create(exec->globalData(), globalObject, - PrototypeClass::createStructure(exec->globalData(), globalObject, globalObject->objectPrototype())); + if (JSC::Structure* structure = globalObject->typedArrayStructureMap.get(&TypeClass::s_info).get()) { + return structure; + } - ASSERT(!globalObject->typedArrayPrototypeMap.contains(&PrototypeClass::s_info)); - JSC::WriteBarrier temp; - globalObject->typedArrayPrototypeMap.add(&PrototypeClass::s_info, temp).iterator->second.set(exec->globalData(), globalObject, prototype); - return prototype; + + JSC::JSObject * proto = TypeClass::createPrototype(exec, globalObject); + JSC::Structure *structure = TypeClass::createStructure(exec->globalData(), globalObject, proto); + + globalObject->typedArrayStructureMap.set( + &TypeClass::s_info, + JSC::WriteBarrier(globalObject->globalData(), globalObject, structure) + ); + return structure; +} + +template +inline JSC::JSObject* getDOMPrototype(JSC::ExecState* exec, JSC::JSGlobalObject* globalObject) +{ + return JSC::jsCast(asObject(getDOMStructure(exec, globalObject)->storedPrototype())); } } diff --git a/JavaScriptCore/runtime/TypedArrays/JSArrayBuffer.cpp b/JavaScriptCore/runtime/TypedArrays/JSArrayBuffer.cpp index 4810a3af..de3ea815 100644 --- a/JavaScriptCore/runtime/TypedArrays/JSArrayBuffer.cpp +++ b/JavaScriptCore/runtime/TypedArrays/JSArrayBuffer.cpp @@ -104,7 +104,7 @@ const ClassInfo JSArrayBufferPrototype::s_info = { "ArrayBufferPrototype", &Base static JSObject * globalProto = NULL; JSObject* JSArrayBufferPrototype::self(ExecState* exec, JSGlobalObject* globalObject) { - return getDOMPrototype(exec, globalObject); + return getDOMPrototype(exec, globalObject); } bool JSArrayBufferPrototype::getOwnPropertySlot(JSCell* cell, ExecState* exec, const Identifier& propertyName, PropertySlot& slot) @@ -244,7 +244,7 @@ void JSArrayBufferOwner::finalize(JSC::Handle handle, void* contex JSC::JSValue toJS(JSC::ExecState* exec, JSGlobalObject* globalObject, ArrayBuffer* impl) { - JSArrayBuffer * buf = JSArrayBuffer::create( JSArrayBuffer::createStructure(exec->globalData(), globalObject, JSArrayBufferPrototype::self(exec, globalObject)), globalObject, impl); + JSArrayBuffer * buf = JSArrayBuffer::create( getDOMStructure(exec, globalObject), globalObject, impl); JSC::JSCell* jsCell = reinterpret_cast(buf); return jsCell; } diff --git a/JavaScriptCore/runtime/TypedArrays/JSArrayBufferView.cpp b/JavaScriptCore/runtime/TypedArrays/JSArrayBufferView.cpp index 54deb723..5409ab19 100644 --- a/JavaScriptCore/runtime/TypedArrays/JSArrayBufferView.cpp +++ b/JavaScriptCore/runtime/TypedArrays/JSArrayBufferView.cpp @@ -63,7 +63,7 @@ const ClassInfo JSArrayBufferViewPrototype::s_info = { "ArrayBufferViewPrototype JSObject* JSArrayBufferViewPrototype::self(ExecState* exec, JSGlobalObject* globalObject) { - return getDOMPrototype(exec, globalObject); + return getDOMPrototype(exec, globalObject); } static const HashTable* getJSArrayBufferViewTable(ExecState* exec) diff --git a/JavaScriptCore/runtime/TypedArrays/JSArrayBufferViewHelper.h b/JavaScriptCore/runtime/TypedArrays/JSArrayBufferViewHelper.h index a46f90ba..ca5b44a4 100644 --- a/JavaScriptCore/runtime/TypedArrays/JSArrayBufferViewHelper.h +++ b/JavaScriptCore/runtime/TypedArrays/JSArrayBufferViewHelper.h @@ -34,6 +34,7 @@ #include #include #include +#include "GlobalDataHelper.h" namespace WebCore { @@ -167,8 +168,7 @@ static JSC::JSValue toJSArrayBufferView(JSC::ExecState* exec, JSC::JSGlobalObjec return JSC::jsNull(); exec->heap()->reportExtraMemoryCost(object->byteLength()); - JSC::JSCell * jsCell = JSType::create(JSType::createStructure(exec->globalData(), globalObject,JSType::createPrototype(exec, globalObject)), globalObject, object); - return jsCell; + return JSType::create(getDOMStructure(exec, globalObject), globalObject, object); } } // namespace WebCore diff --git a/JavaScriptCore/runtime/TypedArrays/JSFloat32Array.cpp b/JavaScriptCore/runtime/TypedArrays/JSFloat32Array.cpp index 08e360d9..956da6d8 100644 --- a/JavaScriptCore/runtime/TypedArrays/JSFloat32Array.cpp +++ b/JavaScriptCore/runtime/TypedArrays/JSFloat32Array.cpp @@ -106,7 +106,7 @@ const ClassInfo JSFloat32ArrayPrototype::s_info = { "Float32ArrayPrototype", &Ba JSObject* JSFloat32ArrayPrototype::self(ExecState* exec, JSGlobalObject* globalObject) { - return getDOMPrototype(exec, globalObject); + return getDOMPrototype(exec, globalObject); } bool JSFloat32ArrayPrototype::getOwnPropertySlot(JSCell* cell, ExecState* exec, const Identifier& propertyName, PropertySlot& slot) diff --git a/JavaScriptCore/runtime/TypedArrays/JSFloat64Array.cpp b/JavaScriptCore/runtime/TypedArrays/JSFloat64Array.cpp index b449eccf..0c94bb75 100644 --- a/JavaScriptCore/runtime/TypedArrays/JSFloat64Array.cpp +++ b/JavaScriptCore/runtime/TypedArrays/JSFloat64Array.cpp @@ -106,7 +106,7 @@ const ClassInfo JSFloat64ArrayPrototype::s_info = { "Float64ArrayPrototype", &Ba JSObject* JSFloat64ArrayPrototype::self(ExecState* exec, JSGlobalObject* globalObject) { - return getDOMPrototype(exec, globalObject); + return getDOMPrototype(exec, globalObject); } bool JSFloat64ArrayPrototype::getOwnPropertySlot(JSCell* cell, ExecState* exec, const Identifier& propertyName, PropertySlot& slot) diff --git a/JavaScriptCore/runtime/TypedArrays/JSInt16Array.cpp b/JavaScriptCore/runtime/TypedArrays/JSInt16Array.cpp index 3f1d0162..fa7d561b 100644 --- a/JavaScriptCore/runtime/TypedArrays/JSInt16Array.cpp +++ b/JavaScriptCore/runtime/TypedArrays/JSInt16Array.cpp @@ -106,7 +106,7 @@ const ClassInfo JSInt16ArrayPrototype::s_info = { "Int16ArrayPrototype", &Base:: JSObject* JSInt16ArrayPrototype::self(ExecState* exec, JSGlobalObject* globalObject) { - return getDOMPrototype(exec, globalObject); + return getDOMPrototype(exec, globalObject); } bool JSInt16ArrayPrototype::getOwnPropertySlot(JSCell* cell, ExecState* exec, const Identifier& propertyName, PropertySlot& slot) diff --git a/JavaScriptCore/runtime/TypedArrays/JSInt32Array.cpp b/JavaScriptCore/runtime/TypedArrays/JSInt32Array.cpp index b6c3bea3..fcb4a5ef 100644 --- a/JavaScriptCore/runtime/TypedArrays/JSInt32Array.cpp +++ b/JavaScriptCore/runtime/TypedArrays/JSInt32Array.cpp @@ -106,7 +106,7 @@ const ClassInfo JSInt32ArrayPrototype::s_info = { "Int32ArrayPrototype", &Base:: JSObject* JSInt32ArrayPrototype::self(ExecState* exec, JSGlobalObject* globalObject) { - return getDOMPrototype(exec, globalObject); + return getDOMPrototype(exec, globalObject); } bool JSInt32ArrayPrototype::getOwnPropertySlot(JSCell* cell, ExecState* exec, const Identifier& propertyName, PropertySlot& slot) diff --git a/JavaScriptCore/runtime/TypedArrays/JSInt8Array.cpp b/JavaScriptCore/runtime/TypedArrays/JSInt8Array.cpp index e0fb24bc..58c46cec 100644 --- a/JavaScriptCore/runtime/TypedArrays/JSInt8Array.cpp +++ b/JavaScriptCore/runtime/TypedArrays/JSInt8Array.cpp @@ -106,7 +106,7 @@ const ClassInfo JSInt8ArrayPrototype::s_info = { "Int8ArrayPrototype", &Base::s_ JSObject* JSInt8ArrayPrototype::self(ExecState* exec, JSGlobalObject* globalObject) { - return getDOMPrototype(exec, globalObject); + return getDOMPrototype(exec, globalObject); } bool JSInt8ArrayPrototype::getOwnPropertySlot(JSCell* cell, ExecState* exec, const Identifier& propertyName, PropertySlot& slot) diff --git a/JavaScriptCore/runtime/TypedArrays/JSUint16Array.cpp b/JavaScriptCore/runtime/TypedArrays/JSUint16Array.cpp index dafb6429..270ce74f 100644 --- a/JavaScriptCore/runtime/TypedArrays/JSUint16Array.cpp +++ b/JavaScriptCore/runtime/TypedArrays/JSUint16Array.cpp @@ -106,7 +106,7 @@ const ClassInfo JSUint16ArrayPrototype::s_info = { "Uint16ArrayPrototype", &Base JSObject* JSUint16ArrayPrototype::self(ExecState* exec, JSGlobalObject* globalObject) { - return getDOMPrototype(exec, globalObject); + return getDOMPrototype(exec, globalObject); } bool JSUint16ArrayPrototype::getOwnPropertySlot(JSCell* cell, ExecState* exec, const Identifier& propertyName, PropertySlot& slot) diff --git a/JavaScriptCore/runtime/TypedArrays/JSUint32Array.cpp b/JavaScriptCore/runtime/TypedArrays/JSUint32Array.cpp index 235b1292..77c7a445 100644 --- a/JavaScriptCore/runtime/TypedArrays/JSUint32Array.cpp +++ b/JavaScriptCore/runtime/TypedArrays/JSUint32Array.cpp @@ -106,7 +106,7 @@ const ClassInfo JSUint32ArrayPrototype::s_info = { "Uint32ArrayPrototype", &Base JSObject* JSUint32ArrayPrototype::self(ExecState* exec, JSGlobalObject* globalObject) { - return getDOMPrototype(exec, globalObject); + return getDOMPrototype(exec, globalObject); } bool JSUint32ArrayPrototype::getOwnPropertySlot(JSCell* cell, ExecState* exec, const Identifier& propertyName, PropertySlot& slot) diff --git a/JavaScriptCore/runtime/TypedArrays/JSUint8Array.cpp b/JavaScriptCore/runtime/TypedArrays/JSUint8Array.cpp index fcb418d2..82fd2503 100644 --- a/JavaScriptCore/runtime/TypedArrays/JSUint8Array.cpp +++ b/JavaScriptCore/runtime/TypedArrays/JSUint8Array.cpp @@ -106,7 +106,7 @@ const ClassInfo JSUint8ArrayPrototype::s_info = { "Uint8ArrayPrototype", &Base:: JSObject* JSUint8ArrayPrototype::self(ExecState* exec, JSGlobalObject* globalObject) { - return getDOMPrototype(exec, globalObject); + return getDOMPrototype(exec, globalObject); } bool JSUint8ArrayPrototype::getOwnPropertySlot(JSCell* cell, ExecState* exec, const Identifier& propertyName, PropertySlot& slot) diff --git a/JavaScriptCore/runtime/TypedArrays/JSUint8ClampedArray.cpp b/JavaScriptCore/runtime/TypedArrays/JSUint8ClampedArray.cpp index a96c574f..548a864f 100644 --- a/JavaScriptCore/runtime/TypedArrays/JSUint8ClampedArray.cpp +++ b/JavaScriptCore/runtime/TypedArrays/JSUint8ClampedArray.cpp @@ -106,7 +106,7 @@ const ClassInfo JSUint8ClampedArrayPrototype::s_info = { "Uint8ClampedArrayProto JSObject* JSUint8ClampedArrayPrototype::self(ExecState* exec, JSGlobalObject* globalObject) { - return getDOMPrototype(exec, globalObject); + return getDOMPrototype(exec, globalObject); } bool JSUint8ClampedArrayPrototype::getOwnPropertySlot(JSCell* cell, ExecState* exec, const Identifier& propertyName, PropertySlot& slot) From 3d6601b1178ccce58ccdaa9fc2f8c36badb7d95d Mon Sep 17 00:00:00 2001 From: Dominic Szablewski Date: Tue, 19 Nov 2013 10:57:59 +0100 Subject: [PATCH 30/30] Added obsolete notice --- README.md | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/README.md b/README.md index 8a4b3eca..39113872 100644 --- a/README.md +++ b/README.md @@ -1,3 +1,9 @@ +## The typed-arrays branch is obsolete + +The new JSC version used in the [master branch](https://github.com/phoboslab/JavaScriptCore-iOS) now contains support for Typed Arrays by default. This makes this branch obsolete. + +[Ejecta](https://github.com/phoboslab/Ejecta) has been updated to also use the master branch. + # JavaScriptCore iOS The JavaScriptCore library is part of the [WebKit project](http://www.webkit.org/) and thus Open Source. However, in the sources you get from the [WebKit SVN](https://svn.webkit.org/repository/webkit/trunk), the XCode project files are curiously missing an iOS compile target. You can't compile it for iOS. The sources you get from [opensource.apple.com](http://opensource.apple.com/release/ios-601/) are missing the project files altogether. You can't compile it all. That's quite the Open Source spirit, Apple!