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