1 /****************************************************************************
2 **
3 ** Copyright (C) 2015 The Qt Company Ltd.
4 ** Contact: http://www.qt.io/licensing/
5 **
6 ** This file is part of the QtDeclarative module of the Qt Toolkit.
7 **
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 The Qt Company. For licensing terms
14 ** and conditions see http://www.qt.io/terms-conditions. For further
15 ** information use the contact form at http://www.qt.io/contact-us.
16 **
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 or version 3 as published by the Free
20 ** Software Foundation and appearing in the file LICENSE.LGPLv21 and
21 ** LICENSE.LGPLv3 included in the packaging of this file. Please review the
22 ** following information to ensure the GNU Lesser General Public License
23 ** requirements will be met: https://www.gnu.org/licenses/lgpl.html and
24 ** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
25 **
26 ** As a special exception, The Qt Company gives you certain additional
27 ** rights. These rights are described in The Qt Company LGPL Exception
28 ** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
29 **
30 ** GNU General Public License Usage
31 ** Alternatively, this file may be used under the terms of the GNU
32 ** General Public License version 3.0 as published by the Free Software
33 ** Foundation and appearing in the file LICENSE.GPL included in the
34 ** packaging of this file.  Please review the following information to
35 ** ensure the GNU General Public License version 3.0 requirements will be
36 ** met: http://www.gnu.org/copyleft/gpl.html.
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 
58 QT_BEGIN_NAMESPACE
59 
60 class QDeclarativeCompiledData;
61 class Q_AUTOTEST_EXPORT QDeclarativeInstruction
62 {
63 public:
64     enum Type {
65         //
66         // Object Creation
67         //
68         //    CreateObject - Create a new object instance and push it on the
69         //                   object stack
70         //    SetId - Set the id of the object on the top of the object stack
71         //    SetDefault - Sets the instance on the top of the object stack to
72         //                 be the context's default object.
73         //    StoreMetaObject - Assign the dynamic metaobject to object on the
74         //                      top of the stack.
75         Init,                     /* init */
76         CreateObject,             /* create */
77         CreateSimpleObject,       /* createSimple */
78         SetId,                    /* setId */
79         SetDefault,
80         CreateComponent,          /* createComponent */
81         StoreMetaObject,          /* storeMeta */
82 
83         //
84         // Precomputed single assignment
85         //
86         //    StoreFloat - Store a float in a core property
87         //    StoreDouble - Store a double in a core property
88         //    StoreInteger - Store a int or uint in a core property
89         //    StoreBool - Store a bool in a core property
90         //    StoreString - Store a QString in a core property
91         //    StoreUrl - Store a QUrl in a core property
92         //    StoreColor - Store a QColor in a core property
93         //    StoreDate - Store a QDate in a core property
94         //    StoreTime - Store a QTime in a core property
95         //    StoreDateTime - Store a QDateTime in a core property
96         //    StoreVariant - Store a QVariant in a core property
97         //    StoreObject - Pop the object on the top of the object stack and
98         //                  store it in a core property
99         StoreFloat,               /* storeFloat */
100         StoreDouble,              /* storeDouble */
101         StoreInteger,             /* storeInteger */
102         StoreBool,                /* storeBool */
103         StoreString,              /* storeString */
104         StoreUrl,                 /* storeUrl */
105         StoreColor,               /* storeColor */
106         StoreDate,                /* storeDate */
107         StoreTime,                /* storeTime */
108         StoreDateTime,            /* storeDateTime */
109         StorePoint,               /* storeRealPair */
110         StorePointF,              /* storeRealPair */
111         StoreSize,                /* storeRealPair */
112         StoreSizeF,               /* storeRealPair */
113         StoreRect,                /* storeRect */
114         StoreRectF,               /* storeRect */
115         StoreVector3D,            /* storeVector3D */
116         StoreVariant,             /* storeString */
117         StoreVariantInteger,      /* storeInteger */
118         StoreVariantDouble,       /* storeDouble */
119         StoreVariantBool,         /* storeBool */
120         StoreObject,              /* storeObject */
121         StoreVariantObject,       /* storeObject */
122         StoreInterface,           /* storeObject */
123 
124         StoreSignal,              /* storeSignal */
125         StoreImportedScript,      /* storeScript */
126         StoreScriptString,        /* storeScriptString */
127 
128         //
129         // Unresolved single assignment
130         //
131         AssignSignalObject,       /* assignSignalObject */
132         AssignCustomType,         /* assignCustomType */
133 
134         StoreBinding,             /* assignBinding */
135         StoreBindingOnAlias,      /* assignBinding */
136         StoreCompiledBinding,     /* assignBinding */
137         StoreValueSource,         /* assignValueSource */
138         StoreValueInterceptor,    /* assignValueInterceptor */
139 
140         BeginObject,              /* begin */
141 
142         StoreObjectQList,         /* NA */
143         AssignObjectList,         /* NA */
144 
145         FetchAttached,            /* fetchAttached */
146         FetchQList,               /* fetch */
147         FetchObject,              /* fetch */
148         FetchValueType,           /* fetchValue */
149 
150         //
151         // Stack manipulation
152         //
153         //    PopFetchedObject - Remove an object from the object stack
154         //    PopQList - Remove a list from the list stack
155         PopFetchedObject,
156         PopQList,
157         PopValueType,            /* fetchValue */
158 
159         //
160         // Deferred creation
161         //
162         Defer                    /* defer */
163     };
QDeclarativeInstruction()164     QDeclarativeInstruction()
165         : line(0) {}
166 
167     Type type;
168     unsigned short line;
169 
170     struct InitInstruction {
171         int bindingsSize;
172         int parserStatusSize;
173         int contextCache;
174         int compiledBinding;
175     };
176     struct CreateInstruction {
177         int type;
178         int data;
179         int bindingBits;
180         ushort column;
181     };
182     struct CreateSimpleInstruction {
183         void (*create)(void *);
184         int typeSize;
185         int type;
186         ushort column;
187     };
188     struct StoreMetaInstruction {
189         int data;
190         int aliasData;
191         int propertyCache;
192     };
193     struct SetIdInstruction {
194         int value;
195         int index;
196     };
197     struct AssignValueSourceInstruction {
198         int property;
199         int owner;
200         int castValue;
201     };
202     struct AssignValueInterceptorInstruction {
203         int property;
204         int owner;
205         int castValue;
206     };
207     struct AssignBindingInstruction {
208         unsigned int property;
209         int value;
210         short context;
211         short owner;
212     };
213     struct FetchInstruction {
214         int property;
215     };
216     struct FetchValueInstruction {
217         int property;
218         int type;
219         quint32 bindingSkipList;
220     };
221     struct FetchQmlListInstruction {
222         int property;
223         int type;
224     };
225     struct BeginInstruction {
226         int castValue;
227     };
228     struct StoreFloatInstruction {
229         int propertyIndex;
230         float value;
231     };
232     struct StoreDoubleInstruction {
233         int propertyIndex;
234         double value;
235     };
236     struct StoreIntegerInstruction {
237         int propertyIndex;
238         int value;
239     };
240     struct StoreBoolInstruction {
241         int propertyIndex;
242         bool value;
243     };
244     struct StoreStringInstruction {
245         int propertyIndex;
246         int value;
247     };
248     struct StoreScriptStringInstruction {
249         int propertyIndex;
250         int value;
251         int scope;
252     };
253     struct StoreScriptInstruction {
254         int value;
255     };
256     struct StoreUrlInstruction {
257         int propertyIndex;
258         int value;
259     };
260     struct StoreColorInstruction {
261         int propertyIndex;
262         unsigned int value;
263     };
264     struct StoreDateInstruction {
265         int propertyIndex;
266         int value;
267     };
268     struct StoreTimeInstruction {
269         int propertyIndex;
270         int valueIndex;
271     };
272     struct StoreDateTimeInstruction {
273         int propertyIndex;
274         int valueIndex;
275     };
276     struct StoreRealPairInstruction {
277         int propertyIndex;
278         int valueIndex;
279     };
280     struct StoreRectInstruction {
281         int propertyIndex;
282         int valueIndex;
283     };
284     struct StoreVector3DInstruction {
285         int propertyIndex;
286         int valueIndex;
287     };
288     struct StoreObjectInstruction {
289         int propertyIndex;
290     };
291     struct AssignCustomTypeInstruction {
292         int propertyIndex;
293         int valueIndex;
294     };
295     struct StoreSignalInstruction {
296         int signalIndex;
297         int value;
298         short context;
299         int name;
300     };
301     struct AssignSignalObjectInstruction {
302         int signal;
303     };
304     struct CreateComponentInstruction {
305         int count;
306         ushort column;
307         int endLine;
308         int metaObject;
309     };
310     struct FetchAttachedInstruction {
311         int id;
312     };
313     struct DeferInstruction {
314         int deferCount;
315     };
316 
317     union {
318         InitInstruction init;
319         CreateInstruction create;
320         CreateSimpleInstruction createSimple;
321         StoreMetaInstruction storeMeta;
322         SetIdInstruction setId;
323         AssignValueSourceInstruction assignValueSource;
324         AssignValueInterceptorInstruction assignValueInterceptor;
325         AssignBindingInstruction assignBinding;
326         FetchInstruction fetch;
327         FetchValueInstruction fetchValue;
328         FetchQmlListInstruction fetchQmlList;
329         BeginInstruction begin;
330         StoreFloatInstruction storeFloat;
331         StoreDoubleInstruction storeDouble;
332         StoreIntegerInstruction storeInteger;
333         StoreBoolInstruction storeBool;
334         StoreStringInstruction storeString;
335         StoreScriptStringInstruction storeScriptString;
336         StoreScriptInstruction storeScript;
337         StoreUrlInstruction storeUrl;
338         StoreColorInstruction storeColor;
339         StoreDateInstruction storeDate;
340         StoreTimeInstruction storeTime;
341         StoreDateTimeInstruction storeDateTime;
342         StoreRealPairInstruction storeRealPair;
343         StoreRectInstruction storeRect;
344         StoreVector3DInstruction storeVector3D;
345         StoreObjectInstruction storeObject;
346         AssignCustomTypeInstruction assignCustomType;
347         StoreSignalInstruction storeSignal;
348         AssignSignalObjectInstruction assignSignalObject;
349         CreateComponentInstruction createComponent;
350         FetchAttachedInstruction fetchAttached;
351         DeferInstruction defer;
352     };
353 
354     void dump(QDeclarativeCompiledData *);
355 };
356 
357 QT_END_NAMESPACE
358 
359 #endif // QDECLARATIVEINSTRUCTION_P_H
360