diff --git a/JavaScriptCore/API/JSTypedArray.cpp b/JavaScriptCore/API/JSTypedArray.cpp new file mode 100644 index 00000000..89014f94 --- /dev/null +++ b/JavaScriptCore/API/JSTypedArray.cpp @@ -0,0 +1,133 @@ + +#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, + /* not a TypedArray */ kJSTypedArrayTypeArrayBuffer +}; + +const int kJSTypedArrayTypeLast = kJSTypedArrayTypeArrayBuffer; + + +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())); +} + +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, + [kJSTypedArrayTypeInt8Array] = CreateTypedArray, + [kJSTypedArrayTypeInt16Array] = CreateTypedArray, + [kJSTypedArrayTypeInt32Array] = CreateTypedArray, + [kJSTypedArrayTypeUint8Array] = CreateTypedArray, + [kJSTypedArrayTypeUint8ClampedArray] = CreateTypedArray, + [kJSTypedArrayTypeUint16Array] = CreateTypedArray, + [kJSTypedArrayTypeUint32Array] = CreateTypedArray, + [kJSTypedArrayTypeFloat32Array] = CreateTypedArray, + [kJSTypedArrayTypeFloat64Array] = CreateTypedArray, + [kJSTypedArrayTypeArrayBuffer] = CreateArrayBuffer, +}; + + + + +JSTypedArrayType JSTypedArrayGetType(JSContextRef ctx, JSValueRef value) { + ExecState* exec = toJS(ctx); + APIEntryShim entryShim(exec); + + JSValue jsValue = toJS(exec, value); + 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 type; +} + +JSObjectRef 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(); + } + else if( ArrayBuffer * buffer = toArrayBuffer(jsValue) ) { + if( byteLength ) { + *byteLength = buffer->byteLength(); + } + return buffer->data(); + } + + if( byteLength ) { + *byteLength = 0; + } + return NULL; +} + + + diff --git a/JavaScriptCore/API/JSTypedArray.h b/JavaScriptCore/API/JSTypedArray.h new file mode 100644 index 00000000..ea7f30a6 --- /dev/null +++ b/JavaScriptCore/API/JSTypedArray.h @@ -0,0 +1,73 @@ +#ifndef JSTypedArray_h +#define JSTypedArray_h + +#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 +@constant kJSTypedArrayTypeArrayBuffer ArrayBuffer +*/ +typedef enum { + kJSTypedArrayTypeNone, + kJSTypedArrayTypeInt8Array, + kJSTypedArrayTypeInt16Array, + kJSTypedArrayTypeInt32Array, + kJSTypedArrayTypeUint8Array, + kJSTypedArrayTypeUint8ClampedArray, + kJSTypedArrayTypeUint16Array, + kJSTypedArrayTypeUint32Array, + kJSTypedArrayTypeFloat32Array, + kJSTypedArrayTypeFloat64Array, + kJSTypedArrayTypeArrayBuffer +} 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); + +/*! +@function +@abstract Creates a JavaScript Typed Array with the given number of elements +@param ctx The execution context to use. +@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 +*/ +JS_EXPORT JSObjectRef JSTypedArrayMake(JSContextRef ctx, JSTypedArrayType arrayType, size_t numElements); + +/*! +@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 +} +#endif + +#endif /* JSTypedArray_h */ diff --git a/JavaScriptCore/JavaScriptCore.xcodeproj/project.pbxproj b/JavaScriptCore/JavaScriptCore.xcodeproj/project.pbxproj index e8533a2f..470a7c40 100644 --- a/JavaScriptCore/JavaScriptCore.xcodeproj/project.pbxproj +++ b/JavaScriptCore/JavaScriptCore.xcodeproj/project.pbxproj @@ -537,6 +537,30 @@ 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 */; }; + 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 */; }; + 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 */; }; + 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, ); }; }; @@ -1090,6 +1114,58 @@ 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 */; }; + 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 */; }; @@ -1804,9 +1880,47 @@ 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 = ""; }; + 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 = ""; }; + 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 = ""; }; + 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 = ""; }; + 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 = ""; }; @@ -2291,6 +2405,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 */, @@ -2419,6 +2535,7 @@ 7EF6E0BB0EB7A1EC0079AFAF /* runtime */ = { isa = PBXGroup; children = ( + B6D18813166FA73300D1037C /* TypedArrays */, 0F21C27914BE727300ADC64B /* CodeSpecializationKind.h */, 0F21C27A14BE727300ADC64B /* ExecutionHarness.h */, 0F15F15D14B7A73A005DE37D /* CommonSlowPaths.h */, @@ -2849,6 +2966,49 @@ path = bytecode; sourceTree = ""; }; + B6D18813166FA73300D1037C /* TypedArrays */ = { + isa = PBXGroup; + children = ( + B6D188881673751400D1037C /* GlobalDataHelper.h */, + B6E02BBB16D17CC400616925 /* TypedArrayHashTableMap.cpp */, + B6E02BB616D1666300616925 /* TypedArrayHashTableMap.h */, + B6D18814166FA73400D1037C /* JSArrayBuffer.cpp */, + B6D18815166FA73400D1037C /* JSArrayBuffer.h */, + B6D18816166FA73400D1037C /* JSArrayBufferCustom.cpp */, + B6D18817166FA73400D1037C /* JSArrayBufferView.cpp */, + B6D18818166FA73400D1037C /* JSArrayBufferView.h */, + B6D18819166FA73400D1037C /* JSArrayBufferViewHelper.h */, + 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 = ""; + }; /* End PBXGroup section */ /* Begin PBXHeadersBuildPhase section */ @@ -3206,6 +3366,21 @@ 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 */, + 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 */, + B6F114CA16755F98001F1324 /* JSTypedArray.h in Headers */, + B6E02BB916D1666300616925 /* TypedArrayHashTableMap.h in Headers */, ); runOnlyForDeploymentPostprocessing = 0; }; @@ -3551,6 +3726,21 @@ 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 */, + 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 */, + B6F114CB16755F98001F1324 /* JSTypedArray.h in Headers */, + B6E02BBA16D1666300616925 /* TypedArrayHashTableMap.h in Headers */, ); runOnlyForDeploymentPostprocessing = 0; }; @@ -3719,7 +3909,7 @@ isa = PBXProject; attributes = { BuildIndependentTargetsInParallel = YES; - LastUpgradeCheck = 0440; + LastUpgradeCheck = 0450; }; buildConfigurationList = 149C277108902AFE008A9EFC /* Build configuration list for PBXProject "JavaScriptCore" */; compatibilityVersion = "Xcode 3.2"; @@ -4296,6 +4486,29 @@ 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 */, + 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 */, + B6F114C816755F98001F1324 /* JSTypedArray.cpp in Sources */, + B6E02BBC16D17CC400616925 /* TypedArrayHashTableMap.cpp in Sources */, ); runOnlyForDeploymentPostprocessing = 0; }; @@ -4520,6 +4733,29 @@ 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 */, + 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 */, + B6F114C916755F98001F1324 /* JSTypedArray.cpp in Sources */, + B6E02BBD16D17CC400616925 /* TypedArrayHashTableMap.cpp in Sources */, ); runOnlyForDeploymentPostprocessing = 0; }; @@ -4600,6 +4836,7 @@ 0F4680AD14BA7FD900BFE272 /* Debug */ = { isa = XCBuildConfiguration; buildSettings = { + COMBINE_HIDPI_IMAGES = YES; PRODUCT_NAME = "Derived Sources copy"; }; name = Debug; @@ -4607,6 +4844,7 @@ 0F4680AE14BA7FD900BFE272 /* Release */ = { isa = XCBuildConfiguration; buildSettings = { + COMBINE_HIDPI_IMAGES = YES; PRODUCT_NAME = "Derived Sources copy"; }; name = Release; @@ -4614,6 +4852,7 @@ 0F4680AF14BA7FD900BFE272 /* Profiling */ = { isa = XCBuildConfiguration; buildSettings = { + COMBINE_HIDPI_IMAGES = YES; PRODUCT_NAME = "Derived Sources copy"; }; name = Profiling; @@ -4621,6 +4860,7 @@ 0F4680B014BA7FD900BFE272 /* Production */ = { isa = XCBuildConfiguration; buildSettings = { + COMBINE_HIDPI_IMAGES = YES; PRODUCT_NAME = "Derived Sources copy"; }; name = Production; @@ -4678,6 +4918,7 @@ isa = XCBuildConfiguration; baseConfigurationReference = 1C9051430BA9E8A70081E9D0 /* JavaScriptCore.xcconfig */; buildSettings = { + COMBINE_HIDPI_IMAGES = YES; INSTALL_PATH = "$(BUILT_PRODUCTS_DIR)"; }; name = Debug; @@ -4686,6 +4927,7 @@ isa = XCBuildConfiguration; baseConfigurationReference = 1C9051430BA9E8A70081E9D0 /* JavaScriptCore.xcconfig */; buildSettings = { + COMBINE_HIDPI_IMAGES = YES; INSTALL_PATH = "$(BUILT_PRODUCTS_DIR)"; }; name = Release; @@ -4695,6 +4937,7 @@ baseConfigurationReference = 1C9051430BA9E8A70081E9D0 /* JavaScriptCore.xcconfig */; buildSettings = { BUILD_VARIANTS = normal; + COMBINE_HIDPI_IMAGES = YES; }; name = Production; }; @@ -4722,6 +4965,7 @@ 149C276D08902AFE008A9EFC /* Debug */ = { isa = XCBuildConfiguration; buildSettings = { + COMBINE_HIDPI_IMAGES = YES; PRODUCT_NAME = All; }; name = Debug; @@ -4729,6 +4973,7 @@ 149C276E08902AFE008A9EFC /* Release */ = { isa = XCBuildConfiguration; buildSettings = { + COMBINE_HIDPI_IMAGES = YES; PRODUCT_NAME = All; }; name = Release; @@ -4736,6 +4981,7 @@ 149C277008902AFE008A9EFC /* Production */ = { isa = XCBuildConfiguration; buildSettings = { + COMBINE_HIDPI_IMAGES = YES; PRODUCT_NAME = All; }; name = Production; @@ -4747,6 +4993,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; @@ -4755,6 +5002,7 @@ isa = XCBuildConfiguration; baseConfigurationReference = 1C9051440BA9E8A70081E9D0 /* DebugRelease.xcconfig */; buildSettings = { + GCC_TREAT_WARNINGS_AS_ERRORS = NO; STRIP_INSTALLED_PRODUCT = NO; }; name = Release; @@ -4763,6 +5011,7 @@ isa = XCBuildConfiguration; baseConfigurationReference = 1C9051450BA9E8A70081E9D0 /* Base.xcconfig */; buildSettings = { + GCC_TREAT_WARNINGS_AS_ERRORS = NO; }; name = Production; }; @@ -4790,6 +5039,7 @@ 5D6B2A48152B9E17005231DE /* Debug */ = { isa = XCBuildConfiguration; buildSettings = { + COMBINE_HIDPI_IMAGES = YES; PRODUCT_NAME = "$(TARGET_NAME)"; }; name = Debug; @@ -4797,6 +5047,7 @@ 5D6B2A49152B9E17005231DE /* Release */ = { isa = XCBuildConfiguration; buildSettings = { + COMBINE_HIDPI_IMAGES = YES; PRODUCT_NAME = "$(TARGET_NAME)"; }; name = Release; @@ -4804,6 +5055,7 @@ 5D6B2A4A152B9E17005231DE /* Profiling */ = { isa = XCBuildConfiguration; buildSettings = { + COMBINE_HIDPI_IMAGES = YES; PRODUCT_NAME = "$(TARGET_NAME)"; }; name = Profiling; @@ -4811,6 +5063,7 @@ 5D6B2A4B152B9E17005231DE /* Production */ = { isa = XCBuildConfiguration; buildSettings = { + COMBINE_HIDPI_IMAGES = YES; PRODUCT_NAME = "$(TARGET_NAME)"; }; name = Production; @@ -4846,6 +5099,7 @@ 65FB3F7809D11EBD00F49DEB /* Debug */ = { isa = XCBuildConfiguration; buildSettings = { + COMBINE_HIDPI_IMAGES = YES; PRODUCT_NAME = "Generate Derived Sources"; }; name = Debug; @@ -4853,6 +5107,7 @@ 65FB3F7909D11EBD00F49DEB /* Release */ = { isa = XCBuildConfiguration; buildSettings = { + COMBINE_HIDPI_IMAGES = YES; PRODUCT_NAME = "Generate Derived Sources"; }; name = Release; @@ -4860,6 +5115,7 @@ 65FB3F7A09D11EBD00F49DEB /* Production */ = { isa = XCBuildConfiguration; buildSettings = { + COMBINE_HIDPI_IMAGES = YES; PRODUCT_NAME = "Generate Derived Sources"; }; name = Production; @@ -4868,6 +5124,7 @@ isa = XCBuildConfiguration; baseConfigurationReference = 1C9051440BA9E8A70081E9D0 /* DebugRelease.xcconfig */; buildSettings = { + GCC_TREAT_WARNINGS_AS_ERRORS = NO; STRIP_INSTALLED_PRODUCT = NO; }; name = Profiling; @@ -4875,6 +5132,7 @@ A761483E0E6402F700E357FA /* Profiling */ = { isa = XCBuildConfiguration; buildSettings = { + COMBINE_HIDPI_IMAGES = YES; PRODUCT_NAME = All; }; name = Profiling; @@ -4883,6 +5141,7 @@ isa = XCBuildConfiguration; baseConfigurationReference = 1C9051430BA9E8A70081E9D0 /* JavaScriptCore.xcconfig */; buildSettings = { + COMBINE_HIDPI_IMAGES = YES; INSTALL_PATH = "$(BUILT_PRODUCTS_DIR)"; }; name = Profiling; @@ -4890,6 +5149,7 @@ A76148400E6402F700E357FA /* Profiling */ = { isa = XCBuildConfiguration; buildSettings = { + COMBINE_HIDPI_IMAGES = YES; PRODUCT_NAME = "Generate Derived Sources"; }; name = Profiling; @@ -5170,6 +5430,7 @@ B6E69C01166BDD18005EF4B1 /* Debug */ = { isa = XCBuildConfiguration; buildSettings = { + COMBINE_HIDPI_IMAGES = YES; PRODUCT_NAME = "$(TARGET_NAME)"; }; name = Debug; @@ -5177,6 +5438,7 @@ B6E69C02166BDD18005EF4B1 /* Release */ = { isa = XCBuildConfiguration; buildSettings = { + COMBINE_HIDPI_IMAGES = YES; PRODUCT_NAME = "$(TARGET_NAME)"; }; name = Release; @@ -5184,6 +5446,7 @@ B6E69C03166BDD18005EF4B1 /* Profiling */ = { isa = XCBuildConfiguration; buildSettings = { + COMBINE_HIDPI_IMAGES = YES; PRODUCT_NAME = "$(TARGET_NAME)"; }; name = Profiling; @@ -5191,6 +5454,7 @@ B6E69C04166BDD18005EF4B1 /* Production */ = { isa = XCBuildConfiguration; buildSettings = { + COMBINE_HIDPI_IMAGES = YES; PRODUCT_NAME = "$(TARGET_NAME)"; }; name = Production; @@ -5372,6 +5636,7 @@ B6E69C04166BDD18005EF4B1 /* Production */, ); defaultConfigurationIsVisible = 0; + defaultConfigurationName = Production; }; /* End XCConfigurationList section */ }; 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.cpp b/JavaScriptCore/runtime/JSGlobalObject.cpp index 4e273153..0e6f238b 100644 --- a/JavaScriptCore/runtime/JSGlobalObject.cpp +++ b/JavaScriptCore/runtime/JSGlobalObject.cpp @@ -72,6 +72,19 @@ #include "StringPrototype.h" #include "Debugger.h" +// 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" namespace JSC { @@ -290,6 +303,39 @@ 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::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); + + 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::JSUint32Array::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); @@ -379,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 d9fc81dc..19dc3594 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,12 @@ namespace JSC { } static JS_EXPORTDATA const ClassInfo s_info; + + 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/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 diff --git a/JavaScriptCore/runtime/TypedArrays/GlobalDataHelper.h b/JavaScriptCore/runtime/TypedArrays/GlobalDataHelper.h new file mode 100644 index 00000000..e0fbd3c3 --- /dev/null +++ b/JavaScriptCore/runtime/TypedArrays/GlobalDataHelper.h @@ -0,0 +1,69 @@ +#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) { + return globalData.typedArrayHashTableMap.get(staticTable); +} + +template +inline JSC::JSObject* getDOMConstructor(JSC::ExecState* exec, JSC::JSGlobalObject* globalObject) +{ + 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 +inline JSC::Structure* getDOMStructure(JSC::ExecState* exec, JSC::JSGlobalObject* globalObject) +{ + if (JSC::Structure* structure = globalObject->typedArrayStructureMap.get(&TypeClass::s_info).get()) { + return structure; + } + + + 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())); +} + +} + +#endif /* defined(__JavaScriptCore__GlobalDataHelper__) */ diff --git a/JavaScriptCore/runtime/TypedArrays/JSArrayBuffer.cpp b/JavaScriptCore/runtime/TypedArrays/JSArrayBuffer.cpp new file mode 100644 index 00000000..de3ea815 --- /dev/null +++ b/JavaScriptCore/runtime/TypedArrays/JSArrayBuffer.cpp @@ -0,0 +1,257 @@ +/* + 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 "JSArrayBuffer.h" +#include "Lookup.h" +#include +#include +#include + +#include "GlobalDataHelper.h" + +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(JSGlobalObject* globalObject, Structure* structure) + : InternalFunction(globalObject, structure) +{ +} + +void JSArrayBufferConstructor::finishCreation(ExecState* exec, JSGlobalObject* globalObject) +{ + 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, 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); +} + +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) }; + +static JSObject * globalProto = NULL; +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) +{ + 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, JSGlobalObject* globalObject, PassRefPtr impl) + : JSNonFinalObject(globalObject->globalData(), structure) + , 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) +{ + ASSERT_UNUSED(context, context); + JSArrayBuffer* jsArrayBuffer = jsCast(handle.get().asCell()); + jsArrayBuffer->releaseImpl(); +} + +JSC::JSValue toJS(JSC::ExecState* exec, JSGlobalObject* globalObject, ArrayBuffer* impl) +{ + JSArrayBuffer * buf = JSArrayBuffer::create( getDOMStructure(exec, globalObject), globalObject, impl); + JSC::JSCell* jsCell = reinterpret_cast(buf); + return jsCell; +} + +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..e15ac881 --- /dev/null +++ b/JavaScriptCore/runtime/TypedArrays/JSArrayBuffer.h @@ -0,0 +1,153 @@ +/* + 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 "JSObject.h" +#include "InternalFunction.h" + +#include +#include +#include +#include + +namespace WebCore { + +class JSArrayBuffer : public JSC::JSNonFinalObject { +public: + 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()); + 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*, JSC::JSGlobalObject*, 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*, JSC::JSGlobalObject*, 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 JSC::InternalFunction { +private: + JSArrayBufferConstructor(JSC::JSGlobalObject* globalObject, JSC::Structure* structure); + void finishCreation(JSC::ExecState*, JSC::JSGlobalObject*); + +public: + 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); + 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 | JSC::InternalFunction::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..a5784027 --- /dev/null +++ b/JavaScriptCore/runtime/TypedArrays/JSArrayBufferCustom.cpp @@ -0,0 +1,49 @@ +/* + * 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 +#include + +namespace WebCore { + +JSC::EncodedJSValue JSC_HOST_CALL JSArrayBufferConstructor::constructJSArrayBuffer(JSC::ExecState* exec) +{ + JSArrayBufferConstructor* jsConstructor = JSC::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 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 new file mode 100644 index 00000000..5409ab19 --- /dev/null +++ b/JavaScriptCore/runtime/TypedArrays/JSArrayBufferView.cpp @@ -0,0 +1,176 @@ +/* + 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 "Lookup.h" +#include "JSArrayBuffer.h" +#include +#include +#include + +#include "GlobalDataHelper.h" + +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, JSGlobalObject* globalObject, PassRefPtr impl) + : JSNonFinalObject(globalObject->globalData(), structure) + , 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) +{ + ASSERT_UNUSED(context, context); + JSArrayBufferView* jsArrayBufferView = jsCast(handle.get().asCell()); + 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..0303b8bc --- /dev/null +++ b/JavaScriptCore/runtime/TypedArrays/JSArrayBufferView.h @@ -0,0 +1,119 @@ +/* + 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 +#include +#include +#include + +namespace WebCore { + +class JSArrayBufferView : public JSC::JSNonFinalObject { +public: + typedef JSNonFinalObject Base; + 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()); + 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*, JSC::JSGlobalObject*, 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*, JSC::JSGlobalObject*, 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..ca5b44a4 --- /dev/null +++ b/JavaScriptCore/runtime/TypedArrays/JSArrayBufferViewHelper.h @@ -0,0 +1,176 @@ +/* + * 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 "JSArrayBuffer.h" +#include +#include +#include +#include +#include +#include +#include "GlobalDataHelper.h" + +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)) + throwTypeError(exec); + + 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) + throwTypeError(exec); + 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) + throwTypeError(exec); + 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) { + throwTypeError(exec); + 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, JSC::JSGlobalObject* globalObject, WebCoreType* object) +{ + if (!object) + return JSC::jsNull(); + + exec->heap()->reportExtraMemoryCost(object->byteLength()); + return JSType::create(getDOMStructure(exec, globalObject), globalObject, object); +} + +} // namespace WebCore + +#endif // JSArrayBufferViewHelper_h diff --git a/JavaScriptCore/runtime/TypedArrays/JSFloat32Array.cpp b/JavaScriptCore/runtime/TypedArrays/JSFloat32Array.cpp new file mode 100644 index 00000000..956da6d8 --- /dev/null +++ b/JavaScriptCore/runtime/TypedArrays/JSFloat32Array.cpp @@ -0,0 +1,299 @@ +/* + 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 "Lookup.h" +#include "GlobalDataHelper.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, JSGlobalObject* globalObject) + : InternalFunction(globalObject, structure) +{ +} + +void JSFloat32ArrayConstructor::finishCreation(ExecState* exec, JSGlobalObject* globalObject) +{ + 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, proto, 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, JSGlobalObject* 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..eac460f6 --- /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 "InternalFunction.h" +#include +#include + +namespace WebCore { + +class JSFloat32Array : public JSArrayBufferView { +public: + typedef JSArrayBufferView Base; + 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()); + 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*, 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*, JSC::JSGlobalObject*, 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 JSC::InternalFunction { +private: + JSFloat32ArrayConstructor(JSC::Structure*, JSC::JSGlobalObject*); + void finishCreation(JSC::ExecState*, JSC::JSGlobalObject*); + +public: + 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); + 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 | InternalFunction::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 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 diff --git a/JavaScriptCore/runtime/TypedArrays/JSFloat64Array.cpp b/JavaScriptCore/runtime/TypedArrays/JSFloat64Array.cpp new file mode 100644 index 00000000..0c94bb75 --- /dev/null +++ b/JavaScriptCore/runtime/TypedArrays/JSFloat64Array.cpp @@ -0,0 +1,299 @@ +/* + 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 "Lookup.h" +#include "GlobalDataHelper.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, JSC::JSGlobalObject* globalObject) + : InternalFunction(globalObject, structure) +{ +} + +void JSFloat64ArrayConstructor::finishCreation(ExecState* exec, JSC::JSGlobalObject* globalObject) +{ + 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, 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); +} + +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, JSGlobalObject* 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..3b8c0484 --- /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 "InternalFunction.h" +#include +#include + +namespace WebCore { + +class JSFloat64Array : public JSArrayBufferView { +public: + typedef JSArrayBufferView Base; + 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()); + 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*, 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*, JSC::JSGlobalObject*, 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 JSC::InternalFunction { +private: + JSFloat64ArrayConstructor(JSC::Structure*, JSC::JSGlobalObject*); + void finishCreation(JSC::ExecState*, JSC::JSGlobalObject*); + +public: + 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); + 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 | JSC::InternalFunction::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..8c05ae91 --- /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, JSGlobalObject* 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..fa7d561b --- /dev/null +++ b/JavaScriptCore/runtime/TypedArrays/JSInt16Array.cpp @@ -0,0 +1,299 @@ +/* + 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 "Lookup.h" +#include "GlobalDataHelper.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, JSGlobalObject* globalObject) + : InternalFunction(globalObject, structure) +{ +} + +void JSInt16ArrayConstructor::finishCreation(ExecState* exec, JSGlobalObject* globalObject) +{ + 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, 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); +} + +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, JSGlobalObject* 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..b0c8f18d --- /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 "InternalFunction.h" +#include +#include + +namespace WebCore { + +class JSInt16Array : public JSArrayBufferView { +public: + typedef JSArrayBufferView Base; + 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()); + 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*, 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*, JSC::JSGlobalObject*, 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 JSC::InternalFunction { +private: + JSInt16ArrayConstructor(JSC::Structure*, JSC::JSGlobalObject*); + void finishCreation(JSC::ExecState*, JSC::JSGlobalObject*); + +public: + 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); + 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 | JSC::InternalFunction::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..1c6c50b6 --- /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, JSGlobalObject* 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..fcb4a5ef --- /dev/null +++ b/JavaScriptCore/runtime/TypedArrays/JSInt32Array.cpp @@ -0,0 +1,299 @@ +/* + 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 "Lookup.h" +#include "GlobalDataHelper.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, JSGlobalObject* globalObject) + : InternalFunction(globalObject, structure) +{ +} + +void JSInt32ArrayConstructor::finishCreation(ExecState* exec, JSGlobalObject* globalObject) +{ + 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, 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); +} + +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, JSGlobalObject* 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..dc8ee7c9 --- /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 "InternalFunction.h" +#include +#include + +namespace WebCore { + +class JSInt32Array : public JSArrayBufferView { +public: + typedef JSArrayBufferView Base; + 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()); + 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*, 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*, JSC::JSGlobalObject*, 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 JSC::InternalFunction { +private: + JSInt32ArrayConstructor(JSC::Structure*, JSC::JSGlobalObject*); + void finishCreation(JSC::ExecState*, JSC::JSGlobalObject*); + +public: + 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); + 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 | JSC::InternalFunction::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..cf0d8907 --- /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, JSGlobalObject* 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..58c46cec --- /dev/null +++ b/JavaScriptCore/runtime/TypedArrays/JSInt8Array.cpp @@ -0,0 +1,299 @@ +/* + 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 "Lookup.h" +#include "GlobalDataHelper.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, JSGlobalObject* globalObject) + : InternalFunction(globalObject, structure) +{ +} + +void JSInt8ArrayConstructor::finishCreation(ExecState* exec, JSGlobalObject* globalObject) +{ + 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, 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); +} + +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, JSGlobalObject* 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..42eae1a1 --- /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 "InternalFunction.h" +#include "JSArrayBufferView.h" +#include +#include + +namespace WebCore { + +class JSInt8Array : public JSArrayBufferView { +public: + typedef JSArrayBufferView Base; + 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()); + 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*, 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*, JSC::JSGlobalObject*, 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 JSC::InternalFunction { +private: + JSInt8ArrayConstructor(JSC::Structure*, JSC::JSGlobalObject*); + void finishCreation(JSC::ExecState*, JSC::JSGlobalObject*); + +public: + 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); + 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 | JSC::InternalFunction::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..e424615a --- /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, JSGlobalObject* 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..270ce74f --- /dev/null +++ b/JavaScriptCore/runtime/TypedArrays/JSUint16Array.cpp @@ -0,0 +1,299 @@ +/* + 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 "Lookup.h" +#include "GlobalDataHelper.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, JSGlobalObject* globalObject) + : InternalFunction(globalObject, structure) +{ +} + +void JSUint16ArrayConstructor::finishCreation(ExecState* exec, JSGlobalObject* globalObject) +{ + 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, 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); +} + +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, JSGlobalObject* 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..522e5ad5 --- /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 "InternalFunction.h" +#include +#include + +namespace WebCore { + +class JSUint16Array : public JSArrayBufferView { +public: + typedef JSArrayBufferView Base; + 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()); + 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*, 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*, JSC::JSGlobalObject*, 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 JSC::InternalFunction { +private: + JSUint16ArrayConstructor(JSC::Structure*, JSC::JSGlobalObject*); + void finishCreation(JSC::ExecState*, JSC::JSGlobalObject*); + +public: + 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); + 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 | JSC::InternalFunction::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..14fda1bf --- /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, JSGlobalObject* 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..77c7a445 --- /dev/null +++ b/JavaScriptCore/runtime/TypedArrays/JSUint32Array.cpp @@ -0,0 +1,299 @@ +/* + 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 "Lookup.h" +#include "GlobalDataHelper.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, JSGlobalObject* globalObject) + : InternalFunction(globalObject, structure) +{ +} + +void JSUint32ArrayConstructor::finishCreation(ExecState* exec, JSGlobalObject* globalObject) +{ + 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, 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); +} + +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, JSGlobalObject* 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..e59e8066 --- /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 "InternalFunction.h" +#include +#include + +namespace WebCore { + +class JSUint32Array : public JSArrayBufferView { +public: + typedef JSArrayBufferView Base; + 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()); + 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*, 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*, JSC::JSGlobalObject*, 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 JSC::InternalFunction { +private: + JSUint32ArrayConstructor(JSC::Structure*, JSC::JSGlobalObject*); + void finishCreation(JSC::ExecState*, JSC::JSGlobalObject*); + +public: + 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); + 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 | JSC::InternalFunction::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..d44d812f --- /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, JSGlobalObject* 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..82fd2503 --- /dev/null +++ b/JavaScriptCore/runtime/TypedArrays/JSUint8Array.cpp @@ -0,0 +1,299 @@ +/* + 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 "Lookup.h" +#include "GlobalDataHelper.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, JSGlobalObject* globalObject) + : InternalFunction(globalObject, structure) +{ +} + +void JSUint8ArrayConstructor::finishCreation(ExecState* exec, JSGlobalObject* globalObject) +{ + 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, 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); +} + +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, JSGlobalObject* 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..98f501a4 --- /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 "InternalFunction.h" +#include +#include + +namespace WebCore { + +class JSUint8Array : public JSArrayBufferView { +public: + typedef JSArrayBufferView Base; + 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()); + 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*, 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*, JSC::JSGlobalObject*, 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 JSC::InternalFunction { +private: + JSUint8ArrayConstructor(JSC::Structure*, JSC::JSGlobalObject*); + void finishCreation(JSC::ExecState*, JSC::JSGlobalObject*); + +public: + 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); + 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 | JSC::InternalFunction::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..4a769738 --- /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, JSGlobalObject* 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..548a864f --- /dev/null +++ b/JavaScriptCore/runtime/TypedArrays/JSUint8ClampedArray.cpp @@ -0,0 +1,299 @@ +/* + 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 "Lookup.h" +#include "GlobalDataHelper.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, JSGlobalObject* globalObject) + : InternalFunction(globalObject, structure) +{ +} + +void JSUint8ClampedArrayConstructor::finishCreation(ExecState* exec, JSGlobalObject* globalObject) +{ + 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, 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); +} + +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, JSGlobalObject* 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..7c430c74 --- /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 "InternalFunction.h" +#include "JSUint8Array.h" +#include +#include + +namespace WebCore { + +class JSUint8ClampedArray : public JSUint8Array { +public: + typedef JSUint8Array Base; + 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()); + 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*, 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*, JSC::JSGlobalObject*, 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 JSC::InternalFunction { +private: + JSUint8ClampedArrayConstructor(JSC::Structure*, JSC::JSGlobalObject*); + void finishCreation(JSC::ExecState*, JSC::JSGlobalObject*); + +public: + 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); + 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 | JSC::InternalFunction::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..1b36c53f --- /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, JSGlobalObject* 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 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 diff --git a/README.md b/README.md index bd23122b..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! @@ -6,9 +12,19 @@ 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. +## Typed Array Branch + +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. + ## Binaries -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). +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