Mercurial > projects > qtd
annotate generator/abstractmetalang.h @ 363:3b0545d4d479
Fixed enums in designated interfaces
author | Max Samukha <maxter@maxter.com> |
---|---|
date | Thu, 10 Jun 2010 00:57:32 +0300 |
parents | 9784459f0750 |
children |
rev | line source |
---|---|
1 | 1 /**************************************************************************** |
2 ** | |
3 ** Copyright (C) 1992-2008 Nokia. All rights reserved. | |
4 ** | |
5 ** This file is part of Qt Jambi. | |
6 ** | |
7 ** * Commercial Usage | |
8 * Licensees holding valid Qt Commercial licenses may use this file in | |
9 * accordance with the Qt Commercial License Agreement provided with the | |
10 * Software or, alternatively, in accordance with the terms contained in | |
11 * a written agreement between you and Nokia. | |
12 * | |
13 * | |
14 * GNU General Public License Usage | |
15 * Alternatively, this file may be used under the terms of the GNU | |
16 * General Public License versions 2.0 or 3.0 as published by the Free | |
17 * Software Foundation and appearing in the file LICENSE.GPL included in | |
18 * the packaging of this file. Please review the following information | |
19 * to ensure GNU General Public Licensing requirements will be met: | |
20 * http://www.fsf.org/licensing/licenses/info/GPLv2.html and | |
21 * http://www.gnu.org/copyleft/gpl.html. In addition, as a special | |
22 * exception, Nokia gives you certain additional rights. These rights | |
23 * are described in the Nokia Qt GPL Exception version 1.2, included in | |
24 * the file GPL_EXCEPTION.txt in this package. | |
25 * | |
26 * Qt for Windows(R) Licensees | |
27 * As a special exception, Nokia, as the sole copyright holder for Qt | |
28 * Designer, grants users of the Qt/Eclipse Integration plug-in the | |
29 * right for the Qt/Eclipse Integration to link to functionality | |
30 * provided by Qt Designer and its related libraries. | |
31 * | |
32 * | |
33 * If you are unsure which license is appropriate for your use, please | |
34 * contact the sales department at qt-sales@nokia.com. | |
35 | |
36 ** | |
37 ** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE | |
38 ** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. | |
39 ** | |
40 ****************************************************************************/ | |
41 | |
42 #ifndef ABSTRACTMETALANG_H | |
43 #define ABSTRACTMETALANG_H | |
44 | |
45 #include "codemodel.h" | |
46 | |
47 #include "typesystem.h" | |
48 | |
49 #include <QHash> | |
50 #include <QSet> | |
51 #include <QStringList> | |
52 #include <QTextStream> | |
53 | |
54 | |
55 class AbstractMeta; | |
56 class AbstractMetaClass; | |
57 class AbstractMetaField; | |
58 class AbstractMetaFunction; | |
59 class AbstractMetaType; | |
60 class AbstractMetaVariable; | |
61 class AbstractMetaArgument; | |
62 class AbstractMetaEnumValue; | |
63 class AbstractMetaEnum; | |
64 class QPropertySpec; | |
65 | |
66 typedef QList<AbstractMetaField *> AbstractMetaFieldList; | |
67 typedef QList<AbstractMetaArgument *> AbstractMetaArgumentList; | |
68 typedef QList<AbstractMetaFunction *> AbstractMetaFunctionList; | |
69 class AbstractMetaClassList : public QList<AbstractMetaClass *> | |
70 { | |
71 public: | |
72 AbstractMetaClass *findClass(const QString &name) const; | |
73 AbstractMetaEnumValue *findEnumValue(const QString &string) const; | |
74 AbstractMetaEnum *findEnum(const EnumTypeEntry *entry) const; | |
75 | |
76 }; | |
77 | |
78 | |
79 | |
80 class AbstractMetaAttributes | |
81 { | |
82 public: | |
83 AbstractMetaAttributes() : m_attributes(0) { }; | |
84 | |
85 enum Attribute { | |
86 None = 0x00000000, | |
87 | |
88 Private = 0x00000001, | |
89 Protected = 0x00000002, | |
90 Public = 0x00000004, | |
91 Friendly = 0x00000008, | |
92 Visibility = 0x0000000f, | |
93 | |
94 Native = 0x00000010, | |
95 Abstract = 0x00000020, | |
96 Static = 0x00000040, | |
97 | |
98 FinalInTargetLang = 0x00000080, | |
99 FinalInCpp = 0x00000100, | |
100 ForceShellImplementation = 0x00000200, | |
101 | |
102 GetterFunction = 0x00000400, | |
103 SetterFunction = 0x00000800, | |
104 | |
105 FinalOverload = 0x00001000, | |
106 InterfaceFunction = 0x00002000, | |
107 | |
108 PropertyReader = 0x00004000, | |
109 PropertyWriter = 0x00008000, | |
110 PropertyResetter = 0x00010000, | |
111 | |
112 Fake = 0x00020000, | |
113 | |
114 Invokable = 0x00040000, | |
115 | |
116 Final = FinalInTargetLang | FinalInCpp | |
117 }; | |
118 | |
119 uint attributes() const { return m_attributes; } | |
120 void setAttributes(uint attributes) { m_attributes = attributes; } | |
121 | |
122 uint originalAttributes() const { return m_originalAttributes; } | |
123 void setOriginalAttributes(uint attributes) { m_originalAttributes = attributes; } | |
124 | |
125 uint visibility() const { return m_attributes & Visibility; } | |
126 void setVisibility(uint visi) { m_attributes = (m_attributes & ~Visibility) | visi; } | |
127 | |
128 void operator+=(Attribute attribute) { m_attributes |= attribute; } | |
129 void operator-=(Attribute attribute) { m_attributes &= ~attribute; } | |
130 | |
131 bool isNative() const { return m_attributes & Native; } | |
132 bool isFinal() const { return (m_attributes & Final) == Final; } | |
133 bool isFinalInTargetLang() const { return m_attributes & FinalInTargetLang; } | |
134 bool isFinalInCpp() const { return m_attributes & FinalInCpp; } | |
135 bool isAbstract() const { return m_attributes & Abstract; } | |
136 bool isStatic() const { return m_attributes & Static; } | |
137 bool isForcedShellImplementation() const { return m_attributes & ForceShellImplementation; } | |
138 bool isInterfaceFunction() const { return m_attributes & InterfaceFunction; } | |
139 bool isFinalOverload() const { return m_attributes & FinalOverload; } | |
140 bool isInvokable() const { return m_attributes & Invokable; } | |
141 | |
142 bool isPropertyReader() const { return m_attributes & PropertyReader; } | |
143 bool isPropertyWriter() const { return m_attributes & PropertyWriter; } | |
144 bool isPropertyResetter() const { return m_attributes & PropertyResetter; } | |
145 | |
146 bool isPrivate() const { return m_attributes & Private; } | |
147 bool isProtected() const { return m_attributes & Protected; } | |
148 bool isPublic() const { return m_attributes & Public; } | |
149 bool isFriendly() const { return m_attributes & Friendly; } | |
150 | |
151 bool wasPrivate() const { return m_originalAttributes & Private; } | |
152 bool wasProtected() const { return m_originalAttributes & Protected; } | |
153 bool wasPublic() const { return m_originalAttributes & Public; } | |
154 bool wasFriendly() const { return m_originalAttributes & Friendly; } | |
155 | |
156 private: | |
157 uint m_attributes; | |
158 uint m_originalAttributes; | |
159 }; | |
160 | |
161 | |
162 class AbstractMetaType | |
163 { | |
164 public: | |
165 enum TypeUsagePattern { | |
166 InvalidPattern, | |
167 PrimitivePattern, | |
168 FlagsPattern, | |
169 EnumPattern, | |
170 ValuePattern, | |
171 StringPattern, | |
172 CharPattern, | |
173 ObjectPattern, | |
174 QObjectPattern, | |
175 NativePointerPattern, | |
176 ContainerPattern, | |
177 VariantPattern, | |
178 JObjectWrapperPattern, | |
179 ArrayPattern, | |
180 ThreadPattern | |
181 }; | |
182 | |
183 AbstractMetaType() : | |
184 m_type_entry(0), | |
185 m_array_element_count(0), | |
186 m_array_element_type(0), | |
187 m_original_template_type(0), | |
188 m_pattern(InvalidPattern), | |
189 m_constant(false), | |
190 m_reference(false), | |
191 m_cpp_instantiation(true), | |
192 m_indirections(0), | |
193 m_reserved(0) | |
194 { | |
195 } | |
196 | |
197 QString package() const { return m_type_entry->javaPackage(); } | |
198 QString name() const { return m_type_entry->targetLangName(); } | |
199 QString fullName() const { return m_type_entry->qualifiedTargetLangName(); } | |
200 | |
201 void setTypeUsagePattern(TypeUsagePattern pattern) { m_pattern = pattern; } | |
202 TypeUsagePattern typeUsagePattern() const { return m_pattern; } | |
203 | |
204 // true when use pattern is container | |
205 bool hasInstantiations() const { return !m_instantiations.isEmpty(); } | |
206 void addInstantiation(AbstractMetaType *inst) { m_instantiations << inst; } | |
207 void setInstantiations(const QList<AbstractMetaType *> &insts) { m_instantiations = insts; } | |
208 QList<AbstractMetaType *> instantiations() const { return m_instantiations; } | |
209 void setInstantiationInCpp(bool incpp) { m_cpp_instantiation = incpp; } | |
210 bool hasInstantiationInCpp() const { return hasInstantiations() && m_cpp_instantiation; } | |
211 | |
212 QString minimalSignature() const; | |
213 | |
214 // true when the type is a QtJambiObject subclass | |
215 bool hasNativeId() const; | |
216 | |
217 // returns true if the typs is used as a non complex primitive, no & or *'s | |
218 bool isPrimitive() const { return m_pattern == PrimitivePattern; } | |
219 | |
220 // returns true if the type is used as an enum | |
221 bool isEnum() const { return m_pattern == EnumPattern; } | |
222 | |
223 // returns true if the type is used as a QObject * | |
224 bool isQObject() const { return m_pattern == QObjectPattern; } | |
225 | |
226 // returns true if the type is used as an object, e.g. Xxx * | |
227 bool isObject() const { return m_pattern == ObjectPattern; } | |
228 | |
229 // returns true if the type is used as an array, e.g. Xxx[42] | |
230 bool isArray() const { return m_pattern == ArrayPattern; } | |
231 | |
232 // returns true if the type is used as a value type (X or const X &) | |
233 bool isValue() const { return m_pattern == ValuePattern; } | |
234 | |
235 // returns true for more complex types... | |
236 bool isNativePointer() const { return m_pattern == NativePointerPattern; } | |
237 | |
238 // returns true if the type was originally a QString or const QString & or equivalent for QLatin1String | |
239 bool isTargetLangString() const { return m_pattern == StringPattern; } | |
240 | |
241 // returns true if the type was originally a QChar or const QChar & | |
242 bool isTargetLangChar() const { return m_pattern == CharPattern; } | |
243 | |
244 // return true if the type was originally a QVariant or const QVariant & | |
245 bool isVariant() const { return m_pattern == VariantPattern; } | |
246 | |
247 // return true if the type was originally a JObjectWrapper or const JObjectWrapper & | |
248 bool isJObjectWrapper() const { return m_pattern == JObjectWrapperPattern; } | |
249 | |
250 // returns true if the type was used as a container | |
251 bool isContainer() const { return m_pattern == ContainerPattern; } | |
252 | |
253 // returns true if the type was used as a flag | |
254 bool isFlags() const { return m_pattern == FlagsPattern; } | |
255 | |
256 // returns true if the type was used as a thread | |
257 bool isThread() const { return m_pattern == ThreadPattern; } | |
258 | |
259 bool isConstant() const { return m_constant; } | |
260 void setConstant(bool constant) { m_constant = constant; } | |
261 | |
262 bool isReference() const { return m_reference; } | |
263 void setReference(bool ref) { m_reference = ref; } | |
264 | |
265 // Returns true if the type is to be implemented using Java enums, e.g. not plain ints. | |
266 bool isTargetLangEnum() const { return isEnum() && !((EnumTypeEntry *) typeEntry())->forceInteger(); } | |
267 bool isIntegerEnum() const { return isEnum() && !isTargetLangEnum(); } | |
268 | |
269 // Returns true if the type is to be implemented using Java QFlags, e.g. not plain ints. | |
270 bool isTargetLangFlags() const { | |
271 return isFlags() && !((FlagsTypeEntry *) typeEntry())->forceInteger(); } | |
272 bool isIntegerFlags() const { return isFlags() && !isTargetLangFlags(); } | |
273 | |
274 int actualIndirections() const { return m_indirections + (isReference() ? 1 : 0); } | |
275 int indirections() const { return m_indirections; } | |
276 void setIndirections(int indirections) { m_indirections = indirections; } | |
277 | |
278 void setArrayElementCount(int n) { m_array_element_count = n; } | |
279 int arrayElementCount() const { return m_array_element_count; } | |
280 | |
281 AbstractMetaType *arrayElementType() const { return m_array_element_type; } | |
282 void setArrayElementType(AbstractMetaType *t) { m_array_element_type = t; } | |
283 | |
284 QString cppSignature() const; | |
285 | |
286 AbstractMetaType *copy() const; | |
287 | |
288 const TypeEntry *typeEntry() const { return m_type_entry; } | |
289 void setTypeEntry(const TypeEntry *type) { m_type_entry = type; } | |
290 | |
291 void setOriginalTypeDescription(const QString &otd) { m_original_type_description = otd; } | |
292 QString originalTypeDescription() const { return m_original_type_description; } | |
293 | |
294 void setOriginalTemplateType(const AbstractMetaType *type) { m_original_template_type = type; } | |
295 const AbstractMetaType *originalTemplateType() const { return m_original_template_type; } | |
296 | |
297 private: | |
298 const TypeEntry *m_type_entry; | |
299 QList <AbstractMetaType *> m_instantiations; | |
300 QString m_package; | |
301 QString m_original_type_description; | |
302 | |
303 int m_array_element_count; | |
304 AbstractMetaType *m_array_element_type; | |
305 const AbstractMetaType *m_original_template_type; | |
306 | |
307 TypeUsagePattern m_pattern; | |
308 uint m_constant : 1; | |
309 uint m_reference : 1; | |
310 uint m_cpp_instantiation : 1; | |
311 int m_indirections : 4; | |
312 uint m_reserved : 25; // unused | |
313 }; | |
314 | |
315 class AbstractMetaVariable | |
316 { | |
317 public: | |
318 AbstractMetaVariable() : m_type(0) { } | |
319 | |
320 AbstractMetaType *type() const { return m_type; } | |
321 void setType(AbstractMetaType *type) { m_type = type; } | |
322 | |
323 QString name() const { return m_name; } | |
324 void setName(const QString &name) { m_name = name; } | |
325 | |
326 private: | |
327 QString m_name; | |
328 AbstractMetaType *m_type; | |
329 }; | |
330 | |
331 | |
332 | |
333 class AbstractMetaArgument : public AbstractMetaVariable | |
334 { | |
335 public: | |
336 AbstractMetaArgument() : m_argument_index(0) { }; | |
337 | |
338 QString defaultValueExpression() const { return m_expression; } | |
339 void setDefaultValueExpression(const QString &expr) { m_expression = expr; } | |
340 | |
341 QString originalDefaultValueExpression() const { return m_original_expression; } | |
342 void setOriginalDefaultValueExpression(const QString &expr) { m_original_expression = expr; } | |
343 | |
344 QString toString() const { return type()->name() + " " + AbstractMetaVariable::name() + | |
345 (m_expression.isEmpty() ? "" : " = " + m_expression); } | |
346 | |
347 int argumentIndex() const { return m_argument_index; } | |
348 void setArgumentIndex(int argIndex) { m_argument_index = argIndex; } | |
349 | |
350 QString argumentName() const; | |
351 QString indexedName() const; | |
352 | |
353 AbstractMetaArgument *copy() const; | |
354 | |
355 private: | |
356 // Just to force people to call argumentName() And indexedName(); | |
357 QString name() const; | |
358 | |
359 QString m_expression; | |
360 QString m_original_expression; | |
361 int m_argument_index; | |
362 }; | |
363 | |
364 | |
365 class AbstractMetaField : public AbstractMetaVariable, public AbstractMetaAttributes | |
366 { | |
367 public: | |
368 AbstractMetaField(); | |
369 ~AbstractMetaField(); | |
370 | |
371 const AbstractMetaClass *enclosingClass() const { return m_class; } | |
372 void setEnclosingClass(const AbstractMetaClass *cls) { m_class = cls; } | |
373 | |
374 const AbstractMetaFunction *getter() const; | |
375 const AbstractMetaFunction *setter() const; | |
376 | |
377 FieldModificationList modifications() const; | |
378 | |
379 AbstractMetaField *copy() const; | |
380 | |
381 private: | |
382 mutable AbstractMetaFunction *m_getter; | |
383 mutable AbstractMetaFunction *m_setter; | |
384 const AbstractMetaClass *m_class; | |
385 }; | |
386 | |
387 | |
388 class AbstractMetaFunction : public AbstractMetaAttributes | |
389 { | |
390 public: | |
391 enum FunctionType { | |
392 ConstructorFunction, | |
393 DestructorFunction, | |
394 NormalFunction, | |
395 SignalFunction, | |
396 EmptyFunction, | |
397 SlotFunction, | |
357
9784459f0750
An attempt (failed due to optlink) to improve locality of declarations exported from QtD executables
Max Samukha <maxter@spambox.com>
parents:
354
diff
changeset
|
398 GlobalScopeFunction, |
1 | 399 }; |
400 | |
401 enum CompareResult { | |
402 EqualName = 0x00000001, | |
403 EqualArguments = 0x00000002, | |
404 EqualAttributes = 0x00000004, | |
405 EqualImplementor = 0x00000008, | |
406 EqualReturnType = 0x00000010, | |
407 EqualDefaultValueOverload = 0x00000020, | |
408 EqualModifiedName = 0x00000040, | |
326
baaf74652f4c
treat const and non-const functions as separate
eldar1@eldar1-laptop
parents:
304
diff
changeset
|
409 EqualConstness = 0x00000080, |
1 | 410 |
411 NameLessThan = 0x00001000, | |
412 | |
326
baaf74652f4c
treat const and non-const functions as separate
eldar1@eldar1-laptop
parents:
304
diff
changeset
|
413 PrettySimilar = EqualName | EqualArguments | EqualConstness, |
1 | 414 Equal = 0x0000001f, |
415 NotEqual = 0x00001000 | |
416 }; | |
417 | |
357
9784459f0750
An attempt (failed due to optlink) to improve locality of declarations exported from QtD executables
Max Samukha <maxter@spambox.com>
parents:
354
diff
changeset
|
418 enum Option |
9784459f0750
An attempt (failed due to optlink) to improve locality of declarations exported from QtD executables
Max Samukha <maxter@spambox.com>
parents:
354
diff
changeset
|
419 { |
9784459f0750
An attempt (failed due to optlink) to improve locality of declarations exported from QtD executables
Max Samukha <maxter@spambox.com>
parents:
354
diff
changeset
|
420 NoOptions = 0, |
9784459f0750
An attempt (failed due to optlink) to improve locality of declarations exported from QtD executables
Max Samukha <maxter@spambox.com>
parents:
354
diff
changeset
|
421 DeclaringClass = 0x01, |
9784459f0750
An attempt (failed due to optlink) to improve locality of declarations exported from QtD executables
Max Samukha <maxter@spambox.com>
parents:
354
diff
changeset
|
422 NoExternNamespace = 0x02 |
9784459f0750
An attempt (failed due to optlink) to improve locality of declarations exported from QtD executables
Max Samukha <maxter@spambox.com>
parents:
354
diff
changeset
|
423 }; |
9784459f0750
An attempt (failed due to optlink) to improve locality of declarations exported from QtD executables
Max Samukha <maxter@spambox.com>
parents:
354
diff
changeset
|
424 |
9784459f0750
An attempt (failed due to optlink) to improve locality of declarations exported from QtD executables
Max Samukha <maxter@spambox.com>
parents:
354
diff
changeset
|
425 typedef QFlags<Option> Options; |
9784459f0750
An attempt (failed due to optlink) to improve locality of declarations exported from QtD executables
Max Samukha <maxter@spambox.com>
parents:
354
diff
changeset
|
426 |
1 | 427 AbstractMetaFunction() |
428 : m_function_type(NormalFunction), | |
429 m_type(0), | |
430 m_class(0), | |
431 m_implementing_class(0), | |
432 m_declaring_class(0), | |
433 m_interface_class(0), | |
434 m_property_spec(0), | |
435 m_constant(false), | |
436 m_invalid(false), | |
437 m_jumptable_id(-1), | |
438 // qtd | |
439 m_store_result(0) | |
440 { | |
441 } | |
442 | |
443 ~AbstractMetaFunction(); | |
444 | |
445 QString name() const { return m_name; } | |
446 void setName(const QString &name) { m_name = name; } | |
447 | |
448 QString originalName() const { return m_original_name.isEmpty() ? name() : m_original_name; } | |
449 void setOriginalName(const QString &name) { m_original_name = name; } | |
450 | |
451 QString modifiedName() const; | |
452 | |
288 | 453 QString minimalSignature(int reduce = 0) const; |
1 | 454 QStringList possibleIntrospectionCompatibleSignatures() const; |
455 | |
357
9784459f0750
An attempt (failed due to optlink) to improve locality of declarations exported from QtD executables
Max Samukha <maxter@spambox.com>
parents:
354
diff
changeset
|
456 QString marshalledName(Options options = NoOptions) const; |
1 | 457 |
458 // true if one or more of the arguments are of QtJambiObject subclasses | |
459 bool argumentsHaveNativeId() const | |
460 { | |
461 foreach (const AbstractMetaArgument *arg, m_arguments) { | |
462 if (arg->type()->hasNativeId()) | |
463 return true; | |
464 } | |
465 | |
466 return false; | |
467 } | |
468 | |
469 bool isModifiedRemoved(int types = TypeSystem::All) const; | |
470 | |
471 AbstractMetaType *type() const { return m_type; } | |
472 void setType(AbstractMetaType *type) { m_type = type; } | |
473 | |
474 // The class that has this function as a member. | |
475 const AbstractMetaClass *ownerClass() const { return m_class; } | |
476 void setOwnerClass(const AbstractMetaClass *cls) { m_class = cls; } | |
477 | |
478 // The first class in a hierarchy that declares the function | |
479 const AbstractMetaClass *declaringClass() const { return m_declaring_class; } | |
480 void setDeclaringClass(const AbstractMetaClass *cls) { m_declaring_class = cls; } | |
481 | |
482 // The class that actually implements this function | |
483 const AbstractMetaClass *implementingClass() const { return m_implementing_class; } | |
484 void setImplementingClass(const AbstractMetaClass *cls) { m_implementing_class = cls; } | |
485 | |
486 bool needsCallThrough() const; | |
487 | |
488 AbstractMetaArgumentList arguments() const { return m_arguments; } | |
489 void setArguments(const AbstractMetaArgumentList &arguments) { m_arguments = arguments; } | |
490 void addArgument(AbstractMetaArgument *argument) { m_arguments << argument; } | |
491 int actualMinimumArgumentCount() const; | |
492 | |
493 void setInvalid(bool on) { m_invalid = on; } | |
494 bool isInvalid() const { return m_invalid; } | |
495 bool isDeprecated() const; | |
496 bool isDestructor() const { return functionType() == DestructorFunction; } | |
497 bool isConstructor() const { return functionType() == ConstructorFunction; } | |
498 bool isNormal() const { return functionType() == NormalFunction || isSlot() || isInGlobalScope(); } | |
499 bool isInGlobalScope() const { return functionType() == GlobalScopeFunction; } | |
500 bool isSignal() const { return functionType() == SignalFunction; } | |
501 bool isSlot() const { return functionType() == SlotFunction; } | |
502 bool isEmptyFunction() const { return functionType() == EmptyFunction; } | |
503 FunctionType functionType() const { return m_function_type; } | |
504 void setFunctionType(FunctionType type) { m_function_type = type; } | |
505 | |
506 QStringList introspectionCompatibleSignatures(const QStringList &resolvedArguments = QStringList()) const; | |
507 QString signature() const; | |
508 QString targetLangSignature(bool minimal = false) const; | |
509 bool shouldReturnThisObject() const { return QLatin1String("this") == argumentReplaced(0); } | |
510 | |
511 bool isConstant() const { return m_constant; } | |
512 void setConstant(bool constant) { m_constant = constant; } | |
513 | |
514 QString toString() const { return m_name; } | |
515 | |
516 uint compareTo(const AbstractMetaFunction *other) const; | |
517 | |
518 bool operator <(const AbstractMetaFunction &a) const; | |
519 | |
520 AbstractMetaFunction *copy() const; | |
521 | |
522 QString replacedDefaultExpression(const AbstractMetaClass *cls, int idx) const; | |
523 bool removedDefaultExpression(const AbstractMetaClass *cls, int idx) const; | |
524 QString conversionRule(TypeSystem::Language language, int idx) const; | |
525 QList<ReferenceCount> referenceCounts(const AbstractMetaClass *cls, int idx = -2) const; | |
526 | |
527 bool nullPointersDisabled(const AbstractMetaClass *cls = 0, int argument_idx = 0) const; | |
528 QString nullPointerDefaultValue(const AbstractMetaClass *cls = 0, int argument_idx = 0) const; | |
529 | |
530 bool resetObjectAfterUse(int argument_idx) const; | |
531 | |
532 // Returns whether garbage collection is disabled for the argument in any context | |
533 bool disabledGarbageCollection(const AbstractMetaClass *cls, int key) const; | |
534 | |
535 // Returns the ownership rules for the given argument in the given context | |
536 TypeSystem::Ownership ownership(const AbstractMetaClass *cls, TypeSystem::Language language, int idx) const; | |
537 | |
538 bool isVirtualSlot() const; | |
539 | |
540 QString typeReplaced(int argument_index) const; | |
541 bool isRemovedFromAllLanguages(const AbstractMetaClass *) const; | |
542 bool isRemovedFrom(const AbstractMetaClass *, TypeSystem::Language language) const; | |
543 bool argumentRemoved(int) const; | |
544 | |
545 QString argumentReplaced(int key) const; | |
546 bool needsSuppressUncheckedWarning() const; | |
547 | |
548 bool hasModifications(const AbstractMetaClass *implementor) const; | |
549 FunctionModificationList modifications(const AbstractMetaClass *implementor) const; | |
550 | |
551 // If this function stems from an interface, this returns the | |
552 // interface that declares it. | |
553 const AbstractMetaClass *interfaceClass() const { return m_interface_class; } | |
554 void setInterfaceClass(const AbstractMetaClass *cl) { m_interface_class = cl; } | |
555 | |
556 void setPropertySpec(QPropertySpec *spec) { m_property_spec = spec; } | |
557 QPropertySpec *propertySpec() const { return m_property_spec; } | |
558 | |
559 int jumpTableId() const { return m_jumptable_id; } | |
560 void setJumpTableId(int id) { m_jumptable_id = id; } | |
561 | |
562 // qtd | |
563 bool storeResult() const; | |
564 void checkStoreResult(); | |
565 | |
566 private: | |
567 int m_store_result; | |
568 | |
569 private: | |
570 QString m_name; | |
571 QString m_original_name; | |
572 mutable QString m_cached_minimal_signature; | |
573 mutable QString m_cached_modified_name; | |
574 | |
575 FunctionType m_function_type; | |
576 AbstractMetaType *m_type; | |
577 const AbstractMetaClass *m_class; | |
578 const AbstractMetaClass *m_implementing_class; | |
579 const AbstractMetaClass *m_declaring_class; | |
580 const AbstractMetaClass *m_interface_class; | |
581 QPropertySpec *m_property_spec; | |
582 AbstractMetaArgumentList m_arguments; | |
583 uint m_constant : 1; | |
584 uint m_invalid : 1; | |
585 int m_jumptable_id; | |
586 }; | |
587 | |
588 | |
589 class AbstractMetaEnumValue | |
590 { | |
591 public: | |
592 AbstractMetaEnumValue() | |
593 : m_value_set(false), m_value(0) | |
594 { | |
595 } | |
596 | |
597 int value() const { return m_value; } | |
598 void setValue(int value) { m_value_set = true; m_value = value; } | |
599 | |
600 QString stringValue() const { return m_string_value; } | |
601 void setStringValue(const QString &v) { m_string_value = v; } | |
602 | |
603 QString name() const { return m_name; } | |
604 void setName(const QString &name) { m_name = name; } | |
605 | |
606 bool isValueSet() const { return m_value_set; } | |
607 | |
608 private: | |
609 QString m_name; | |
610 QString m_string_value; | |
611 | |
612 bool m_value_set; | |
613 int m_value; | |
614 }; | |
615 | |
616 | |
617 class AbstractMetaEnumValueList : public QList<AbstractMetaEnumValue *> | |
618 { | |
619 public: | |
620 AbstractMetaEnumValue *find(const QString &name) const; | |
621 }; | |
622 | |
623 class AbstractMetaEnum : public AbstractMetaAttributes | |
624 { | |
625 public: | |
626 AbstractMetaEnum() : m_type_entry(0), m_class(0), m_has_qenums_declaration(false) {} | |
627 | |
628 AbstractMetaEnumValueList values() const { return m_enum_values; } | |
629 void addEnumValue(AbstractMetaEnumValue *enumValue) { m_enum_values << enumValue; } | |
630 | |
631 QString name() const { return m_type_entry->targetLangName(); } | |
632 QString qualifier() const { return m_type_entry->javaQualifier(); } | |
633 QString package() const { return m_type_entry->javaPackage(); } | |
634 QString fullName() const { return package() + "." + qualifier() + "." + name(); } | |
635 | |
636 // Has the enum been declared inside a Q_ENUMS() macro in its enclosing class? | |
637 void setHasQEnumsDeclaration(bool on) { m_has_qenums_declaration = on; } | |
638 bool hasQEnumsDeclaration() const { return m_has_qenums_declaration; } | |
639 | |
640 EnumTypeEntry *typeEntry() const { return m_type_entry; } | |
641 void setTypeEntry(EnumTypeEntry *entry) { m_type_entry = entry; } | |
642 | |
643 AbstractMetaClass *enclosingClass() const { return m_class; } | |
644 void setEnclosingClass(AbstractMetaClass *c) { m_class = c; } | |
645 | |
646 private: | |
647 AbstractMetaEnumValueList m_enum_values; | |
648 EnumTypeEntry *m_type_entry; | |
649 AbstractMetaClass *m_class; | |
650 | |
651 uint m_has_qenums_declaration : 1; | |
652 uint m_reserved : 31; | |
653 }; | |
654 | |
655 typedef QList<AbstractMetaEnum *> AbstractMetaEnumList; | |
656 | |
657 class AbstractMetaClass : public AbstractMetaAttributes | |
658 { | |
659 public: | |
660 enum FunctionQueryOption { | |
661 Constructors = 0x000001, // Only constructors | |
662 //Destructors = 0x000002, // Only destructors. Not included in class. | |
663 VirtualFunctions = 0x000004, // Only virtual functions (virtual in both TargetLang and C++) | |
664 FinalInTargetLangFunctions = 0x000008, // Only functions that are non-virtual in TargetLang | |
665 FinalInCppFunctions = 0x000010, // Only functions that are non-virtual in C++ | |
666 ClassImplements = 0x000020, // Only functions implemented by the current class | |
667 Inconsistent = 0x000040, // Only inconsistent functions (inconsistent virtualness in TargetLang/C++) | |
668 StaticFunctions = 0x000080, // Only static functions | |
669 Signals = 0x000100, // Only signals | |
670 NormalFunctions = 0x000200, // Only functions that aren't signals | |
671 Visible = 0x000400, // Only public and protected functions | |
672 ForcedShellFunctions = 0x000800, // Only functions that are overridden to be implemented in the shell class | |
673 WasPublic = 0x001000, // Only functions that were originally public | |
674 WasProtected = 0x002000, // Only functions that were originally protected | |
675 NonStaticFunctions = 0x004000, // No static functions | |
676 Empty = 0x008000, // Empty overrides of abstract functions | |
677 Invisible = 0x010000, // Only private functions | |
678 VirtualInCppFunctions = 0x020000, // Only functions that are virtual in C++ | |
679 NonEmptyFunctions = 0x040000, // Only functions with JNI implementations | |
680 VirtualInTargetLangFunctions = 0x080000, // Only functions which are virtual in TargetLang | |
681 AbstractFunctions = 0x100000, // Only abstract functions | |
682 WasVisible = 0x200000, // Only functions that were public or protected in the original code | |
683 NotRemovedFromTargetLang = 0x400000, // Only functions that have not been removed from TargetLang | |
684 NotRemovedFromShell = 0x800000, // Only functions that have not been removed from the shell class | |
685 VirtualSlots = 0x1000000 // Only functions that are set as virtual slots in the type system | |
686 }; | |
687 | |
688 AbstractMetaClass() | |
689 : m_namespace(false), | |
690 m_qobject(false), | |
691 m_has_virtuals(false), | |
692 m_has_nonpublic(false), | |
693 m_has_virtual_slots(false), | |
694 m_has_nonprivateconstructor(false), | |
695 m_functions_fixed(false), | |
696 m_has_public_destructor(true), | |
697 m_force_shell_class(false), | |
698 m_has_hash_function(false), | |
699 m_has_equals_operator(false), | |
700 m_has_clone_operator(false), | |
354
18bd68f586c6
removed superfluous destructors
Max Samukha <maxter@spambox.com>
parents:
326
diff
changeset
|
701 m_has_virtual_destructor(false), |
1 | 702 m_is_type_alias(false), |
703 m_enclosing_class(0), | |
704 m_base_class(0), | |
705 m_template_base_class(0), | |
706 m_extracted_interface(0), | |
707 m_primary_interface_implementor(0), | |
708 m_type_entry(0), | |
110 | 709 m_qDebug_stream_function(0), |
710 needsConversionFunc(false) | |
1 | 711 { |
712 } | |
713 | |
714 virtual ~AbstractMetaClass(); | |
715 | |
716 AbstractMetaClass *extractInterface(); | |
717 void fixFunctions(); | |
718 | |
719 AbstractMetaFunctionList functions() const { return m_functions; } | |
720 void setFunctions(const AbstractMetaFunctionList &functions); | |
721 void addFunction(AbstractMetaFunction *function); | |
722 bool hasFunction(const AbstractMetaFunction *f) const; | |
723 bool hasFunction(const QString &str) const; | |
724 bool hasSignal(const AbstractMetaFunction *f) const; | |
725 | |
726 bool hasConstructors() const; | |
293 | 727 AbstractMetaFunction *copyConstructor() const; |
1 | 728 |
729 void addDefaultConstructor(); | |
730 | |
731 bool hasNonPrivateConstructor() const { return m_has_nonprivateconstructor; } | |
732 void setHasNonPrivateConstructor(bool on) { m_has_nonprivateconstructor = on; } | |
733 bool hasPublicDestructor() const { return m_has_public_destructor; } | |
734 void setHasPublicDestructor(bool on) { m_has_public_destructor = on; } | |
735 | |
736 AbstractMetaFunctionList queryFunctionsByName(const QString &name) const; | |
737 AbstractMetaFunctionList queryFunctions(uint query) const; | |
738 inline AbstractMetaFunctionList allVirtualFunctions() const; | |
739 inline AbstractMetaFunctionList allFinalFunctions() const; | |
740 AbstractMetaFunctionList functionsInTargetLang() const; | |
741 AbstractMetaFunctionList functionsInShellClass() const; | |
742 inline AbstractMetaFunctionList cppInconsistentFunctions() const; | |
743 inline AbstractMetaFunctionList cppSignalFunctions() const; | |
744 AbstractMetaFunctionList publicOverrideFunctions() const; | |
745 AbstractMetaFunctionList virtualOverrideFunctions() const; | |
746 AbstractMetaFunctionList virtualFunctions() const; | |
747 AbstractMetaFunctionList nonVirtualShellFunctions() const; | |
748 | |
749 AbstractMetaFieldList fields() const { return m_fields; } | |
750 void setFields(const AbstractMetaFieldList &fields) { m_fields = fields; } | |
751 void addField(AbstractMetaField *field) { m_fields << field; } | |
752 | |
753 AbstractMetaEnumList enums() const { return m_enums; } | |
754 void setEnums(const AbstractMetaEnumList &enums) { m_enums = enums; } | |
755 void addEnum(AbstractMetaEnum *e) { m_enums << e; } | |
756 | |
757 AbstractMetaEnum *findEnum(const QString &enumName); | |
758 AbstractMetaEnum *findEnumForValue(const QString &enumName); | |
759 AbstractMetaEnumValue *findEnumValue(const QString &enumName, AbstractMetaEnum *meta_enum); | |
760 | |
761 AbstractMetaClassList interfaces() const { return m_interfaces; } | |
762 void addInterface(AbstractMetaClass *interface); | |
763 void setInterfaces(const AbstractMetaClassList &interface); | |
764 | |
765 QString fullName() const { return package() + "." + name(); } | |
766 QString name() const; | |
767 | |
768 QString baseClassName() const { return m_base_class ? m_base_class->name() : QString(); } | |
769 | |
770 AbstractMetaClass *baseClass() const { return m_base_class; } | |
771 void setBaseClass(AbstractMetaClass *base_class) { m_base_class = base_class; } | |
772 | |
773 const AbstractMetaClass *enclosingClass() const { return m_enclosing_class; } | |
774 void setEnclosingClass(AbstractMetaClass *cl) { m_enclosing_class = cl; } | |
775 | |
776 QString package() const { return m_type_entry->javaPackage(); } | |
777 bool isInterface() const { return m_type_entry->isInterface(); } | |
778 bool isNamespace() const { return m_type_entry->isNamespace(); } | |
779 bool isQObject() const { return m_type_entry->isQObject(); } | |
780 bool isQtNamespace() const { return isNamespace() && name() == "Qt"; } | |
781 QString qualifiedCppName() const { return m_type_entry->qualifiedCppName(); } | |
782 | |
783 bool hasInconsistentFunctions() const; | |
784 bool hasSignals() const; | |
785 bool inheritsFrom(const AbstractMetaClass *other) const; | |
786 | |
787 void setForceShellClass(bool on) { m_force_shell_class = on; } | |
788 bool generateShellClass() const; | |
789 | |
790 bool hasVirtualSlots() const { return m_has_virtual_slots; } | |
791 bool hasVirtualFunctions() const { return !isFinal() && m_has_virtuals; } | |
792 bool hasProtectedFunctions() const; | |
793 | |
354
18bd68f586c6
removed superfluous destructors
Max Samukha <maxter@spambox.com>
parents:
326
diff
changeset
|
794 // returns true if this class or its base classes have a |
18bd68f586c6
removed superfluous destructors
Max Samukha <maxter@spambox.com>
parents:
326
diff
changeset
|
795 // virtual destructor |
18bd68f586c6
removed superfluous destructors
Max Samukha <maxter@spambox.com>
parents:
326
diff
changeset
|
796 bool hasVirtualDestructor() const { return m_has_virtual_destructor |
18bd68f586c6
removed superfluous destructors
Max Samukha <maxter@spambox.com>
parents:
326
diff
changeset
|
797 || m_base_class && m_base_class->hasVirtualDestructor(); } |
18bd68f586c6
removed superfluous destructors
Max Samukha <maxter@spambox.com>
parents:
326
diff
changeset
|
798 |
18bd68f586c6
removed superfluous destructors
Max Samukha <maxter@spambox.com>
parents:
326
diff
changeset
|
799 const AbstractMetaClass* destructorBase() const |
18bd68f586c6
removed superfluous destructors
Max Samukha <maxter@spambox.com>
parents:
326
diff
changeset
|
800 { |
18bd68f586c6
removed superfluous destructors
Max Samukha <maxter@spambox.com>
parents:
326
diff
changeset
|
801 const AbstractMetaClass* ret = this; |
18bd68f586c6
removed superfluous destructors
Max Samukha <maxter@spambox.com>
parents:
326
diff
changeset
|
802 for (const AbstractMetaClass* base = this->m_base_class; base; base = base->m_base_class) { |
18bd68f586c6
removed superfluous destructors
Max Samukha <maxter@spambox.com>
parents:
326
diff
changeset
|
803 if (base->m_has_virtual_destructor) |
18bd68f586c6
removed superfluous destructors
Max Samukha <maxter@spambox.com>
parents:
326
diff
changeset
|
804 ret = base; |
18bd68f586c6
removed superfluous destructors
Max Samukha <maxter@spambox.com>
parents:
326
diff
changeset
|
805 } |
18bd68f586c6
removed superfluous destructors
Max Samukha <maxter@spambox.com>
parents:
326
diff
changeset
|
806 return ret; |
18bd68f586c6
removed superfluous destructors
Max Samukha <maxter@spambox.com>
parents:
326
diff
changeset
|
807 } |
18bd68f586c6
removed superfluous destructors
Max Samukha <maxter@spambox.com>
parents:
326
diff
changeset
|
808 |
18bd68f586c6
removed superfluous destructors
Max Samukha <maxter@spambox.com>
parents:
326
diff
changeset
|
809 bool isDestructorBase() const |
18bd68f586c6
removed superfluous destructors
Max Samukha <maxter@spambox.com>
parents:
326
diff
changeset
|
810 { |
18bd68f586c6
removed superfluous destructors
Max Samukha <maxter@spambox.com>
parents:
326
diff
changeset
|
811 return this == destructorBase(); |
18bd68f586c6
removed superfluous destructors
Max Samukha <maxter@spambox.com>
parents:
326
diff
changeset
|
812 } |
18bd68f586c6
removed superfluous destructors
Max Samukha <maxter@spambox.com>
parents:
326
diff
changeset
|
813 |
18bd68f586c6
removed superfluous destructors
Max Samukha <maxter@spambox.com>
parents:
326
diff
changeset
|
814 const AbstractMetaClass* polymorphicBase() const |
18bd68f586c6
removed superfluous destructors
Max Samukha <maxter@spambox.com>
parents:
326
diff
changeset
|
815 { |
18bd68f586c6
removed superfluous destructors
Max Samukha <maxter@spambox.com>
parents:
326
diff
changeset
|
816 const AbstractMetaClass *ret = 0; |
18bd68f586c6
removed superfluous destructors
Max Samukha <maxter@spambox.com>
parents:
326
diff
changeset
|
817 |
18bd68f586c6
removed superfluous destructors
Max Samukha <maxter@spambox.com>
parents:
326
diff
changeset
|
818 for (const AbstractMetaClass *base = this; base; base = base->baseClass()) { |
18bd68f586c6
removed superfluous destructors
Max Samukha <maxter@spambox.com>
parents:
326
diff
changeset
|
819 if (base->m_has_virtuals || base->m_has_virtual_destructor) |
18bd68f586c6
removed superfluous destructors
Max Samukha <maxter@spambox.com>
parents:
326
diff
changeset
|
820 ret = base; |
18bd68f586c6
removed superfluous destructors
Max Samukha <maxter@spambox.com>
parents:
326
diff
changeset
|
821 } |
18bd68f586c6
removed superfluous destructors
Max Samukha <maxter@spambox.com>
parents:
326
diff
changeset
|
822 |
18bd68f586c6
removed superfluous destructors
Max Samukha <maxter@spambox.com>
parents:
326
diff
changeset
|
823 return ret; |
18bd68f586c6
removed superfluous destructors
Max Samukha <maxter@spambox.com>
parents:
326
diff
changeset
|
824 } |
18bd68f586c6
removed superfluous destructors
Max Samukha <maxter@spambox.com>
parents:
326
diff
changeset
|
825 |
18bd68f586c6
removed superfluous destructors
Max Samukha <maxter@spambox.com>
parents:
326
diff
changeset
|
826 |
18bd68f586c6
removed superfluous destructors
Max Samukha <maxter@spambox.com>
parents:
326
diff
changeset
|
827 |
18bd68f586c6
removed superfluous destructors
Max Samukha <maxter@spambox.com>
parents:
326
diff
changeset
|
828 bool isPolymorphic() const |
18bd68f586c6
removed superfluous destructors
Max Samukha <maxter@spambox.com>
parents:
326
diff
changeset
|
829 { |
18bd68f586c6
removed superfluous destructors
Max Samukha <maxter@spambox.com>
parents:
326
diff
changeset
|
830 for (const AbstractMetaClass *base = this; base; base = base->baseClass()) { |
18bd68f586c6
removed superfluous destructors
Max Samukha <maxter@spambox.com>
parents:
326
diff
changeset
|
831 if (base->m_has_virtuals || base->m_has_virtual_destructor) |
18bd68f586c6
removed superfluous destructors
Max Samukha <maxter@spambox.com>
parents:
326
diff
changeset
|
832 return true; |
18bd68f586c6
removed superfluous destructors
Max Samukha <maxter@spambox.com>
parents:
326
diff
changeset
|
833 } |
18bd68f586c6
removed superfluous destructors
Max Samukha <maxter@spambox.com>
parents:
326
diff
changeset
|
834 return false; |
18bd68f586c6
removed superfluous destructors
Max Samukha <maxter@spambox.com>
parents:
326
diff
changeset
|
835 } |
18bd68f586c6
removed superfluous destructors
Max Samukha <maxter@spambox.com>
parents:
326
diff
changeset
|
836 |
18bd68f586c6
removed superfluous destructors
Max Samukha <maxter@spambox.com>
parents:
326
diff
changeset
|
837 bool setHasVirtualDestructor(bool value) { m_has_virtual_destructor = value; } |
18bd68f586c6
removed superfluous destructors
Max Samukha <maxter@spambox.com>
parents:
326
diff
changeset
|
838 |
1 | 839 QList<TypeEntry *> templateArguments() const { return m_template_args; } |
840 void setTemplateArguments(const QList<TypeEntry *> &args) { m_template_args = args; } | |
841 | |
842 bool hasFieldAccessors() const; | |
843 | |
844 // only valid during metajavabuilder's run | |
845 QStringList baseClassNames() const { return m_base_class_names; } | |
846 void setBaseClassNames(const QStringList &names) { m_base_class_names = names; } | |
847 | |
848 AbstractMetaClass *primaryInterfaceImplementor() const { return m_primary_interface_implementor; } | |
849 void setPrimaryInterfaceImplementor(AbstractMetaClass *cl) { m_primary_interface_implementor = cl; } | |
850 | |
851 const ComplexTypeEntry *typeEntry() const { return m_type_entry; } | |
852 ComplexTypeEntry *typeEntry() { return m_type_entry; } | |
853 void setTypeEntry(ComplexTypeEntry *type) { m_type_entry = type; } | |
854 | |
855 void setHasHashFunction(bool on) { m_has_hash_function = on; } | |
856 bool hasHashFunction() const { return m_has_hash_function; } | |
857 | |
858 void setToStringCapability(FunctionModelItem fun) { m_qDebug_stream_function= fun; } | |
859 FunctionModelItem hasToStringCapability() const { return m_qDebug_stream_function; } | |
860 | |
861 virtual bool hasDefaultToStringFunction() const; | |
862 | |
863 void setHasEqualsOperator(bool on) { m_has_equals_operator = on; } | |
864 bool hasEqualsOperator() const { return m_has_equals_operator; } | |
865 | |
866 void setHasCloneOperator(bool on) { m_has_clone_operator = on; } | |
867 bool hasCloneOperator() const { return m_has_clone_operator; } | |
868 | |
869 void addPropertySpec(QPropertySpec *spec) { m_property_specs << spec; } | |
870 QList<QPropertySpec *> propertySpecs() const { return m_property_specs; } | |
871 | |
872 QPropertySpec *propertySpecForRead(const QString &name) const; | |
873 QPropertySpec *propertySpecForWrite(const QString &name) const; | |
874 QPropertySpec *propertySpecForReset(const QString &name) const; | |
875 | |
876 QList<ReferenceCount> referenceCounts() const; | |
877 | |
878 void setEqualsFunctions(const AbstractMetaFunctionList &lst) { m_equals_functions = lst; } | |
879 AbstractMetaFunctionList equalsFunctions() const { return m_equals_functions; } | |
880 | |
881 void setNotEqualsFunctions(const AbstractMetaFunctionList &lst) { m_nequals_functions = lst; } | |
882 AbstractMetaFunctionList notEqualsFunctions() const { return m_nequals_functions; } | |
883 | |
884 void setLessThanFunctions(const AbstractMetaFunctionList &lst) { m_less_than_functions = lst; } | |
885 AbstractMetaFunctionList lessThanFunctions() const { return m_less_than_functions; } | |
886 | |
887 void setGreaterThanFunctions(const AbstractMetaFunctionList &lst) { m_greater_than_functions = lst; } | |
888 AbstractMetaFunctionList greaterThanFunctions() const { return m_greater_than_functions; } | |
889 | |
890 void setLessThanEqFunctions(const AbstractMetaFunctionList &lst) { m_less_than_eq_functions = lst; } | |
891 AbstractMetaFunctionList lessThanEqFunctions() const { return m_less_than_eq_functions; } | |
892 | |
893 void setGreaterThanEqFunctions(const AbstractMetaFunctionList &lst) { m_greater_than_eq_functions = lst; } | |
894 AbstractMetaFunctionList greaterThanEqFunctions() const { return m_greater_than_eq_functions; } | |
895 | |
896 void sortFunctions(); | |
897 | |
898 const AbstractMetaClass *templateBaseClass() const { return m_template_base_class; } | |
899 void setTemplateBaseClass(const AbstractMetaClass *cls) { m_template_base_class = cls; } | |
900 | |
901 void setTypeAlias(bool typeAlias) { m_is_type_alias = typeAlias; } | |
902 bool isTypeAlias() const { return m_is_type_alias; } | |
903 | |
42 | 904 const QStringList &depends() { return m_type_entry->depends(); } |
304 | 905 AbstractMetaFunctionList allFunctions() const { return m_functions; } |
110 | 906 |
907 bool needsConversionFunc; | |
1 | 908 private: |
909 uint m_namespace : 1; | |
910 uint m_qobject : 1; | |
911 uint m_has_virtuals : 1; | |
912 uint m_has_nonpublic : 1; | |
913 uint m_has_virtual_slots : 1; | |
914 uint m_has_nonprivateconstructor : 1; | |
915 uint m_functions_fixed : 1; | |
916 uint m_has_public_destructor : 1; | |
917 uint m_force_shell_class : 1; | |
918 uint m_has_hash_function : 1; | |
919 uint m_has_equals_operator : 1; | |
920 uint m_has_clone_operator :1; | |
921 uint m_is_type_alias : 1; | |
354
18bd68f586c6
removed superfluous destructors
Max Samukha <maxter@spambox.com>
parents:
326
diff
changeset
|
922 uint m_has_virtual_destructor : 1; |
18bd68f586c6
removed superfluous destructors
Max Samukha <maxter@spambox.com>
parents:
326
diff
changeset
|
923 uint m_reserved : 18; |
1 | 924 |
925 const AbstractMetaClass *m_enclosing_class; | |
926 AbstractMetaClass *m_base_class; | |
927 const AbstractMetaClass *m_template_base_class; | |
928 AbstractMetaFunctionList m_functions; | |
929 AbstractMetaFieldList m_fields; | |
930 AbstractMetaEnumList m_enums; | |
931 AbstractMetaClassList m_interfaces; | |
932 AbstractMetaClass *m_extracted_interface; | |
933 AbstractMetaClass *m_primary_interface_implementor; | |
934 QList<QPropertySpec *> m_property_specs; | |
935 AbstractMetaFunctionList m_equals_functions; | |
936 AbstractMetaFunctionList m_nequals_functions; | |
937 | |
938 AbstractMetaFunctionList m_less_than_functions; | |
939 AbstractMetaFunctionList m_greater_than_functions; | |
940 AbstractMetaFunctionList m_less_than_eq_functions; | |
941 AbstractMetaFunctionList m_greater_than_eq_functions; | |
942 | |
943 QStringList m_base_class_names; | |
944 QList<TypeEntry *> m_template_args; | |
945 ComplexTypeEntry *m_type_entry; | |
946 FunctionModelItem m_qDebug_stream_function; | |
947 | |
948 // qtd2 hack | |
949 friend class DGenerator; | |
950 }; | |
951 | |
952 class QPropertySpec { | |
953 public: | |
954 QPropertySpec(const TypeEntry *type) | |
955 : m_type(type), | |
956 m_index(-1) | |
957 { | |
958 } | |
959 | |
960 const TypeEntry *type() const { return m_type; } | |
961 | |
962 QString name() const { return m_name; } | |
963 void setName(const QString &name) { m_name = name; } | |
964 | |
965 QString read() const { return m_read; } | |
966 void setRead(const QString &read) { m_read = read; } | |
967 | |
968 QString write() const { return m_write; } | |
969 void setWrite(const QString &write) { m_write = write; } | |
970 | |
971 QString designable() const { return m_designable; } | |
972 void setDesignable(const QString &designable) { m_designable = designable; } | |
973 | |
974 QString reset() const { return m_reset; } | |
975 void setReset(const QString &reset) { m_reset = reset; } | |
976 | |
977 int index() const { return m_index; } | |
978 void setIndex(int index) { m_index = index; } | |
979 | |
980 private: | |
981 QString m_name; | |
982 QString m_read; | |
983 QString m_write; | |
984 QString m_designable; | |
985 QString m_reset; | |
986 const TypeEntry *m_type; | |
987 int m_index; | |
988 }; | |
989 | |
990 // qtd | |
991 class ArgumentReplace | |
992 { | |
993 private: | |
994 QHash<QString, QString> data; | |
995 static ArgumentReplace *m_instance; | |
996 ArgumentReplace(); | |
997 | |
998 public: | |
999 static void init(); | |
1000 static QString translate(QString arg); | |
1001 }; | |
1002 | |
1003 inline AbstractMetaFunctionList AbstractMetaClass::allVirtualFunctions() const | |
1004 { | |
1005 return queryFunctions(VirtualFunctions | |
1006 | NotRemovedFromTargetLang); | |
1007 } | |
1008 | |
1009 inline AbstractMetaFunctionList AbstractMetaClass::allFinalFunctions() const | |
1010 { | |
1011 return queryFunctions(FinalInTargetLangFunctions | |
1012 | FinalInCppFunctions | |
1013 | NotRemovedFromTargetLang); | |
1014 } | |
1015 | |
1016 inline AbstractMetaFunctionList AbstractMetaClass::cppInconsistentFunctions() const | |
1017 { | |
1018 return queryFunctions(Inconsistent | |
1019 | NormalFunctions | |
1020 | Visible | |
1021 | NotRemovedFromTargetLang); | |
1022 } | |
1023 | |
1024 inline AbstractMetaFunctionList AbstractMetaClass::cppSignalFunctions() const | |
1025 { | |
1026 return queryFunctions(Signals | |
1027 | Visible | |
1028 | NotRemovedFromTargetLang); | |
1029 } | |
1030 | |
298
adae77fdc1ea
Native QList implementation is now used throughout QtD
eldar
parents:
293
diff
changeset
|
1031 inline bool isNativeContainer(AbstractMetaType *argumentType) |
adae77fdc1ea
Native QList implementation is now used throughout QtD
eldar
parents:
293
diff
changeset
|
1032 { |
adae77fdc1ea
Native QList implementation is now used throughout QtD
eldar
parents:
293
diff
changeset
|
1033 if (argumentType && argumentType->isContainer()) |
adae77fdc1ea
Native QList implementation is now used throughout QtD
eldar
parents:
293
diff
changeset
|
1034 if (((const ContainerTypeEntry *)argumentType->typeEntry())->isQList()) |
adae77fdc1ea
Native QList implementation is now used throughout QtD
eldar
parents:
293
diff
changeset
|
1035 return true; |
adae77fdc1ea
Native QList implementation is now used throughout QtD
eldar
parents:
293
diff
changeset
|
1036 return false; |
adae77fdc1ea
Native QList implementation is now used throughout QtD
eldar
parents:
293
diff
changeset
|
1037 } |
adae77fdc1ea
Native QList implementation is now used throughout QtD
eldar
parents:
293
diff
changeset
|
1038 |
1 | 1039 #endif // ABSTRACTMETALANG_H |