Rename QDeclarative symbols to QQuick and QQml
[profile/ivi/qtdeclarative.git] / src / qml / qml / qqmlinstruction_p.h
1 /****************************************************************************
2 **
3 ** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
4 ** Contact: http://www.qt-project.org/
5 **
6 ** This file is part of the QtQml module of the Qt Toolkit.
7 **
8 ** $QT_BEGIN_LICENSE:LGPL$
9 ** GNU Lesser General Public License Usage
10 ** This file may be used under the terms of the GNU Lesser General Public
11 ** License version 2.1 as published by the Free Software Foundation and
12 ** appearing in the file LICENSE.LGPL included in the packaging of this
13 ** file. Please review the following information to ensure the GNU Lesser
14 ** General Public License version 2.1 requirements will be met:
15 ** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
16 **
17 ** In addition, as a special exception, Nokia gives you certain additional
18 ** rights. These rights are described in the Nokia Qt LGPL Exception
19 ** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
20 **
21 ** GNU General Public License Usage
22 ** Alternatively, this file may be used under the terms of the GNU General
23 ** Public License version 3.0 as published by the Free Software Foundation
24 ** and appearing in the file LICENSE.GPL included in the packaging of this
25 ** file. Please review the following information to ensure the GNU General
26 ** Public License version 3.0 requirements will be met:
27 ** http://www.gnu.org/copyleft/gpl.html.
28 **
29 ** Other Usage
30 ** Alternatively, this file may be used in accordance with the terms and
31 ** conditions contained in a signed written agreement between you and Nokia.
32 **
33 **
34 **
35 **
36 **
37 **
38 ** $QT_END_LICENSE$
39 **
40 ****************************************************************************/
41
42 #ifndef QQMLINSTRUCTION_P_H
43 #define QQMLINSTRUCTION_P_H
44
45 //
46 //  W A R N I N G
47 //  -------------
48 //
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.
52 //
53 // We mean it.
54 //
55
56 #include <QtCore/qglobal.h>
57 #include <private/qqmlpropertycache_p.h>
58
59 QT_BEGIN_NAMESPACE
60
61 #define FOR_EACH_QML_INSTR(F) \
62     F(Init, init) \
63     F(DeferInit, deferInit) \
64     F(Done, common) \
65     F(CreateCppObject, create) \
66     F(CreateQMLObject, createQml) \
67     F(CompleteQMLObject, completeQml) \
68     F(CreateSimpleObject, createSimple) \
69     F(SetId, setId) \
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(StoreStringList, storeString) \
83     F(StoreStringQList, storeString) \
84     F(StoreTrString, storeTrString) \
85     F(StoreTrIdString, storeTrIdString) \
86     F(StoreByteArray, storeByteArray) \
87     F(StoreUrl, storeUrl) \
88     F(StoreUrlQList, storeUrl) \
89     F(StoreFloat, storeFloat) \
90     F(StoreDouble, storeDouble) \
91     F(StoreDoubleQList, storeDouble) \
92     F(StoreBool, storeBool) \
93     F(StoreBoolQList, storeBool) \
94     F(StoreInteger, storeInteger) \
95     F(StoreIntegerQList, storeInteger) \
96     F(StoreColor, storeColor) \
97     F(StoreDate, storeDate) \
98     F(StoreTime, storeTime) \
99     F(StoreDateTime, storeDateTime) \
100     F(StorePoint, storePoint) \
101     F(StorePointF, storePointF) \
102     F(StoreSize, storeSize) \
103     F(StoreSizeF, storeSizeF) \
104     F(StoreRect, storeRect) \
105     F(StoreRectF, storeRectF) \
106     F(StoreVector3D, storeVector3D) \
107     F(StoreVector4D, storeVector4D) \
108     F(StoreObject, storeObject) \
109     F(AssignCustomType, assignCustomType) \
110     F(AssignSignalObject, assignSignalObject) \
111     F(StoreSignal, storeSignal) \
112     F(StoreImportedScript, storeScript) \
113     F(StoreScriptString, storeScriptString) \
114     F(BeginObject, begin) \
115     F(InitV8Bindings, initV8Bindings) \
116     F(StoreBinding, assignBinding) \
117     F(StoreBindingOnAlias, assignBinding) \
118     F(StoreV8Binding, assignBinding) \
119     F(StoreV4Binding, assignV4Binding) \
120     F(StoreValueSource, assignValueSource) \
121     F(StoreValueInterceptor, assignValueInterceptor) \
122     F(StoreObjectQList, common) \
123     F(AssignObjectList, assignObjectList) \
124     F(StoreVariantObject, storeObject) \
125     F(StoreVarObject, storeObject) \
126     F(StoreInterface, storeObject) \
127     F(FetchAttached, fetchAttached) \
128     F(FetchQList, fetchQmlList) \
129     F(FetchObject, fetch) \
130     F(PopQList, common) \
131     F(Defer, defer) \
132     F(PopFetchedObject, common) \
133     F(FetchValueType, fetchValue) \
134     F(PopValueType, fetchValue) 
135
136 #if defined(Q_CC_GNU) && (!defined(Q_CC_INTEL) || __INTEL_COMPILER >= 1200)
137 #  define QML_THREADED_VME_INTERPRETER
138 #endif
139
140 #ifdef Q_ALIGNOF
141 #  define QML_INSTR_ALIGN_MASK (Q_ALIGNOF(QQmlInstruction) - 1)
142 #else
143 #  define QML_INSTR_ALIGN_MASK (sizeof(void *) - 1)
144 #endif
145
146 #ifdef QML_THREADED_VME_INTERPRETER
147 #  define QML_INSTR_HEADER void *code;
148 #else
149 #  define QML_INSTR_HEADER quint8 instructionType;
150 #endif
151
152 #define QML_INSTR_ENUM(I, FMT)  I,
153 #define QML_INSTR_SIZE(I, FMT) ((sizeof(QQmlInstruction::instr_##FMT) + QML_INSTR_ALIGN_MASK) & ~QML_INSTR_ALIGN_MASK)
154
155 class QQmlCompiledData;
156 union QQmlInstruction
157 {
158     enum Type { 
159         FOR_EACH_QML_INSTR(QML_INSTR_ENUM)
160     };
161
162     struct instr_common {
163         QML_INSTR_HEADER
164     };
165     struct instr_init {
166         QML_INSTR_HEADER
167         int bindingsSize;
168         int parserStatusSize;
169         int contextCache;
170         int compiledBinding;
171         int objectStackSize;
172         int listStackSize;
173     };
174     struct instr_deferInit {
175         QML_INSTR_HEADER
176         int bindingsSize;
177         int parserStatusSize;
178         int objectStackSize;
179         int listStackSize;
180     };
181     struct instr_createQml {
182         QML_INSTR_HEADER
183         int type;
184         int bindingBits;
185         bool isRoot;
186     };
187     struct instr_completeQml {
188         QML_INSTR_HEADER
189         ushort column;
190         ushort line; 
191         bool isRoot;
192     };
193     struct instr_create {
194         QML_INSTR_HEADER
195         int type;
196         int data;
197         ushort column;
198         ushort line; 
199         bool isRoot;
200     };
201     struct instr_createSimple {
202         QML_INSTR_HEADER
203         void (*create)(void *);
204         int typeSize;
205         int type;
206         ushort column;
207         ushort line; 
208     };
209     struct instr_storeMeta {
210         QML_INSTR_HEADER
211         int data;
212         int aliasData;
213         int propertyCache;
214     };
215     struct instr_setId {
216         QML_INSTR_HEADER
217         int value;
218         int index;
219     };
220     struct instr_assignValueSource {
221         QML_INSTR_HEADER
222         QQmlPropertyRawData property;
223         int owner;
224         int castValue;
225     };
226     struct instr_assignValueInterceptor {
227         QML_INSTR_HEADER
228         QQmlPropertyRawData property;
229         int owner;
230         int castValue;
231     };
232     struct instr_initV8Bindings {
233         QML_INSTR_HEADER
234         ushort programIndex;
235         ushort line;
236     };
237     struct instr_assignV4Binding {
238         QML_INSTR_HEADER
239         unsigned int property;
240         int value;
241         short context;
242         short owner;
243         bool isRoot;
244         ushort line;
245         ushort column;
246     };
247     struct instr_assignBinding {
248         QML_INSTR_HEADER
249         QQmlPropertyRawData property;
250         int value;
251         short context;
252         short owner;
253         bool isRoot;
254         ushort line;
255         ushort column;
256     };
257     struct instr_fetch {
258         QML_INSTR_HEADER
259         int property;
260         ushort line;
261     };
262     struct instr_fetchValue {
263         QML_INSTR_HEADER
264         int property;
265         int type;
266         quint32 bindingSkipList;
267     };
268     struct instr_fetchQmlList {
269         QML_INSTR_HEADER
270         int property;
271         int type;
272     };
273     struct instr_begin {
274         QML_INSTR_HEADER
275         int castValue;
276     }; 
277     struct instr_storeFloat {
278         QML_INSTR_HEADER
279         int propertyIndex;
280         float value;
281     };
282     struct instr_storeDouble {
283         QML_INSTR_HEADER
284         int propertyIndex;
285         double value;
286     };
287     struct instr_storeInteger {
288         QML_INSTR_HEADER
289         int propertyIndex;
290         int value;
291     };
292     struct instr_storeBool {
293         QML_INSTR_HEADER
294         int propertyIndex;
295         bool value;
296     };
297     struct instr_storeString {
298         QML_INSTR_HEADER
299         int propertyIndex;
300         int value;
301     };
302     struct instr_storeTrString {
303         QML_INSTR_HEADER
304         int propertyIndex;
305         int context;
306         int text;
307         int comment;
308         int n;
309     };
310     struct instr_storeTrIdString {
311         QML_INSTR_HEADER
312         int propertyIndex;
313         int text;
314         int n;
315     };
316     struct instr_storeByteArray {
317         QML_INSTR_HEADER
318         int propertyIndex;
319         int value;
320     };
321     struct instr_storeScriptString {
322         QML_INSTR_HEADER
323         int propertyIndex;
324         int value;
325         int scope;
326         int bindingId;
327         ushort line;
328         ushort column;
329     }; 
330     struct instr_storeScript {
331         QML_INSTR_HEADER
332         int value;
333     };
334     struct instr_storeUrl {
335         QML_INSTR_HEADER
336         int propertyIndex;
337         int value;
338     };
339     struct instr_storeColor {
340         QML_INSTR_HEADER
341         int propertyIndex;
342         unsigned int value;
343     };
344     struct instr_storeDate {
345         QML_INSTR_HEADER
346         int propertyIndex;
347         int value;
348     };
349     struct instr_storeTime {
350         QML_INSTR_HEADER
351         int propertyIndex;
352         struct QTime {
353             int mds;
354 #if defined(Q_OS_WINCE)
355             int startTick;
356 #endif
357         } time;
358     };
359     struct instr_storeDateTime {
360         QML_INSTR_HEADER
361         int propertyIndex;
362         int date;
363         instr_storeTime::QTime time;
364     };
365     struct instr_storeRect {
366         QML_INSTR_HEADER
367         int propertyIndex;
368         struct QRect {
369             int x1;
370             int y1;
371             int x2;
372             int y2;
373         } rect;
374     };
375     struct instr_storeRectF {
376         QML_INSTR_HEADER
377         int propertyIndex;
378         struct QRectF {
379             qreal xp;
380             qreal yp;
381             qreal w;
382             qreal h;
383         } rect;
384     };
385     struct instr_storeObject {
386         QML_INSTR_HEADER
387         int propertyIndex;
388         ushort line;
389     };
390     struct instr_assignCustomType {
391         QML_INSTR_HEADER
392         int propertyIndex;
393         int primitive;
394         int type;
395         ushort line;
396     };
397     struct instr_storeSignal {
398         QML_INSTR_HEADER
399         int signalIndex;
400         int value;
401         short context;
402         ushort line;
403         ushort column;
404     };
405     struct instr_assignSignalObject {
406         QML_INSTR_HEADER
407         int signal;
408         ushort line; 
409     };
410     struct instr_createComponent {
411         QML_INSTR_HEADER
412         int count;
413         int endLine;
414         int metaObject;
415         ushort column;
416         ushort line;
417         bool isRoot;
418     };
419     struct instr_fetchAttached {
420         QML_INSTR_HEADER
421         int id;
422         ushort line;
423     };
424     struct instr_defer {
425         QML_INSTR_HEADER
426         int deferCount;
427     };
428     struct instr_assignObjectList {
429         QML_INSTR_HEADER
430         ushort line;
431     };
432     struct instr_storePoint {
433         QML_INSTR_HEADER
434         int propertyIndex;
435         struct QPoint {
436             int xp;
437             int yp;
438         } point;
439     };
440     struct instr_storePointF {
441         QML_INSTR_HEADER
442         int propertyIndex;
443         struct QPointF {
444             qreal xp;
445             qreal yp;
446         } point;
447     };
448     struct instr_storeSize {
449         QML_INSTR_HEADER
450         int propertyIndex;
451         struct QSize {
452             int wd;
453             int ht;
454         } size;
455     };
456     struct instr_storeSizeF {
457         QML_INSTR_HEADER
458         int propertyIndex;
459         struct QSizeF {
460             qreal wd;
461             qreal ht;
462         } size;
463     };
464     struct instr_storeVector3D {
465         QML_INSTR_HEADER
466         int propertyIndex;
467         struct QVector3D {
468             float xp;
469             float yp;
470             float zp;
471         } vector;
472     };
473     struct instr_storeVector4D {
474         QML_INSTR_HEADER
475         int propertyIndex;
476         struct QVector4D {
477             float xp;
478             float yp;
479             float zp;
480             float wp;
481         } vector;
482     };
483
484     instr_common common;
485     instr_init init;
486     instr_deferInit deferInit;
487     instr_create create;
488     instr_createQml createQml;
489     instr_completeQml completeQml;
490     instr_createSimple createSimple;
491     instr_storeMeta storeMeta;
492     instr_setId setId;
493     instr_assignValueSource assignValueSource;
494     instr_assignValueInterceptor assignValueInterceptor;
495     instr_initV8Bindings initV8Bindings;
496     instr_assignV4Binding assignV4Binding;
497     instr_assignBinding assignBinding;
498     instr_fetch fetch;
499     instr_fetchValue fetchValue;
500     instr_fetchQmlList fetchQmlList;
501     instr_begin begin;
502     instr_storeFloat storeFloat;
503     instr_storeDouble storeDouble;
504     instr_storeInteger storeInteger;
505     instr_storeBool storeBool;
506     instr_storeString storeString;
507     instr_storeTrString storeTrString;
508     instr_storeTrIdString storeTrIdString;
509     instr_storeByteArray storeByteArray;
510     instr_storeScriptString storeScriptString;
511     instr_storeScript storeScript;
512     instr_storeUrl storeUrl;
513     instr_storeColor storeColor;
514     instr_storeDate storeDate;
515     instr_storeTime storeTime;
516     instr_storeDateTime storeDateTime;
517     instr_storePoint storePoint;
518     instr_storePointF storePointF;
519     instr_storeSize storeSize;
520     instr_storeSizeF storeSizeF;
521     instr_storeRect storeRect;
522     instr_storeRectF storeRectF;
523     instr_storeVector3D storeVector3D;
524     instr_storeVector4D storeVector4D;
525     instr_storeObject storeObject;
526     instr_assignCustomType assignCustomType;
527     instr_storeSignal storeSignal;
528     instr_assignSignalObject assignSignalObject;
529     instr_createComponent createComponent;
530     instr_fetchAttached fetchAttached;
531     instr_defer defer;
532     instr_assignObjectList assignObjectList;
533
534     static int size(Type type);
535 };
536
537 template<int N>
538 struct QQmlInstructionMeta {
539 };
540
541 #define QML_INSTR_META_TEMPLATE(I, FMT) \
542     template<> struct QQmlInstructionMeta<(int)QQmlInstruction::I> { \
543         enum { Size = QML_INSTR_SIZE(I, FMT) }; \
544         typedef QQmlInstruction::instr_##FMT DataType; \
545         static const DataType &data(const QQmlInstruction &instr) { return instr.FMT; } \
546         static void setData(QQmlInstruction &instr, const DataType &v) { instr.FMT = v; } \
547     }; 
548 FOR_EACH_QML_INSTR(QML_INSTR_META_TEMPLATE);
549 #undef QML_INSTR_META_TEMPLATE
550
551 template<int Instr>
552 class QQmlInstructionData : public QQmlInstructionMeta<Instr>::DataType
553 {
554 };
555
556 QT_END_NAMESPACE
557
558 #endif // QQMLINSTRUCTION_P_H