From 380c65e62de0e60da667dc0d87935171b91b9c6c Mon Sep 17 00:00:00 2001 From: Christian Tismer Date: Sun, 16 Jun 2019 12:05:39 +0200 Subject: Cleanup pointer whitespace everywhere Among other files to fix, basewrapper.(cpp|h) was full of uncommon pointer whitespace. After fixing that, I could not resist and fixed also libshiboken, generators, and after acceptance also PySide. Most of the time, this regex worked fine (\w\w+)([*&]+)[ ]*(?![&*]*[/=]) replaced with \1 \2 but everything was checked by hand. I did not touch the shiboken tests which are quite hairy. It turned out that inserting a space between a variable and asterisk causes a crash of shiboken, if the same line contains "CONVERTTOCPP". This was temporarily fixed by adding another space after it. Example.. sources/pyside2/PySide2/glue/qtcore.cpp line 977 QByteArray * cppSelf = %CONVERTTOCPP[QByteArray *](obj); //XXX /|\ omitting this space crashes shiboken! cppgenerator.cpp was special, since it was modified to _generate_ correct pointer whitespace. This caused a few testcases to fail, which had to be adjusted, again. This was difficult since some internal names must end on "*" and generated code normally not. Removing the last errors involved binary search on path sets... Apply C++ 11 fixits to the changed code, where applicable. Done-with: Friedemann.Kleint@qt.io Task-number: PYSIDE-1037 Change-Id: I4ac070f52c5efb296c05d581c9d46e6f397a6c81 Reviewed-by: Qt CI Bot Reviewed-by: Friedemann Kleint --- sources/shiboken2/generator/generator.h | 64 ++++++++++++++++----------------- 1 file changed, 32 insertions(+), 32 deletions(-) (limited to 'sources/shiboken2/generator/generator.h') diff --git a/sources/shiboken2/generator/generator.h b/sources/shiboken2/generator/generator.h index 04840427f..b7b002ea6 100644 --- a/sources/shiboken2/generator/generator.h +++ b/sources/shiboken2/generator/generator.h @@ -56,11 +56,11 @@ QT_END_NAMESPACE class PrimitiveTypeEntry; class ContainerTypeEntry; -QTextStream& formatCode(QTextStream &s, const QString& code, Indentor &indentor); +QTextStream &formatCode(QTextStream &s, const QString &code, Indentor &indentor); void verifyDirectoryFor(const QString &file); -QString getClassTargetFullName(const AbstractMetaClass* metaClass, bool includePackageName = true); -QString getClassTargetFullName(const AbstractMetaEnum* metaEnum, bool includePackageName = true); +QString getClassTargetFullName(const AbstractMetaClass *metaClass, bool includePackageName = true); +QString getClassTargetFullName(const AbstractMetaEnum *metaEnum, bool includePackageName = true); QString getClassTargetFullName(const AbstractMetaType *metaType, bool includePackageName = true); QString getFilteredCppSignatureString(QString signature); @@ -202,7 +202,7 @@ public: Generator(); virtual ~Generator(); - bool setup(const ApiExtractor& extractor); + bool setup(const ApiExtractor &extractor); virtual OptionDescriptions options() const; virtual bool handleOption(const QString &key, const QString &value); @@ -231,7 +231,7 @@ public: void setLicenseComment(const QString &licenseComment); /// Returns the generator's name. Used for cosmetic purposes. - virtual const char* name() const = 0; + virtual const char *name() const = 0; /** * Retrieves the name of the currently processed module. @@ -250,24 +250,24 @@ public: * \param type a TypeEntry that is expected to be a value-type * \return a list of constructors that could be used as implicit converters */ - AbstractMetaFunctionList implicitConversions(const TypeEntry* type) const; + AbstractMetaFunctionList implicitConversions(const TypeEntry *type) const; - /// Convenience function for implicitConversions(const TypeEntry* type). - AbstractMetaFunctionList implicitConversions(const AbstractMetaType* metaType) const; + /// Convenience function for implicitConversions(const TypeEntry *type). + AbstractMetaFunctionList implicitConversions(const AbstractMetaType *metaType) const; /// Check if type is a pointer. - static bool isPointer(const AbstractMetaType* type); + static bool isPointer(const AbstractMetaType *type); /// Tells if the type or class is an Object (or QObject) Type. - static bool isObjectType(const TypeEntry* type); - static bool isObjectType(const ComplexTypeEntry* type); - static bool isObjectType(const AbstractMetaType* metaType); - static bool isObjectType(const AbstractMetaClass* metaClass); + static bool isObjectType(const TypeEntry *type); + static bool isObjectType(const ComplexTypeEntry *type); + static bool isObjectType(const AbstractMetaType *metaType); + static bool isObjectType(const AbstractMetaClass *metaClass); - /// Returns true if the type is a C string (const char*). - static bool isCString(const AbstractMetaType* type); + /// Returns true if the type is a C string (const char *). + static bool isCString(const AbstractMetaType *type); /// Returns true if the type is a void pointer. - static bool isVoidPointer(const AbstractMetaType* type); + static bool isVoidPointer(const AbstractMetaType *type); protected: /// Returns the classes, topologically ordered, used to generate the binding code. @@ -289,10 +289,10 @@ protected: ContainerTypeEntryList containerTypes() const; /// Returns an AbstractMetaEnum for a given TypeEntry that is an EnumTypeEntry, or nullptr if not found. - const AbstractMetaEnum* findAbstractMetaEnum(const TypeEntry* typeEntry) const; + const AbstractMetaEnum *findAbstractMetaEnum(const TypeEntry *typeEntry) const; /// Returns an AbstractMetaEnum for a given AbstractMetaType that holds an EnumTypeEntry, or nullptr if not found. - const AbstractMetaEnum* findAbstractMetaEnum(const AbstractMetaType* metaType) const; + const AbstractMetaEnum *findAbstractMetaEnum(const AbstractMetaType *metaType) const; /// Generates a file for given AbstractMetaClass or AbstractMetaType (smart pointer case). bool generateFileForContext(GeneratorContext &context); @@ -302,13 +302,13 @@ protected: const AbstractMetaClass *smartPointerClass) const; /// Returns true if the generator should generate any code for the TypeEntry. - bool shouldGenerateTypeEntry(const TypeEntry*) const; + bool shouldGenerateTypeEntry(const TypeEntry *) const; /// Returns true if the generator should generate any code for the AbstractMetaClass. virtual bool shouldGenerate(const AbstractMetaClass *) const; /// Returns the subdirectory used to write the binding code of an AbstractMetaClass. - virtual QString subDirectoryForClass(const AbstractMetaClass* clazz) const; + virtual QString subDirectoryForClass(const AbstractMetaClass *clazz) const; /** * Translate metatypes to binding source format. @@ -344,25 +344,25 @@ protected: QString packageName() const; // Returns the full name of the type. - QString getFullTypeName(const TypeEntry* type) const; - QString getFullTypeName(const AbstractMetaType* type) const; - QString getFullTypeName(const AbstractMetaClass* metaClass) const; + QString getFullTypeName(const TypeEntry *type) const; + QString getFullTypeName(const AbstractMetaType *type) const; + QString getFullTypeName(const AbstractMetaClass *metaClass) const; /** * Returns the full qualified C++ name for an AbstractMetaType, but removing modifiers * as 'const', '&', and '*' (except if the class is not derived from a template). * This is useful for instantiated templates. */ - QString getFullTypeNameWithoutModifiers(const AbstractMetaType* type) const; + QString getFullTypeNameWithoutModifiers(const AbstractMetaType *type) const; /** * Tries to build a minimal constructor for the type. * It will check first for a user defined default constructor. * Returns a null string if it fails. */ - DefaultValue minimalConstructor(const TypeEntry* type) const; - DefaultValue minimalConstructor(const AbstractMetaType* type) const; - DefaultValue minimalConstructor(const AbstractMetaClass* metaClass) const; + DefaultValue minimalConstructor(const TypeEntry *type) const; + DefaultValue minimalConstructor(const AbstractMetaType *type) const; + DefaultValue minimalConstructor(const AbstractMetaClass *metaClass) const; /** * Returns the file name used to write the binding code of an AbstractMetaClass/Type. @@ -382,7 +382,7 @@ protected: * \param s text stream to write the generated output * \param metaClass the class that should be generated */ - virtual void generateClass(QTextStream& s, GeneratorContext &classContext) = 0; + virtual void generateClass(QTextStream &s, GeneratorContext &classContext) = 0; virtual bool finishGeneration() = 0; /** @@ -396,8 +396,8 @@ protected: */ virtual QString subDirectoryForPackage(QString packageName = QString()) const; - QVector instantiatedContainers() const; - QVector instantiatedSmartPointers() const; + QVector instantiatedContainers() const; + QVector instantiatedSmartPointers() const; static QString getSimplifiedContainerTypeName(const AbstractMetaType *type); void addInstantiatedContainersAndSmartPointers(const AbstractMetaType *type, @@ -407,8 +407,8 @@ private: bool useEnumAsIntForProtectedHack(const AbstractMetaType *cType) const; struct GeneratorPrivate; - GeneratorPrivate* m_d; - void collectInstantiatedContainersAndSmartPointers(const AbstractMetaFunction* func); + GeneratorPrivate *m_d; + void collectInstantiatedContainersAndSmartPointers(const AbstractMetaFunction *func); void collectInstantiatedContainersAndSmartPointers(const AbstractMetaClass *metaClass); void collectInstantiatedContainersAndSmartPointers(); }; -- cgit v1.2.3 From d8e42fbde07db9980e182e80a7b42c20d1485f8d Mon Sep 17 00:00:00 2001 From: Friedemann Kleint Date: Tue, 25 Jun 2019 09:39:12 +0200 Subject: shiboken: Introduce member initialization Use member initialization, use default bodies for constructors. Initialize missing members as reported by clang. Change-Id: Ibc51e46a37b310912ec8f274543092dfdda78e1b Reviewed-by: Christian Tismer --- sources/shiboken2/generator/generator.h | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) (limited to 'sources/shiboken2/generator/generator.h') diff --git a/sources/shiboken2/generator/generator.h b/sources/shiboken2/generator/generator.h index b7b002ea6..1642752be 100644 --- a/sources/shiboken2/generator/generator.h +++ b/sources/shiboken2/generator/generator.h @@ -147,7 +147,7 @@ private: */ class GeneratorContext { public: - GeneratorContext() : m_metaClass(0), m_preciseClassType(0), m_forSmartPointer(false) {} + GeneratorContext() = default; GeneratorContext(AbstractMetaClass *metaClass, const AbstractMetaType *preciseType = 0, bool forSmartPointer = false) @@ -161,9 +161,9 @@ public: const AbstractMetaType *preciseType() const { return m_preciseClassType; } private: - AbstractMetaClass *m_metaClass; - const AbstractMetaType *m_preciseClassType; - bool m_forSmartPointer; + AbstractMetaClass *m_metaClass = nullptr; + const AbstractMetaType *m_preciseClassType = nullptr; + bool m_forSmartPointer = false; }; /** -- cgit v1.2.3 From ddfbbd346b522703a5b6f8d274a7f79983e5f319 Mon Sep 17 00:00:00 2001 From: Friedemann Kleint Date: Tue, 25 Jun 2019 09:33:27 +0200 Subject: shiboken: Introduce nullptr Apply Fixits by Qt Creator with some amendments. Change-Id: Ie8300ddb834adb8b649324562f2c912a4e8cf4ce Reviewed-by: Christian Tismer --- sources/shiboken2/generator/generator.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'sources/shiboken2/generator/generator.h') diff --git a/sources/shiboken2/generator/generator.h b/sources/shiboken2/generator/generator.h index 1642752be..9d4201bc5 100644 --- a/sources/shiboken2/generator/generator.h +++ b/sources/shiboken2/generator/generator.h @@ -149,7 +149,7 @@ class GeneratorContext { public: GeneratorContext() = default; GeneratorContext(AbstractMetaClass *metaClass, - const AbstractMetaType *preciseType = 0, + const AbstractMetaType *preciseType = nullptr, bool forSmartPointer = false) : m_metaClass(metaClass), m_preciseClassType(preciseType), -- cgit v1.2.3 From 7be4e64b4bac6e6b5a90eec74b9f2b661c60db3a Mon Sep 17 00:00:00 2001 From: Friedemann Kleint Date: Wed, 29 May 2019 10:45:37 +0200 Subject: shiboken: Replace 'typedef' by 'using' Apply Fixits by Qt Creator with some amendments. Remove iterator types by using auto instead. Change-Id: I8a75323da6ae5cdcc6b67af8be9376408953986b Reviewed-by: Christian Tismer --- sources/shiboken2/generator/generator.h | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) (limited to 'sources/shiboken2/generator/generator.h') diff --git a/sources/shiboken2/generator/generator.h b/sources/shiboken2/generator/generator.h index 9d4201bc5..dde281f0e 100644 --- a/sources/shiboken2/generator/generator.h +++ b/sources/shiboken2/generator/generator.h @@ -173,8 +173,8 @@ private: class Generator { public: - typedef QPair OptionDescription; - typedef QVector OptionDescriptions; + using OptionDescription = QPair; + using OptionDescriptions = QVector; /// Optiosn used around the generator code enum Option { @@ -414,8 +414,8 @@ private: }; Q_DECLARE_OPERATORS_FOR_FLAGS(Generator::Options) -typedef QSharedPointer GeneratorPtr; -typedef QVector Generators; +using GeneratorPtr = QSharedPointer; +using Generators = QVector; #endif // GENERATOR_H -- cgit v1.2.3