aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorPasi Keranen <pasi.keranen@digia.com>2015-02-10 13:52:04 +0200
committerPasi Keränen <pasi.keranen@digia.com>2015-02-11 07:25:38 +0000
commit08bd120f012949199ee0c1d20d42a628af01289e (patch)
treeb5bdc008a43cf5b6287b3614840bdf55c6e71de0
parentf09bd9825b29612f98d884460504b07150bcb639 (diff)
Exposed TypedArray private APIs for Canvas3D use.
Exported QV4::TypedArray, QV4::ArrayBuffer and QV4::Heap::ArrayBuffer in to the private API set. Changed ArrayBuffer length in the constructor to size_t instead of int. Added accessor methods to TypedArray array type and byte length. Change-Id: I3f89b8e263012bc90cc665aed5744cbc66379204 Reviewed-by: Simon Hausmann <simon.hausmann@theqtcompany.com>
-rw-r--r--src/qml/jsruntime/qv4arraybuffer.cpp2
-rw-r--r--src/qml/jsruntime/qv4arraybuffer_p.h6
-rw-r--r--src/qml/jsruntime/qv4typedarray.cpp3
-rw-r--r--src/qml/jsruntime/qv4typedarray_p.h15
4 files changed, 20 insertions, 6 deletions
diff --git a/src/qml/jsruntime/qv4arraybuffer.cpp b/src/qml/jsruntime/qv4arraybuffer.cpp
index e288023b80..76d5b6a7b8 100644
--- a/src/qml/jsruntime/qv4arraybuffer.cpp
+++ b/src/qml/jsruntime/qv4arraybuffer.cpp
@@ -82,7 +82,7 @@ ReturnedValue ArrayBufferCtor::method_isView(CallContext *ctx)
}
-Heap::ArrayBuffer::ArrayBuffer(ExecutionEngine *e, int length)
+Heap::ArrayBuffer::ArrayBuffer(ExecutionEngine *e, size_t length)
: Heap::Object(e->emptyClass, e->arrayBufferPrototype.asObject())
{
data = QTypedArrayData<char>::allocate(length + 1);
diff --git a/src/qml/jsruntime/qv4arraybuffer_p.h b/src/qml/jsruntime/qv4arraybuffer_p.h
index b2d24f76bc..3c7faa1ea1 100644
--- a/src/qml/jsruntime/qv4arraybuffer_p.h
+++ b/src/qml/jsruntime/qv4arraybuffer_p.h
@@ -46,8 +46,8 @@ struct ArrayBufferCtor : FunctionObject {
ArrayBufferCtor(QV4::ExecutionContext *scope);
};
-struct ArrayBuffer : Object {
- ArrayBuffer(ExecutionEngine *e, int length);
+struct Q_QML_PRIVATE_EXPORT ArrayBuffer : Object {
+ ArrayBuffer(ExecutionEngine *e, size_t length);
~ArrayBuffer();
QTypedArrayData<char> *data;
@@ -67,7 +67,7 @@ struct ArrayBufferCtor: FunctionObject
};
-struct ArrayBuffer : Object
+struct Q_QML_PRIVATE_EXPORT ArrayBuffer : Object
{
V4_OBJECT2(ArrayBuffer, Object)
V4_NEEDS_DESTROY
diff --git a/src/qml/jsruntime/qv4typedarray.cpp b/src/qml/jsruntime/qv4typedarray.cpp
index ba3ebdd60c..4ddf77188c 100644
--- a/src/qml/jsruntime/qv4typedarray.cpp
+++ b/src/qml/jsruntime/qv4typedarray.cpp
@@ -334,7 +334,8 @@ ReturnedValue TypedArrayCtor::call(Managed *that, CallData *callData)
Heap::TypedArray::TypedArray(ExecutionEngine *e, Type t)
: Heap::Object(e->emptyClass, e->typedArrayPrototype[t].asObject()),
- type(operations + t)
+ type(operations + t),
+ arrayType(t)
{
}
diff --git a/src/qml/jsruntime/qv4typedarray_p.h b/src/qml/jsruntime/qv4typedarray_p.h
index 78949226b8..670a55157c 100644
--- a/src/qml/jsruntime/qv4typedarray_p.h
+++ b/src/qml/jsruntime/qv4typedarray_p.h
@@ -35,6 +35,7 @@
#include "qv4object_p.h"
#include "qv4functionobject_p.h"
+#include "qv4arraybuffer_p.h"
QT_BEGIN_NAMESPACE
@@ -74,6 +75,7 @@ struct TypedArray : Object {
ArrayBuffer *buffer;
uint byteLength;
uint byteOffset;
+ Type arrayType;
};
struct TypedArrayCtor : FunctionObject {
@@ -90,14 +92,25 @@ struct TypedArrayPrototype : Object {
}
-struct TypedArray : Object
+struct Q_QML_PRIVATE_EXPORT TypedArray : Object
{
V4_OBJECT2(TypedArray, Object)
+ uint byteLength() const {
+ return d()->byteLength;
+ }
+
uint length() const {
return d()->byteLength/d()->type->bytesPerElement;
}
+ QTypedArrayData<char> *arrayData() {
+ return d()->buffer->data;
+ }
+
+ Heap::TypedArray::Type arrayType() const {
+ return d()->arrayType;
+ }
static void markObjects(Heap::Base *that, ExecutionEngine *e);
static ReturnedValue getIndexed(Managed *m, uint index, bool *hasProperty);