1 /****************************************************************************
3 ** Copyright (C) 2012 Digia Plc and/or its subsidiary(-ies).
4 ** Contact: http://www.qt-project.org/legal
6 ** This file is part of the QtQml module of the Qt Toolkit.
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 Digia. For licensing terms and
14 ** conditions see http://qt.digia.com/licensing. For further information
15 ** use the contact form at http://qt.digia.com/contact-us.
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 2.1 as published by the Free Software
20 ** Foundation and appearing in the file LICENSE.LGPL included in the
21 ** packaging of this file. Please review the following information to
22 ** ensure the GNU Lesser General Public License version 2.1 requirements
23 ** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
25 ** In addition, as a special exception, Digia gives you certain additional
26 ** rights. These rights are described in the Digia Qt LGPL Exception
27 ** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
29 ** GNU General Public License Usage
30 ** Alternatively, this file may be used under the terms of the GNU
31 ** General Public License version 3.0 as published by the Free Software
32 ** Foundation and appearing in the file LICENSE.GPL included in the
33 ** packaging of this file. Please review the following information to
34 ** ensure the GNU General Public License version 3.0 requirements will be
35 ** met: http://www.gnu.org/copyleft/gpl.html.
40 ****************************************************************************/
42 #ifndef QQMLINSTRUCTION_P_H
43 #define QQMLINSTRUCTION_P_H
49 // This file is not part of the Qt API. It exists purely as an
50 // implementation detail. This header file may change from version to
51 // version without notice, or even be removed.
56 #include <QtCore/qglobal.h>
57 #include <private/qqmlpropertycache_p.h>
61 #define FOR_EACH_QML_INSTR(F) \
63 F(DeferInit, deferInit) \
65 F(CreateCppObject, create) \
66 F(CreateQMLObject, createQml) \
67 F(CompleteQMLObject, completeQml) \
68 F(CreateSimpleObject, createSimple) \
70 F(SetDefault, common) \
71 F(CreateComponent, createComponent) \
72 F(StoreMetaObject, storeMeta) \
73 F(StoreVariant, storeString) \
74 F(StoreVariantInteger, storeInteger) \
75 F(StoreVariantDouble, storeDouble) \
76 F(StoreVariantBool, storeBool) \
77 F(StoreVar, storeString) \
78 F(StoreVarInteger, storeInteger) \
79 F(StoreVarDouble, storeDouble) \
80 F(StoreVarBool, storeBool) \
81 F(StoreString, storeString) \
82 F(StoreJSValueString, storeString) \
83 F(StoreJSValueInteger, storeInteger) \
84 F(StoreJSValueDouble, storeDouble) \
85 F(StoreJSValueBool, storeBool) \
86 F(StoreStringList, storeString) \
87 F(StoreStringQList, storeString) \
88 F(StoreTrString, storeTrString) \
89 F(StoreTrIdString, storeTrIdString) \
90 F(StoreByteArray, storeByteArray) \
91 F(StoreUrl, storeUrl) \
92 F(StoreUrlQList, storeUrl) \
93 F(StoreFloat, storeFloat) \
94 F(StoreDouble, storeDouble) \
95 F(StoreDoubleQList, storeDouble) \
96 F(StoreBool, storeBool) \
97 F(StoreBoolQList, storeBool) \
98 F(StoreInteger, storeInteger) \
99 F(StoreIntegerQList, storeInteger) \
100 F(StoreColor, storeColor) \
101 F(StoreDate, storeDate) \
102 F(StoreTime, storeTime) \
103 F(StoreDateTime, storeDateTime) \
104 F(StorePoint, storePoint) \
105 F(StorePointF, storePointF) \
106 F(StoreSize, storeSize) \
107 F(StoreSizeF, storeSizeF) \
108 F(StoreRect, storeRect) \
109 F(StoreRectF, storeRectF) \
110 F(StoreVector3D, storeVector3D) \
111 F(StoreVector4D, storeVector4D) \
112 F(StoreObject, storeObject) \
113 F(AssignCustomType, assignCustomType) \
114 F(AssignSignalObject, assignSignalObject) \
115 F(StoreSignal, storeSignal) \
116 F(StoreImportedScript, storeScript) \
117 F(StoreScriptString, storeScriptString) \
118 F(BeginObject, begin) \
119 F(InitV8Bindings, initV8Bindings) \
120 F(StoreBinding, assignBinding) \
121 F(StoreV8Binding, assignBinding) \
122 F(StoreV4Binding, assignV4Binding) \
123 F(StoreValueSource, assignValueSource) \
124 F(StoreValueInterceptor, assignValueInterceptor) \
125 F(StoreObjectQList, common) \
126 F(AssignObjectList, assignObjectList) \
127 F(StoreVariantObject, storeObject) \
128 F(StoreVarObject, storeObject) \
129 F(StoreInterface, storeObject) \
130 F(FetchAttached, fetchAttached) \
131 F(FetchQList, fetchQmlList) \
132 F(FetchObject, fetch) \
133 F(PopQList, common) \
135 F(PopFetchedObject, common) \
136 F(FetchValueType, fetchValue) \
137 F(PopValueType, fetchValue)
139 #if defined(Q_CC_GNU) && (!defined(Q_CC_INTEL) || __INTEL_COMPILER >= 1200)
140 # define QML_THREADED_VME_INTERPRETER
144 # define QML_INSTR_ALIGN_MASK (Q_ALIGNOF(QQmlInstruction) - 1)
146 # define QML_INSTR_ALIGN_MASK (sizeof(void *) - 1)
149 #ifdef QML_THREADED_VME_INTERPRETER
150 # define QML_INSTR_HEADER void *code;
152 # define QML_INSTR_HEADER quint8 instructionType;
155 #define QML_INSTR_ENUM(I, FMT) I,
156 #define QML_INSTR_SIZE(I, FMT) ((sizeof(QQmlInstruction::instr_##FMT) + QML_INSTR_ALIGN_MASK) & ~QML_INSTR_ALIGN_MASK)
158 class QQmlCompiledData;
159 union QQmlInstruction
162 FOR_EACH_QML_INSTR(QML_INSTR_ENUM)
165 struct instr_common {
171 int parserStatusSize;
177 struct instr_deferInit {
180 int parserStatusSize;
184 struct instr_createQml {
190 struct instr_completeQml {
196 struct instr_create {
203 bool parentToSuper:1;
205 struct instr_createSimple {
207 void (*create)(void *);
214 struct instr_storeMeta {
224 struct instr_assignValueSource {
226 QQmlPropertyRawData property;
229 struct instr_assignValueInterceptor {
231 QQmlPropertyRawData property;
234 struct instr_initV8Bindings {
239 struct instr_assignV4Binding {
241 int property; // ((value type sub-property index << 16) | property index)
252 struct instr_assignBinding {
254 QQmlPropertyRawData property;
270 struct instr_fetchValue {
274 quint32 bindingSkipList;
276 struct instr_fetchQmlList {
285 struct instr_storeFloat {
290 struct instr_storeDouble {
295 struct instr_storeInteger {
300 struct instr_storeBool {
305 struct instr_storeString {
310 struct instr_storeTrString {
318 struct instr_storeTrIdString {
324 struct instr_storeByteArray {
329 struct instr_storeScriptString {
338 bool isStringLiteral:1;
339 bool isNumberLiteral:1;
341 struct instr_storeScript {
345 struct instr_storeUrl {
350 struct instr_storeColor {
355 struct instr_storeDate {
360 struct instr_storeTime {
365 #if defined(Q_OS_WINCE)
370 struct instr_storeDateTime {
374 instr_storeTime::QTime time;
376 struct instr_storeRect {
386 struct instr_storeRectF {
396 struct instr_storeObject {
401 struct instr_assignCustomType {
408 struct instr_storeSignal {
417 struct instr_assignSignalObject {
422 struct instr_createComponent {
431 struct instr_fetchAttached {
440 struct instr_assignObjectList {
444 struct instr_storePoint {
452 struct instr_storePointF {
460 struct instr_storeSize {
468 struct instr_storeSizeF {
476 struct instr_storeVector3D {
485 struct instr_storeVector4D {
498 instr_deferInit deferInit;
500 instr_createQml createQml;
501 instr_completeQml completeQml;
502 instr_createSimple createSimple;
503 instr_storeMeta storeMeta;
505 instr_assignValueSource assignValueSource;
506 instr_assignValueInterceptor assignValueInterceptor;
507 instr_initV8Bindings initV8Bindings;
508 instr_assignV4Binding assignV4Binding;
509 instr_assignBinding assignBinding;
511 instr_fetchValue fetchValue;
512 instr_fetchQmlList fetchQmlList;
514 instr_storeFloat storeFloat;
515 instr_storeDouble storeDouble;
516 instr_storeInteger storeInteger;
517 instr_storeBool storeBool;
518 instr_storeString storeString;
519 instr_storeTrString storeTrString;
520 instr_storeTrIdString storeTrIdString;
521 instr_storeByteArray storeByteArray;
522 instr_storeScriptString storeScriptString;
523 instr_storeScript storeScript;
524 instr_storeUrl storeUrl;
525 instr_storeColor storeColor;
526 instr_storeDate storeDate;
527 instr_storeTime storeTime;
528 instr_storeDateTime storeDateTime;
529 instr_storePoint storePoint;
530 instr_storePointF storePointF;
531 instr_storeSize storeSize;
532 instr_storeSizeF storeSizeF;
533 instr_storeRect storeRect;
534 instr_storeRectF storeRectF;
535 instr_storeVector3D storeVector3D;
536 instr_storeVector4D storeVector4D;
537 instr_storeObject storeObject;
538 instr_assignCustomType assignCustomType;
539 instr_storeSignal storeSignal;
540 instr_assignSignalObject assignSignalObject;
541 instr_createComponent createComponent;
542 instr_fetchAttached fetchAttached;
544 instr_assignObjectList assignObjectList;
546 static int size(Type type);
550 struct QQmlInstructionMeta {
553 #define QML_INSTR_META_TEMPLATE(I, FMT) \
554 template<> struct QQmlInstructionMeta<(int)QQmlInstruction::I> { \
555 enum { Size = QML_INSTR_SIZE(I, FMT) }; \
556 typedef QQmlInstruction::instr_##FMT DataType; \
557 static const DataType &data(const QQmlInstruction &instr) { return instr.FMT; } \
558 static void setData(QQmlInstruction &instr, const DataType &v) { instr.FMT = v; } \
560 FOR_EACH_QML_INSTR(QML_INSTR_META_TEMPLATE);
561 #undef QML_INSTR_META_TEMPLATE
564 class QQmlInstructionData : public QQmlInstructionMeta<Instr>::DataType
570 #endif // QQMLINSTRUCTION_P_H