author | Eckhart Koeppen <eckhart.koppen@nokia.com> |
Fri, 16 Apr 2010 11:39:52 +0300 | |
branch | RCL_3 |
changeset 9 | 740e5562c97f |
parent 4 | 3b1da2848fc7 |
child 30 | 5dc02b23752f |
permissions | -rw-r--r-- |
0 | 1 |
/**************************************************************************** |
2 |
** |
|
4
3b1da2848fc7
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
3 |
** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies). |
0 | 4 |
** All rights reserved. |
5 |
** Contact: Nokia Corporation (qt-info@nokia.com) |
|
6 |
** |
|
7 |
** This file is part of the QtCore 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 QMETAOBJECT_P_H |
|
43 |
#define QMETAOBJECT_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 for the convenience |
|
50 |
// of moc. This header file may change from version to version without notice, |
|
51 |
// or even be removed. |
|
52 |
// |
|
53 |
// We mean it. |
|
54 |
// |
|
55 |
||
56 |
#include <QtCore/qglobal.h> |
|
57 |
#include <QtCore/qobjectdefs.h> |
|
58 |
||
59 |
QT_BEGIN_NAMESPACE |
|
60 |
||
61 |
enum PropertyFlags { |
|
62 |
Invalid = 0x00000000, |
|
63 |
Readable = 0x00000001, |
|
64 |
Writable = 0x00000002, |
|
65 |
Resettable = 0x00000004, |
|
66 |
EnumOrFlag = 0x00000008, |
|
67 |
StdCppSet = 0x00000100, |
|
68 |
// Override = 0x00000200, |
|
69 |
Constant = 0x00000400, |
|
70 |
Final = 0x00000800, |
|
71 |
Designable = 0x00001000, |
|
72 |
ResolveDesignable = 0x00002000, |
|
73 |
Scriptable = 0x00004000, |
|
74 |
ResolveScriptable = 0x00008000, |
|
75 |
Stored = 0x00010000, |
|
76 |
ResolveStored = 0x00020000, |
|
77 |
Editable = 0x00040000, |
|
78 |
ResolveEditable = 0x00080000, |
|
79 |
User = 0x00100000, |
|
80 |
ResolveUser = 0x00200000, |
|
81 |
Notify = 0x00400000 |
|
82 |
}; |
|
83 |
||
84 |
enum MethodFlags { |
|
85 |
AccessPrivate = 0x00, |
|
86 |
AccessProtected = 0x01, |
|
87 |
AccessPublic = 0x02, |
|
88 |
AccessMask = 0x03, //mask |
|
89 |
||
90 |
MethodMethod = 0x00, |
|
91 |
MethodSignal = 0x04, |
|
92 |
MethodSlot = 0x08, |
|
93 |
MethodConstructor = 0x0c, |
|
94 |
MethodTypeMask = 0x0c, |
|
95 |
||
96 |
MethodCompatibility = 0x10, |
|
97 |
MethodCloned = 0x20, |
|
98 |
MethodScriptable = 0x40 |
|
99 |
}; |
|
100 |
||
101 |
enum MetaObjectFlags { |
|
102 |
DynamicMetaObject = 0x01 |
|
103 |
}; |
|
104 |
||
105 |
class QMutex; |
|
106 |
||
107 |
struct QMetaObjectPrivate |
|
108 |
{ |
|
109 |
int revision; |
|
110 |
int className; |
|
111 |
int classInfoCount, classInfoData; |
|
112 |
int methodCount, methodData; |
|
113 |
int propertyCount, propertyData; |
|
114 |
int enumeratorCount, enumeratorData; |
|
115 |
int constructorCount, constructorData; //since revision 2 |
|
116 |
int flags; //since revision 3 |
|
117 |
int signalCount; //since revision 4 |
|
118 |
||
119 |
static inline const QMetaObjectPrivate *get(const QMetaObject *metaobject) |
|
120 |
{ return reinterpret_cast<const QMetaObjectPrivate*>(metaobject->d.data); } |
|
121 |
||
122 |
static int indexOfSignalRelative(const QMetaObject **baseObject, const char* name); |
|
123 |
static int originalClone(const QMetaObject *obj, int local_method_index); |
|
124 |
||
125 |
#ifndef QT_NO_QOBJECT |
|
126 |
//defined in qobject.cpp |
|
4
3b1da2848fc7
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
127 |
enum DisconnectType { DisconnectAll, DisconnectOne }; |
0 | 128 |
static bool connect(const QObject *sender, int signal_index, |
129 |
const QObject *receiver, int method_index, |
|
130 |
int type = 0, int *types = 0); |
|
131 |
static bool disconnect(const QObject *sender, int signal_index, |
|
4
3b1da2848fc7
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
132 |
const QObject *receiver, int method_index, |
3b1da2848fc7
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
133 |
DisconnectType = DisconnectAll); |
0 | 134 |
static inline bool disconnectHelper(QObjectPrivate::Connection *c, |
135 |
const QObject *receiver, int method_index, |
|
4
3b1da2848fc7
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
136 |
QMutex *senderMutex, DisconnectType); |
0 | 137 |
#endif |
138 |
}; |
|
139 |
||
140 |
#ifndef UTILS_H |
|
141 |
// mirrored in moc's utils.h |
|
142 |
static inline bool is_ident_char(char s) |
|
143 |
{ |
|
144 |
return ((s >= 'a' && s <= 'z') |
|
145 |
|| (s >= 'A' && s <= 'Z') |
|
146 |
|| (s >= '0' && s <= '9') |
|
147 |
|| s == '_' |
|
148 |
); |
|
149 |
} |
|
150 |
||
151 |
static inline bool is_space(char s) |
|
152 |
{ |
|
153 |
return (s == ' ' || s == '\t'); |
|
154 |
} |
|
155 |
#endif |
|
156 |
||
157 |
// This code is shared with moc.cpp |
|
158 |
static QByteArray normalizeTypeInternal(const char *t, const char *e, bool fixScope = false, bool adjustConst = true) |
|
159 |
{ |
|
160 |
int len = e - t; |
|
161 |
/* |
|
162 |
Convert 'char const *' into 'const char *'. Start at index 1, |
|
163 |
not 0, because 'const char *' is already OK. |
|
164 |
*/ |
|
165 |
QByteArray constbuf; |
|
166 |
for (int i = 1; i < len; i++) { |
|
167 |
if ( t[i] == 'c' |
|
168 |
&& strncmp(t + i + 1, "onst", 4) == 0 |
|
169 |
&& (i + 5 >= len || !is_ident_char(t[i + 5])) |
|
170 |
&& !is_ident_char(t[i-1]) |
|
171 |
) { |
|
172 |
constbuf = QByteArray(t, len); |
|
173 |
if (is_space(t[i-1])) |
|
174 |
constbuf.remove(i-1, 6); |
|
175 |
else |
|
176 |
constbuf.remove(i, 5); |
|
177 |
constbuf.prepend("const "); |
|
178 |
t = constbuf.data(); |
|
179 |
e = constbuf.data() + constbuf.length(); |
|
180 |
break; |
|
181 |
} |
|
182 |
/* |
|
183 |
We musn't convert 'char * const *' into 'const char **' |
|
184 |
and we must beware of 'Bar<const Bla>'. |
|
185 |
*/ |
|
186 |
if (t[i] == '&' || t[i] == '*' ||t[i] == '<') |
|
187 |
break; |
|
188 |
} |
|
189 |
if (adjustConst && e > t + 6 && strncmp("const ", t, 6) == 0) { |
|
190 |
if (*(e-1) == '&') { // treat const reference as value |
|
191 |
t += 6; |
|
192 |
--e; |
|
193 |
} else if (is_ident_char(*(e-1))) { // treat const value as value |
|
194 |
t += 6; |
|
195 |
} |
|
196 |
} |
|
197 |
QByteArray result; |
|
198 |
result.reserve(len); |
|
199 |
||
200 |
#if 1 |
|
201 |
// consume initial 'const ' |
|
202 |
if (strncmp("const ", t, 6) == 0) { |
|
203 |
t+= 6; |
|
204 |
result += "const "; |
|
205 |
} |
|
206 |
#endif |
|
207 |
||
208 |
// some type substitutions for 'unsigned x' |
|
209 |
if (strncmp("unsigned", t, 8) == 0) { |
|
210 |
// make sure "unsigned" is an isolated word before making substitutions |
|
211 |
if (!t[8] || !is_ident_char(t[8])) { |
|
212 |
if (strncmp(" int", t+8, 4) == 0) { |
|
213 |
t += 8+4; |
|
214 |
result += "uint"; |
|
215 |
} else if (strncmp(" long", t+8, 5) == 0) { |
|
216 |
if ((strlen(t + 8 + 5) < 4 || strncmp(t + 8 + 5, " int", 4) != 0) // preserve '[unsigned] long int' |
|
217 |
&& (strlen(t + 8 + 5) < 5 || strncmp(t + 8 + 5, " long", 5) != 0) // preserve '[unsigned] long long' |
|
218 |
) { |
|
219 |
t += 8+5; |
|
220 |
result += "ulong"; |
|
221 |
} |
|
222 |
} else if (strncmp(" short", t+8, 6) != 0 // preserve unsigned short |
|
223 |
&& strncmp(" char", t+8, 5) != 0) { // preserve unsigned char |
|
224 |
// treat rest (unsigned) as uint |
|
225 |
t += 8; |
|
226 |
result += "uint"; |
|
227 |
} |
|
228 |
} |
|
229 |
} else { |
|
230 |
// discard 'struct', 'class', and 'enum'; they are optional |
|
231 |
// and we don't want them in the normalized signature |
|
232 |
struct { |
|
233 |
const char *keyword; |
|
234 |
int len; |
|
235 |
} optional[] = { |
|
236 |
{ "struct ", 7 }, |
|
237 |
{ "class ", 6 }, |
|
238 |
{ "enum ", 5 }, |
|
239 |
{ 0, 0 } |
|
240 |
}; |
|
241 |
int i = 0; |
|
242 |
do { |
|
243 |
if (strncmp(optional[i].keyword, t, optional[i].len) == 0) { |
|
244 |
t += optional[i].len; |
|
245 |
break; |
|
246 |
} |
|
247 |
} while (optional[++i].keyword != 0); |
|
248 |
} |
|
249 |
||
250 |
while (t != e) { |
|
251 |
char c = *t++; |
|
252 |
if (fixScope && c == ':' && *t == ':' ) { |
|
253 |
++t; |
|
254 |
c = *t++; |
|
255 |
int i = result.size() - 1; |
|
256 |
while (i >= 0 && is_ident_char(result.at(i))) |
|
257 |
--i; |
|
258 |
result.resize(i + 1); |
|
259 |
} |
|
260 |
result += c; |
|
261 |
if (c == '<') { |
|
262 |
//template recursion |
|
263 |
const char* tt = t; |
|
264 |
int templdepth = 1; |
|
265 |
while (t != e) { |
|
266 |
c = *t++; |
|
267 |
if (c == '<') |
|
268 |
++templdepth; |
|
269 |
if (c == '>') |
|
270 |
--templdepth; |
|
271 |
if (templdepth == 0) { |
|
272 |
result += normalizeTypeInternal(tt, t-1, fixScope, false); |
|
273 |
result += c; |
|
274 |
if (*t == '>') |
|
275 |
result += ' '; // avoid >> |
|
276 |
break; |
|
277 |
} |
|
278 |
} |
|
279 |
} |
|
280 |
} |
|
281 |
||
282 |
return result; |
|
283 |
} |
|
284 |
||
285 |
||
286 |
QT_END_NAMESPACE |
|
287 |
||
288 |
#endif |
|
289 |