diff options
author | Lars Knoll <lars.knoll@qt.io> | 2018-08-24 13:56:37 +0200 |
---|---|---|
committer | Lars Knoll <lars.knoll@qt.io> | 2018-08-25 08:30:04 +0000 |
commit | 7bdb46c5aae3da345653fe91fbe9281b39015497 (patch) | |
tree | 779aac192deb1a971df1e52c3fca2b90c013de9c /src/qml/jsruntime/qv4typedarray_p.h | |
parent | 860807b22ab4f7d1c55ce69bb7711dcc777ceefa (diff) |
Clean up the code handling reads and writes into typed arrays
This is a preparation for supporting atomic operations on Typed arrays.
Change-Id: I91d00f3aee3f35fc22e74ee010ed2cbec2d46aae
Reviewed-by: Simon Hausmann <simon.hausmann@qt.io>
Diffstat (limited to 'src/qml/jsruntime/qv4typedarray_p.h')
-rw-r--r-- | src/qml/jsruntime/qv4typedarray_p.h | 33 |
1 files changed, 19 insertions, 14 deletions
diff --git a/src/qml/jsruntime/qv4typedarray_p.h b/src/qml/jsruntime/qv4typedarray_p.h index 11b3a0dabf..a5eabb168c 100644 --- a/src/qml/jsruntime/qv4typedarray_p.h +++ b/src/qml/jsruntime/qv4typedarray_p.h @@ -60,10 +60,26 @@ namespace QV4 { struct ArrayBuffer; -typedef ReturnedValue (*TypedArrayRead)(const char *data, int index); -typedef void (*TypedArrayWrite)(char *data, int index, const Value &value); +typedef ReturnedValue (*TypedArrayRead)(const char *data); +typedef void (*TypedArrayWrite)(char *data, Value value); + +enum TypedArrayType { + Int8Array, + UInt8Array, + UInt8ClampedArray, + Int16Array, + UInt16Array, + Int32Array, + UInt32Array, + Float32Array, + Float64Array, + NTypedArrayTypes +}; struct TypedArrayOperations { + template<typename T> + static constexpr TypedArrayOperations create(const char *name); + int bytesPerElement; const char *name; TypedArrayRead read; @@ -81,18 +97,7 @@ namespace Heap { DECLARE_HEAP_OBJECT(TypedArray, Object) { DECLARE_MARKOBJECTS(TypedArray); - enum Type { - Int8Array, - UInt8Array, - UInt8ClampedArray, - Int16Array, - UInt16Array, - Int32Array, - UInt32Array, - Float32Array, - Float64Array, - NTypes - }; + using Type = TypedArrayType; void init(Type t); }; |