@@ -1,244 +1,272 | |||||
1 | /**************************************************************************** |
|
1 | /**************************************************************************** | |
2 | ** |
|
2 | ** | |
3 | ** Copyright (C) 1992-2008 Trolltech ASA. All rights reserved. |
|
3 | ** Copyright (C) 1992-2008 Trolltech ASA. All rights reserved. | |
4 | ** |
|
4 | ** | |
5 | ** This file is part of the Qt Script Generator project on Trolltech Labs. |
|
5 | ** This file is part of the Qt Script Generator project on Trolltech Labs. | |
6 | ** |
|
6 | ** | |
7 | ** This file may be used under the terms of the GNU General Public |
|
7 | ** This file may be used under the terms of the GNU General Public | |
8 | ** License version 2.0 as published by the Free Software Foundation |
|
8 | ** License version 2.0 as published by the Free Software Foundation | |
9 | ** and appearing in the file LICENSE.GPL included in the packaging of |
|
9 | ** and appearing in the file LICENSE.GPL included in the packaging of | |
10 | ** this file. Please review the following information to ensure GNU |
|
10 | ** this file. Please review the following information to ensure GNU | |
11 | ** General Public Licensing requirements will be met: |
|
11 | ** General Public Licensing requirements will be met: | |
12 | ** http://www.trolltech.com/products/qt/opensource.html |
|
12 | ** http://www.trolltech.com/products/qt/opensource.html | |
13 | ** |
|
13 | ** | |
14 | ** If you are unsure which license is appropriate for your use, please |
|
14 | ** If you are unsure which license is appropriate for your use, please | |
15 | ** review the following information: |
|
15 | ** review the following information: | |
16 | ** http://www.trolltech.com/products/qt/licensing.html or contact the |
|
16 | ** http://www.trolltech.com/products/qt/licensing.html or contact the | |
17 | ** sales department at sales@trolltech.com. |
|
17 | ** sales department at sales@trolltech.com. | |
18 | ** |
|
18 | ** | |
19 | ** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE |
|
19 | ** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE | |
20 | ** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. |
|
20 | ** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. | |
21 | ** |
|
21 | ** | |
22 | ****************************************************************************/ |
|
22 | ****************************************************************************/ | |
23 |
|
23 | |||
24 | #include "shellheadergenerator.h" |
|
24 | #include "shellheadergenerator.h" | |
25 | #include "fileout.h" |
|
25 | #include "fileout.h" | |
26 |
|
26 | |||
27 | #include <QtCore/QDir> |
|
27 | #include <QtCore/QDir> | |
28 |
|
28 | |||
29 | #include <qdebug.h> |
|
29 | #include <qdebug.h> | |
30 |
|
30 | |||
31 | QString ShellHeaderGenerator::fileNameForClass(const AbstractMetaClass *meta_class) const |
|
31 | QString ShellHeaderGenerator::fileNameForClass(const AbstractMetaClass *meta_class) const | |
32 | { |
|
32 | { | |
33 | return QString("PythonQtWrapper_%1.h").arg(meta_class->name()); |
|
33 | return QString("PythonQtWrapper_%1.h").arg(meta_class->name()); | |
34 | } |
|
34 | } | |
35 |
|
35 | |||
36 | void writeQtScriptQtBindingsLicense(QTextStream &stream); |
|
36 | void writeQtScriptQtBindingsLicense(QTextStream &stream); | |
37 |
|
37 | |||
38 | void ShellHeaderGenerator::write(QTextStream &s, const AbstractMetaClass *meta_class) |
|
38 | void ShellHeaderGenerator::write(QTextStream &s, const AbstractMetaClass *meta_class) | |
39 | { |
|
39 | { | |
40 |
|
40 | |||
41 | setupGenerator->addClass(meta_class); |
|
41 | setupGenerator->addClass(meta_class); | |
42 |
|
42 | |||
43 | if (FileOut::license) |
|
43 | if (FileOut::license) | |
44 | writeQtScriptQtBindingsLicense(s); |
|
44 | writeQtScriptQtBindingsLicense(s); | |
45 |
|
45 | |||
46 | QString include_block = "PYTHONQTWRAPPER_" + meta_class->name().toUpper() + "_H"; |
|
46 | QString include_block = "PYTHONQTWRAPPER_" + meta_class->name().toUpper() + "_H"; | |
47 |
|
47 | |||
48 | s << "#ifndef " << include_block << endl |
|
48 | s << "#ifndef " << include_block << endl | |
49 | << "#define " << include_block << endl << endl; |
|
49 | << "#define " << include_block << endl << endl; | |
50 |
|
50 | |||
51 | Include inc = meta_class->typeEntry()->include(); |
|
51 | Include inc = meta_class->typeEntry()->include(); | |
52 | ShellGenerator::writeInclude(s, inc); |
|
52 | ShellGenerator::writeInclude(s, inc); | |
53 |
|
53 | |||
54 | s << "#include <QObject>" << endl << endl; |
|
54 | s << "#include <QObject>" << endl << endl; | |
55 | s << "#include <PythonQt.h>" << endl << endl; |
|
55 | s << "#include <PythonQt.h>" << endl << endl; | |
56 |
|
56 | |||
57 | IncludeList list = meta_class->typeEntry()->extraIncludes(); |
|
57 | IncludeList list = meta_class->typeEntry()->extraIncludes(); | |
58 | qSort(list.begin(), list.end()); |
|
58 | qSort(list.begin(), list.end()); | |
59 | foreach (const Include &inc, list) { |
|
59 | foreach (const Include &inc, list) { | |
60 | ShellGenerator::writeInclude(s, inc); |
|
60 | ShellGenerator::writeInclude(s, inc); | |
61 | } |
|
61 | } | |
62 | s << endl; |
|
62 | s << endl; | |
63 |
|
63 | |||
64 | QString pro_file_name = meta_class->package().replace(".", "_") + "/" + meta_class->package().replace(".", "_") + ".pri"; |
|
64 | QString pro_file_name = meta_class->package().replace(".", "_") + "/" + meta_class->package().replace(".", "_") + ".pri"; | |
65 |
|
65 | |||
66 | // if (!meta_class->generateShellClass()) { |
|
66 | // if (!meta_class->generateShellClass()) { | |
67 | // s << "#endif" << endl << endl; |
|
67 | // s << "#endif" << endl << endl; | |
68 | // priGenerator->addHeader(pro_file_name, fileNameForClass(meta_class)); |
|
68 | // priGenerator->addHeader(pro_file_name, fileNameForClass(meta_class)); | |
69 | // return ; |
|
69 | // return ; | |
70 | // } |
|
70 | // } | |
71 |
|
71 | |||
72 | AbstractMetaFunctionList ctors = meta_class->queryFunctions(AbstractMetaClass::Constructors |
|
72 | AbstractMetaFunctionList ctors = meta_class->queryFunctions(AbstractMetaClass::Constructors | |
73 | | AbstractMetaClass::WasVisible |
|
73 | | AbstractMetaClass::WasVisible | |
74 | | AbstractMetaClass::NotRemovedFromTargetLang); |
|
74 | | AbstractMetaClass::NotRemovedFromTargetLang); | |
75 |
|
75 | |||
76 | // Shell------------------------------------------------------------------- |
|
76 | // Shell------------------------------------------------------------------- | |
77 | if (meta_class->generateShellClass()) { |
|
77 | if (meta_class->generateShellClass()) { | |
78 |
|
78 | |||
79 | AbstractMetaFunctionList virtualsForShell = getVirtualFunctionsForShell(meta_class); |
|
79 | AbstractMetaFunctionList virtualsForShell = getVirtualFunctionsForShell(meta_class); | |
80 |
|
80 | |||
81 | s << "class " << shellClassName(meta_class) |
|
81 | s << "class " << shellClassName(meta_class) | |
82 | << " : public " << meta_class->qualifiedCppName() << endl << "{" << endl; |
|
82 | << " : public " << meta_class->qualifiedCppName() << endl << "{" << endl; | |
83 | s << "public:" << endl; |
|
83 | s << "public:" << endl; | |
84 | foreach(AbstractMetaFunction* fun, ctors) { |
|
84 | foreach(AbstractMetaFunction* fun, ctors) { | |
85 | s << " "; |
|
85 | s << " "; | |
86 | writeFunctionSignature(s, fun, 0,"PythonQtShell_", |
|
86 | writeFunctionSignature(s, fun, 0,"PythonQtShell_", | |
87 | Option(IncludeDefaultExpression | OriginalName | ShowStatic | UnderscoreSpaces)); |
|
87 | Option(IncludeDefaultExpression | OriginalName | ShowStatic | UnderscoreSpaces)); | |
88 | s << ":" << meta_class->qualifiedCppName() << "("; |
|
88 | s << ":" << meta_class->qualifiedCppName() << "("; | |
89 | QString scriptFunctionName = fun->originalName(); |
|
89 | QString scriptFunctionName = fun->originalName(); | |
90 | AbstractMetaArgumentList args = fun->arguments(); |
|
90 | AbstractMetaArgumentList args = fun->arguments(); | |
91 | for (int i = 0; i < args.size(); ++i) { |
|
91 | for (int i = 0; i < args.size(); ++i) { | |
92 | if (i > 0) |
|
92 | if (i > 0) | |
93 | s << ", "; |
|
93 | s << ", "; | |
94 | s << args.at(i)->argumentName(); |
|
94 | s << args.at(i)->argumentName(); | |
95 | } |
|
95 | } | |
96 | s << "),_wrapper(NULL) {};" << endl; |
|
96 | s << "),_wrapper(NULL) {};" << endl; | |
97 | } |
|
97 | } | |
98 | s << endl; |
|
98 | s << endl; | |
99 |
|
99 | |||
100 | foreach(AbstractMetaFunction* fun, virtualsForShell) { |
|
100 | foreach(AbstractMetaFunction* fun, virtualsForShell) { | |
101 | s << "virtual "; |
|
101 | s << "virtual "; | |
102 | writeFunctionSignature(s, fun, 0, QString(), |
|
102 | writeFunctionSignature(s, fun, 0, QString(), | |
103 | Option(IncludeDefaultExpression | OriginalName | ShowStatic | UnderscoreSpaces)); |
|
103 | Option(IncludeDefaultExpression | OriginalName | ShowStatic | UnderscoreSpaces)); | |
104 | s << ";" << endl; |
|
104 | s << ";" << endl; | |
105 | } |
|
105 | } | |
106 | s << endl; |
|
106 | s << endl; | |
107 | s << " PythonQtInstanceWrapper* _wrapper; " << endl; |
|
107 | s << " PythonQtInstanceWrapper* _wrapper; " << endl; | |
108 |
|
108 | |||
109 | s << "};" << endl << endl; |
|
109 | s << "};" << endl << endl; | |
110 | } |
|
110 | } | |
111 |
|
111 | |||
112 | // Promoter------------------------------------------------------------------- |
|
112 | // Promoter------------------------------------------------------------------- | |
113 | AbstractMetaFunctionList promoteFunctions = getProtectedFunctionsThatNeedPromotion(meta_class); |
|
113 | AbstractMetaFunctionList promoteFunctions = getProtectedFunctionsThatNeedPromotion(meta_class); | |
114 | if (!promoteFunctions.isEmpty()) { |
|
114 | if (!promoteFunctions.isEmpty()) { | |
115 | s << "class " << promoterClassName(meta_class) |
|
115 | s << "class " << promoterClassName(meta_class) | |
116 | << " : public " << meta_class->qualifiedCppName() << endl << "{ public:" << endl; |
|
116 | << " : public " << meta_class->qualifiedCppName() << endl << "{ public:" << endl; | |
117 |
|
117 | |||
118 | foreach(AbstractMetaFunction* fun, promoteFunctions) { |
|
118 | foreach(AbstractMetaFunction* fun, promoteFunctions) { | |
119 | s << "inline "; |
|
119 | s << "inline "; | |
120 | writeFunctionSignature(s, fun, 0, "promoted_", |
|
120 | writeFunctionSignature(s, fun, 0, "promoted_", | |
121 | Option(IncludeDefaultExpression | OriginalName | ShowStatic | UnderscoreSpaces)); |
|
121 | Option(IncludeDefaultExpression | OriginalName | ShowStatic | UnderscoreSpaces)); | |
122 | s << " { "; |
|
122 | s << " { "; | |
123 | QString scriptFunctionName = fun->originalName(); |
|
123 | QString scriptFunctionName = fun->originalName(); | |
124 | AbstractMetaArgumentList args = fun->arguments(); |
|
124 | AbstractMetaArgumentList args = fun->arguments(); | |
125 | if (fun->type()) |
|
125 | if (fun->type()) | |
126 | s << "return "; |
|
126 | s << "return "; | |
127 | s << meta_class->qualifiedCppName() << "::"; |
|
127 | s << meta_class->qualifiedCppName() << "::"; | |
128 | s << fun->originalName() << "("; |
|
128 | s << fun->originalName() << "("; | |
129 | for (int i = 0; i < args.size(); ++i) { |
|
129 | for (int i = 0; i < args.size(); ++i) { | |
130 | if (i > 0) |
|
130 | if (i > 0) | |
131 | s << ", "; |
|
131 | s << ", "; | |
132 | s << args.at(i)->argumentName(); |
|
132 | s << args.at(i)->argumentName(); | |
133 | } |
|
133 | } | |
134 | s << "); }" << endl; |
|
134 | s << "); }" << endl; | |
135 | } |
|
135 | } | |
136 |
|
136 | |||
137 | s << "};" << endl << endl; |
|
137 | s << "};" << endl << endl; | |
138 | } |
|
138 | } | |
139 |
|
139 | |||
140 | // Wrapper------------------------------------------------------------------- |
|
140 | // Wrapper------------------------------------------------------------------- | |
141 |
|
141 | |||
142 | s << "class " << wrapperClassName(meta_class) |
|
142 | s << "class " << wrapperClassName(meta_class) | |
143 | << " : public QObject" << endl |
|
143 | << " : public QObject" << endl | |
144 | << "{ Q_OBJECT" << endl; |
|
144 | << "{ Q_OBJECT" << endl; | |
145 |
|
145 | |||
146 | s << "public:" << endl; |
|
146 | s << "public:" << endl; | |
147 |
|
147 | |||
148 | AbstractMetaEnumList enums1 = meta_class->enums(); |
|
148 | AbstractMetaEnumList enums1 = meta_class->enums(); | |
149 | AbstractMetaEnumList enums; |
|
149 | AbstractMetaEnumList enums; | |
|
150 | QList<FlagsTypeEntry*> flags; | |||
150 | foreach(AbstractMetaEnum* enum1, enums1) { |
|
151 | foreach(AbstractMetaEnum* enum1, enums1) { | |
151 | // catch gadgets and enums that are not exported on QObjects... |
|
152 | // catch gadgets and enums that are not exported on QObjects... | |
152 | if (enum1->wasPublic() && (!meta_class->isQObject() || !enum1->hasQEnumsDeclaration())) { |
|
153 | if (enum1->wasPublic() && (!meta_class->isQObject() || !enum1->hasQEnumsDeclaration())) { | |
153 | enums << enum1; |
|
154 | enums << enum1; | |
|
155 | if (enum1->typeEntry()->flags()) { | |||
|
156 | flags << enum1->typeEntry()->flags(); | |||
|
157 | } | |||
154 | } |
|
158 | } | |
155 | } |
|
159 | } | |
156 | if (enums.count()) { |
|
160 | if (enums.count()) { | |
157 | s << "Q_ENUMS("; |
|
161 | s << "Q_ENUMS("; | |
158 | foreach(AbstractMetaEnum* enum1, enums) { |
|
162 | foreach(AbstractMetaEnum* enum1, enums) { | |
159 | s << enum1->name() << " "; |
|
163 | s << enum1->name() << " "; | |
160 | } |
|
164 | } | |
161 | s << ")" << endl; |
|
165 | s << ")" << endl; | |
162 |
|
166 | |||
|
167 | if (flags.count()) { | |||
|
168 | s << "Q_FLAGS("; | |||
|
169 | foreach(FlagsTypeEntry* flag1, flags) { | |||
|
170 | QString origName = flag1->originalName(); | |||
|
171 | int idx = origName.lastIndexOf("::"); | |||
|
172 | if (idx!= -1) { | |||
|
173 | origName = origName.mid(idx+2); | |||
|
174 | } | |||
|
175 | s << origName << " "; | |||
|
176 | } | |||
|
177 | s << ")" << endl; | |||
|
178 | } | |||
|
179 | ||||
163 |
|
|
180 | foreach(AbstractMetaEnum* enum1, enums) { | |
164 | s << "enum " << enum1->name() << "{" << endl; |
|
181 | s << "enum " << enum1->name() << "{" << endl; | |
165 | bool first = true; |
|
182 | bool first = true; | |
166 | foreach(AbstractMetaEnumValue* value, enum1->values()) { |
|
183 | foreach(AbstractMetaEnumValue* value, enum1->values()) { | |
167 | if (first) { first = false; } |
|
184 | if (first) { first = false; } | |
168 | else { s << ", "; } |
|
185 | else { s << ", "; } | |
169 | s << " " << value->name() << " = " << meta_class->qualifiedCppName() << "::" << value->name(); |
|
186 | s << " " << value->name() << " = " << meta_class->qualifiedCppName() << "::" << value->name(); | |
170 | } |
|
187 | } | |
171 | s << "};" << endl; |
|
188 | s << "};" << endl; | |
172 | } |
|
189 | } | |
|
190 | if (flags.count()) { | |||
|
191 | foreach(AbstractMetaEnum* enum1, enums) { | |||
|
192 | if (enum1->typeEntry()->flags()) { | |||
|
193 | QString origName = enum1->typeEntry()->flags()->originalName(); | |||
|
194 | int idx = origName.lastIndexOf("::"); | |||
|
195 | if (idx!= -1) { | |||
|
196 | origName = origName.mid(idx+2); | |||
|
197 | } | |||
|
198 | s << "Q_DECLARE_FLAGS("<< origName << ", " << enum1->name() <<")"<<endl; | |||
|
199 | } | |||
|
200 | } | |||
|
201 | } | |||
173 | } |
|
202 | } | |
174 |
|
||||
175 | s << "public slots:" << endl; |
|
203 | s << "public slots:" << endl; | |
176 | if (meta_class->generateShellClass() || !meta_class->isAbstract()) { |
|
204 | if (meta_class->generateShellClass() || !meta_class->isAbstract()) { | |
177 |
|
205 | |||
178 | bool copyConstructorSeen = false; |
|
206 | bool copyConstructorSeen = false; | |
179 | bool defaultConstructorSeen = false; |
|
207 | bool defaultConstructorSeen = false; | |
180 | foreach (const AbstractMetaFunction *fun, ctors) { |
|
208 | foreach (const AbstractMetaFunction *fun, ctors) { | |
181 | if (!fun->isPublic() || fun->isAbstract()) { continue; } |
|
209 | if (!fun->isPublic() || fun->isAbstract()) { continue; } | |
182 | s << meta_class->qualifiedCppName() << "* "; |
|
210 | s << meta_class->qualifiedCppName() << "* "; | |
183 | writeFunctionSignature(s, fun, 0, "new_", |
|
211 | writeFunctionSignature(s, fun, 0, "new_", | |
184 | Option(IncludeDefaultExpression | OriginalName | ShowStatic)); |
|
212 | Option(IncludeDefaultExpression | OriginalName | ShowStatic)); | |
185 | s << ";" << endl; |
|
213 | s << ";" << endl; | |
186 | if (fun->arguments().size()==1 && meta_class->qualifiedCppName() == fun->arguments().at(0)->type()->typeEntry()->qualifiedCppName()) { |
|
214 | if (fun->arguments().size()==1 && meta_class->qualifiedCppName() == fun->arguments().at(0)->type()->typeEntry()->qualifiedCppName()) { | |
187 | copyConstructorSeen = true; |
|
215 | copyConstructorSeen = true; | |
188 | } |
|
216 | } | |
189 | if (fun->arguments().size()==0) { |
|
217 | if (fun->arguments().size()==0) { | |
190 | defaultConstructorSeen = true; |
|
218 | defaultConstructorSeen = true; | |
191 | } |
|
219 | } | |
192 | } |
|
220 | } | |
193 |
|
221 | |||
194 | if (meta_class->typeEntry()->isValue() |
|
222 | if (meta_class->typeEntry()->isValue() | |
195 | && !copyConstructorSeen && defaultConstructorSeen) { |
|
223 | && !copyConstructorSeen && defaultConstructorSeen) { | |
196 | QString className = meta_class->generateShellClass()?shellClassName(meta_class):meta_class->qualifiedCppName(); |
|
224 | QString className = meta_class->generateShellClass()?shellClassName(meta_class):meta_class->qualifiedCppName(); | |
197 | s << meta_class->qualifiedCppName() << "* new_" << meta_class->name() << "(const " << meta_class->qualifiedCppName() << "& other) {" << endl; |
|
225 | s << meta_class->qualifiedCppName() << "* new_" << meta_class->name() << "(const " << meta_class->qualifiedCppName() << "& other) {" << endl; | |
198 | s << className << "* a = new " << className << "();" << endl; |
|
226 | s << className << "* a = new " << className << "();" << endl; | |
199 | s << "*((" << meta_class->qualifiedCppName() << "*)a) = other;" << endl; |
|
227 | s << "*((" << meta_class->qualifiedCppName() << "*)a) = other;" << endl; | |
200 | s << "return a; }" << endl; |
|
228 | s << "return a; }" << endl; | |
201 | } |
|
229 | } | |
202 | } |
|
230 | } | |
203 | if (meta_class->hasPublicDestructor() && !meta_class->isNamespace()) { |
|
231 | if (meta_class->hasPublicDestructor() && !meta_class->isNamespace()) { | |
204 | s << "void delete_" << meta_class->name() << "(" << meta_class->qualifiedCppName() << "* obj) { delete obj; } "; |
|
232 | s << "void delete_" << meta_class->name() << "(" << meta_class->qualifiedCppName() << "* obj) { delete obj; } "; | |
205 | s << endl; |
|
233 | s << endl; | |
206 | } |
|
234 | } | |
207 | if (meta_class->name()=="QTreeWidgetItem") { |
|
235 | if (meta_class->name()=="QTreeWidgetItem") { | |
208 | s << "bool hasOwner(QTreeWidgetItem* theWrappedObject) { return theWrappedObject->treeWidget()!=NULL || theWrappedObject->parent()!=NULL; }" << endl; |
|
236 | s << "bool hasOwner(QTreeWidgetItem* theWrappedObject) { return theWrappedObject->treeWidget()!=NULL || theWrappedObject->parent()!=NULL; }" << endl; | |
209 | } else if (meta_class->name()=="QGraphicsItem") { |
|
237 | } else if (meta_class->name()=="QGraphicsItem") { | |
210 | s << "bool hasOwner(QGraphicsItem* theWrappedObject) { return theWrappedObject->scene()!=NULL || theWrappedObject->parentItem()!=NULL; }" << endl; |
|
238 | s << "bool hasOwner(QGraphicsItem* theWrappedObject) { return theWrappedObject->scene()!=NULL || theWrappedObject->parentItem()!=NULL; }" << endl; | |
211 | } |
|
239 | } | |
212 |
|
240 | |||
213 | AbstractMetaFunctionList functions = getFunctionsToWrap(meta_class); |
|
241 | AbstractMetaFunctionList functions = getFunctionsToWrap(meta_class); | |
214 |
|
242 | |||
215 | foreach (const AbstractMetaFunction *function, functions) { |
|
243 | foreach (const AbstractMetaFunction *function, functions) { | |
216 | if (!function->isSlot()) { |
|
244 | if (!function->isSlot()) { | |
217 | s << " "; |
|
245 | s << " "; | |
218 | writeFunctionSignature(s, function, 0, QString(), |
|
246 | writeFunctionSignature(s, function, 0, QString(), | |
219 | Option(FirstArgIsWrappedObject| IncludeDefaultExpression | OriginalName | ShowStatic | UnderscoreSpaces)); |
|
247 | Option(FirstArgIsWrappedObject| IncludeDefaultExpression | OriginalName | ShowStatic | UnderscoreSpaces)); | |
220 | s << ";" << endl; |
|
248 | s << ";" << endl; | |
221 | } |
|
249 | } | |
222 | } |
|
250 | } | |
223 |
|
251 | |||
224 | // writeInjectedCode(s, meta_class); |
|
252 | // writeInjectedCode(s, meta_class); | |
225 |
|
253 | |||
226 | // s << endl << " QScriptValue __qtscript_self;" << endl; |
|
254 | // s << endl << " QScriptValue __qtscript_self;" << endl; | |
227 |
|
255 | |||
228 | s << "};" << endl << endl |
|
256 | s << "};" << endl << endl | |
229 | << "#endif // " << include_block << endl; |
|
257 | << "#endif // " << include_block << endl; | |
230 |
|
258 | |||
231 | if (!ShellGenerator::isBuiltIn(meta_class->name())) { |
|
259 | if (!ShellGenerator::isBuiltIn(meta_class->name())) { | |
232 | priGenerator->addHeader(pro_file_name, fileNameForClass(meta_class)); |
|
260 | priGenerator->addHeader(pro_file_name, fileNameForClass(meta_class)); | |
233 | } |
|
261 | } | |
234 | } |
|
262 | } | |
235 |
|
263 | |||
236 | void ShellHeaderGenerator::writeInjectedCode(QTextStream &s, const AbstractMetaClass *meta_class) |
|
264 | void ShellHeaderGenerator::writeInjectedCode(QTextStream &s, const AbstractMetaClass *meta_class) | |
237 | { |
|
265 | { | |
238 | CodeSnipList code_snips = meta_class->typeEntry()->codeSnips(); |
|
266 | CodeSnipList code_snips = meta_class->typeEntry()->codeSnips(); | |
239 | foreach (const CodeSnip &cs, code_snips) { |
|
267 | foreach (const CodeSnip &cs, code_snips) { | |
240 | if (cs.language == TypeSystem::ShellDeclaration) { |
|
268 | if (cs.language == TypeSystem::ShellDeclaration) { | |
241 | s << cs.code() << endl; |
|
269 | s << cs.code() << endl; | |
242 | } |
|
270 | } | |
243 | } |
|
271 | } | |
244 | } |
|
272 | } |
General Comments 0
You need to be logged in to leave comments.
Login now