| Absolute File Name: | /home/opencoverage/opencoverage/guest-scripts/qtdeclarative/src/qtdeclarative/src/qml/jsruntime/qv4typedarray_p.h |
| Source code | Switch to Preprocessed file |
| Line | Source | Count | ||||||
|---|---|---|---|---|---|---|---|---|
| 1 | /**************************************************************************** | - | ||||||
| 2 | ** | - | ||||||
| 3 | ** Copyright (C) 2016 The Qt Company Ltd. | - | ||||||
| 4 | ** Contact: https://www.qt.io/licensing/ | - | ||||||
| 5 | ** | - | ||||||
| 6 | ** This file is part of the QtQml module of the Qt Toolkit. | - | ||||||
| 7 | ** | - | ||||||
| 8 | ** $QT_BEGIN_LICENSE:LGPL$ | - | ||||||
| 9 | ** Commercial License Usage | - | ||||||
| 10 | ** Licensees holding valid commercial Qt licenses may use this file in | - | ||||||
| 11 | ** accordance with the commercial license agreement provided with the | - | ||||||
| 12 | ** Software or, alternatively, in accordance with the terms contained in | - | ||||||
| 13 | ** a written agreement between you and The Qt Company. For licensing terms | - | ||||||
| 14 | ** and conditions see https://www.qt.io/terms-conditions. For further | - | ||||||
| 15 | ** information use the contact form at https://www.qt.io/contact-us. | - | ||||||
| 16 | ** | - | ||||||
| 17 | ** GNU Lesser General Public License Usage | - | ||||||
| 18 | ** Alternatively, this file may be used under the terms of the GNU Lesser | - | ||||||
| 19 | ** General Public License version 3 as published by the Free Software | - | ||||||
| 20 | ** Foundation and appearing in the file LICENSE.LGPL3 included in the | - | ||||||
| 21 | ** packaging of this file. Please review the following information to | - | ||||||
| 22 | ** ensure the GNU Lesser General Public License version 3 requirements | - | ||||||
| 23 | ** will be met: https://www.gnu.org/licenses/lgpl-3.0.html. | - | ||||||
| 24 | ** | - | ||||||
| 25 | ** GNU General Public License Usage | - | ||||||
| 26 | ** Alternatively, this file may be used under the terms of the GNU | - | ||||||
| 27 | ** General Public License version 2.0 or (at your option) the GNU General | - | ||||||
| 28 | ** Public license version 3 or any later version approved by the KDE Free | - | ||||||
| 29 | ** Qt Foundation. The licenses are as published by the Free Software | - | ||||||
| 30 | ** Foundation and appearing in the file LICENSE.GPL2 and LICENSE.GPL3 | - | ||||||
| 31 | ** included in the packaging of this file. Please review the following | - | ||||||
| 32 | ** information to ensure the GNU General Public License requirements will | - | ||||||
| 33 | ** be met: https://www.gnu.org/licenses/gpl-2.0.html and | - | ||||||
| 34 | ** https://www.gnu.org/licenses/gpl-3.0.html. | - | ||||||
| 35 | ** | - | ||||||
| 36 | ** $QT_END_LICENSE$ | - | ||||||
| 37 | ** | - | ||||||
| 38 | ****************************************************************************/ | - | ||||||
| 39 | #ifndef QV4TYPEDARRAY_H | - | ||||||
| 40 | #define QV4TYPEDARRAY_H | - | ||||||
| 41 | - | |||||||
| 42 | // | - | ||||||
| 43 | // W A R N I N G | - | ||||||
| 44 | // ------------- | - | ||||||
| 45 | // | - | ||||||
| 46 | // This file is not part of the Qt API. It exists purely as an | - | ||||||
| 47 | // implementation detail. This header file may change from version to | - | ||||||
| 48 | // version without notice, or even be removed. | - | ||||||
| 49 | // | - | ||||||
| 50 | // We mean it. | - | ||||||
| 51 | // | - | ||||||
| 52 | - | |||||||
| 53 | #include "qv4object_p.h" | - | ||||||
| 54 | #include "qv4functionobject_p.h" | - | ||||||
| 55 | #include "qv4arraybuffer_p.h" | - | ||||||
| 56 | - | |||||||
| 57 | QT_BEGIN_NAMESPACE | - | ||||||
| 58 | - | |||||||
| 59 | namespace QV4 { | - | ||||||
| 60 | - | |||||||
| 61 | struct ArrayBuffer; | - | ||||||
| 62 | - | |||||||
| 63 | typedef ReturnedValue (*TypedArrayRead)(const char *data, int index); | - | ||||||
| 64 | typedef void (*TypedArrayWrite)(ExecutionEngine *engine, char *data, int index, const Value &value); | - | ||||||
| 65 | - | |||||||
| 66 | struct TypedArrayOperations { | - | ||||||
| 67 | int bytesPerElement; | - | ||||||
| 68 | const char *name; | - | ||||||
| 69 | TypedArrayRead read; | - | ||||||
| 70 | TypedArrayWrite write; | - | ||||||
| 71 | }; | - | ||||||
| 72 | - | |||||||
| 73 | namespace Heap { | - | ||||||
| 74 | - | |||||||
| 75 | #define TypedArrayMembers(class, Member) \ | - | ||||||
| 76 | Member(class, Pointer, ArrayBuffer *, buffer) \ | - | ||||||
| 77 | Member(class, NoMark, const TypedArrayOperations *, type) \ | - | ||||||
| 78 | Member(class, NoMark, uint, byteLength) \ | - | ||||||
| 79 | Member(class, NoMark, uint, byteOffset) \ | - | ||||||
| 80 | Member(class, NoMark, uint, arrayType) | - | ||||||
| 81 | - | |||||||
| 82 | DECLARE_HEAP_OBJECT(TypedArray, Object) { | - | ||||||
| 83 | DECLARE_MARKOBJECTS(TypedArray); never executed: end of blocknever executed: o->buffer.heapObject()->mark(stack);
| 0 | ||||||
| 84 | enum Type { | - | ||||||
| 85 | Int8Array, | - | ||||||
| 86 | UInt8Array, | - | ||||||
| 87 | UInt8ClampedArray, | - | ||||||
| 88 | Int16Array, | - | ||||||
| 89 | UInt16Array, | - | ||||||
| 90 | Int32Array, | - | ||||||
| 91 | UInt32Array, | - | ||||||
| 92 | Float32Array, | - | ||||||
| 93 | Float64Array, | - | ||||||
| 94 | NTypes | - | ||||||
| 95 | }; | - | ||||||
| 96 | - | |||||||
| 97 | void init(Type t); | - | ||||||
| 98 | }; | - | ||||||
| 99 | - | |||||||
| 100 | struct IntrinsicTypedArrayCtor : FunctionObject { | - | ||||||
| 101 | }; | - | ||||||
| 102 | - | |||||||
| 103 | struct TypedArrayCtor : FunctionObject { | - | ||||||
| 104 | void init(QV4::ExecutionContext *scope, TypedArray::Type t); | - | ||||||
| 105 | - | |||||||
| 106 | TypedArray::Type type; | - | ||||||
| 107 | }; | - | ||||||
| 108 | - | |||||||
| 109 | struct IntrinsicTypedArrayPrototype : Object { | - | ||||||
| 110 | }; | - | ||||||
| 111 | - | |||||||
| 112 | struct TypedArrayPrototype : Object { | - | ||||||
| 113 | inline void init(TypedArray::Type t); | - | ||||||
| 114 | TypedArray::Type type; | - | ||||||
| 115 | }; | - | ||||||
| 116 | - | |||||||
| 117 | - | |||||||
| 118 | } | - | ||||||
| 119 | - | |||||||
| 120 | struct Q_QML_PRIVATE_EXPORT TypedArray : Object | - | ||||||
| 121 | { | - | ||||||
| 122 | V4_OBJECT2(TypedArray, Object) executed 86738 times by 2 tests: end of blockExecuted by:
never executed: end of blockexecuted 161276 times by 2 tests: return &static_vtbl;Executed by:
executed 451842 times by 2 tests: return static_cast<QV4::Heap::TypedArray *>(m());Executed by:
executed 451918 times by 2 tests: return dptr;Executed by:
| 0-451918 | ||||||
| 123 | - | |||||||
| 124 | static Heap::TypedArray *create(QV4::ExecutionEngine *e, Heap::TypedArray::Type t); | - | ||||||
| 125 | - | |||||||
| 126 | uint byteLength() const { | - | ||||||
| 127 | return d()->byteLength; never executed: return d()->byteLength; | 0 | ||||||
| 128 | } | - | ||||||
| 129 | - | |||||||
| 130 | uint length() const { | - | ||||||
| 131 | return d()->byteLength/d()->type->bytesPerElement; executed 12462 times by 1 test: return d()->byteLength/d()->type->bytesPerElement;Executed by:
| 12462 | ||||||
| 132 | } | - | ||||||
| 133 | - | |||||||
| 134 | QTypedArrayData<char> *arrayData() { | - | ||||||
| 135 | return d()->buffer->data; never executed: return d()->buffer->data; | 0 | ||||||
| 136 | } | - | ||||||
| 137 | - | |||||||
| 138 | Heap::TypedArray::Type arrayType() const { | - | ||||||
| 139 | return static_cast<Heap::TypedArray::Type>(d()->arrayType); never executed: return static_cast<Heap::TypedArray::Type>(d()->arrayType); | 0 | ||||||
| 140 | } | - | ||||||
| 141 | using Object::get; | - | ||||||
| 142 | - | |||||||
| 143 | static ReturnedValue virtualGet(const Managed *m, PropertyKey id, const Value *receiver, bool *hasProperty); | - | ||||||
| 144 | static bool virtualPut(Managed *m, PropertyKey id, const Value &value, Value *receiver); | - | ||||||
| 145 | }; | - | ||||||
| 146 | - | |||||||
| 147 | struct IntrinsicTypedArrayCtor: FunctionObject | - | ||||||
| 148 | { | - | ||||||
| 149 | V4_OBJECT2(IntrinsicTypedArrayCtor, FunctionObject) never executed: end of blocknever executed: end of blockexecuted 296354 times by 153 tests: return &static_vtbl;Executed by:
executed 197751 times by 153 tests: return static_cast<QV4::Heap::IntrinsicTypedArrayCtor *>(m());Executed by:
executed 98963 times by 153 tests: return dptr;Executed by:
| 0-296354 | ||||||
| 150 | - | |||||||
| 151 | static ReturnedValue virtualCallAsConstructor(const FunctionObject *f, const Value *argv, int argc, const Value *); | - | ||||||
| 152 | static ReturnedValue virtualCall(const FunctionObject *f, const Value *thisObject, const Value *argv, int argc); | - | ||||||
| 153 | }; | - | ||||||
| 154 | - | |||||||
| 155 | struct TypedArrayCtor: FunctionObject | - | ||||||
| 156 | { | - | ||||||
| 157 | V4_OBJECT2(TypedArrayCtor, FunctionObject) never executed: end of blocknever executed: end of blockexecuted 2668017 times by 153 tests: return &static_vtbl;Executed by:
executed 3610027 times by 153 tests: return static_cast<QV4::Heap::TypedArrayCtor *>(m());Executed by:
executed 2722927 times by 153 tests: return dptr;Executed by:
| 0-3610027 | ||||||
| 158 | - | |||||||
| 159 | static ReturnedValue virtualCallAsConstructor(const FunctionObject *f, const Value *argv, int argc, const Value *); | - | ||||||
| 160 | static ReturnedValue virtualCall(const FunctionObject *f, const Value *thisObject, const Value *argv, int argc); | - | ||||||
| 161 | }; | - | ||||||
| 162 | - | |||||||
| 163 | struct IntrinsicTypedArrayPrototype : Object | - | ||||||
| 164 | { | - | ||||||
| 165 | V4_OBJECT2(IntrinsicTypedArrayPrototype, Object) never executed: end of blocknever executed: end of blockexecuted 296351 times by 153 tests: return &static_vtbl;Executed by:
executed 197444 times by 153 tests: return static_cast<QV4::Heap::IntrinsicTypedArrayPrototype *>(m());Executed by:
executed 98906 times by 153 tests: return dptr;Executed by:
| 0-296351 | ||||||
| 166 | V4_PROTOTYPE(objectPrototype) executed 98966 times by 153 tests: return e->objectPrototype();Executed by:
| 98966 | ||||||
| 167 | - | |||||||
| 168 | void init(ExecutionEngine *engine, IntrinsicTypedArrayCtor *ctor); | - | ||||||
| 169 | - | |||||||
| 170 | static ReturnedValue method_get_buffer(const FunctionObject *, const Value *thisObject, const Value *argv, int argc); | - | ||||||
| 171 | static ReturnedValue method_get_byteLength(const FunctionObject *, const Value *thisObject, const Value *argv, int argc); | - | ||||||
| 172 | static ReturnedValue method_get_byteOffset(const FunctionObject *, const Value *thisObject, const Value *argv, int argc); | - | ||||||
| 173 | static ReturnedValue method_get_length(const FunctionObject *, const Value *thisObject, const Value *argv, int argc); | - | ||||||
| 174 | - | |||||||
| 175 | static ReturnedValue method_entries(const FunctionObject *, const Value *thisObject, const Value *argv, int argc); | - | ||||||
| 176 | static ReturnedValue method_keys(const FunctionObject *, const Value *thisObject, const Value *argv, int argc); | - | ||||||
| 177 | static ReturnedValue method_values(const FunctionObject *, const Value *thisObject, const Value *argv, int argc); | - | ||||||
| 178 | static ReturnedValue method_set(const FunctionObject *, const Value *thisObject, const Value *argv, int argc); | - | ||||||
| 179 | static ReturnedValue method_subarray(const FunctionObject *, const Value *thisObject, const Value *argv, int argc); | - | ||||||
| 180 | - | |||||||
| 181 | static ReturnedValue method_get_toStringTag(const FunctionObject *, const Value *thisObject, const Value *argv, int argc); | - | ||||||
| 182 | - | |||||||
| 183 | }; | - | ||||||
| 184 | - | |||||||
| 185 | struct TypedArrayPrototype : Object | - | ||||||
| 186 | { | - | ||||||
| 187 | V4_OBJECT2(TypedArrayPrototype, Object) executed 888953 times by 153 tests: end of blockExecuted by:
never executed: end of blockexecuted 3555449 times by 153 tests: return &static_vtbl;Executed by:
executed 1777005 times by 153 tests: return static_cast<QV4::Heap::TypedArrayPrototype *>(m());Executed by:
executed 888748 times by 153 tests: return dptr;Executed by:
| 0-3555449 | ||||||
| 188 | V4_PROTOTYPE(objectPrototype) executed 889923 times by 153 tests: return e->objectPrototype();Executed by:
| 889923 | ||||||
| 189 | - | |||||||
| 190 | void init(ExecutionEngine *engine, TypedArrayCtor *ctor); | - | ||||||
| 191 | }; | - | ||||||
| 192 | - | |||||||
| 193 | inline void | - | ||||||
| 194 | Heap::TypedArrayPrototype::init(TypedArray::Type t) | - | ||||||
| 195 | { | - | ||||||
| 196 | Object::init(); | - | ||||||
| 197 | type = t; | - | ||||||
| 198 | } executed 888846 times by 153 tests: end of blockExecuted by:
| 888846 | ||||||
| 199 | - | |||||||
| 200 | } // namespace QV4 | - | ||||||
| 201 | - | |||||||
| 202 | QT_END_NAMESPACE | - | ||||||
| 203 | - | |||||||
| 204 | #endif | - | ||||||
| Source code | Switch to Preprocessed file |