##// END OF EJS Templates
added builtin support for variants etc., this will replace the direct includes in PythonQt...
florianlink -
r93:7b53f64eae84
parent child
Show More
@@ -11,20 +11,16 HEADERS += \
11 generatorsetqtscript.h \
11 generatorsetqtscript.h \
12 metaqtscriptbuilder.h \
12 metaqtscriptbuilder.h \
13 metaqtscript.h \
13 metaqtscript.h \
14 classgenerator.h \
15 shellgenerator.h \
14 shellgenerator.h \
16 shellimplgenerator.h \
15 shellimplgenerator.h \
17 shellheadergenerator.h \
16 shellheadergenerator.h \
18 setupgenerator.h \
17 setupgenerator.h
19 docgenerator.h
20
18
21 SOURCES += \
19 SOURCES += \
22 generatorsetqtscript.cpp \
20 generatorsetqtscript.cpp \
23 metaqtscriptbuilder.cpp \
21 metaqtscriptbuilder.cpp \
24 metaqtscript.cpp \
22 metaqtscript.cpp \
25 classgenerator.cpp \
26 shellgenerator.cpp \
23 shellgenerator.cpp \
27 shellimplgenerator.cpp \
24 shellimplgenerator.cpp \
28 shellheadergenerator.cpp \
25 shellheadergenerator.cpp \
29 setupgenerator.cpp \
26 setupgenerator.cpp
30 docgenerator.cpp
@@ -41,10 +41,8
41
41
42 #include "generatorsetqtscript.h"
42 #include "generatorsetqtscript.h"
43 #include "reporthandler.h"
43 #include "reporthandler.h"
44 #include "classgenerator.h"
45 #include "shellheadergenerator.h"
44 #include "shellheadergenerator.h"
46 #include "shellimplgenerator.h"
45 #include "shellimplgenerator.h"
47 #include "docgenerator.h"
48
46
49 GeneratorSet *GeneratorSet::getInstance() {
47 GeneratorSet *GeneratorSet::getInstance() {
50 return new GeneratorSetQtScript();
48 return new GeneratorSetQtScript();
@@ -88,13 +86,6 QString GeneratorSetQtScript::generate() {
88 setupGenerator.setQtMetaTypeDeclaredTypeNames(declaredTypeNames);
86 setupGenerator.setQtMetaTypeDeclaredTypeNames(declaredTypeNames);
89 setupGenerator.setClasses(classes);
87 setupGenerator.setClasses(classes);
90
88
91 /*
92 ClassGenerator classGenerator(&priGenerator, &setupGenerator);
93 classGenerator.setOutputDirectory(outDir);
94 classGenerator.setClasses(classes);
95 classGenerator.setQtMetaTypeDeclaredTypeNames(declaredTypeNames);
96 classGenerator.generate();
97 */
98 ShellImplGenerator shellImplGenerator(&priGenerator);
89 ShellImplGenerator shellImplGenerator(&priGenerator);
99 shellImplGenerator.setOutputDirectory(outDir);
90 shellImplGenerator.setOutputDirectory(outDir);
100 shellImplGenerator.setClasses(classes);
91 shellImplGenerator.setClasses(classes);
@@ -106,11 +97,6 QString GeneratorSetQtScript::generate() {
106 shellHeaderGenerator.setClasses(classes);
97 shellHeaderGenerator.setClasses(classes);
107 shellHeaderGenerator.generate();
98 shellHeaderGenerator.generate();
108
99
109 //DocGenerator docGenerator;
110 //docGenerator.setOutputDirectory(outDir);
111 //docGenerator.setClasses(classes);
112 //docGenerator.generate();
113
114 priGenerator.generate();
100 priGenerator.generate();
115 setupGenerator.generate();
101 setupGenerator.generate();
116
102
@@ -91,6 +91,10 static QStringList compactFiles(const QStringList& list, const QString& ext, con
91 QStringList outList;
91 QStringList outList;
92 int count = list.count();
92 int count = list.count();
93 int fileNum = 0;
93 int fileNum = 0;
94 QString srcDir = dir;
95 if (dir.endsWith("_builtin")) {
96 srcDir = dir.left(dir.length()-strlen("_builtin"));
97 }
94 while (count>0) {
98 while (count>0) {
95 QString outFileName = prefix + QString::number(fileNum) + ext;
99 QString outFileName = prefix + QString::number(fileNum) + ext;
96 FileOut file(dir + "/" + outFileName);
100 FileOut file(dir + "/" + outFileName);
@@ -101,7 +105,7 static QStringList compactFiles(const QStringList& list, const QString& ext, con
101 QString allText;
105 QString allText;
102 QTextStream ts(&allText);
106 QTextStream ts(&allText);
103 for (int i = 0; i<MAX_CLASSES_PER_FILE && count>0; i++) {
107 for (int i = 0; i<MAX_CLASSES_PER_FILE && count>0; i++) {
104 collectAndRemoveFile(ts, dir + "/" + list.at(list.length()-count));
108 collectAndRemoveFile(ts, srcDir + "/" + list.at(list.length()-count));
105 count--;
109 count--;
106 }
110 }
107 allText = combineIncludes(allText);
111 allText = combineIncludes(allText);
@@ -122,7 +126,8 void PriGenerator::generate()
122
126
123 QString folder = pri.key();
127 QString folder = pri.key();
124 folder.replace('\\','/');
128 folder.replace('\\','/');
125 folder = folder.left(folder.indexOf('/'));
129 int idx = folder.indexOf('/');
130 folder = folder.left(idx);
126
131
127 qSort(list.begin(), list.end());
132 qSort(list.begin(), list.end());
128 FileOut file(m_out_dir + "/generated_cpp/" + pri.key());
133 FileOut file(m_out_dir + "/generated_cpp/" + pri.key());
@@ -46,9 +46,9
46
46
47 //#define Q_SCRIPT_LAZY_GENERATOR
47 //#define Q_SCRIPT_LAZY_GENERATOR
48
48
49 void SetupGenerator::addClass(const AbstractMetaClass *cls)
49 void SetupGenerator::addClass(const QString& package, const AbstractMetaClass *cls)
50 {
50 {
51 packHash[cls->package()].append(cls);
51 packHash[package].append(cls);
52 }
52 }
53
53
54 void maybeDeclareMetaType(QTextStream &stream, const QString &typeName,
54 void maybeDeclareMetaType(QTextStream &stream, const QString &typeName,
@@ -80,15 +80,13 void SetupGenerator::generate()
80
80
81 QString packKey = pack.key();
81 QString packKey = pack.key();
82 QString packName = pack.key();
82 QString packName = pack.key();
83 QStringList components = packName.split(".");
83 QStringList components = packName.split("_");
84 if ((components.size() > 2) && (components.at(0) == "com")
84 if ((components.size() > 2) && (components.at(0) == "com")
85 && (components.at(1) == "trolltech")) {
85 && (components.at(1) == "trolltech")) {
86 // kill com.trolltech in key
86 // kill com.trolltech in key
87 components.removeAt(0);
87 components.removeAt(0);
88 components.removeAt(0);
88 components.removeAt(0);
89 }
89 }
90 packName.replace(".", "_");
91 packKey.replace(".", "_");
92
90
93 QString shortPackName;
91 QString shortPackName;
94 foreach (QString comp, components) {
92 foreach (QString comp, components) {
@@ -118,14 +116,21 void SetupGenerator::generate()
118 }
116 }
119 s << endl;
117 s << endl;
120
118
121 QStringList polymorphicHandlers = writePolymorphicHandler(s, list.at(0)->package(), classes_with_polymorphic_id);
119 QStringList polymorphicHandlers;
122 s << endl;
120 if (!packName.endsWith("_builtin")) {
123
121 polymorphicHandlers = writePolymorphicHandler(s, list.at(0)->package(), classes_with_polymorphic_id);
122 s << endl;
123 }
124
124 // declare individual class creation functions
125 // declare individual class creation functions
125 s << "void PythonQt_init_" << shortPackName << "() {" << endl;
126 s << "void PythonQt_init_" << shortPackName << "() {" << endl;
127
128 if (shortPackName.endsWith("Builtin")) {
129 shortPackName = shortPackName.mid(shortPackName.length()-strlen("builtin"));
130 }
131
126 QStringList cppClassNames;
132 QStringList cppClassNames;
127 foreach (const AbstractMetaClass *cls, list) {
133 foreach (const AbstractMetaClass *cls, list) {
128 if (ShellGenerator::isBuiltIn(cls->name())) { continue; }
129
134
130 QString shellCreator;
135 QString shellCreator;
131 if (cls->generateShellClass()) {
136 if (cls->generateShellClass()) {
@@ -52,7 +52,7 class SetupGenerator : public Generator
52 public:
52 public:
53 virtual void generate();
53 virtual void generate();
54
54
55 void addClass(const AbstractMetaClass *cls);
55 void addClass(const QString& package, const AbstractMetaClass *cls);
56
56
57 static void writeInclude(QTextStream &stream, const Include &inc);
57 static void writeInclude(QTextStream &stream, const Include &inc);
58
58
@@ -46,7 +46,7
46 #include "metaqtscript.h"
46 #include "metaqtscript.h"
47 #include "prigenerator.h"
47 #include "prigenerator.h"
48
48
49 #define MAX_CLASSES_PER_FILE 20
49 #define MAX_CLASSES_PER_FILE 30
50
50
51 class ShellGenerator : public Generator
51 class ShellGenerator : public Generator
52 {
52 {
@@ -53,9 +53,10 QString ShellHeaderGenerator::fileNameForClass(const AbstractMetaClass *meta_cla
53
53
54 void ShellHeaderGenerator::write(QTextStream &s, const AbstractMetaClass *meta_class)
54 void ShellHeaderGenerator::write(QTextStream &s, const AbstractMetaClass *meta_class)
55 {
55 {
56 if (!ShellGenerator::isBuiltIn(meta_class->name())) {
56 QString builtIn = ShellGenerator::isBuiltIn(meta_class->name())?"_builtin":"";
57 setupGenerator->addClass(meta_class);
57 QString pro_file_name = meta_class->package().replace(".", "_") + builtIn + "/" + meta_class->package().replace(".", "_") + builtIn + ".pri";
58 }
58 priGenerator->addHeader(pro_file_name, fileNameForClass(meta_class));
59 setupGenerator->addClass(meta_class->package().replace(".", "_") + builtIn, meta_class);
59
60
60 QString include_block = "PYTHONQTWRAPPER_" + meta_class->name().toUpper() + "_H";
61 QString include_block = "PYTHONQTWRAPPER_" + meta_class->name().toUpper() + "_H";
61
62
@@ -75,14 +76,6 void ShellHeaderGenerator::write(QTextStream &s, const AbstractMetaClass *meta_c
75 }
76 }
76 s << endl;
77 s << endl;
77
78
78 QString pro_file_name = meta_class->package().replace(".", "_") + "/" + meta_class->package().replace(".", "_") + ".pri";
79
80 // if (!meta_class->generateShellClass()) {
81 // s << "#endif" << endl << endl;
82 // priGenerator->addHeader(pro_file_name, fileNameForClass(meta_class));
83 // return ;
84 // }
85
86 AbstractMetaFunctionList ctors = meta_class->queryFunctions(AbstractMetaClass::Constructors
79 AbstractMetaFunctionList ctors = meta_class->queryFunctions(AbstractMetaClass::Constructors
87 | AbstractMetaClass::WasVisible
80 | AbstractMetaClass::WasVisible
88 | AbstractMetaClass::NotRemovedFromTargetLang);
81 | AbstractMetaClass::NotRemovedFromTargetLang);
@@ -273,9 +266,6 void ShellHeaderGenerator::write(QTextStream &s, const AbstractMetaClass *meta_c
273 s << "};" << endl << endl
266 s << "};" << endl << endl
274 << "#endif // " << include_block << endl;
267 << "#endif // " << include_block << endl;
275
268
276 if (!ShellGenerator::isBuiltIn(meta_class->name())) {
277 priGenerator->addHeader(pro_file_name, fileNameForClass(meta_class));
278 }
279 }
269 }
280
270
281 void ShellHeaderGenerator::writeInjectedCode(QTextStream &s, const AbstractMetaClass *meta_class)
271 void ShellHeaderGenerator::writeInjectedCode(QTextStream &s, const AbstractMetaClass *meta_class)
@@ -63,12 +63,9 static void writeHelperCode(QTextStream &s, const AbstractMetaClass *)
63
63
64 void ShellImplGenerator::write(QTextStream &s, const AbstractMetaClass *meta_class)
64 void ShellImplGenerator::write(QTextStream &s, const AbstractMetaClass *meta_class)
65 {
65 {
66
66 QString builtIn = ShellGenerator::isBuiltIn(meta_class->name())?"_builtin":"";
67 QString pro_file_name = meta_class->package().replace(".", "_") + "/" + meta_class->package().replace(".", "_") + ".pri";
67 QString pro_file_name = meta_class->package().replace(".", "_") + builtIn + "/" + meta_class->package().replace(".", "_") + builtIn + ".pri";
68
68 priGenerator->addSource(pro_file_name, fileNameForClass(meta_class));
69 if (!ShellGenerator::isBuiltIn(meta_class->name())) {
70 priGenerator->addSource(pro_file_name, fileNameForClass(meta_class));
71 }
72
69
73 s << "#include \"PythonQtWrapper_" << meta_class->name() << ".h\"" << endl << endl;
70 s << "#include \"PythonQtWrapper_" << meta_class->name() << ".h\"" << endl << endl;
74
71
1 NO CONTENT: file was removed
NO CONTENT: file was removed
This diff has been collapsed as it changes many lines, (1842 lines changed) Show them Hide them
1 NO CONTENT: file was removed
NO CONTENT: file was removed
1 NO CONTENT: file was removed
NO CONTENT: file was removed
1 NO CONTENT: file was removed
NO CONTENT: file was removed
General Comments 0
You need to be logged in to leave comments. Login now