diff options
Diffstat (limited to 'src/qml/jsruntime/qv4typedarray_p.h')
-rw-r--r-- | src/qml/jsruntime/qv4typedarray_p.h | 64 |
1 files changed, 37 insertions, 27 deletions
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 |