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