Skip to content

Commit e687622

Browse files
usiemsjcfr
authored andcommitted
[Backport generator] Remove work-around for package spelling
by putting the correct spelling in the package name in the typesystem files (cherry picked from commit MeVisLab/pythonqt@182df8d)
1 parent daaf0da commit e687622

18 files changed

+36
-62
lines changed

generator/setupgenerator.cpp

Lines changed: 9 additions & 40 deletions
Original file line numberDiff line numberDiff line change
@@ -52,10 +52,6 @@ void SetupGenerator::addClass(const QString& package, const AbstractMetaClass *c
5252
packHash[package].append(cls);
5353
}
5454

55-
void maybeDeclareMetaType(QTextStream &stream, const QString &typeName,
56-
QSet<QString> &registeredTypeNames);
57-
bool hasDefaultConstructor(const AbstractMetaClass *meta_class);
58-
5955
static QStringList getOperatorCodes(const AbstractMetaClass* cls) {
6056
QSet<QString> operatorCodes;
6157
AbstractMetaFunctionList returned;
@@ -247,34 +243,11 @@ void SetupGenerator::generate()
247243
continue;
248244
std::stable_sort(list.begin(), list.end(), AbstractMetaClass::less_than);
249245

250-
QString packKey = pack.key();
251-
QString packName = pack.key();
252-
QStringList components = packName.split("_");
253-
if ((components.size() > 2) && (components.at(0) == "com")
254-
&& (components.at(1) == "trolltech")) {
255-
// kill com.trolltech in key
256-
components.removeAt(0);
257-
components.removeAt(0);
258-
}
259-
260-
QString shortPackName;
261-
foreach (QString comp, components) {
262-
comp[0] = comp[0].toUpper();
263-
shortPackName += comp;
264-
}
265-
// add missing camel case (workaround..)
266-
if (shortPackName == "QtWebkit") {
267-
shortPackName = "QtWebKit";
268-
} else if (shortPackName == "QtXmlpatterns") {
269-
shortPackName = "QtXmlPatterns";
270-
} else if (shortPackName == "QtWebenginewidgets") {
271-
shortPackName = "QtWebEngineWidgets";
272-
} else if (shortPackName == "QtOpengl") {
273-
shortPackName = "QtOpenGL";
274-
} else if (shortPackName == "QtUitools") {
275-
shortPackName = "QtUiTools";
276-
}
277-
246+
QString packKey = ShellGenerator::toFileNameBase(pack.key());
247+
QString packName = packKey;
248+
QString qtPackageName = "Qt" + pack.key().split('.').back().split('_').front();
249+
bool isBuiltin = packKey.endsWith("_builtin");
250+
QString initName = qtPackageName + (isBuiltin ? "Builtin" : "");
278251

279252
{
280253
QString fileName(packName + "/" + packKey + "_init.cpp");
@@ -291,7 +264,7 @@ void SetupGenerator::generate()
291264
s << endl;
292265

293266
QStringList polymorphicHandlers;
294-
if (!packName.endsWith("_builtin")) {
267+
if (!isBuiltin) {
295268
polymorphicHandlers = writePolymorphicHandler(s, list.at(0)->package(), classes_with_polymorphic_id, list);
296269
s << endl;
297270
}
@@ -328,11 +301,7 @@ void SetupGenerator::generate()
328301
s << endl;
329302

330303
// declare individual class creation functions
331-
s << "void PythonQt_init_" << shortPackName << "(PyObject* module) {" << endl;
332-
333-
if (shortPackName.endsWith("Builtin")) {
334-
shortPackName = shortPackName.mid(0, shortPackName.length()-strlen("builtin"));
335-
}
304+
s << "void PythonQt_init_" << initName << "(PyObject* module) {" << endl;
336305

337306
foreach (const AbstractMetaClass *cls, list) {
338307
if (cls->qualifiedCppName().contains("Ssl")) {
@@ -367,10 +336,10 @@ void SetupGenerator::generate()
367336
operatorCodes = "0";
368337
}
369338
if (cls->isQObject()) {
370-
s << "PythonQt::priv()->registerClass(&" << cls->qualifiedCppName() << "::staticMetaObject, \"" << shortPackName <<"\", PythonQtCreateObject<PythonQtWrapper_" << cls->name() << ">" << shellCreator << ", module, " << operatorCodes <<");" << endl;
339+
s << "PythonQt::priv()->registerClass(&" << cls->qualifiedCppName() << "::staticMetaObject, \"" << qtPackageName <<"\", PythonQtCreateObject<PythonQtWrapper_" << cls->name() << ">" << shellCreator << ", module, " << operatorCodes <<");" << endl;
371340
} else {
372341
QString baseName = cls->baseClass()?cls->baseClass()->qualifiedCppName():"";
373-
s << "PythonQt::priv()->registerCPPClass(\""<< cls->qualifiedCppName() << "\", \"" << baseName << "\", \"" << shortPackName <<"\", PythonQtCreateObject<PythonQtWrapper_" << cls->name() << ">" << shellCreator << ", module, " << operatorCodes <<");" << endl;
342+
s << "PythonQt::priv()->registerCPPClass(\""<< cls->qualifiedCppName() << "\", \"" << baseName << "\", \"" << qtPackageName <<"\", PythonQtCreateObject<PythonQtWrapper_" << cls->name() << ">" << shellCreator << ", module, " << operatorCodes <<");" << endl;
374343
}
375344
for (AbstractMetaClass* interface : cls->interfaces()) {
376345
// the interface might be our own class... (e.g. QPaintDevice)

generator/shellgenerator.h

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -53,7 +53,7 @@ class ShellGenerator : public Generator
5353
public:
5454
virtual QString subDirectoryForClass(const AbstractMetaClass *cls) const
5555
{
56-
return "generated_cpp/" + cls->package().replace(".", "_") + "/";
56+
return "generated_cpp/" + toFileNameBase(cls->package()) + "/";
5757
}
5858

5959
void writeTypeInfo(QTextStream &s, const AbstractMetaType *type, Option option = NoOption, TypeSystem::Ownership ownership = TypeSystem::InvalidOwnership);
@@ -95,7 +95,9 @@ class ShellGenerator : public Generator
9595
static bool isBuiltIn(const QString& name);
9696

9797
static bool isSpecialStreamingOperator(const AbstractMetaFunction *fun);
98-
98+
99+
static QString toFileNameBase(QString packageName) { return packageName.replace('.', '_').toLower(); }
100+
99101
static void writeInclude(QTextStream &stream, const Include &inc);
100102

101103
// this scope is used in writeFunctionArguments

generator/shellheadergenerator.cpp

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -102,9 +102,10 @@ void ShellHeaderGenerator::write(QTextStream& s, const AbstractMetaClass* meta_c
102102
{
103103
setCurrentScope(meta_class);
104104
QString builtIn = ShellGenerator::isBuiltIn(meta_class->name()) ? "_builtin" : "";
105-
QString pro_file_name = meta_class->package().replace(".", "_") + builtIn + "/" + meta_class->package().replace(".", "_") + builtIn + ".pri";
105+
QString fileBaseName = toFileNameBase(meta_class->package() + builtIn);
106+
QString pro_file_name = fileBaseName + "/" + fileBaseName + ".pri";
106107
priGenerator->addHeader(pro_file_name, fileNameForClass(meta_class));
107-
setupGenerator->addClass(meta_class->package().replace(".", "_") + builtIn, meta_class);
108+
setupGenerator->addClass(meta_class->package() + builtIn, meta_class);
108109

109110
QString include_block = "PYTHONQTWRAPPER_" + meta_class->name().toUpper() + "_H";
110111

generator/shellimplgenerator.cpp

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -73,7 +73,8 @@ void ShellImplGenerator::write(QTextStream &s, const AbstractMetaClass *meta_cla
7373
setCurrentScope(meta_class);
7474

7575
QString builtIn = ShellGenerator::isBuiltIn(meta_class->name())?"_builtin":"";
76-
QString pro_file_name = meta_class->package().replace(".", "_") + builtIn + "/" + meta_class->package().replace(".", "_") + builtIn + ".pri";
76+
QString fileBaseName = toFileNameBase(meta_class->package() + builtIn);
77+
QString pro_file_name = fileBaseName + "/" + fileBaseName + ".pri";
7778
priGenerator->addSource(pro_file_name, fileNameForClass(meta_class));
7879

7980
s << "#include \"PythonQtWrapper_" << meta_class->name() << ".h\"" << endl << endl;

generator/typesystem_core.xml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
<?xml version="1.0"?>
2-
<typesystem package="com.trolltech.qt.core">
2+
<typesystem package="com.trolltech.qt.Core">
33

44
<rejection class="QSysInfo" enum-name="WinVersion"/>
55
<rejection class="QSysInfo" enum-name="MacVersion"/>

generator/typesystem_gui.xml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
<?xml version="1.0"?>
2-
<typesystem package="com.trolltech.qt.gui">
2+
<typesystem package="com.trolltech.qt.Gui">
33
<rejection class="QColormap"/>
44
<rejection class="QIconEngineV2"/>
55
<rejection class="QTextBlock::iterator"/>

generator/typesystem_multimedia.xml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
<?xml version="1.0"?>
2-
<typesystem package="com.trolltech.qt.multimedia">
2+
<typesystem package="com.trolltech.qt.Multimedia">
33

44
<rejection class="QAbstractVideoBuffer" function-name="mapPlanes"/>
55
<rejection class="QAbstractPlanarVideoBuffer"/>

generator/typesystem_network.xml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
<?xml version="1.0"?>
2-
<typesystem package="com.trolltech.qt.network">
2+
<typesystem package="com.trolltech.qt.Network">
33
<namespace-type name="QSsl">
44
<include file-name="qssl.h" location="global"/>
55
</namespace-type>

generator/typesystem_opengl.xml

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
11
<?xml version="1.0"?>
2-
<typesystem package="com.trolltech.qt.opengl"><rejection class="QGL"/>
3-
4-
2+
<typesystem package="com.trolltech.qt.OpenGL">
3+
<rejection class="QGL"/>
54

65
<rejection class="QGLColormap::QGLColormapData"/>
76
<rejection class="QGLWidget" function-name="setMouseTracking"/>

generator/typesystem_qml.xml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
<?xml version="1.0"?>
2-
<typesystem package="com.trolltech.qt.qml">
2+
<typesystem package="com.trolltech.qt.Qml">
33

44
<rejection class="QQmlEngine" function-name="singletonInstance&lt;QJSValue&gt;"/>
55

generator/typesystem_quick.xml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
<?xml version="1.0"?>
2-
<typesystem package="com.trolltech.qt.quick">
2+
<typesystem package="com.trolltech.qt.Quick">
33

44
<!-- not yet supported: -->
55
<rejection class="QSGMaterial"/>

generator/typesystem_sql.xml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
<?xml version="1.0"?>
2-
<typesystem package="com.trolltech.qt.sql">
2+
<typesystem package="com.trolltech.qt.Sql">
33
<rejection class="QSqlDriverCreator"/>
44
<rejection class="QSqlDriverPlugin"/>
55
<rejection class="QSqlDriverFactoryInterface"/>

generator/typesystem_svg.xml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
<?xml version="1.0"?>
2-
<typesystem package="com.trolltech.qt.svg">
2+
<typesystem package="com.trolltech.qt.Svg">
33

44
<namespace-type name="QSvg"/>
55

generator/typesystem_uitools.xml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
<typesystem package="com.trolltech.qt.uitools">
1+
<typesystem package="com.trolltech.qt.UiTools">
22

33
<object-type name="QUiLoader"/>
44

generator/typesystem_webenginewidgets.xml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
<?xml version="1.0"?>
2-
<typesystem package="com.trolltech.qt.webenginewidgets">
2+
<typesystem package="com.trolltech.qt.WebEngineWidgets">
33

44
<object-type name="QWebEngineView">
55
</object-type>

generator/typesystem_webkit.xml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
<?xml version="1.0"?>
2-
<typesystem package="com.trolltech.qt.webkit">
2+
<typesystem package="com.trolltech.qt.WebKit">
33
<rejection class="WebCore"/>
44
<suppress-warning text="WARNING(MetaJavaBuilder) :: skipping field 'QWebPluginFactory_Plugin::mimeTypes' with unmatched type 'QList&lt;MimeType&gt;'"/>
55
<namespace-type name="WebCore"/>

generator/typesystem_xml.xml

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
<?xml version="1.0"?>
2-
<typesystem package="com.trolltech.qt.xml"><rejection class="QXmlNamespaceSupport"/>
2+
<typesystem package="com.trolltech.qt.Xml">
3+
<rejection class="QXmlNamespaceSupport"/>
34
<rejection class="QXmlAttributes::Attribute"/>
45
<rejection class="QDomNode" field-name="impl"/>
56

generator/typesystem_xmlpatterns.xml

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
11
<?xml version="1.0"?>
2-
<typesystem package="com.trolltech.qt.xmlpatterns"><suppress-warning text="WARNING(MetaJavaBuilder) :: unhandled enum value: ForwardAxis in QXmlNodeModelIndex::Axis"/><suppress-warning text="WARNING(MetaJavaBuilder) :: unhandled enum value: ReverseAxis in QXmlNodeModelIndex::Axis"/>
3-
2+
<typesystem package="com.trolltech.qt.XmlPatterns">
43

54
<namespace-type name="QPatternist"/>
65
<namespace-type name="QPatternistSDK"/>
@@ -112,6 +111,8 @@
112111
</object-type>
113112

114113

114+
<suppress-warning text="WARNING(MetaJavaBuilder) :: unhandled enum value: ForwardAxis in QXmlNodeModelIndex::Axis"/>
115+
<suppress-warning text="WARNING(MetaJavaBuilder) :: unhandled enum value: ReverseAxis in QXmlNodeModelIndex::Axis"/>
115116

116117
<suppress-warning text="WARNING(MetaJavaBuilder) :: horribly broken type ''"/>
117118
<suppress-warning text="WARNING(MetaJavaBuilder) :: template baseclass 'QExplicitlySharedDataPointer&lt;QXmlSerializer&gt;' of 'QXmlSerializerPointer' is not known"/>

0 commit comments

Comments
 (0)