aboutsummaryrefslogtreecommitdiffstats
path: root/sources/shiboken2/generator
diff options
context:
space:
mode:
authorFriedemann Kleint <Friedemann.Kleint@qt.io>2019-07-03 08:24:42 +0200
committerFriedemann Kleint <Friedemann.Kleint@qt.io>2019-07-03 13:42:12 +0200
commit3dd32863337ea2f6308ebf2f7656795d3fd488c9 (patch)
tree08a3b35607dee19536ccb5f21b2ede0fdc41cc79 /sources/shiboken2/generator
parent4f4f1be9f46e02e87357aeee613cfd5ea0be8220 (diff)
parent67d635fe2cc2c89c30486a2e26dea4106a9d9c16 (diff)
Merge "Merge remote-tracking branch 'origin/5.13' into dev"
Diffstat (limited to 'sources/shiboken2/generator')
-rw-r--r--sources/shiboken2/generator/generator.cpp72
-rw-r--r--sources/shiboken2/generator/generator.h82
-rw-r--r--sources/shiboken2/generator/main.cpp10
-rw-r--r--sources/shiboken2/generator/qtdoc/qtdocgenerator.cpp39
-rw-r--r--sources/shiboken2/generator/qtdoc/qtdocgenerator.h18
-rw-r--r--sources/shiboken2/generator/shiboken2/cppgenerator.cpp802
-rw-r--r--sources/shiboken2/generator/shiboken2/cppgenerator.h201
-rw-r--r--sources/shiboken2/generator/shiboken2/headergenerator.cpp72
-rw-r--r--sources/shiboken2/generator/shiboken2/headergenerator.h22
-rw-r--r--sources/shiboken2/generator/shiboken2/overloaddata.cpp106
-rw-r--r--sources/shiboken2/generator/shiboken2/overloaddata.h62
-rw-r--r--sources/shiboken2/generator/shiboken2/shibokengenerator.cpp358
-rw-r--r--sources/shiboken2/generator/shiboken2/shibokengenerator.h276
13 files changed, 1059 insertions, 1061 deletions
diff --git a/sources/shiboken2/generator/generator.cpp b/sources/shiboken2/generator/generator.cpp
index 49064a6a..6da9fd93 100644
--- a/sources/shiboken2/generator/generator.cpp
+++ b/sources/shiboken2/generator/generator.cpp
@@ -153,7 +153,7 @@ QString DefaultValue::constructorParameter() const
struct Generator::GeneratorPrivate
{
- const ApiExtractor* apiextractor = nullptr;
+ const ApiExtractor *apiextractor = nullptr;
QString outDir;
// License comment
QString licenseComment;
@@ -174,7 +174,7 @@ Generator::~Generator()
delete m_d;
}
-bool Generator::setup(const ApiExtractor& extractor)
+bool Generator::setup(const ApiExtractor &extractor)
{
m_d->apiextractor = &extractor;
const auto moduleEntry = TypeDatabase::instance()->defaultTypeSystemType();
@@ -188,7 +188,7 @@ bool Generator::setup(const ApiExtractor& extractor)
return doSetup();
}
-QString Generator::getSimplifiedContainerTypeName(const AbstractMetaType* type)
+QString Generator::getSimplifiedContainerTypeName(const AbstractMetaType *type)
{
const QString signature = type->cppSignature();
if (!type->typeEntry()->isContainer() && !type->typeEntry()->isSmartPointer())
@@ -217,7 +217,7 @@ void Generator::addInstantiatedContainersAndSmartPointers(const AbstractMetaType
if (!type)
return;
const AbstractMetaTypeList &instantiations = type->instantiations();
- for (const AbstractMetaType* t : instantiations)
+ for (const AbstractMetaType *t : instantiations)
addInstantiatedContainersAndSmartPointers(t, context);
const auto typeEntry = type->typeEntry();
const bool isContainer = typeEntry->isContainer();
@@ -298,7 +298,7 @@ QVector<const AbstractMetaType *> Generator::instantiatedContainers() const
return m_d->instantiatedContainers;
}
-QVector<const AbstractMetaType*> Generator::instantiatedSmartPointers() const
+QVector<const AbstractMetaType *> Generator::instantiatedSmartPointers() const
{
return m_d->instantiatedSmartPointers;
}
@@ -343,12 +343,12 @@ ContainerTypeEntryList Generator::containerTypes() const
return m_d->apiextractor->containerTypes();
}
-const AbstractMetaEnum* Generator::findAbstractMetaEnum(const TypeEntry* typeEntry) const
+const AbstractMetaEnum *Generator::findAbstractMetaEnum(const TypeEntry *typeEntry) const
{
return m_d->apiextractor->findAbstractMetaEnum(typeEntry);
}
-const AbstractMetaEnum* Generator::findAbstractMetaEnum(const AbstractMetaType* metaType) const
+const AbstractMetaEnum *Generator::findAbstractMetaEnum(const AbstractMetaType *metaType) const
{
return m_d->apiextractor->findAbstractMetaEnum(metaType->typeEntry());
}
@@ -358,7 +358,7 @@ QString Generator::licenseComment() const
return m_d->licenseComment;
}
-void Generator::setLicenseComment(const QString& licenseComment)
+void Generator::setLicenseComment(const QString &licenseComment)
{
m_d->licenseComment = licenseComment;
}
@@ -440,12 +440,12 @@ bool Generator::generate()
return finishGeneration();
}
-bool Generator::shouldGenerateTypeEntry(const TypeEntry* type) const
+bool Generator::shouldGenerateTypeEntry(const TypeEntry *type) const
{
return type->codeGeneration() & TypeEntry::GenerateTargetLang;
}
-bool Generator::shouldGenerate(const AbstractMetaClass* metaClass) const
+bool Generator::shouldGenerate(const AbstractMetaClass *metaClass) const
{
return shouldGenerateTypeEntry(metaClass->typeEntry());
}
@@ -490,7 +490,7 @@ void Generator::replaceTemplateVariables(QString &code, const AbstractMetaFuncti
}
}
-QTextStream& formatCode(QTextStream &s, const QString& code, Indentor &indentor)
+QTextStream &formatCode(QTextStream &s, const QString &code, Indentor &indentor)
{
// detect number of spaces before the first character
const QStringList lst(code.split(QLatin1Char('\n')));
@@ -527,7 +527,7 @@ QTextStream& formatCode(QTextStream &s, const QString& code, Indentor &indentor)
return s;
}
-AbstractMetaFunctionList Generator::implicitConversions(const TypeEntry* type) const
+AbstractMetaFunctionList Generator::implicitConversions(const TypeEntry *type) const
{
if (type->isValue()) {
if (const AbstractMetaClass *metaClass = AbstractMetaClass::findClass(classes(), type))
@@ -536,52 +536,52 @@ AbstractMetaFunctionList Generator::implicitConversions(const TypeEntry* type) c
return AbstractMetaFunctionList();
}
-AbstractMetaFunctionList Generator::implicitConversions(const AbstractMetaType* metaType) const
+AbstractMetaFunctionList Generator::implicitConversions(const AbstractMetaType *metaType) const
{
return implicitConversions(metaType->typeEntry());
}
-bool Generator::isObjectType(const TypeEntry* type)
+bool Generator::isObjectType(const TypeEntry *type)
{
if (type->isComplex())
return Generator::isObjectType(static_cast<const ComplexTypeEntry *>(type));
return type->isObject();
}
-bool Generator::isObjectType(const ComplexTypeEntry* type)
+bool Generator::isObjectType(const ComplexTypeEntry *type)
{
return type->isObject();
}
-bool Generator::isObjectType(const AbstractMetaClass* metaClass)
+bool Generator::isObjectType(const AbstractMetaClass *metaClass)
{
return Generator::isObjectType(metaClass->typeEntry());
}
-bool Generator::isObjectType(const AbstractMetaType* metaType)
+bool Generator::isObjectType(const AbstractMetaType *metaType)
{
return isObjectType(metaType->typeEntry());
}
-bool Generator::isPointer(const AbstractMetaType* type)
+bool Generator::isPointer(const AbstractMetaType *type)
{
return type->indirections() > 0
|| type->isNativePointer()
|| type->isValuePointer();
}
-bool Generator::isCString(const AbstractMetaType* type)
+bool Generator::isCString(const AbstractMetaType *type)
{
return type->isNativePointer()
&& type->indirections() == 1
&& type->name() == QLatin1String("char");
}
-bool Generator::isVoidPointer(const AbstractMetaType* type)
+bool Generator::isVoidPointer(const AbstractMetaType *type)
{
return type->isNativePointer()
&& type->indirections() == 1
&& type->name() == QLatin1String("void");
}
-QString Generator::getFullTypeName(const TypeEntry* type) const
+QString Generator::getFullTypeName(const TypeEntry *type) const
{
QString result = type->qualifiedCppName();
if (type->isArray())
@@ -591,7 +591,7 @@ QString Generator::getFullTypeName(const TypeEntry* type) const
return result;
}
-QString Generator::getFullTypeName(const AbstractMetaType* type) const
+QString Generator::getFullTypeName(const AbstractMetaType *type) const
{
if (isCString(type))
return QLatin1String("const char*");
@@ -607,12 +607,12 @@ QString Generator::getFullTypeName(const AbstractMetaType* type) const
return typeName + QString::fromLatin1("*").repeated(type->indirections());
}
-QString Generator::getFullTypeName(const AbstractMetaClass* metaClass) const
+QString Generator::getFullTypeName(const AbstractMetaClass *metaClass) const
{
return QLatin1String("::") + metaClass->qualifiedCppName();
}
-QString Generator::getFullTypeNameWithoutModifiers(const AbstractMetaType* type) const
+QString Generator::getFullTypeNameWithoutModifiers(const AbstractMetaType *type) const
{
if (isCString(type))
return QLatin1String("const char*");
@@ -638,7 +638,7 @@ QString Generator::getFullTypeNameWithoutModifiers(const AbstractMetaType* type)
return QLatin1String("::") + typeName;
}
-DefaultValue Generator::minimalConstructor(const AbstractMetaType* type) const
+DefaultValue Generator::minimalConstructor(const AbstractMetaType *type) const
{
if (!type || (type->referenceType() == LValueReference && Generator::isObjectType(type)))
return DefaultValue(DefaultValue::Error);
@@ -664,7 +664,7 @@ DefaultValue Generator::minimalConstructor(const AbstractMetaType* type) const
return DefaultValue(DefaultValue::Pointer, QLatin1String("::") + type->typeEntry()->qualifiedCppName());
if (type->typeEntry()->isComplex()) {
- const ComplexTypeEntry* cType = static_cast<const ComplexTypeEntry*>(type->typeEntry());
+ auto cType = static_cast<const ComplexTypeEntry *>(type->typeEntry());
if (cType->hasDefaultConstructor())
return DefaultValue(DefaultValue::Custom, cType->defaultConstructor());
auto ctor = minimalConstructor(AbstractMetaClass::findClass(classes(), cType));
@@ -679,7 +679,7 @@ DefaultValue Generator::minimalConstructor(const AbstractMetaType* type) const
return minimalConstructor(type->typeEntry());
}
-DefaultValue Generator::minimalConstructor(const TypeEntry* type) const
+DefaultValue Generator::minimalConstructor(const TypeEntry *type) const
{
if (!type)
return DefaultValue(DefaultValue::Error);
@@ -706,7 +706,7 @@ DefaultValue Generator::minimalConstructor(const TypeEntry* type) const
}
if (type->isPrimitive()) {
- QString ctor = static_cast<const PrimitiveTypeEntry*>(type)->defaultConstructor();
+ QString ctor = static_cast<const PrimitiveTypeEntry *>(type)->defaultConstructor();
// If a non-C++ (i.e. defined by the user) primitive type does not have
// a default constructor defined by the user, the empty constructor is
// heuristically returned. If this is wrong the build of the generated
@@ -729,12 +729,12 @@ static QString constructorCall(const QString &qualifiedCppName, const QStringLis
+ args.join(QLatin1String(", ")) + QLatin1Char(')');
}
-DefaultValue Generator::minimalConstructor(const AbstractMetaClass* metaClass) const
+DefaultValue Generator::minimalConstructor(const AbstractMetaClass *metaClass) const
{
if (!metaClass)
return DefaultValue(DefaultValue::Error);
- const ComplexTypeEntry* cType = static_cast<const ComplexTypeEntry*>(metaClass->typeEntry());
+ auto cType = static_cast<const ComplexTypeEntry *>(metaClass->typeEntry());
if (cType->hasDefaultConstructor())
return DefaultValue(DefaultValue::Custom, cType->defaultConstructor());
@@ -845,7 +845,7 @@ QString Generator::translateType(const AbstractMetaType *cType,
s = s.remove(index, constLen);
}
} else if (options & Generator::ExcludeConst || options & Generator::ExcludeReference) {
- AbstractMetaType* copyType = cType->copy();
+ AbstractMetaType *copyType = cType->copy();
if (options & Generator::ExcludeConst)
copyType->setConstant(false);
@@ -866,7 +866,7 @@ QString Generator::translateType(const AbstractMetaType *cType,
}
-QString Generator::subDirectoryForClass(const AbstractMetaClass* clazz) const
+QString Generator::subDirectoryForClass(const AbstractMetaClass *clazz) const
{
return subDirectoryForPackage(clazz->package());
}
@@ -880,10 +880,10 @@ QString Generator::subDirectoryForPackage(QString packageNameIn) const
}
template<typename T>
-static QString getClassTargetFullName_(const T* t, bool includePackageName)
+static QString getClassTargetFullName_(const T *t, bool includePackageName)
{
QString name = t->name();
- const AbstractMetaClass* context = t->enclosingClass();
+ const AbstractMetaClass *context = t->enclosingClass();
while (context) {
name.prepend(QLatin1Char('.'));
name.prepend(context->name());
@@ -896,12 +896,12 @@ static QString getClassTargetFullName_(const T* t, bool includePackageName)
return name;
}
-QString getClassTargetFullName(const AbstractMetaClass* metaClass, bool includePackageName)
+QString getClassTargetFullName(const AbstractMetaClass *metaClass, bool includePackageName)
{
return getClassTargetFullName_(metaClass, includePackageName);
}
-QString getClassTargetFullName(const AbstractMetaEnum* metaEnum, bool includePackageName)
+QString getClassTargetFullName(const AbstractMetaEnum *metaEnum, bool includePackageName)
{
return getClassTargetFullName_(metaEnum, includePackageName);
}
diff --git a/sources/shiboken2/generator/generator.h b/sources/shiboken2/generator/generator.h
index 04840427..dde281f0 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);
@@ -147,9 +147,9 @@ private:
*/
class GeneratorContext {
public:
- GeneratorContext() : m_metaClass(0), m_preciseClassType(0), m_forSmartPointer(false) {}
+ GeneratorContext() = default;
GeneratorContext(AbstractMetaClass *metaClass,
- const AbstractMetaType *preciseType = 0,
+ const AbstractMetaType *preciseType = nullptr,
bool forSmartPointer = false)
: m_metaClass(metaClass),
m_preciseClassType(preciseType),
@@ -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;
};
/**
@@ -173,8 +173,8 @@ private:
class Generator
{
public:
- typedef QPair<QString, QString> OptionDescription;
- typedef QVector<OptionDescription> OptionDescriptions;
+ using OptionDescription = QPair<QString, QString>;
+ using OptionDescriptions = QVector<OptionDescription>;
/// Optiosn used around the generator code
enum Option {
@@ -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<const AbstractMetaType*> instantiatedContainers() const;
- QVector<const AbstractMetaType*> instantiatedSmartPointers() const;
+ QVector<const AbstractMetaType *> instantiatedContainers() const;
+ QVector<const AbstractMetaType *> instantiatedSmartPointers() const;
static QString getSimplifiedContainerTypeName(const AbstractMetaType *type);
void addInstantiatedContainersAndSmartPointers(const AbstractMetaType *type,
@@ -407,15 +407,15 @@ 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();
};
Q_DECLARE_OPERATORS_FOR_FLAGS(Generator::Options)
-typedef QSharedPointer<Generator> GeneratorPtr;
-typedef QVector<GeneratorPtr> Generators;
+using GeneratorPtr = QSharedPointer<Generator>;
+using Generators = QVector<GeneratorPtr>;
#endif // GENERATOR_H
diff --git a/sources/shiboken2/generator/main.cpp b/sources/shiboken2/generator/main.cpp
index ac576d65..25daea99 100644
--- a/sources/shiboken2/generator/main.cpp
+++ b/sources/shiboken2/generator/main.cpp
@@ -59,11 +59,11 @@ static inline QString skipDeprecatedOption() { return QStringLiteral("skip-depre
static const char helpHint[] = "Note: use --help or -h for more information.\n";
-typedef QMap<QString, QString> CommandArgumentMap;
+using CommandArgumentMap = QMap<QString, QString>;
-typedef Generator::OptionDescriptions OptionDescriptions;
+using OptionDescriptions = Generator::OptionDescriptions;
-static void printOptions(QTextStream& s, const OptionDescriptions& options)
+static void printOptions(QTextStream &s, const OptionDescriptions &options)
{
s.setFieldAlignment(QTextStream::AlignLeft);
for (const auto &od : options) {
@@ -82,7 +82,7 @@ static void printOptions(QTextStream& s, const OptionDescriptions& options)
}
}
-static bool processProjectFile(QFile& projectFile, QMap<QString, QString>& args)
+static bool processProjectFile(QFile &projectFile, QMap<QString, QString> &args)
{
QByteArray line = projectFile.readLine().trimmed();
if (line.isEmpty() || line != "[generator-project]")
@@ -355,7 +355,7 @@ static inline void printVerAndBanner()
std::cout << "Copyright (C) 2016 The Qt Company Ltd." << std::endl;
}
-static inline void errorPrint(const QString& s)
+static inline void errorPrint(const QString &s)
{
QStringList arguments = QCoreApplication::arguments();
arguments.pop_front();
diff --git a/sources/shiboken2/generator/qtdoc/qtdocgenerator.cpp b/sources/shiboken2/generator/qtdoc/qtdocgenerator.cpp
index 6abfde7c..9cad400f 100644
--- a/sources/shiboken2/generator/qtdoc/qtdocgenerator.cpp
+++ b/sources/shiboken2/generator/qtdoc/qtdocgenerator.cpp
@@ -387,7 +387,7 @@ QtXmlToSphinx::QtXmlToSphinx(QtDocGenerator* generator, const QString& doc, cons
void QtXmlToSphinx::pushOutputBuffer()
{
- QString* buffer = new QString();
+ auto *buffer = new QString();
m_buffers << buffer;
m_output.setString(buffer);
}
@@ -427,7 +427,7 @@ QString QtXmlToSphinx::resolveContextForMethod(const QString& methodName) const
{
const QStringRef currentClass = m_context.splitRef(QLatin1Char('.')).constLast();
- const AbstractMetaClass* metaClass = 0;
+ const AbstractMetaClass *metaClass = nullptr;
const AbstractMetaClassList &classes = m_generator->classes();
for (const AbstractMetaClass *cls : classes) {
if (cls->name() == currentClass) {
@@ -444,7 +444,7 @@ QString QtXmlToSphinx::resolveContextForMethod(const QString& methodName) const
funcList.append(func);
}
- const AbstractMetaClass* implementingClass = 0;
+ const AbstractMetaClass *implementingClass = nullptr;
for (const AbstractMetaFunction *func : qAsConst(funcList)) {
implementingClass = func->implementingClass();
if (implementingClass->name() == currentClass)
@@ -528,7 +528,6 @@ static QString resolveFile(const QStringList &locations, const QString &path)
QString QtXmlToSphinx::readFromLocations(const QStringList &locations, const QString &path,
const QString &identifier, QString *errorMessage)
{
- QString result;
QString resolvedPath;
if (path.endsWith(QLatin1String(".cpp"))) {
const QString pySnippet = path.left(path.size() - 3) + QLatin1String("py");
@@ -919,7 +918,8 @@ void QtXmlToSphinx::handleListTag(QXmlStreamReader& reader)
if (token == QXmlStreamReader::StartElement) {
listType = webXmlListType(reader.attributes().value(QLatin1String("type")));
if (listType == EnumeratedList) {
- m_currentTable << (TableRow() << "Constant" << "Description");
+ m_currentTable << TableRow{TableCell(QLatin1String("Constant")),
+ TableCell(QLatin1String("Description"))};
m_tableHasHeader = true;
}
INDENT.indent--;
@@ -981,7 +981,7 @@ QtXmlToSphinx::LinkContext *QtXmlToSphinx::handleLinkStart(const QString &type,
{
ref.replace(QLatin1String("::"), QLatin1String("."));
ref.remove(QLatin1String("()"));
- LinkContext *result = new LinkContext(ref);
+ auto *result = new LinkContext(ref);
if (m_insideBold)
result->flags |= LinkContext::InsideBold;
@@ -1503,7 +1503,7 @@ static QString getFuncName(const AbstractMetaFunction* cppFunc) {
return result;
}
-QtDocGenerator::QtDocGenerator() : m_docParser(0)
+QtDocGenerator::QtDocGenerator() : m_docParser(nullptr)
{
}
@@ -1656,8 +1656,8 @@ void QtDocGenerator::generateClass(QTextStream &s, GeneratorContext &classContex
"--------------------\n\n"
<< ".. _More:\n";
- writeInjectDocumentation(s, TypeSystem::DocModificationPrepend, metaClass, 0);
- if (!writeInjectDocumentation(s, TypeSystem::DocModificationReplace, metaClass, 0))
+ writeInjectDocumentation(s, TypeSystem::DocModificationPrepend, metaClass, nullptr);
+ if (!writeInjectDocumentation(s, TypeSystem::DocModificationReplace, metaClass, nullptr))
writeFormattedText(s, documentation, metaClass);
if (!metaClass->isNamespace())
@@ -1679,7 +1679,7 @@ void QtDocGenerator::generateClass(QTextStream &s, GeneratorContext &classContex
writeFunction(s, metaClass, func);
}
- writeInjectDocumentation(s, TypeSystem::DocModificationAppend, metaClass, 0);
+ writeInjectDocumentation(s, TypeSystem::DocModificationAppend, metaClass, nullptr);
}
void QtDocGenerator::writeFunctionList(QTextStream& s, const AbstractMetaClass* cppClass)
@@ -1910,7 +1910,7 @@ void QtDocGenerator::writeDocSnips(QTextStream &s,
QString codeBlock = code.mid(startBlock, endBlock - startBlock);
const QStringList rows = codeBlock.split(QLatin1Char('\n'));
- int currenRow = 0;
+ int currentRow = 0;
int offset = 0;
for (QString row : rows) {
@@ -1918,25 +1918,24 @@ void QtDocGenerator::writeDocSnips(QTextStream &s,
row.remove(invalidString);
if (row.trimmed().size() == 0) {
- if (currenRow == 0)
+ if (currentRow == 0)
continue;
s << endl;
}
- if (currenRow == 0) {
+ if (currentRow == 0) {
//find offset
- for (int i=0, i_max = row.size(); i < i_max; i++) {
- if (row[i] == QLatin1Char(' '))
+ for (auto c : row) {
+ if (c == QLatin1Char(' '))
offset++;
- else if (row[i] == QLatin1Char('\n'))
+ else if (c == QLatin1Char('\n'))
offset = 0;
else
break;
}
}
- row = row.mid(offset);
- s << row << endl;
- currenRow++;
+ s << row.midRef(offset) << endl;
+ currentRow++;
}
code = code.mid(endBlock+endMarkup.size());
@@ -2110,7 +2109,7 @@ void QtDocGenerator::writeFunction(QTextStream& s, const AbstractMetaClass* cppC
static void writeFancyToc(QTextStream& s, const QStringList& items, int cols = 4)
{
- typedef QMap<QChar, QStringList> TocMap;
+ using TocMap = QMap<QChar, QStringList>;
TocMap tocMap;
QChar Q = QLatin1Char('Q');
QChar idx;
diff --git a/sources/shiboken2/generator/qtdoc/qtdocgenerator.h b/sources/shiboken2/generator/qtdoc/qtdocgenerator.h
index 21afd0f4..53e292d2 100644
--- a/sources/shiboken2/generator/qtdoc/qtdocgenerator.h
+++ b/sources/shiboken2/generator/qtdoc/qtdocgenerator.h
@@ -59,21 +59,19 @@ public:
struct TableCell
{
- short rowSpan;
- short colSpan;
+ short rowSpan = 0;
+ short colSpan = 0;
QString data;
- TableCell(const QString& text = QString()) : rowSpan(0), colSpan(0), data(text) {}
- TableCell(const char* text) : rowSpan(0), colSpan(0), data(QLatin1String(text)) {}
+ TableCell(const QString& text = QString()) : data(text) {}
+ TableCell(const char* text) : data(QLatin1String(text)) {}
};
- typedef QList<TableCell> TableRow;
+ using TableRow = QList<TableCell>;
class Table : public QList<TableRow>
{
public:
- Table() : m_hasHeader(false), m_normalized(false)
- {
- }
+ Table() = default;
void enableHeader(bool enable)
{
@@ -98,8 +96,8 @@ public:
}
private:
- bool m_hasHeader;
- bool m_normalized;
+ bool m_hasHeader = false;
+ bool m_normalized = false;
};
QtXmlToSphinx(QtDocGenerator* generator, const QString& doc, const QString& context = QString());
diff --git a/sources/shiboken2/generator/shiboken2/cppgenerator.cpp b/sources/shiboken2/generator/shiboken2/cppgenerator.cpp
index 95f93fd4..104b0a42 100644
--- a/sources/shiboken2/generator/shiboken2/cppgenerator.cpp
+++ b/sources/shiboken2/generator/shiboken2/cppgenerator.cpp
@@ -81,7 +81,7 @@ static const char *typeNameOf(const T &t)
)CPP";
// utility functions
-inline AbstractMetaType* getTypeWithoutContainer(AbstractMetaType* arg)
+inline AbstractMetaType *getTypeWithoutContainer(AbstractMetaType *arg)
{
if (arg && arg->typeEntry()->isContainer()) {
AbstractMetaTypeList lst = arg->instantiations();
@@ -144,25 +144,25 @@ CppGenerator::CppGenerator()
// sequence protocol functions
m_sequenceProtocol.insert(QLatin1String("__len__"),
- {QLatin1String("PyObject* self"),
+ {QLatin1String("PyObject *self"),
QLatin1String("Py_ssize_t")});
m_sequenceProtocol.insert(QLatin1String("__getitem__"),
- {QLatin1String("PyObject* self, Py_ssize_t _i"),
+ {QLatin1String("PyObject *self, Py_ssize_t _i"),
QLatin1String("PyObject*")});
m_sequenceProtocol.insert(QLatin1String("__setitem__"),
- {QLatin1String("PyObject* self, Py_ssize_t _i, PyObject* _value"),
+ {QLatin1String("PyObject *self, Py_ssize_t _i, PyObject *_value"),
QLatin1String("int")});
m_sequenceProtocol.insert(QLatin1String("__getslice__"),
- {QLatin1String("PyObject* self, Py_ssize_t _i1, Py_ssize_t _i2"),
+ {QLatin1String("PyObject *self, Py_ssize_t _i1, Py_ssize_t _i2"),
QLatin1String("PyObject*")});
m_sequenceProtocol.insert(QLatin1String("__setslice__"),
- {QLatin1String("PyObject* self, Py_ssize_t _i1, Py_ssize_t _i2, PyObject* _value"),
+ {QLatin1String("PyObject *self, Py_ssize_t _i1, Py_ssize_t _i2, PyObject *_value"),
QLatin1String("int")});
m_sequenceProtocol.insert(QLatin1String("__contains__"),
- {QLatin1String("PyObject* self, PyObject* _value"),
+ {QLatin1String("PyObject *self, PyObject *_value"),
QLatin1String("int")});
m_sequenceProtocol.insert(QLatin1String("__concat__"),
- {QLatin1String("PyObject* self, PyObject* _other"),
+ {QLatin1String("PyObject *self, PyObject *_other"),
QLatin1String("PyObject*")});
// Sequence protocol structure members names
@@ -176,13 +176,13 @@ CppGenerator::CppGenerator()
// mapping protocol function
m_mappingProtocol.insert(QLatin1String("__mlen__"),
- {QLatin1String("PyObject* self"),
+ {QLatin1String("PyObject *self"),
QLatin1String("Py_ssize_t")});
m_mappingProtocol.insert(QLatin1String("__mgetitem__"),
- {QLatin1String("PyObject* self, PyObject* _key"),
+ {QLatin1String("PyObject *self, PyObject *_key"),
QLatin1String("PyObject*")});
m_mappingProtocol.insert(QLatin1String("__msetitem__"),
- {QLatin1String("PyObject* self, PyObject* _key, PyObject* _value"),
+ {QLatin1String("PyObject *self, PyObject *_key, PyObject *_value"),
QLatin1String("int")});
// Sequence protocol structure members names
@@ -203,19 +203,17 @@ QString CppGenerator::fileNameForContext(GeneratorContext &context) const
QString fileNameBase = metaClass->qualifiedCppName().toLower();
fileNameBase.replace(QLatin1String("::"), QLatin1String("_"));
return fileNameBase + fileNameSuffix();
- } else {
- const AbstractMetaType *smartPointerType = context.preciseType();
- QString fileNameBase = getFileNameBaseForSmartPointer(smartPointerType, metaClass);
- return fileNameBase + fileNameSuffix();
}
+ const AbstractMetaType *smartPointerType = context.preciseType();
+ QString fileNameBase = getFileNameBaseForSmartPointer(smartPointerType, metaClass);
+ return fileNameBase + fileNameSuffix();
}
-QVector<AbstractMetaFunctionList> CppGenerator::filterGroupedOperatorFunctions(const AbstractMetaClass* metaClass,
- uint queryIn)
+QVector<AbstractMetaFunctionList> CppGenerator::filterGroupedOperatorFunctions(const AbstractMetaClass *metaClass,
+ uint queryIn)
{
// ( func_name, num_args ) => func_list
- typedef QMap<QPair<QString, int >, AbstractMetaFunctionList> ResultMap;
- ResultMap results;
+ QMap<QPair<QString, int>, AbstractMetaFunctionList> results;
const AbstractMetaClass::OperatorQueryOptions query(queryIn);
const AbstractMetaFunctionList &funcs = metaClass->operatorOverloads(query);
for (AbstractMetaFunction *func : funcs) {
@@ -237,28 +235,27 @@ QVector<AbstractMetaFunctionList> CppGenerator::filterGroupedOperatorFunctions(c
}
QVector<AbstractMetaFunctionList> result;
result.reserve(results.size());
- for (ResultMap::const_iterator it = results.cbegin(), end = results.cend(); it != end; ++it)
+ for (auto it = results.cbegin(), end = results.cend(); it != end; ++it)
result.append(it.value());
return result;
}
-const AbstractMetaFunction *CppGenerator::boolCast(const AbstractMetaClass* metaClass) const
+const AbstractMetaFunction *CppGenerator::boolCast(const AbstractMetaClass *metaClass) const
{
if (!useIsNullAsNbNonZero())
return nullptr;
// TODO: This could be configurable someday
- const AbstractMetaFunction* func = metaClass->findFunction(QLatin1String("isNull"));
+ const AbstractMetaFunction *func = metaClass->findFunction(QLatin1String("isNull"));
if (!func || !func->type() || !func->type()->typeEntry()->isPrimitive() || !func->isPublic())
return nullptr;
- const PrimitiveTypeEntry* pte = static_cast<const PrimitiveTypeEntry*>(func->type()->typeEntry());
+ auto pte = static_cast<const PrimitiveTypeEntry *>(func->type()->typeEntry());
while (pte->referencedTypeEntry())
pte = pte->referencedTypeEntry();
return func && func->isConstant() && pte->name() == QLatin1String("bool")
&& func->arguments().isEmpty() ? func : nullptr;
}
-typedef QMap<QString, AbstractMetaFunctionList> FunctionGroupMap;
-typedef FunctionGroupMap::const_iterator FunctionGroupMapIt;
+using FunctionGroupMap = QMap<QString, AbstractMetaFunctionList>;
// Prevent ELF symbol qt_version_tag from being generated into the source
static const char includeQDebug[] =
@@ -390,7 +387,7 @@ void CppGenerator::generateClass(QTextStream &s, GeneratorContext &classContext)
// Create string literal for smart pointer getter method.
if (classContext.forSmartPointer()) {
- const SmartPointerTypeEntry *typeEntry =
+ const auto *typeEntry =
static_cast<const SmartPointerTypeEntry *>(classContext.preciseType()
->typeEntry());
QString rawGetter = typeEntry->getter();
@@ -489,7 +486,7 @@ void CppGenerator::generateClass(QTextStream &s, GeneratorContext &classContext)
if (overloads.isEmpty())
continue;
- const AbstractMetaFunction* rfunc = overloads.constFirst();
+ const AbstractMetaFunction *rfunc = overloads.constFirst();
if (m_sequenceProtocol.contains(rfunc->name()) || m_mappingProtocol.contains(rfunc->name()))
continue;
@@ -509,7 +506,7 @@ void CppGenerator::generateClass(QTextStream &s, GeneratorContext &classContext)
else if (!rfunc->isOperatorOverload()) {
if (classContext.forSmartPointer()) {
- const SmartPointerTypeEntry *smartPointerTypeEntry =
+ const auto *smartPointerTypeEntry =
static_cast<const SmartPointerTypeEntry *>(
classContext.preciseType()->typeEntry());
@@ -587,7 +584,7 @@ void CppGenerator::generateClass(QTextStream &s, GeneratorContext &classContext)
if (const AbstractMetaFunction *f = boolCast(metaClass)) {
ErrorCode errorCode(-1);
- s << "static int " << cpythonBaseName(metaClass) << "___nb_bool(PyObject* self)" << endl;
+ s << "static int " << cpythonBaseName(metaClass) << "___nb_bool(PyObject *self)" << endl;
s << '{' << endl;
writeCppSelfDefinition(s, classContext);
if (f->allowThread()) {
@@ -656,7 +653,7 @@ void CppGenerator::generateClass(QTextStream &s, GeneratorContext &classContext)
if (metaField->isStatic())
continue;
- s << INDENT << "{const_cast<char*>(\"" << metaField->name() << "\"), ";
+ s << INDENT << "{const_cast<char *>(\"" << metaField->name() << "\"), ";
s << cpythonGetterFunctionName(metaField) << ", ";
if (canGenerateFieldSetter(metaField))
s << cpythonSetterFunctionName(metaField);
@@ -707,7 +704,7 @@ void CppGenerator::generateClass(QTextStream &s, GeneratorContext &classContext)
}
}
-void CppGenerator::writeConstructorNative(QTextStream& s, const AbstractMetaFunction* func)
+void CppGenerator::writeConstructorNative(QTextStream &s, const AbstractMetaFunction *func)
{
Indentation indentation(INDENT);
s << functionSignature(func, wrapperName(func->ownerClass()) + QLatin1String("::"), QString(),
@@ -715,7 +712,7 @@ void CppGenerator::writeConstructorNative(QTextStream& s, const AbstractMetaFunc
s << " : ";
writeFunctionCall(s, func);
s << endl << "{" << endl;
- const AbstractMetaArgument* lastArg = func->arguments().isEmpty() ? 0 : func->arguments().constLast();
+ const AbstractMetaArgument *lastArg = func->arguments().isEmpty() ? nullptr : func->arguments().constLast();
writeCodeSnips(s, func->injectedCodeSnips(), TypeSystem::CodeSnipPositionBeginning, TypeSystem::NativeCode, func, lastArg);
s << INDENT << "// ... middle" << endl;
writeCodeSnips(s, func->injectedCodeSnips(), TypeSystem::CodeSnipPositionEnd, TypeSystem::NativeCode, func, lastArg);
@@ -727,12 +724,12 @@ void CppGenerator::writeDestructorNative(QTextStream &s, const AbstractMetaClass
Indentation indentation(INDENT);
s << wrapperName(metaClass) << "::~" << wrapperName(metaClass) << "()" << endl << '{' << endl;
// kill pyobject
- s << INDENT << "SbkObject* wrapper = Shiboken::BindingManager::instance().retrieveWrapper(this);" << endl;
+ s << INDENT << "SbkObject *wrapper = Shiboken::BindingManager::instance().retrieveWrapper(this);" << endl;
s << INDENT << "Shiboken::Object::destroy(wrapper, this);" << endl;
s << '}' << endl;
}
-static bool allArgumentsRemoved(const AbstractMetaFunction* func)
+static bool allArgumentsRemoved(const AbstractMetaFunction *func)
{
if (func->arguments().isEmpty())
return false;
@@ -744,7 +741,7 @@ static bool allArgumentsRemoved(const AbstractMetaFunction* func)
return true;
}
-QString CppGenerator::getVirtualFunctionReturnTypeName(const AbstractMetaFunction* func)
+QString CppGenerator::getVirtualFunctionReturnTypeName(const AbstractMetaFunction *func)
{
if (!func->type())
return QLatin1String("\"\"");
@@ -755,12 +752,12 @@ QString CppGenerator::getVirtualFunctionReturnTypeName(const AbstractMetaFunctio
// SbkType would return null when the type is a container.
if (func->type()->typeEntry()->isContainer()) {
return QLatin1Char('"')
- + reinterpret_cast<const ContainerTypeEntry*>(func->type()->typeEntry())->typeName()
+ + reinterpret_cast<const ContainerTypeEntry *>(func->type()->typeEntry())->typeName()
+ QLatin1Char('"');
}
if (avoidProtectedHack()) {
- const AbstractMetaEnum* metaEnum = findAbstractMetaEnum(func->type());
+ const AbstractMetaEnum *metaEnum = findAbstractMetaEnum(func->type());
if (metaEnum && metaEnum->isProtected())
return QLatin1Char('"') + protectedEnumSurrogateName(metaEnum) + QLatin1Char('"');
}
@@ -771,14 +768,14 @@ QString CppGenerator::getVirtualFunctionReturnTypeName(const AbstractMetaFunctio
return QString::fromLatin1("reinterpret_cast<PyTypeObject *>(Shiboken::SbkType< %1 >())->tp_name").arg(func->type()->typeEntry()->qualifiedCppName());
}
-void CppGenerator::writeVirtualMethodNative(QTextStream&s, const AbstractMetaFunction* func)
+void CppGenerator::writeVirtualMethodNative(QTextStream &s, const AbstractMetaFunction *func)
{
//skip metaObject function, this will be written manually ahead
if (usePySideExtensions() && func->ownerClass() && func->ownerClass()->isQObject() &&
((func->name() == QLatin1String("metaObject")) || (func->name() == QLatin1String("qt_metacall"))))
return;
- const TypeEntry* retType = func->type() ? func->type()->typeEntry() : 0;
+ const TypeEntry *retType = func->type() ? func->type()->typeEntry() : nullptr;
const QString funcName = func->isOperatorOverload() ? pythonOperatorFunctionName(func) : func->name();
QString prefix = wrapperName(func->ownerClass()) + QLatin1String("::");
@@ -841,7 +838,7 @@ void CppGenerator::writeVirtualMethodNative(QTextStream&s, const AbstractMetaFun
//Write declaration/native injected code
if (func->hasInjectedCode()) {
CodeSnipList snips = func->injectedCodeSnips();
- const AbstractMetaArgument* lastArg = func->arguments().isEmpty() ? 0 : func->arguments().constLast();
+ const AbstractMetaArgument *lastArg = func->arguments().isEmpty() ? nullptr : func->arguments().constLast();
writeCodeSnips(s, snips, TypeSystem::CodeSnipPositionDeclaration, TypeSystem::NativeCode, func, lastArg);
s << endl;
}
@@ -864,7 +861,7 @@ void CppGenerator::writeVirtualMethodNative(QTextStream&s, const AbstractMetaFun
CodeSnipList snips;
if (func->hasInjectedCode()) {
snips = func->injectedCodeSnips();
- const AbstractMetaArgument* lastArg = func->arguments().isEmpty() ? 0 : func->arguments().constLast();
+ const AbstractMetaArgument *lastArg = func->arguments().isEmpty() ? nullptr : func->arguments().constLast();
writeCodeSnips(s, snips, TypeSystem::CodeSnipPositionBeginning, TypeSystem::ShellCode, func, lastArg);
s << endl;
}
@@ -905,7 +902,7 @@ void CppGenerator::writeVirtualMethodNative(QTextStream&s, const AbstractMetaFun
QString argConv;
QTextStream ac(&argConv);
- const PrimitiveTypeEntry* argType = (const PrimitiveTypeEntry*) arg->type()->typeEntry();
+ auto argType = static_cast<const PrimitiveTypeEntry *>(arg->type()->typeEntry());
bool convert = argType->isObject()
|| argType->isValue()
|| arg->type()->isValuePointer()
@@ -963,9 +960,9 @@ void CppGenerator::writeVirtualMethodNative(QTextStream&s, const AbstractMetaFun
snips = func->injectedCodeSnips();
if (injectedCodeUsesPySelf(func))
- s << INDENT << "PyObject* pySelf = BindingManager::instance().retrieveWrapper(this);" << endl;
+ s << INDENT << "PyObject *pySelf = BindingManager::instance().retrieveWrapper(this);" << endl;
- const AbstractMetaArgument* lastArg = func->arguments().isEmpty() ? 0 : func->arguments().constLast();
+ const AbstractMetaArgument *lastArg = func->arguments().isEmpty() ? nullptr : func->arguments().constLast();
writeCodeSnips(s, snips, TypeSystem::CodeSnipPositionBeginning, TypeSystem::NativeCode, func, lastArg);
s << endl;
}
@@ -1067,14 +1064,14 @@ void CppGenerator::writeVirtualMethodNative(QTextStream&s, const AbstractMetaFun
if (func->hasInjectedCode()) {
s << endl;
- const AbstractMetaArgument* lastArg = func->arguments().isEmpty() ? 0 : func->arguments().constLast();
+ const AbstractMetaArgument *lastArg = func->arguments().isEmpty() ? nullptr : func->arguments().constLast();
writeCodeSnips(s, snips, TypeSystem::CodeSnipPositionEnd, TypeSystem::NativeCode, func, lastArg);
}
if (retType) {
s << INDENT << "return ";
if (avoidProtectedHack() && retType->isEnum()) {
- const AbstractMetaEnum* metaEnum = findAbstractMetaEnum(retType);
+ const AbstractMetaEnum *metaEnum = findAbstractMetaEnum(retType);
bool isProtectedEnum = metaEnum && metaEnum->isProtected();
if (isProtectedEnum) {
QString typeCast;
@@ -1085,29 +1082,29 @@ void CppGenerator::writeVirtualMethodNative(QTextStream&s, const AbstractMetaFun
}
}
if (func->type()->referenceType() == LValueReference && !isPointer(func->type()))
- s << '*';
+ s << " *";
s << CPP_RETURN_VAR << ';' << endl;
}
s << '}' << endl << endl;
}
-void CppGenerator::writeMetaObjectMethod(QTextStream& s, const AbstractMetaClass* metaClass)
+void CppGenerator::writeMetaObjectMethod(QTextStream &s, const AbstractMetaClass *metaClass)
{
Indentation indentation(INDENT);
QString wrapperClassName = wrapperName(metaClass);
- s << "const QMetaObject* " << wrapperClassName << "::metaObject() const" << endl;
+ s << "const QMetaObject *" << wrapperClassName << "::metaObject() const" << endl;
s << '{' << endl;
s << INDENT << "if (QObject::d_ptr->metaObject)" << endl
<< INDENT << INDENT << "return QObject::d_ptr->dynamicMetaObject();" << endl;
- s << INDENT << "SbkObject* pySelf = Shiboken::BindingManager::instance().retrieveWrapper(this);" << endl;
+ s << INDENT << "SbkObject *pySelf = Shiboken::BindingManager::instance().retrieveWrapper(this);" << endl;
s << INDENT << "if (pySelf == nullptr)" << endl;
s << INDENT << INDENT << "return " << metaClass->qualifiedCppName() << "::metaObject();" << endl;
- s << INDENT << "return PySide::SignalManager::retrieveMetaObject(reinterpret_cast<PyObject*>(pySelf));" << endl;
+ s << INDENT << "return PySide::SignalManager::retrieveMetaObject(reinterpret_cast<PyObject *>(pySelf));" << endl;
s << '}' << endl << endl;
// qt_metacall function
- s << "int " << wrapperClassName << "::qt_metacall(QMetaObject::Call call, int id, void** args)" << endl;
+ s << "int " << wrapperClassName << "::qt_metacall(QMetaObject::Call call, int id, void **args)" << endl;
s << "{" << endl;
AbstractMetaFunction *func = nullptr;
@@ -1132,28 +1129,28 @@ void CppGenerator::writeMetaObjectMethod(QTextStream& s, const AbstractMetaClass
writeMetaCast(s, metaClass);
}
-void CppGenerator::writeMetaCast(QTextStream& s, const AbstractMetaClass* metaClass)
+void CppGenerator::writeMetaCast(QTextStream &s, const AbstractMetaClass *metaClass)
{
Indentation indentation(INDENT);
QString wrapperClassName = wrapperName(metaClass);
- s << "void* " << wrapperClassName << "::qt_metacast(const char* _clname)" << endl;
+ s << "void *" << wrapperClassName << "::qt_metacast(const char *_clname)" << endl;
s << '{' << endl;
s << INDENT << "if (!_clname) return {};" << endl;
- s << INDENT << "SbkObject* pySelf = Shiboken::BindingManager::instance().retrieveWrapper(this);" << endl;
+ s << INDENT << "SbkObject *pySelf = Shiboken::BindingManager::instance().retrieveWrapper(this);" << endl;
s << INDENT << "if (pySelf && PySide::inherits(Py_TYPE(pySelf), _clname))" << endl;
- s << INDENT << INDENT << "return static_cast<void*>(const_cast< " << wrapperClassName << "* >(this));" << endl;
+ s << INDENT << INDENT << "return static_cast<void *>(const_cast< " << wrapperClassName << " *>(this));" << endl;
s << INDENT << "return " << metaClass->qualifiedCppName() << "::qt_metacast(_clname);" << endl;
s << "}" << endl << endl;
}
-void CppGenerator::writeEnumConverterFunctions(QTextStream& s, const AbstractMetaEnum* metaEnum)
+void CppGenerator::writeEnumConverterFunctions(QTextStream &s, const AbstractMetaEnum *metaEnum)
{
if (metaEnum->isPrivate() || metaEnum->isAnonymous())
return;
writeEnumConverterFunctions(s, metaEnum->typeEntry());
}
-void CppGenerator::writeEnumConverterFunctions(QTextStream& s, const TypeEntry* enumType)
+void CppGenerator::writeEnumConverterFunctions(QTextStream &s, const TypeEntry *enumType)
{
if (!enumType)
return;
@@ -1161,16 +1158,16 @@ void CppGenerator::writeEnumConverterFunctions(QTextStream& s, const TypeEntry*
QString enumPythonType = cpythonTypeNameExt(enumType);
QString cppTypeName = getFullTypeName(enumType).trimmed();
if (avoidProtectedHack()) {
- const AbstractMetaEnum* metaEnum = findAbstractMetaEnum(enumType);
+ const AbstractMetaEnum *metaEnum = findAbstractMetaEnum(enumType);
if (metaEnum && metaEnum->isProtected())
cppTypeName = protectedEnumSurrogateName(metaEnum);
}
QString code;
QTextStream c(&code);
- c << INDENT << "*reinterpret_cast<" << cppTypeName << "*>(cppOut) =\n"
+ c << INDENT << "*reinterpret_cast<" << cppTypeName << " *>(cppOut) =\n"
<< INDENT << " ";
if (enumType->isFlags())
- c << cppTypeName << "(QFlag(int(PySide::QFlags::getValue(reinterpret_cast<PySideQFlagsObject*>(pyIn)))))";
+ c << cppTypeName << "(QFlag(int(PySide::QFlags::getValue(reinterpret_cast<PySideQFlagsObject *>(pyIn)))))";
else
c << "static_cast<" << cppTypeName << ">(Shiboken::Enum::getValue(pyIn))";
c << ';' << endl;
@@ -1186,7 +1183,7 @@ void CppGenerator::writeEnumConverterFunctions(QTextStream& s, const TypeEntry*
c << INDENT;
c << "return ";
if (enumType->isFlags()) {
- c << "reinterpret_cast<PyObject*>(PySide::QFlags::newObject(castCppIn, "
+ c << "reinterpret_cast<PyObject *>(PySide::QFlags::newObject(castCppIn, "
<< enumPythonType << "))";
} else {
c << "Shiboken::Enum::newItem(" << enumPythonType << ", castCppIn)";
@@ -1198,7 +1195,7 @@ void CppGenerator::writeEnumConverterFunctions(QTextStream& s, const TypeEntry*
if (enumType->isFlags())
return;
- const FlagsTypeEntry* flags = reinterpret_cast<const EnumTypeEntry*>(enumType)->flags();
+ auto flags = reinterpret_cast<const EnumTypeEntry *>(enumType)->flags();
if (!flags)
return;
@@ -1208,7 +1205,7 @@ void CppGenerator::writeEnumConverterFunctions(QTextStream& s, const TypeEntry*
code.clear();
cppTypeName = getFullTypeName(flags).trimmed();
- c << INDENT << "*reinterpret_cast<" << cppTypeName << "*>(cppOut) =\n"
+ c << INDENT << "*reinterpret_cast<" << cppTypeName << " *>(cppOut) =\n"
<< INDENT << " " << cppTypeName
<< "(QFlag(int(Shiboken::Enum::getValue(pyIn))));" << endl;
@@ -1218,7 +1215,7 @@ void CppGenerator::writeEnumConverterFunctions(QTextStream& s, const TypeEntry*
code.clear();
c << INDENT << "Shiboken::AutoDecRef pyLong(PyNumber_Long(pyIn));" << endl;
- c << INDENT << "*reinterpret_cast<" << cppTypeName << "*>(cppOut) =\n"
+ c << INDENT << "*reinterpret_cast<" << cppTypeName << " *>(cppOut) =\n"
<< INDENT << " " << cppTypeName
<< "(QFlag(int(PyLong_AsLong(pyLong.object()))));" << endl;
// PYSIDE-898: Include an additional condition to detect if the type of the
@@ -1270,7 +1267,7 @@ void CppGenerator::writeConverterFunctions(QTextStream &s, const AbstractMetaCla
writePythonToCppFunction(s, code, sourceTypeName, targetTypeName);
// "Is convertible" function for the Python object to C++ pointer conversion.
- const QString pyTypeCheck = QLatin1String("PyObject_TypeCheck(pyIn, reinterpret_cast<PyTypeObject*>(")
+ const QString pyTypeCheck = QLatin1String("PyObject_TypeCheck(pyIn, reinterpret_cast<PyTypeObject *>(")
+ cpythonType + QLatin1String("))");
writeIsPythonConvertibleToCppFunction(s, sourceTypeName, targetTypeName, pyTypeCheck, QString(), true);
s << endl;
@@ -1281,9 +1278,9 @@ void CppGenerator::writeConverterFunctions(QTextStream &s, const AbstractMetaCla
if (usePySideExtensions() && metaClass->isQObject())
{
c << INDENT << "return PySide::getWrapperForQObject(reinterpret_cast<"
- << typeName << "*>(const_cast<void*>(cppIn)), " << cpythonType << ");" << endl;
+ << typeName << " *>(const_cast<void *>(cppIn)), " << cpythonType << ");" << endl;
} else {
- c << INDENT << "auto pyOut = reinterpret_cast<PyObject*>(Shiboken::BindingManager::instance().retrieveWrapper(cppIn));" << endl;
+ c << INDENT << "auto pyOut = reinterpret_cast<PyObject *>(Shiboken::BindingManager::instance().retrieveWrapper(cppIn));" << endl;
c << INDENT << "if (pyOut) {" << endl;
{
Indentation indent(INDENT);
@@ -1300,7 +1297,7 @@ void CppGenerator::writeConverterFunctions(QTextStream &s, const AbstractMetaCla
<< INDENT << " changedTypeName = true;\n"
<< INDENT << " }\n"
<< INDENT << "PyObject *result = Shiboken::Object::newObject(" << cpythonType
- << ", const_cast<void*>(cppIn), false, /* exactType */ changedTypeName, typeName);\n"
+ << ", const_cast<void *>(cppIn), false, /* exactType */ changedTypeName, typeName);\n"
<< INDENT << "if (changedTypeName)\n"
<< INDENT << " delete [] typeName;\n"
<< INDENT << "return result;";
@@ -1333,7 +1330,7 @@ void CppGenerator::writeConverterFunctions(QTextStream &s, const AbstractMetaCla
c << INDENT << "return Shiboken::Object::newObject(" << cpythonType
<< ", new ::" << computedWrapperName << "(*reinterpret_cast<const "
- << typeName << "*>(cppIn)), true, true);";
+ << typeName << " *>(cppIn)), true, true);";
writeCppToPythonFunction(s, code, sourceTypeName, targetTypeName);
s << endl;
@@ -1354,7 +1351,7 @@ void CppGenerator::writeConverterFunctions(QTextStream &s, const AbstractMetaCla
else
wrappedCPtrExpression = cpythonWrapperCPtr(classContext.preciseType(), pyInVariable);
- c << INDENT << "*reinterpret_cast<" << typeName << "*>(cppOut) = *"
+ c << INDENT << "*reinterpret_cast<" << typeName << " *>(cppOut) = *"
<< wrappedCPtrExpression << ';';
writePythonToCppFunction(s, code, sourceTypeName, targetTypeName);
@@ -1363,7 +1360,7 @@ void CppGenerator::writeConverterFunctions(QTextStream &s, const AbstractMetaCla
s << endl;
// User provided implicit conversions.
- CustomConversion* customConversion = metaClass->typeEntry()->customConversion();
+ CustomConversion *customConversion = metaClass->typeEntry()->customConversion();
// Implicit conversions.
AbstractMetaFunctionList implicitConvs;
@@ -1378,8 +1375,8 @@ void CppGenerator::writeConverterFunctions(QTextStream &s, const AbstractMetaCla
if (!implicitConvs.isEmpty())
s << "// Implicit conversions." << endl;
- AbstractMetaType* targetType = buildAbstractMetaTypeFromAbstractMetaClass(metaClass);
- for (const AbstractMetaFunction* conv : qAsConst(implicitConvs)) {
+ AbstractMetaType *targetType = buildAbstractMetaTypeFromAbstractMetaClass(metaClass);
+ for (const AbstractMetaFunction *conv : qAsConst(implicitConvs)) {
if (conv->isModifiedRemoved())
continue;
@@ -1387,14 +1384,14 @@ void CppGenerator::writeConverterFunctions(QTextStream &s, const AbstractMetaCla
QString toCppConv;
QString toCppPreConv;
if (conv->isConversionOperator()) {
- const AbstractMetaClass* sourceClass = conv->ownerClass();
+ const AbstractMetaClass *sourceClass = conv->ownerClass();
typeCheck = QStringLiteral("PyObject_TypeCheck(pyIn, %1)").arg(cpythonTypeNameExt(sourceClass->typeEntry()));
toCppConv = QLatin1Char('*') + cpythonWrapperCPtr(sourceClass->typeEntry(), QLatin1String("pyIn"));
} else {
// Constructor that does implicit conversion.
if (!conv->typeReplaced(1).isEmpty() || conv->isModifiedToArray(1))
continue;
- const AbstractMetaType* sourceType = conv->arguments().constFirst()->type();
+ const AbstractMetaType *sourceType = conv->arguments().constFirst()->type();
typeCheck = cpythonCheckFunction(sourceType);
bool isUserPrimitiveWithoutTargetLangName = isUserPrimitive(sourceType)
&& sourceType->typeEntry()->targetLangApiName() == sourceType->typeEntry()->name();
@@ -1408,7 +1405,7 @@ void CppGenerator::writeConverterFunctions(QTextStream &s, const AbstractMetaCla
if (isWrapperType(sourceType)) {
typeCheck += QLatin1String("pyIn)");
toCppConv = (sourceType->referenceType() == LValueReference || !isPointerToWrapperType(sourceType))
- ? QLatin1String("*") : QString();
+ ? QLatin1String(" *") : QString();
toCppConv += cpythonWrapperCPtr(sourceType->typeEntry(), QLatin1String("pyIn"));
} else if (typeCheck.contains(QLatin1String("%in"))) {
typeCheck.replace(QLatin1String("%in"), QLatin1String("pyIn"));
@@ -1426,7 +1423,7 @@ void CppGenerator::writeConverterFunctions(QTextStream &s, const AbstractMetaCla
pc << INDENT << getFullTypeNameWithoutModifiers(sourceType) << " cppIn";
writeMinimalConstructorExpression(pc, sourceType);
pc << ';' << endl;
- writeToCppConversion(pc, sourceType, 0, QLatin1String("pyIn"), QLatin1String("cppIn"));
+ writeToCppConversion(pc, sourceType, nullptr, QLatin1String("pyIn"), QLatin1String("cppIn"));
pc << ';';
toCppConv.append(QLatin1String("cppIn"));
} else if (!isWrapperType(sourceType)) {
@@ -1436,7 +1433,7 @@ void CppGenerator::writeConverterFunctions(QTextStream &s, const AbstractMetaCla
}
- const AbstractMetaType* sourceType = conv->isConversionOperator()
+ const AbstractMetaType *sourceType = conv->isConversionOperator()
? buildAbstractMetaTypeFromAbstractMetaClass(conv->ownerClass())
: conv->arguments().constFirst()->type();
writePythonToCppConversionFunctions(s, sourceType, targetType, typeCheck, toCppConv, toCppPreConv);
@@ -1445,11 +1442,11 @@ void CppGenerator::writeConverterFunctions(QTextStream &s, const AbstractMetaCla
writeCustomConverterFunctions(s, customConversion);
}
-void CppGenerator::writeCustomConverterFunctions(QTextStream& s, const CustomConversion* customConversion)
+void CppGenerator::writeCustomConverterFunctions(QTextStream &s, const CustomConversion *customConversion)
{
if (!customConversion)
return;
- const CustomConversion::TargetToNativeConversions& toCppConversions = customConversion->targetToNativeConversions();
+ const CustomConversion::TargetToNativeConversions &toCppConversions = customConversion->targetToNativeConversions();
if (toCppConversions.isEmpty())
return;
s << "// Python to C++ conversions for type '" << customConversion->ownerType()->qualifiedCppName() << "'." << endl;
@@ -1464,7 +1461,7 @@ void CppGenerator::writeConverterRegister(QTextStream &s, const AbstractMetaClas
if (metaClass->isNamespace())
return;
s << INDENT << "// Register Converter" << endl;
- s << INDENT << "SbkConverter* converter = Shiboken::Conversions::createConverter(";
+ s << INDENT << "SbkConverter *converter = Shiboken::Conversions::createConverter(";
s << cpythonTypeName(metaClass) << ',' << endl;
{
Indentation indent(INDENT);
@@ -1528,7 +1525,7 @@ void CppGenerator::writeConverterRegister(QTextStream &s, const AbstractMetaClas
writeAddPythonToCppConversion(s, QLatin1String("converter"), toCpp, isConv);
// User provided implicit conversions.
- CustomConversion* customConversion = metaClass->typeEntry()->customConversion();
+ CustomConversion *customConversion = metaClass->typeEntry()->customConversion();
// Add implicit conversions.
AbstractMetaFunctionList implicitConvs;
@@ -1543,11 +1540,11 @@ void CppGenerator::writeConverterRegister(QTextStream &s, const AbstractMetaClas
if (!implicitConvs.isEmpty())
s << INDENT << "// Add implicit conversions to type converter." << endl;
- AbstractMetaType* targetType = buildAbstractMetaTypeFromAbstractMetaClass(metaClass);
+ AbstractMetaType *targetType = buildAbstractMetaTypeFromAbstractMetaClass(metaClass);
for (const AbstractMetaFunction *conv : qAsConst(implicitConvs)) {
if (conv->isModifiedRemoved())
continue;
- const AbstractMetaType* sourceType;
+ const AbstractMetaType *sourceType;
if (conv->isConversionOperator()) {
sourceType = buildAbstractMetaTypeFromAbstractMetaClass(conv->ownerClass());
} else {
@@ -1564,11 +1561,11 @@ void CppGenerator::writeConverterRegister(QTextStream &s, const AbstractMetaClas
writeCustomConverterRegister(s, customConversion, QLatin1String("converter"));
}
-void CppGenerator::writeCustomConverterRegister(QTextStream& s, const CustomConversion* customConversion, const QString& converterVar)
+void CppGenerator::writeCustomConverterRegister(QTextStream &s, const CustomConversion *customConversion, const QString &converterVar)
{
if (!customConversion)
return;
- const CustomConversion::TargetToNativeConversions& toCppConversions = customConversion->targetToNativeConversions();
+ const CustomConversion::TargetToNativeConversions &toCppConversions = customConversion->targetToNativeConversions();
if (toCppConversions.isEmpty())
return;
s << INDENT << "// Add user defined implicit conversions to type converter." << endl;
@@ -1579,7 +1576,7 @@ void CppGenerator::writeCustomConverterRegister(QTextStream& s, const CustomConv
}
}
-void CppGenerator::writeContainerConverterFunctions(QTextStream& s, const AbstractMetaType* containerType)
+void CppGenerator::writeContainerConverterFunctions(QTextStream &s, const AbstractMetaType *containerType)
{
writeCppToPythonFunction(s, containerType);
writePythonToCppConversionFunctions(s, containerType);
@@ -1588,8 +1585,8 @@ void CppGenerator::writeContainerConverterFunctions(QTextStream& s, const Abstra
void CppGenerator::writeMethodWrapperPreamble(QTextStream &s, OverloadData &overloadData,
GeneratorContext &context)
{
- const AbstractMetaFunction* rfunc = overloadData.referenceFunction();
- const AbstractMetaClass* ownerClass = rfunc->ownerClass();
+ const AbstractMetaFunction *rfunc = overloadData.referenceFunction();
+ const AbstractMetaClass *ownerClass = rfunc->ownerClass();
int minArgs = overloadData.minArgs();
int maxArgs = overloadData.maxArgs();
bool initPythonArguments;
@@ -1619,7 +1616,7 @@ void CppGenerator::writeMethodWrapperPreamble(QTextStream &s, OverloadData &over
} else {
s << context.preciseType()->cppSignature();
}
- s << "* cptr{};" << endl;
+ s << " *cptr{};" << endl;
initPythonArguments = maxArgs > 0;
usesNamedArguments = !ownerClass->isQObject() && overloadData.hasArgumentWithDefaultValue();
@@ -1630,7 +1627,7 @@ void CppGenerator::writeMethodWrapperPreamble(QTextStream &s, OverloadData &over
writeCppSelfDefinition(s, rfunc, context, overloadData.hasStaticFunction());
}
if (!rfunc->isInplaceOperator() && overloadData.hasNonVoidReturnType())
- s << INDENT << "PyObject* " << PYTHON_RETURN_VAR << "{};" << endl;
+ s << INDENT << "PyObject *" << PYTHON_RETURN_VAR << "{};" << endl;
initPythonArguments = minArgs != maxArgs || maxArgs > 1;
usesNamedArguments = rfunc->isCallOperator() || overloadData.hasArgumentWithDefaultValue();
@@ -1662,17 +1659,17 @@ void CppGenerator::writeMethodWrapperPreamble(QTextStream &s, OverloadData &over
}
}
-void CppGenerator::writeConstructorWrapper(QTextStream &s, const AbstractMetaFunctionList overloads,
+void CppGenerator::writeConstructorWrapper(QTextStream &s, const AbstractMetaFunctionList &overloads,
GeneratorContext &classContext)
{
ErrorCode errorCode(-1);
OverloadData overloadData(overloads, this);
- const AbstractMetaFunction* rfunc = overloadData.referenceFunction();
- const AbstractMetaClass* metaClass = rfunc->ownerClass();
+ const AbstractMetaFunction *rfunc = overloadData.referenceFunction();
+ const AbstractMetaClass *metaClass = rfunc->ownerClass();
s << "static int" << endl;
- s << cpythonFunctionName(rfunc) << "(PyObject* self, PyObject* args, PyObject* kwds)" << endl;
+ s << cpythonFunctionName(rfunc) << "(PyObject *self, PyObject *args, PyObject *kwds)" << endl;
s << '{' << endl;
QSet<QString> argNamesSet;
@@ -1690,19 +1687,19 @@ void CppGenerator::writeConstructorWrapper(QTextStream &s, const AbstractMetaFun
QStringList argNamesList = argNamesSet.values();
std::sort(argNamesList.begin(), argNamesList.end());
if (argNamesList.isEmpty()) {
- s << INDENT << "const char** argNames{};" << endl;
+ s << INDENT << "const char **argNames{};" << endl;
} else {
- s << INDENT << "const char* argNames[] = {\""
+ s << INDENT << "const char *argNames[] = {\""
<< argNamesList.join(QLatin1String("\", \"")) << "\"};" << endl;
}
- s << INDENT << "const QMetaObject* metaObject;" << endl;
+ s << INDENT << "const QMetaObject *metaObject;" << endl;
}
- s << INDENT << "SbkObject* sbkSelf = reinterpret_cast<SbkObject*>(self);" << endl;
+ s << INDENT << "SbkObject *sbkSelf = reinterpret_cast<SbkObject *>(self);" << endl;
if (metaClass->isAbstract() || metaClass->baseClassNames().size() > 1) {
- s << INDENT << "SbkObjectType* type = reinterpret_cast<SbkObjectType*>(self->ob_type);" << endl;
- s << INDENT << "SbkObjectType* myType = reinterpret_cast<SbkObjectType*>(" << cpythonTypeNameExt(metaClass->typeEntry()) << ");" << endl;
+ s << INDENT << "SbkObjectType *type = reinterpret_cast<SbkObjectType *>(self->ob_type);" << endl;
+ s << INDENT << "SbkObjectType *myType = reinterpret_cast<SbkObjectType *>(" << cpythonTypeNameExt(metaClass->typeEntry()) << ");" << endl;
}
if (metaClass->isAbstract()) {
@@ -1823,20 +1820,20 @@ void CppGenerator::writeConstructorWrapper(QTextStream &s, const AbstractMetaFun
s << '}' << endl << endl;
}
-void CppGenerator::writeMethodWrapper(QTextStream &s, const AbstractMetaFunctionList overloads,
+void CppGenerator::writeMethodWrapper(QTextStream &s, const AbstractMetaFunctionList &overloads,
GeneratorContext &classContext)
{
OverloadData overloadData(overloads, this);
- const AbstractMetaFunction* rfunc = overloadData.referenceFunction();
+ const AbstractMetaFunction *rfunc = overloadData.referenceFunction();
int maxArgs = overloadData.maxArgs();
- s << "static PyObject* ";
- s << cpythonFunctionName(rfunc) << "(PyObject* self";
+ s << "static PyObject *";
+ s << cpythonFunctionName(rfunc) << "(PyObject *self";
if (maxArgs > 0) {
- s << ", PyObject* " << (pythonFunctionWrapperUsesListOfArguments(overloadData) ? "args" : PYTHON_ARG);
+ s << ", PyObject *" << (pythonFunctionWrapperUsesListOfArguments(overloadData) ? "args" : PYTHON_ARG);
if (overloadData.hasArgumentWithDefaultValue() || rfunc->isCallOperator())
- s << ", PyObject* kwds";
+ s << ", PyObject *kwds";
}
s << ')' << endl << '{' << endl;
@@ -1868,17 +1865,17 @@ void CppGenerator::writeMethodWrapper(QTextStream &s, const AbstractMetaFunction
Indentation indent(INDENT);
s << INDENT << "&& Shiboken::Object::checkType(" << PYTHON_ARG << ")" << endl;
s << INDENT << "&& !PyObject_TypeCheck(" << PYTHON_ARG << ", self->ob_type)" << endl;
- s << INDENT << "&& PyObject_HasAttrString(" << PYTHON_ARG << ", const_cast<char*>(\"" << revOpName << "\"))) {" << endl;
+ s << INDENT << "&& PyObject_HasAttrString(" << PYTHON_ARG << ", const_cast<char *>(\"" << revOpName << "\"))) {" << endl;
// This PyObject_CallMethod call will emit lots of warnings like
// "deprecated conversion from string constant to char *" during compilation
- // due to the method name argument being declared as "char*" instead of "const char*"
+ // due to the method name argument being declared as "char *" instead of "const char *"
// issue 6952 http://bugs.python.org/issue6952
- s << INDENT << "PyObject* revOpMethod = PyObject_GetAttrString(" << PYTHON_ARG << ", const_cast<char*>(\"" << revOpName << "\"));" << endl;
+ s << INDENT << "PyObject *revOpMethod = PyObject_GetAttrString(" << PYTHON_ARG << ", const_cast<char *>(\"" << revOpName << "\"));" << endl;
s << INDENT << "if (revOpMethod && PyCallable_Check(revOpMethod)) {" << endl;
{
Indentation indent(INDENT);
- s << INDENT << PYTHON_RETURN_VAR << " = PyObject_CallFunction(revOpMethod, const_cast<char*>(\"O\"), self);" << endl;
+ s << INDENT << PYTHON_RETURN_VAR << " = PyObject_CallFunction(revOpMethod, const_cast<char *>(\"O\"), self);" << endl;
s << INDENT << "if (PyErr_Occurred() && (PyErr_ExceptionMatches(PyExc_NotImplementedError)";
s << " || PyErr_ExceptionMatches(PyExc_AttributeError))) {" << endl;
{
@@ -1927,16 +1924,16 @@ void CppGenerator::writeMethodWrapper(QTextStream &s, const AbstractMetaFunction
s << '}' << endl << endl;
}
-void CppGenerator::writeArgumentsInitializer(QTextStream& s, OverloadData& overloadData)
+void CppGenerator::writeArgumentsInitializer(QTextStream &s, OverloadData &overloadData)
{
- const AbstractMetaFunction* rfunc = overloadData.referenceFunction();
+ const AbstractMetaFunction *rfunc = overloadData.referenceFunction();
s << "PyTuple_GET_SIZE(args);" << endl;
writeUnusedVariableCast(s, QLatin1String("numArgs"));
int minArgs = overloadData.minArgs();
int maxArgs = overloadData.maxArgs();
- s << INDENT << "PyObject* ";
+ s << INDENT << "PyObject *";
s << PYTHON_ARGS << "[] = {"
<< QString(maxArgs, QLatin1Char('0')).split(QLatin1String(""), QString::SkipEmptyParts).join(QLatin1String(", "))
<< "};" << endl;
@@ -1947,7 +1944,7 @@ void CppGenerator::writeArgumentsInitializer(QTextStream& s, OverloadData& overl
if (minArgs > maxArgs)
minArgs = maxArgs;
- s << INDENT << "PyObject* nonvarargs = PyTuple_GetSlice(args, 0, " << maxArgs << ");" << endl;
+ s << INDENT << "PyObject *nonvarargs = PyTuple_GetSlice(args, 0, " << maxArgs << ");" << endl;
s << INDENT << "Shiboken::AutoDecRef auto_nonvarargs(nonvarargs);" << endl;
s << INDENT << PYTHON_ARGS << '[' << maxArgs << "] = PyTuple_GetSlice(args, " << maxArgs << ", numArgs);" << endl;
s << INDENT << "Shiboken::AutoDecRef auto_varargs(" << PYTHON_ARGS << "[" << maxArgs << "]);" << endl;
@@ -2025,10 +2022,10 @@ void CppGenerator::writeCppSelfAssigment(QTextStream &s, const GeneratorContext
{
static const QString pythonSelfVar = QLatin1String("self");
if (cppSelfAsReference)
- s << className << "& ";
+ s << className << " &";
s << CPP_SELF_VAR << " = ";
if (cppSelfAsReference)
- s << '*';
+ s << " *";
if (useWrapperClass)
s << "static_cast<" << className << " *>(";
if (!context.forSmartPointer())
@@ -2056,7 +2053,7 @@ void CppGenerator::writeCppSelfDefinition(QTextStream &s,
}
if (!cppSelfAsReference) {
- s << INDENT << className << "* " << CPP_SELF_VAR << " = nullptr;" << endl;
+ s << INDENT << className << " *" << CPP_SELF_VAR << " = nullptr;" << endl;
writeUnusedVariableCast(s, QLatin1String(CPP_SELF_VAR));
}
@@ -2103,9 +2100,9 @@ void CppGenerator::writeCppSelfDefinition(QTextStream &s,
writeCppSelfDefinition(s, context, hasStaticOverload);
}
-void CppGenerator::writeErrorSection(QTextStream& s, OverloadData& overloadData)
+void CppGenerator::writeErrorSection(QTextStream &s, OverloadData &overloadData)
{
- const AbstractMetaFunction* rfunc = overloadData.referenceFunction();
+ const AbstractMetaFunction *rfunc = overloadData.referenceFunction();
s << endl << INDENT << cpythonFunctionName(rfunc) << "_TypeError:" << endl;
Indentation indentation(INDENT);
QString funcName = fullPythonFunctionName(rfunc);
@@ -2116,7 +2113,7 @@ void CppGenerator::writeErrorSection(QTextStream& s, OverloadData& overloadData)
s << INDENT << "return " << m_currentErrorCode << ';' << endl;
}
-void CppGenerator::writeFunctionReturnErrorCheckSection(QTextStream& s, bool hasReturnValue)
+void CppGenerator::writeFunctionReturnErrorCheckSection(QTextStream &s, bool hasReturnValue)
{
s << INDENT << "if (PyErr_Occurred()";
if (hasReturnValue)
@@ -2131,14 +2128,14 @@ void CppGenerator::writeFunctionReturnErrorCheckSection(QTextStream& s, bool has
s << INDENT << '}' << endl;
}
-void CppGenerator::writeInvalidPyObjectCheck(QTextStream& s, const QString& pyObj)
+void CppGenerator::writeInvalidPyObjectCheck(QTextStream &s, const QString &pyObj)
{
s << INDENT << "if (!Shiboken::Object::isValid(" << pyObj << "))" << endl;
Indentation indent(INDENT);
s << INDENT << returnStatement(m_currentErrorCode) << endl;
}
-static QString pythonToCppConverterForArgumentName(const QString& argumentName)
+static QString pythonToCppConverterForArgumentName(const QString &argumentName)
{
static const QRegularExpression pyArgsRegex(QLatin1String(PYTHON_ARGS)
+ QLatin1String(R"((\[\d+[-]?\d*\]))"));
@@ -2150,11 +2147,13 @@ static QString pythonToCppConverterForArgumentName(const QString& argumentName)
return result;
}
-void CppGenerator::writeTypeCheck(QTextStream& s, const AbstractMetaType* argType, QString argumentName, bool isNumber, QString customType, bool rejectNull)
+void CppGenerator::writeTypeCheck(QTextStream &s, const AbstractMetaType *argType,
+ const QString &argumentName, bool isNumber,
+ const QString &customType, bool rejectNull)
{
QString customCheck;
if (!customType.isEmpty()) {
- AbstractMetaType* metaType;
+ AbstractMetaType *metaType;
customCheck = guessCPythonCheckFunction(customType, &metaType);
if (metaType)
argType = metaType;
@@ -2182,7 +2181,7 @@ void CppGenerator::writeTypeCheck(QTextStream& s, const AbstractMetaType* argTyp
s << typeCheck;
}
-static void checkTypeViability(const AbstractMetaFunction* func, const AbstractMetaType* type, int argIdx)
+static void checkTypeViability(const AbstractMetaFunction *func, const AbstractMetaType *type, int argIdx)
{
if (!type
|| !type->typeEntry()->isPrimitive()
@@ -2209,25 +2208,25 @@ static void checkTypeViability(const AbstractMetaFunction* func, const AbstractM
qCWarning(lcShiboken).noquote().nospace() << message;
}
-static void checkTypeViability(const AbstractMetaFunction* func)
+static void checkTypeViability(const AbstractMetaFunction *func)
{
if (func->isUserAdded())
return;
- const AbstractMetaType* type = func->type();
+ const AbstractMetaType *type = func->type();
checkTypeViability(func, type, 0);
for (int i = 0; i < func->arguments().count(); ++i)
checkTypeViability(func, func->arguments().at(i)->type(), i + 1);
}
-void CppGenerator::writeTypeCheck(QTextStream& s, const OverloadData* overloadData, QString argumentName)
+void CppGenerator::writeTypeCheck(QTextStream &s, const OverloadData *overloadData, QString argumentName)
{
- QSet<const TypeEntry*> numericTypes;
+ QSet<const TypeEntry *> numericTypes;
const OverloadDataList &overloads = overloadData->previousOverloadData()->nextOverloadData();
for (OverloadData *od : overloads) {
const OverloadData::MetaFunctionList &odOverloads = od->overloads();
for (const AbstractMetaFunction *func : odOverloads) {
checkTypeViability(func);
- const AbstractMetaType* argType = od->argument(func)->type();
+ const AbstractMetaType *argType = od->argument(func)->type();
if (!argType->isPrimitive())
continue;
if (ShibokenGenerator::isNumber(argType->typeEntry()))
@@ -2237,18 +2236,18 @@ void CppGenerator::writeTypeCheck(QTextStream& s, const OverloadData* overloadDa
// This condition trusts that the OverloadData object will arrange for
// PyInt type to come after the more precise numeric types (e.g. float and bool)
- const AbstractMetaType* argType = overloadData->argType();
+ const AbstractMetaType *argType = overloadData->argType();
bool numberType = numericTypes.count() == 1 || ShibokenGenerator::isPyInt(argType);
QString customType = (overloadData->hasArgumentTypeReplace() ? overloadData->argumentTypeReplaced() : QString());
bool rejectNull = shouldRejectNullPointerArgument(overloadData->referenceFunction(), overloadData->argPos());
writeTypeCheck(s, argType, argumentName, numberType, customType, rejectNull);
}
-void CppGenerator::writeArgumentConversion(QTextStream& s,
- const AbstractMetaType* argType,
- const QString& argName, const QString& pyArgName,
- const AbstractMetaClass* context,
- const QString& defaultValue,
+void CppGenerator::writeArgumentConversion(QTextStream &s,
+ const AbstractMetaType *argType,
+ const QString &argName, const QString &pyArgName,
+ const AbstractMetaClass *context,
+ const QString &defaultValue,
bool castArgumentAsUnused)
{
if (argType->typeEntry()->isCustom() || argType->typeEntry()->isVarargs())
@@ -2260,15 +2259,15 @@ void CppGenerator::writeArgumentConversion(QTextStream& s,
writeUnusedVariableCast(s, argName);
}
-const AbstractMetaType* CppGenerator::getArgumentType(const AbstractMetaFunction* func, int argPos)
+const AbstractMetaType *CppGenerator::getArgumentType(const AbstractMetaFunction *func, int argPos)
{
if (argPos < 0 || argPos > func->arguments().size()) {
qCWarning(lcShiboken).noquote().nospace()
<< QStringLiteral("Argument index for function '%1' out of range.").arg(func->signature());
- return 0;
+ return nullptr;
}
- const AbstractMetaType* argType = 0;
+ const AbstractMetaType *argType = nullptr;
QString typeReplaced = func->typeReplaced(argPos);
if (typeReplaced.isEmpty())
argType = (argPos == 0) ? func->type() : func->arguments().at(argPos-1)->type();
@@ -2300,14 +2299,14 @@ static inline QString arrayHandleType(const AbstractMetaTypeCList &nestedArrayTy
return QString();
}
-void CppGenerator::writePythonToCppTypeConversion(QTextStream& s,
- const AbstractMetaType* type,
- const QString& pyIn,
- const QString& cppOut,
- const AbstractMetaClass* /* context */,
- const QString& defaultValue)
+void CppGenerator::writePythonToCppTypeConversion(QTextStream &s,
+ const AbstractMetaType *type,
+ const QString &pyIn,
+ const QString &cppOut,
+ const AbstractMetaClass * /* context */,
+ const QString &defaultValue)
{
- const TypeEntry* typeEntry = type->typeEntry();
+ const TypeEntry *typeEntry = type->typeEntry();
if (typeEntry->isCustom() || typeEntry->isVarargs())
return;
@@ -2336,7 +2335,7 @@ void CppGenerator::writePythonToCppTypeConversion(QTextStream& s,
writeMinimalConstructorExpression(s, type, defaultValue);
s << ';' << endl;
} else if (avoidProtectedHack() && type->typeEntry()->isEnum()) {
- const AbstractMetaEnum* metaEnum = findAbstractMetaEnum(type);
+ const AbstractMetaEnum *metaEnum = findAbstractMetaEnum(type);
if (metaEnum && metaEnum->isProtected()) {
typeName = QLatin1String("long");
isProtectedEnum = true;
@@ -2347,11 +2346,11 @@ void CppGenerator::writePythonToCppTypeConversion(QTextStream& s,
if (isCppPrimitiveArray) {
s << ' ' << cppOut;
} else if (treatAsPointer || isPointerOrObjectType) {
- s << "* " << cppOut;
+ s << " *" << cppOut;
if (!defaultValue.isEmpty())
s << " = " << defaultValue;
} else if (type->referenceType() == LValueReference && !typeEntry->isPrimitive() && isNotContainerEnumOrFlags) {
- s << "* " << cppOut << " = &" << cppOutAux;
+ s << " *" << cppOut << " = &" << cppOutAux;
} else {
s << ' ' << cppOut;
if (isProtectedEnum && avoidProtectedHack()) {
@@ -2400,11 +2399,11 @@ void CppGenerator::writePythonToCppTypeConversion(QTextStream& s,
s << endl;
}
-static void addConversionRuleCodeSnippet(CodeSnipList& snippetList, QString& rule,
+static void addConversionRuleCodeSnippet(CodeSnipList &snippetList, QString &rule,
TypeSystem::Language /* conversionLanguage */,
TypeSystem::Language snippetLanguage,
- QString outputName = QString(),
- QString inputName = QString())
+ const QString &outputName = QString(),
+ const QString &inputName = QString())
{
if (rule.isEmpty())
return;
@@ -2420,7 +2419,7 @@ static void addConversionRuleCodeSnippet(CodeSnipList& snippetList, QString& rul
snippetList << snip;
}
-void CppGenerator::writeConversionRule(QTextStream& s, const AbstractMetaFunction* func, TypeSystem::Language language)
+void CppGenerator::writeConversionRule(QTextStream &s, const AbstractMetaFunction *func, TypeSystem::Language language)
{
CodeSnipList snippets;
const AbstractMetaArgumentList &arguments = func->arguments();
@@ -2432,7 +2431,7 @@ void CppGenerator::writeConversionRule(QTextStream& s, const AbstractMetaFunctio
writeCodeSnips(s, snippets, TypeSystem::CodeSnipPositionBeginning, TypeSystem::TargetLangCode, func);
}
-void CppGenerator::writeConversionRule(QTextStream& s, const AbstractMetaFunction* func, TypeSystem::Language language, const QString& outputVar)
+void CppGenerator::writeConversionRule(QTextStream &s, const AbstractMetaFunction *func, TypeSystem::Language language, const QString &outputVar)
{
CodeSnipList snippets;
QString rule = func->conversionRule(language, 0);
@@ -2440,7 +2439,7 @@ void CppGenerator::writeConversionRule(QTextStream& s, const AbstractMetaFunctio
writeCodeSnips(s, snippets, TypeSystem::CodeSnipPositionAny, language, func);
}
-void CppGenerator::writeNoneReturn(QTextStream& s, const AbstractMetaFunction* func, bool thereIsReturnValue)
+void CppGenerator::writeNoneReturn(QTextStream &s, const AbstractMetaFunction *func, bool thereIsReturnValue)
{
if (thereIsReturnValue && (!func->type() || func->argumentRemoved(0)) && !injectedCodeHasReturnValueAttribution(func)) {
s << INDENT << PYTHON_RETURN_VAR << " = Py_None;" << endl;
@@ -2448,10 +2447,10 @@ void CppGenerator::writeNoneReturn(QTextStream& s, const AbstractMetaFunction* f
}
}
-void CppGenerator::writeOverloadedFunctionDecisor(QTextStream& s, const OverloadData& overloadData)
+void CppGenerator::writeOverloadedFunctionDecisor(QTextStream &s, const OverloadData &overloadData)
{
s << INDENT << "// Overloaded function decisor" << endl;
- const AbstractMetaFunction* rfunc = overloadData.referenceFunction();
+ const AbstractMetaFunction *rfunc = overloadData.referenceFunction();
const OverloadData::MetaFunctionList &functionOverloads = overloadData.overloadsWithoutRepetition();
for (int i = 0; i < functionOverloads.count(); i++) {
const auto func = functionOverloads.at(i);
@@ -2482,10 +2481,10 @@ void CppGenerator::writeOverloadedFunctionDecisor(QTextStream& s, const Overload
s << endl;
}
-void CppGenerator::writeOverloadedFunctionDecisorEngine(QTextStream& s, const OverloadData* parentOverloadData)
+void CppGenerator::writeOverloadedFunctionDecisorEngine(QTextStream &s, const OverloadData *parentOverloadData)
{
bool hasDefaultCall = parentOverloadData->nextArgumentHasDefaultValue();
- const AbstractMetaFunction* referenceFunction = parentOverloadData->referenceFunction();
+ const AbstractMetaFunction *referenceFunction = parentOverloadData->referenceFunction();
// If the next argument has not an argument with a default value, it is still possible
// that one of the overloads for the current overload data has its final occurrence here.
@@ -2513,17 +2512,18 @@ void CppGenerator::writeOverloadedFunctionDecisorEngine(QTextStream& s, const Ov
s << "; // " << referenceFunction->minimalSignature() << endl;
return;
+ }
// To decide if a method call is possible at this point the current overload
// data object cannot be the head, since it is just an entry point, or a root,
// for the tree of arguments and it does not represent a valid method call.
- } else if (!parentOverloadData->isHeadOverloadData()) {
+ if (!parentOverloadData->isHeadOverloadData()) {
bool isLastArgument = parentOverloadData->nextOverloadData().isEmpty();
bool signatureFound = parentOverloadData->overloads().size() == 1;
// The current overload data describes the last argument of a signature,
// so the method can be identified right now.
if (isLastArgument || (signatureFound && !hasDefaultCall)) {
- const AbstractMetaFunction* func = parentOverloadData->referenceFunction();
+ const AbstractMetaFunction *func = parentOverloadData->referenceFunction();
s << INDENT << "overloadId = " << parentOverloadData->headOverloadData()->overloads().indexOf(func);
s << "; // " << func->minimalSignature() << endl;
return;
@@ -2542,9 +2542,9 @@ void CppGenerator::writeOverloadedFunctionDecisorEngine(QTextStream& s, const Ov
s << INDENT << "if (numArgs == " << numArgs << ") {" << endl;
{
Indentation indent(INDENT);
- const AbstractMetaFunction* func = referenceFunction;
+ const AbstractMetaFunction *func = referenceFunction;
for (OverloadData *overloadData : overloads) {
- const AbstractMetaFunction* defValFunc = overloadData->getFunctionWithDefaultValue();
+ const AbstractMetaFunction *defValFunc = overloadData->getFunctionWithDefaultValue();
if (defValFunc) {
func = defValFunc;
break;
@@ -2561,14 +2561,14 @@ void CppGenerator::writeOverloadedFunctionDecisorEngine(QTextStream& s, const Ov
&& !overloadData->getFunctionWithDefaultValue()
&& !overloadData->findNextArgWithDefault();
- const AbstractMetaFunction* refFunc = overloadData->referenceFunction();
+ const AbstractMetaFunction *refFunc = overloadData->referenceFunction();
QStringList typeChecks;
QString pyArgName = (usePyArgs && maxArgs > 1)
? pythonArgsAt(overloadData->argPos())
: QLatin1String(PYTHON_ARG);
- OverloadData* od = overloadData;
+ OverloadData *od = overloadData;
int startArg = od->argPos();
int sequenceArgCount = 0;
while (od && !od->argType()->isVarargs()) {
@@ -2578,11 +2578,11 @@ void CppGenerator::writeOverloadedFunctionDecisorEngine(QTextStream& s, const Ov
pyArgName = pythonArgsAt(od->argPos());
QString typeCheck;
QTextStream tck(&typeCheck);
- const AbstractMetaFunction* func = od->referenceFunction();
+ const AbstractMetaFunction *func = od->referenceFunction();
if (func->isConstructor() && func->arguments().count() == 1) {
- const AbstractMetaClass* ownerClass = func->ownerClass();
- const ComplexTypeEntry* baseContainerType = ownerClass->typeEntry()->baseContainerType();
+ const AbstractMetaClass *ownerClass = func->ownerClass();
+ const ComplexTypeEntry *baseContainerType = ownerClass->typeEntry()->baseContainerType();
if (baseContainerType && baseContainerType == func->arguments().constFirst()->type()->typeEntry() && isCopyable(ownerClass)) {
tck << '!' << cpythonCheckFunction(ownerClass->typeEntry()) << pyArgName << ')' << endl;
Indentation indent(INDENT);
@@ -2600,7 +2600,7 @@ void CppGenerator::writeOverloadedFunctionDecisorEngine(QTextStream& s, const Ov
|| od->nextOverloadData().size() != 1
|| od->overloads().size() != od->nextOverloadData().constFirst()->overloads().size()) {
overloadData = od;
- od = 0;
+ od = nullptr;
} else {
od = od->nextOverloadData().constFirst();
}
@@ -2655,7 +2655,7 @@ void CppGenerator::writeFunctionCalls(QTextStream &s, const OverloadData &overlo
writeSingleFunctionCall(s, overloadData, overloads.constFirst(), context);
} else {
for (int i = 0; i < overloads.count(); i++) {
- const AbstractMetaFunction* func = overloads.at(i);
+ const AbstractMetaFunction *func = overloads.at(i);
s << INDENT << "case " << i << ": // " << func->signature() << endl;
s << INDENT << '{' << endl;
{
@@ -2705,7 +2705,7 @@ void CppGenerator::writeSingleFunctionCall(QTextStream &s,
int removedArgs = 0;
for (int argIdx = 0; argIdx < func->arguments().count(); ++argIdx) {
bool hasConversionRule = !func->conversionRule(TypeSystem::NativeCode, argIdx + 1).isEmpty();
- const AbstractMetaArgument* arg = func->arguments().at(argIdx);
+ const AbstractMetaArgument *arg = func->arguments().at(argIdx);
if (func->argumentRemoved(argIdx + 1)) {
if (!arg->defaultValueExpression().isEmpty()) {
const QString cppArgRemoved = QLatin1String(CPP_ARG_REMOVED)
@@ -2724,7 +2724,7 @@ void CppGenerator::writeSingleFunctionCall(QTextStream &s,
}
if (hasConversionRule)
continue;
- const AbstractMetaType* argType = getArgumentType(func, argIdx + 1);
+ const AbstractMetaType *argType = getArgumentType(func, argIdx + 1);
if (!argType || (mayHaveUnunsedArguments && !injectedCodeUsesArgument(func, argIdx)))
continue;
int argPos = argIdx - removedArgs;
@@ -2748,72 +2748,72 @@ void CppGenerator::writeSingleFunctionCall(QTextStream &s,
s << INDENT << '}' << endl;
}
-QString CppGenerator::cppToPythonFunctionName(const QString& sourceTypeName, QString targetTypeName)
+QString CppGenerator::cppToPythonFunctionName(const QString &sourceTypeName, QString targetTypeName)
{
if (targetTypeName.isEmpty())
targetTypeName = sourceTypeName;
return QString::fromLatin1("%1_CppToPython_%2").arg(sourceTypeName, targetTypeName);
}
-QString CppGenerator::pythonToCppFunctionName(const QString& sourceTypeName, const QString& targetTypeName)
+QString CppGenerator::pythonToCppFunctionName(const QString &sourceTypeName, const QString &targetTypeName)
{
return QString::fromLatin1("%1_PythonToCpp_%2").arg(sourceTypeName, targetTypeName);
}
-QString CppGenerator::pythonToCppFunctionName(const AbstractMetaType* sourceType, const AbstractMetaType* targetType)
+QString CppGenerator::pythonToCppFunctionName(const AbstractMetaType *sourceType, const AbstractMetaType *targetType)
{
return pythonToCppFunctionName(fixedCppTypeName(sourceType), fixedCppTypeName(targetType));
}
-QString CppGenerator::pythonToCppFunctionName(const CustomConversion::TargetToNativeConversion* toNative,
- const TypeEntry* targetType)
+QString CppGenerator::pythonToCppFunctionName(const CustomConversion::TargetToNativeConversion *toNative,
+ const TypeEntry *targetType)
{
return pythonToCppFunctionName(fixedCppTypeName(toNative), fixedCppTypeName(targetType));
}
-QString CppGenerator::convertibleToCppFunctionName(const QString& sourceTypeName, const QString& targetTypeName)
+QString CppGenerator::convertibleToCppFunctionName(const QString &sourceTypeName, const QString &targetTypeName)
{
return QString::fromLatin1("is_%1_PythonToCpp_%2_Convertible").arg(sourceTypeName, targetTypeName);
}
-QString CppGenerator::convertibleToCppFunctionName(const AbstractMetaType* sourceType, const AbstractMetaType* targetType)
+QString CppGenerator::convertibleToCppFunctionName(const AbstractMetaType *sourceType, const AbstractMetaType *targetType)
{
return convertibleToCppFunctionName(fixedCppTypeName(sourceType), fixedCppTypeName(targetType));
}
-QString CppGenerator::convertibleToCppFunctionName(const CustomConversion::TargetToNativeConversion* toNative,
- const TypeEntry* targetType)
+QString CppGenerator::convertibleToCppFunctionName(const CustomConversion::TargetToNativeConversion *toNative,
+ const TypeEntry *targetType)
{
return convertibleToCppFunctionName(fixedCppTypeName(toNative), fixedCppTypeName(targetType));
}
-void CppGenerator::writeCppToPythonFunction(QTextStream& s, const QString& code, const QString& sourceTypeName, QString targetTypeName)
+void CppGenerator::writeCppToPythonFunction(QTextStream &s, const QString &code, const QString &sourceTypeName, QString targetTypeName)
{
QString prettyCode;
QTextStream c(&prettyCode);
formatCode(c, code, INDENT);
processCodeSnip(prettyCode);
- s << "static PyObject* " << cppToPythonFunctionName(sourceTypeName, targetTypeName);
- s << "(const void* cppIn) {" << endl;
+ s << "static PyObject *" << cppToPythonFunctionName(sourceTypeName, targetTypeName);
+ s << "(const void *cppIn) {" << endl;
s << prettyCode;
s << '}' << endl;
}
-static void replaceCppToPythonVariables(QString& code, const QString& typeName)
+static void replaceCppToPythonVariables(QString &code, const QString &typeName)
{
code.prepend(QLatin1String("auto &cppInRef = *reinterpret_cast<")
- + typeName + QLatin1String("*>(const_cast<void *>(cppIn));\n"));
+ + typeName + QLatin1String(" *>(const_cast<void *>(cppIn));\n"));
code.replace(QLatin1String("%INTYPE"), typeName);
- code.replace(QLatin1String("%OUTTYPE"), QLatin1String("PyObject*"));
+ code.replace(QLatin1String("%OUTTYPE"), QLatin1String("PyObject *"));
code.replace(QLatin1String("%in"), QLatin1String("cppInRef"));
code.replace(QLatin1String("%out"), QLatin1String("pyOut"));
}
-void CppGenerator::writeCppToPythonFunction(QTextStream& s, const CustomConversion* customConversion)
+void CppGenerator::writeCppToPythonFunction(QTextStream &s, const CustomConversion *customConversion)
{
QString code = customConversion->nativeToTargetConversion();
replaceCppToPythonVariables(code, getFullTypeName(customConversion->ownerType()));
writeCppToPythonFunction(s, code, fixedCppTypeName(customConversion->ownerType()));
}
-void CppGenerator::writeCppToPythonFunction(QTextStream& s, const AbstractMetaType* containerType)
+void CppGenerator::writeCppToPythonFunction(QTextStream &s, const AbstractMetaType *containerType)
{
- const CustomConversion* customConversion = containerType->typeEntry()->customConversion();
+ const CustomConversion *customConversion = containerType->typeEntry()->customConversion();
if (!customConversion) {
qFatal("Can't write the C++ to Python conversion function for container type '%s' - "\
"no conversion rule was defined for it in the type system.",
@@ -2825,7 +2825,7 @@ void CppGenerator::writeCppToPythonFunction(QTextStream& s, const AbstractMetaTy
}
QString code = customConversion->nativeToTargetConversion();
for (int i = 0; i < containerType->instantiations().count(); ++i) {
- AbstractMetaType* type = containerType->instantiations().at(i);
+ AbstractMetaType *type = containerType->instantiations().at(i);
QString typeName = getFullTypeName(type);
if (type->isConstant())
typeName = QLatin1String("const ") + typeName;
@@ -2836,22 +2836,22 @@ void CppGenerator::writeCppToPythonFunction(QTextStream& s, const AbstractMetaTy
writeCppToPythonFunction(s, code, fixedCppTypeName(containerType));
}
-void CppGenerator::writePythonToCppFunction(QTextStream& s, const QString& code, const QString& sourceTypeName, const QString& targetTypeName)
+void CppGenerator::writePythonToCppFunction(QTextStream &s, const QString &code, const QString &sourceTypeName, const QString &targetTypeName)
{
QString prettyCode;
QTextStream c(&prettyCode);
formatCode(c, code, INDENT);
processCodeSnip(prettyCode);
s << "static void " << pythonToCppFunctionName(sourceTypeName, targetTypeName);
- s << "(PyObject* pyIn, void* cppOut) {" << endl;
+ s << "(PyObject *pyIn, void *cppOut) {" << endl;
s << prettyCode;
s << '}' << endl;
}
-void CppGenerator::writeIsPythonConvertibleToCppFunction(QTextStream& s,
- const QString& sourceTypeName,
- const QString& targetTypeName,
- const QString& condition,
+void CppGenerator::writeIsPythonConvertibleToCppFunction(QTextStream &s,
+ const QString &sourceTypeName,
+ const QString &targetTypeName,
+ const QString &condition,
QString pythonToCppFuncName,
bool acceptNoneAsCppNull)
{
@@ -2859,7 +2859,7 @@ void CppGenerator::writeIsPythonConvertibleToCppFunction(QTextStream& s,
pythonToCppFuncName = pythonToCppFunctionName(sourceTypeName, targetTypeName);
s << "static PythonToCppFunc " << convertibleToCppFunctionName(sourceTypeName, targetTypeName);
- s << "(PyObject* pyIn) {" << endl;
+ s << "(PyObject *pyIn) {" << endl;
if (acceptNoneAsCppNull) {
s << INDENT << "if (pyIn == Py_None)" << endl;
Indentation indent(INDENT);
@@ -2874,12 +2874,12 @@ void CppGenerator::writeIsPythonConvertibleToCppFunction(QTextStream& s,
s << '}' << endl;
}
-void CppGenerator::writePythonToCppConversionFunctions(QTextStream& s,
- const AbstractMetaType* sourceType,
- const AbstractMetaType* targetType,
+void CppGenerator::writePythonToCppConversionFunctions(QTextStream &s,
+ const AbstractMetaType *sourceType,
+ const AbstractMetaType *targetType,
QString typeCheck,
QString conversion,
- QString preConversion)
+ const QString &preConversion)
{
QString sourcePyType = cpythonTypeNameExt(sourceType);
@@ -2891,7 +2891,7 @@ void CppGenerator::writePythonToCppConversionFunctions(QTextStream& s,
if (!preConversion.isEmpty())
c << INDENT << preConversion << endl;
const QString fullTypeName = getFullTypeName(targetType->typeEntry());
- c << INDENT << "*reinterpret_cast<" << fullTypeName << "*>(cppOut) = "
+ c << INDENT << "*reinterpret_cast<" << fullTypeName << " *>(cppOut) = "
<< fullTypeName << '(' << conversion << ");";
QString sourceTypeName = fixedCppTypeName(sourceType);
QString targetTypeName = fixedCppTypeName(targetType);
@@ -2904,9 +2904,9 @@ void CppGenerator::writePythonToCppConversionFunctions(QTextStream& s,
s << endl;
}
-void CppGenerator::writePythonToCppConversionFunctions(QTextStream& s,
- const CustomConversion::TargetToNativeConversion* toNative,
- const TypeEntry* targetType)
+void CppGenerator::writePythonToCppConversionFunctions(QTextStream &s,
+ const CustomConversion::TargetToNativeConversion *toNative,
+ const TypeEntry *targetType)
{
// Python to C++ conversion function.
QString code = toNative->conversion();
@@ -2919,7 +2919,7 @@ void CppGenerator::writePythonToCppConversionFunctions(QTextStream& s,
code.replace(QLatin1String("%OUTTYPE"), targetType->qualifiedCppName());
code.replace(QLatin1String("%in"), QLatin1String("pyIn"));
code.replace(QLatin1String("%out"),
- QLatin1String("*reinterpret_cast<") + getFullTypeName(targetType) + QLatin1String("*>(cppOut)"));
+ QLatin1String("*reinterpret_cast<") + getFullTypeName(targetType) + QLatin1String(" *>(cppOut)"));
QString sourceTypeName = fixedCppTypeName(toNative);
QString targetTypeName = fixedCppTypeName(targetType);
@@ -2956,14 +2956,14 @@ void CppGenerator::writePythonToCppConversionFunctions(QTextStream& s,
writeIsPythonConvertibleToCppFunction(s, sourceTypeName, targetTypeName, typeCheck);
}
-void CppGenerator::writePythonToCppConversionFunctions(QTextStream& s, const AbstractMetaType* containerType)
+void CppGenerator::writePythonToCppConversionFunctions(QTextStream &s, const AbstractMetaType *containerType)
{
- const CustomConversion* customConversion = containerType->typeEntry()->customConversion();
+ const CustomConversion *customConversion = containerType->typeEntry()->customConversion();
if (!customConversion) {
//qFatal
return;
}
- const CustomConversion::TargetToNativeConversions& toCppConversions = customConversion->targetToNativeConversions();
+ const CustomConversion::TargetToNativeConversions &toCppConversions = customConversion->targetToNativeConversions();
if (toCppConversions.isEmpty()) {
//qFatal
return;
@@ -2973,10 +2973,10 @@ void CppGenerator::writePythonToCppConversionFunctions(QTextStream& s, const Abs
QString code;
QTextStream c(&code);
c << INDENT << "auto &cppOutRef = *reinterpret_cast<"
- << cppTypeName << "*>(cppOut);\n";
+ << cppTypeName << " *>(cppOut);\n";
code.append(toCppConversions.constFirst()->conversion());
for (int i = 0; i < containerType->instantiations().count(); ++i) {
- const AbstractMetaType* type = containerType->instantiations().at(i);
+ const AbstractMetaType *type = containerType->instantiations().at(i);
QString typeName = getFullTypeName(type);
if (type->isValue() && isValueTypeWithCopyConstructorOnly(type)) {
for (int pos = 0; ; ) {
@@ -2989,7 +2989,7 @@ void CppGenerator::writePythonToCppConversionFunctions(QTextStream& s, const Abs
rightCode.replace(varName, QLatin1Char('*') + varName);
code.replace(pos, code.size() - pos, rightCode);
}
- typeName.append(QLatin1Char('*'));
+ typeName.append(QLatin1String(" *"));
}
code.replace(QString::fromLatin1("%OUTTYPE_%1").arg(i), typeName);
}
@@ -3009,7 +3009,7 @@ void CppGenerator::writePythonToCppConversionFunctions(QTextStream& s, const Abs
s << endl;
}
-void CppGenerator::writeAddPythonToCppConversion(QTextStream& s, const QString& converterVar, const QString& pythonToCppFunc, const QString& isConvertibleFunc)
+void CppGenerator::writeAddPythonToCppConversion(QTextStream &s, const QString &converterVar, const QString &pythonToCppFunc, const QString &isConvertibleFunc)
{
s << INDENT << "Shiboken::Conversions::addPythonToCppValueConversion(" << converterVar << ',' << endl;
{
@@ -3020,7 +3020,7 @@ void CppGenerator::writeAddPythonToCppConversion(QTextStream& s, const QString&
s << ");" << endl;
}
-void CppGenerator::writeNamedArgumentResolution(QTextStream& s, const AbstractMetaFunction* func, bool usePyArgs)
+void CppGenerator::writeNamedArgumentResolution(QTextStream &s, const AbstractMetaFunction *func, bool usePyArgs)
{
const AbstractMetaArgumentList &args = OverloadData::getArgumentsWithDefaultValues(func);
if (args.isEmpty())
@@ -3032,7 +3032,7 @@ void CppGenerator::writeNamedArgumentResolution(QTextStream& s, const AbstractMe
s << INDENT << "if (kwds) {" << endl;
{
Indentation indent(INDENT);
- s << INDENT << "PyObject* ";
+ s << INDENT << "PyObject *";
for (const AbstractMetaArgument *arg : args) {
int pyArgIndex = arg->argumentIndex() - OverloadData::numberOfRemovedArguments(func, arg->argumentIndex());
QString pyArgName = usePyArgs ? pythonArgsAt(pyArgIndex) : QLatin1String(PYTHON_ARG);
@@ -3063,9 +3063,9 @@ void CppGenerator::writeNamedArgumentResolution(QTextStream& s, const AbstractMe
s << INDENT << '}' << endl;
}
-QString CppGenerator::argumentNameFromIndex(const AbstractMetaFunction* func, int argIndex, const AbstractMetaClass** wrappedClass)
+QString CppGenerator::argumentNameFromIndex(const AbstractMetaFunction *func, int argIndex, const AbstractMetaClass **wrappedClass)
{
- *wrappedClass = 0;
+ *wrappedClass = nullptr;
QString pyArgName;
if (argIndex == -1) {
pyArgName = QLatin1String("self");
@@ -3086,7 +3086,7 @@ QString CppGenerator::argumentNameFromIndex(const AbstractMetaFunction* func, in
}
} else {
int realIndex = argIndex - 1 - OverloadData::numberOfRemovedArguments(func, argIndex - 1);
- AbstractMetaType* argType = getTypeWithoutContainer(func->arguments().at(realIndex)->type());
+ AbstractMetaType *argType = getTypeWithoutContainer(func->arguments().at(realIndex)->type());
if (argType) {
*wrappedClass = AbstractMetaClass::findClass(classes(), argType->typeEntry());
@@ -3120,14 +3120,14 @@ void CppGenerator::writeMethodCall(QTextStream &s, const AbstractMetaFunction *f
const CodeSnipList &snips = func->injectedCodeSnips();
for (const CodeSnip &cs : snips) {
if (cs.position == TypeSystem::CodeSnipPositionEnd) {
- s << INDENT << "overloadId = " << func->ownerClass()->functions().indexOf(const_cast<AbstractMetaFunction* const>(func)) << ';' << endl;
+ s << INDENT << "overloadId = " << func->ownerClass()->functions().indexOf(const_cast<AbstractMetaFunction *const>(func)) << ';' << endl;
break;
}
}
}
if (func->isAbstract()) {
- s << INDENT << "if (Shiboken::Object::hasCppWrapper(reinterpret_cast<SbkObject*>(self))) {\n";
+ s << INDENT << "if (Shiboken::Object::hasCppWrapper(reinterpret_cast<SbkObject *>(self))) {\n";
{
Indentation indent(INDENT);
s << INDENT << "PyErr_SetString(PyExc_NotImplementedError, \"pure virtual method '";
@@ -3138,7 +3138,7 @@ void CppGenerator::writeMethodCall(QTextStream &s, const AbstractMetaFunction *f
}
// Used to provide contextual information to custom code writer function.
- const AbstractMetaArgument* lastArg = 0;
+ const AbstractMetaArgument *lastArg = nullptr;
CodeSnipList snips;
if (func->hasInjectedCode()) {
@@ -3169,7 +3169,7 @@ void CppGenerator::writeMethodCall(QTextStream &s, const AbstractMetaFunction *f
if (func->functionType() != AbstractMetaFunction::CopyConstructorFunction) {
int removedArgs = 0;
for (int i = 0; i < maxArgs + removedArgs; i++) {
- const AbstractMetaArgument* arg = func->arguments().at(i);
+ const AbstractMetaArgument *arg = func->arguments().at(i);
bool hasConversionRule = !func->conversionRule(TypeSystem::NativeCode, arg->argumentIndex() + 1).isEmpty();
if (func->argumentRemoved(i + 1)) {
// If some argument with default value is removed from a
@@ -3207,7 +3207,7 @@ void CppGenerator::writeMethodCall(QTextStream &s, const AbstractMetaFunction *f
bool otherArgsModified = false;
bool argsClear = true;
for (int i = func->arguments().size() - 1; i >= maxArgs + removedArgs; i--) {
- const AbstractMetaArgument* arg = func->arguments().at(i);
+ const AbstractMetaArgument *arg = func->arguments().at(i);
const bool defValModified = arg->hasModifiedDefaultValueExpression();
bool hasConversionRule = !func->conversionRule(TypeSystem::NativeCode, arg->argumentIndex() + 1).isEmpty();
if (argsClear && !defValModified && !hasConversionRule)
@@ -3269,7 +3269,7 @@ void CppGenerator::writeMethodCall(QTextStream &s, const AbstractMetaFunction *f
} else {
QString ctorCall = className + QLatin1Char('(') + userArgs.join(QLatin1String(", ")) + QLatin1Char(')');
if (usePySideExtensions() && func->ownerClass()->isQObject()) {
- s << INDENT << "void* addr = PySide::nextQObjectMemoryAddr();" << endl;
+ s << INDENT << "void *addr = PySide::nextQObjectMemoryAddr();" << endl;
uva << "if (addr) {" << endl;
{
Indentation indent(INDENT);
@@ -3318,15 +3318,15 @@ void CppGenerator::writeMethodCall(QTextStream &s, const AbstractMetaFunction *f
: QLatin1String("reinterpret_cast<") + wrapperName(func->ownerClass())
+ QLatin1String(" *>(") + QLatin1String(CPP_SELF_VAR) + QLatin1Char(')');
mc << wrapperName(func->ownerClass());
- mc << "*>(" << selfWrapCast << ")->";
+ mc << " *>(" << selfWrapCast << ")->";
}
else {
mc << methodCallClassName;
- mc << "*>(" << selfVarCast << ")->";
+ mc << " *>(" << selfVarCast << ")->";
}
} else {
mc << "const_cast<const ::" << methodCallClassName;
- mc << "*>(" << selfVarCast << ")->";
+ mc << " *>(" << selfVarCast << ")->";
}
} else {
mc << selfVarCast << "->";
@@ -3342,7 +3342,7 @@ void CppGenerator::writeMethodCall(QTextStream &s, const AbstractMetaFunction *f
const auto *owner = func->ownerClass();
const bool directInheritance = context.metaClass() == owner;
mc << (directInheritance ? "static_cast" : "reinterpret_cast")
- << "<::" << wrapperName(owner) << "*>(" << CPP_SELF_VAR << ")->";
+ << "<::" << wrapperName(owner) << " *>(" << CPP_SELF_VAR << ")->";
}
if (!func->isAbstract())
@@ -3364,7 +3364,7 @@ void CppGenerator::writeMethodCall(QTextStream &s, const AbstractMetaFunction *f
methodCallClassName);
normalCall.remove(QLatin1String("::%CLASS_NAME::"));
methodCall.clear();
- mc << "Shiboken::Object::hasCppWrapper(reinterpret_cast<SbkObject*>(self)) ? ";
+ mc << "Shiboken::Object::hasCppWrapper(reinterpret_cast<SbkObject *>(self)) ? ";
mc << virtualCall << " : " << normalCall;
}
}
@@ -3391,7 +3391,7 @@ void CppGenerator::writeMethodCall(QTextStream &s, const AbstractMetaFunction *f
} else if (func->type() && !func->isInplaceOperator()) {
bool writeReturnType = true;
if (avoidProtectedHack()) {
- const AbstractMetaEnum* metaEnum = findAbstractMetaEnum(func->type());
+ const AbstractMetaEnum *metaEnum = findAbstractMetaEnum(func->type());
if (metaEnum) {
QString enumName;
if (metaEnum->isProtected())
@@ -3475,7 +3475,7 @@ void CppGenerator::writeMethodCall(QTextStream &s, const AbstractMetaFunction *f
if (!ownership_mods.isEmpty()) {
s << endl << INDENT << "// Ownership transferences." << endl;
for (const ArgumentModification &arg_mod : qAsConst(ownership_mods)) {
- const AbstractMetaClass* wrappedClass = 0;
+ const AbstractMetaClass *wrappedClass = nullptr;
QString pyArgName = argumentNameFromIndex(func, arg_mod.index, &wrappedClass);
if (!wrappedClass) {
s << "#error Invalid ownership modification for argument " << arg_mod.index << '(' << pyArgName << ')' << endl << endl;
@@ -3513,7 +3513,7 @@ void CppGenerator::writeMethodCall(QTextStream &s, const AbstractMetaFunction *f
qCWarning(lcShiboken) << "\"set\", \"add\" and \"remove\" are the only values supported by Shiboken for action attribute of reference-count tag.";
continue;
}
- const AbstractMetaClass* wrappedClass = 0;
+ const AbstractMetaClass *wrappedClass = nullptr;
QString pyArgName;
if (refCount.action == ReferenceCount::Remove) {
@@ -3531,7 +3531,7 @@ void CppGenerator::writeMethodCall(QTextStream &s, const AbstractMetaFunction *f
else
s << INDENT << "Shiboken::Object::removeReference(";
- s << "reinterpret_cast<SbkObject*>(self), \"";
+ s << "reinterpret_cast<SbkObject *>(self), \"";
QString varName = arg_mod.referenceCounts.constFirst().varName;
if (varName.isEmpty())
varName = func->minimalSignature() + QString::number(arg_mod.index);
@@ -3547,7 +3547,7 @@ void CppGenerator::writeMethodCall(QTextStream &s, const AbstractMetaFunction *f
writeParentChildManagement(s, func, !hasReturnPolicy);
}
-QStringList CppGenerator::getAncestorMultipleInheritance(const AbstractMetaClass* metaClass)
+QStringList CppGenerator::getAncestorMultipleInheritance(const AbstractMetaClass *metaClass)
{
QStringList result;
const AbstractMetaClassList &baseClases = getBaseClasses(metaClass);
@@ -3555,13 +3555,13 @@ QStringList CppGenerator::getAncestorMultipleInheritance(const AbstractMetaClass
for (const AbstractMetaClass *baseClass : baseClases) {
QString offset;
QTextStream(&offset) << "reinterpret_cast<uintptr_t>(static_cast<const "
- << baseClass->qualifiedCppName() << "*>(class_ptr)) - base";
+ << baseClass->qualifiedCppName() << " *>(class_ptr)) - base";
result.append(offset);
offset.clear();
QTextStream(&offset) << "reinterpret_cast<uintptr_t>(static_cast<const "
- << baseClass->qualifiedCppName() << "*>(static_cast<const "
+ << baseClass->qualifiedCppName() << " *>(static_cast<const "
<< metaClass->qualifiedCppName()
- << "*>(static_cast<const void*>(class_ptr)))) - base";
+ << " *>(static_cast<const void *>(class_ptr)))) - base";
result.append(offset);
}
@@ -3571,7 +3571,7 @@ QStringList CppGenerator::getAncestorMultipleInheritance(const AbstractMetaClass
return result;
}
-void CppGenerator::writeMultipleInheritanceInitializerFunction(QTextStream& s, const AbstractMetaClass* metaClass)
+void CppGenerator::writeMultipleInheritanceInitializerFunction(QTextStream &s, const AbstractMetaClass *metaClass)
{
QString className = metaClass->qualifiedCppName();
const QStringList ancestors = getAncestorMultipleInheritance(metaClass);
@@ -3579,14 +3579,14 @@ void CppGenerator::writeMultipleInheritanceInitializerFunction(QTextStream& s, c
for (int i = 0; i < ancestors.size(); i++)
s << "-1, ";
s << "-1 };" << endl;
- s << "int*" << endl;
- s << multipleInheritanceInitializerFunctionName(metaClass) << "(const void* cptr)" << endl;
+ s << "int *" << endl;
+ s << multipleInheritanceInitializerFunctionName(metaClass) << "(const void *cptr)" << endl;
s << '{' << endl;
s << INDENT << "if (mi_offsets[0] == -1) {" << endl;
{
Indentation indent(INDENT);
s << INDENT << "std::set<int> offsets;" << endl;
- s << INDENT << "const auto* class_ptr = reinterpret_cast<const " << className << "*>(cptr);" << endl;
+ s << INDENT << "const auto *class_ptr = reinterpret_cast<const " << className << " *>(cptr);" << endl;
s << INDENT << "const auto base = reinterpret_cast<uintptr_t>(class_ptr);" << endl;
for (const QString &ancestor : ancestors)
@@ -3603,27 +3603,27 @@ void CppGenerator::writeMultipleInheritanceInitializerFunction(QTextStream& s, c
s << '}' << endl;
}
-void CppGenerator::writeSpecialCastFunction(QTextStream& s, const AbstractMetaClass* metaClass)
+void CppGenerator::writeSpecialCastFunction(QTextStream &s, const AbstractMetaClass *metaClass)
{
QString className = metaClass->qualifiedCppName();
- s << "static void* " << cpythonSpecialCastFunctionName(metaClass) << "(void* obj, SbkObjectType* desiredType)\n";
+ s << "static void * " << cpythonSpecialCastFunctionName(metaClass) << "(void *obj, SbkObjectType *desiredType)\n";
s << "{\n";
- s << INDENT << className << "* me = reinterpret_cast< ::" << className << "*>(obj);\n";
+ s << INDENT << "auto me = reinterpret_cast< ::" << className << " *>(obj);\n";
bool firstClass = true;
const AbstractMetaClassList &allAncestors = getAllAncestors(metaClass);
for (const AbstractMetaClass *baseClass : allAncestors) {
- s << INDENT << (!firstClass ? "else " : "") << "if (desiredType == reinterpret_cast<SbkObjectType*>(" << cpythonTypeNameExt(baseClass->typeEntry()) << "))\n";
+ s << INDENT << (!firstClass ? "else " : "") << "if (desiredType == reinterpret_cast<SbkObjectType *>(" << cpythonTypeNameExt(baseClass->typeEntry()) << "))\n";
Indentation indent(INDENT);
- s << INDENT << "return static_cast< ::" << baseClass->qualifiedCppName() << "*>(me);\n";
+ s << INDENT << "return static_cast< ::" << baseClass->qualifiedCppName() << " *>(me);\n";
firstClass = false;
}
s << INDENT << "return me;\n";
s << "}\n\n";
}
-void CppGenerator::writePrimitiveConverterInitialization(QTextStream& s, const CustomConversion* customConversion)
+void CppGenerator::writePrimitiveConverterInitialization(QTextStream &s, const CustomConversion *customConversion)
{
- const TypeEntry* type = customConversion->ownerType();
+ const TypeEntry *type = customConversion->ownerType();
QString converter = converterObject(type);
s << INDENT << "// Register converter for type '" << type->qualifiedTargetLangName() << "'." << endl;
s << INDENT << converter << " = Shiboken::Conversions::createConverter(";
@@ -3639,30 +3639,30 @@ void CppGenerator::writePrimitiveConverterInitialization(QTextStream& s, const C
writeCustomConverterRegister(s, customConversion, converter);
}
-void CppGenerator::writeEnumConverterInitialization(QTextStream& s, const AbstractMetaEnum* metaEnum)
+void CppGenerator::writeEnumConverterInitialization(QTextStream &s, const AbstractMetaEnum *metaEnum)
{
if (metaEnum->isPrivate() || metaEnum->isAnonymous())
return;
writeEnumConverterInitialization(s, metaEnum->typeEntry());
}
-void CppGenerator::writeEnumConverterInitialization(QTextStream& s, const TypeEntry* enumType)
+void CppGenerator::writeEnumConverterInitialization(QTextStream &s, const TypeEntry *enumType)
{
if (!enumType)
return;
QString enumFlagName = enumType->isFlags() ? QLatin1String("flag") : QLatin1String("enum");
QString enumPythonType = cpythonTypeNameExt(enumType);
- const FlagsTypeEntry* flags = 0;
+ const FlagsTypeEntry *flags = nullptr;
if (enumType->isFlags())
- flags = static_cast<const FlagsTypeEntry*>(enumType);
+ flags = static_cast<const FlagsTypeEntry *>(enumType);
s << INDENT << "// Register converter for " << enumFlagName << " '" << enumType->qualifiedCppName() << "'." << endl;
s << INDENT << '{' << endl;
{
Indentation indent(INDENT);
QString typeName = fixedCppTypeName(enumType);
- s << INDENT << "SbkConverter* converter = Shiboken::Conversions::createConverter(" << enumPythonType << ',' << endl;
+ s << INDENT << "SbkConverter *converter = Shiboken::Conversions::createConverter(" << enumPythonType << ',' << endl;
{
Indentation indent(INDENT);
s << INDENT << cppToPythonFunctionName(typeName, typeName) << ");" << endl;
@@ -3714,10 +3714,10 @@ void CppGenerator::writeEnumConverterInitialization(QTextStream& s, const TypeEn
s << INDENT << '}' << endl;
if (!flags)
- writeEnumConverterInitialization(s, static_cast<const EnumTypeEntry*>(enumType)->flags());
+ writeEnumConverterInitialization(s, static_cast<const EnumTypeEntry *>(enumType)->flags());
}
-void CppGenerator::writeContainerConverterInitialization(QTextStream& s, const AbstractMetaType* type)
+void CppGenerator::writeContainerConverterInitialization(QTextStream &s, const AbstractMetaType *type)
{
QByteArray cppSignature = QMetaObject::normalizedSignature(type->cppSignature().toUtf8());
s << INDENT << "// Register converter for type '" << cppSignature << "'." << endl;
@@ -3744,8 +3744,8 @@ void CppGenerator::writeContainerConverterInitialization(QTextStream& s, const A
writeAddPythonToCppConversion(s, converterObject(type), toCpp, isConv);
}
-void CppGenerator::writeExtendedConverterInitialization(QTextStream& s, const TypeEntry* externalType,
- const QVector<const AbstractMetaClass*>& conversions)
+void CppGenerator::writeExtendedConverterInitialization(QTextStream &s, const TypeEntry *externalType,
+ const QVector<const AbstractMetaClass *>& conversions)
{
s << INDENT << "// Extended implicit conversions for " << externalType->qualifiedTargetLangName() << '.' << endl;
for (const AbstractMetaClass *sourceClass : conversions) {
@@ -3760,16 +3760,14 @@ void CppGenerator::writeExtendedConverterInitialization(QTextStream& s, const Ty
}
}
-QString CppGenerator::multipleInheritanceInitializerFunctionName(const AbstractMetaClass* metaClass)
+QString CppGenerator::multipleInheritanceInitializerFunctionName(const AbstractMetaClass *metaClass)
{
return cpythonBaseName(metaClass->typeEntry()) + QLatin1String("_mi_init");
}
-typedef QHash<QString, QPair<QString, QString> >::const_iterator ProtocolIt;
-
-bool CppGenerator::supportsMappingProtocol(const AbstractMetaClass* metaClass)
+bool CppGenerator::supportsMappingProtocol(const AbstractMetaClass *metaClass)
{
- for (ProtocolIt it = m_mappingProtocol.cbegin(), end = m_mappingProtocol.cend(); it != end; ++it) {
+ for (auto it = m_mappingProtocol.cbegin(), end = m_mappingProtocol.cend(); it != end; ++it) {
if (metaClass->hasFunction(it.key()))
return true;
}
@@ -3777,7 +3775,7 @@ bool CppGenerator::supportsMappingProtocol(const AbstractMetaClass* metaClass)
return false;
}
-bool CppGenerator::supportsNumberProtocol(const AbstractMetaClass* metaClass)
+bool CppGenerator::supportsNumberProtocol(const AbstractMetaClass *metaClass)
{
return metaClass->hasArithmeticOperatorOverload()
|| metaClass->hasLogicalOperatorOverload()
@@ -3785,18 +3783,18 @@ bool CppGenerator::supportsNumberProtocol(const AbstractMetaClass* metaClass)
|| hasBoolCast(metaClass);
}
-bool CppGenerator::supportsSequenceProtocol(const AbstractMetaClass* metaClass)
+bool CppGenerator::supportsSequenceProtocol(const AbstractMetaClass *metaClass)
{
- for (ProtocolIt it = m_sequenceProtocol.cbegin(), end = m_sequenceProtocol.cend(); it != end; ++it) {
+ for (auto it = m_sequenceProtocol.cbegin(), end = m_sequenceProtocol.cend(); it != end; ++it) {
if (metaClass->hasFunction(it.key()))
return true;
}
- const ComplexTypeEntry* baseType = metaClass->typeEntry()->baseContainerType();
+ const ComplexTypeEntry *baseType = metaClass->typeEntry()->baseContainerType();
return baseType && baseType->isContainer();
}
-bool CppGenerator::shouldGenerateGetSetList(const AbstractMetaClass* metaClass)
+bool CppGenerator::shouldGenerateGetSetList(const AbstractMetaClass *metaClass)
{
const AbstractMetaFieldList &fields = metaClass->fields();
for (const AbstractMetaField *f : fields) {
@@ -3824,7 +3822,7 @@ QTextStream &operator<<(QTextStream &str, const pyTypeSlotEntry &e)
if (e.m_function.isEmpty())
str << NULL_PTR;
else
- str << "reinterpret_cast<void*>(" << e.m_function << ')';
+ str << "reinterpret_cast<void *>(" << e.m_function << ')';
str << "},\n";
return str;
}
@@ -3850,7 +3848,7 @@ void CppGenerator::writeClassDefinition(QTextStream &s,
}
if (!metaClass->baseClass())
- baseClassName = QLatin1String("reinterpret_cast<PyTypeObject*>(SbkObject_TypeF())");
+ baseClassName = QLatin1String("reinterpret_cast<PyTypeObject *>(SbkObject_TypeF())");
bool onlyPrivCtor = !metaClass->hasNonPrivateConstructor();
@@ -3937,7 +3935,7 @@ void CppGenerator::writeClassDefinition(QTextStream &s,
}
// class or some ancestor has multiple inheritance
- const AbstractMetaClass* miClass = getMultipleInheritingClass(metaClass);
+ const AbstractMetaClass *miClass = getMultipleInheritingClass(metaClass);
if (miClass) {
if (metaClass == miClass)
writeMultipleInheritanceInitializerFunction(s, metaClass);
@@ -3951,7 +3949,7 @@ void CppGenerator::writeClassDefinition(QTextStream &s,
if (!metaClass->typeEntry()->hashFunction().isEmpty())
tp_hash = QLatin1Char('&') + cpythonBaseName(metaClass) + QLatin1String("_HashFunc");
- const AbstractMetaFunction* callOp = metaClass->findFunction(QLatin1String("operator()"));
+ const AbstractMetaFunction *callOp = metaClass->findFunction(QLatin1String("operator()"));
if (callOp && !callOp->isModifiedRemoved())
tp_call = QLatin1Char('&') + cpythonFunctionName(callOp);
@@ -3963,7 +3961,7 @@ void CppGenerator::writeClassDefinition(QTextStream &s,
QString suffix;
if (isObjectType(metaClass))
- suffix = QLatin1String("*");
+ suffix = QLatin1String(" *");
const QString typePtr = QLatin1String("_") + className
+ QLatin1String("_Type");
s << "static SbkObjectType *" << typePtr << " = nullptr;" << endl;
@@ -4021,7 +4019,7 @@ void CppGenerator::writeMappingMethods(QTextStream &s,
GeneratorContext &context)
{
for (auto it = m_mappingProtocol.cbegin(), end = m_mappingProtocol.cend(); it != end; ++it) {
- const AbstractMetaFunction* func = metaClass->findFunction(it.key());
+ const AbstractMetaFunction *func = metaClass->findFunction(it.key());
if (!func)
continue;
QString funcName = cpythonFunctionName(func);
@@ -4034,7 +4032,7 @@ void CppGenerator::writeMappingMethods(QTextStream &s,
writeCppSelfDefinition(s, func, context);
- const AbstractMetaArgument* lastArg = func->arguments().isEmpty() ? 0 : func->arguments().constLast();
+ const AbstractMetaArgument *lastArg = func->arguments().isEmpty() ? nullptr : func->arguments().constLast();
writeCodeSnips(s, snips, TypeSystem::CodeSnipPositionAny, TypeSystem::TargetLangCode, func, lastArg);
s << '}' << endl << endl;
}
@@ -4047,7 +4045,7 @@ void CppGenerator::writeSequenceMethods(QTextStream &s,
bool injectedCode = false;
for (auto it = m_sequenceProtocol.cbegin(), end = m_sequenceProtocol.cend(); it != end; ++it) {
- const AbstractMetaFunction* func = metaClass->findFunction(it.key());
+ const AbstractMetaFunction *func = metaClass->findFunction(it.key());
if (!func)
continue;
injectedCode = true;
@@ -4061,7 +4059,7 @@ void CppGenerator::writeSequenceMethods(QTextStream &s,
writeCppSelfDefinition(s, func, context);
- const AbstractMetaArgument* lastArg = func->arguments().isEmpty() ? 0 : func->arguments().constLast();
+ const AbstractMetaArgument *lastArg = func->arguments().isEmpty() ? 0 : func->arguments().constLast();
writeCodeSnips(s, snips,TypeSystem::CodeSnipPositionAny, TypeSystem::TargetLangCode, func, lastArg);
s << '}' << endl << endl;
}
@@ -4070,13 +4068,13 @@ void CppGenerator::writeSequenceMethods(QTextStream &s,
writeStdListWrapperMethods(s, context);
}
-void CppGenerator::writeTypeAsSequenceDefinition(QTextStream& s, const AbstractMetaClass* metaClass)
+void CppGenerator::writeTypeAsSequenceDefinition(QTextStream &s, const AbstractMetaClass *metaClass)
{
bool hasFunctions = false;
QMap<QString, QString> funcs;
- for (ProtocolIt it = m_sequenceProtocol.cbegin(), end = m_sequenceProtocol.cend(); it != end; ++it) {
+ for (auto it = m_sequenceProtocol.cbegin(), end = m_sequenceProtocol.cend(); it != end; ++it) {
const QString &funcName = it.key();
- const AbstractMetaFunction* func = metaClass->findFunction(funcName);
+ const AbstractMetaFunction *func = metaClass->findFunction(funcName);
funcs[funcName] = func ? cpythonFunctionName(func).prepend(QLatin1Char('&')) : QString();
if (!hasFunctions && func)
hasFunctions = true;
@@ -4092,7 +4090,7 @@ void CppGenerator::writeTypeAsSequenceDefinition(QTextStream& s, const AbstractM
}
for (QHash<QString, QString>::const_iterator it = m_sqFuncs.cbegin(), end = m_sqFuncs.cend(); it != end; ++it) {
- const QString& sqName = it.key();
+ const QString &sqName = it.key();
if (funcs[sqName].isEmpty())
continue;
if (it.value() == QLatin1String("sq_slice"))
@@ -4103,13 +4101,13 @@ void CppGenerator::writeTypeAsSequenceDefinition(QTextStream& s, const AbstractM
}
}
-void CppGenerator::writeTypeAsMappingDefinition(QTextStream& s, const AbstractMetaClass* metaClass)
+void CppGenerator::writeTypeAsMappingDefinition(QTextStream &s, const AbstractMetaClass *metaClass)
{
bool hasFunctions = false;
QMap<QString, QString> funcs;
- for (ProtocolIt it = m_mappingProtocol.cbegin(), end = m_mappingProtocol.cend(); it != end; ++it) {
+ for (auto it = m_mappingProtocol.cbegin(), end = m_mappingProtocol.cend(); it != end; ++it) {
const QString &funcName = it.key();
- const AbstractMetaFunction* func = metaClass->findFunction(funcName);
+ const AbstractMetaFunction *func = metaClass->findFunction(funcName);
funcs[funcName] = func ? cpythonFunctionName(func).prepend(QLatin1Char('&')) : QLatin1String("0");
if (!hasFunctions && func)
hasFunctions = true;
@@ -4130,7 +4128,7 @@ void CppGenerator::writeTypeAsMappingDefinition(QTextStream& s, const AbstractMe
}
}
-void CppGenerator::writeTypeAsNumberDefinition(QTextStream& s, const AbstractMetaClass* metaClass)
+void CppGenerator::writeTypeAsNumberDefinition(QTextStream &s, const AbstractMetaClass *metaClass)
{
QMap<QString, QString> nb;
@@ -4165,7 +4163,7 @@ void CppGenerator::writeTypeAsNumberDefinition(QTextStream& s, const AbstractMet
| AbstractMetaClass::BitwiseOp);
for (const AbstractMetaFunctionList &opOverload : opOverloads) {
- const AbstractMetaFunction* rfunc = opOverload[0];
+ const AbstractMetaFunction *rfunc = opOverload.at(0);
QString opName = ShibokenGenerator::pythonOperatorFunctionName(rfunc);
nb[opName] = cpythonFunctionName(rfunc);
}
@@ -4208,21 +4206,21 @@ void CppGenerator::writeTypeAsNumberDefinition(QTextStream& s, const AbstractMet
}
}
-void CppGenerator::writeTpTraverseFunction(QTextStream& s, const AbstractMetaClass* metaClass)
+void CppGenerator::writeTpTraverseFunction(QTextStream &s, const AbstractMetaClass *metaClass)
{
QString baseName = cpythonBaseName(metaClass);
s << "static int ";
- s << baseName << "_traverse(PyObject* self, visitproc visit, void* arg)" << endl;
+ s << baseName << "_traverse(PyObject *self, visitproc visit, void *arg)" << endl;
s << '{' << endl;
s << INDENT << "return reinterpret_cast<PyTypeObject *>(SbkObject_TypeF())->tp_traverse(self, visit, arg);" << endl;
s << '}' << endl;
}
-void CppGenerator::writeTpClearFunction(QTextStream& s, const AbstractMetaClass* metaClass)
+void CppGenerator::writeTpClearFunction(QTextStream &s, const AbstractMetaClass *metaClass)
{
QString baseName = cpythonBaseName(metaClass);
s << "static int ";
- s << baseName << "_clear(PyObject* self)" << endl;
+ s << baseName << "_clear(PyObject *self)" << endl;
s << '{' << endl;
s << INDENT << "return reinterpret_cast<PyTypeObject *>(SbkObject_TypeF())->tp_clear(self);" << endl;
s << '}' << endl;
@@ -4232,7 +4230,7 @@ void CppGenerator::writeCopyFunction(QTextStream &s, GeneratorContext &context)
{
const AbstractMetaClass *metaClass = context.metaClass();
const QString className = chopType(cpythonTypeName(metaClass));
- s << "static PyObject* " << className << "___copy__(PyObject* self)" << endl;
+ s << "static PyObject *" << className << "___copy__(PyObject *self)" << endl;
s << "{" << endl;
writeCppSelfDefinition(s, context, false, true);
QString conversionCode;
@@ -4241,7 +4239,7 @@ void CppGenerator::writeCopyFunction(QTextStream &s, GeneratorContext &context)
else
conversionCode = cpythonToPythonConversionFunction(context.preciseType());
- s << INDENT << "PyObject* " << PYTHON_RETURN_VAR << " = " << conversionCode;
+ s << INDENT << "PyObject *" << PYTHON_RETURN_VAR << " = " << conversionCode;
s << CPP_SELF_VAR << ");" << endl;
writeFunctionReturnErrorCheckSection(s);
s << INDENT << "return " << PYTHON_RETURN_VAR << ";" << endl;
@@ -4254,19 +4252,19 @@ void CppGenerator::writeGetterFunction(QTextStream &s,
GeneratorContext &context)
{
ErrorCode errorCode(QString::fromLatin1(NULL_PTR));
- s << "static PyObject* " << cpythonGetterFunctionName(metaField) << "(PyObject* self, void*)" << endl;
+ s << "static PyObject *" << cpythonGetterFunctionName(metaField) << "(PyObject *self, void *)" << endl;
s << '{' << endl;
writeCppSelfDefinition(s, context);
- AbstractMetaType* fieldType = metaField->type();
+ AbstractMetaType *fieldType = metaField->type();
// Force use of pointer to return internal variable memory
bool newWrapperSameObject = !fieldType->isConstant() && isWrapperType(fieldType) && !isPointer(fieldType);
QString cppField;
if (avoidProtectedHack() && metaField->isProtected()) {
QTextStream(&cppField) << "static_cast<"
- << wrapperName(metaField->enclosingClass()) << "*>("
+ << wrapperName(metaField->enclosingClass()) << " *>("
<< CPP_SELF_VAR << ")->" << protectedFieldGetterName(metaField) << "()";
} else {
cppField = QLatin1String(CPP_SELF_VAR) + QLatin1String("->") + metaField->name();
@@ -4281,16 +4279,16 @@ void CppGenerator::writeGetterFunction(QTextStream &s,
} else if (avoidProtectedHack() && metaField->isProtected()) {
s << INDENT << getFullTypeNameWithoutModifiers(fieldType);
if (fieldType->isContainer() || fieldType->isFlags() || fieldType->isSmartPointer()) {
- s << '&';
+ s << " &";
cppField.prepend(QLatin1Char('*'));
} else if ((!fieldType->isConstant() && !fieldType->isEnum() && !fieldType->isPrimitive()) || fieldType->indirections() == 1) {
- s << '*';
+ s << " *";
}
s << " fieldValue = " << cppField << ';' << endl;
cppField = QLatin1String("fieldValue");
}
- s << INDENT << "PyObject* pyOut = {};\n";
+ s << INDENT << "PyObject *pyOut = {};\n";
if (newWrapperSameObject) {
// Special case colocated field with same address (first field in a struct)
s << INDENT << "if (reinterpret_cast<void *>("
@@ -4310,7 +4308,7 @@ void CppGenerator::writeGetterFunction(QTextStream &s,
s << INDENT << "else if (Shiboken::BindingManager::instance().hasWrapper(" << cppField << ")) {" << "\n";
{
Indentation indent(INDENT);
- s << INDENT << "pyOut = reinterpret_cast<PyObject*>(Shiboken::BindingManager::instance().retrieveWrapper("
+ s << INDENT << "pyOut = reinterpret_cast<PyObject *>(Shiboken::BindingManager::instance().retrieveWrapper("
<< cppField << "));" << "\n";
s << INDENT << "Py_IncRef(pyOut);" << "\n";
s << INDENT << "return pyOut;" << "\n";
@@ -4336,7 +4334,7 @@ void CppGenerator::writeSetterFunction(QTextStream &s,
GeneratorContext &context)
{
ErrorCode errorCode(0);
- s << "static int " << cpythonSetterFunctionName(metaField) << "(PyObject* self, PyObject* pyIn, void*)" << endl;
+ s << "static int " << cpythonSetterFunctionName(metaField) << "(PyObject *self, PyObject *pyIn, void *)" << endl;
s << '{' << endl;
writeCppSelfDefinition(s, context);
@@ -4350,7 +4348,7 @@ void CppGenerator::writeSetterFunction(QTextStream &s,
}
s << INDENT << '}' << endl;
- AbstractMetaType* fieldType = metaField->type();
+ AbstractMetaType *fieldType = metaField->type();
s << INDENT << "PythonToCppFunc " << PYTHON_TO_CPP_VAR << "{nullptr};" << endl;
s << INDENT << "if (!";
@@ -4368,10 +4366,10 @@ void CppGenerator::writeSetterFunction(QTextStream &s,
s << INDENT;
if (avoidProtectedHack() && metaField->isProtected()) {
s << getFullTypeNameWithoutModifiers(fieldType);
- s << (fieldType->indirections() == 1 ? "*" : "") << " cppOut;" << endl;
+ s << (fieldType->indirections() == 1 ? " *" : "") << " cppOut;" << endl;
s << INDENT << PYTHON_TO_CPP_VAR << "(pyIn, &cppOut);" << endl;
s << INDENT << "static_cast<" << wrapperName(metaField->enclosingClass())
- << "*>(" << CPP_SELF_VAR << ")->" << protectedFieldSetterName(metaField)
+ << " *>(" << CPP_SELF_VAR << ")->" << protectedFieldSetterName(metaField)
<< "(cppOut)";
} else if (isCppIntegralPrimitive(fieldType) || fieldType->typeEntry()->isEnum() || fieldType->typeEntry()->isFlags()) {
s << getFullTypeNameWithoutModifiers(fieldType) << " cppOut_local = " << cppField << ';' << endl;
@@ -4381,14 +4379,14 @@ void CppGenerator::writeSetterFunction(QTextStream &s,
if (isPointerToConst(fieldType))
s << "const ";
s << getFullTypeNameWithoutModifiers(fieldType);
- s << QString::fromLatin1("*").repeated(fieldType->indirections()) << "& cppOut_ptr = ";
+ s << QString::fromLatin1(" *").repeated(fieldType->indirections()) << "& cppOut_ptr = ";
s << cppField << ';' << endl;
s << INDENT << PYTHON_TO_CPP_VAR << "(pyIn, &cppOut_ptr)";
}
s << ';' << endl << endl;
if (isPointerToWrapperType(fieldType)) {
- s << INDENT << "Shiboken::Object::keepReference(reinterpret_cast<SbkObject*>(self), \"";
+ s << INDENT << "Shiboken::Object::keepReference(reinterpret_cast<SbkObject *>(self), \"";
s << metaField->name() << "\", pyIn);" << endl;
}
@@ -4400,12 +4398,12 @@ void CppGenerator::writeRichCompareFunction(QTextStream &s, GeneratorContext &co
{
const AbstractMetaClass *metaClass = context.metaClass();
QString baseName = cpythonBaseName(metaClass);
- s << "static PyObject* ";
- s << baseName << "_richcompare(PyObject* self, PyObject* " << PYTHON_ARG << ", int op)" << endl;
+ s << "static PyObject * ";
+ s << baseName << "_richcompare(PyObject *self, PyObject *" << PYTHON_ARG << ", int op)" << endl;
s << '{' << endl;
writeCppSelfDefinition(s, context, false, true);
writeUnusedVariableCast(s, QLatin1String(CPP_SELF_VAR));
- s << INDENT << "PyObject* " << PYTHON_RETURN_VAR << "{};" << endl;
+ s << INDENT << "PyObject *" << PYTHON_RETURN_VAR << "{};" << endl;
s << INDENT << "PythonToCppFunc " << PYTHON_TO_CPP_VAR << ';' << endl;
writeUnusedVariableCast(s, QLatin1String(PYTHON_TO_CPP_VAR));
s << endl;
@@ -4415,7 +4413,7 @@ void CppGenerator::writeRichCompareFunction(QTextStream &s, GeneratorContext &co
Indentation indent(INDENT);
const QVector<AbstractMetaFunctionList> &groupedFuncs = filterGroupedOperatorFunctions(metaClass, AbstractMetaClass::ComparisonOp);
for (const AbstractMetaFunctionList &overloads : groupedFuncs) {
- const AbstractMetaFunction* rfunc = overloads[0];
+ const AbstractMetaFunction *rfunc = overloads[0];
QString operatorId = ShibokenGenerator::pythonRichCompareOperatorId(rfunc);
s << INDENT << "case " << operatorId << ':' << endl;
@@ -4436,10 +4434,10 @@ void CppGenerator::writeRichCompareFunction(QTextStream &s, GeneratorContext &co
OverloadData overloadData(overloads, this);
const OverloadDataList &nextOverloads = overloadData.nextOverloadData();
for (OverloadData *od : nextOverloads) {
- const AbstractMetaFunction* func = od->referenceFunction();
+ const AbstractMetaFunction *func = od->referenceFunction();
if (func->isStatic())
continue;
- const AbstractMetaType* argType = getArgumentType(func, 1);
+ const AbstractMetaType *argType = getArgumentType(func, 1);
if (!argType)
continue;
if (!first) {
@@ -4517,12 +4515,12 @@ void CppGenerator::writeRichCompareFunction(QTextStream &s, GeneratorContext &co
s << '}' << endl << endl;
}
-void CppGenerator::writeMethodDefinitionEntry(QTextStream& s, const AbstractMetaFunctionList &overloads)
+void CppGenerator::writeMethodDefinitionEntry(QTextStream &s, const AbstractMetaFunctionList &overloads)
{
Q_ASSERT(!overloads.isEmpty());
OverloadData overloadData(overloads, this);
bool usePyArgs = pythonFunctionWrapperUsesListOfArguments(overloadData);
- const AbstractMetaFunction* func = overloadData.referenceFunction();
+ const AbstractMetaFunction *func = overloadData.referenceFunction();
int min = overloadData.minArgs();
int max = overloadData.maxArgs();
@@ -4542,10 +4540,10 @@ void CppGenerator::writeMethodDefinitionEntry(QTextStream& s, const AbstractMeta
s << "|METH_STATIC";
}
-void CppGenerator::writeMethodDefinition(QTextStream& s, const AbstractMetaFunctionList &overloads)
+void CppGenerator::writeMethodDefinition(QTextStream &s, const AbstractMetaFunctionList &overloads)
{
Q_ASSERT(!overloads.isEmpty());
- const AbstractMetaFunction* func = overloads.constFirst();
+ const AbstractMetaFunction *func = overloads.constFirst();
if (m_tpFuncs.contains(func->name()))
return;
@@ -4566,7 +4564,7 @@ static QString resolveRetOrArgType(const AbstractMetaType *someType)
if (CppGenerator::isCString(someType)) {
strRetArg = QLatin1String("str");
} else if (someType->isPrimitive()) {
- const PrimitiveTypeEntry* ptp = static_cast<const PrimitiveTypeEntry*>(someType->typeEntry());
+ auto ptp = static_cast<const PrimitiveTypeEntry *>(someType->typeEntry());
while (ptp->referencedTypeEntry())
ptp = ptp->referencedTypeEntry();
strRetArg = ptp->name();
@@ -4580,7 +4578,7 @@ static QString resolveRetOrArgType(const AbstractMetaType *someType)
void CppGenerator::writeSignatureInfo(QTextStream &s, const AbstractMetaFunctionList &overloads)
{
OverloadData overloadData(overloads, this);
- const AbstractMetaFunction* rfunc = overloadData.referenceFunction();
+ const AbstractMetaFunction *rfunc = overloadData.referenceFunction();
QString funcName = fullPythonFunctionName(rfunc);
int idx = overloads.length() - 1;
@@ -4619,7 +4617,7 @@ void CppGenerator::writeSignatureInfo(QTextStream &s, const AbstractMetaFunction
}
}
-void CppGenerator::writeEnumsInitialization(QTextStream& s, AbstractMetaEnumList& enums)
+void CppGenerator::writeEnumsInitialization(QTextStream &s, AbstractMetaEnumList &enums)
{
if (enums.isEmpty())
return;
@@ -4631,10 +4629,10 @@ void CppGenerator::writeEnumsInitialization(QTextStream& s, AbstractMetaEnumList
}
}
-void CppGenerator::writeEnumInitialization(QTextStream& s, const AbstractMetaEnum* cppEnum)
+void CppGenerator::writeEnumInitialization(QTextStream &s, const AbstractMetaEnum *cppEnum)
{
- const AbstractMetaClass* enclosingClass = getProperEnclosingClassForEnum(cppEnum);
- const AbstractMetaClass* upper = enclosingClass ? enclosingClass->enclosingClass() : 0;
+ const AbstractMetaClass *enclosingClass = getProperEnclosingClassForEnum(cppEnum);
+ const AbstractMetaClass *upper = enclosingClass ? enclosingClass->enclosingClass() : nullptr;
bool hasUpperEnclosingClass = upper && upper->typeEntry()->codeGeneration() != TypeEntry::GenerateForSubclass;
const EnumTypeEntry *enumTypeEntry = cppEnum->typeEntry();
QString enclosingObjectVariable;
@@ -4651,7 +4649,7 @@ void CppGenerator::writeEnumInitialization(QTextStream& s, const AbstractMetaEnu
QString enumVarTypeObj;
if (!cppEnum->isAnonymous()) {
- FlagsTypeEntry* flags = enumTypeEntry->flags();
+ FlagsTypeEntry *flags = enumTypeEntry->flags();
if (flags) {
// The following could probably be made nicer:
// We need 'flags->flagsName()' with the full module/class path.
@@ -4708,7 +4706,7 @@ void CppGenerator::writeEnumInitialization(QTextStream& s, const AbstractMetaEnu
s << INDENT << '{' << endl;
{
Indentation indent(INDENT);
- s << INDENT << "PyObject* anonEnumItem = PyInt_FromLong(" << enumValueText << ");" << endl;
+ s << INDENT << "PyObject *anonEnumItem = PyInt_FromLong(" << enumValueText << ");" << endl;
s << INDENT << "if (PyDict_SetItemString(reinterpret_cast<PyTypeObject *>(reinterpret_cast<SbkObjectType *>(" << enclosingObjectVariable
<< "))->tp_dict, \"" << enumValue->name() << "\", anonEnumItem) < 0)" << endl;
{
@@ -4757,7 +4755,7 @@ void CppGenerator::writeEnumInitialization(QTextStream& s, const AbstractMetaEnu
s << '.' << endl << endl;
}
-void CppGenerator::writeSignalInitialization(QTextStream& s, const AbstractMetaClass* metaClass)
+void CppGenerator::writeSignalInitialization(QTextStream &s, const AbstractMetaClass *metaClass)
{
// Try to check something and print some warnings
const AbstractMetaFunctionList &signalFuncs = metaClass->cppSignalFunctions();
@@ -4766,7 +4764,7 @@ void CppGenerator::writeSignalInitialization(QTextStream& s, const AbstractMetaC
continue;
const AbstractMetaArgumentList &arguments = cppSignal->arguments();
for (AbstractMetaArgument *arg : arguments) {
- AbstractMetaType* metaType = arg->type();
+ AbstractMetaType *metaType = arg->type();
const QByteArray origType =
QMetaObject::normalizedType(qPrintable(metaType->originalTypeDescription()));
const QByteArray cppSig =
@@ -4783,36 +4781,36 @@ void CppGenerator::writeSignalInitialization(QTextStream& s, const AbstractMetaC
<< metaClass->qualifiedCppName() << "::staticMetaObject);" << endl;
}
-void CppGenerator::writeFlagsToLong(QTextStream& s, const AbstractMetaEnum* cppEnum)
+void CppGenerator::writeFlagsToLong(QTextStream &s, const AbstractMetaEnum *cppEnum)
{
- FlagsTypeEntry* flagsEntry = cppEnum->typeEntry()->flags();
+ FlagsTypeEntry *flagsEntry = cppEnum->typeEntry()->flags();
if (!flagsEntry)
return;
- s << "static PyObject* " << cpythonEnumName(cppEnum) << "_long(PyObject* self)" << endl;
+ s << "static PyObject *" << cpythonEnumName(cppEnum) << "_long(PyObject *self)" << endl;
s << "{" << endl;
s << INDENT << "int val;" << endl;
- AbstractMetaType* flagsType = buildAbstractMetaTypeFromTypeEntry(flagsEntry);
+ AbstractMetaType *flagsType = buildAbstractMetaTypeFromTypeEntry(flagsEntry);
s << INDENT << cpythonToCppConversionFunction(flagsType) << "self, &val);" << endl;
s << INDENT << "return Shiboken::Conversions::copyToPython(Shiboken::Conversions::PrimitiveTypeConverter<int>(), &val);" << endl;
s << "}" << endl;
}
-void CppGenerator::writeFlagsNonZero(QTextStream& s, const AbstractMetaEnum* cppEnum)
+void CppGenerator::writeFlagsNonZero(QTextStream &s, const AbstractMetaEnum *cppEnum)
{
- FlagsTypeEntry* flagsEntry = cppEnum->typeEntry()->flags();
+ FlagsTypeEntry *flagsEntry = cppEnum->typeEntry()->flags();
if (!flagsEntry)
return;
- s << "static int " << cpythonEnumName(cppEnum) << "__nonzero(PyObject* self)" << endl;
+ s << "static int " << cpythonEnumName(cppEnum) << "__nonzero(PyObject *self)" << endl;
s << "{" << endl;
s << INDENT << "int val;" << endl;
- AbstractMetaType* flagsType = buildAbstractMetaTypeFromTypeEntry(flagsEntry);
+ AbstractMetaType *flagsType = buildAbstractMetaTypeFromTypeEntry(flagsEntry);
s << INDENT << cpythonToCppConversionFunction(flagsType) << "self, &val);" << endl;
s << INDENT << "return val != 0;" << endl;
s << "}" << endl;
}
-void CppGenerator::writeFlagsMethods(QTextStream& s, const AbstractMetaEnum* cppEnum)
+void CppGenerator::writeFlagsMethods(QTextStream &s, const AbstractMetaEnum *cppEnum)
{
writeFlagsBinaryOperator(s, cppEnum, QLatin1String("and"), QLatin1String("&"));
writeFlagsBinaryOperator(s, cppEnum, QLatin1String("or"), QLatin1String("|"));
@@ -4825,7 +4823,7 @@ void CppGenerator::writeFlagsMethods(QTextStream& s, const AbstractMetaEnum* cpp
s << endl;
}
-void CppGenerator::writeFlagsNumberMethodsDefinition(QTextStream& s, const AbstractMetaEnum* cppEnum)
+void CppGenerator::writeFlagsNumberMethodsDefinition(QTextStream &s, const AbstractMetaEnum *cppEnum)
{
QString cpythonName = cpythonEnumName(cppEnum);
@@ -4848,16 +4846,16 @@ void CppGenerator::writeFlagsNumberMethodsDefinition(QTextStream& s, const Abstr
s << "};" << endl << endl;
}
-void CppGenerator::writeFlagsBinaryOperator(QTextStream& s, const AbstractMetaEnum* cppEnum,
+void CppGenerator::writeFlagsBinaryOperator(QTextStream &s, const AbstractMetaEnum *cppEnum,
const QString &pyOpName, const QString &cppOpName)
{
- FlagsTypeEntry* flagsEntry = cppEnum->typeEntry()->flags();
+ FlagsTypeEntry *flagsEntry = cppEnum->typeEntry()->flags();
Q_ASSERT(flagsEntry);
- s << "PyObject* " << cpythonEnumName(cppEnum) << "___" << pyOpName << "__(PyObject* self, PyObject* " << PYTHON_ARG << ")" << endl;
+ s << "PyObject * " << cpythonEnumName(cppEnum) << "___" << pyOpName << "__(PyObject *self, PyObject *" << PYTHON_ARG << ")" << endl;
s << '{' << endl;
- AbstractMetaType* flagsType = buildAbstractMetaTypeFromTypeEntry(flagsEntry);
+ AbstractMetaType *flagsType = buildAbstractMetaTypeFromTypeEntry(flagsEntry);
s << INDENT << "::" << flagsEntry->originalName() << " cppResult, " << CPP_SELF_VAR << ", cppArg;" << endl;
s << "#ifdef IS_PY3K" << endl;
s << INDENT << CPP_SELF_VAR << " = static_cast<::" << flagsEntry->originalName()
@@ -4872,22 +4870,22 @@ void CppGenerator::writeFlagsBinaryOperator(QTextStream& s, const AbstractMetaEn
s << "#endif" << endl << endl;
s << INDENT << "cppResult = " << CPP_SELF_VAR << " " << cppOpName << " cppArg;" << endl;
s << INDENT << "return ";
- writeToPythonConversion(s, flagsType, 0, QLatin1String("cppResult"));
+ writeToPythonConversion(s, flagsType, nullptr, QLatin1String("cppResult"));
s << ';' << endl;
s << '}' << endl << endl;
}
-void CppGenerator::writeFlagsUnaryOperator(QTextStream& s, const AbstractMetaEnum* cppEnum,
+void CppGenerator::writeFlagsUnaryOperator(QTextStream &s, const AbstractMetaEnum *cppEnum,
const QString &pyOpName,
const QString &cppOpName, bool boolResult)
{
- FlagsTypeEntry* flagsEntry = cppEnum->typeEntry()->flags();
+ FlagsTypeEntry *flagsEntry = cppEnum->typeEntry()->flags();
Q_ASSERT(flagsEntry);
- s << "PyObject* " << cpythonEnumName(cppEnum) << "___" << pyOpName << "__(PyObject* self, PyObject* " << PYTHON_ARG << ")" << endl;
+ s << "PyObject *" << cpythonEnumName(cppEnum) << "___" << pyOpName << "__(PyObject *self, PyObject *" << PYTHON_ARG << ")" << endl;
s << '{' << endl;
- AbstractMetaType* flagsType = buildAbstractMetaTypeFromTypeEntry(flagsEntry);
+ AbstractMetaType *flagsType = buildAbstractMetaTypeFromTypeEntry(flagsEntry);
s << INDENT << "::" << flagsEntry->originalName() << " " << CPP_SELF_VAR << ";" << endl;
s << INDENT << cpythonToCppConversionFunction(flagsType) << "self, &" << CPP_SELF_VAR << ");" << endl;
s << INDENT;
@@ -4900,7 +4898,7 @@ void CppGenerator::writeFlagsUnaryOperator(QTextStream& s, const AbstractMetaEnu
if (boolResult)
s << "PyBool_FromLong(cppResult)";
else
- writeToPythonConversion(s, flagsType, 0, QLatin1String("cppResult"));
+ writeToPythonConversion(s, flagsType, nullptr, QLatin1String("cppResult"));
s << ';' << endl;
s << '}' << endl << endl;
}
@@ -4928,9 +4926,9 @@ void CppGenerator::writeClassRegister(QTextStream &s,
GeneratorContext &classContext,
QTextStream &signatureStream)
{
- const ComplexTypeEntry* classTypeEntry = metaClass->typeEntry();
+ const ComplexTypeEntry *classTypeEntry = metaClass->typeEntry();
- const AbstractMetaClass* enc = metaClass->enclosingClass();
+ const AbstractMetaClass *enc = metaClass->enclosingClass();
bool hasEnclosingClass = enc && enc->typeEntry()->codeGeneration() != TypeEntry::GenerateForSubclass;
QString enclosingObjectVariable = hasEnclosingClass ? QLatin1String("enclosingClass") : QLatin1String("module");
@@ -4946,20 +4944,20 @@ void CppGenerator::writeClassRegister(QTextStream &s,
s << INDENT << '"' << line << "\"," << endl;
s << INDENT << NULL_PTR << "}; // Sentinel" << endl << endl;
s << "void init_" << initFunctionName;
- s << "(PyObject* " << enclosingObjectVariable << ")" << endl;
+ s << "(PyObject *" << enclosingObjectVariable << ")" << endl;
s << '{' << endl;
// Multiple inheritance
QString pyTypeBasesVariable = chopType(pyTypeName) + QLatin1String("_Type_bases");
const AbstractMetaClassList baseClasses = getBaseClasses(metaClass);
if (metaClass->baseClassNames().size() > 1) {
- s << INDENT << "PyObject* " << pyTypeBasesVariable
+ s << INDENT << "PyObject *" << pyTypeBasesVariable
<< " = PyTuple_Pack(" << baseClasses.size() << ',' << endl;
Indentation indent(INDENT);
for (int i = 0, size = baseClasses.size(); i < size; ++i) {
if (i)
s << "," << endl;
- s << INDENT << "reinterpret_cast<PyObject*>("
+ s << INDENT << "reinterpret_cast<PyObject *>("
<< cpythonTypeNameExt(baseClasses.at(i)->typeEntry()) << ')';
}
s << ");" << endl << endl;
@@ -5048,7 +5046,7 @@ void CppGenerator::writeClassRegister(QTextStream &s,
s << INDENT << cpythonTypeNameExt(classTypeEntry) << endl;
else
s << INDENT << cpythonTypeNameExt(classContext.preciseType()) << endl;
- s << INDENT << " = reinterpret_cast<PyTypeObject*>(" << pyTypeName << ");" << endl;
+ s << INDENT << " = reinterpret_cast<PyTypeObject *>(" << pyTypeName << ");" << endl;
s << endl;
// Register conversions for the type.
@@ -5062,13 +5060,13 @@ void CppGenerator::writeClassRegister(QTextStream &s,
}
// Fill multiple inheritance data, if needed.
- const AbstractMetaClass* miClass = getMultipleInheritingClass(metaClass);
+ const AbstractMetaClass *miClass = getMultipleInheritingClass(metaClass);
if (miClass) {
s << INDENT << "MultipleInheritanceInitFunction func = ";
if (miClass == metaClass) {
s << multipleInheritanceInitializerFunctionName(miClass) << ";" << endl;
} else {
- s << "Shiboken::ObjectType::getMultipleInheritanceFunction(reinterpret_cast<SbkObjectType*>(";
+ s << "Shiboken::ObjectType::getMultipleInheritanceFunction(reinterpret_cast<SbkObjectType *>(";
s << cpythonTypeNameExt(miClass->typeEntry()) << "));" << endl;
}
s << INDENT << "Shiboken::ObjectType::setMultipleInheritanceFunction(";
@@ -5130,7 +5128,7 @@ void CppGenerator::writeClassRegister(QTextStream &s,
void CppGenerator::writeInitQtMetaTypeFunctionBody(QTextStream &s, GeneratorContext &context) const
{
- const AbstractMetaClass* metaClass = context.metaClass();
+ const AbstractMetaClass *metaClass = context.metaClass();
// Gets all class name variants used on different possible scopes
QStringList nameVariants;
if (!context.forSmartPointer())
@@ -5138,7 +5136,7 @@ void CppGenerator::writeInitQtMetaTypeFunctionBody(QTextStream &s, GeneratorCont
else
nameVariants << context.preciseType()->cppSignature();
- const AbstractMetaClass* enclosingClass = metaClass->enclosingClass();
+ const AbstractMetaClass *enclosingClass = metaClass->enclosingClass();
while (enclosingClass) {
if (enclosingClass->typeEntry()->generateCode())
nameVariants << (enclosingClass->name() + QLatin1String("::") + nameVariants.constLast());
@@ -5194,17 +5192,17 @@ void CppGenerator::writeInitQtMetaTypeFunctionBody(QTextStream &s, GeneratorCont
}
}
-void CppGenerator::writeTypeDiscoveryFunction(QTextStream& s, const AbstractMetaClass* metaClass)
+void CppGenerator::writeTypeDiscoveryFunction(QTextStream &s, const AbstractMetaClass *metaClass)
{
QString polymorphicExpr = metaClass->typeEntry()->polymorphicIdValue();
- s << "static void* " << cpythonBaseName(metaClass) << "_typeDiscovery(void* cptr, SbkObjectType* instanceType)\n{" << endl;
+ s << "static void *" << cpythonBaseName(metaClass) << "_typeDiscovery(void *cptr, SbkObjectType *instanceType)\n{" << endl;
if (!polymorphicExpr.isEmpty()) {
polymorphicExpr = polymorphicExpr.replace(QLatin1String("%1"),
QLatin1String(" reinterpret_cast< ::")
+ metaClass->qualifiedCppName()
- + QLatin1String("*>(cptr)"));
+ + QLatin1String(" *>(cptr)"));
s << INDENT << " if (" << polymorphicExpr << ")" << endl;
{
Indentation indent(INDENT);
@@ -5216,11 +5214,11 @@ void CppGenerator::writeTypeDiscoveryFunction(QTextStream& s, const AbstractMeta
if (ancestor->baseClass())
continue;
if (ancestor->isPolymorphic()) {
- s << INDENT << "if (instanceType == reinterpret_cast<SbkObjectType*>(Shiboken::SbkType< ::"
+ s << INDENT << "if (instanceType == reinterpret_cast<SbkObjectType *>(Shiboken::SbkType< ::"
<< ancestor->qualifiedCppName() << " >()))" << endl;
Indentation indent(INDENT);
s << INDENT << "return dynamic_cast< ::" << metaClass->qualifiedCppName()
- << "*>(reinterpret_cast< ::"<< ancestor->qualifiedCppName() << "*>(cptr));" << endl;
+ << " *>(reinterpret_cast< ::"<< ancestor->qualifiedCppName() << " *>(cptr));" << endl;
} else {
qCWarning(lcShiboken).noquote().nospace()
<< metaClass->qualifiedCppName() << " inherits from a non polymorphic type ("
@@ -5242,14 +5240,14 @@ QString CppGenerator::writeSmartPointerGetterCast()
void CppGenerator::writeSetattroFunction(QTextStream &s, GeneratorContext &context)
{
- const AbstractMetaClass* metaClass = context.metaClass();
- s << "static int " << cpythonSetattroFunctionName(metaClass) << "(PyObject* self, PyObject* name, PyObject* value)" << endl;
+ const AbstractMetaClass *metaClass = context.metaClass();
+ s << "static int " << cpythonSetattroFunctionName(metaClass) << "(PyObject *self, PyObject *name, PyObject *value)" << endl;
s << '{' << endl;
if (usePySideExtensions()) {
- s << INDENT << "Shiboken::AutoDecRef pp(reinterpret_cast<PyObject*>(PySide::Property::getObject(self, name)));" << endl;
+ s << INDENT << "Shiboken::AutoDecRef pp(reinterpret_cast<PyObject *>(PySide::Property::getObject(self, name)));" << endl;
s << INDENT << "if (!pp.isNull())" << endl;
Indentation indent(INDENT);
- s << INDENT << "return PySide::Property::setValue(reinterpret_cast<PySideProperty*>(pp.object()), self, value);" << endl;
+ s << INDENT << "return PySide::Property::setValue(reinterpret_cast<PySideProperty *>(pp.object()), self, value);" << endl;
}
if (context.forSmartPointer()) {
@@ -5279,10 +5277,10 @@ void CppGenerator::writeSetattroFunction(QTextStream &s, GeneratorContext &conte
static inline QString qObjectClassName() { return QStringLiteral("QObject"); }
static inline QString qMetaObjectClassName() { return QStringLiteral("QMetaObject"); }
-void CppGenerator::writeGetattroFunction(QTextStream& s, GeneratorContext &context)
+void CppGenerator::writeGetattroFunction(QTextStream &s, GeneratorContext &context)
{
- const AbstractMetaClass* metaClass = context.metaClass();
- s << "static PyObject* " << cpythonGetattroFunctionName(metaClass) << "(PyObject* self, PyObject* name)" << endl;
+ const AbstractMetaClass *metaClass = context.metaClass();
+ s << "static PyObject *" << cpythonGetattroFunctionName(metaClass) << "(PyObject *self, PyObject *name)" << endl;
s << '{' << endl;
QString getattrFunc;
@@ -5301,10 +5299,10 @@ void CppGenerator::writeGetattroFunction(QTextStream& s, GeneratorContext &conte
{
Indentation indent(INDENT);
s << INDENT << "// Search the method in the instance dict" << endl;
- s << INDENT << "if (reinterpret_cast<SbkObject*>(self)->ob_dict) {" << endl;
+ s << INDENT << "if (reinterpret_cast<SbkObject *>(self)->ob_dict) {" << endl;
{
Indentation indent(INDENT);
- s << INDENT << "PyObject* meth = PyDict_GetItem(reinterpret_cast<SbkObject*>(self)->ob_dict, name);" << endl;
+ s << INDENT << "PyObject *meth = PyDict_GetItem(reinterpret_cast<SbkObject *>(self)->ob_dict, name);" << endl;
s << INDENT << "if (meth) {" << endl;
{
Indentation indent(INDENT);
@@ -5463,7 +5461,7 @@ bool CppGenerator::finishGeneration()
const QString initFunctionName = QLatin1String("init_") + getSimpleClassInitFunctionName(cls);
- s_classInitDecl << "void " << initFunctionName << "(PyObject* module);" << endl;
+ s_classInitDecl << "void " << initFunctionName << "(PyObject *module);" << endl;
s_classPythonDefines << INDENT << initFunctionName;
if (cls->enclosingClass()
@@ -5479,9 +5477,9 @@ bool CppGenerator::finishGeneration()
// Initialize smart pointer types.
const QVector<const AbstractMetaType *> &smartPtrs = instantiatedSmartPointers();
for (const AbstractMetaType *metaType : smartPtrs) {
- GeneratorContext context(0, metaType, true);
+ GeneratorContext context(nullptr, metaType, true);
QString initFunctionName = getInitFunctionName(context);
- s_classInitDecl << "void init_" << initFunctionName << "(PyObject* module);" << endl;
+ s_classInitDecl << "void init_" << initFunctionName << "(PyObject *module);" << endl;
QString defineStr = QLatin1String("init_") + initFunctionName;
defineStr += QLatin1String("(module);");
s_classPythonDefines << INDENT << defineStr << endl;
@@ -5518,13 +5516,13 @@ bool CppGenerator::finishGeneration()
AbstractMetaEnumList globalEnums = this->globalEnums();
const AbstractMetaClassList &classList = classes();
for (const AbstractMetaClass *metaClass : classList) {
- const AbstractMetaClass* encClass = metaClass->enclosingClass();
+ const AbstractMetaClass *encClass = metaClass->enclosingClass();
if (encClass && encClass->typeEntry()->codeGeneration() != TypeEntry::GenerateForSubclass)
continue;
lookForEnumsInClassesNotToBeGenerated(globalEnums, metaClass);
}
- TypeDatabase* typeDb = TypeDatabase::instance();
+ TypeDatabase *typeDb = TypeDatabase::instance();
const TypeSystemTypeEntry *moduleEntry = typeDb->defaultTypeSystemType();
Q_ASSERT(moduleEntry);
@@ -5539,13 +5537,13 @@ bool CppGenerator::finishGeneration()
s << endl;
s << "// Current module's type array." << endl;
- s << "PyTypeObject** " << cppApiVariableName() << " = nullptr;" << endl;
+ s << "PyTypeObject **" << cppApiVariableName() << " = nullptr;" << endl;
s << "// Current module's PyObject pointer." << endl;
- s << "PyObject* " << pythonModuleObjectName() << " = nullptr;" << endl;
+ s << "PyObject *" << pythonModuleObjectName() << " = nullptr;" << endl;
s << "// Current module's converter array." << endl;
- s << "SbkConverter** " << convertersVariableName() << " = nullptr;" << endl;
+ s << "SbkConverter **" << convertersVariableName() << " = nullptr;" << endl;
const CodeSnipList snips = moduleEntry->codeSnips();
@@ -5563,7 +5561,7 @@ bool CppGenerator::finishGeneration()
s << INDENT << "for (int i = 0, imax = SBK_" << moduleName() << "_IDX_COUNT; i < imax; i++) {" << endl;
{
Indentation indentation(INDENT);
- s << INDENT << "PyObject *pyType = reinterpret_cast<PyObject*>(" << cppApiVariableName() << "[i]);" << endl;
+ s << INDENT << "PyObject *pyType = reinterpret_cast<PyObject *>(" << cppApiVariableName() << "[i]);" << endl;
s << INDENT << "if (pyType && PyObject_HasAttrString(pyType, \"staticMetaObject\"))"<< endl;
{
Indentation indentation(INDENT);
@@ -5612,8 +5610,8 @@ bool CppGenerator::finishGeneration()
if (!requiredModules.isEmpty())
s << "// Required modules' type and converter arrays." << endl;
for (const QString &requiredModule : requiredModules) {
- s << "PyTypeObject** " << cppApiVariableName(requiredModule) << ';' << endl;
- s << "SbkConverter** " << convertersVariableName(requiredModule) << ';' << endl;
+ s << "PyTypeObject **" << cppApiVariableName(requiredModule) << ';' << endl;
+ s << "SbkConverter **" << convertersVariableName(requiredModule) << ';' << endl;
}
s << endl;
@@ -5626,8 +5624,8 @@ bool CppGenerator::finishGeneration()
const TypeEntry *externalType = it.key();
s << "// Extended implicit conversions for " << externalType->qualifiedTargetLangName() << '.' << endl;
for (const AbstractMetaClass *sourceClass : it.value()) {
- AbstractMetaType* sourceType = buildAbstractMetaTypeFromAbstractMetaClass(sourceClass);
- AbstractMetaType* targetType = buildAbstractMetaTypeFromTypeEntry(externalType);
+ AbstractMetaType *sourceType = buildAbstractMetaTypeFromAbstractMetaClass(sourceClass);
+ AbstractMetaType *targetType = buildAbstractMetaTypeFromTypeEntry(externalType);
writePythonToCppConversionFunctions(s, sourceType, targetType);
}
}
@@ -5694,7 +5692,7 @@ bool CppGenerator::finishGeneration()
s << endl;
}
- for (const QString& requiredModule : requiredModules) {
+ for (const QString &requiredModule : requiredModules) {
s << INDENT << "{" << endl;
{
Indentation indentation(INDENT);
@@ -5713,18 +5711,18 @@ bool CppGenerator::finishGeneration()
int maxTypeIndex = getMaxTypeIndex() + instantiatedSmartPointers().size();
if (maxTypeIndex) {
s << INDENT << "// Create an array of wrapper types for the current module." << endl;
- s << INDENT << "static PyTypeObject* cppApi[SBK_" << moduleName() << "_IDX_COUNT];" << endl;
+ s << INDENT << "static PyTypeObject *cppApi[SBK_" << moduleName() << "_IDX_COUNT];" << endl;
s << INDENT << cppApiVariableName() << " = cppApi;" << endl << endl;
}
s << INDENT << "// Create an array of primitive type converters for the current module." << endl;
- s << INDENT << "static SbkConverter* sbkConverters[SBK_" << moduleName() << "_CONVERTERS_IDX_COUNT" << "];" << endl;
+ s << INDENT << "static SbkConverter *sbkConverters[SBK_" << moduleName() << "_CONVERTERS_IDX_COUNT" << "];" << endl;
s << INDENT << convertersVariableName() << " = sbkConverters;" << endl << endl;
s << "#ifdef IS_PY3K" << endl;
- s << INDENT << "PyObject* module = Shiboken::Module::create(\"" << moduleName() << "\", &moduledef);" << endl;
+ s << INDENT << "PyObject *module = Shiboken::Module::create(\"" << moduleName() << "\", &moduledef);" << endl;
s << "#else" << endl;
- s << INDENT << "PyObject* module = Shiboken::Module::create(\"" << moduleName() << "\", ";
+ s << INDENT << "PyObject *module = Shiboken::Module::create(\"" << moduleName() << "\", ";
s << moduleName() << "_methods);" << endl;
s << "#endif" << endl << endl;
@@ -5829,7 +5827,7 @@ bool CppGenerator::finishGeneration()
return file.done() != FileOut::Failure;
}
-static ArgumentOwner getArgumentOwner(const AbstractMetaFunction* func, int argIndex)
+static ArgumentOwner getArgumentOwner(const AbstractMetaFunction *func, int argIndex)
{
ArgumentOwner argOwner = func->argumentOwner(func->ownerClass(), argIndex);
if (argOwner.index == ArgumentOwner::InvalidIndex)
@@ -5837,7 +5835,7 @@ static ArgumentOwner getArgumentOwner(const AbstractMetaFunction* func, int argI
return argOwner;
}
-bool CppGenerator::writeParentChildManagement(QTextStream& s, const AbstractMetaFunction* func, int argIndex, bool useHeuristicPolicy)
+bool CppGenerator::writeParentChildManagement(QTextStream &s, const AbstractMetaFunction *func, int argIndex, bool useHeuristicPolicy)
{
const int numArgs = func->arguments().count();
bool ctorHeuristicEnabled = func->isConstructor() && useCtorHeuristic() && useHeuristicPolicy;
@@ -5852,7 +5850,7 @@ bool CppGenerator::writeParentChildManagement(QTextStream& s, const AbstractMeta
int parentIndex = argOwner.index;
int childIndex = argIndex;
if (ctorHeuristicEnabled && argIndex > 0 && numArgs) {
- AbstractMetaArgument* arg = func->arguments().at(argIndex-1);
+ AbstractMetaArgument *arg = func->arguments().at(argIndex-1);
if (arg->name() == QLatin1String("parent") && isObjectType(arg->type())) {
action = ArgumentOwner::Add;
parentIndex = argIndex;
@@ -5896,7 +5894,7 @@ bool CppGenerator::writeParentChildManagement(QTextStream& s, const AbstractMeta
return false;
}
-void CppGenerator::writeParentChildManagement(QTextStream& s, const AbstractMetaFunction* func, bool useHeuristicForReturn)
+void CppGenerator::writeParentChildManagement(QTextStream &s, const AbstractMetaFunction *func, bool useHeuristicForReturn)
{
const int numArgs = func->arguments().count();
@@ -5910,7 +5908,7 @@ void CppGenerator::writeParentChildManagement(QTextStream& s, const AbstractMeta
writeReturnValueHeuristics(s, func);
}
-void CppGenerator::writeReturnValueHeuristics(QTextStream& s, const AbstractMetaFunction* func, const QString& self)
+void CppGenerator::writeReturnValueHeuristics(QTextStream &s, const AbstractMetaFunction *func, const QString &self)
{
AbstractMetaType *type = func->type();
if (!useReturnValueHeuristic()
@@ -5932,7 +5930,7 @@ void CppGenerator::writeReturnValueHeuristics(QTextStream& s, const AbstractMeta
void CppGenerator::writeHashFunction(QTextStream &s, GeneratorContext &context)
{
const AbstractMetaClass *metaClass = context.metaClass();
- s << "static Py_hash_t " << cpythonBaseName(metaClass) << "_HashFunc(PyObject* self) {" << endl;
+ s << "static Py_hash_t " << cpythonBaseName(metaClass) << "_HashFunc(PyObject *self) {" << endl;
writeCppSelfDefinition(s, context);
s << INDENT << "return " << metaClass->typeEntry()->hashFunction() << '(';
s << (isObjectType(metaClass) ? "" : "*") << CPP_SELF_VAR << ");" << endl;
@@ -5945,14 +5943,14 @@ void CppGenerator::writeStdListWrapperMethods(QTextStream &s, GeneratorContext &
ErrorCode errorCode(0);
// __len__
- s << "Py_ssize_t " << cpythonBaseName(metaClass->typeEntry()) << "__len__(PyObject* self)" << endl;
+ s << "Py_ssize_t " << cpythonBaseName(metaClass->typeEntry()) << "__len__(PyObject *self)" << endl;
s << '{' << endl;
writeCppSelfDefinition(s, context);
s << INDENT << "return " << CPP_SELF_VAR << "->size();" << endl;
s << '}' << endl;
// __getitem__
- s << "PyObject* " << cpythonBaseName(metaClass->typeEntry()) << "__getitem__(PyObject* self, Py_ssize_t _i)" << endl;
+ s << "PyObject *" << cpythonBaseName(metaClass->typeEntry()) << "__getitem__(PyObject *self, Py_ssize_t _i)" << endl;
s << '{' << endl;
writeCppSelfDefinition(s, context);
writeIndexError(s, QLatin1String("index out of bounds"));
@@ -5960,7 +5958,7 @@ void CppGenerator::writeStdListWrapperMethods(QTextStream &s, GeneratorContext &
s << INDENT << metaClass->qualifiedCppName() << "::iterator _item = " << CPP_SELF_VAR << "->begin();" << endl;
s << INDENT << "for (Py_ssize_t pos = 0; pos < _i; pos++) _item++;" << endl;
- const AbstractMetaType* itemType = metaClass->templateBaseClassInstantiations().constFirst();
+ const AbstractMetaType *itemType = metaClass->templateBaseClassInstantiations().constFirst();
s << INDENT << "return ";
writeToPythonConversion(s, itemType, metaClass, QLatin1String("*_item"));
@@ -5969,7 +5967,7 @@ void CppGenerator::writeStdListWrapperMethods(QTextStream &s, GeneratorContext &
// __setitem__
ErrorCode errorCode2(-1);
- s << "int " << cpythonBaseName(metaClass->typeEntry()) << "__setitem__(PyObject* self, Py_ssize_t _i, PyObject* pyArg)" << endl;
+ s << "int " << cpythonBaseName(metaClass->typeEntry()) << "__setitem__(PyObject *self, Py_ssize_t _i, PyObject *pyArg)" << endl;
s << '{' << endl;
writeCppSelfDefinition(s, context);
writeIndexError(s, QLatin1String("list assignment index out of range"));
@@ -5993,7 +5991,7 @@ void CppGenerator::writeStdListWrapperMethods(QTextStream &s, GeneratorContext &
s << INDENT << "return {};" << endl;
s << '}' << endl;
}
-void CppGenerator::writeIndexError(QTextStream& s, const QString& errorMsg)
+void CppGenerator::writeIndexError(QTextStream &s, const QString &errorMsg)
{
s << INDENT << "if (_i < 0 || _i >= (Py_ssize_t) " << CPP_SELF_VAR << "->size()) {" << endl;
{
@@ -6010,7 +6008,7 @@ QString CppGenerator::writeReprFunction(QTextStream &s, GeneratorContext &contex
QString funcName = cpythonBaseName(metaClass) + QLatin1String("__repr__");
s << "extern \"C\"" << endl;
s << '{' << endl;
- s << "static PyObject* " << funcName << "(PyObject* self)" << endl;
+ s << "static PyObject *" << funcName << "(PyObject *self)" << endl;
s << '{' << endl;
writeCppSelfDefinition(s, context);
s << INDENT << "QBuffer buffer;" << endl;
@@ -6028,7 +6026,7 @@ QString CppGenerator::writeReprFunction(QTextStream &s, GeneratorContext &contex
Indentation indent(INDENT);
s << INDENT << "str.replace(0, idx, Py_TYPE(self)->tp_name);" << endl;
}
- s << INDENT << "PyObject* mod = PyDict_GetItemString(Py_TYPE(self)->tp_dict, \"__module__\");" << endl;
+ s << INDENT << "PyObject *mod = PyDict_GetItemString(Py_TYPE(self)->tp_dict, \"__module__\");" << endl;
// PYSIDE-595: The introduction of heap types has the side effect that the module name
// is always prepended to the type name. Therefore the strchr check:
s << INDENT << "if (mod && !strchr(str, '.'))" << endl;
diff --git a/sources/shiboken2/generator/shiboken2/cppgenerator.h b/sources/shiboken2/generator/shiboken2/cppgenerator.h
index 519e12b7..ae6da958 100644
--- a/sources/shiboken2/generator/shiboken2/cppgenerator.h
+++ b/sources/shiboken2/generator/shiboken2/cppgenerator.h
@@ -44,38 +44,39 @@ public:
protected:
QString fileNameSuffix() const override;
QString fileNameForContext(GeneratorContext &context) const override;
- QVector<AbstractMetaFunctionList> filterGroupedOperatorFunctions(const AbstractMetaClass* metaClass,
+ QVector<AbstractMetaFunctionList> filterGroupedOperatorFunctions(const AbstractMetaClass *metaClass,
uint query);
- void generateClass(QTextStream& s, GeneratorContext &classContext) override;
+ void generateClass(QTextStream &s, GeneratorContext &classContext) override;
bool finishGeneration() override;
private:
- void writeConstructorNative(QTextStream& s, const AbstractMetaFunction* func);
- void writeDestructorNative(QTextStream& s, const AbstractMetaClass* metaClass);
+ void writeConstructorNative(QTextStream &s, const AbstractMetaFunction *func);
+ void writeDestructorNative(QTextStream &s, const AbstractMetaClass *metaClass);
- QString getVirtualFunctionReturnTypeName(const AbstractMetaFunction* func);
- void writeVirtualMethodNative(QTextStream& s, const AbstractMetaFunction* func);
+ QString getVirtualFunctionReturnTypeName(const AbstractMetaFunction *func);
+ void writeVirtualMethodNative(QTextStream &s, const AbstractMetaFunction *func);
- void writeMetaObjectMethod(QTextStream& s, const AbstractMetaClass* metaClass);
- void writeMetaCast(QTextStream& s, const AbstractMetaClass* metaClass);
+ void writeMetaObjectMethod(QTextStream &s, const AbstractMetaClass *metaClass);
+ void writeMetaCast(QTextStream &s, const AbstractMetaClass *metaClass);
- void writeEnumConverterFunctions(QTextStream& s, const TypeEntry* enumType);
- void writeEnumConverterFunctions(QTextStream& s, const AbstractMetaEnum* metaEnum);
+ void writeEnumConverterFunctions(QTextStream &s, const TypeEntry *enumType);
+ void writeEnumConverterFunctions(QTextStream &s, const AbstractMetaEnum *metaEnum);
void writeConverterFunctions(QTextStream &s, const AbstractMetaClass *metaClass,
GeneratorContext &classContext);
- void writeCustomConverterFunctions(QTextStream& s, const CustomConversion* customConversion);
+ void writeCustomConverterFunctions(QTextStream &s, const CustomConversion *customConversion);
void writeConverterRegister(QTextStream &s, const AbstractMetaClass *metaClass,
GeneratorContext &classContext);
- void writeCustomConverterRegister(QTextStream& s, const CustomConversion* customConversion, const QString& converterVar);
+ void writeCustomConverterRegister(QTextStream &s, const CustomConversion *customConversion, const QString &converterVar);
- void writeContainerConverterFunctions(QTextStream& s, const AbstractMetaType* containerType);
+ void writeContainerConverterFunctions(QTextStream &s, const AbstractMetaType *containerType);
void writeMethodWrapperPreamble(QTextStream &s, OverloadData &overloadData,
GeneratorContext &context);
- void writeConstructorWrapper(QTextStream &s, const AbstractMetaFunctionList overloads, GeneratorContext &classContext);
- void writeMethodWrapper(QTextStream &s, const AbstractMetaFunctionList overloads,
+ void writeConstructorWrapper(QTextStream &s, const AbstractMetaFunctionList &overloads,
+ GeneratorContext &classContext);
+ void writeMethodWrapper(QTextStream &s, const AbstractMetaFunctionList &overloads,
GeneratorContext &classContext);
- void writeArgumentsInitializer(QTextStream& s, OverloadData& overloadData);
+ void writeArgumentsInitializer(QTextStream &s, OverloadData &overloadData);
void writeCppSelfAssigment(QTextStream &s, const GeneratorContext &context,
const QString &className, bool cppSelfAsReference,
bool useWrapperClass);
@@ -88,16 +89,18 @@ private:
bool hasStaticOverload = false,
bool cppSelfAsReference = false);
- void writeErrorSection(QTextStream& s, OverloadData& overloadData);
- void writeFunctionReturnErrorCheckSection(QTextStream& s, bool hasReturnValue = true);
+ void writeErrorSection(QTextStream &s, OverloadData &overloadData);
+ void writeFunctionReturnErrorCheckSection(QTextStream &s, bool hasReturnValue = true);
/// Writes the check section for the validity of wrapped C++ objects.
- void writeInvalidPyObjectCheck(QTextStream& s, const QString& pyObj);
+ void writeInvalidPyObjectCheck(QTextStream &s, const QString &pyObj);
- void writeTypeCheck(QTextStream& s, const AbstractMetaType* argType, QString argumentName, bool isNumber = false, QString customType = QString(), bool rejectNull = false);
- void writeTypeCheck(QTextStream& s, const OverloadData* overloadData, QString argumentName);
+ void writeTypeCheck(QTextStream &s, const AbstractMetaType *argType, const QString &argumentName,
+ bool isNumber = false, const QString &customType = QString(),
+ bool rejectNull = false);
+ void writeTypeCheck(QTextStream& s, const OverloadData *overloadData, QString argumentName);
- void writeTypeDiscoveryFunction(QTextStream& s, const AbstractMetaClass* metaClass);
+ void writeTypeDiscoveryFunction(QTextStream &s, const AbstractMetaClass *metaClass);
void writeSetattroFunction(QTextStream &s, GeneratorContext &context);
void writeGetattroFunction(QTextStream &s, GeneratorContext &context);
@@ -115,10 +118,10 @@ private:
* \param defaultValue an optional default value to be used instead of the conversion result
* \param castArgumentAsUnused if true the converted argument is cast as unused to avoid compiler warnings
*/
- void writeArgumentConversion(QTextStream& s, const AbstractMetaType* argType,
- const QString& argName, const QString& pyArgName,
- const AbstractMetaClass* context = 0,
- const QString& defaultValue = QString(),
+ void writeArgumentConversion(QTextStream &s, const AbstractMetaType *argType,
+ const QString &argName, const QString &pyArgName,
+ const AbstractMetaClass *context = nullptr,
+ const QString &defaultValue = QString(),
bool castArgumentAsUnused = false);
/**
@@ -132,19 +135,19 @@ private:
* \param newType It is set to true if the type returned is a new object that must be deallocated.
* \return The type of the argument indicated by \p argPos.
*/
- const AbstractMetaType* getArgumentType(const AbstractMetaFunction* func, int argPos);
+ const AbstractMetaType *getArgumentType(const AbstractMetaFunction *func, int argPos);
- void writePythonToCppTypeConversion(QTextStream& s,
- const AbstractMetaType* type,
- const QString& pyIn,
- const QString& cppOut,
- const AbstractMetaClass* context = 0,
- const QString& defaultValue = QString());
+ void writePythonToCppTypeConversion(QTextStream &s,
+ const AbstractMetaType *type,
+ const QString &pyIn,
+ const QString &cppOut,
+ const AbstractMetaClass *context = nullptr,
+ const QString &defaultValue = QString());
/// Writes the conversion rule for arguments of regular and virtual methods.
- void writeConversionRule(QTextStream& s, const AbstractMetaFunction* func, TypeSystem::Language language);
+ void writeConversionRule(QTextStream &s, const AbstractMetaFunction *func, TypeSystem::Language language);
/// Writes the conversion rule for the return value of a method.
- void writeConversionRule(QTextStream& s, const AbstractMetaFunction* func, TypeSystem::Language language, const QString& outputVar);
+ void writeConversionRule(QTextStream &s, const AbstractMetaFunction *func, TypeSystem::Language language, const QString &outputVar);
/**
* Set the Python method wrapper return value variable to Py_None if
@@ -155,7 +158,7 @@ private:
* \param thereIsReturnValue indicates if the return type of any of the other overloads
* for this function is different from 'void'
*/
- void writeNoneReturn(QTextStream& s, const AbstractMetaFunction* func, bool thereIsReturnValue);
+ void writeNoneReturn(QTextStream &s, const AbstractMetaFunction *func, bool thereIsReturnValue);
/**
* Writes the Python function wrapper overload decisor that selects which C++
@@ -163,9 +166,9 @@ private:
* \param s text stream to write
* \param overloadData the overload data describing all the possible overloads for the function/method
*/
- void writeOverloadedFunctionDecisor(QTextStream& s, const OverloadData& overloadData);
+ void writeOverloadedFunctionDecisor(QTextStream &s, const OverloadData &overloadData);
/// Recursive auxiliar method to the other writeOverloadedFunctionDecisor.
- void writeOverloadedFunctionDecisorEngine(QTextStream& s, const OverloadData* parentOverloadData);
+ void writeOverloadedFunctionDecisorEngine(QTextStream &s, const OverloadData *parentOverloadData);
/// Writes calls to all the possible method/function overloads.
void writeFunctionCalls(QTextStream &s,
@@ -179,55 +182,55 @@ private:
GeneratorContext &context);
/// Returns the name of a C++ to Python conversion function.
- static QString cppToPythonFunctionName(const QString& sourceTypeName, QString targetTypeName = QString());
+ static QString cppToPythonFunctionName(const QString &sourceTypeName, QString targetTypeName = QString());
/// Returns the name of a Python to C++ conversion function.
- static QString pythonToCppFunctionName(const QString& sourceTypeName, const QString& targetTypeName);
- static QString pythonToCppFunctionName(const AbstractMetaType* sourceType, const AbstractMetaType* targetType);
- static QString pythonToCppFunctionName(const CustomConversion::TargetToNativeConversion* toNative, const TypeEntry* targetType);
+ static QString pythonToCppFunctionName(const QString &sourceTypeName, const QString &targetTypeName);
+ static QString pythonToCppFunctionName(const AbstractMetaType *sourceType, const AbstractMetaType *targetType);
+ static QString pythonToCppFunctionName(const CustomConversion::TargetToNativeConversion *toNative, const TypeEntry *targetType);
/// Returns the name of a Python to C++ convertible check function.
- static QString convertibleToCppFunctionName(const QString& sourceTypeName, const QString& targetTypeName);
- static QString convertibleToCppFunctionName(const AbstractMetaType* sourceType, const AbstractMetaType* targetType);
- static QString convertibleToCppFunctionName(const CustomConversion::TargetToNativeConversion* toNative, const TypeEntry* targetType);
+ static QString convertibleToCppFunctionName(const QString &sourceTypeName, const QString &targetTypeName);
+ static QString convertibleToCppFunctionName(const AbstractMetaType *sourceType, const AbstractMetaType *targetType);
+ static QString convertibleToCppFunctionName(const CustomConversion::TargetToNativeConversion *toNative, const TypeEntry *targetType);
/// Writes a C++ to Python conversion function.
- void writeCppToPythonFunction(QTextStream& s, const QString& code, const QString& sourceTypeName, QString targetTypeName = QString());
- void writeCppToPythonFunction(QTextStream& s, const CustomConversion* customConversion);
- void writeCppToPythonFunction(QTextStream& s, const AbstractMetaType* containerType);
+ void writeCppToPythonFunction(QTextStream &s, const QString &code, const QString &sourceTypeName, QString targetTypeName = QString());
+ void writeCppToPythonFunction(QTextStream &s, const CustomConversion *customConversion);
+ void writeCppToPythonFunction(QTextStream &s, const AbstractMetaType *containerType);
/// Writes a Python to C++ conversion function.
- void writePythonToCppFunction(QTextStream& s, const QString& code, const QString& sourceTypeName, const QString& targetTypeName);
+ void writePythonToCppFunction(QTextStream &s, const QString &code, const QString &sourceTypeName, const QString &targetTypeName);
/// Writes a Python to C++ convertible check function.
- void writeIsPythonConvertibleToCppFunction(QTextStream& s,
- const QString& sourceTypeName,
- const QString& targetTypeName,
- const QString& condition,
+ void writeIsPythonConvertibleToCppFunction(QTextStream &s,
+ const QString &sourceTypeName,
+ const QString &targetTypeName,
+ const QString &condition,
QString pythonToCppFuncName = QString(),
bool acceptNoneAsCppNull = false);
/// Writes a pair of Python to C++ conversion and check functions.
- void writePythonToCppConversionFunctions(QTextStream& s,
- const AbstractMetaType* sourceType,
- const AbstractMetaType* targetType,
+ void writePythonToCppConversionFunctions(QTextStream &s,
+ const AbstractMetaType *sourceType,
+ const AbstractMetaType *targetType,
QString typeCheck = QString(),
QString conversion = QString(),
- QString preConversion = QString());
+ const QString &preConversion = QString());
/// Writes a pair of Python to C++ conversion and check functions for implicit conversions.
- void writePythonToCppConversionFunctions(QTextStream& s,
- const CustomConversion::TargetToNativeConversion* toNative,
- const TypeEntry* targetType);
+ void writePythonToCppConversionFunctions(QTextStream &s,
+ const CustomConversion::TargetToNativeConversion *toNative,
+ const TypeEntry *targetType);
/// Writes a pair of Python to C++ conversion and check functions for instantiated container types.
- void writePythonToCppConversionFunctions(QTextStream& s, const AbstractMetaType* containerType);
+ void writePythonToCppConversionFunctions(QTextStream &s, const AbstractMetaType *containerType);
- void writeAddPythonToCppConversion(QTextStream& s, const QString& converterVar, const QString& pythonToCppFunc, const QString& isConvertibleFunc);
+ void writeAddPythonToCppConversion(QTextStream &s, const QString &converterVar, const QString &pythonToCppFunc, const QString &isConvertibleFunc);
- void writeNamedArgumentResolution(QTextStream& s, const AbstractMetaFunction* func, bool usePyArgs);
+ void writeNamedArgumentResolution(QTextStream &s, const AbstractMetaFunction *func, bool usePyArgs);
/// Returns a string containing the name of an argument for the given function and argument index.
- QString argumentNameFromIndex(const AbstractMetaFunction* func, int argIndex, const AbstractMetaClass** wrappedClass);
+ QString argumentNameFromIndex(const AbstractMetaFunction *func, int argIndex, const AbstractMetaClass **wrappedClass);
void writeMethodCall(QTextStream &s, const AbstractMetaFunction *func,
GeneratorContext &context, int maxArgs = 0);
@@ -241,25 +244,25 @@ private:
void writeClassDefinition(QTextStream &s,
const AbstractMetaClass *metaClass,
GeneratorContext &classContext);
- void writeMethodDefinitionEntry(QTextStream& s, const AbstractMetaFunctionList &overloads);
- void writeMethodDefinition(QTextStream& s, const AbstractMetaFunctionList &overloads);
+ void writeMethodDefinitionEntry(QTextStream &s, const AbstractMetaFunctionList &overloads);
+ void writeMethodDefinition(QTextStream &s, const AbstractMetaFunctionList &overloads);
void writeSignatureInfo(QTextStream &s, const AbstractMetaFunctionList &overloads);
/// Writes the implementation of all methods part of python sequence protocol
void writeSequenceMethods(QTextStream &s,
const AbstractMetaClass *metaClass,
GeneratorContext &context);
- void writeTypeAsSequenceDefinition(QTextStream& s, const AbstractMetaClass* metaClass);
+ void writeTypeAsSequenceDefinition(QTextStream &s, const AbstractMetaClass *metaClass);
/// Writes the PyMappingMethods structure for types that supports the python mapping protocol.
- void writeTypeAsMappingDefinition(QTextStream& s, const AbstractMetaClass* metaClass);
+ void writeTypeAsMappingDefinition(QTextStream &s, const AbstractMetaClass *metaClass);
void writeMappingMethods(QTextStream &s,
const AbstractMetaClass *metaClass,
GeneratorContext &context);
- void writeTypeAsNumberDefinition(QTextStream& s, const AbstractMetaClass* metaClass);
+ void writeTypeAsNumberDefinition(QTextStream &s, const AbstractMetaClass *metaClass);
- void writeTpTraverseFunction(QTextStream& s, const AbstractMetaClass* metaClass);
- void writeTpClearFunction(QTextStream& s, const AbstractMetaClass* metaClass);
+ void writeTpTraverseFunction(QTextStream &s, const AbstractMetaClass *metaClass);
+ void writeTpClearFunction(QTextStream &s, const AbstractMetaClass *metaClass);
void writeCopyFunction(QTextStream &s, GeneratorContext &context);
@@ -272,35 +275,35 @@ private:
void writeRichCompareFunction(QTextStream &s, GeneratorContext &context);
- void writeEnumsInitialization(QTextStream& s, AbstractMetaEnumList& enums);
- void writeEnumInitialization(QTextStream& s, const AbstractMetaEnum* metaEnum);
+ void writeEnumsInitialization(QTextStream &s, AbstractMetaEnumList &enums);
+ void writeEnumInitialization(QTextStream &s, const AbstractMetaEnum *metaEnum);
- void writeSignalInitialization(QTextStream& s, const AbstractMetaClass* metaClass);
+ void writeSignalInitialization(QTextStream &s, const AbstractMetaClass *metaClass);
- void writeFlagsMethods(QTextStream& s, const AbstractMetaEnum* cppEnum);
- void writeFlagsToLong(QTextStream& s, const AbstractMetaEnum* cppEnum);
- void writeFlagsNonZero(QTextStream& s, const AbstractMetaEnum* cppEnum);
- void writeFlagsNumberMethodsDefinition(QTextStream& s, const AbstractMetaEnum* cppEnum);
- void writeFlagsBinaryOperator(QTextStream& s, const AbstractMetaEnum* cppEnum,
+ void writeFlagsMethods(QTextStream &s, const AbstractMetaEnum *cppEnum);
+ void writeFlagsToLong(QTextStream &s, const AbstractMetaEnum *cppEnum);
+ void writeFlagsNonZero(QTextStream &s, const AbstractMetaEnum *cppEnum);
+ void writeFlagsNumberMethodsDefinition(QTextStream &s, const AbstractMetaEnum *cppEnum);
+ void writeFlagsBinaryOperator(QTextStream &s, const AbstractMetaEnum *cppEnum,
const QString &pyOpName, const QString &cppOpName);
- void writeFlagsUnaryOperator(QTextStream& s, const AbstractMetaEnum* cppEnum,
+ void writeFlagsUnaryOperator(QTextStream &s, const AbstractMetaEnum *cppEnum,
const QString &pyOpName, const QString &cppOpName,
bool boolResult = false);
/// Writes the function that registers the multiple inheritance information for the classes that need it.
- void writeMultipleInheritanceInitializerFunction(QTextStream& s, const AbstractMetaClass* metaClass);
+ void writeMultipleInheritanceInitializerFunction(QTextStream &s, const AbstractMetaClass *metaClass);
/// Writes the implementation of special cast functions, used when we need to cast a class with multiple inheritance.
- void writeSpecialCastFunction(QTextStream& s, const AbstractMetaClass* metaClass);
+ void writeSpecialCastFunction(QTextStream &s, const AbstractMetaClass *metaClass);
- void writePrimitiveConverterInitialization(QTextStream& s, const CustomConversion* customConversion);
- void writeEnumConverterInitialization(QTextStream& s, const TypeEntry* enumType);
- void writeEnumConverterInitialization(QTextStream& s, const AbstractMetaEnum* metaEnum);
- void writeContainerConverterInitialization(QTextStream& s, const AbstractMetaType* type);
- void writeExtendedConverterInitialization(QTextStream& s, const TypeEntry* externalType, const QVector<const AbstractMetaClass*>& conversions);
+ void writePrimitiveConverterInitialization(QTextStream &s, const CustomConversion *customConversion);
+ void writeEnumConverterInitialization(QTextStream &s, const TypeEntry *enumType);
+ void writeEnumConverterInitialization(QTextStream &s, const AbstractMetaEnum *metaEnum);
+ void writeContainerConverterInitialization(QTextStream &s, const AbstractMetaType *type);
+ void writeExtendedConverterInitialization(QTextStream &s, const TypeEntry *externalType, const QVector<const AbstractMetaClass *>& conversions);
- void writeParentChildManagement(QTextStream& s, const AbstractMetaFunction* func, bool userHeuristicForReturn);
- bool writeParentChildManagement(QTextStream& s, const AbstractMetaFunction* func, int argIndex, bool userHeuristicPolicy);
- void writeReturnValueHeuristics(QTextStream& s, const AbstractMetaFunction* func, const QString& self = QLatin1String("self"));
+ void writeParentChildManagement(QTextStream &s, const AbstractMetaFunction *func, bool userHeuristicForReturn);
+ bool writeParentChildManagement(QTextStream &s, const AbstractMetaFunction *func, int argIndex, bool userHeuristicPolicy);
+ void writeReturnValueHeuristics(QTextStream &s, const AbstractMetaFunction *func, const QString &self = QLatin1String("self"));
void writeInitQtMetaTypeFunctionBody(QTextStream &s, GeneratorContext &context) const;
/**
@@ -309,34 +312,34 @@ private:
* \return name of the multiple inheritance information initializer function or
* an empty string if there is no multiple inheritance in its ancestry.
*/
- QString multipleInheritanceInitializerFunctionName(const AbstractMetaClass* metaClass);
+ QString multipleInheritanceInitializerFunctionName(const AbstractMetaClass *metaClass);
/// Returns a list of all classes to which the given class could be cast.
- QStringList getAncestorMultipleInheritance(const AbstractMetaClass* metaClass);
+ QStringList getAncestorMultipleInheritance(const AbstractMetaClass *metaClass);
/// Returns true if the given class supports the python number protocol
- bool supportsNumberProtocol(const AbstractMetaClass* metaClass);
+ bool supportsNumberProtocol(const AbstractMetaClass *metaClass);
/// Returns true if the given class supports the python sequence protocol
- bool supportsSequenceProtocol(const AbstractMetaClass* metaClass);
+ bool supportsSequenceProtocol(const AbstractMetaClass *metaClass);
/// Returns true if the given class supports the python mapping protocol
- bool supportsMappingProtocol(const AbstractMetaClass* metaClass);
+ bool supportsMappingProtocol(const AbstractMetaClass *metaClass);
/// Returns true if generator should produce getters and setters for the given class.
- bool shouldGenerateGetSetList(const AbstractMetaClass* metaClass);
+ bool shouldGenerateGetSetList(const AbstractMetaClass *metaClass);
void writeHashFunction(QTextStream &s, GeneratorContext &context);
/// Write default implementations for sequence protocol
void writeStdListWrapperMethods(QTextStream &s, GeneratorContext &context);
/// Helper function for writeStdListWrapperMethods.
- void writeIndexError(QTextStream& s, const QString& errorMsg);
+ void writeIndexError(QTextStream &s, const QString &errorMsg);
QString writeReprFunction(QTextStream &s, GeneratorContext &context);
- const AbstractMetaFunction *boolCast(const AbstractMetaClass* metaClass) const;
- bool hasBoolCast(const AbstractMetaClass* metaClass) const
+ const AbstractMetaFunction *boolCast(const AbstractMetaClass *metaClass) const;
+ bool hasBoolCast(const AbstractMetaClass *metaClass) const
{ return boolCast(metaClass) != nullptr; }
// Number protocol structure members names.
diff --git a/sources/shiboken2/generator/shiboken2/headergenerator.cpp b/sources/shiboken2/generator/shiboken2/headergenerator.cpp
index a55539d7..8a2c5623 100644
--- a/sources/shiboken2/generator/shiboken2/headergenerator.cpp
+++ b/sources/shiboken2/generator/shiboken2/headergenerator.cpp
@@ -58,7 +58,7 @@ QString HeaderGenerator::fileNameForContext(GeneratorContext &context) const
return fileNameBase + fileNameSuffix();
}
-void HeaderGenerator::writeCopyCtor(QTextStream& s, const AbstractMetaClass* metaClass) const
+void HeaderGenerator::writeCopyCtor(QTextStream &s, const AbstractMetaClass *metaClass) const
{
s << INDENT << wrapperName(metaClass) << "(const " << metaClass->qualifiedCppName() << "& self)";
s << " : " << metaClass->qualifiedCppName() << "(self)" << endl;
@@ -66,7 +66,7 @@ void HeaderGenerator::writeCopyCtor(QTextStream& s, const AbstractMetaClass* met
s << INDENT << "}" << endl << endl;
}
-void HeaderGenerator::writeProtectedFieldAccessors(QTextStream& s, const AbstractMetaField* field) const
+void HeaderGenerator::writeProtectedFieldAccessors(QTextStream &s, const AbstractMetaField *field) const
{
AbstractMetaType *metaType = field->type();
QString fieldType = metaType->cppSignature();
@@ -81,10 +81,10 @@ void HeaderGenerator::writeProtectedFieldAccessors(QTextStream& s, const Abstrac
// Get function
s << INDENT << "inline " << fieldType
- << (useReference ? '*' : ' ')
+ << (useReference ? " *" : " ")
<< ' ' << protectedFieldGetterName(field) << "()"
<< " { return "
- << (useReference ? '&' : ' ') << "this->" << fieldName << "; }" << endl;
+ << (useReference ? " &" : " ") << "this->" << fieldName << "; }" << endl;
// Set function
s << INDENT << "inline void " << protectedFieldSetterName(field) << '(' << fieldType << " value)"
@@ -169,8 +169,8 @@ void HeaderGenerator::generateClass(QTextStream &s, GeneratorContext &classConte
if ((!avoidProtectedHack() || !metaClass->hasPrivateDestructor())
&& usePySideExtensions() && metaClass->isQObject()) {
s << "public:\n";
- s << INDENT << "int qt_metacall(QMetaObject::Call call, int id, void** args) override;" << endl;
- s << INDENT << "void* qt_metacast(const char* _clname) override;" << endl;
+ s << INDENT << "int qt_metacall(QMetaObject::Call call, int id, void **args) override;" << endl;
+ s << INDENT << "void *qt_metacast(const char *_clname) override;" << endl;
}
if (!m_inheritedOverloads.isEmpty()) {
@@ -205,7 +205,7 @@ void HeaderGenerator::generateClass(QTextStream &s, GeneratorContext &classConte
s << "#endif // SBK_" << outerHeaderGuard << "_H" << endl << endl;
}
-void HeaderGenerator::writeFunction(QTextStream& s, const AbstractMetaFunction* func)
+void HeaderGenerator::writeFunction(QTextStream &s, const AbstractMetaFunction *func)
{
// do not write copy ctors here.
@@ -228,9 +228,9 @@ void HeaderGenerator::writeFunction(QTextStream& s, const AbstractMetaFunction*
const AbstractMetaArgumentList &arguments = func->arguments();
for (const AbstractMetaArgument *arg : arguments) {
QString argName = arg->name();
- const TypeEntry* enumTypeEntry = 0;
+ const TypeEntry *enumTypeEntry = nullptr;
if (arg->type()->isFlags())
- enumTypeEntry = static_cast<const FlagsTypeEntry*>(arg->type()->typeEntry())->originator();
+ enumTypeEntry = static_cast<const FlagsTypeEntry *>(arg->type()->typeEntry())->originator();
else if (arg->type()->isEnum())
enumTypeEntry = arg->type()->typeEntry();
if (enumTypeEntry)
@@ -284,7 +284,7 @@ void HeaderGenerator::writeFunction(QTextStream& s, const AbstractMetaFunction*
}
}
-static void _writeTypeIndexValue(QTextStream& s, const QString& variableName,
+static void _writeTypeIndexValue(QTextStream &s, const QString &variableName,
int typeIndex)
{
s << " ";
@@ -294,15 +294,15 @@ static void _writeTypeIndexValue(QTextStream& s, const QString& variableName,
s << " = " << typeIndex;
}
-static inline void _writeTypeIndexValueLine(QTextStream& s,
- const QString& variableName,
+static inline void _writeTypeIndexValueLine(QTextStream &s,
+ const QString &variableName,
int typeIndex)
{
_writeTypeIndexValue(s, variableName, typeIndex);
s << ",\n";
}
-void HeaderGenerator::writeTypeIndexValueLine(QTextStream& s, const TypeEntry* typeEntry)
+void HeaderGenerator::writeTypeIndexValueLine(QTextStream &s, const TypeEntry *typeEntry)
{
if (!typeEntry || !typeEntry->generateCode())
return;
@@ -310,7 +310,7 @@ void HeaderGenerator::writeTypeIndexValueLine(QTextStream& s, const TypeEntry* t
const int typeIndex = typeEntry->sbkIndex();
_writeTypeIndexValueLine(s, getTypeIndexVariableName(typeEntry), typeIndex);
if (typeEntry->isComplex()) {
- const ComplexTypeEntry* cType = static_cast<const ComplexTypeEntry*>(typeEntry);
+ const auto *cType = static_cast<const ComplexTypeEntry *>(typeEntry);
if (cType->baseContainerType()) {
const AbstractMetaClass *metaClass = AbstractMetaClass::findClass(classes(), cType);
if (metaClass->templateBaseClass())
@@ -318,13 +318,13 @@ void HeaderGenerator::writeTypeIndexValueLine(QTextStream& s, const TypeEntry* t
}
}
if (typeEntry->isEnum()) {
- const EnumTypeEntry* ete = static_cast<const EnumTypeEntry*>(typeEntry);
+ auto ete = static_cast<const EnumTypeEntry *>(typeEntry);
if (ete->flags())
writeTypeIndexValueLine(s, ete->flags());
}
}
-void HeaderGenerator::writeTypeIndexValueLines(QTextStream& s, const AbstractMetaClass* metaClass)
+void HeaderGenerator::writeTypeIndexValueLines(QTextStream &s, const AbstractMetaClass *metaClass)
{
if (!metaClass->typeEntry()->generateCode())
return;
@@ -383,7 +383,7 @@ bool HeaderGenerator::finishGeneration()
AbstractMetaEnumList globalEnums = this->globalEnums();
AbstractMetaClassList classList = classes();
- std::sort(classList.begin(), classList.end(), [](AbstractMetaClass *a, AbstractMetaClass* b) {
+ std::sort(classList.begin(), classList.end(), [](AbstractMetaClass *a, AbstractMetaClass *b) {
return a->typeEntry()->sbkIndex() < b->typeEntry()->sbkIndex();
});
@@ -413,11 +413,11 @@ bool HeaderGenerator::finishGeneration()
macrosStream << "\n};\n";
macrosStream << "// This variable stores all Python types exported by this module." << endl;
- macrosStream << "extern PyTypeObject** " << cppApiVariableName() << ';' << endl << endl;
+ macrosStream << "extern PyTypeObject **" << cppApiVariableName() << ';' << endl << endl;
macrosStream << "// This variable stores the Python module object exported by this module." << endl;
- macrosStream << "extern PyObject* " << pythonModuleObjectName() << ';' << endl << endl;
+ macrosStream << "extern PyObject *" << pythonModuleObjectName() << ';' << endl << endl;
macrosStream << "// This variable stores all type converters exported by this module." << endl;
- macrosStream << "extern SbkConverter** " << convertersVariableName() << ';' << endl << endl;
+ macrosStream << "extern SbkConverter **" << convertersVariableName() << ';' << endl << endl;
// TODO-CONVERTER ------------------------------------------------------------------------------
// Using a counter would not do, a fix must be made to APIExtractor's getTypeIndex().
@@ -467,14 +467,14 @@ bool HeaderGenerator::finishGeneration()
continue;
//Includes
- const TypeEntry* classType = metaClass->typeEntry();
+ const TypeEntry *classType = metaClass->typeEntry();
includes << classType->include();
const AbstractMetaEnumList &enums = metaClass->enums();
for (const AbstractMetaEnum *cppEnum : enums) {
if (cppEnum->isAnonymous() || cppEnum->isPrivate())
continue;
- EnumTypeEntry* enumType = cppEnum->typeEntry();
+ EnumTypeEntry *enumType = cppEnum->typeEntry();
includes << enumType->include();
writeProtectedEnumSurrogate(protEnumsSurrogates, cppEnum);
writeSbkTypeFunction(typeFunctions, cppEnum);
@@ -497,7 +497,7 @@ bool HeaderGenerator::finishGeneration()
QString includeShield(QLatin1String("SBK_") + moduleName().toUpper() + QLatin1String("_PYTHON_H"));
FileOut file(moduleHeaderFileName);
- QTextStream& s = file.stream;
+ QTextStream &s = file.stream;
// write license comment
s << licenseComment() << endl << endl;
@@ -558,13 +558,13 @@ bool HeaderGenerator::finishGeneration()
return file.done() != FileOut::Failure;
}
-void HeaderGenerator::writeProtectedEnumSurrogate(QTextStream& s, const AbstractMetaEnum* cppEnum)
+void HeaderGenerator::writeProtectedEnumSurrogate(QTextStream &s, const AbstractMetaEnum *cppEnum)
{
if (avoidProtectedHack() && cppEnum->isProtected())
s << "enum " << protectedEnumSurrogateName(cppEnum) << " {};" << endl;
}
-void HeaderGenerator::writeSbkTypeFunction(QTextStream& s, const AbstractMetaEnum* cppEnum)
+void HeaderGenerator::writeSbkTypeFunction(QTextStream &s, const AbstractMetaEnum *cppEnum)
{
QString enumName;
if (avoidProtectedHack() && cppEnum->isProtected()) {
@@ -575,29 +575,29 @@ void HeaderGenerator::writeSbkTypeFunction(QTextStream& s, const AbstractMetaEnu
enumName = cppEnum->enclosingClass()->qualifiedCppName() + QLatin1String("::") + enumName;
}
- s << "template<> inline PyTypeObject* SbkType< ::" << enumName << " >() ";
+ s << "template<> inline PyTypeObject *SbkType< ::" << enumName << " >() ";
s << "{ return " << cpythonTypeNameExt(cppEnum->typeEntry()) << "; }\n";
- FlagsTypeEntry* flag = cppEnum->typeEntry()->flags();
+ FlagsTypeEntry *flag = cppEnum->typeEntry()->flags();
if (flag) {
- s << "template<> inline PyTypeObject* SbkType< ::" << flag->name() << " >() "
+ s << "template<> inline PyTypeObject *SbkType< ::" << flag->name() << " >() "
<< "{ return " << cpythonTypeNameExt(flag) << "; }\n";
}
}
-void HeaderGenerator::writeSbkTypeFunction(QTextStream& s, const AbstractMetaClass* cppClass)
+void HeaderGenerator::writeSbkTypeFunction(QTextStream &s, const AbstractMetaClass *cppClass)
{
- s << "template<> inline PyTypeObject* SbkType< ::" << cppClass->qualifiedCppName() << " >() "
- << "{ return reinterpret_cast<PyTypeObject*>(" << cpythonTypeNameExt(cppClass->typeEntry()) << "); }\n";
+ s << "template<> inline PyTypeObject *SbkType< ::" << cppClass->qualifiedCppName() << " >() "
+ << "{ return reinterpret_cast<PyTypeObject *>(" << cpythonTypeNameExt(cppClass->typeEntry()) << "); }\n";
}
void HeaderGenerator::writeSbkTypeFunction(QTextStream &s, const AbstractMetaType *metaType)
{
- s << "template<> inline PyTypeObject* SbkType< ::" << metaType->cppSignature() << " >() "
- << "{ return reinterpret_cast<PyTypeObject*>(" << cpythonTypeNameExt(metaType) << "); }\n";
+ s << "template<> inline PyTypeObject *SbkType< ::" << metaType->cppSignature() << " >() "
+ << "{ return reinterpret_cast<PyTypeObject *>(" << cpythonTypeNameExt(metaType) << "); }\n";
}
-void HeaderGenerator::writeInheritedOverloads(QTextStream& s)
+void HeaderGenerator::writeInheritedOverloads(QTextStream &s)
{
for (const AbstractMetaFunction *func : qAsConst(m_inheritedOverloads)) {
s << INDENT << "inline ";
@@ -608,9 +608,9 @@ void HeaderGenerator::writeInheritedOverloads(QTextStream& s)
const AbstractMetaArgumentList &arguments = func->arguments();
for (const AbstractMetaArgument *arg : arguments) {
QString argName = arg->name();
- const TypeEntry* enumTypeEntry = 0;
+ const TypeEntry *enumTypeEntry = nullptr;
if (arg->type()->isFlags())
- enumTypeEntry = static_cast<const FlagsTypeEntry*>(arg->type()->typeEntry())->originator();
+ enumTypeEntry = static_cast<const FlagsTypeEntry *>(arg->type()->typeEntry())->originator();
else if (arg->type()->isEnum())
enumTypeEntry = arg->type()->typeEntry();
if (enumTypeEntry)
diff --git a/sources/shiboken2/generator/shiboken2/headergenerator.h b/sources/shiboken2/generator/shiboken2/headergenerator.h
index f59e0fd9..5f59dd13 100644
--- a/sources/shiboken2/generator/shiboken2/headergenerator.h
+++ b/sources/shiboken2/generator/shiboken2/headergenerator.h
@@ -48,22 +48,22 @@ public:
protected:
QString fileNameSuffix() const override;
QString fileNameForContext(GeneratorContext &context) const override;
- void generateClass(QTextStream& s, GeneratorContext &classContext) override;
+ void generateClass(QTextStream &s, GeneratorContext &classContext) override;
bool finishGeneration() override;
private:
- void writeCopyCtor(QTextStream &s, const AbstractMetaClass* metaClass) const;
- void writeProtectedFieldAccessors(QTextStream& s, const AbstractMetaField* field) const;
- void writeFunction(QTextStream& s, const AbstractMetaFunction* func);
- void writeSbkTypeFunction(QTextStream& s, const AbstractMetaEnum* cppEnum);
- void writeSbkTypeFunction(QTextStream& s, const AbstractMetaClass* cppClass);
+ void writeCopyCtor(QTextStream &s, const AbstractMetaClass *metaClass) const;
+ void writeProtectedFieldAccessors(QTextStream &s, const AbstractMetaField *field) const;
+ void writeFunction(QTextStream &s, const AbstractMetaFunction *func);
+ void writeSbkTypeFunction(QTextStream &s, const AbstractMetaEnum *cppEnum);
+ void writeSbkTypeFunction(QTextStream &s, const AbstractMetaClass *cppClass);
void writeSbkTypeFunction(QTextStream &s, const AbstractMetaType *metaType);
- void writeTypeIndexValueLine(QTextStream& s, const TypeEntry* typeEntry);
- void writeTypeIndexValueLines(QTextStream& s, const AbstractMetaClass* metaClass);
- void writeProtectedEnumSurrogate(QTextStream& s, const AbstractMetaEnum* cppEnum);
- void writeInheritedOverloads(QTextStream& s);
+ void writeTypeIndexValueLine(QTextStream &s, const TypeEntry *typeEntry);
+ void writeTypeIndexValueLines(QTextStream &s, const AbstractMetaClass *metaClass);
+ void writeProtectedEnumSurrogate(QTextStream &s, const AbstractMetaEnum *cppEnum);
+ void writeInheritedOverloads(QTextStream &s);
- QSet<const AbstractMetaFunction*> m_inheritedOverloads;
+ QSet<const AbstractMetaFunction *> m_inheritedOverloads;
};
#endif // HEADERGENERATOR_H
diff --git a/sources/shiboken2/generator/shiboken2/overloaddata.cpp b/sources/shiboken2/generator/shiboken2/overloaddata.cpp
index bbcdd6d5..4aa5e5c0 100644
--- a/sources/shiboken2/generator/shiboken2/overloaddata.cpp
+++ b/sources/shiboken2/generator/shiboken2/overloaddata.cpp
@@ -40,7 +40,7 @@
static const TypeEntry *getReferencedTypeEntry(const TypeEntry *typeEntry)
{
if (typeEntry->isPrimitive()) {
- const PrimitiveTypeEntry* pte = dynamic_cast<const PrimitiveTypeEntry*>(typeEntry);
+ auto pte = dynamic_cast<const PrimitiveTypeEntry *>(typeEntry);
while (pte->referencedTypeEntry())
pte = pte->referencedTypeEntry();
typeEntry = pte;
@@ -48,9 +48,9 @@ static const TypeEntry *getReferencedTypeEntry(const TypeEntry *typeEntry)
return typeEntry;
}
-static QString getTypeName(const AbstractMetaType* type)
+static QString getTypeName(const AbstractMetaType *type)
{
- const TypeEntry* typeEntry = getReferencedTypeEntry(type->typeEntry());
+ const TypeEntry *typeEntry = getReferencedTypeEntry(type->typeEntry());
QString typeName = typeEntry->name();
if (typeEntry->isContainer()) {
QStringList types;
@@ -64,12 +64,12 @@ static QString getTypeName(const AbstractMetaType* type)
return typeName;
}
-static QString getTypeName(const OverloadData* ov)
+static QString getTypeName(const OverloadData *ov)
{
return ov->hasArgumentTypeReplace() ? ov->argumentTypeReplaced() : getTypeName(ov->argType());
}
-static bool typesAreEqual(const AbstractMetaType* typeA, const AbstractMetaType* typeB)
+static bool typesAreEqual(const AbstractMetaType *typeA, const AbstractMetaType *typeB)
{
if (typeA->typeEntry() == typeB->typeEntry()) {
if (typeA->isContainer() || typeA->isSmartPointer()) {
@@ -100,7 +100,7 @@ struct OverloadSortData
* a OverloadData. This is done to express type dependencies that could
* or could not appear in overloaded signatures not processed yet.
*/
- void mapType(const QString& typeName)
+ void mapType(const QString &typeName)
{
if (map.contains(typeName))
return;
@@ -110,7 +110,7 @@ struct OverloadSortData
counter++;
}
- void mapType(OverloadData* overloadData)
+ void mapType(OverloadData *overloadData)
{
QString typeName = getTypeName(overloadData);
map[typeName] = counter;
@@ -122,7 +122,7 @@ struct OverloadSortData
int counter = 0;
QHash<QString, int> map; // typeName -> id
- QHash<int, OverloadData*> reverseMap; // id -> OverloadData;
+ QHash<int, OverloadData *> reverseMap; // id -> OverloadData;
};
/**
@@ -130,10 +130,10 @@ struct OverloadSortData
* an instantiation taken either from an implicit conversion expressed by the function argument,
* or from the string argument implicitConvTypeName.
*/
-static QString getImplicitConversionTypeName(const AbstractMetaType* containerType,
- const AbstractMetaType* instantiation,
- const AbstractMetaFunction* function,
- const QString& implicitConvTypeName = QString())
+static QString getImplicitConversionTypeName(const AbstractMetaType *containerType,
+ const AbstractMetaType *instantiation,
+ const AbstractMetaFunction *function,
+ const QString &implicitConvTypeName = QString())
{
QString impConv;
if (!implicitConvTypeName.isEmpty())
@@ -254,7 +254,7 @@ void OverloadData::sortNextOverloads()
// be called. In the case of primitive types, list<double> must come before list<int>.
if (instantiation->isPrimitive() && (signedIntegerPrimitives.contains(instantiation->name()))) {
for (const QString &primitive : qAsConst(nonIntegerPrimitives))
- sortData.mapType(getImplicitConversionTypeName(ov->argType(), instantiation, 0, primitive));
+ sortData.mapType(getImplicitConversionTypeName(ov->argType(), instantiation, nullptr, primitive));
} else {
const AbstractMetaFunctionList &funcs = m_generator->implicitConversions(instantiation);
for (const AbstractMetaFunction *function : funcs)
@@ -267,7 +267,7 @@ void OverloadData::sortNextOverloads()
// Create the graph of type dependencies based on implicit conversions.
Graph graph(sortData.reverseMap.count());
// All C++ primitive types, add any forgotten type AT THE END OF THIS LIST!
- const char* primitiveTypes[] = {"int",
+ const char *primitiveTypes[] = {"int",
"unsigned int",
"long",
"unsigned long",
@@ -280,7 +280,7 @@ void OverloadData::sortNextOverloads()
"double",
"const char*"
};
- const int numPrimitives = sizeof(primitiveTypes)/sizeof(const char*);
+ const int numPrimitives = sizeof(primitiveTypes)/sizeof(const char *);
bool hasPrimitive[numPrimitives];
for (int i = 0; i < numPrimitives; ++i)
hasPrimitive[i] = sortData.map.contains(QLatin1String(primitiveTypes[i]));
@@ -293,7 +293,7 @@ void OverloadData::sortNextOverloads()
MetaFunctionList involvedConversions;
for (OverloadData *ov : qAsConst(m_nextOverloadData)) {
- const AbstractMetaType* targetType = ov->argType();
+ const AbstractMetaType *targetType = ov->argType();
const QString targetTypeEntryName(getTypeName(ov));
int targetTypeId = sortData.map[targetTypeEntryName];
@@ -346,7 +346,7 @@ void OverloadData::sortNextOverloads()
if (instantiation->isPrimitive() && (signedIntegerPrimitives.contains(instantiation->name()))) {
for (const QString &primitive : qAsConst(nonIntegerPrimitives)) {
- QString convertibleTypeName = getImplicitConversionTypeName(ov->argType(), instantiation, 0, primitive);
+ QString convertibleTypeName = getImplicitConversionTypeName(ov->argType(), instantiation, nullptr, primitive);
if (!graph.containsEdge(targetTypeId, sortData.map[convertibleTypeName])) // Avoid cyclic dependency.
graph.addEdge(sortData.map[convertibleTypeName], targetTypeId);
}
@@ -404,7 +404,7 @@ void OverloadData::sortNextOverloads()
graph.addEdge(sortData.map[QLatin1String("QString")], sortData.map[QLatin1String("QByteArray")]);
for (OverloadData *ov : qAsConst(m_nextOverloadData)) {
- const AbstractMetaType* targetType = ov->argType();
+ const AbstractMetaType *targetType = ov->argType();
if (!targetType->isEnum())
continue;
@@ -462,13 +462,13 @@ void OverloadData::sortNextOverloads()
*
* Given these two overloads, there will be the following graph:
*
- * addStuff - double - PyObject*
+ * addStuff - double - PyObject *
* \- int
*
*/
-OverloadData::OverloadData(const AbstractMetaFunctionList& overloads, const ShibokenGenerator* generator)
- : m_minArgs(256), m_maxArgs(0), m_argPos(-1), m_argType(0),
- m_headOverloadData(this), m_previousOverloadData(0), m_generator(generator)
+OverloadData::OverloadData(const AbstractMetaFunctionList &overloads, const ShibokenGenerator *generator)
+ : m_minArgs(256), m_maxArgs(0), m_argPos(-1), m_argType(nullptr),
+ m_headOverloadData(this), m_previousOverloadData(nullptr), m_generator(generator)
{
for (const AbstractMetaFunction *func : overloads) {
m_overloads.append(func);
@@ -477,7 +477,7 @@ OverloadData::OverloadData(const AbstractMetaFunctionList& overloads, const Shib
m_minArgs = argSize;
else if (m_maxArgs < argSize)
m_maxArgs = argSize;
- OverloadData* currentOverloadData = this;
+ OverloadData *currentOverloadData = this;
const AbstractMetaArgumentList &arguments = func->arguments();
for (const AbstractMetaArgument *arg : arguments) {
if (func->argumentRemoved(arg->argumentIndex() + 1))
@@ -495,8 +495,8 @@ OverloadData::OverloadData(const AbstractMetaFunctionList& overloads, const Shib
m_headOverloadData->m_minArgs = maxArgs();
}
-OverloadData::OverloadData(OverloadData* headOverloadData, const AbstractMetaFunction* func,
- const AbstractMetaType* argType, int argPos)
+OverloadData::OverloadData(OverloadData *headOverloadData, const AbstractMetaFunction *func,
+ const AbstractMetaType *argType, int argPos)
: m_minArgs(256), m_maxArgs(0), m_argPos(argPos), m_argType(argType),
m_headOverloadData(headOverloadData), m_previousOverloadData(nullptr),
m_generator(nullptr)
@@ -505,7 +505,7 @@ OverloadData::OverloadData(OverloadData* headOverloadData, const AbstractMetaFun
this->addOverload(func);
}
-void OverloadData::addOverload(const AbstractMetaFunction* func)
+void OverloadData::addOverload(const AbstractMetaFunction *func)
{
int origNumArgs = func->arguments().size();
int removed = numberOfRemovedArguments(func);
@@ -530,11 +530,11 @@ void OverloadData::addOverload(const AbstractMetaFunction* func)
m_overloads.append(func);
}
-OverloadData* OverloadData::addOverloadData(const AbstractMetaFunction* func,
- const AbstractMetaArgument* arg)
+OverloadData *OverloadData::addOverloadData(const AbstractMetaFunction *func,
+ const AbstractMetaArgument *arg)
{
- const AbstractMetaType* argType = arg->type();
- OverloadData* overloadData = 0;
+ const AbstractMetaType *argType = arg->type();
+ OverloadData *overloadData = nullptr;
if (!func->isOperatorOverload()) {
for (OverloadData *tmp : qAsConst(m_nextOverloadData)) {
// TODO: 'const char *', 'char *' and 'char' will have the same TypeEntry?
@@ -604,7 +604,7 @@ bool OverloadData::hasAllowThread() const
return false;
}
-bool OverloadData::hasStaticFunction(const AbstractMetaFunctionList& overloads)
+bool OverloadData::hasStaticFunction(const AbstractMetaFunctionList &overloads)
{
for (const AbstractMetaFunction *func : qAsConst(overloads)) {
if (func->isStatic())
@@ -622,7 +622,7 @@ bool OverloadData::hasStaticFunction() const
return false;
}
-bool OverloadData::hasInstanceFunction(const AbstractMetaFunctionList& overloads)
+bool OverloadData::hasInstanceFunction(const AbstractMetaFunctionList &overloads)
{
for (const AbstractMetaFunction *func : qAsConst(overloads)) {
if (!func->isStatic())
@@ -640,7 +640,7 @@ bool OverloadData::hasInstanceFunction() const
return false;
}
-bool OverloadData::hasStaticAndInstanceFunctions(const AbstractMetaFunctionList& overloads)
+bool OverloadData::hasStaticAndInstanceFunctions(const AbstractMetaFunctionList &overloads)
{
return OverloadData::hasStaticFunction(overloads) && OverloadData::hasInstanceFunction(overloads);
}
@@ -650,15 +650,15 @@ bool OverloadData::hasStaticAndInstanceFunctions() const
return OverloadData::hasStaticFunction() && OverloadData::hasInstanceFunction();
}
-const AbstractMetaFunction* OverloadData::referenceFunction() const
+const AbstractMetaFunction *OverloadData::referenceFunction() const
{
return m_overloads.constFirst();
}
-const AbstractMetaArgument* OverloadData::argument(const AbstractMetaFunction* func) const
+const AbstractMetaArgument *OverloadData::argument(const AbstractMetaFunction *func) const
{
if (isHeadOverloadData() || !m_overloads.contains(func))
- return 0;
+ return nullptr;
int argPos = 0;
int removed = 0;
@@ -672,7 +672,7 @@ const AbstractMetaArgument* OverloadData::argument(const AbstractMetaFunction* f
return func->arguments().at(m_argPos + removed);
}
-OverloadDataList OverloadData::overloadDataOnPosition(OverloadData* overloadData, int argPos) const
+OverloadDataList OverloadData::overloadDataOnPosition(OverloadData *overloadData, int argPos) const
{
OverloadDataList overloadDataList;
if (overloadData->argPos() == argPos) {
@@ -701,27 +701,27 @@ bool OverloadData::nextArgumentHasDefaultValue() const
return false;
}
-static OverloadData* _findNextArgWithDefault(OverloadData* overloadData)
+static OverloadData *_findNextArgWithDefault(OverloadData *overloadData)
{
if (overloadData->getFunctionWithDefaultValue())
return overloadData;
- OverloadData* result = 0;
+ OverloadData *result = nullptr;
const OverloadDataList &data = overloadData->nextOverloadData();
for (OverloadData *odata : data) {
- OverloadData* tmp = _findNextArgWithDefault(odata);
+ OverloadData *tmp = _findNextArgWithDefault(odata);
if (!result || (tmp && result->argPos() > tmp->argPos()))
result = tmp;
}
return result;
}
-OverloadData* OverloadData::findNextArgWithDefault()
+OverloadData *OverloadData::findNextArgWithDefault()
{
return _findNextArgWithDefault(this);
}
-bool OverloadData::isFinalOccurrence(const AbstractMetaFunction* func) const
+bool OverloadData::isFinalOccurrence(const AbstractMetaFunction *func) const
{
for (const OverloadData *pd : m_nextOverloadData) {
if (pd->overloads().contains(func))
@@ -746,7 +746,7 @@ OverloadData::MetaFunctionList OverloadData::overloadsWithoutRepetition() const
return overloads;
}
-const AbstractMetaFunction* OverloadData::getFunctionWithDefaultValue() const
+const AbstractMetaFunction *OverloadData::getFunctionWithDefaultValue() const
{
for (const AbstractMetaFunction *func : m_overloads) {
int removedArgs = 0;
@@ -757,7 +757,7 @@ const AbstractMetaFunction* OverloadData::getFunctionWithDefaultValue() const
if (!ShibokenGenerator::getDefaultValue(func, func->arguments().at(m_argPos + removedArgs)).isEmpty())
return func;
}
- return 0;
+ return nullptr;
}
QVector<int> OverloadData::invalidArgumentLengths() const
@@ -787,7 +787,7 @@ QVector<int> OverloadData::invalidArgumentLengths() const
return invalidArgLengths;
}
-int OverloadData::numberOfRemovedArguments(const AbstractMetaFunction* func, int finalArgPos)
+int OverloadData::numberOfRemovedArguments(const AbstractMetaFunction *func, int finalArgPos)
{
int removed = 0;
if (finalArgPos < 0) {
@@ -804,7 +804,7 @@ int OverloadData::numberOfRemovedArguments(const AbstractMetaFunction* func, int
return removed;
}
-QPair<int, int> OverloadData::getMinMaxArguments(const AbstractMetaFunctionList& overloads)
+QPair<int, int> OverloadData::getMinMaxArguments(const AbstractMetaFunctionList &overloads)
{
int minArgs = 10000;
int maxArgs = 0;
@@ -827,7 +827,7 @@ QPair<int, int> OverloadData::getMinMaxArguments(const AbstractMetaFunctionList&
return {minArgs, maxArgs};
}
-bool OverloadData::isSingleArgument(const AbstractMetaFunctionList& overloads)
+bool OverloadData::isSingleArgument(const AbstractMetaFunctionList &overloads)
{
bool singleArgument = true;
for (const AbstractMetaFunction *func : overloads) {
@@ -863,7 +863,7 @@ QString OverloadData::dumpGraph() const
QString result;
QTextStream s(&result);
if (m_argPos == -1) {
- const AbstractMetaFunction* rfunc = referenceFunction();
+ const AbstractMetaFunction *rfunc = referenceFunction();
s << "digraph OverloadedFunction {" << endl;
s << INDENT << "graph [fontsize=12 fontname=freemono labelloc=t splines=true overlap=false rankdir=LR];" << endl;
@@ -964,7 +964,7 @@ QString OverloadData::dumpGraph() const
// Show default values (original and modified) for various functions
for (const AbstractMetaFunction *func : m_overloads) {
- const AbstractMetaArgument* arg = argument(func);
+ const AbstractMetaArgument *arg = argument(func);
if (!arg)
continue;
QString argDefault = ShibokenGenerator::getDefaultValue(func, arg);
@@ -989,7 +989,7 @@ QString OverloadData::dumpGraph() const
return result;
}
-int OverloadData::functionNumber(const AbstractMetaFunction* func) const
+int OverloadData::functionNumber(const AbstractMetaFunction *func) const
{
return m_headOverloadData->m_overloads.indexOf(func);
}
@@ -1010,7 +1010,7 @@ QString OverloadData::argumentTypeReplaced() const
return m_argTypeReplaced;
}
-bool OverloadData::hasArgumentWithDefaultValue(const AbstractMetaFunctionList& overloads)
+bool OverloadData::hasArgumentWithDefaultValue(const AbstractMetaFunctionList &overloads)
{
if (OverloadData::getMinMaxArguments(overloads).second == 0)
return false;
@@ -1032,7 +1032,7 @@ bool OverloadData::hasArgumentWithDefaultValue() const
return false;
}
-bool OverloadData::hasArgumentWithDefaultValue(const AbstractMetaFunction* func)
+bool OverloadData::hasArgumentWithDefaultValue(const AbstractMetaFunction *func)
{
const AbstractMetaArgumentList &arguments = func->arguments();
for (const AbstractMetaArgument *arg : arguments) {
@@ -1044,7 +1044,7 @@ bool OverloadData::hasArgumentWithDefaultValue(const AbstractMetaFunction* func)
return false;
}
-AbstractMetaArgumentList OverloadData::getArgumentsWithDefaultValues(const AbstractMetaFunction* func)
+AbstractMetaArgumentList OverloadData::getArgumentsWithDefaultValues(const AbstractMetaFunction *func)
{
AbstractMetaArgumentList args;
const AbstractMetaArgumentList &arguments = func->arguments();
diff --git a/sources/shiboken2/generator/shiboken2/overloaddata.h b/sources/shiboken2/generator/shiboken2/overloaddata.h
index 4759ca9c..4fd4199e 100644
--- a/sources/shiboken2/generator/shiboken2/overloaddata.h
+++ b/sources/shiboken2/generator/shiboken2/overloaddata.h
@@ -38,21 +38,21 @@ QT_FORWARD_DECLARE_CLASS(QDebug)
class ShibokenGenerator;
class OverloadData;
-typedef QVector<OverloadData *> OverloadDataList;
+using OverloadDataList = QVector<OverloadData *>;
class OverloadData
{
public:
- typedef QVector<const AbstractMetaFunction *> MetaFunctionList;
+ using MetaFunctionList = QVector<const AbstractMetaFunction *>;
- OverloadData(const AbstractMetaFunctionList& overloads, const ShibokenGenerator* generator);
+ OverloadData(const AbstractMetaFunctionList &overloads, const ShibokenGenerator *generator);
~OverloadData();
int minArgs() const { return m_headOverloadData->m_minArgs; }
int maxArgs() const { return m_headOverloadData->m_maxArgs; }
int argPos() const { return m_argPos; }
- const AbstractMetaType* argType() const { return m_argType; }
+ const AbstractMetaType *argType() const { return m_argType; }
/// Returns a string list containing all the possible return types (including void) for the current OverloadData.
QStringList returnTypes() const;
@@ -70,49 +70,49 @@ public:
bool hasStaticFunction() const;
/// Returns true if any of the overloads passed as argument is static.
- static bool hasStaticFunction(const AbstractMetaFunctionList& overloads);
+ static bool hasStaticFunction(const AbstractMetaFunctionList &overloads);
/// Returns true if any of the overloads for the current OverloadData is not static.
bool hasInstanceFunction() const;
/// Returns true if any of the overloads passed as argument is not static.
- static bool hasInstanceFunction(const AbstractMetaFunctionList& overloads);
+ static bool hasInstanceFunction(const AbstractMetaFunctionList &overloads);
/// Returns true if among the overloads for the current OverloadData there are static and non-static methods altogether.
bool hasStaticAndInstanceFunctions() const;
/// Returns true if among the overloads passed as argument there are static and non-static methods altogether.
- static bool hasStaticAndInstanceFunctions(const AbstractMetaFunctionList& overloads);
+ static bool hasStaticAndInstanceFunctions(const AbstractMetaFunctionList &overloads);
- const AbstractMetaFunction* referenceFunction() const;
- const AbstractMetaArgument* argument(const AbstractMetaFunction* func) const;
+ const AbstractMetaFunction *referenceFunction() const;
+ const AbstractMetaArgument *argument(const AbstractMetaFunction *func) const;
OverloadDataList overloadDataOnPosition(int argPos) const;
bool isHeadOverloadData() const { return this == m_headOverloadData; }
/// Returns the root OverloadData object that represents all the overloads.
- OverloadData* headOverloadData() const { return m_headOverloadData; }
+ OverloadData *headOverloadData() const { return m_headOverloadData; }
/// Returns the function that has a default value at the current OverloadData argument position, otherwise returns null.
- const AbstractMetaFunction* getFunctionWithDefaultValue() const;
+ const AbstractMetaFunction *getFunctionWithDefaultValue() const;
bool nextArgumentHasDefaultValue() const;
/// Returns the nearest occurrence, including this instance, of an argument with a default value.
- OverloadData* findNextArgWithDefault();
- bool isFinalOccurrence(const AbstractMetaFunction* func) const;
+ OverloadData *findNextArgWithDefault();
+ bool isFinalOccurrence(const AbstractMetaFunction *func) const;
/// Returns the list of overloads removing repeated constant functions (ex.: "foo()" and "foo()const", the second is removed).
MetaFunctionList overloadsWithoutRepetition() const;
- const MetaFunctionList& overloads() const { return m_overloads; }
+ const MetaFunctionList &overloads() const { return m_overloads; }
OverloadDataList nextOverloadData() const { return m_nextOverloadData; }
- OverloadData* previousOverloadData() const { return m_previousOverloadData; }
+ OverloadData *previousOverloadData() const { return m_previousOverloadData; }
QVector<int> invalidArgumentLengths() const;
- static int numberOfRemovedArguments(const AbstractMetaFunction* func, int finalArgPos = -1);
- static QPair<int, int> getMinMaxArguments(const AbstractMetaFunctionList& overloads);
+ static int numberOfRemovedArguments(const AbstractMetaFunction *func, int finalArgPos = -1);
+ static QPair<int, int> getMinMaxArguments(const AbstractMetaFunctionList &overloads);
/// Returns true if all overloads have no more than one argument.
- static bool isSingleArgument(const AbstractMetaFunctionList& overloads);
+ static bool isSingleArgument(const AbstractMetaFunctionList &overloads);
void dumpGraph(const QString &filename) const;
QString dumpGraph() const;
@@ -121,39 +121,39 @@ public:
QString argumentTypeReplaced() const;
bool hasArgumentWithDefaultValue() const;
- static bool hasArgumentWithDefaultValue(const AbstractMetaFunctionList& overloads);
- static bool hasArgumentWithDefaultValue(const AbstractMetaFunction* func);
+ static bool hasArgumentWithDefaultValue(const AbstractMetaFunctionList &overloads);
+ static bool hasArgumentWithDefaultValue(const AbstractMetaFunction *func);
/// Returns a list of function arguments which have default values and were not removed.
- static AbstractMetaArgumentList getArgumentsWithDefaultValues(const AbstractMetaFunction* func);
+ static AbstractMetaArgumentList getArgumentsWithDefaultValues(const AbstractMetaFunction *func);
#ifndef QT_NO_DEBUG_STREAM
void formatDebug(QDebug &) const;
#endif
private:
- OverloadData(OverloadData* headOverloadData, const AbstractMetaFunction* func,
- const AbstractMetaType* argType, int argPos);
+ OverloadData(OverloadData *headOverloadData, const AbstractMetaFunction *func,
+ const AbstractMetaType *argType, int argPos);
- void addOverload(const AbstractMetaFunction* func);
- OverloadData* addOverloadData(const AbstractMetaFunction* func, const AbstractMetaArgument* arg);
+ void addOverload(const AbstractMetaFunction *func);
+ OverloadData *addOverloadData(const AbstractMetaFunction *func, const AbstractMetaArgument *arg);
void sortNextOverloads();
- int functionNumber(const AbstractMetaFunction* func) const;
- OverloadDataList overloadDataOnPosition(OverloadData* overloadData, int argPos) const;
+ int functionNumber(const AbstractMetaFunction *func) const;
+ OverloadDataList overloadDataOnPosition(OverloadData *overloadData, int argPos) const;
int m_minArgs;
int m_maxArgs;
int m_argPos;
- const AbstractMetaType* m_argType;
+ const AbstractMetaType *m_argType;
QString m_argTypeReplaced;
MetaFunctionList m_overloads;
- OverloadData* m_headOverloadData;
+ OverloadData *m_headOverloadData;
OverloadDataList m_nextOverloadData;
- OverloadData* m_previousOverloadData;
- const ShibokenGenerator* m_generator;
+ OverloadData *m_previousOverloadData;
+ const ShibokenGenerator *m_generator;
};
#ifndef QT_NO_DEBUG_STREAM
diff --git a/sources/shiboken2/generator/shiboken2/shibokengenerator.cpp b/sources/shiboken2/generator/shiboken2/shibokengenerator.cpp
index 2b3b20c7..8e27777d 100644
--- a/sources/shiboken2/generator/shiboken2/shibokengenerator.cpp
+++ b/sources/shiboken2/generator/shiboken2/shibokengenerator.cpp
@@ -62,7 +62,7 @@ const char *SMART_POINTER_GETTER = "kSmartPointerGetter";
const char *CONV_RULE_OUT_VAR_SUFFIX = "_out";
const char *BEGIN_ALLOW_THREADS =
- "PyThreadState* _save = PyEval_SaveThread(); // Py_BEGIN_ALLOW_THREADS";
+ "PyThreadState *_save = PyEval_SaveThread(); // Py_BEGIN_ALLOW_THREADS";
const char *END_ALLOW_THREADS = "PyEval_RestoreThread(_save); // Py_END_ALLOW_THREADS";
//static void dumpFunction(AbstractMetaFunctionList lst);
@@ -277,15 +277,15 @@ void ShibokenGenerator::initKnownPythonTypes()
<< QLatin1String("PyObject*") << QLatin1String("PyObject *") << QLatin1String("PyTupleObject*");
}
-QString ShibokenGenerator::translateTypeForWrapperMethod(const AbstractMetaType* cType,
- const AbstractMetaClass* context,
+QString ShibokenGenerator::translateTypeForWrapperMethod(const AbstractMetaType *cType,
+ const AbstractMetaClass *context,
Options options) const
{
if (cType->isArray())
return translateTypeForWrapperMethod(cType->arrayElementType(), context, options) + QLatin1String("[]");
if (avoidProtectedHack() && cType->isEnum()) {
- const AbstractMetaEnum* metaEnum = findAbstractMetaEnum(cType);
+ const AbstractMetaEnum *metaEnum = findAbstractMetaEnum(cType);
if (metaEnum && metaEnum->isProtected())
return protectedEnumSurrogateName(metaEnum);
}
@@ -293,7 +293,7 @@ QString ShibokenGenerator::translateTypeForWrapperMethod(const AbstractMetaType*
return translateType(cType, context, options);
}
-bool ShibokenGenerator::shouldGenerateCppWrapper(const AbstractMetaClass* metaClass) const
+bool ShibokenGenerator::shouldGenerateCppWrapper(const AbstractMetaClass *metaClass) const
{
if (metaClass->isNamespace() || (metaClass->attributes() & AbstractMetaAttributes::FinalCppClass))
return false;
@@ -320,7 +320,7 @@ bool ShibokenGenerator::shouldGenerateCppWrapper(const AbstractMetaClass* metaCl
return result;
}
-void ShibokenGenerator::lookForEnumsInClassesNotToBeGenerated(AbstractMetaEnumList& enumList, const AbstractMetaClass* metaClass)
+void ShibokenGenerator::lookForEnumsInClassesNotToBeGenerated(AbstractMetaEnumList &enumList, const AbstractMetaClass *metaClass)
{
if (!metaClass)
return;
@@ -330,17 +330,17 @@ void ShibokenGenerator::lookForEnumsInClassesNotToBeGenerated(AbstractMetaEnumLi
for (const AbstractMetaEnum *metaEnum : enums) {
if (metaEnum->isPrivate() || metaEnum->typeEntry()->codeGeneration() == TypeEntry::GenerateForSubclass)
continue;
- if (!enumList.contains(const_cast<AbstractMetaEnum*>(metaEnum)))
- enumList.append(const_cast<AbstractMetaEnum*>(metaEnum));
+ if (!enumList.contains(const_cast<AbstractMetaEnum *>(metaEnum)))
+ enumList.append(const_cast<AbstractMetaEnum *>(metaEnum));
}
lookForEnumsInClassesNotToBeGenerated(enumList, metaClass->enclosingClass());
}
}
-static const AbstractMetaClass* getProperEnclosingClass(const AbstractMetaClass* metaClass)
+static const AbstractMetaClass *getProperEnclosingClass(const AbstractMetaClass *metaClass)
{
if (!metaClass)
- return 0;
+ return nullptr;
if (metaClass->typeEntry()->codeGeneration() != TypeEntry::GenerateForSubclass)
return metaClass;
@@ -348,12 +348,12 @@ static const AbstractMetaClass* getProperEnclosingClass(const AbstractMetaClass*
return getProperEnclosingClass(metaClass->enclosingClass());
}
-const AbstractMetaClass* ShibokenGenerator::getProperEnclosingClassForEnum(const AbstractMetaEnum* metaEnum)
+const AbstractMetaClass *ShibokenGenerator::getProperEnclosingClassForEnum(const AbstractMetaEnum *metaEnum)
{
return getProperEnclosingClass(metaEnum->enclosingClass());
}
-QString ShibokenGenerator::wrapperName(const AbstractMetaClass* metaClass) const
+QString ShibokenGenerator::wrapperName(const AbstractMetaClass *metaClass) const
{
if (shouldGenerateCppWrapper(metaClass)) {
QString result = metaClass->name();
@@ -403,22 +403,22 @@ QString ShibokenGenerator::fullPythonFunctionName(const AbstractMetaFunction *fu
return funcName;
}
-QString ShibokenGenerator::protectedEnumSurrogateName(const AbstractMetaEnum* metaEnum)
+QString ShibokenGenerator::protectedEnumSurrogateName(const AbstractMetaEnum *metaEnum)
{
return metaEnum->fullName().replace(QLatin1Char('.'), QLatin1Char('_')).replace(QLatin1String("::"), QLatin1String("_")) + QLatin1String("_Surrogate");
}
-QString ShibokenGenerator::protectedFieldGetterName(const AbstractMetaField* field)
+QString ShibokenGenerator::protectedFieldGetterName(const AbstractMetaField *field)
{
return QStringLiteral("protected_%1_getter").arg(field->name());
}
-QString ShibokenGenerator::protectedFieldSetterName(const AbstractMetaField* field)
+QString ShibokenGenerator::protectedFieldSetterName(const AbstractMetaField *field)
{
return QStringLiteral("protected_%1_setter").arg(field->name());
}
-QString ShibokenGenerator::cpythonFunctionName(const AbstractMetaFunction* func)
+QString ShibokenGenerator::cpythonFunctionName(const AbstractMetaFunction *func)
{
QString result;
@@ -442,35 +442,35 @@ QString ShibokenGenerator::cpythonFunctionName(const AbstractMetaFunction* func)
return result;
}
-QString ShibokenGenerator::cpythonMethodDefinitionName(const AbstractMetaFunction* func)
+QString ShibokenGenerator::cpythonMethodDefinitionName(const AbstractMetaFunction *func)
{
if (!func->ownerClass())
return QString();
return QStringLiteral("%1Method_%2").arg(cpythonBaseName(func->ownerClass()->typeEntry()), func->name());
}
-QString ShibokenGenerator::cpythonGettersSettersDefinitionName(const AbstractMetaClass* metaClass)
+QString ShibokenGenerator::cpythonGettersSettersDefinitionName(const AbstractMetaClass *metaClass)
{
return cpythonBaseName(metaClass) + QLatin1String("_getsetlist");
}
-QString ShibokenGenerator::cpythonSetattroFunctionName(const AbstractMetaClass* metaClass)
+QString ShibokenGenerator::cpythonSetattroFunctionName(const AbstractMetaClass *metaClass)
{
return cpythonBaseName(metaClass) + QLatin1String("_setattro");
}
-QString ShibokenGenerator::cpythonGetattroFunctionName(const AbstractMetaClass* metaClass)
+QString ShibokenGenerator::cpythonGetattroFunctionName(const AbstractMetaClass *metaClass)
{
return cpythonBaseName(metaClass) + QLatin1String("_getattro");
}
-QString ShibokenGenerator::cpythonGetterFunctionName(const AbstractMetaField* metaField)
+QString ShibokenGenerator::cpythonGetterFunctionName(const AbstractMetaField *metaField)
{
return QStringLiteral("%1_get_%2").arg(cpythonBaseName(metaField->enclosingClass()), metaField->name());
}
-QString ShibokenGenerator::cpythonSetterFunctionName(const AbstractMetaField* metaField)
+QString ShibokenGenerator::cpythonSetterFunctionName(const AbstractMetaField *metaField)
{
return QStringLiteral("%1_set_%2").arg(cpythonBaseName(metaField->enclosingClass()), metaField->name());
}
@@ -484,7 +484,7 @@ static QString cpythonEnumFlagsName(const QString &moduleName,
}
// Return the scope for fully qualifying the enumeration including trailing "::".
-static QString searchForEnumScope(const AbstractMetaClass* metaClass, const QString& value)
+static QString searchForEnumScope(const AbstractMetaClass *metaClass, const QString &value)
{
if (!metaClass)
return QString();
@@ -587,7 +587,7 @@ QString ShibokenGenerator::guessScopeForDefaultValue(const AbstractMetaFunction
QString prefix;
if (arg->type()->isEnum()) {
- if (const AbstractMetaEnum* metaEnum = findAbstractMetaEnum(arg->type()))
+ if (const AbstractMetaEnum *metaEnum = findAbstractMetaEnum(arg->type()))
prefix = resolveScopePrefix(metaEnum, value);
} else if (arg->type()->isFlags()) {
value = guessScopeForDefaultFlagsValue(func, arg, value);
@@ -626,7 +626,7 @@ QString ShibokenGenerator::guessScopeForDefaultValue(const AbstractMetaFunction
return value;
}
-QString ShibokenGenerator::cpythonEnumName(const EnumTypeEntry* enumEntry)
+QString ShibokenGenerator::cpythonEnumName(const EnumTypeEntry *enumEntry)
{
QString p = enumEntry->targetLangPackage();
p.replace(QLatin1Char('.'), QLatin1Char('_'));
@@ -638,7 +638,7 @@ QString ShibokenGenerator::cpythonEnumName(const AbstractMetaEnum *metaEnum)
return cpythonEnumName(metaEnum->typeEntry());
}
-QString ShibokenGenerator::cpythonFlagsName(const FlagsTypeEntry* flagsEntry)
+QString ShibokenGenerator::cpythonFlagsName(const FlagsTypeEntry *flagsEntry)
{
QString p = flagsEntry->targetLangPackage();
p.replace(QLatin1Char('.'), QLatin1Char('_'));
@@ -653,12 +653,12 @@ QString ShibokenGenerator::cpythonFlagsName(const AbstractMetaEnum *metaEnum)
return cpythonFlagsName(flags);
}
-QString ShibokenGenerator::cpythonSpecialCastFunctionName(const AbstractMetaClass* metaClass)
+QString ShibokenGenerator::cpythonSpecialCastFunctionName(const AbstractMetaClass *metaClass)
{
return cpythonBaseName(metaClass->typeEntry()) + QLatin1String("SpecialCastFunction");
}
-QString ShibokenGenerator::cpythonWrapperCPtr(const AbstractMetaClass* metaClass,
+QString ShibokenGenerator::cpythonWrapperCPtr(const AbstractMetaClass *metaClass,
const QString &argName)
{
return cpythonWrapperCPtr(metaClass->typeEntry(), argName);
@@ -674,7 +674,7 @@ QString ShibokenGenerator::cpythonWrapperCPtr(const AbstractMetaType *metaType,
+ QLatin1String(", reinterpret_cast<SbkObject *>(") + argName + QLatin1String(")))");
}
-QString ShibokenGenerator::cpythonWrapperCPtr(const TypeEntry* type,
+QString ShibokenGenerator::cpythonWrapperCPtr(const TypeEntry *type,
const QString &argName)
{
if (!ShibokenGenerator::isWrapperType(type))
@@ -684,31 +684,31 @@ QString ShibokenGenerator::cpythonWrapperCPtr(const TypeEntry* type,
+ QLatin1String(", reinterpret_cast<SbkObject *>(") + argName + QLatin1String(")))");
}
-void ShibokenGenerator::writeToPythonConversion(QTextStream & s, const AbstractMetaType* type,
+void ShibokenGenerator::writeToPythonConversion(QTextStream & s, const AbstractMetaType *type,
const AbstractMetaClass * /* context */,
- const QString& argumentName)
+ const QString &argumentName)
{
s << cpythonToPythonConversionFunction(type) << argumentName << ')';
}
-void ShibokenGenerator::writeToCppConversion(QTextStream& s, const AbstractMetaClass* metaClass,
- const QString& inArgName, const QString& outArgName)
+void ShibokenGenerator::writeToCppConversion(QTextStream &s, const AbstractMetaClass *metaClass,
+ const QString &inArgName, const QString &outArgName)
{
s << cpythonToCppConversionFunction(metaClass) << inArgName << ", &" << outArgName << ')';
}
-void ShibokenGenerator::writeToCppConversion(QTextStream& s, const AbstractMetaType* type, const AbstractMetaClass* context,
- const QString& inArgName, const QString& outArgName)
+void ShibokenGenerator::writeToCppConversion(QTextStream &s, const AbstractMetaType *type, const AbstractMetaClass *context,
+ const QString &inArgName, const QString &outArgName)
{
s << cpythonToCppConversionFunction(type, context) << inArgName << ", &" << outArgName << ')';
}
-bool ShibokenGenerator::shouldRejectNullPointerArgument(const AbstractMetaFunction* func, int argIndex)
+bool ShibokenGenerator::shouldRejectNullPointerArgument(const AbstractMetaFunction *func, int argIndex)
{
if (argIndex < 0 || argIndex >= func->arguments().count())
return false;
- const AbstractMetaArgument* arg = func->arguments().at(argIndex);
+ const AbstractMetaArgument *arg = func->arguments().at(argIndex);
if (isValueTypeWithCopyConstructorOnly(arg->type()))
return true;
@@ -728,7 +728,7 @@ bool ShibokenGenerator::shouldRejectNullPointerArgument(const AbstractMetaFuncti
return false;
}
-QString ShibokenGenerator::getFormatUnitString(const AbstractMetaFunction* func, bool incRef) const
+QString ShibokenGenerator::getFormatUnitString(const AbstractMetaFunction *func, bool incRef) const
{
QString result;
const char objType = (incRef ? 'O' : 'N');
@@ -750,7 +750,7 @@ QString ShibokenGenerator::getFormatUnitString(const AbstractMetaFunction* func,
|| arg->type()->referenceType() == LValueReference) {
result += QLatin1Char(objType);
} else if (arg->type()->isPrimitive()) {
- const PrimitiveTypeEntry *ptype =
+ const auto *ptype =
static_cast<const PrimitiveTypeEntry *>(arg->type()->typeEntry());
if (ptype->basicReferencedTypeEntry())
ptype = ptype->basicReferencedTypeEntry();
@@ -772,25 +772,25 @@ QString ShibokenGenerator::getFormatUnitString(const AbstractMetaFunction* func,
return result;
}
-QString ShibokenGenerator::cpythonBaseName(const AbstractMetaType* type)
+QString ShibokenGenerator::cpythonBaseName(const AbstractMetaType *type)
{
if (isCString(type))
return QLatin1String("PyString");
return cpythonBaseName(type->typeEntry());
}
-QString ShibokenGenerator::cpythonBaseName(const AbstractMetaClass* metaClass)
+QString ShibokenGenerator::cpythonBaseName(const AbstractMetaClass *metaClass)
{
return cpythonBaseName(metaClass->typeEntry());
}
-QString ShibokenGenerator::cpythonBaseName(const TypeEntry* type)
+QString ShibokenGenerator::cpythonBaseName(const TypeEntry *type)
{
QString baseName;
if (ShibokenGenerator::isWrapperType(type) || type->isNamespace()) { // && type->referenceType() == NoReference) {
baseName = QLatin1String("Sbk_") + type->name();
} else if (type->isPrimitive()) {
- const PrimitiveTypeEntry *ptype = static_cast<const PrimitiveTypeEntry *>(type);
+ const auto *ptype = static_cast<const PrimitiveTypeEntry *>(type);
while (ptype->basicReferencedTypeEntry())
ptype = ptype->basicReferencedTypeEntry();
if (ptype->targetLangApiName() == ptype->name())
@@ -802,7 +802,7 @@ QString ShibokenGenerator::cpythonBaseName(const TypeEntry* type)
} else if (type->isFlags()) {
baseName = cpythonFlagsName(static_cast<const FlagsTypeEntry *>(type));
} else if (type->isContainer()) {
- const ContainerTypeEntry *ctype = static_cast<const ContainerTypeEntry *>(type);
+ const auto *ctype = static_cast<const ContainerTypeEntry *>(type);
switch (ctype->type()) {
case ContainerTypeEntry::ListContainer:
case ContainerTypeEntry::StringListContainer:
@@ -834,28 +834,28 @@ QString ShibokenGenerator::cpythonBaseName(const TypeEntry* type)
return baseName.replace(QLatin1String("::"), QLatin1String("_"));
}
-QString ShibokenGenerator::cpythonTypeName(const AbstractMetaClass* metaClass)
+QString ShibokenGenerator::cpythonTypeName(const AbstractMetaClass *metaClass)
{
return cpythonTypeName(metaClass->typeEntry());
}
-QString ShibokenGenerator::cpythonTypeName(const TypeEntry* type)
+QString ShibokenGenerator::cpythonTypeName(const TypeEntry *type)
{
return cpythonBaseName(type) + QLatin1String("_TypeF()");
}
-QString ShibokenGenerator::cpythonTypeNameExt(const TypeEntry* type)
+QString ShibokenGenerator::cpythonTypeNameExt(const TypeEntry *type)
{
return cppApiVariableName(type->targetLangPackage()) + QLatin1Char('[')
+ getTypeIndexVariableName(type) + QLatin1Char(']');
}
-QString ShibokenGenerator::converterObject(const AbstractMetaType* type)
+QString ShibokenGenerator::converterObject(const AbstractMetaType *type)
{
if (isCString(type))
- return QLatin1String("Shiboken::Conversions::PrimitiveTypeConverter<const char*>()");
+ return QLatin1String("Shiboken::Conversions::PrimitiveTypeConverter<const char *>()");
if (isVoidPointer(type))
- return QLatin1String("Shiboken::Conversions::PrimitiveTypeConverter<void*>()");
+ return QLatin1String("Shiboken::Conversions::PrimitiveTypeConverter<void *>()");
const AbstractMetaTypeCList nestedArrayTypes = type->nestedArrayTypes();
if (!nestedArrayTypes.isEmpty() && nestedArrayTypes.constLast()->isCppPrimitive()) {
return QStringLiteral("Shiboken::Conversions::ArrayTypeConverter<")
@@ -870,7 +870,7 @@ QString ShibokenGenerator::converterObject(const AbstractMetaType* type)
return converterObject(type->typeEntry());
}
-QString ShibokenGenerator::converterObject(const TypeEntry* type)
+QString ShibokenGenerator::converterObject(const TypeEntry *type)
{
if (isCppPrimitive(type))
return QString::fromLatin1("Shiboken::Conversions::PrimitiveTypeConverter<%1>()").arg(type->qualifiedCppName());
@@ -883,7 +883,7 @@ QString ShibokenGenerator::converterObject(const TypeEntry* type)
}
/* the typedef'd primitive types case */
- const PrimitiveTypeEntry* pte = dynamic_cast<const PrimitiveTypeEntry*>(type);
+ const auto *pte = dynamic_cast<const PrimitiveTypeEntry *>(type);
if (!pte) {
qDebug() << "Warning: the Qt5 primitive type is unknown" << type->qualifiedCppName();
return QString();
@@ -897,7 +897,7 @@ QString ShibokenGenerator::converterObject(const TypeEntry* type)
+ QLatin1Char('[') + getTypeIndexVariableName(type) + QLatin1Char(']');
}
-QString ShibokenGenerator::cpythonTypeNameExt(const AbstractMetaType* type)
+QString ShibokenGenerator::cpythonTypeNameExt(const AbstractMetaType *type)
{
return cppApiVariableName(type->typeEntry()->targetLangPackage()) + QLatin1Char('[')
+ getTypeIndexVariableName(type) + QLatin1Char(']');
@@ -905,13 +905,13 @@ QString ShibokenGenerator::cpythonTypeNameExt(const AbstractMetaType* type)
static inline QString unknownOperator() { return QStringLiteral("__UNKNOWN_OPERATOR__"); }
-QString ShibokenGenerator::fixedCppTypeName(const CustomConversion::TargetToNativeConversion* toNative)
+QString ShibokenGenerator::fixedCppTypeName(const CustomConversion::TargetToNativeConversion *toNative)
{
if (toNative->sourceType())
return fixedCppTypeName(toNative->sourceType());
return toNative->sourceTypeName();
}
-QString ShibokenGenerator::fixedCppTypeName(const AbstractMetaType* type)
+QString ShibokenGenerator::fixedCppTypeName(const AbstractMetaType *type)
{
return fixedCppTypeName(type->typeEntry(), type->cppSignature());
}
@@ -928,7 +928,7 @@ static QString _fixedCppTypeName(QString typeName)
typeName.replace(QLatin1String("&"), QLatin1String("REF"));
return typeName;
}
-QString ShibokenGenerator::fixedCppTypeName(const TypeEntry* type, QString typeName)
+QString ShibokenGenerator::fixedCppTypeName(const TypeEntry *type, QString typeName)
{
if (typeName.isEmpty())
typeName = type->qualifiedCppName();
@@ -939,7 +939,7 @@ QString ShibokenGenerator::fixedCppTypeName(const TypeEntry* type, QString typeN
return _fixedCppTypeName(typeName);
}
-QString ShibokenGenerator::pythonPrimitiveTypeName(const QString& cppTypeName)
+QString ShibokenGenerator::pythonPrimitiveTypeName(const QString &cppTypeName)
{
QString rv = ShibokenGenerator::m_pythonPrimitiveTypeName.value(cppTypeName, QString());
if (rv.isEmpty()) {
@@ -955,7 +955,7 @@ QString ShibokenGenerator::pythonPrimitiveTypeName(const QString& cppTypeName)
return rv;
}
-QString ShibokenGenerator::pythonPrimitiveTypeName(const PrimitiveTypeEntry* type)
+QString ShibokenGenerator::pythonPrimitiveTypeName(const PrimitiveTypeEntry *type)
{
while (type->basicReferencedTypeEntry())
type = type->basicReferencedTypeEntry();
@@ -972,7 +972,7 @@ QString ShibokenGenerator::pythonOperatorFunctionName(const QString &cppOpFuncNa
return value;
}
-QString ShibokenGenerator::pythonOperatorFunctionName(const AbstractMetaFunction* func)
+QString ShibokenGenerator::pythonOperatorFunctionName(const AbstractMetaFunction *func)
{
QString op = pythonOperatorFunctionName(func->originalName());
if (op == unknownOperator())
@@ -995,7 +995,7 @@ QString ShibokenGenerator::pythonRichCompareOperatorId(const QString &cppOpFuncN
return QLatin1String("Py_") + m_pythonOperators.value(cppOpFuncName).toUpper();
}
-QString ShibokenGenerator::pythonRichCompareOperatorId(const AbstractMetaFunction* func)
+QString ShibokenGenerator::pythonRichCompareOperatorId(const AbstractMetaFunction *func)
{
return pythonRichCompareOperatorId(func->originalName());
}
@@ -1008,19 +1008,19 @@ bool ShibokenGenerator::isNumber(const QString &cpythonApiName)
|| cpythonApiName == QLatin1String("PyBool");
}
-bool ShibokenGenerator::isNumber(const TypeEntry* type)
+bool ShibokenGenerator::isNumber(const TypeEntry *type)
{
if (!type->isPrimitive())
return false;
return isNumber(pythonPrimitiveTypeName(static_cast<const PrimitiveTypeEntry *>(type)));
}
-bool ShibokenGenerator::isNumber(const AbstractMetaType* type)
+bool ShibokenGenerator::isNumber(const AbstractMetaType *type)
{
return isNumber(type->typeEntry());
}
-bool ShibokenGenerator::isPyInt(const TypeEntry* type)
+bool ShibokenGenerator::isPyInt(const TypeEntry *type)
{
if (!type->isPrimitive())
return false;
@@ -1028,39 +1028,39 @@ bool ShibokenGenerator::isPyInt(const TypeEntry* type)
== QLatin1String("PyInt");
}
-bool ShibokenGenerator::isPyInt(const AbstractMetaType* type)
+bool ShibokenGenerator::isPyInt(const AbstractMetaType *type)
{
return isPyInt(type->typeEntry());
}
-bool ShibokenGenerator::isWrapperType(const TypeEntry* type)
+bool ShibokenGenerator::isWrapperType(const TypeEntry *type)
{
if (type->isComplex())
return ShibokenGenerator::isWrapperType(static_cast<const ComplexTypeEntry *>(type));
return type->isObject() || type->isValue() || type->isSmartPointer();
}
-bool ShibokenGenerator::isWrapperType(const ComplexTypeEntry* type)
+bool ShibokenGenerator::isWrapperType(const ComplexTypeEntry *type)
{
return isObjectType(type) || type->isValue() || type->isSmartPointer();
}
-bool ShibokenGenerator::isWrapperType(const AbstractMetaType* metaType)
+bool ShibokenGenerator::isWrapperType(const AbstractMetaType *metaType)
{
return isObjectType(metaType)
|| metaType->typeEntry()->isValue()
|| metaType->typeEntry()->isSmartPointer();
}
-bool ShibokenGenerator::isPointerToWrapperType(const AbstractMetaType* type)
+bool ShibokenGenerator::isPointerToWrapperType(const AbstractMetaType *type)
{
return (isObjectType(type) && type->indirections() == 1) || type->isValuePointer();
}
-bool ShibokenGenerator::isObjectTypeUsedAsValueType(const AbstractMetaType* type)
+bool ShibokenGenerator::isObjectTypeUsedAsValueType(const AbstractMetaType *type)
{
return type->typeEntry()->isObject() && type->referenceType() == NoReference && type->indirections() == 0;
}
-bool ShibokenGenerator::isValueTypeWithCopyConstructorOnly(const AbstractMetaClass* metaClass)
+bool ShibokenGenerator::isValueTypeWithCopyConstructorOnly(const AbstractMetaClass *metaClass)
{
if (!metaClass || !metaClass->typeEntry()->isValue())
return false;
@@ -1086,51 +1086,51 @@ bool ShibokenGenerator::isValueTypeWithCopyConstructorOnly(const AbstractMetaCla
return copyConstructorFound;
}
-bool ShibokenGenerator::isValueTypeWithCopyConstructorOnly(const TypeEntry* type) const
+bool ShibokenGenerator::isValueTypeWithCopyConstructorOnly(const TypeEntry *type) const
{
if (!type || !type->isValue())
return false;
return isValueTypeWithCopyConstructorOnly(AbstractMetaClass::findClass(classes(), type));
}
-bool ShibokenGenerator::isValueTypeWithCopyConstructorOnly(const AbstractMetaType* type) const
+bool ShibokenGenerator::isValueTypeWithCopyConstructorOnly(const AbstractMetaType *type) const
{
if (!type || !type->typeEntry()->isValue())
return false;
return isValueTypeWithCopyConstructorOnly(type->typeEntry());
}
-bool ShibokenGenerator::isUserPrimitive(const TypeEntry* type)
+bool ShibokenGenerator::isUserPrimitive(const TypeEntry *type)
{
if (!type->isPrimitive())
return false;
- const PrimitiveTypeEntry *trueType = static_cast<const PrimitiveTypeEntry *>(type);
+ const auto *trueType = static_cast<const PrimitiveTypeEntry *>(type);
if (trueType->basicReferencedTypeEntry())
trueType = trueType->basicReferencedTypeEntry();
return trueType->isPrimitive() && !trueType->isCppPrimitive()
&& trueType->qualifiedCppName() != QLatin1String("std::string");
}
-bool ShibokenGenerator::isUserPrimitive(const AbstractMetaType* type)
+bool ShibokenGenerator::isUserPrimitive(const AbstractMetaType *type)
{
if (type->indirections() != 0)
return false;
return isUserPrimitive(type->typeEntry());
}
-bool ShibokenGenerator::isCppPrimitive(const TypeEntry* type)
+bool ShibokenGenerator::isCppPrimitive(const TypeEntry *type)
{
if (type->isCppPrimitive())
return true;
if (!type->isPrimitive())
return false;
- const PrimitiveTypeEntry *trueType = static_cast<const PrimitiveTypeEntry *>(type);
+ const auto *trueType = static_cast<const PrimitiveTypeEntry *>(type);
if (trueType->basicReferencedTypeEntry())
trueType = trueType->basicReferencedTypeEntry();
return trueType->qualifiedCppName() == QLatin1String("std::string");
}
-bool ShibokenGenerator::isCppPrimitive(const AbstractMetaType* type)
+bool ShibokenGenerator::isCppPrimitive(const AbstractMetaType *type)
{
if (isCString(type) || isVoidPointer(type))
return true;
@@ -1139,17 +1139,17 @@ bool ShibokenGenerator::isCppPrimitive(const AbstractMetaType* type)
return isCppPrimitive(type->typeEntry());
}
-bool ShibokenGenerator::shouldDereferenceArgumentPointer(const AbstractMetaArgument* arg)
+bool ShibokenGenerator::shouldDereferenceArgumentPointer(const AbstractMetaArgument *arg)
{
return shouldDereferenceAbstractMetaTypePointer(arg->type());
}
-bool ShibokenGenerator::shouldDereferenceAbstractMetaTypePointer(const AbstractMetaType* metaType)
+bool ShibokenGenerator::shouldDereferenceAbstractMetaTypePointer(const AbstractMetaType *metaType)
{
return metaType->referenceType() == LValueReference && isWrapperType(metaType) && !isPointer(metaType);
}
-bool ShibokenGenerator::visibilityModifiedToPrivate(const AbstractMetaFunction* func)
+bool ShibokenGenerator::visibilityModifiedToPrivate(const AbstractMetaFunction *func)
{
const FunctionModificationList &mods = func->modifications();
for (const FunctionModification &mod : mods) {
@@ -1159,11 +1159,11 @@ bool ShibokenGenerator::visibilityModifiedToPrivate(const AbstractMetaFunction*
return false;
}
-QString ShibokenGenerator::cpythonCheckFunction(const AbstractMetaType* metaType, bool genericNumberType)
+QString ShibokenGenerator::cpythonCheckFunction(const AbstractMetaType *metaType, bool genericNumberType)
{
QString customCheck;
if (metaType->typeEntry()->isCustom()) {
- AbstractMetaType* type;
+ AbstractMetaType *type;
customCheck = guessCPythonCheckFunction(metaType->typeEntry()->name(), &type);
if (type)
metaType = type;
@@ -1189,7 +1189,7 @@ QString ShibokenGenerator::cpythonCheckFunction(const AbstractMetaType* metaType
|| type == ContainerTypeEntry::StackContainer
|| type == ContainerTypeEntry::SetContainer
|| type == ContainerTypeEntry::QueueContainer) {
- const AbstractMetaType* type = metaType->instantiations().constFirst();
+ const AbstractMetaType *type = metaType->instantiations().constFirst();
if (isPointerToWrapperType(type)) {
typeCheck += QString::fromLatin1("checkSequenceTypes(%1, ").arg(cpythonTypeNameExt(type));
} else if (isWrapperType(type)) {
@@ -1205,8 +1205,8 @@ QString ShibokenGenerator::cpythonCheckFunction(const AbstractMetaType* metaType
|| type == ContainerTypeEntry::MultiHashContainer
|| type == ContainerTypeEntry::PairContainer) {
QString pyType = (type == ContainerTypeEntry::PairContainer) ? QLatin1String("Pair") : QLatin1String("Dict");
- const AbstractMetaType* firstType = metaType->instantiations().constFirst();
- const AbstractMetaType* secondType = metaType->instantiations().constLast();
+ const AbstractMetaType *firstType = metaType->instantiations().constFirst();
+ const AbstractMetaType *secondType = metaType->instantiations().constLast();
if (isPointerToWrapperType(firstType) && isPointerToWrapperType(secondType)) {
typeCheck += QString::fromLatin1("check%1Types(%2, %3, ")
.arg(pyType, cpythonTypeNameExt(firstType), cpythonTypeNameExt(secondType));
@@ -1223,11 +1223,11 @@ QString ShibokenGenerator::cpythonCheckFunction(const AbstractMetaType* metaType
return cpythonCheckFunction(metaType->typeEntry(), genericNumberType);
}
-QString ShibokenGenerator::cpythonCheckFunction(const TypeEntry* type, bool genericNumberType)
+QString ShibokenGenerator::cpythonCheckFunction(const TypeEntry *type, bool genericNumberType)
{
QString customCheck;
if (type->isCustom()) {
- AbstractMetaType* metaType;
+ AbstractMetaType *metaType;
customCheck = guessCPythonCheckFunction(type->name(), &metaType);
if (metaType)
return cpythonCheckFunction(metaType, genericNumberType);
@@ -1250,9 +1250,9 @@ QString ShibokenGenerator::cpythonCheckFunction(const TypeEntry* type, bool gene
return typeCheck;
}
-QString ShibokenGenerator::guessCPythonCheckFunction(const QString& type, AbstractMetaType** metaType)
+QString ShibokenGenerator::guessCPythonCheckFunction(const QString &type, AbstractMetaType **metaType)
{
- *metaType = 0;
+ *metaType = nullptr;
if (type == QLatin1String("PyTypeObject"))
return QLatin1String("PyType_Check");
@@ -1269,7 +1269,7 @@ QString ShibokenGenerator::guessCPythonCheckFunction(const QString& type, Abstra
return type + QLatin1String("_Check");
}
-QString ShibokenGenerator::cpythonIsConvertibleFunction(const TypeEntry* type,
+QString ShibokenGenerator::cpythonIsConvertibleFunction(const TypeEntry *type,
bool /* genericNumberType */,
bool /* checkExact */)
{
@@ -1285,12 +1285,12 @@ QString ShibokenGenerator::cpythonIsConvertibleFunction(const TypeEntry* type,
return QString::fromLatin1("Shiboken::Conversions::isPythonToCppConvertible(%1, ")
.arg(converterObject(type));
}
-QString ShibokenGenerator::cpythonIsConvertibleFunction(const AbstractMetaType* metaType,
+QString ShibokenGenerator::cpythonIsConvertibleFunction(const AbstractMetaType *metaType,
bool /* genericNumberType */)
{
QString customCheck;
if (metaType->typeEntry()->isCustom()) {
- AbstractMetaType* type;
+ AbstractMetaType *type;
customCheck = guessCPythonCheckFunction(metaType->typeEntry()->name(), &type);
if (type)
metaType = type;
@@ -1329,7 +1329,7 @@ QString ShibokenGenerator::cpythonIsConvertibleFunction(const AbstractMetaArgume
return cpythonIsConvertibleFunction(metaArg->type(), genericNumberType);
}
-QString ShibokenGenerator::cpythonToCppConversionFunction(const AbstractMetaClass* metaClass)
+QString ShibokenGenerator::cpythonToCppConversionFunction(const AbstractMetaClass *metaClass)
{
return QLatin1String("Shiboken::Conversions::pythonToCppPointer(reinterpret_cast<SbkObjectType *>(")
+ cpythonTypeNameExt(metaClass->typeEntry()) + QLatin1String("), ");
@@ -1371,12 +1371,12 @@ QString ShibokenGenerator::cpythonToPythonConversionFunction(const AbstractMetaT
(isCString(type) || isVoidPointer(type)) ? QString() : QLatin1String("&"));
}
-QString ShibokenGenerator::cpythonToPythonConversionFunction(const AbstractMetaClass* metaClass)
+QString ShibokenGenerator::cpythonToPythonConversionFunction(const AbstractMetaClass *metaClass)
{
return cpythonToPythonConversionFunction(metaClass->typeEntry());
}
-QString ShibokenGenerator::cpythonToPythonConversionFunction(const TypeEntry* type)
+QString ShibokenGenerator::cpythonToPythonConversionFunction(const TypeEntry *type)
{
if (isWrapperType(type)) {
const QString conversion = type->isValue() ? QLatin1String("copy") : QLatin1String("pointer");
@@ -1463,7 +1463,7 @@ void ShibokenGenerator::writeFunctionArguments(QTextStream &s,
}
}
-QString ShibokenGenerator::functionReturnType(const AbstractMetaFunction* func, Options options) const
+QString ShibokenGenerator::functionReturnType(const AbstractMetaFunction *func, Options options) const
{
QString modifiedReturnType = QString(func->typeReplaced(0));
if (!modifiedReturnType.isEmpty() && !(options & OriginalTypeDescription))
@@ -1510,18 +1510,18 @@ void ShibokenGenerator::writeArgumentNames(QTextStream &s,
const AbstractMetaFunction *func,
Options options) const
{
- AbstractMetaArgumentList arguments = func->arguments();
+ const AbstractMetaArgumentList arguments = func->arguments();
int argCount = 0;
- for (int j = 0, max = arguments.size(); j < max; j++) {
-
- if ((options & Generator::SkipRemovedArguments) && (func->argumentRemoved(arguments.at(j)->argumentIndex()+1)))
+ for (auto argument : arguments) {
+ const int index = argument->argumentIndex() + 1;
+ if ((options & Generator::SkipRemovedArguments) && (func->argumentRemoved(index)))
continue;
- s << ((argCount > 0) ? ", " : "") << arguments.at(j)->name();
+ s << ((argCount > 0) ? ", " : "") << argument->name();
if (((options & Generator::VirtualCall) == 0)
- && (!func->conversionRule(TypeSystem::NativeCode, arguments.at(j)->argumentIndex() + 1).isEmpty()
- || !func->conversionRule(TypeSystem::TargetLangCode, arguments.at(j)->argumentIndex() + 1).isEmpty())
+ && (!func->conversionRule(TypeSystem::NativeCode, index).isEmpty()
+ || !func->conversionRule(TypeSystem::TargetLangCode, index).isEmpty())
&& !func->isConstructor()) {
s << CONV_RULE_OUT_VAR_SUFFIX;
}
@@ -1530,8 +1530,8 @@ void ShibokenGenerator::writeArgumentNames(QTextStream &s,
}
}
-void ShibokenGenerator::writeFunctionCall(QTextStream& s,
- const AbstractMetaFunction* func,
+void ShibokenGenerator::writeFunctionCall(QTextStream &s,
+ const AbstractMetaFunction *func,
Options options) const
{
if (!(options & Generator::SkipName))
@@ -1541,12 +1541,12 @@ void ShibokenGenerator::writeFunctionCall(QTextStream& s,
s << ')';
}
-void ShibokenGenerator::writeUnusedVariableCast(QTextStream& s, const QString& variableName)
+void ShibokenGenerator::writeUnusedVariableCast(QTextStream &s, const QString &variableName)
{
s << INDENT << "SBK_UNUSED(" << variableName<< ')' << endl;
}
-AbstractMetaFunctionList ShibokenGenerator::filterFunctions(const AbstractMetaClass* metaClass)
+AbstractMetaFunctionList ShibokenGenerator::filterFunctions(const AbstractMetaClass *metaClass)
{
AbstractMetaFunctionList result;
const AbstractMetaFunctionList &funcs = metaClass->functions();
@@ -1572,7 +1572,7 @@ ShibokenGenerator::ExtendedConverterData ShibokenGenerator::getExtendedConverter
for (AbstractMetaFunction *convOp : overloads) {
// Get only the conversion operators that return a type from another module,
// that are value-types and were not removed in the type system.
- const TypeEntry* convType = convOp->type()->typeEntry();
+ const TypeEntry *convType = convOp->type()->typeEntry();
if ((convType->codeGeneration() & TypeEntry::GenerateTargetLang)
|| !convType->isValue()
|| convOp->isModifiedRemoved())
@@ -1585,7 +1585,7 @@ ShibokenGenerator::ExtendedConverterData ShibokenGenerator::getExtendedConverter
QVector<const CustomConversion *> ShibokenGenerator::getPrimitiveCustomConversions()
{
- QVector<const CustomConversion*> conversions;
+ QVector<const CustomConversion *> conversions;
const PrimitiveTypeEntryList &primitiveTypeList = primitiveTypes();
for (const PrimitiveTypeEntry *type : primitiveTypeList) {
if (!shouldGenerateTypeEntry(type) || !isUserPrimitive(type) || !type->customConversion())
@@ -1596,7 +1596,7 @@ QVector<const CustomConversion *> ShibokenGenerator::getPrimitiveCustomConversio
return conversions;
}
-static QString getArgumentsFromMethodCall(const QString& str)
+static QString getArgumentsFromMethodCall(const QString &str)
{
// It would be way nicer to be able to use a Perl like
// regular expression that accepts temporary variables
@@ -1624,7 +1624,7 @@ static QString getArgumentsFromMethodCall(const QString& str)
return str.mid(begin, pos-begin-1);
}
-QString ShibokenGenerator::getCodeSnippets(const CodeSnipList& codeSnips,
+QString ShibokenGenerator::getCodeSnippets(const CodeSnipList &codeSnips,
TypeSystem::CodeSnipPosition position,
TypeSystem::Language language)
{
@@ -1640,7 +1640,7 @@ QString ShibokenGenerator::getCodeSnippets(const CodeSnipList& codeSnips,
}
return code;
}
-void ShibokenGenerator::processCodeSnip(QString& code, const AbstractMetaClass* context)
+void ShibokenGenerator::processCodeSnip(QString &code, const AbstractMetaClass *context)
{
if (context) {
// Replace template variable by the Python Type object
@@ -1664,16 +1664,16 @@ void ShibokenGenerator::processCodeSnip(QString& code, const AbstractMetaClass*
replaceTypeCheckTypeSystemVariable(code);
}
-ShibokenGenerator::ArgumentVarReplacementList ShibokenGenerator::getArgumentReplacement(const AbstractMetaFunction* func,
+ShibokenGenerator::ArgumentVarReplacementList ShibokenGenerator::getArgumentReplacement(const AbstractMetaFunction *func,
bool usePyArgs, TypeSystem::Language language,
- const AbstractMetaArgument* lastArg)
+ const AbstractMetaArgument *lastArg)
{
ArgumentVarReplacementList argReplacements;
TypeSystem::Language convLang = (language == TypeSystem::TargetLangCode)
? TypeSystem::NativeCode : TypeSystem::TargetLangCode;
int removed = 0;
for (int i = 0; i < func->arguments().size(); ++i) {
- const AbstractMetaArgument* arg = func->arguments().at(i);
+ const AbstractMetaArgument *arg = func->arguments().at(i);
QString argValue;
if (language == TypeSystem::TargetLangCode) {
bool hasConversionRule = !func->conversionRule(convLang, i+1).isEmpty();
@@ -1686,10 +1686,10 @@ ShibokenGenerator::ArgumentVarReplacementList ShibokenGenerator::getArgumentRepl
argValue = QLatin1String(CPP_ARG_REMOVED) + QString::number(i);
if (!argRemoved && argValue.isEmpty()) {
int argPos = i - removed;
- const AbstractMetaType* type = arg->type();
+ const AbstractMetaType *type = arg->type();
QString typeReplaced = func->typeReplaced(arg->argumentIndex() + 1);
if (!typeReplaced.isEmpty()) {
- AbstractMetaType* builtType = buildAbstractMetaTypeFromString(typeReplaced);
+ AbstractMetaType *builtType = buildAbstractMetaTypeFromString(typeReplaced);
if (builtType)
type = builtType;
}
@@ -1716,11 +1716,11 @@ ShibokenGenerator::ArgumentVarReplacementList ShibokenGenerator::getArgumentRepl
return argReplacements;
}
-void ShibokenGenerator::writeCodeSnips(QTextStream& s,
- const CodeSnipList& codeSnips,
+void ShibokenGenerator::writeCodeSnips(QTextStream &s,
+ const CodeSnipList &codeSnips,
TypeSystem::CodeSnipPosition position,
TypeSystem::Language language,
- const AbstractMetaClass* context)
+ const AbstractMetaClass *context)
{
QString code = getCodeSnippets(codeSnips, position, language);
if (code.isEmpty())
@@ -1731,12 +1731,12 @@ void ShibokenGenerator::writeCodeSnips(QTextStream& s,
s << INDENT << "// End of code injection" << endl;
}
-void ShibokenGenerator::writeCodeSnips(QTextStream& s,
- const CodeSnipList& codeSnips,
+void ShibokenGenerator::writeCodeSnips(QTextStream &s,
+ const CodeSnipList &codeSnips,
TypeSystem::CodeSnipPosition position,
TypeSystem::Language language,
- const AbstractMetaFunction* func,
- const AbstractMetaArgument* lastArg)
+ const AbstractMetaFunction *func,
+ const AbstractMetaArgument *lastArg)
{
QString code = getCodeSnippets(codeSnips, position, language);
if (code.isEmpty())
@@ -1842,14 +1842,14 @@ void ShibokenGenerator::writeCodeSnips(QTextStream& s,
QString wrapperClassName = wrapperName(func->ownerClass());
QString cppSelfVar = avoidProtectedHack()
? QLatin1String("%CPPSELF")
- : QStringLiteral("reinterpret_cast<%1*>(%CPPSELF)").arg(wrapperClassName);
+ : QStringLiteral("reinterpret_cast<%1 *>(%CPPSELF)").arg(wrapperClassName);
code.replace(pattern,
- QString::fromLatin1("(Shiboken::Object::hasCppWrapper(reinterpret_cast<SbkObject*>(%1))"
+ QString::fromLatin1("(Shiboken::Object::hasCppWrapper(reinterpret_cast<SbkObject *>(%1))"
" ? %2->::%3::%FUNCTION_NAME(%4)"
" : %CPPSELF.%FUNCTION_NAME(%4))").arg(pySelf, cppSelfVar, wrapperClassName, methodCallArgs));
} else {
code.replace(pattern,
- QString::fromLatin1("(Shiboken::Object::hasCppWrapper(reinterpret_cast<SbkObject*>(%1))"
+ QString::fromLatin1("(Shiboken::Object::hasCppWrapper(reinterpret_cast<SbkObject *>(%1))"
" ? %CPPSELF->::%TYPE::%FUNCTION_NAME(%2)"
" : %CPPSELF.%FUNCTION_NAME(%2))").arg(pySelf, methodCallArgs));
}
@@ -1892,12 +1892,12 @@ void ShibokenGenerator::writeCodeSnips(QTextStream& s,
code.replace(QLatin1String("%ARGUMENT_NAMES"), args.join(QLatin1String(", ")));
for (const ArgumentVarReplacementPair &pair : argReplacements) {
- const AbstractMetaArgument* arg = pair.first;
+ const AbstractMetaArgument *arg = pair.first;
int idx = arg->argumentIndex() + 1;
- AbstractMetaType* type = arg->type();
+ AbstractMetaType *type = arg->type();
QString typeReplaced = func->typeReplaced(arg->argumentIndex() + 1);
if (!typeReplaced.isEmpty()) {
- AbstractMetaType* builtType = buildAbstractMetaTypeFromString(typeReplaced);
+ AbstractMetaType *builtType = buildAbstractMetaTypeFromString(typeReplaced);
if (builtType)
type = builtType;
}
@@ -1960,7 +1960,7 @@ void ShibokenGenerator::writeCodeSnips(QTextStream& s,
// Returns true if the string is an expression,
// and false if it is a variable.
-static bool isVariable(const QString& code)
+static bool isVariable(const QString &code)
{
static const QRegularExpression expr(QStringLiteral("^\\s*\\*?\\s*[A-Za-z_][A-Za-z_0-9.]*\\s*(?:\\[[^\\[]+\\])*$"));
Q_ASSERT(expr.isValid());
@@ -1970,7 +1970,7 @@ static bool isVariable(const QString& code)
// A miniature normalizer that puts a type string into a format
// suitable for comparison with AbstractMetaType::cppSignature()
// result.
-static QString miniNormalizer(const QString& varType)
+static QString miniNormalizer(const QString &varType)
{
QString normalized = varType.trimmed();
if (normalized.isEmpty())
@@ -1989,7 +1989,7 @@ static QString miniNormalizer(const QString& varType)
// The position must indicate the first character after the opening '('.
// ATTENTION: do not modify this function to trim any resulting string!
// This must be done elsewhere.
-static QString getConverterTypeSystemVariableArgument(const QString& code, int pos)
+static QString getConverterTypeSystemVariableArgument(const QString &code, int pos)
{
QString arg;
int parenthesisDepth = 0;
@@ -2011,9 +2011,9 @@ static QString getConverterTypeSystemVariableArgument(const QString& code, int p
qFatal("Unbalanced parenthesis on type system converter variable call.");
return arg;
}
-typedef QPair<QString, QString> StringPair;
+using StringPair = QPair<QString, QString>;
-void ShibokenGenerator::replaceConverterTypeSystemVariable(TypeSystemConverterVariable converterVariable, QString& code)
+void ShibokenGenerator::replaceConverterTypeSystemVariable(TypeSystemConverterVariable converterVariable, QString &code)
{
QVector<StringPair> replacements;
QRegularExpressionMatchIterator rit = m_typeSystemConvRegEx[converterVariable].globalMatch(code);
@@ -2105,7 +2105,7 @@ void ShibokenGenerator::replaceConverterTypeSystemVariable(TypeSystemConverterVa
code.replace(rep.first, rep.second);
}
-bool ShibokenGenerator::injectedCodeUsesPySelf(const AbstractMetaFunction* func)
+bool ShibokenGenerator::injectedCodeUsesPySelf(const AbstractMetaFunction *func)
{
CodeSnipList snips = func->injectedCodeSnips(TypeSystem::CodeSnipPositionAny, TypeSystem::NativeCode);
for (const CodeSnip &snip : qAsConst(snips)) {
@@ -2115,7 +2115,7 @@ bool ShibokenGenerator::injectedCodeUsesPySelf(const AbstractMetaFunction* func)
return false;
}
-bool ShibokenGenerator::injectedCodeCallsCppFunction(const AbstractMetaFunction* func)
+bool ShibokenGenerator::injectedCodeCallsCppFunction(const AbstractMetaFunction *func)
{
QString funcCall = func->originalName() + QLatin1Char('(');
QString wrappedCtorCall;
@@ -2135,7 +2135,7 @@ bool ShibokenGenerator::injectedCodeCallsCppFunction(const AbstractMetaFunction*
return false;
}
-bool ShibokenGenerator::injectedCodeCallsPythonOverride(const AbstractMetaFunction* func)
+bool ShibokenGenerator::injectedCodeCallsPythonOverride(const AbstractMetaFunction *func)
{
static const QRegularExpression overrideCallRegexCheck(QStringLiteral("PyObject_Call\\s*\\(\\s*%PYTHON_METHOD_OVERRIDE\\s*,"));
Q_ASSERT(overrideCallRegexCheck.isValid());
@@ -2147,7 +2147,7 @@ bool ShibokenGenerator::injectedCodeCallsPythonOverride(const AbstractMetaFuncti
return false;
}
-bool ShibokenGenerator::injectedCodeHasReturnValueAttribution(const AbstractMetaFunction* func, TypeSystem::Language language)
+bool ShibokenGenerator::injectedCodeHasReturnValueAttribution(const AbstractMetaFunction *func, TypeSystem::Language language)
{
static const QRegularExpression retValAttributionRegexCheck_native(QStringLiteral("%0\\s*=[^=]\\s*.+"));
Q_ASSERT(retValAttributionRegexCheck_native.isValid());
@@ -2166,7 +2166,7 @@ bool ShibokenGenerator::injectedCodeHasReturnValueAttribution(const AbstractMeta
return false;
}
-bool ShibokenGenerator::injectedCodeUsesArgument(const AbstractMetaFunction* func, int argumentIndex)
+bool ShibokenGenerator::injectedCodeUsesArgument(const AbstractMetaFunction *func, int argumentIndex)
{
CodeSnipList snips = func->injectedCodeSnips(TypeSystem::CodeSnipPositionAny);
const QRegularExpression argRegEx = placeHolderRegex(argumentIndex + 1);
@@ -2178,12 +2178,12 @@ bool ShibokenGenerator::injectedCodeUsesArgument(const AbstractMetaFunction* fun
return false;
}
-bool ShibokenGenerator::classNeedsGetattroFunction(const AbstractMetaClass* metaClass)
+bool ShibokenGenerator::classNeedsGetattroFunction(const AbstractMetaClass *metaClass)
{
return getGeneratorClassInfo(metaClass).needsGetattroFunction;
}
-bool ShibokenGenerator::classNeedsGetattroFunctionImpl(const AbstractMetaClass* metaClass)
+bool ShibokenGenerator::classNeedsGetattroFunctionImpl(const AbstractMetaClass *metaClass)
{
if (!metaClass)
return false;
@@ -2214,7 +2214,7 @@ bool ShibokenGenerator::classNeedsSetattroFunction(const AbstractMetaClass *meta
return metaClass->typeEntry()->isSmartPointer();
}
-AbstractMetaFunctionList ShibokenGenerator::getMethodsWithBothStaticAndNonStaticMethods(const AbstractMetaClass* metaClass)
+AbstractMetaFunctionList ShibokenGenerator::getMethodsWithBothStaticAndNonStaticMethods(const AbstractMetaClass *metaClass)
{
AbstractMetaFunctionList methods;
if (metaClass) {
@@ -2237,7 +2237,7 @@ AbstractMetaFunctionList ShibokenGenerator::getMethodsWithBothStaticAndNonStatic
return methods;
}
-AbstractMetaClassList ShibokenGenerator::getBaseClasses(const AbstractMetaClass* metaClass) const
+AbstractMetaClassList ShibokenGenerator::getBaseClasses(const AbstractMetaClass *metaClass) const
{
AbstractMetaClassList baseClasses;
if (metaClass) {
@@ -2257,7 +2257,7 @@ AbstractMetaClassList ShibokenGenerator::getBaseClasses(const AbstractMetaClass*
return baseClasses;
}
-const AbstractMetaClass* ShibokenGenerator::getMultipleInheritingClass(const AbstractMetaClass* metaClass)
+const AbstractMetaClass *ShibokenGenerator::getMultipleInheritingClass(const AbstractMetaClass *metaClass)
{
if (!metaClass || metaClass->baseClassNames().isEmpty())
return nullptr;
@@ -2266,7 +2266,7 @@ const AbstractMetaClass* ShibokenGenerator::getMultipleInheritingClass(const Abs
return getMultipleInheritingClass(metaClass->baseClass());
}
-AbstractMetaClassList ShibokenGenerator::getAllAncestors(const AbstractMetaClass* metaClass) const
+AbstractMetaClassList ShibokenGenerator::getAllAncestors(const AbstractMetaClass *metaClass) const
{
AbstractMetaClassList result;
if (metaClass) {
@@ -2279,7 +2279,7 @@ AbstractMetaClassList ShibokenGenerator::getAllAncestors(const AbstractMetaClass
return result;
}
-QString ShibokenGenerator::getModuleHeaderFileName(const QString& moduleName) const
+QString ShibokenGenerator::getModuleHeaderFileName(const QString &moduleName) const
{
return moduleCppPrefix(moduleName).toLower() + QLatin1String("_python.h");
}
@@ -2316,14 +2316,14 @@ AbstractMetaType *ShibokenGenerator::buildAbstractMetaTypeFromString(QString typ
return it.value();
}
-AbstractMetaType* ShibokenGenerator::buildAbstractMetaTypeFromTypeEntry(const TypeEntry* typeEntry)
+AbstractMetaType *ShibokenGenerator::buildAbstractMetaTypeFromTypeEntry(const TypeEntry *typeEntry)
{
QString typeName = typeEntry->qualifiedCppName();
if (typeName.startsWith(QLatin1String("::")))
typeName.remove(0, 2);
if (m_metaTypeFromStringCache.contains(typeName))
return m_metaTypeFromStringCache.value(typeName);
- AbstractMetaType* metaType = new AbstractMetaType;
+ auto *metaType = new AbstractMetaType;
metaType->setTypeEntry(typeEntry);
metaType->clearIndirections();
metaType->setReferenceType(NoReference);
@@ -2332,7 +2332,7 @@ AbstractMetaType* ShibokenGenerator::buildAbstractMetaTypeFromTypeEntry(const Ty
m_metaTypeFromStringCache.insert(typeName, metaType);
return metaType;
}
-AbstractMetaType* ShibokenGenerator::buildAbstractMetaTypeFromAbstractMetaClass(const AbstractMetaClass* metaClass)
+AbstractMetaType *ShibokenGenerator::buildAbstractMetaTypeFromAbstractMetaClass(const AbstractMetaClass *metaClass)
{
return ShibokenGenerator::buildAbstractMetaTypeFromTypeEntry(metaClass->typeEntry());
}
@@ -2354,7 +2354,7 @@ static void dumpFunction(AbstractMetaFunctionList lst)
}
*/
-static bool isGroupable(const AbstractMetaFunction* func)
+static bool isGroupable(const AbstractMetaFunction *func)
{
if (func->isSignal() || func->isDestructor() || (func->isModifiedRemoved() && !func->isAbstract()))
return false;
@@ -2422,13 +2422,13 @@ ShibokenGenerator::FunctionGroups ShibokenGenerator::getFunctionGroupsImpl(const
AbstractMetaFunctionList ShibokenGenerator::getInheritedOverloads(const AbstractMetaFunction *func, QSet<QString> *seen)
{
AbstractMetaFunctionList results;
- AbstractMetaClass* basis;
+ AbstractMetaClass *basis;
if (func->ownerClass() && (basis = func->ownerClass()->baseClass())) {
for (; basis; basis = basis->baseClass()) {
- const AbstractMetaFunction* inFunc = basis->findFunction(func->name());
+ const AbstractMetaFunction *inFunc = basis->findFunction(func->name());
if (inFunc && !seen->contains(inFunc->minimalSignature())) {
seen->insert(inFunc->minimalSignature());
- AbstractMetaFunction* newFunc = inFunc->copy();
+ AbstractMetaFunction *newFunc = inFunc->copy();
newFunc->setImplementingClass(func->implementingClass());
results << newFunc;
}
@@ -2445,7 +2445,7 @@ AbstractMetaFunctionList ShibokenGenerator::getFunctionAndInheritedOverloads(con
return results;
}
-AbstractMetaFunctionList ShibokenGenerator::getFunctionOverloads(const AbstractMetaClass* scope, const QString& functionName)
+AbstractMetaFunctionList ShibokenGenerator::getFunctionOverloads(const AbstractMetaClass *scope, const QString &functionName)
{
AbstractMetaFunctionList lst = scope ? scope->functions() : globalFunctions();
@@ -2500,24 +2500,24 @@ bool ShibokenGenerator::handleOption(const QString &key, const QString & /* valu
return false;
}
-static void getCode(QStringList& code, const CodeSnipList& codeSnips)
+static void getCode(QStringList &code, const CodeSnipList &codeSnips)
{
for (const CodeSnip &snip : qAsConst(codeSnips))
code.append(snip.code());
}
-static void getCode(QStringList& code, const TypeEntry* type)
+static void getCode(QStringList &code, const TypeEntry *type)
{
getCode(code, type->codeSnips());
- CustomConversion* customConversion = type->customConversion();
+ CustomConversion *customConversion = type->customConversion();
if (!customConversion)
return;
if (!customConversion->nativeToTargetConversion().isEmpty())
code.append(customConversion->nativeToTargetConversion());
- const CustomConversion::TargetToNativeConversions& toCppConversions = customConversion->targetToNativeConversions();
+ const CustomConversion::TargetToNativeConversions &toCppConversions = customConversion->targetToNativeConversions();
if (toCppConversions.isEmpty())
return;
@@ -2556,7 +2556,7 @@ bool ShibokenGenerator::doSetup()
return true;
}
-void ShibokenGenerator::collectContainerTypesFromConverterMacros(const QString& code, bool toPythonMacro)
+void ShibokenGenerator::collectContainerTypesFromConverterMacros(const QString &code, bool toPythonMacro)
{
QString convMacro = toPythonMacro ? QLatin1String("%CONVERTTOPYTHON[") : QLatin1String("%CONVERTTOCPP[");
int offset = toPythonMacro ? sizeof("%CONVERTTOPYTHON") : sizeof("%CONVERTTOCPP");
@@ -2566,7 +2566,7 @@ void ShibokenGenerator::collectContainerTypesFromConverterMacros(const QString&
start += offset;
if (code.at(start) != QLatin1Char('%')) {
QString typeString = code.mid(start, end - start);
- AbstractMetaType* type = buildAbstractMetaTypeFromString(typeString);
+ AbstractMetaType *type = buildAbstractMetaTypeFromString(typeString);
addInstantiatedContainersAndSmartPointers(type, type->originalTypeDescription());
}
start = end;
@@ -2598,26 +2598,26 @@ bool ShibokenGenerator::avoidProtectedHack() const
return m_avoidProtectedHack;
}
-QString ShibokenGenerator::moduleCppPrefix(const QString& moduleName) const
+QString ShibokenGenerator::moduleCppPrefix(const QString &moduleName) const
{
QString result = moduleName.isEmpty() ? packageName() : moduleName;
result.replace(QLatin1Char('.'), QLatin1Char('_'));
return result;
}
-QString ShibokenGenerator::cppApiVariableName(const QString& moduleName) const
+QString ShibokenGenerator::cppApiVariableName(const QString &moduleName) const
{
return QLatin1String("Sbk") + moduleCppPrefix(moduleName)
+ QLatin1String("Types");
}
-QString ShibokenGenerator::pythonModuleObjectName(const QString& moduleName) const
+QString ShibokenGenerator::pythonModuleObjectName(const QString &moduleName) const
{
return QLatin1String("Sbk") + moduleCppPrefix(moduleName)
+ QLatin1String("ModuleObject");
}
-QString ShibokenGenerator::convertersVariableName(const QString& moduleName) const
+QString ShibokenGenerator::convertersVariableName(const QString &moduleName) const
{
QString result = cppApiVariableName(moduleName);
result.chop(1);
@@ -2625,7 +2625,7 @@ QString ShibokenGenerator::convertersVariableName(const QString& moduleName) con
return result;
}
-static QString processInstantiationsVariableName(const AbstractMetaType* type)
+static QString processInstantiationsVariableName(const AbstractMetaType *type)
{
QString res = QLatin1Char('_') + _fixedCppTypeName(type->typeEntry()->qualifiedCppName()).toUpper();
const AbstractMetaTypeList &instantiations = type->instantiations();
@@ -2644,10 +2644,10 @@ static void appendIndexSuffix(QString *s)
s->append(QStringLiteral("IDX"));
}
-QString ShibokenGenerator::getTypeIndexVariableName(const AbstractMetaClass* metaClass, bool alternativeTemplateName)
+QString ShibokenGenerator::getTypeIndexVariableName(const AbstractMetaClass *metaClass, bool alternativeTemplateName)
{
if (alternativeTemplateName) {
- const AbstractMetaClass* templateBaseClass = metaClass->templateBaseClass();
+ const AbstractMetaClass *templateBaseClass = metaClass->templateBaseClass();
if (!templateBaseClass)
return QString();
QString result = QLatin1String("SBK_")
@@ -2660,10 +2660,10 @@ QString ShibokenGenerator::getTypeIndexVariableName(const AbstractMetaClass* met
}
return getTypeIndexVariableName(metaClass->typeEntry());
}
-QString ShibokenGenerator::getTypeIndexVariableName(const TypeEntry* type)
+QString ShibokenGenerator::getTypeIndexVariableName(const TypeEntry *type)
{
if (type->isCppPrimitive()) {
- const PrimitiveTypeEntry *trueType = static_cast<const PrimitiveTypeEntry*>(type);
+ const auto *trueType = static_cast<const PrimitiveTypeEntry *>(type);
if (trueType->basicReferencedTypeEntry())
type = trueType->basicReferencedTypeEntry();
}
@@ -2678,7 +2678,7 @@ QString ShibokenGenerator::getTypeIndexVariableName(const TypeEntry* type)
appendIndexSuffix(&result);
return result;
}
-QString ShibokenGenerator::getTypeIndexVariableName(const AbstractMetaType* type)
+QString ShibokenGenerator::getTypeIndexVariableName(const AbstractMetaType *type)
{
QString result = QLatin1String("SBK");
if (type->typeEntry()->isContainer())
@@ -2693,7 +2693,7 @@ bool ShibokenGenerator::verboseErrorMessagesDisabled() const
return m_verboseErrorMessagesDisabled;
}
-bool ShibokenGenerator::pythonFunctionWrapperUsesListOfArguments(const OverloadData& overloadData)
+bool ShibokenGenerator::pythonFunctionWrapperUsesListOfArguments(const OverloadData &overloadData)
{
if (overloadData.referenceFunction()->isCallOperator())
return true;
@@ -2707,7 +2707,7 @@ bool ShibokenGenerator::pythonFunctionWrapperUsesListOfArguments(const OverloadD
|| overloadData.hasArgumentWithDefaultValue();
}
-QString ShibokenGenerator::getDefaultValue(const AbstractMetaFunction* func, const AbstractMetaArgument* arg)
+QString ShibokenGenerator::getDefaultValue(const AbstractMetaFunction *func, const AbstractMetaArgument *arg)
{
if (!arg->defaultValueExpression().isEmpty())
return arg->defaultValueExpression();
@@ -2723,7 +2723,7 @@ QString ShibokenGenerator::getDefaultValue(const AbstractMetaFunction* func, co
return QString();
}
-void ShibokenGenerator::writeMinimalConstructorExpression(QTextStream& s, const AbstractMetaType* type, const QString& defaultCtor)
+void ShibokenGenerator::writeMinimalConstructorExpression(QTextStream &s, const AbstractMetaType *type, const QString &defaultCtor)
{
if (!defaultCtor.isEmpty()) {
s << " = " << defaultCtor;
@@ -2741,7 +2741,7 @@ void ShibokenGenerator::writeMinimalConstructorExpression(QTextStream& s, const
}
}
-void ShibokenGenerator::writeMinimalConstructorExpression(QTextStream& s, const TypeEntry* type, const QString& defaultCtor)
+void ShibokenGenerator::writeMinimalConstructorExpression(QTextStream &s, const TypeEntry *type, const QString &defaultCtor)
{
if (!defaultCtor.isEmpty()) {
s << " = " << defaultCtor;
@@ -2759,11 +2759,11 @@ void ShibokenGenerator::writeMinimalConstructorExpression(QTextStream& s, const
}
}
-bool ShibokenGenerator::isCppIntegralPrimitive(const TypeEntry* type)
+bool ShibokenGenerator::isCppIntegralPrimitive(const TypeEntry *type)
{
if (!type->isCppPrimitive())
return false;
- const PrimitiveTypeEntry *trueType = static_cast<const PrimitiveTypeEntry *>(type);
+ const auto *trueType = static_cast<const PrimitiveTypeEntry *>(type);
if (trueType->basicReferencedTypeEntry())
trueType = trueType->basicReferencedTypeEntry();
QString typeName = trueType->qualifiedCppName();
@@ -2771,7 +2771,7 @@ bool ShibokenGenerator::isCppIntegralPrimitive(const TypeEntry* type)
&& !typeName.contains(QLatin1String("float"))
&& !typeName.contains(QLatin1String("wchar"));
}
-bool ShibokenGenerator::isCppIntegralPrimitive(const AbstractMetaType* type)
+bool ShibokenGenerator::isCppIntegralPrimitive(const AbstractMetaType *type)
{
return isCppIntegralPrimitive(type->typeEntry());
}
diff --git a/sources/shiboken2/generator/shiboken2/shibokengenerator.h b/sources/shiboken2/generator/shiboken2/shibokengenerator.h
index f5f29152..84b3137b 100644
--- a/sources/shiboken2/generator/shiboken2/shibokengenerator.h
+++ b/sources/shiboken2/generator/shiboken2/shibokengenerator.h
@@ -74,16 +74,16 @@ public:
/**
* Helper function to find for argument default value
*/
- static QString getDefaultValue(const AbstractMetaFunction* func, const AbstractMetaArgument* arg);
+ static QString getDefaultValue(const AbstractMetaFunction *func, const AbstractMetaArgument *arg);
/// Returns a list of all ancestor classes for the given class.
- AbstractMetaClassList getAllAncestors(const AbstractMetaClass* metaClass) const;
+ AbstractMetaClassList getAllAncestors(const AbstractMetaClass *metaClass) const;
protected:
bool doSetup() override;
void writeArgumentNames(QTextStream &s,
- const AbstractMetaFunction* func,
+ const AbstractMetaFunction *func,
Options options = NoOption) const override;
/**
@@ -94,7 +94,7 @@ protected:
* \param options some extra options used during the parser
*/
void writeFunctionArguments(QTextStream &s,
- const AbstractMetaFunction* func,
+ const AbstractMetaFunction *func,
Options options = NoOption) const override;
/**
@@ -114,21 +114,21 @@ protected:
AbstractMetaFunctionList getFunctionAndInheritedOverloads(const AbstractMetaFunction *func, QSet<QString> *seen);
/// Write user's custom code snippets at class or module level.
- void writeCodeSnips(QTextStream& s,
+ void writeCodeSnips(QTextStream &s,
const QVector<CodeSnip> & codeSnips,
TypeSystem::CodeSnipPosition position,
TypeSystem::Language language,
- const AbstractMetaClass* context = 0);
+ const AbstractMetaClass *context = nullptr);
/// Write user's custom code snippets at function level.
- void writeCodeSnips(QTextStream& s,
+ void writeCodeSnips(QTextStream &s,
const QVector<CodeSnip> & codeSnips,
TypeSystem::CodeSnipPosition position,
TypeSystem::Language language,
- const AbstractMetaFunction* func,
- const AbstractMetaArgument* lastArg = 0);
+ const AbstractMetaFunction *func,
+ const AbstractMetaArgument *lastArg = nullptr);
/// Replaces variables for the user's custom code at global or class level.
- void processCodeSnip(QString& code, const AbstractMetaClass* context = 0);
+ void processCodeSnip(QString &code, const AbstractMetaClass *context = nullptr);
/**
* Verifies if any of the function's code injections of the "native"
@@ -136,7 +136,7 @@ protected:
* \param func the function to check
* \return true if the function's native code snippets use "%PYSELF"
*/
- bool injectedCodeUsesPySelf(const AbstractMetaFunction* func);
+ bool injectedCodeUsesPySelf(const AbstractMetaFunction *func);
/**
* Verifies if any of the function's code injections makes a call
@@ -145,7 +145,7 @@ protected:
* \param func the function to check
* \return true if the function's code snippets call the wrapped C++ function
*/
- bool injectedCodeCallsCppFunction(const AbstractMetaFunction* func);
+ bool injectedCodeCallsCppFunction(const AbstractMetaFunction *func);
/**
* Verifies if any of the function's code injections of the "native" class makes a
@@ -154,7 +154,7 @@ protected:
* \param func the function to check
* \return true if the function's code snippets call the Python override for a C++ virtual method
*/
- bool injectedCodeCallsPythonOverride(const AbstractMetaFunction* func);
+ bool injectedCodeCallsPythonOverride(const AbstractMetaFunction *func);
/**
* Verifies if any of the function's code injections attributes values to
@@ -163,13 +163,13 @@ protected:
* \param language the kind of code snip
* \return true if the function's code attributes values to "%0" or "%PYARG_0"
*/
- bool injectedCodeHasReturnValueAttribution(const AbstractMetaFunction* func, TypeSystem::Language language = TypeSystem::TargetLangCode);
+ bool injectedCodeHasReturnValueAttribution(const AbstractMetaFunction *func, TypeSystem::Language language = TypeSystem::TargetLangCode);
/**
* Verifies if any of the function's code injections uses the type system variable
* for function arguments of a given index.
*/
- bool injectedCodeUsesArgument(const AbstractMetaFunction* func, int argumentIndex);
+ bool injectedCodeUsesArgument(const AbstractMetaFunction *func, int argumentIndex);
/**
* Function which parse the metafunction information
@@ -177,125 +177,125 @@ protected:
* \param option some extra options
* \param arg_count the number of function arguments
*/
- QString functionSignature(const AbstractMetaFunction* func,
+ QString functionSignature(const AbstractMetaFunction *func,
const QString &prepend = QString(),
const QString &append = QString(),
Options options = NoOption,
int arg_count = -1) const;
/// Returns the top-most class that has multiple inheritance in the ancestry.
- static const AbstractMetaClass *getMultipleInheritingClass(const AbstractMetaClass* metaClass);
+ static const AbstractMetaClass *getMultipleInheritingClass(const AbstractMetaClass *metaClass);
/// Returns true if the class needs to have a getattro function.
- bool classNeedsGetattroFunction(const AbstractMetaClass* metaClass);
+ bool classNeedsGetattroFunction(const AbstractMetaClass *metaClass);
/// Returns true if the class needs to have a setattro function.
bool classNeedsSetattroFunction(const AbstractMetaClass *metaClass);
/// Returns a list of methods of the given class where each one is part of a different overload with both static and non-static method.
- AbstractMetaFunctionList getMethodsWithBothStaticAndNonStaticMethods(const AbstractMetaClass* metaClass);
+ AbstractMetaFunctionList getMethodsWithBothStaticAndNonStaticMethods(const AbstractMetaClass *metaClass);
/// Returns a list of parent classes for a given class.
- AbstractMetaClassList getBaseClasses(const AbstractMetaClass* metaClass) const;
+ AbstractMetaClassList getBaseClasses(const AbstractMetaClass *metaClass) const;
- void writeToPythonConversion(QTextStream& s, const AbstractMetaType* type,
- const AbstractMetaClass* context, const QString& argumentName);
- void writeToCppConversion(QTextStream& s, const AbstractMetaType* type, const AbstractMetaClass* context, const QString& inArgName, const QString& outArgName);
- void writeToCppConversion(QTextStream& s, const AbstractMetaClass* metaClass, const QString& inArgName, const QString& outArgName);
+ void writeToPythonConversion(QTextStream &s, const AbstractMetaType *type,
+ const AbstractMetaClass *context, const QString &argumentName);
+ void writeToCppConversion(QTextStream &s, const AbstractMetaType *type, const AbstractMetaClass *context, const QString &inArgName, const QString &outArgName);
+ void writeToCppConversion(QTextStream &s, const AbstractMetaClass *metaClass, const QString &inArgName, const QString &outArgName);
/// Returns true if the argument is a pointer that rejects nullptr values.
- bool shouldRejectNullPointerArgument(const AbstractMetaFunction* func, int argIndex);
+ bool shouldRejectNullPointerArgument(const AbstractMetaFunction *func, int argIndex);
/// Verifies if the class should have a C++ wrapper generated for it, instead of only a Python wrapper.
- bool shouldGenerateCppWrapper(const AbstractMetaClass* metaClass) const;
+ bool shouldGenerateCppWrapper(const AbstractMetaClass *metaClass) const;
/// Adds enums eligible for generation from classes/namespaces marked not to be generated.
- static void lookForEnumsInClassesNotToBeGenerated(AbstractMetaEnumList& enumList, const AbstractMetaClass* metaClass);
+ static void lookForEnumsInClassesNotToBeGenerated(AbstractMetaEnumList &enumList, const AbstractMetaClass *metaClass);
/// Returns the enclosing class for an enum, or nullptr if it should be global.
- const AbstractMetaClass* getProperEnclosingClassForEnum(const AbstractMetaEnum* metaEnum);
+ const AbstractMetaClass *getProperEnclosingClassForEnum(const AbstractMetaEnum *metaEnum);
- QString wrapperName(const AbstractMetaClass* metaClass) const;
+ QString wrapperName(const AbstractMetaClass *metaClass) const;
QString wrapperName(const AbstractMetaType *metaType) const;
QString fullPythonClassName(const AbstractMetaClass *metaClass);
QString fullPythonFunctionName(const AbstractMetaFunction *func);
- static QString protectedEnumSurrogateName(const AbstractMetaEnum* metaEnum);
- static QString protectedFieldGetterName(const AbstractMetaField* field);
- static QString protectedFieldSetterName(const AbstractMetaField* field);
+ static QString protectedEnumSurrogateName(const AbstractMetaEnum *metaEnum);
+ static QString protectedFieldGetterName(const AbstractMetaField *field);
+ static QString protectedFieldSetterName(const AbstractMetaField *field);
- static QString pythonPrimitiveTypeName(const QString& cppTypeName);
- static QString pythonPrimitiveTypeName(const PrimitiveTypeEntry* type);
+ static QString pythonPrimitiveTypeName(const QString &cppTypeName);
+ static QString pythonPrimitiveTypeName(const PrimitiveTypeEntry *type);
static QString pythonOperatorFunctionName(const QString &cppOpFuncName);
- static QString pythonOperatorFunctionName(const AbstractMetaFunction* func);
+ static QString pythonOperatorFunctionName(const AbstractMetaFunction *func);
static QString pythonRichCompareOperatorId(const QString &cppOpFuncName);
- static QString pythonRichCompareOperatorId(const AbstractMetaFunction* func);
+ static QString pythonRichCompareOperatorId(const AbstractMetaFunction *func);
- static QString fixedCppTypeName(const CustomConversion::TargetToNativeConversion* toNative);
- static QString fixedCppTypeName(const AbstractMetaType* type);
- static QString fixedCppTypeName(const TypeEntry* type, QString typeName = QString());
+ static QString fixedCppTypeName(const CustomConversion::TargetToNativeConversion *toNative);
+ static QString fixedCppTypeName(const AbstractMetaType *type);
+ static QString fixedCppTypeName(const TypeEntry *type, QString typeName = QString());
static bool isNumber(const QString &cpythonApiName);
- static bool isNumber(const TypeEntry* type);
- static bool isNumber(const AbstractMetaType* type);
- static bool isPyInt(const TypeEntry* type);
- static bool isPyInt(const AbstractMetaType* type);
+ static bool isNumber(const TypeEntry *type);
+ static bool isNumber(const AbstractMetaType *type);
+ static bool isPyInt(const TypeEntry *type);
+ static bool isPyInt(const AbstractMetaType *type);
/**
* Returns true if the type passed has a Python wrapper for it.
* Although namespace has a Python wrapper, it's not considered a type.
*/
- static bool isWrapperType(const TypeEntry* type);
- static bool isWrapperType(const ComplexTypeEntry* type);
- static bool isWrapperType(const AbstractMetaType* metaType);
+ static bool isWrapperType(const TypeEntry *type);
+ static bool isWrapperType(const ComplexTypeEntry *type);
+ static bool isWrapperType(const AbstractMetaType *metaType);
/**
* Checks if the type is an Object/QObject or pointer to Value Type.
* In other words, tells if the type is "T*" and T has a Python wrapper.
*/
- static bool isPointerToWrapperType(const AbstractMetaType* type);
+ static bool isPointerToWrapperType(const AbstractMetaType *type);
/**
* Returns true if \p type is an Object Type used as a value.
*/
- static bool isObjectTypeUsedAsValueType(const AbstractMetaType* type);
+ static bool isObjectTypeUsedAsValueType(const AbstractMetaType *type);
- static bool isValueTypeWithCopyConstructorOnly(const AbstractMetaClass* metaClass);
- bool isValueTypeWithCopyConstructorOnly(const TypeEntry* type) const;
- bool isValueTypeWithCopyConstructorOnly(const AbstractMetaType* type) const;
+ static bool isValueTypeWithCopyConstructorOnly(const AbstractMetaClass *metaClass);
+ bool isValueTypeWithCopyConstructorOnly(const TypeEntry *type) const;
+ bool isValueTypeWithCopyConstructorOnly(const AbstractMetaType *type) const;
/// Returns true if the type is a primitive but not a C++ primitive.
- static bool isUserPrimitive(const TypeEntry* type);
- static bool isUserPrimitive(const AbstractMetaType* type);
+ static bool isUserPrimitive(const TypeEntry *type);
+ static bool isUserPrimitive(const AbstractMetaType *type);
/// Returns true if the type is a C++ primitive, a void*, a const char*, or a std::string.
- static bool isCppPrimitive(const TypeEntry* type);
- static bool isCppPrimitive(const AbstractMetaType* type);
+ static bool isCppPrimitive(const TypeEntry *type);
+ static bool isCppPrimitive(const AbstractMetaType *type);
/// Returns true if the type is a C++ integral primitive, i.e. bool, char, int, long, and their unsigned counterparts.
- static bool isCppIntegralPrimitive(const TypeEntry* type);
- static bool isCppIntegralPrimitive(const AbstractMetaType* type);
+ static bool isCppIntegralPrimitive(const TypeEntry *type);
+ static bool isCppIntegralPrimitive(const AbstractMetaType *type);
/// Checks if an argument type should be dereferenced by the Python method wrapper before calling the C++ method.
- static bool shouldDereferenceArgumentPointer(const AbstractMetaArgument* arg);
+ static bool shouldDereferenceArgumentPointer(const AbstractMetaArgument *arg);
/// Checks if a meta type should be dereferenced by the Python method wrapper passing it to C++.
- static bool shouldDereferenceAbstractMetaTypePointer(const AbstractMetaType* metaType);
-
- static bool visibilityModifiedToPrivate(const AbstractMetaFunction* func);
-
- QString converterObject(const AbstractMetaType* type);
- QString converterObject(const TypeEntry* type);
-
- QString cpythonBaseName(const AbstractMetaClass* metaClass);
- QString cpythonBaseName(const TypeEntry* type);
- QString cpythonBaseName(const AbstractMetaType* type);
- QString cpythonTypeName(const AbstractMetaClass* metaClass);
- QString cpythonTypeName(const TypeEntry* type);
- QString cpythonTypeNameExt(const TypeEntry* type);
- QString cpythonTypeNameExt(const AbstractMetaType* type);
- QString cpythonCheckFunction(const TypeEntry* type, bool genericNumberType = false);
- QString cpythonCheckFunction(const AbstractMetaType* metaType, bool genericNumberType = false);
+ static bool shouldDereferenceAbstractMetaTypePointer(const AbstractMetaType *metaType);
+
+ static bool visibilityModifiedToPrivate(const AbstractMetaFunction *func);
+
+ QString converterObject(const AbstractMetaType *type);
+ QString converterObject(const TypeEntry *type);
+
+ QString cpythonBaseName(const AbstractMetaClass *metaClass);
+ QString cpythonBaseName(const TypeEntry *type);
+ QString cpythonBaseName(const AbstractMetaType *type);
+ QString cpythonTypeName(const AbstractMetaClass *metaClass);
+ QString cpythonTypeName(const TypeEntry *type);
+ QString cpythonTypeNameExt(const TypeEntry *type);
+ QString cpythonTypeNameExt(const AbstractMetaType *type);
+ QString cpythonCheckFunction(const TypeEntry *type, bool genericNumberType = false);
+ QString cpythonCheckFunction(const AbstractMetaType *metaType, bool genericNumberType = false);
/**
* Receives the argument \p type and tries to find the appropriate AbstractMetaType for it
* or a custom type check.
@@ -306,28 +306,28 @@ protected:
* \return A custom check if \p type is a custom type, or an empty string if \p metaType
* receives an existing type object.
*/
- QString guessCPythonCheckFunction(const QString& type, AbstractMetaType** metaType);
- QString cpythonIsConvertibleFunction(const TypeEntry* type, bool genericNumberType = false, bool checkExact = false);
- QString cpythonIsConvertibleFunction(const AbstractMetaType* metaType, bool genericNumberType = false);
- QString cpythonIsConvertibleFunction(const AbstractMetaArgument* metaArg, bool genericNumberType = false);
-
- QString cpythonToCppConversionFunction(const AbstractMetaClass* metaClass);
- QString cpythonToCppConversionFunction(const AbstractMetaType* type, const AbstractMetaClass* context = 0);
- QString cpythonToPythonConversionFunction(const AbstractMetaType* type, const AbstractMetaClass* context = 0);
- QString cpythonToPythonConversionFunction(const AbstractMetaClass* metaClass);
- QString cpythonToPythonConversionFunction(const TypeEntry* type);
-
- QString cpythonFunctionName(const AbstractMetaFunction* func);
- QString cpythonMethodDefinitionName(const AbstractMetaFunction* func);
- QString cpythonGettersSettersDefinitionName(const AbstractMetaClass* metaClass);
- QString cpythonGetattroFunctionName(const AbstractMetaClass* metaClass);
- QString cpythonSetattroFunctionName(const AbstractMetaClass* metaClass);
- QString cpythonGetterFunctionName(const AbstractMetaField* metaField);
- QString cpythonSetterFunctionName(const AbstractMetaField* metaField);
- QString cpythonWrapperCPtr(const AbstractMetaClass* metaClass,
+ QString guessCPythonCheckFunction(const QString &type, AbstractMetaType **metaType);
+ QString cpythonIsConvertibleFunction(const TypeEntry *type, bool genericNumberType = false, bool checkExact = false);
+ QString cpythonIsConvertibleFunction(const AbstractMetaType *metaType, bool genericNumberType = false);
+ QString cpythonIsConvertibleFunction(const AbstractMetaArgument *metaArg, bool genericNumberType = false);
+
+ QString cpythonToCppConversionFunction(const AbstractMetaClass *metaClass);
+ QString cpythonToCppConversionFunction(const AbstractMetaType *type, const AbstractMetaClass *context = nullptr);
+ QString cpythonToPythonConversionFunction(const AbstractMetaType *type, const AbstractMetaClass *context = nullptr);
+ QString cpythonToPythonConversionFunction(const AbstractMetaClass *metaClass);
+ QString cpythonToPythonConversionFunction(const TypeEntry *type);
+
+ QString cpythonFunctionName(const AbstractMetaFunction *func);
+ QString cpythonMethodDefinitionName(const AbstractMetaFunction *func);
+ QString cpythonGettersSettersDefinitionName(const AbstractMetaClass *metaClass);
+ QString cpythonGetattroFunctionName(const AbstractMetaClass *metaClass);
+ QString cpythonSetattroFunctionName(const AbstractMetaClass *metaClass);
+ QString cpythonGetterFunctionName(const AbstractMetaField *metaField);
+ QString cpythonSetterFunctionName(const AbstractMetaField *metaField);
+ QString cpythonWrapperCPtr(const AbstractMetaClass *metaClass,
const QString &argName = QLatin1String("self"));
QString cpythonWrapperCPtr(const AbstractMetaType *metaType, const QString &argName);
- QString cpythonWrapperCPtr(const TypeEntry* type, const QString &argName);
+ QString cpythonWrapperCPtr(const TypeEntry *type, const QString &argName);
/// Guesses the scope to where belongs an argument's default value.
QString guessScopeForDefaultValue(const AbstractMetaFunction *func,
@@ -336,18 +336,18 @@ protected:
const AbstractMetaArgument *arg,
const QString &value) const;
- QString cpythonEnumName(const EnumTypeEntry* enumEntry);
- QString cpythonEnumName(const AbstractMetaEnum* metaEnum);
+ QString cpythonEnumName(const EnumTypeEntry *enumEntry);
+ QString cpythonEnumName(const AbstractMetaEnum *metaEnum);
- QString cpythonFlagsName(const FlagsTypeEntry* flagsEntry);
- QString cpythonFlagsName(const AbstractMetaEnum* metaEnum);
+ QString cpythonFlagsName(const FlagsTypeEntry *flagsEntry);
+ QString cpythonFlagsName(const AbstractMetaEnum *metaEnum);
/// Returns the special cast function name, the function used to proper cast class with multiple inheritance.
- QString cpythonSpecialCastFunctionName(const AbstractMetaClass* metaClass);
+ QString cpythonSpecialCastFunctionName(const AbstractMetaClass *metaClass);
- QString getFormatUnitString(const AbstractMetaFunction* func, bool incRef = false) const;
+ QString getFormatUnitString(const AbstractMetaFunction *func, bool incRef = false) const;
/// Returns the file name for the module global header. If no module name is provided the current will be used.
- QString getModuleHeaderFileName(const QString& moduleName = QString()) const;
+ QString getModuleHeaderFileName(const QString &moduleName = QString()) const;
OptionDescriptions options() const override;
bool handleOption(const QString &key, const QString &value) override;
@@ -362,18 +362,18 @@ protected:
bool useIsNullAsNbNonZero() const;
/// Returns true if the generated code should use the "#define protected public" hack.
bool avoidProtectedHack() const;
- QString cppApiVariableName(const QString& moduleName = QString()) const;
- QString pythonModuleObjectName(const QString& moduleName = QString()) const;
- QString convertersVariableName(const QString& moduleName = QString()) const;
+ QString cppApiVariableName(const QString &moduleName = QString()) const;
+ QString pythonModuleObjectName(const QString &moduleName = QString()) const;
+ QString convertersVariableName(const QString &moduleName = QString()) const;
/**
* Returns the type index variable name for a given class. If \p alternativeTemplateName is true
* and the class is a typedef for a template class instantiation, it will return an alternative name
* made of the template class and the instantiation values, or an empty string if the class isn't
* derived from a template class at all.
*/
- QString getTypeIndexVariableName(const AbstractMetaClass* metaClass, bool alternativeTemplateName = false);
- QString getTypeIndexVariableName(const TypeEntry* type);
- QString getTypeIndexVariableName(const AbstractMetaType* type);
+ QString getTypeIndexVariableName(const AbstractMetaClass *metaClass, bool alternativeTemplateName = false);
+ QString getTypeIndexVariableName(const TypeEntry *type);
+ QString getTypeIndexVariableName(const AbstractMetaType *type);
/// Returns true if the user don't want verbose error messages on the generated bindings.
bool verboseErrorMessagesDisabled() const;
@@ -389,16 +389,16 @@ protected:
QString *errorMessage = nullptr);
/// Creates an AbstractMetaType object from a TypeEntry.
- AbstractMetaType* buildAbstractMetaTypeFromTypeEntry(const TypeEntry* typeEntry);
+ AbstractMetaType *buildAbstractMetaTypeFromTypeEntry(const TypeEntry *typeEntry);
/// Creates an AbstractMetaType object from an AbstractMetaClass.
- AbstractMetaType* buildAbstractMetaTypeFromAbstractMetaClass(const AbstractMetaClass* metaClass);
+ AbstractMetaType *buildAbstractMetaTypeFromAbstractMetaClass(const AbstractMetaClass *metaClass);
- void writeMinimalConstructorExpression(QTextStream& s, const AbstractMetaType* type, const QString& defaultCtor = QString());
- void writeMinimalConstructorExpression(QTextStream& s, const TypeEntry* type, const QString& defaultCtor = QString());
+ void writeMinimalConstructorExpression(QTextStream &s, const AbstractMetaType *type, const QString &defaultCtor = QString());
+ void writeMinimalConstructorExpression(QTextStream &s, const TypeEntry *type, const QString &defaultCtor = QString());
- void collectContainerTypesFromConverterMacros(const QString& code, bool toPythonMacro);
+ void collectContainerTypesFromConverterMacros(const QString &code, bool toPythonMacro);
// verify whether the class is copyable
- bool isCopyable(const AbstractMetaClass* metaClass);
+ bool isCopyable(const AbstractMetaClass *metaClass);
void clearTpFuncs();
@@ -408,17 +408,17 @@ protected:
/// Initializes a list of Python known type names.
static void initKnownPythonTypes();
- void writeFunctionCall(QTextStream& s,
- const AbstractMetaFunction* metaFunc,
+ void writeFunctionCall(QTextStream &s,
+ const AbstractMetaFunction *metaFunc,
Options options = NoOption) const;
- void writeUnusedVariableCast(QTextStream& s, const QString& variableName);
+ void writeUnusedVariableCast(QTextStream &s, const QString &variableName);
- AbstractMetaFunctionList filterFunctions(const AbstractMetaClass* metaClass);
+ AbstractMetaFunctionList filterFunctions(const AbstractMetaClass *metaClass);
// All data about extended converters: the type entries of the target type, and a
// list of AbstractMetaClasses accepted as argument for the conversion.
- typedef QHash<const TypeEntry *, QVector<const AbstractMetaClass *> > ExtendedConverterData;
+ using ExtendedConverterData = QHash<const TypeEntry *, QVector<const AbstractMetaClass *> >;
/// Returns all extended conversions for the current module.
ExtendedConverterData getExtendedConverters() const;
@@ -426,7 +426,7 @@ protected:
QVector<const CustomConversion *> getPrimitiveCustomConversions();
/// Returns true if the Python wrapper for the received OverloadData must accept a list of arguments.
- static bool pythonFunctionWrapperUsesListOfArguments(const OverloadData& overloadData);
+ static bool pythonFunctionWrapperUsesListOfArguments(const OverloadData &overloadData);
Indentor INDENT;
@@ -446,8 +446,8 @@ private:
static FunctionGroups getFunctionGroupsImpl(const AbstractMetaClass *scope);
static bool classNeedsGetattroFunctionImpl(const AbstractMetaClass *metaClass);
- QString translateTypeForWrapperMethod(const AbstractMetaType* cType,
- const AbstractMetaClass* context,
+ QString translateTypeForWrapperMethod(const AbstractMetaType *cType,
+ const AbstractMetaClass *context,
Options opt = NoOption) const;
/**
@@ -464,8 +464,8 @@ private:
* \param scope scope used to search for overloads.
* \param functionName the function name.
*/
- AbstractMetaFunctionList getFunctionOverloads(const AbstractMetaClass* scope,
- const QString& functionName);
+ AbstractMetaFunctionList getFunctionOverloads(const AbstractMetaClass *scope,
+ const QString &functionName);
/**
* Write a function argument in the C++ in the text stream \p s.
* This function just call \code s << argumentString(); \endcode
@@ -475,8 +475,8 @@ private:
* \param options some extra options.
*/
void writeArgument(QTextStream &s,
- const AbstractMetaFunction* func,
- const AbstractMetaArgument* argument,
+ const AbstractMetaFunction *func,
+ const AbstractMetaArgument *argument,
Options options = NoOption) const;
/**
* Create a QString in the C++ format to an function argument.
@@ -484,18 +484,18 @@ private:
* \param argument metaargument information to be parsed.
* \param options some extra options.
*/
- QString argumentString(const AbstractMetaFunction* func,
- const AbstractMetaArgument* argument,
+ QString argumentString(const AbstractMetaFunction *func,
+ const AbstractMetaArgument *argument,
Options options = NoOption) const;
- QString functionReturnType(const AbstractMetaFunction* func, Options options = NoOption) const;
+ QString functionReturnType(const AbstractMetaFunction *func, Options options = NoOption) const;
/// Utility function for writeCodeSnips.
- typedef QPair<const AbstractMetaArgument*, QString> ArgumentVarReplacementPair;
- typedef QVector<ArgumentVarReplacementPair> ArgumentVarReplacementList;
+ using ArgumentVarReplacementPair = QPair<const AbstractMetaArgument *, QString>;
+ using ArgumentVarReplacementList = QVector<ArgumentVarReplacementPair>;
ArgumentVarReplacementList getArgumentReplacement(const AbstractMetaFunction* func,
bool usePyArgs, TypeSystem::Language language,
- const AbstractMetaArgument* lastArg);
+ const AbstractMetaArgument *lastArg);
/// Returns a string with the user's custom code snippets that comply with \p position and \p language.
QString getCodeSnippets(const QVector<CodeSnip> & codeSnips,
@@ -509,31 +509,31 @@ private:
TypeSystemToPythonFunction,
TypeSystemConverterVariables
};
- void replaceConverterTypeSystemVariable(TypeSystemConverterVariable converterVariable, QString& code);
+ void replaceConverterTypeSystemVariable(TypeSystemConverterVariable converterVariable, QString &code);
/// Replaces the %CONVERTTOPYTHON type system variable.
- inline void replaceConvertToPythonTypeSystemVariable(QString& code)
+ inline void replaceConvertToPythonTypeSystemVariable(QString &code)
{
replaceConverterTypeSystemVariable(TypeSystemToPythonFunction, code);
}
/// Replaces the %CONVERTTOCPP type system variable.
- inline void replaceConvertToCppTypeSystemVariable(QString& code)
+ inline void replaceConvertToCppTypeSystemVariable(QString &code)
{
replaceConverterTypeSystemVariable(TypeSystemToCppFunction, code);
}
/// Replaces the %ISCONVERTIBLE type system variable.
- inline void replaceIsConvertibleToCppTypeSystemVariable(QString& code)
+ inline void replaceIsConvertibleToCppTypeSystemVariable(QString &code)
{
replaceConverterTypeSystemVariable(TypeSystemIsConvertibleFunction, code);
}
/// Replaces the %CHECKTYPE type system variable.
- inline void replaceTypeCheckTypeSystemVariable(QString& code)
+ inline void replaceTypeCheckTypeSystemVariable(QString &code)
{
replaceConverterTypeSystemVariable(TypeSystemCheckFunction, code);
}
/// Return a prefix with '_' suitable for names in C++
- QString moduleCppPrefix(const QString& moduleName = QString()) const;
+ QString moduleCppPrefix(const QString &moduleName = QString()) const;
bool m_useCtorHeuristic = false;
bool m_userReturnValueHeuristic = false;
@@ -542,7 +542,7 @@ private:
bool m_useIsNullAsNbNonZero = false;
bool m_avoidProtectedHack = false;
- typedef QHash<QString, AbstractMetaType*> AbstractMetaTypeCache;
+ using AbstractMetaTypeCache = QHash<QString, AbstractMetaType *>;
AbstractMetaTypeCache m_metaTypeFromStringCache;
/// Type system converter variable replacement names and regular expressions.