aboutsummaryrefslogtreecommitdiffstats
path: root/sources/shiboken2/generator/shiboken2/overloaddata.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'sources/shiboken2/generator/shiboken2/overloaddata.cpp')
-rw-r--r--sources/shiboken2/generator/shiboken2/overloaddata.cpp106
1 files changed, 53 insertions, 53 deletions
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();