Remove "All rights reserved" line from license headers.
[profile/ivi/qtdeclarative.git] / src / declarative / qml / qdeclarativeinstruction_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 QtDeclarative 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 QDECLARATIVEINSTRUCTION_P_H
43 #define QDECLARATIVEINSTRUCTION_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/qdeclarativepropertycache_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(QDeclarativeInstruction) - 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(QDeclarativeInstruction::instr_##FMT) + QML_INSTR_ALIGN_MASK) & ~QML_INSTR_ALIGN_MASK)
154
155 class QDeclarativeCompiledData;
156 union QDeclarativeInstruction
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         QDeclarativePropertyRawData property;
223         int owner;
224         int castValue;
225     };
226     struct instr_assignValueInterceptor {
227         QML_INSTR_HEADER
228         QDeclarativePropertyRawData property;
229         int owner;
230         int castValue;
231     };
232     struct instr_initV8Bindings {
233         QML_INSTR_HEADER
234         int program;
235         ushort programIndex;
236         ushort line;
237     };
238     struct instr_assignV4Binding {
239         QML_INSTR_HEADER
240         unsigned int property;
241         int value;
242         short context;
243         short owner;
244         bool isRoot;
245         ushort line;
246         ushort column;
247     };
248     struct instr_assignBinding {
249         QML_INSTR_HEADER
250         QDeclarativePropertyRawData property;
251         int value;
252         short context;
253         short owner;
254         bool isRoot;
255         ushort line;
256         ushort column;
257     };
258     struct instr_fetch {
259         QML_INSTR_HEADER
260         int property;
261         ushort line;
262     };
263     struct instr_fetchValue {
264         QML_INSTR_HEADER
265         int property;
266         int type;
267         quint32 bindingSkipList;
268     };
269     struct instr_fetchQmlList {
270         QML_INSTR_HEADER
271         int property;
272         int type;
273     };
274     struct instr_begin {
275         QML_INSTR_HEADER
276         int castValue;
277     }; 
278     struct instr_storeFloat {
279         QML_INSTR_HEADER
280         int propertyIndex;
281         float value;
282     };
283     struct instr_storeDouble {
284         QML_INSTR_HEADER
285         int propertyIndex;
286         double value;
287     };
288     struct instr_storeInteger {
289         QML_INSTR_HEADER
290         int propertyIndex;
291         int value;
292     };
293     struct instr_storeBool {
294         QML_INSTR_HEADER
295         int propertyIndex;
296         bool value;
297     };
298     struct instr_storeString {
299         QML_INSTR_HEADER
300         int propertyIndex;
301         int value;
302     };
303     struct instr_storeTrString {
304         QML_INSTR_HEADER
305         int propertyIndex;
306         int context;
307         int text;
308         int comment;
309         int n;
310     };
311     struct instr_storeTrIdString {
312         QML_INSTR_HEADER
313         int propertyIndex;
314         int text;
315         int n;
316     };
317     struct instr_storeByteArray {
318         QML_INSTR_HEADER
319         int propertyIndex;
320         int value;
321     };
322     struct instr_storeScriptString {
323         QML_INSTR_HEADER
324         int propertyIndex;
325         int value;
326         int scope;
327         int bindingId;
328         ushort line;
329         ushort column;
330     }; 
331     struct instr_storeScript {
332         QML_INSTR_HEADER
333         int value;
334     };
335     struct instr_storeUrl {
336         QML_INSTR_HEADER
337         int propertyIndex;
338         int value;
339     };
340     struct instr_storeColor {
341         QML_INSTR_HEADER
342         int propertyIndex;
343         unsigned int value;
344     };
345     struct instr_storeDate {
346         QML_INSTR_HEADER
347         int propertyIndex;
348         int value;
349     };
350     struct instr_storeTime {
351         QML_INSTR_HEADER
352         int propertyIndex;
353         struct QTime {
354             int mds;
355 #if defined(Q_OS_WINCE)
356             int startTick;
357 #endif
358         } time;
359     };
360     struct instr_storeDateTime {
361         QML_INSTR_HEADER
362         int propertyIndex;
363         int date;
364         instr_storeTime::QTime time;
365     };
366     struct instr_storeRect {
367         QML_INSTR_HEADER
368         int propertyIndex;
369         struct QRect {
370             int x1;
371             int y1;
372             int x2;
373             int y2;
374         } rect;
375     };
376     struct instr_storeRectF {
377         QML_INSTR_HEADER
378         int propertyIndex;
379         struct QRectF {
380             qreal xp;
381             qreal yp;
382             qreal w;
383             qreal h;
384         } rect;
385     };
386     struct instr_storeObject {
387         QML_INSTR_HEADER
388         int propertyIndex;
389         ushort line;
390     };
391     struct instr_assignCustomType {
392         QML_INSTR_HEADER
393         int propertyIndex;
394         int primitive;
395         int type;
396         ushort line;
397     };
398     struct instr_storeSignal {
399         QML_INSTR_HEADER
400         int signalIndex;
401         int value;
402         short context;
403         ushort line;
404         ushort column;
405     };
406     struct instr_assignSignalObject {
407         QML_INSTR_HEADER
408         int signal;
409         ushort line; 
410     };
411     struct instr_createComponent {
412         QML_INSTR_HEADER
413         int count;
414         int endLine;
415         int metaObject;
416         ushort column;
417         ushort line;
418         bool isRoot;
419     };
420     struct instr_fetchAttached {
421         QML_INSTR_HEADER
422         int id;
423         ushort line;
424     };
425     struct instr_defer {
426         QML_INSTR_HEADER
427         int deferCount;
428     };
429     struct instr_assignObjectList {
430         QML_INSTR_HEADER
431         ushort line;
432     };
433     struct instr_storePoint {
434         QML_INSTR_HEADER
435         int propertyIndex;
436         struct QPoint {
437             int xp;
438             int yp;
439         } point;
440     };
441     struct instr_storePointF {
442         QML_INSTR_HEADER
443         int propertyIndex;
444         struct QPointF {
445             qreal xp;
446             qreal yp;
447         } point;
448     };
449     struct instr_storeSize {
450         QML_INSTR_HEADER
451         int propertyIndex;
452         struct QSize {
453             int wd;
454             int ht;
455         } size;
456     };
457     struct instr_storeSizeF {
458         QML_INSTR_HEADER
459         int propertyIndex;
460         struct QSizeF {
461             qreal wd;
462             qreal ht;
463         } size;
464     };
465     struct instr_storeVector3D {
466         QML_INSTR_HEADER
467         int propertyIndex;
468         struct QVector3D {
469             float xp;
470             float yp;
471             float zp;
472         } vector;
473     };
474     struct instr_storeVector4D {
475         QML_INSTR_HEADER
476         int propertyIndex;
477         struct QVector4D {
478             float xp;
479             float yp;
480             float zp;
481             float wp;
482         } vector;
483     };
484
485     instr_common common;
486     instr_init init;
487     instr_deferInit deferInit;
488     instr_create create;
489     instr_createQml createQml;
490     instr_completeQml completeQml;
491     instr_createSimple createSimple;
492     instr_storeMeta storeMeta;
493     instr_setId setId;
494     instr_assignValueSource assignValueSource;
495     instr_assignValueInterceptor assignValueInterceptor;
496     instr_initV8Bindings initV8Bindings;
497     instr_assignV4Binding assignV4Binding;
498     instr_assignBinding assignBinding;
499     instr_fetch fetch;
500     instr_fetchValue fetchValue;
501     instr_fetchQmlList fetchQmlList;
502     instr_begin begin;
503     instr_storeFloat storeFloat;
504     instr_storeDouble storeDouble;
505     instr_storeInteger storeInteger;
506     instr_storeBool storeBool;
507     instr_storeString storeString;
508     instr_storeTrString storeTrString;
509     instr_storeTrIdString storeTrIdString;
510     instr_storeByteArray storeByteArray;
511     instr_storeScriptString storeScriptString;
512     instr_storeScript storeScript;
513     instr_storeUrl storeUrl;
514     instr_storeColor storeColor;
515     instr_storeDate storeDate;
516     instr_storeTime storeTime;
517     instr_storeDateTime storeDateTime;
518     instr_storePoint storePoint;
519     instr_storePointF storePointF;
520     instr_storeSize storeSize;
521     instr_storeSizeF storeSizeF;
522     instr_storeRect storeRect;
523     instr_storeRectF storeRectF;
524     instr_storeVector3D storeVector3D;
525     instr_storeVector4D storeVector4D;
526     instr_storeObject storeObject;
527     instr_assignCustomType assignCustomType;
528     instr_storeSignal storeSignal;
529     instr_assignSignalObject assignSignalObject;
530     instr_createComponent createComponent;
531     instr_fetchAttached fetchAttached;
532     instr_defer defer;
533     instr_assignObjectList assignObjectList;
534
535     static int size(Type type);
536 };
537
538 template<int N>
539 struct QDeclarativeInstructionMeta {
540 };
541
542 #define QML_INSTR_META_TEMPLATE(I, FMT) \
543     template<> struct QDeclarativeInstructionMeta<(int)QDeclarativeInstruction::I> { \
544         enum { Size = QML_INSTR_SIZE(I, FMT) }; \
545         typedef QDeclarativeInstruction::instr_##FMT DataType; \
546         static const DataType &data(const QDeclarativeInstruction &instr) { return instr.FMT; } \
547         static void setData(QDeclarativeInstruction &instr, const DataType &v) { instr.FMT = v; } \
548     }; 
549 FOR_EACH_QML_INSTR(QML_INSTR_META_TEMPLATE);
550 #undef QML_INSTR_META_TEMPLATE
551
552 template<int Instr>
553 class QDeclarativeInstructionData : public QDeclarativeInstructionMeta<Instr>::DataType
554 {
555 };
556
557 QT_END_NAMESPACE
558
559 #endif // QDECLARATIVEINSTRUCTION_P_H