Implement strict mode for qmldir modules
[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(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) \
134     F(Defer, defer) \
135     F(PopFetchedObject, common) \
136     F(FetchValueType, fetchValue) \
137     F(PopValueType, fetchValue) 
138
139 #if defined(Q_CC_GNU) && (!defined(Q_CC_INTEL) || __INTEL_COMPILER >= 1200)
140 #  define QML_THREADED_VME_INTERPRETER
141 #endif
142
143 #ifdef Q_ALIGNOF
144 #  define QML_INSTR_ALIGN_MASK (Q_ALIGNOF(QQmlInstruction) - 1)
145 #else
146 #  define QML_INSTR_ALIGN_MASK (sizeof(void *) - 1)
147 #endif
148
149 #ifdef QML_THREADED_VME_INTERPRETER
150 #  define QML_INSTR_HEADER void *code;
151 #else
152 #  define QML_INSTR_HEADER quint8 instructionType;
153 #endif
154
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)
157
158 class QQmlCompiledData;
159 union QQmlInstruction
160 {
161     enum Type { 
162         FOR_EACH_QML_INSTR(QML_INSTR_ENUM)
163     };
164
165     struct instr_common {
166         QML_INSTR_HEADER
167     };
168     struct instr_init {
169         QML_INSTR_HEADER
170         int bindingsSize;
171         int parserStatusSize;
172         int contextCache;
173         int compiledBinding;
174         int objectStackSize;
175         int listStackSize;
176     };
177     struct instr_deferInit {
178         QML_INSTR_HEADER
179         int bindingsSize;
180         int parserStatusSize;
181         int objectStackSize;
182         int listStackSize;
183     };
184     struct instr_createQml {
185         QML_INSTR_HEADER
186         int type;
187         int bindingBits;
188         bool isRoot;
189     };
190     struct instr_completeQml {
191         QML_INSTR_HEADER
192         ushort column;
193         ushort line; 
194         bool isRoot;
195     };
196     struct instr_create {
197         QML_INSTR_HEADER
198         int type;
199         int data;
200         ushort column;
201         ushort line; 
202         bool isRoot;
203         bool parentToSuper;
204     };
205     struct instr_createSimple {
206         QML_INSTR_HEADER
207         void (*create)(void *);
208         int typeSize;
209         int type;
210         ushort column;
211         ushort line; 
212         bool parentToSuper;
213     };
214     struct instr_storeMeta {
215         QML_INSTR_HEADER
216         int aliasData;
217         int propertyCache;
218     };
219     struct instr_setId {
220         QML_INSTR_HEADER
221         int value;
222         int index;
223     };
224     struct instr_assignValueSource {
225         QML_INSTR_HEADER
226         QQmlPropertyRawData property;
227         int castValue;
228     };
229     struct instr_assignValueInterceptor {
230         QML_INSTR_HEADER
231         QQmlPropertyRawData property;
232         int castValue;
233     };
234     struct instr_initV8Bindings {
235         QML_INSTR_HEADER
236         ushort programIndex;
237         ushort line;
238     };
239     struct instr_assignV4Binding {
240         QML_INSTR_HEADER
241         unsigned int property;
242         int value;
243         int fallbackValue;
244         short context;
245         short owner;
246         bool isRoot;
247         bool isAlias;
248         ushort line;
249         ushort column;
250     };
251     struct instr_assignBinding {
252         QML_INSTR_HEADER
253         QQmlPropertyRawData property;
254         int value;
255         short context;
256         short owner;
257         bool isRoot;
258         bool isAlias;
259         bool isFallback;
260         ushort line;
261         ushort column;
262     };
263     struct instr_fetch {
264         QML_INSTR_HEADER
265         int property;
266         ushort line;
267     };
268     struct instr_fetchValue {
269         QML_INSTR_HEADER
270         int property;
271         int type;
272         quint32 bindingSkipList;
273     };
274     struct instr_fetchQmlList {
275         QML_INSTR_HEADER
276         int property;
277         int type;
278     };
279     struct instr_begin {
280         QML_INSTR_HEADER
281         int castValue;
282     }; 
283     struct instr_storeFloat {
284         QML_INSTR_HEADER
285         int propertyIndex;
286         float value;
287     };
288     struct instr_storeDouble {
289         QML_INSTR_HEADER
290         int propertyIndex;
291         double value;
292     };
293     struct instr_storeInteger {
294         QML_INSTR_HEADER
295         int propertyIndex;
296         int value;
297     };
298     struct instr_storeBool {
299         QML_INSTR_HEADER
300         int propertyIndex;
301         bool value;
302     };
303     struct instr_storeString {
304         QML_INSTR_HEADER
305         int propertyIndex;
306         int value;
307     };
308     struct instr_storeTrString {
309         QML_INSTR_HEADER
310         int propertyIndex;
311         int context;
312         int text;
313         int comment;
314         int n;
315     };
316     struct instr_storeTrIdString {
317         QML_INSTR_HEADER
318         int propertyIndex;
319         int text;
320         int n;
321     };
322     struct instr_storeByteArray {
323         QML_INSTR_HEADER
324         int propertyIndex;
325         int value;
326     };
327     struct instr_storeScriptString {
328         QML_INSTR_HEADER
329         int propertyIndex;
330         int value;
331         int scope;
332         int bindingId;
333         ushort line;
334         ushort column;
335     }; 
336     struct instr_storeScript {
337         QML_INSTR_HEADER
338         int value;
339     };
340     struct instr_storeUrl {
341         QML_INSTR_HEADER
342         int propertyIndex;
343         int value;
344     };
345     struct instr_storeColor {
346         QML_INSTR_HEADER
347         int propertyIndex;
348         unsigned int value;
349     };
350     struct instr_storeDate {
351         QML_INSTR_HEADER
352         int propertyIndex;
353         int value;
354     };
355     struct instr_storeTime {
356         QML_INSTR_HEADER
357         int propertyIndex;
358         struct QTime {
359             int mds;
360 #if defined(Q_OS_WINCE)
361             int startTick;
362 #endif
363         } time;
364     };
365     struct instr_storeDateTime {
366         QML_INSTR_HEADER
367         int propertyIndex;
368         int date;
369         instr_storeTime::QTime time;
370     };
371     struct instr_storeRect {
372         QML_INSTR_HEADER
373         int propertyIndex;
374         struct QRect {
375             int x1;
376             int y1;
377             int x2;
378             int y2;
379         } rect;
380     };
381     struct instr_storeRectF {
382         QML_INSTR_HEADER
383         int propertyIndex;
384         struct QRectF {
385             qreal xp;
386             qreal yp;
387             qreal w;
388             qreal h;
389         } rect;
390     };
391     struct instr_storeObject {
392         QML_INSTR_HEADER
393         int propertyIndex;
394         ushort line;
395     };
396     struct instr_assignCustomType {
397         QML_INSTR_HEADER
398         int propertyIndex;
399         int primitive;
400         int type;
401         ushort line;
402     };
403     struct instr_storeSignal {
404         QML_INSTR_HEADER
405         int signalIndex;
406         int value;
407         short context;
408         ushort line;
409         ushort column;
410     };
411     struct instr_assignSignalObject {
412         QML_INSTR_HEADER
413         int signal;
414         ushort line; 
415     };
416     struct instr_createComponent {
417         QML_INSTR_HEADER
418         int count;
419         int endLine;
420         int metaObject;
421         ushort column;
422         ushort line;
423         bool isRoot;
424     };
425     struct instr_fetchAttached {
426         QML_INSTR_HEADER
427         int id;
428         ushort line;
429     };
430     struct instr_defer {
431         QML_INSTR_HEADER
432         int deferCount;
433     };
434     struct instr_assignObjectList {
435         QML_INSTR_HEADER
436         ushort line;
437     };
438     struct instr_storePoint {
439         QML_INSTR_HEADER
440         int propertyIndex;
441         struct QPoint {
442             int xp;
443             int yp;
444         } point;
445     };
446     struct instr_storePointF {
447         QML_INSTR_HEADER
448         int propertyIndex;
449         struct QPointF {
450             qreal xp;
451             qreal yp;
452         } point;
453     };
454     struct instr_storeSize {
455         QML_INSTR_HEADER
456         int propertyIndex;
457         struct QSize {
458             int wd;
459             int ht;
460         } size;
461     };
462     struct instr_storeSizeF {
463         QML_INSTR_HEADER
464         int propertyIndex;
465         struct QSizeF {
466             qreal wd;
467             qreal ht;
468         } size;
469     };
470     struct instr_storeVector3D {
471         QML_INSTR_HEADER
472         int propertyIndex;
473         struct QVector3D {
474             float xp;
475             float yp;
476             float zp;
477         } vector;
478     };
479     struct instr_storeVector4D {
480         QML_INSTR_HEADER
481         int propertyIndex;
482         struct QVector4D {
483             float xp;
484             float yp;
485             float zp;
486             float wp;
487         } vector;
488     };
489
490     instr_common common;
491     instr_init init;
492     instr_deferInit deferInit;
493     instr_create create;
494     instr_createQml createQml;
495     instr_completeQml completeQml;
496     instr_createSimple createSimple;
497     instr_storeMeta storeMeta;
498     instr_setId setId;
499     instr_assignValueSource assignValueSource;
500     instr_assignValueInterceptor assignValueInterceptor;
501     instr_initV8Bindings initV8Bindings;
502     instr_assignV4Binding assignV4Binding;
503     instr_assignBinding assignBinding;
504     instr_fetch fetch;
505     instr_fetchValue fetchValue;
506     instr_fetchQmlList fetchQmlList;
507     instr_begin begin;
508     instr_storeFloat storeFloat;
509     instr_storeDouble storeDouble;
510     instr_storeInteger storeInteger;
511     instr_storeBool storeBool;
512     instr_storeString storeString;
513     instr_storeTrString storeTrString;
514     instr_storeTrIdString storeTrIdString;
515     instr_storeByteArray storeByteArray;
516     instr_storeScriptString storeScriptString;
517     instr_storeScript storeScript;
518     instr_storeUrl storeUrl;
519     instr_storeColor storeColor;
520     instr_storeDate storeDate;
521     instr_storeTime storeTime;
522     instr_storeDateTime storeDateTime;
523     instr_storePoint storePoint;
524     instr_storePointF storePointF;
525     instr_storeSize storeSize;
526     instr_storeSizeF storeSizeF;
527     instr_storeRect storeRect;
528     instr_storeRectF storeRectF;
529     instr_storeVector3D storeVector3D;
530     instr_storeVector4D storeVector4D;
531     instr_storeObject storeObject;
532     instr_assignCustomType assignCustomType;
533     instr_storeSignal storeSignal;
534     instr_assignSignalObject assignSignalObject;
535     instr_createComponent createComponent;
536     instr_fetchAttached fetchAttached;
537     instr_defer defer;
538     instr_assignObjectList assignObjectList;
539
540     static int size(Type type);
541 };
542
543 template<int N>
544 struct QQmlInstructionMeta {
545 };
546
547 #define QML_INSTR_META_TEMPLATE(I, FMT) \
548     template<> struct QQmlInstructionMeta<(int)QQmlInstruction::I> { \
549         enum { Size = QML_INSTR_SIZE(I, FMT) }; \
550         typedef QQmlInstruction::instr_##FMT DataType; \
551         static const DataType &data(const QQmlInstruction &instr) { return instr.FMT; } \
552         static void setData(QQmlInstruction &instr, const DataType &v) { instr.FMT = v; } \
553     }; 
554 FOR_EACH_QML_INSTR(QML_INSTR_META_TEMPLATE);
555 #undef QML_INSTR_META_TEMPLATE
556
557 template<int Instr>
558 class QQmlInstructionData : public QQmlInstructionMeta<Instr>::DataType
559 {
560 };
561
562 QT_END_NAMESPACE
563
564 #endif // QQMLINSTRUCTION_P_H