aboutsummaryrefslogtreecommitdiffstats
path: root/sources/shiboken2/generator
diff options
context:
space:
mode:
authorFriedemann Kleint <Friedemann.Kleint@qt.io>2020-01-16 15:07:12 +0100
committerFriedemann Kleint <Friedemann.Kleint@qt.io>2020-02-10 14:09:12 +0100
commit8681f3a11c458ca9b092e96bbd24e51603342d6c (patch)
tree30e2c02c325e3d5f0189782fea461b3f8c1ca95e /sources/shiboken2/generator
parentf597a74e3b3eb3042c7d85dc2df813852e0c3db5 (diff)
shiboken: Refactor writing of get/setattro methods
getattro functions are needed for: - smartpointer dispatch - special cases of function overload resolution setattro functions are needed for: - smartpointer dispatch - QObject property handling All of this was previously handled in the writeSet/GetattroFunction which duplicated, inconsistent checks in various places, which makes it very hard to add additional functionality to tp_getsetattro(). To overcome this, define a flag to describe the various use cases, a check function to determine it. The flag is passed to the write functions. Smart pointer handling is split out completely since it will never mix with the other use cases. Task-number: PYSIDE-803 Change-Id: Iead9ee5b086830fb670b25917914117da62fefe5 Reviewed-by: Cristian Maureira-Fredes <cristian.maureira-fredes@qt.io>
Diffstat (limited to 'sources/shiboken2/generator')
-rw-r--r--sources/shiboken2/generator/shiboken2/cppgenerator.cpp209
-rw-r--r--sources/shiboken2/generator/shiboken2/cppgenerator.h10
-rw-r--r--sources/shiboken2/generator/shiboken2/shibokengenerator.cpp37
-rw-r--r--sources/shiboken2/generator/shiboken2/shibokengenerator.h54
4 files changed, 173 insertions, 137 deletions
diff --git a/sources/shiboken2/generator/shiboken2/cppgenerator.cpp b/sources/shiboken2/generator/shiboken2/cppgenerator.cpp
index 0c5da737c..ae770f94d 100644
--- a/sources/shiboken2/generator/shiboken2/cppgenerator.cpp
+++ b/sources/shiboken2/generator/shiboken2/cppgenerator.cpp
@@ -562,21 +562,16 @@ void CppGenerator::generateClass(QTextStream &s, GeneratorContext &classContext)
s << INDENT << '{' << NULL_PTR << ", " << NULL_PTR << "} // Sentinel\n";
s << "};\n\n";
- // Write tp_getattro function
- if ((usePySideExtensions() && metaClass->qualifiedCppName() == QLatin1String("QObject"))) {
- writeGetattroFunction(s, classContext);
- s << endl;
- writeSetattroFunction(s, classContext);
- s << endl;
+ // Write tp_s/getattro function
+ const AttroCheck attroCheck = checkAttroFunctionNeeds(metaClass);
+ if (attroCheck.testFlag(AttroCheckFlag::GetattroSmartPointer)) {
+ writeSmartPointerGetattroFunction(s, classContext);
+ writeSmartPointerSetattroFunction(s, classContext);
} else {
- if (classNeedsGetattroFunction(metaClass)) {
- writeGetattroFunction(s, classContext);
- s << endl;
- }
- if (classNeedsSetattroFunction(metaClass)) {
- writeSetattroFunction(s, classContext);
- s << endl;
- }
+ if ((attroCheck & AttroCheckFlag::GetattroMask) != 0)
+ writeGetattroFunction(s, attroCheck, classContext);
+ if ((attroCheck & AttroCheckFlag::SetattroMask) != 0)
+ writeSetattroFunction(s, attroCheck, classContext);
}
if (const AbstractMetaFunction *f = boolCast(metaClass)) {
@@ -3881,17 +3876,11 @@ void CppGenerator::writeClassDefinition(QTextStream &s,
tp_init = cpythonFunctionName(ctors.constFirst());
}
- QString tp_getattro;
- QString tp_setattro;
- if (usePySideExtensions() && (metaClass->qualifiedCppName() == QLatin1String("QObject"))) {
- tp_getattro = cpythonGetattroFunctionName(metaClass);
- tp_setattro = cpythonSetattroFunctionName(metaClass);
- } else {
- if (classNeedsGetattroFunction(metaClass))
- tp_getattro = cpythonGetattroFunctionName(metaClass);
- if (classNeedsSetattroFunction(metaClass))
- tp_setattro = cpythonSetattroFunctionName(metaClass);
- }
+ const AttroCheck attroCheck = checkAttroFunctionNeeds(metaClass);
+ const QString tp_getattro = (attroCheck & AttroCheckFlag::GetattroMask) != 0
+ ? cpythonGetattroFunctionName(metaClass) : QString();
+ const QString tp_setattro = (attroCheck & AttroCheckFlag::SetattroMask) != 0
+ ? cpythonSetattroFunctionName(metaClass) : QString();
if (metaClass->hasPrivateDestructor() || onlyPrivCtor) {
// tp_flags = QLatin1String("Py_TPFLAGS_DEFAULT|Py_TPFLAGS_CHECKTYPES");
@@ -5229,63 +5218,88 @@ QString CppGenerator::writeSmartPointerGetterCast()
+ QLatin1String(SMART_POINTER_GETTER) + QLatin1Char(')');
}
-void CppGenerator::writeSetattroFunction(QTextStream &s, GeneratorContext &context)
+void CppGenerator::writeSetattroDefinition(QTextStream &s, const AbstractMetaClass *metaClass)
{
- const AbstractMetaClass *metaClass = context.metaClass();
- s << "static int " << cpythonSetattroFunctionName(metaClass)
+ s << "static int " << ShibokenGenerator::cpythonSetattroFunctionName(metaClass)
<< "(PyObject *self, PyObject *name, PyObject *value)\n{\n";
- if (usePySideExtensions()) {
+}
+
+inline void CppGenerator::writeSetattroDefaultReturn(QTextStream &s) const
+{
+ s << INDENT << "return PyObject_GenericSetAttr(self, name, value);\n}\n\n";
+}
+
+void CppGenerator::writeSetattroFunction(QTextStream &s, AttroCheck attroCheck,
+ GeneratorContext &context)
+{
+ Q_ASSERT(!context.forSmartPointer());
+ const AbstractMetaClass *metaClass = context.metaClass();
+ writeSetattroDefinition(s, metaClass);
+ if (attroCheck.testFlag(AttroCheckFlag::SetattroQObject)) {
s << INDENT << "Shiboken::AutoDecRef pp(reinterpret_cast<PyObject *>(PySide::Property::getObject(self, name)));\n";
s << INDENT << "if (!pp.isNull())\n";
Indentation indent(INDENT);
s << INDENT << "return PySide::Property::setValue(reinterpret_cast<PySideProperty *>(pp.object()), self, value);\n";
}
+ writeSetattroDefaultReturn(s);
+}
- if (context.forSmartPointer()) {
- s << INDENT << "// Try to find the 'name' attribute, by retrieving the PyObject for the corresponding C++ object held by the smart pointer.\n";
- s << INDENT << "PyObject *rawObj = PyObject_CallMethod(self, "
- << writeSmartPointerGetterCast() << ", 0);\n";
- s << INDENT << "if (rawObj) {\n";
+void CppGenerator::writeSmartPointerSetattroFunction(QTextStream &s, GeneratorContext &context)
+{
+ Q_ASSERT(context.forSmartPointer());
+ writeSetattroDefinition(s, context.metaClass());
+ s << INDENT << "// Try to find the 'name' attribute, by retrieving the PyObject for the corresponding C++ object held by the smart pointer.\n";
+ s << INDENT << "PyObject *rawObj = PyObject_CallMethod(self, "
+ << writeSmartPointerGetterCast() << ", 0);\n";
+ s << INDENT << "if (rawObj) {\n";
+ {
+ Indentation indent(INDENT);
+ s << INDENT << "int hasAttribute = PyObject_HasAttr(rawObj, name);\n";
+ s << INDENT << "if (hasAttribute) {\n";
{
Indentation indent(INDENT);
- s << INDENT << "int hasAttribute = PyObject_HasAttr(rawObj, name);\n";
- s << INDENT << "if (hasAttribute) {\n";
- {
- Indentation indent(INDENT);
- s << INDENT << "return PyObject_GenericSetAttr(rawObj, name, value);\n";
- }
- s << INDENT << "}\n";
- s << INDENT << "Py_DECREF(rawObj);\n";
+ s << INDENT << "return PyObject_GenericSetAttr(rawObj, name, value);\n";
}
s << INDENT << "}\n";
-
+ s << INDENT << "Py_DECREF(rawObj);\n";
}
-
- s << INDENT << "return PyObject_GenericSetAttr(self, name, value);\n";
- s << "}\n";
+ s << INDENT << "}\n";
+ writeSetattroDefaultReturn(s);
}
static inline QString qObjectClassName() { return QStringLiteral("QObject"); }
static inline QString qMetaObjectClassName() { return QStringLiteral("QMetaObject"); }
-void CppGenerator::writeGetattroFunction(QTextStream &s, GeneratorContext &context)
+void CppGenerator::writeGetattroDefinition(QTextStream &s, const AbstractMetaClass *metaClass)
{
- const AbstractMetaClass *metaClass = context.metaClass();
s << "static PyObject *" << cpythonGetattroFunctionName(metaClass)
<< "(PyObject *self, PyObject *name)\n{\n";
- s << INDENT << "assert(self);\n";
+}
- QString getattrFunc;
- if (usePySideExtensions() && metaClass->isQObject()) {
+QString CppGenerator::qObjectGetAttroFunction() const
+{
+ static QString result;
+ if (result.isEmpty()) {
AbstractMetaClass *qobjectClass = AbstractMetaClass::findClass(classes(), qObjectClassName());
- QTextStream(&getattrFunc) << "PySide::getMetaDataFromQObject("
- << cpythonWrapperCPtr(qobjectClass, QLatin1String("self"))
- << ", self, name)";
- } else {
- getattrFunc = QLatin1String("PyObject_GenericGetAttr(self, name)");
+ Q_ASSERT(qobjectClass);
+ result = QLatin1String("PySide::getMetaDataFromQObject(")
+ + cpythonWrapperCPtr(qobjectClass, QLatin1String("self"))
+ + QLatin1String(", self, name)");
}
+ return result;
+}
- if (classNeedsGetattroFunction(metaClass)) {
+void CppGenerator::writeGetattroFunction(QTextStream &s, AttroCheck attroCheck,
+ GeneratorContext &context)
+{
+ Q_ASSERT(!context.forSmartPointer());
+ const AbstractMetaClass *metaClass = context.metaClass();
+ writeGetattroDefinition(s, metaClass);
+
+ const QString getattrFunc = usePySideExtensions() && metaClass->isQObject()
+ ? qObjectGetAttroFunction() : QLatin1String("PyObject_GenericGetAttr(self, name)");
+
+ if (attroCheck.testFlag(AttroCheckFlag::GetattroOverloads)) {
s << INDENT << "// Search the method in the instance dict\n";
s << INDENT << "if (auto ob_dict = reinterpret_cast<SbkObject *>(self)->ob_dict) {\n";
{
@@ -5331,50 +5345,53 @@ void CppGenerator::writeGetattroFunction(QTextStream &s, GeneratorContext &conte
}
}
- if (context.forSmartPointer()) {
- s << INDENT << "PyObject *tmp = " << getattrFunc << ";\n";
- s << INDENT << "if (tmp)\n";
- {
- Indentation indent(INDENT);
- s << INDENT << "return tmp;\n";
- }
- s << INDENT << "if (!PyErr_ExceptionMatches(PyExc_AttributeError))\n";
- {
- Indentation indent(INDENT);
- s << INDENT << "return nullptr;\n";
- }
- s << INDENT << "PyErr_Clear();\n";
+ s << INDENT << "return " << getattrFunc << ";\n}\n\n";
+}
- // This generates the code which dispatches access to member functions
- // and fields from the smart pointer to its pointee.
- s << INDENT << "// Try to find the 'name' attribute, by retrieving the PyObject for "
- "the corresponding C++ object held by the smart pointer.\n";
- s << INDENT << "if (auto rawObj = PyObject_CallMethod(self, "
- << writeSmartPointerGetterCast() << ", 0)) {\n";
- {
- Indentation indent(INDENT);
- s << INDENT << "if (auto attribute = PyObject_GetAttr(rawObj, name))\n";
- {
- Indentation indent(INDENT);
- s << INDENT << "tmp = attribute;\n";
- }
- s << INDENT << "Py_DECREF(rawObj);\n";
- }
- s << INDENT << "}\n";
- s << INDENT << "if (!tmp) {\n";
+void CppGenerator::writeSmartPointerGetattroFunction(QTextStream &s, GeneratorContext &context)
+{
+ Q_ASSERT(context.forSmartPointer());
+ const AbstractMetaClass *metaClass = context.metaClass();
+ writeGetattroDefinition(s, metaClass);
+ s << INDENT << "PyObject *tmp = PyObject_GenericGetAttr(self, name);\n";
+ s << INDENT << "if (tmp)\n";
+ {
+ Indentation indent(INDENT);
+ s << INDENT << "return tmp;\n";
+ }
+ s << INDENT << "if (!PyErr_ExceptionMatches(PyExc_AttributeError))\n";
+ {
+ Indentation indent(INDENT);
+ s << INDENT << "return nullptr;\n";
+ }
+ s << INDENT << "PyErr_Clear();\n";
+
+ // This generates the code which dispatches access to member functions
+ // and fields from the smart pointer to its pointee.
+ s << INDENT << "// Try to find the 'name' attribute, by retrieving the PyObject for "
+ "the corresponding C++ object held by the smart pointer.\n";
+ s << INDENT << "if (auto rawObj = PyObject_CallMethod(self, "
+ << writeSmartPointerGetterCast() << ", 0)) {\n";
+ {
+ Indentation indent(INDENT);
+ s << INDENT << "if (auto attribute = PyObject_GetAttr(rawObj, name))\n";
{
Indentation indent(INDENT);
- s << INDENT << "PyTypeObject *tp = Py_TYPE(self);\n";
- s << INDENT << "PyErr_Format(PyExc_AttributeError,\n";
- s << INDENT << " \"'%.50s' object has no attribute '%.400s'\",\n";
- s << INDENT << " tp->tp_name, Shiboken::String::toCString(name));\n";
+ s << INDENT << "tmp = attribute;\n";
}
- s << INDENT << "}\n";
- s << INDENT << "return tmp;\n";
- } else {
- s << INDENT << "return " << getattrFunc << ";\n";
+ s << INDENT << "Py_DECREF(rawObj);\n";
}
- s << "}\n";
+ s << INDENT << "}\n";
+ s << INDENT << "if (!tmp) {\n";
+ {
+ Indentation indent(INDENT);
+ s << INDENT << "PyTypeObject *tp = Py_TYPE(self);\n";
+ s << INDENT << "PyErr_Format(PyExc_AttributeError,\n";
+ s << INDENT << " \"'%.50s' object has no attribute '%.400s'\",\n";
+ s << INDENT << " tp->tp_name, Shiboken::String::toCString(name));\n";
+ }
+ s << INDENT << "}\n";
+ s << INDENT << "return tmp;\n}\n\n";
}
bool CppGenerator::finishGeneration()
diff --git a/sources/shiboken2/generator/shiboken2/cppgenerator.h b/sources/shiboken2/generator/shiboken2/cppgenerator.h
index 005518f96..e3bb2c9cf 100644
--- a/sources/shiboken2/generator/shiboken2/cppgenerator.h
+++ b/sources/shiboken2/generator/shiboken2/cppgenerator.h
@@ -102,9 +102,15 @@ private:
void writeTypeDiscoveryFunction(QTextStream &s, const AbstractMetaClass *metaClass);
- void writeSetattroFunction(QTextStream &s, GeneratorContext &context);
- void writeGetattroFunction(QTextStream &s, GeneratorContext &context);
+ static void writeSetattroDefinition(QTextStream &s, const AbstractMetaClass *metaClass);
+ void writeSetattroDefaultReturn(QTextStream &s) const;
+ void writeSmartPointerSetattroFunction(QTextStream &s, GeneratorContext &context);
+ void writeSetattroFunction(QTextStream &s, AttroCheck attroCheck, GeneratorContext &context);
+ static void writeGetattroDefinition(QTextStream &s, const AbstractMetaClass *metaClass);
+ void writeSmartPointerGetattroFunction(QTextStream &s, GeneratorContext &context);
+ void writeGetattroFunction(QTextStream &s, AttroCheck attroCheck, GeneratorContext &context);
QString writeSmartPointerGetterCast();
+ QString qObjectGetAttroFunction() const;
/**
* Writes Python to C++ conversions for arguments on Python wrappers.
diff --git a/sources/shiboken2/generator/shiboken2/shibokengenerator.cpp b/sources/shiboken2/generator/shiboken2/shibokengenerator.cpp
index 94c774c30..86fca9c55 100644
--- a/sources/shiboken2/generator/shiboken2/shibokengenerator.cpp
+++ b/sources/shiboken2/generator/shiboken2/shibokengenerator.cpp
@@ -659,13 +659,13 @@ QString ShibokenGenerator::cpythonSpecialCastFunctionName(const AbstractMetaClas
}
QString ShibokenGenerator::cpythonWrapperCPtr(const AbstractMetaClass *metaClass,
- const QString &argName)
+ const QString &argName) const
{
return cpythonWrapperCPtr(metaClass->typeEntry(), argName);
}
QString ShibokenGenerator::cpythonWrapperCPtr(const AbstractMetaType *metaType,
- const QString &argName)
+ const QString &argName) const
{
if (!ShibokenGenerator::isWrapperType(metaType->typeEntry()))
return QString();
@@ -675,7 +675,7 @@ QString ShibokenGenerator::cpythonWrapperCPtr(const AbstractMetaType *metaType,
}
QString ShibokenGenerator::cpythonWrapperCPtr(const TypeEntry *type,
- const QString &argName)
+ const QString &argName) const
{
if (!ShibokenGenerator::isWrapperType(type))
return QString();
@@ -844,7 +844,7 @@ QString ShibokenGenerator::cpythonTypeName(const TypeEntry *type)
return cpythonBaseName(type) + QLatin1String("_TypeF()");
}
-QString ShibokenGenerator::cpythonTypeNameExt(const TypeEntry *type)
+QString ShibokenGenerator::cpythonTypeNameExt(const TypeEntry *type) const
{
return cppApiVariableName(type->targetLangPackage()) + QLatin1Char('[')
+ getTypeIndexVariableName(type) + QLatin1Char(']');
@@ -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) const
{
return cppApiVariableName(type->typeEntry()->targetLangPackage()) + QLatin1Char('[')
+ getTypeIndexVariableName(type) + QLatin1Char(']');
@@ -2182,9 +2182,18 @@ bool ShibokenGenerator::injectedCodeUsesArgument(const AbstractMetaFunction *fun
return false;
}
-bool ShibokenGenerator::classNeedsGetattroFunction(const AbstractMetaClass *metaClass)
+ShibokenGenerator::AttroCheck ShibokenGenerator::checkAttroFunctionNeeds(const AbstractMetaClass *metaClass) const
{
- return getGeneratorClassInfo(metaClass).needsGetattroFunction;
+ AttroCheck result;
+ if (metaClass->typeEntry()->isSmartPointer()) {
+ result |= AttroCheckFlag::GetattroSmartPointer | AttroCheckFlag::SetattroSmartPointer;
+ } else {
+ if (getGeneratorClassInfo(metaClass).needsGetattroFunction)
+ result |= AttroCheckFlag::GetattroOverloads;
+ if (usePySideExtensions() && metaClass->qualifiedCppName() == QLatin1String("QObject"))
+ result |= AttroCheckFlag::SetattroQObject;
+ }
+ return result;
}
bool ShibokenGenerator::classNeedsGetattroFunctionImpl(const AbstractMetaClass *metaClass)
@@ -2211,13 +2220,6 @@ bool ShibokenGenerator::classNeedsGetattroFunctionImpl(const AbstractMetaClass *
return false;
}
-bool ShibokenGenerator::classNeedsSetattroFunction(const AbstractMetaClass *metaClass)
-{
- if (!metaClass)
- return false;
- return metaClass->typeEntry()->isSmartPointer();
-}
-
AbstractMetaFunctionList ShibokenGenerator::getMethodsWithBothStaticAndNonStaticMethods(const AbstractMetaClass *metaClass)
{
AbstractMetaFunctionList methods;
@@ -2648,7 +2650,8 @@ 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) const
{
if (alternativeTemplateName) {
const AbstractMetaClass *templateBaseClass = metaClass->templateBaseClass();
@@ -2664,7 +2667,7 @@ QString ShibokenGenerator::getTypeIndexVariableName(const AbstractMetaClass *met
}
return getTypeIndexVariableName(metaClass->typeEntry());
}
-QString ShibokenGenerator::getTypeIndexVariableName(const TypeEntry *type)
+QString ShibokenGenerator::getTypeIndexVariableName(const TypeEntry *type) const
{
if (type->isCppPrimitive()) {
const auto *trueType = static_cast<const PrimitiveTypeEntry *>(type);
@@ -2682,7 +2685,7 @@ QString ShibokenGenerator::getTypeIndexVariableName(const TypeEntry *type)
appendIndexSuffix(&result);
return result;
}
-QString ShibokenGenerator::getTypeIndexVariableName(const AbstractMetaType *type)
+QString ShibokenGenerator::getTypeIndexVariableName(const AbstractMetaType *type) const
{
QString result = QLatin1String("SBK");
if (type->typeEntry()->isContainer())
diff --git a/sources/shiboken2/generator/shiboken2/shibokengenerator.h b/sources/shiboken2/generator/shiboken2/shibokengenerator.h
index 7970ceb94..13419b79b 100644
--- a/sources/shiboken2/generator/shiboken2/shibokengenerator.h
+++ b/sources/shiboken2/generator/shiboken2/shibokengenerator.h
@@ -64,6 +64,18 @@ QT_FORWARD_DECLARE_CLASS(QTextStream)
class ShibokenGenerator : public Generator
{
public:
+ enum class AttroCheckFlag
+ {
+ None = 0x0,
+ GetattroOverloads = 0x01,
+ GetattroSmartPointer = 0x02,
+ GetattroMask = 0x0F,
+ SetattroQObject = 0x10,
+ SetattroSmartPointer = 0x20,
+ SetattroMask = 0xF0,
+ };
+ Q_DECLARE_FLAGS(AttroCheck, AttroCheckFlag);
+
using FunctionGroups = QMap<QString, AbstractMetaFunctionList>; // Sorted
ShibokenGenerator();
@@ -181,11 +193,7 @@ protected:
/// Returns the top-most class that has multiple inheritance in the ancestry.
static const AbstractMetaClass *getMultipleInheritingClass(const AbstractMetaClass *metaClass);
- /// Returns true if the class needs to have a getattro function.
- bool classNeedsGetattroFunction(const AbstractMetaClass *metaClass);
-
- /// Returns true if the class needs to have a setattro function.
- bool classNeedsSetattroFunction(const AbstractMetaClass *metaClass);
+ AttroCheck checkAttroFunctionNeeds(const AbstractMetaClass *metaClass) const;
/// 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);
@@ -282,13 +290,13 @@ protected:
QString converterObject(const AbstractMetaType *type);
QString converterObject(const TypeEntry *type);
- QString cpythonBaseName(const AbstractMetaClass *metaClass);
- QString cpythonBaseName(const TypeEntry *type);
+ static QString cpythonBaseName(const AbstractMetaClass *metaClass);
+ static 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 cpythonTypeNameExt(const TypeEntry *type) const;
+ QString cpythonTypeNameExt(const AbstractMetaType *type) const;
QString cpythonCheckFunction(const TypeEntry *type, bool genericNumberType = false);
QString cpythonCheckFunction(const AbstractMetaType *metaType, bool genericNumberType = false);
/**
@@ -315,14 +323,14 @@ protected:
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);
+ static QString cpythonGetattroFunctionName(const AbstractMetaClass *metaClass);
+ static 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);
+ const QString &argName = QLatin1String("self")) const;
+ QString cpythonWrapperCPtr(const AbstractMetaType *metaType, const QString &argName) const;
+ QString cpythonWrapperCPtr(const TypeEntry *type, const QString &argName) const;
/// Guesses the scope to where belongs an argument's default value.
QString guessScopeForDefaultValue(const AbstractMetaFunction *func,
@@ -331,13 +339,13 @@ protected:
const AbstractMetaArgument *arg,
const QString &value) const;
- QString cpythonEnumName(const EnumTypeEntry *enumEntry);
- QString cpythonEnumName(const AbstractMetaEnum *metaEnum);
+ static QString cpythonEnumName(const EnumTypeEntry *enumEntry);
+ static QString cpythonEnumName(const AbstractMetaEnum *metaEnum);
- QString cpythonFlagsName(const FlagsTypeEntry *flagsEntry);
- QString cpythonFlagsName(const AbstractMetaEnum *metaEnum);
+ static QString cpythonFlagsName(const FlagsTypeEntry *flagsEntry);
+ static 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);
+ static QString cpythonSpecialCastFunctionName(const AbstractMetaClass *metaClass);
QString getFormatUnitString(const AbstractMetaFunction *func, bool incRef = false) const;
@@ -366,9 +374,9 @@ protected:
* 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) const;
+ QString getTypeIndexVariableName(const TypeEntry *type) const;
+ QString getTypeIndexVariableName(const AbstractMetaType *type) const;
/// Returns true if the user don't want verbose error messages on the generated bindings.
bool verboseErrorMessagesDisabled() const;
@@ -545,4 +553,6 @@ private:
QRegularExpression m_typeSystemConvRegEx[TypeSystemConverterVariables];
};
+Q_DECLARE_OPERATORS_FOR_FLAGS(ShibokenGenerator::AttroCheck);
+
#endif // SHIBOKENGENERATOR_H