aboutsummaryrefslogtreecommitdiffstats
path: root/sources/shiboken2/generator
diff options
context:
space:
mode:
authorFriedemann Kleint <Friedemann.Kleint@qt.io>2020-02-12 15:42:47 +0100
committerFriedemann Kleint <Friedemann.Kleint@qt.io>2020-02-12 15:50:05 +0100
commit02018700e86a7eea18eac2952b819a9b77606d1b (patch)
tree5bd19b6d28405dc92655f10c9f7ed7157756bc15 /sources/shiboken2/generator
parent431a945ab99b6977dd0feace2b4982b801d07cbd (diff)
parent125c35014aeb4ae6944f8d2b3cdc673dce7bee3e (diff)
Merge remote-tracking branch 'origin/5.14' into 5.15
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 8b7ecfd4a..f9020420f 100644
--- a/sources/shiboken2/generator/shiboken2/cppgenerator.cpp
+++ b/sources/shiboken2/generator/shiboken2/cppgenerator.cpp
@@ -561,21 +561,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 << Qt::endl;
- writeSetattroFunction(s, classContext);
- s << Qt::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 << Qt::endl;
- }
- if (classNeedsSetattroFunction(metaClass)) {
- writeSetattroFunction(s, classContext);
- s << Qt::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)) {
@@ -3886,17 +3881,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");
@@ -5232,63 +5221,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";
{
@@ -5334,50 +5348,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";
}
// Write declaration and invocation of the init function for the module init
diff --git a/sources/shiboken2/generator/shiboken2/cppgenerator.h b/sources/shiboken2/generator/shiboken2/cppgenerator.h
index 2134adeda..4b7c80ee4 100644
--- a/sources/shiboken2/generator/shiboken2/cppgenerator.h
+++ b/sources/shiboken2/generator/shiboken2/cppgenerator.h
@@ -105,9 +105,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 320f19dcf..9793998b9 100644
--- a/sources/shiboken2/generator/shiboken2/shibokengenerator.cpp
+++ b/sources/shiboken2/generator/shiboken2/shibokengenerator.cpp
@@ -644,13 +644,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();
@@ -660,7 +660,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();
@@ -829,7 +829,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(']');
@@ -882,7 +882,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(']');
@@ -2167,9 +2167,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)
@@ -2196,13 +2205,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;
@@ -2639,7 +2641,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();
@@ -2655,7 +2658,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);
@@ -2673,7 +2676,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 4501b902d..55622b7c2 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);
@@ -280,13 +288,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);
/**
@@ -313,14 +321,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,
@@ -329,13 +337,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;
@@ -364,9 +372,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;
@@ -543,4 +551,6 @@ private:
QRegularExpression m_typeSystemConvRegEx[TypeSystemConverterVariables];
};
+Q_DECLARE_OPERATORS_FOR_FLAGS(ShibokenGenerator::AttroCheck);
+
#endif // SHIBOKENGENERATOR_H