|
1 /**************************************************************************** |
|
2 ** |
|
3 ** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies). |
|
4 ** All rights reserved. |
|
5 ** Contact: Nokia Corporation (qt-info@nokia.com) |
|
6 ** |
|
7 ** This file is part of the QtDeclarative module of the Qt Toolkit. |
|
8 ** |
|
9 ** $QT_BEGIN_LICENSE:LGPL$ |
|
10 ** No Commercial Usage |
|
11 ** This file contains pre-release code and may not be distributed. |
|
12 ** You may use this file in accordance with the terms and conditions |
|
13 ** contained in the Technology Preview License Agreement accompanying |
|
14 ** this package. |
|
15 ** |
|
16 ** GNU Lesser General Public License Usage |
|
17 ** Alternatively, this file may be used under the terms of the GNU Lesser |
|
18 ** General Public License version 2.1 as published by the Free Software |
|
19 ** Foundation and appearing in the file LICENSE.LGPL included in the |
|
20 ** packaging of this file. Please review the following information to |
|
21 ** ensure the GNU Lesser General Public License version 2.1 requirements |
|
22 ** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. |
|
23 ** |
|
24 ** In addition, as a special exception, Nokia gives you certain additional |
|
25 ** rights. These rights are described in the Nokia Qt LGPL Exception |
|
26 ** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. |
|
27 ** |
|
28 ** If you have questions regarding the use of this file, please contact |
|
29 ** Nokia at qt-info@nokia.com. |
|
30 ** |
|
31 ** |
|
32 ** |
|
33 ** |
|
34 ** |
|
35 ** |
|
36 ** |
|
37 ** |
|
38 ** $QT_END_LICENSE$ |
|
39 ** |
|
40 ****************************************************************************/ |
|
41 |
|
42 #ifndef QDECLARATIVEVMEMETAOBJECT_P_H |
|
43 #define QDECLARATIVEVMEMETAOBJECT_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 "qdeclarative.h" |
|
57 |
|
58 #include <QtCore/QMetaObject> |
|
59 #include <QtCore/QBitArray> |
|
60 #include <QtCore/QPair> |
|
61 #include <QtGui/QColor> |
|
62 #include <QtCore/QDate> |
|
63 #include <QtCore/qlist.h> |
|
64 #include <QtCore/qdebug.h> |
|
65 |
|
66 #include <private/qobject_p.h> |
|
67 |
|
68 #include "private/qdeclarativeguard_p.h" |
|
69 #include "private/qdeclarativecompiler_p.h" |
|
70 #include "private/qdeclarativecontext_p.h" |
|
71 |
|
72 QT_BEGIN_NAMESPACE |
|
73 |
|
74 #define QML_ALIAS_FLAG_PTR 0x00000001 |
|
75 |
|
76 struct QDeclarativeVMEMetaData |
|
77 { |
|
78 short propertyCount; |
|
79 short aliasCount; |
|
80 short signalCount; |
|
81 short methodCount; |
|
82 |
|
83 struct AliasData { |
|
84 int contextIdx; |
|
85 int propertyIdx; |
|
86 int flags; |
|
87 }; |
|
88 |
|
89 struct PropertyData { |
|
90 int propertyType; |
|
91 }; |
|
92 |
|
93 struct MethodData { |
|
94 int parameterCount; |
|
95 int bodyOffset; |
|
96 int bodyLength; |
|
97 int lineNumber; |
|
98 }; |
|
99 |
|
100 PropertyData *propertyData() const { |
|
101 return (PropertyData *)(((const char *)this) + sizeof(QDeclarativeVMEMetaData)); |
|
102 } |
|
103 |
|
104 AliasData *aliasData() const { |
|
105 return (AliasData *)(propertyData() + propertyCount); |
|
106 } |
|
107 |
|
108 MethodData *methodData() const { |
|
109 return (MethodData *)(aliasData() + aliasCount); |
|
110 } |
|
111 }; |
|
112 |
|
113 class QDeclarativeVMEVariant; |
|
114 class QDeclarativeRefCount; |
|
115 class QDeclarativeVMEMetaObject : public QAbstractDynamicMetaObject |
|
116 { |
|
117 public: |
|
118 QDeclarativeVMEMetaObject(QObject *obj, const QMetaObject *other, const QDeclarativeVMEMetaData *data, |
|
119 QDeclarativeCompiledData *compiledData); |
|
120 ~QDeclarativeVMEMetaObject(); |
|
121 |
|
122 void registerInterceptor(int index, int valueIndex, QDeclarativePropertyValueInterceptor *interceptor); |
|
123 QScriptValue vmeMethod(int index); |
|
124 QScriptValue vmeProperty(int index); |
|
125 void setVMEProperty(int index, const QScriptValue &); |
|
126 |
|
127 protected: |
|
128 virtual int metaCall(QMetaObject::Call _c, int _id, void **_a); |
|
129 |
|
130 private: |
|
131 QObject *object; |
|
132 QDeclarativeCompiledData *compiledData; |
|
133 QDeclarativeGuardedContextData ctxt; |
|
134 |
|
135 const QDeclarativeVMEMetaData *metaData; |
|
136 int propOffset; |
|
137 int methodOffset; |
|
138 |
|
139 QDeclarativeVMEVariant *data; |
|
140 |
|
141 QBitArray aConnected; |
|
142 QBitArray aInterceptors; |
|
143 QHash<int, QPair<int, QDeclarativePropertyValueInterceptor*> > interceptors; |
|
144 |
|
145 QScriptValue *methods; |
|
146 QScriptValue method(int); |
|
147 |
|
148 QScriptValue readVarProperty(int); |
|
149 QVariant readVarPropertyAsVariant(int); |
|
150 void writeVarProperty(int, const QScriptValue &); |
|
151 void writeVarProperty(int, const QVariant &); |
|
152 |
|
153 QAbstractDynamicMetaObject *parent; |
|
154 |
|
155 void listChanged(int); |
|
156 class List : public QList<QObject*> |
|
157 { |
|
158 public: |
|
159 List(int lpi) : notifyIndex(lpi) {} |
|
160 int notifyIndex; |
|
161 }; |
|
162 QList<List> listProperties; |
|
163 |
|
164 static void list_append(QDeclarativeListProperty<QObject> *, QObject *); |
|
165 static int list_count(QDeclarativeListProperty<QObject> *); |
|
166 static QObject *list_at(QDeclarativeListProperty<QObject> *, int); |
|
167 static void list_clear(QDeclarativeListProperty<QObject> *); |
|
168 }; |
|
169 |
|
170 QT_END_NAMESPACE |
|
171 |
|
172 #endif // QDECLARATIVEVMEMETAOBJECT_P_H |