diff options
-rw-r--r-- | src/qml/jsruntime/qv4arraybuffer.cpp | 6 | ||||
-rw-r--r-- | src/qml/jsruntime/qv4arraybuffer_p.h | 25 | ||||
-rw-r--r-- | src/qml/jsruntime/qv4dataview.cpp | 6 | ||||
-rw-r--r-- | src/qml/jsruntime/qv4dataview_p.h | 29 | ||||
-rw-r--r-- | src/qml/jsruntime/qv4engine.cpp | 10 | ||||
-rw-r--r-- | src/qml/jsruntime/qv4typedarray.cpp | 10 | ||||
-rw-r--r-- | src/qml/jsruntime/qv4typedarray_p.h | 64 |
7 files changed, 85 insertions, 65 deletions
diff --git a/src/qml/jsruntime/qv4arraybuffer.cpp b/src/qml/jsruntime/qv4arraybuffer.cpp index 55a80f2315..a74e5c6299 100644 --- a/src/qml/jsruntime/qv4arraybuffer.cpp +++ b/src/qml/jsruntime/qv4arraybuffer.cpp @@ -39,10 +39,10 @@ using namespace QV4; DEFINE_OBJECT_VTABLE(ArrayBufferCtor); DEFINE_OBJECT_VTABLE(ArrayBuffer); -ArrayBufferCtor::Data::Data(ExecutionContext *scope) +Heap::ArrayBufferCtor::ArrayBufferCtor(QV4::ExecutionContext *scope) : Heap::FunctionObject(scope, QStringLiteral("ArrayBuffer")) { - setVTable(staticVTable()); + setVTable(QV4::ArrayBufferCtor::staticVTable()); } ReturnedValue ArrayBufferCtor::construct(Managed *m, CallData *callData) @@ -83,7 +83,7 @@ ReturnedValue ArrayBufferCtor::method_isView(CallContext *ctx) } -ArrayBuffer::Data::Data(ExecutionEngine *e, int length) +Heap::ArrayBuffer::ArrayBuffer(ExecutionEngine *e, int length) : Heap::Object(e->arrayBufferClass) { data = QTypedArrayData<char>::allocate(length + 1); diff --git a/src/qml/jsruntime/qv4arraybuffer_p.h b/src/qml/jsruntime/qv4arraybuffer_p.h index e1bf1d7ef0..228b40645d 100644 --- a/src/qml/jsruntime/qv4arraybuffer_p.h +++ b/src/qml/jsruntime/qv4arraybuffer_p.h @@ -40,13 +40,22 @@ QT_BEGIN_NAMESPACE namespace QV4 { +namespace Heap { + +struct ArrayBufferCtor : FunctionObject { + ArrayBufferCtor(QV4::ExecutionContext *scope); +}; + +struct ArrayBuffer : Object { + ArrayBuffer(ExecutionEngine *e, int length); + QTypedArrayData<char> *data; +}; + +} + struct ArrayBufferCtor: FunctionObject { - struct Data : Heap::FunctionObject { - Data(ExecutionContext *scope); - }; - - V4_OBJECT(FunctionObject) + V4_OBJECT2(ArrayBufferCtor, FunctionObject) static ReturnedValue construct(Managed *m, CallData *callData); static ReturnedValue call(Managed *that, CallData *callData); @@ -57,11 +66,7 @@ struct ArrayBufferCtor: FunctionObject struct ArrayBuffer : Object { - struct Data : Heap::Object { - Data(ExecutionEngine *e, int length); - QTypedArrayData<char> *data; - }; - V4_OBJECT(Object) + V4_OBJECT2(ArrayBuffer, Object) QByteArray asByteArray() const; uint byteLength() const { return d()->data->size; } diff --git a/src/qml/jsruntime/qv4dataview.cpp b/src/qml/jsruntime/qv4dataview.cpp index 8c0f109ff4..0a473ca4ed 100644 --- a/src/qml/jsruntime/qv4dataview.cpp +++ b/src/qml/jsruntime/qv4dataview.cpp @@ -41,10 +41,10 @@ using namespace QV4; DEFINE_OBJECT_VTABLE(DataViewCtor); DEFINE_OBJECT_VTABLE(DataView); -DataViewCtor::Data::Data(ExecutionContext *scope) +Heap::DataViewCtor::DataViewCtor(QV4::ExecutionContext *scope) : Heap::FunctionObject(scope, QStringLiteral("DataView")) { - setVTable(staticVTable()); + setVTable(QV4::DataViewCtor::staticVTable()); } ReturnedValue DataViewCtor::construct(Managed *m, CallData *callData) @@ -76,7 +76,7 @@ ReturnedValue DataViewCtor::call(Managed *that, CallData *callData) } -DataView::Data::Data(ExecutionEngine *e) +Heap::DataView::DataView(ExecutionEngine *e) : Heap::Object(e->dataViewClass), buffer(0), byteLength(0), diff --git a/src/qml/jsruntime/qv4dataview_p.h b/src/qml/jsruntime/qv4dataview_p.h index 1e504aaf0f..e9ca05e082 100644 --- a/src/qml/jsruntime/qv4dataview_p.h +++ b/src/qml/jsruntime/qv4dataview_p.h @@ -42,13 +42,24 @@ namespace QV4 { struct ArrayBuffer; +namespace Heap { + +struct DataViewCtor : FunctionObject { + DataViewCtor(QV4::ExecutionContext *scope); +}; + +struct DataView : Object { + DataView(ExecutionEngine *e); + QV4::ArrayBuffer *buffer; + uint byteLength; + uint byteOffset; +}; + +} + struct DataViewCtor: FunctionObject { - struct Data : Heap::FunctionObject { - Data(ExecutionContext *scope); - }; - - V4_OBJECT(FunctionObject) + V4_OBJECT2(DataViewCtor, FunctionObject) static ReturnedValue construct(Managed *m, CallData *callData); static ReturnedValue call(Managed *that, CallData *callData); @@ -56,13 +67,7 @@ struct DataViewCtor: FunctionObject struct DataView : Object { - struct Data : Heap::Object { - Data(ExecutionEngine *e); - ArrayBuffer *buffer; - uint byteLength; - uint byteOffset; - }; - V4_OBJECT(Object) + V4_OBJECT2(DataView, Object) static void markObjects(Heap::Base *that, ExecutionEngine *e); }; diff --git a/src/qml/jsruntime/qv4engine.cpp b/src/qml/jsruntime/qv4engine.cpp index e4fcb2a8fd..19750e15cf 100644 --- a/src/qml/jsruntime/qv4engine.cpp +++ b/src/qml/jsruntime/qv4engine.cpp @@ -384,9 +384,9 @@ ExecutionEngine::ExecutionEngine(EvalISelFactory *factory) dataViewPrototype->init(this, dataViewCtor.asObject()); dataViewClass = InternalClass::create(this, DataView::staticVTable(), dataViewPrototype); - for (int i = 0; i < TypedArray::NTypes; ++i) { - typedArrayCtors[i] = memoryManager->alloc<TypedArrayCtor>(rootContext, TypedArray::Type(i)); - Scoped<TypedArrayPrototype> typedArrayPrototype(scope, memoryManager->alloc<TypedArrayPrototype>(this, TypedArray::Type(i))); + for (int i = 0; i < Heap::TypedArray::NTypes; ++i) { + typedArrayCtors[i] = memoryManager->alloc<TypedArrayCtor>(rootContext, Heap::TypedArray::Type(i)); + Scoped<TypedArrayPrototype> typedArrayPrototype(scope, memoryManager->alloc<TypedArrayPrototype>(this, Heap::TypedArray::Type(i))); typedArrayPrototype->init(this, static_cast<TypedArrayCtor *>(typedArrayCtors[i].asObject())); typedArrayClasses[i] = InternalClass::create(this, TypedArray::staticVTable(), typedArrayPrototype); } @@ -418,7 +418,7 @@ ExecutionEngine::ExecutionEngine(EvalISelFactory *factory) globalObject->defineDefaultProperty(QStringLiteral("ArrayBuffer"), arrayBufferCtor); globalObject->defineDefaultProperty(QStringLiteral("DataView"), dataViewCtor); ScopedString str(scope); - for (int i = 0; i < TypedArray::NTypes; ++i) + for (int i = 0; i < Heap::TypedArray::NTypes; ++i) globalObject->defineDefaultProperty((str = typedArrayCtors[i].asFunctionObject()->name())->toQString(), typedArrayCtors[i]); ScopedObject o(scope); globalObject->defineDefaultProperty(QStringLiteral("Math"), (o = memoryManager->alloc<MathObject>(QV4::InternalClass::create(this, MathObject::staticVTable(), objectPrototype)))); @@ -943,7 +943,7 @@ void ExecutionEngine::markObjects() uRIErrorCtor.mark(this); arrayBufferCtor.mark(this); dataViewCtor.mark(this); - for (int i = 0; i < TypedArray::NTypes; ++i) + for (int i = 0; i < Heap::TypedArray::NTypes; ++i) typedArrayCtors[i].mark(this); sequencePrototype.mark(this); diff --git a/src/qml/jsruntime/qv4typedarray.cpp b/src/qml/jsruntime/qv4typedarray.cpp index d4b51c7214..f1d296a9de 100644 --- a/src/qml/jsruntime/qv4typedarray.cpp +++ b/src/qml/jsruntime/qv4typedarray.cpp @@ -39,7 +39,7 @@ DEFINE_OBJECT_VTABLE(TypedArrayCtor); DEFINE_OBJECT_VTABLE(TypedArrayPrototype); DEFINE_OBJECT_VTABLE(TypedArray); -Q_STATIC_ASSERT((int)ExecutionEngine::NTypedArrayTypes == (int)TypedArray::NTypes); +Q_STATIC_ASSERT((int)ExecutionEngine::NTypedArrayTypes == (int)Heap::TypedArray::NTypes); ReturnedValue Int8ArrayRead(const char *data, int index) { @@ -180,7 +180,7 @@ void Float64ArrayWrite(ExecutionEngine *e, char *data, int index, ValueRef value *(double *)(data + index) = v; } -const TypedArrayOperations operations[TypedArray::NTypes] = { +const TypedArrayOperations operations[Heap::TypedArray::NTypes] = { { 1, "Int8Array", Int8ArrayRead, Int8ArrayWrite }, { 1, "Uint8Array", UInt8ArrayRead, UInt8ArrayWrite }, { 1, "Uint8ClampedArray", UInt8ArrayRead, UInt8ClampedArrayWrite }, @@ -193,11 +193,11 @@ const TypedArrayOperations operations[TypedArray::NTypes] = { }; -TypedArrayCtor::Data::Data(ExecutionContext *scope, TypedArray::Type t) +Heap::TypedArrayCtor::TypedArrayCtor(QV4::ExecutionContext *scope, TypedArray::Type t) : Heap::FunctionObject(scope, QLatin1String(operations[t].name)) , type(t) { - setVTable(staticVTable()); + setVTable(QV4::TypedArrayCtor::staticVTable()); } ReturnedValue TypedArrayCtor::construct(Managed *m, CallData *callData) @@ -333,7 +333,7 @@ ReturnedValue TypedArrayCtor::call(Managed *that, CallData *callData) return construct(that, callData); } -TypedArray::Data::Data(ExecutionEngine *e, Type t) +Heap::TypedArray::TypedArray(ExecutionEngine *e, Type t) : Heap::Object(e->typedArrayClasses[t]), type(operations + t) { diff --git a/src/qml/jsruntime/qv4typedarray_p.h b/src/qml/jsruntime/qv4typedarray_p.h index 20a7827bf2..adc3368243 100644 --- a/src/qml/jsruntime/qv4typedarray_p.h +++ b/src/qml/jsruntime/qv4typedarray_p.h @@ -52,8 +52,9 @@ struct TypedArrayOperations { TypedArrayWrite write; }; -struct TypedArray : Object -{ +namespace Heap { + +struct TypedArray : Object { enum Type { Int8Array, UInt8Array, @@ -67,15 +68,31 @@ struct TypedArray : Object NTypes }; - struct Data : Heap::Object { - Data(ExecutionEngine *e, Type t); + TypedArray(ExecutionEngine *e, Type t); + + const TypedArrayOperations *type; + ArrayBuffer *buffer; + uint byteLength; + uint byteOffset; +}; + +struct TypedArrayCtor : FunctionObject { + TypedArrayCtor(QV4::ExecutionContext *scope, TypedArray::Type t); + + TypedArray::Type type; +}; + +struct TypedArrayPrototype : Object { + inline TypedArrayPrototype(ExecutionEngine *e, TypedArray::Type t); + TypedArray::Type type; +}; - const TypedArrayOperations *type; - ArrayBuffer *buffer; - uint byteLength; - uint byteOffset; - }; - V4_OBJECT(Object) + +} + +struct TypedArray : Object +{ + V4_OBJECT2(TypedArray, Object) uint length() const { return d()->byteLength/d()->type->bytesPerElement; @@ -89,13 +106,7 @@ struct TypedArray : Object struct TypedArrayCtor: FunctionObject { - struct Data : Heap::FunctionObject { - Data(ExecutionContext *scope, TypedArray::Type t); - - TypedArray::Type type; - }; - - V4_OBJECT(FunctionObject) + V4_OBJECT2(TypedArrayCtor, FunctionObject) static ReturnedValue construct(Managed *m, CallData *callData); static ReturnedValue call(Managed *that, CallData *callData); @@ -104,16 +115,7 @@ struct TypedArrayCtor: FunctionObject struct TypedArrayPrototype : Object { - struct Data : Heap::Object { - Data(ExecutionEngine *e, TypedArray::Type t) - : Heap::Object(e) - , type(t) - { - setVTable(staticVTable()); - } - TypedArray::Type type; - }; - V4_OBJECT(Object) + V4_OBJECT2(TypedArrayPrototype, Object) void init(ExecutionEngine *engine, TypedArrayCtor *ctor); @@ -126,6 +128,14 @@ struct TypedArrayPrototype : Object static ReturnedValue method_subarray(CallContext *ctx); }; +inline +Heap::TypedArrayPrototype::TypedArrayPrototype(ExecutionEngine *e, TypedArray::Type t) + : Heap::Object(e) + , type(t) +{ + setVTable(QV4::TypedArrayPrototype::staticVTable()); +} + } // namespace QV4 QT_END_NAMESPACE |