| 1 | // Copyright (C) 2016 The Qt Company Ltd. | 
|---|
| 2 | // SPDX-License-Identifier: LicenseRef-Qt-Commercial OR LGPL-3.0-only OR GPL-2.0-only OR GPL-3.0-only | 
|---|
| 3 | #ifndef QV4MEMBERDATA_H | 
|---|
| 4 | #define QV4MEMBERDATA_H | 
|---|
| 5 |  | 
|---|
| 6 | // | 
|---|
| 7 | //  W A R N I N G | 
|---|
| 8 | //  ------------- | 
|---|
| 9 | // | 
|---|
| 10 | // This file is not part of the Qt API.  It exists purely as an | 
|---|
| 11 | // implementation detail.  This header file may change from version to | 
|---|
| 12 | // version without notice, or even be removed. | 
|---|
| 13 | // | 
|---|
| 14 | // We mean it. | 
|---|
| 15 | // | 
|---|
| 16 |  | 
|---|
| 17 | #include "qv4global_p.h" | 
|---|
| 18 | #include "qv4managed_p.h" | 
|---|
| 19 |  | 
|---|
| 20 | QT_BEGIN_NAMESPACE | 
|---|
| 21 |  | 
|---|
| 22 | namespace QV4 { | 
|---|
| 23 |  | 
|---|
| 24 | namespace Heap { | 
|---|
| 25 |  | 
|---|
| 26 | #define MemberDataMembers(class, Member) \ | 
|---|
| 27 | Member(class, ValueArray, ValueArray, values) | 
|---|
| 28 |  | 
|---|
| 29 | DECLARE_HEAP_OBJECT(MemberData, Base) { | 
|---|
| 30 | DECLARE_MARKOBJECTS(MemberData) | 
|---|
| 31 | }; | 
|---|
| 32 | Q_STATIC_ASSERT(std::is_trivial_v<MemberData>); | 
|---|
| 33 |  | 
|---|
| 34 | } | 
|---|
| 35 |  | 
|---|
| 36 | struct MemberData : Managed | 
|---|
| 37 | { | 
|---|
| 38 | V4_MANAGED(MemberData, Managed) | 
|---|
| 39 | V4_INTERNALCLASS(MemberData) | 
|---|
| 40 |  | 
|---|
| 41 | const Value &operator[] (uint idx) const { return d()->values[idx]; } | 
|---|
| 42 | const Value *data() const { return d()->values.data(); } | 
|---|
| 43 | void set(EngineBase *e, uint index, Value v) { d()->values.set(e, index, v); } | 
|---|
| 44 | void set(EngineBase *e, uint index, Heap::Base *b) { d()->values.set(e, index, b); } | 
|---|
| 45 |  | 
|---|
| 46 | inline uint size() const { return d()->values.size; } | 
|---|
| 47 |  | 
|---|
| 48 | static Heap::MemberData *allocate(QV4::ExecutionEngine *e, uint n, Heap::MemberData *old = nullptr); | 
|---|
| 49 | }; | 
|---|
| 50 |  | 
|---|
| 51 | } | 
|---|
| 52 |  | 
|---|
| 53 | QT_END_NAMESPACE | 
|---|
| 54 |  | 
|---|
| 55 | #endif | 
|---|
| 56 |  | 
|---|