aboutsummaryrefslogtreecommitdiffstats
path: root/sources
diff options
context:
space:
mode:
authorFriedemann Kleint <Friedemann.Kleint@qt.io>2020-09-24 07:39:50 +0200
committerFriedemann Kleint <Friedemann.Kleint@qt.io>2020-09-24 07:49:07 +0200
commit9881b68c4c7bc1715cd266c41c63a3a918d83b07 (patch)
tree5252e3e767e64d98383f6103d9d5941a206a52bc /sources
parent17a20f95151368a3b92b949b905325865643ca45 (diff)
parentcad869b619fdc0969216e6e9b63fd1afb5edb7db (diff)
Merge remote-tracking branch 'origin/5.15' into dev
Diffstat (limited to 'sources')
-rw-r--r--sources/pyside2/PySide2/QtGui/CMakeLists.txt2
-rw-r--r--sources/pyside2/PySide2/QtGui/typesystem_gui_common.xml11
-rw-r--r--sources/pyside2/PySide2/QtWidgets/typesystem_widgets_common.xml4
-rw-r--r--sources/pyside2/doc/index.rst4
-rw-r--r--sources/pyside2/doc/tutorials/expenses/main_snake_prop.py5
-rw-r--r--sources/pyside2/tests/QtGui/qcolor_test.py5
-rw-r--r--sources/shiboken2/ApiExtractor/CMakeLists.txt1
-rw-r--r--sources/shiboken2/ApiExtractor/abstractmetabuilder.cpp95
-rw-r--r--sources/shiboken2/ApiExtractor/abstractmetabuilder_p.h2
-rw-r--r--sources/shiboken2/ApiExtractor/abstractmetalang.cpp42
-rw-r--r--sources/shiboken2/ApiExtractor/abstractmetalang.h95
-rw-r--r--sources/shiboken2/ApiExtractor/doxygenparser.cpp1
-rw-r--r--sources/shiboken2/ApiExtractor/messages.cpp19
-rw-r--r--sources/shiboken2/ApiExtractor/messages.h4
-rw-r--r--sources/shiboken2/ApiExtractor/propertyspec.cpp217
-rw-r--r--sources/shiboken2/ApiExtractor/propertyspec.h110
-rw-r--r--sources/shiboken2/ApiExtractor/qtdocparser.cpp1
-rw-r--r--sources/shiboken2/ApiExtractor/typesystem.h16
-rw-r--r--sources/shiboken2/ApiExtractor/typesystemparser.cpp35
-rw-r--r--sources/shiboken2/ApiExtractor/typesystemparser.h3
-rw-r--r--sources/shiboken2/doc/typesystem_manipulating_objects.rst32
-rw-r--r--sources/shiboken2/generator/qtdoc/qtdocgenerator.cpp1
-rw-r--r--sources/shiboken2/generator/shiboken2/cppgenerator.cpp10
-rw-r--r--sources/shiboken2/libshiboken/signature.cpp308
24 files changed, 635 insertions, 388 deletions
diff --git a/sources/pyside2/PySide2/QtGui/CMakeLists.txt b/sources/pyside2/PySide2/QtGui/CMakeLists.txt
index c6393a1aa..7885af343 100644
--- a/sources/pyside2/PySide2/QtGui/CMakeLists.txt
+++ b/sources/pyside2/PySide2/QtGui/CMakeLists.txt
@@ -34,6 +34,8 @@ ${QtGui_GEN_DIR}/qclipboard_wrapper.cpp
${QtGui_GEN_DIR}/qcloseevent_wrapper.cpp
${QtGui_GEN_DIR}/qcolor_wrapper.cpp
${QtGui_GEN_DIR}/qcolorspace_wrapper.cpp
+${QtGui_GEN_DIR}/qcolorconstants_wrapper.cpp
+${QtGui_GEN_DIR}/qcolorconstants_svg_wrapper.cpp
${QtGui_GEN_DIR}/qconicalgradient_wrapper.cpp
${QtGui_GEN_DIR}/qcontextmenuevent_wrapper.cpp
${QtGui_GEN_DIR}/qcursor_wrapper.cpp
diff --git a/sources/pyside2/PySide2/QtGui/typesystem_gui_common.xml b/sources/pyside2/PySide2/QtGui/typesystem_gui_common.xml
index a096cb0b4..f3456e646 100644
--- a/sources/pyside2/PySide2/QtGui/typesystem_gui_common.xml
+++ b/sources/pyside2/PySide2/QtGui/typesystem_gui_common.xml
@@ -1001,6 +1001,17 @@
</modify-function>
</value-type>
+ <namespace-type name="QColorConstants" since="5.14">
+ <extra-includes>
+ <include file-name="QColor" location="global"/>
+ </extra-includes>
+ <namespace-type name="Svg" since="5.14">
+ <extra-includes>
+ <include file-name="QColor" location="global"/>
+ </extra-includes>
+ </namespace-type>
+ </namespace-type>
+
<value-type name="QColorSpace" since="5.14">
<enum-type name="NamedColorSpace"/>
<enum-type name="Primaries"/>
diff --git a/sources/pyside2/PySide2/QtWidgets/typesystem_widgets_common.xml b/sources/pyside2/PySide2/QtWidgets/typesystem_widgets_common.xml
index 6347c9394..be53f97de 100644
--- a/sources/pyside2/PySide2/QtWidgets/typesystem_widgets_common.xml
+++ b/sources/pyside2/PySide2/QtWidgets/typesystem_widgets_common.xml
@@ -1182,7 +1182,8 @@
<object-type name="QLayout">
<inject-code class="native" position="beginning" file="../glue/qtwidgets.cpp" snippet="qlayout-help-functions"/>
-
+ <!-- Becomes a real Q_OPROPERTY in Qt 6 -->
+ <property name="contentsMargins" type="QMargins" get="contentsMargins" set="setContentsMargins"/>
<enum-type name="SizeConstraint"/>
<modify-function signature="itemAt(int)const">
@@ -1211,6 +1212,7 @@
<modify-function signature="takeAt(int)">
<modify-argument index="return">
<parent index="this" action="remove"/>
+ <define-ownership class="native" owner="c++"/>
</modify-argument>
</modify-function>
diff --git a/sources/pyside2/doc/index.rst b/sources/pyside2/doc/index.rst
index 72a26d19d..289a653f3 100644
--- a/sources/pyside2/doc/index.rst
+++ b/sources/pyside2/doc/index.rst
@@ -80,6 +80,10 @@ Documentation
</tr>
</table>
+We have also a `wiki page`_ where you can find how to report bugs, contribute or contact the community.
+
+.. _`wiki page`: https://wiki.qt.io/Qt_for_Python
+
.. toctree::
:hidden:
:glob:
diff --git a/sources/pyside2/doc/tutorials/expenses/main_snake_prop.py b/sources/pyside2/doc/tutorials/expenses/main_snake_prop.py
index 4421980c5..f4382e711 100644
--- a/sources/pyside2/doc/tutorials/expenses/main_snake_prop.py
+++ b/sources/pyside2/doc/tutorials/expenses/main_snake_prop.py
@@ -39,7 +39,7 @@
#############################################################################
import sys
-from PySide2.QtCore import Qt, Slot, QSize
+from PySide2.QtCore import QMargins, Qt, Slot, QSize
from PySide2.QtGui import QPainter
from PySide2.QtWidgets import (QAction, QApplication, QHeaderView, QHBoxLayout, QLabel, QLineEdit,
QMainWindow, QPushButton, QTableWidget, QTableWidgetItem,
@@ -81,7 +81,8 @@ class Widget(QWidget):
self.add.enabled = False
self.right = QVBoxLayout()
- self.right.margin = 10
+
+ self.right.contents_margins = QMargins(10, 10, 10, 10)
self.right.add_widget(QLabel("Description"))
self.right.add_widget(self.description)
self.right.add_widget(QLabel("Price"))
diff --git a/sources/pyside2/tests/QtGui/qcolor_test.py b/sources/pyside2/tests/QtGui/qcolor_test.py
index 55554b6c5..22955d86e 100644
--- a/sources/pyside2/tests/QtGui/qcolor_test.py
+++ b/sources/pyside2/tests/QtGui/qcolor_test.py
@@ -37,7 +37,7 @@ init_test_paths(False)
import PySide2
from PySide2.QtCore import Qt
-from PySide2.QtGui import QColor
+from PySide2.QtGui import QColor, QColorConstants
class QColorGetTest(unittest.TestCase):
@@ -115,7 +115,8 @@ class QColorCopy(unittest.TestCase):
class QColorRepr(unittest.TestCase):
def testReprFunction(self):
- c = QColor(100, 120, 200)
+ # QColorConstants are disabled for MSVC/5.15, fixme: Check Qt 6
+ c = QColorConstants.Yellow if sys.platform != 'win32' else QColor(100, 120, 200)
c2 = eval(c.__repr__())
self.assertEqual(c, c2)
diff --git a/sources/shiboken2/ApiExtractor/CMakeLists.txt b/sources/shiboken2/ApiExtractor/CMakeLists.txt
index 20e10c2cc..cbe3310a4 100644
--- a/sources/shiboken2/ApiExtractor/CMakeLists.txt
+++ b/sources/shiboken2/ApiExtractor/CMakeLists.txt
@@ -12,6 +12,7 @@ abstractmetalang.cpp
fileout.cpp
graph.cpp
messages.cpp
+propertyspec.cpp
reporthandler.cpp
sourcelocation.cpp
typeparser.cpp
diff --git a/sources/shiboken2/ApiExtractor/abstractmetabuilder.cpp b/sources/shiboken2/ApiExtractor/abstractmetabuilder.cpp
index b6a38dbeb..4dccbf09d 100644
--- a/sources/shiboken2/ApiExtractor/abstractmetabuilder.cpp
+++ b/sources/shiboken2/ApiExtractor/abstractmetabuilder.cpp
@@ -28,6 +28,7 @@
#include "abstractmetabuilder_p.h"
#include "messages.h"
+#include "propertyspec.h"
#include "reporthandler.h"
#include "typedatabase.h"
@@ -1300,7 +1301,7 @@ void AbstractMetaBuilderPrivate::traverseFunctions(ScopeModelItem scopeItem,
QPropertySpec *read = nullptr;
if (!metaFunction->isSignal() && (read = metaClass->propertySpecForRead(metaFunction->name()))) {
// Property reader must be in the form "<type> name()"
- if (metaFunction->type() && (read->type() == metaFunction->type()->typeEntry())
+ if (metaFunction->type() && (read->typeEntry() == metaFunction->type()->typeEntry())
&& metaFunction->arguments().isEmpty()) {
*metaFunction += AbstractMetaAttributes::PropertyReader;
metaFunction->setPropertySpec(read);
@@ -1309,7 +1310,8 @@ void AbstractMetaBuilderPrivate::traverseFunctions(ScopeModelItem scopeItem,
// Property setter must be in the form "void name(<type>)"
// Make sure the function was created with all arguments; some argument can be
// missing during the parsing because of errors in the typesystem.
- if ((!metaFunction->type()) && (metaFunction->arguments().size() == 1) && (write->type() == metaFunction->arguments().at(0)->type()->typeEntry())) {
+ if ((!metaFunction->type()) && (metaFunction->arguments().size() == 1)
+ && (write->typeEntry() == metaFunction->arguments().at(0)->type()->typeEntry())) {
*metaFunction += AbstractMetaAttributes::PropertyWriter;
metaFunction->setPropertySpec(write);
}
@@ -2784,8 +2786,9 @@ void AbstractMetaBuilderPrivate::parseQ_Properties(AbstractMetaClass *metaClass,
{
const QStringList scopes = currentScope()->qualifiedName();
QString errorMessage;
- for (int i = 0; i < declarations.size(); ++i) {
- if (auto spec = parseQ_Property(metaClass, declarations.at(i), scopes, &errorMessage)) {
+ int i = 0;
+ for (; i < declarations.size(); ++i) {
+ if (auto spec = QPropertySpec::parseQ_Property(this, metaClass, declarations.at(i), scopes, &errorMessage)) {
spec->setIndex(i);
metaClass->addPropertySpec(spec);
} else {
@@ -2795,76 +2798,26 @@ void AbstractMetaBuilderPrivate::parseQ_Properties(AbstractMetaClass *metaClass,
qCWarning(lcShiboken, "%s", qPrintable(message));
}
}
-}
-
-QPropertySpec *AbstractMetaBuilderPrivate::parseQ_Property(AbstractMetaClass *metaClass,
- const QString &declarationIn,
- const QStringList &scopes,
- QString *errorMessage)
-{
- errorMessage->clear();
-
- // Q_PROPERTY(QString objectName READ objectName WRITE setObjectName NOTIFY objectNameChanged)
-
- const QString declaration = declarationIn.simplified();
- auto propertyTokens = QStringView{declaration}.split(QLatin1Char(' '),
- Qt::SkipEmptyParts);
- if (propertyTokens.size() < 4) {
- *errorMessage = QLatin1String("Insufficient number of tokens");
- return nullptr;
- }
- QString fullTypeName = propertyTokens.takeFirst().toString();
- QString name = propertyTokens.takeFirst().toString();
- // Fix errors like "Q_PROPERTY(QXYSeries *series .." to be of type "QXYSeries*"
- while (name.startsWith(QLatin1Char('*'))) {
- fullTypeName += name.at(0);
- name.remove(0, 1);
- }
-
- int indirections = 0;
- QString typeName = fullTypeName;
- for (; typeName.endsWith(QLatin1Char('*')); ++indirections)
- typeName.chop(1);
-
- QScopedPointer<AbstractMetaType> type;
- QString typeError;
- for (int j = scopes.size(); j >= 0 && type.isNull(); --j) {
- QStringList qualifiedName = scopes.mid(0, j);
- qualifiedName.append(typeName);
- TypeInfo info;
- info.setIndirections(indirections);
- info.setQualifiedName(qualifiedName);
- type.reset(translateType(info, metaClass, {}, &typeError));
- }
-
- if (!type) {
- QTextStream str(errorMessage);
- str << "Unable to decide type of property: \"" << name << "\" ("
- << typeName << "): " << typeError;
- return nullptr;
- }
-
- QScopedPointer<QPropertySpec> spec(new QPropertySpec(type->typeEntry()));
- spec->setName(name);
- spec->setIndirections(indirections);
-
- for (int pos = 0; pos + 1 < propertyTokens.size(); pos += 2) {
- if (propertyTokens.at(pos) == QLatin1String("READ"))
- spec->setRead(propertyTokens.at(pos + 1).toString());
- else if (propertyTokens.at(pos) == QLatin1String("WRITE"))
- spec->setWrite(propertyTokens.at(pos + 1).toString());
- else if (propertyTokens.at(pos) == QLatin1String("DESIGNABLE"))
- spec->setDesignable(propertyTokens.at(pos + 1).toString());
- else if (propertyTokens.at(pos) == QLatin1String("RESET"))
- spec->setReset(propertyTokens.at(pos + 1).toString());
- }
+ // User-added properties
+ auto typeEntry = metaClass->typeEntry();
+ for (const TypeSystemProperty &tp : typeEntry->properties()) {
+ QPropertySpec *spec = nullptr;
+ if (metaClass->propertySpecByName(tp.name))
+ errorMessage = msgPropertyExists(metaClass->name(), tp.name);
+ else
+ spec = QPropertySpec::fromTypeSystemProperty(this, metaClass, tp, scopes, &errorMessage);
- if (!spec->isValid()) {
- *errorMessage = QLatin1String("Incomplete specification");
- return nullptr;
+ if (spec) {
+ spec->setIndex(i++);
+ metaClass->addPropertySpec(spec);
+ } else {
+ QString message;
+ QTextStream str(&message);
+ str << typeEntry->sourceLocation() << errorMessage;
+ qCWarning(lcShiboken, "%s", qPrintable(message));
+ }
}
- return spec.take();
}
static AbstractMetaFunction* findCopyCtor(AbstractMetaClass* cls)
diff --git a/sources/shiboken2/ApiExtractor/abstractmetabuilder_p.h b/sources/shiboken2/ApiExtractor/abstractmetabuilder_p.h
index 2867e5f74..671775130 100644
--- a/sources/shiboken2/ApiExtractor/abstractmetabuilder_p.h
+++ b/sources/shiboken2/ApiExtractor/abstractmetabuilder_p.h
@@ -126,8 +126,6 @@ public:
void fixReturnTypeOfConversionOperator(AbstractMetaFunction *metaFunction);
void parseQ_Properties(AbstractMetaClass *metaClass, const QStringList &declarations);
- QPropertySpec *parseQ_Property(AbstractMetaClass *metaClass, const QString &declaration,
- const QStringList &scopes, QString *errorMessage);
void setupEquals(AbstractMetaClass *metaClass);
void setupComparable(AbstractMetaClass *metaClass);
void setupClonable(AbstractMetaClass *cls);
diff --git a/sources/shiboken2/ApiExtractor/abstractmetalang.cpp b/sources/shiboken2/ApiExtractor/abstractmetalang.cpp
index 382eea191..e300fd827 100644
--- a/sources/shiboken2/ApiExtractor/abstractmetalang.cpp
+++ b/sources/shiboken2/ApiExtractor/abstractmetalang.cpp
@@ -28,6 +28,7 @@
#include "abstractmetalang.h"
#include "messages.h"
+#include "propertyspec.h"
#include "reporthandler.h"
#include "typedatabase.h"
#include "typesystem.h"
@@ -1396,6 +1397,7 @@ AbstractMetaClass::~AbstractMetaClass()
qDeleteAll(m_functions);
qDeleteAll(m_fields);
qDeleteAll(m_enums);
+ qDeleteAll(m_propertySpecs);
if (hasTemplateBaseClassInstantiations())
qDeleteAll(templateBaseClassInstantiations());
}
@@ -1689,6 +1691,15 @@ bool AbstractMetaClass::hasProtectedMembers() const
return hasProtectedFields() || hasProtectedFunctions();
}
+QPropertySpec *AbstractMetaClass::propertySpecByName(const QString &name) const
+{
+ for (auto propertySpec : m_propertySpecs) {
+ if (name == propertySpec->name())
+ return propertySpec;
+ }
+ return nullptr;
+}
+
QPropertySpec *AbstractMetaClass::propertySpecForRead(const QString &name) const
{
for (const auto &propertySpec : m_propertySpecs) {
@@ -2790,34 +2801,3 @@ QString AbstractMetaEnum::package() const
return m_typeEntry->targetLangPackage();
}
-bool QPropertySpec::isValid() const
-{
- return m_type != nullptr && !m_name.isEmpty() && !m_read.isEmpty();
-}
-
-#ifndef QT_NO_DEBUG_STREAM
-void QPropertySpec::formatDebug(QDebug &d) const
-{
- d << '#' << m_index << " \"" << m_name << "\" (" << m_type->qualifiedCppName();
- for (int i = 0; i < m_indirections; ++i)
- d << '*';
- d << "), read=" << m_read;
- if (!m_write.isEmpty())
- d << ", write=" << m_write;
- if (!m_reset.isEmpty())
- d << ", reset=" << m_reset;
- if (!m_designable.isEmpty())
- d << ", designable=" << m_designable;
-}
-
-QDebug operator<<(QDebug d, const QPropertySpec &p)
-{
- QDebugStateSaver s(d);
- d.noquote();
- d.nospace();
- d << "QPropertySpec(";
- p.formatDebug(d);
- d << ')';
- return d;
-}
-#endif // QT_NO_DEBUG_STREAM
diff --git a/sources/shiboken2/ApiExtractor/abstractmetalang.h b/sources/shiboken2/ApiExtractor/abstractmetalang.h
index 2fe114de4..c17051f45 100644
--- a/sources/shiboken2/ApiExtractor/abstractmetalang.h
+++ b/sources/shiboken2/ApiExtractor/abstractmetalang.h
@@ -1607,6 +1607,7 @@ public:
return m_propertySpecs;
}
+ QPropertySpec *propertySpecByName(const QString &name) const;
QPropertySpec *propertySpecForRead(const QString &name) const;
QPropertySpec *propertySpecForWrite(const QString &name) const;
QPropertySpec *propertySpecForReset(const QString &name) const;
@@ -1734,98 +1735,4 @@ private:
Q_DECLARE_OPERATORS_FOR_FLAGS(AbstractMetaClass::FunctionQueryOptions)
Q_DECLARE_OPERATORS_FOR_FLAGS(AbstractMetaClass::OperatorQueryOptions)
-class QPropertySpec
-{
-public:
- explicit QPropertySpec(const TypeEntry *type) : m_type(type) {}
-
- bool isValid() const;
-
- const TypeEntry *type() const
- {
- return m_type;
- }
-
- int indirections() const { return m_indirections; }
- void setIndirections(int indirections) { m_indirections = indirections; }
-
- QString name() const
- {
- return m_name;
- }
-
- void setName(const QString &name)
- {
- m_name = name;
- }
-
- QString read() const
- {
- return m_read;
- }
-
- void setRead(const QString &read)
- {
- m_read = read;
- }
-
- QString write() const
- {
- return m_write;
- }
-
- void setWrite(const QString &write)
- {
- m_write = write;
- }
-
- QString designable() const
- {
- return m_designable;
- }
-
- void setDesignable(const QString &designable)
- {
- m_designable = designable;
- }
-
- QString reset() const
- {
- return m_reset;
- }
-
- void setReset(const QString &reset)
- {
- m_reset = reset;
- }
-
- int index() const
- {
- return m_index;
- }
-
- void setIndex(int index)
- {
- m_index = index;
- }
-
-#ifndef QT_NO_DEBUG_STREAM
- void formatDebug(QDebug &d) const;
-#endif
-
-private:
- QString m_name;
- QString m_read;
- QString m_write;
- QString m_designable;
- QString m_reset;
- const TypeEntry *m_type;
- int m_indirections = 0;
- int m_index = -1;
-};
-
-#ifndef QT_NO_DEBUG_STREAM
-QDebug operator<<(QDebug d, const QPropertySpec &p);
-#endif
-
#endif // ABSTRACTMETALANG_H
diff --git a/sources/shiboken2/ApiExtractor/doxygenparser.cpp b/sources/shiboken2/ApiExtractor/doxygenparser.cpp
index 9fceb4328..da6e32fba 100644
--- a/sources/shiboken2/ApiExtractor/doxygenparser.cpp
+++ b/sources/shiboken2/ApiExtractor/doxygenparser.cpp
@@ -29,6 +29,7 @@
#include "doxygenparser.h"
#include "abstractmetalang.h"
#include "messages.h"
+#include "propertyspec.h"
#include "reporthandler.h"
#include "typesystem.h"
#include "xmlutils.h"
diff --git a/sources/shiboken2/ApiExtractor/messages.cpp b/sources/shiboken2/ApiExtractor/messages.cpp
index f218faace..55c51ffa4 100644
--- a/sources/shiboken2/ApiExtractor/messages.cpp
+++ b/sources/shiboken2/ApiExtractor/messages.cpp
@@ -1,4 +1,4 @@
-/****************************************************************************
+/****************************************************************************
**
** Copyright (C) 2018 The Qt Company Ltd.
** Contact: https://www.qt.io/licensing/
@@ -368,6 +368,23 @@ QString msgNamespaceToBeExtendedNotFound(const QString &namespaceName, const QSt
+ packageName + QLatin1Char('.');
}
+QString msgPropertyTypeParsingFailed(const QString &name, const QString &typeName,
+ const QString &why)
+{
+ QString result;
+ QTextStream str(&result);
+ str << "Unable to decide type of property: \"" << name << "\" (" << typeName
+ << "): " << why;
+ return result;
+}
+
+QString msgPropertyExists(const QString &className, const QString &name)
+{
+ return QLatin1String("class ") + className
+ + QLatin1String(" already has a property \"") + name
+ + QLatin1String("\" (defined by Q_PROPERTY).");
+}
+
// docparser.cpp
QString msgCannotFindDocumentation(const QString &fileName,
diff --git a/sources/shiboken2/ApiExtractor/messages.h b/sources/shiboken2/ApiExtractor/messages.h
index 4dd808a66..6c173dc09 100644
--- a/sources/shiboken2/ApiExtractor/messages.h
+++ b/sources/shiboken2/ApiExtractor/messages.h
@@ -127,6 +127,10 @@ QString msgDisallowThread(const AbstractMetaFunction *f);
QString msgNamespaceToBeExtendedNotFound(const QString &namespaceName, const QString &packageName);
+QString msgPropertyTypeParsingFailed(const QString &name, const QString &typeName,
+ const QString &why);
+QString msgPropertyExists(const QString &className, const QString &name);
+
QString msgCannotFindDocumentation(const QString &fileName,
const char *what, const QString &name,
const QString &query);
diff --git a/sources/shiboken2/ApiExtractor/propertyspec.cpp b/sources/shiboken2/ApiExtractor/propertyspec.cpp
new file mode 100644
index 000000000..fcb8286bf
--- /dev/null
+++ b/sources/shiboken2/ApiExtractor/propertyspec.cpp
@@ -0,0 +1,217 @@
+/****************************************************************************
+**
+** Copyright (C) 2020 The Qt Company Ltd.
+** Contact: https://www.qt.io/licensing/
+**
+** This file is part of Qt for Python.
+**
+** $QT_BEGIN_LICENSE:GPL-EXCEPT$
+** Commercial License Usage
+** Licensees holding valid commercial Qt licenses may use this file in
+** accordance with the commercial license agreement provided with the
+** Software or, alternatively, in accordance with the terms contained in
+** a written agreement between you and The Qt Company. For licensing terms
+** and conditions see https://www.qt.io/terms-conditions. For further
+** information use the contact form at https://www.qt.io/contact-us.
+**
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU
+** General Public License version 3 as published by the Free Software
+** Foundation with exceptions as appearing in the file LICENSE.GPL3-EXCEPT
+** included in the packaging of this file. Please review the following
+** information to ensure the GNU General Public License requirements will
+** be met: https://www.gnu.org/licenses/gpl-3.0.html.
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#include "propertyspec.h"
+#include "abstractmetalang.h"
+#include "abstractmetabuilder_p.h"
+#include "codemodel.h"
+#include "messages.h"
+#include "typesystem.h"
+
+#include <QtCore/QHash>
+
+#ifndef QT_NO_DEBUG_STREAM
+# include <QtCore/QDebug>
+#endif
+
+#include <algorithm>
+
+QPropertySpec::QPropertySpec(const TypeSystemProperty &ts,
+ const AbstractMetaType *type) :
+ m_name(ts.name),
+ m_read(ts.read),
+ m_write(ts.write),
+ m_designable(ts.designable),
+ m_reset(ts.reset),
+ m_type(type)
+{
+}
+
+QPropertySpec::~QPropertySpec()
+{
+ delete m_type;
+}
+
+bool QPropertySpec::isValid() const
+{
+ return m_type != nullptr && !m_name.isEmpty() && !m_read.isEmpty();
+}
+
+const TypeEntry *QPropertySpec::typeEntry() const
+{
+ return m_type->typeEntry();
+}
+
+// Parse a Q_PROPERTY macro
+// Q_PROPERTY(QString objectName READ objectName WRITE setObjectName NOTIFY objectNameChanged)
+// into a TypeSystemProperty.
+TypeSystemProperty QPropertySpec::typeSystemPropertyFromQ_Property(const QString &declarationIn,
+ QString *errorMessage)
+{
+ enum class PropertyToken { None, Read, Write, Designable, Reset };
+
+ static const QHash<QString, PropertyToken> tokenLookup = {
+ {QStringLiteral("READ"), PropertyToken::Read},
+ {QStringLiteral("WRITE"), PropertyToken::Write},
+ {QStringLiteral("DESIGNABLE"), PropertyToken::Designable},
+ {QStringLiteral("RESET"), PropertyToken::Reset}
+ };
+
+ errorMessage->clear();
+
+ TypeSystemProperty result;
+
+ // Q_PROPERTY(QString objectName READ objectName WRITE setObjectName NOTIFY objectNameChanged)
+
+ const QString declaration = declarationIn.simplified();
+ auto propertyTokens = declaration.split(QLatin1Char(' '), Qt::SkipEmptyParts);
+
+ // To properly parse complicated type declarations like
+ // "Q_PROPERTY(const QList<QString > *objectName READ objectName ..."
+ // we first search the first "READ" token, parse the subsequent tokens and
+ // extract type and name from the tokens before "READ".
+ const auto it = std::find_if(propertyTokens.cbegin(), propertyTokens.cend(),
+ [](const QString &t) { return tokenLookup.contains(t); });
+ if (it == propertyTokens.cend()) {
+ *errorMessage = QLatin1String("Invalid property specification, READ missing");
+ return result;
+ }
+
+ const int firstToken = int(it - propertyTokens.cbegin());
+ if (firstToken < 2) {
+ *errorMessage = QLatin1String("Insufficient number of tokens in property specification");
+ return result;
+ }
+
+ for (int pos = firstToken; pos + 1 < propertyTokens.size(); pos += 2) {
+ switch (tokenLookup.value(propertyTokens.at(pos))) {
+ case PropertyToken::Read:
+ result.read = propertyTokens.at(pos + 1);
+ break;
+ case PropertyToken::Write:
+ result.write = propertyTokens.at(pos + 1);
+ break;
+ case PropertyToken::Reset:
+ result.reset = propertyTokens.at(pos + 1);
+ break;
+ case PropertyToken::Designable:
+ result.designable = propertyTokens.at(pos + 1);
+ break;
+ case PropertyToken::None:
+ break;
+ }
+ }
+
+ const int namePos = firstToken - 1;
+ result.name = propertyTokens.at(namePos);
+
+ result.type = propertyTokens.constFirst();
+ for (int pos = 1; pos < namePos; ++pos)
+ result.type += QLatin1Char(' ') + propertyTokens.at(pos);
+
+ // Fix errors like "Q_PROPERTY(QXYSeries *series .." to be of type "QXYSeries*"
+ while (!result.name.isEmpty() && !result.name.at(0).isLetter()) {
+ result.type += result.name.at(0);
+ result.name.remove(0, 1);
+ }
+ if (!result.isValid())
+ *errorMessage = QLatin1String("Incomplete property specification");
+ return result;
+}
+
+// Create a QPropertySpec from a TypeSystemProperty, determining
+// the AbstractMetaType from the type string.
+QPropertySpec *QPropertySpec::fromTypeSystemProperty(AbstractMetaBuilderPrivate *b,
+ AbstractMetaClass *metaClass,
+ const TypeSystemProperty &ts,
+ const QStringList &scopes,
+ QString *errorMessage)
+ {
+ Q_ASSERT(ts.isValid());
+ QString typeError;
+ TypeInfo info = TypeParser::parse(ts.type, &typeError);
+ if (info.qualifiedName().isEmpty()) {
+ *errorMessage = msgPropertyTypeParsingFailed(ts.name, ts.type, typeError);
+ return nullptr;
+ }
+
+ AbstractMetaType *type = b->translateType(info, metaClass, {}, &typeError);
+ if (!type) {
+ const QStringList qualifiedName = info.qualifiedName();
+ for (int j = scopes.size(); j >= 0 && type == nullptr; --j) {
+ info.setQualifiedName(scopes.mid(0, j) + qualifiedName);
+ type = b->translateType(info, metaClass, {}, &typeError);
+ }
+ }
+
+ if (!type) {
+ *errorMessage = msgPropertyTypeParsingFailed(ts.name, ts.type, typeError);
+ return nullptr;
+ }
+ return new QPropertySpec(ts, type);
+ }
+
+// Convenience to create a QPropertySpec from a Q_PROPERTY macro
+// via TypeSystemProperty.
+QPropertySpec *QPropertySpec::parseQ_Property(AbstractMetaBuilderPrivate *b,
+ AbstractMetaClass *metaClass,
+ const QString &declarationIn,
+ const QStringList &scopes,
+ QString *errorMessage)
+{
+ const TypeSystemProperty ts =
+ typeSystemPropertyFromQ_Property(declarationIn, errorMessage);
+ return ts.isValid()
+ ? fromTypeSystemProperty(b, metaClass, ts, scopes, errorMessage)
+ : nullptr;
+}
+
+#ifndef QT_NO_DEBUG_STREAM
+void QPropertySpec::formatDebug(QDebug &d) const
+{
+ d << '#' << m_index << " \"" << m_name << "\" (" << m_type->cppSignature();
+ d << "), read=" << m_read;
+ if (!m_write.isEmpty())
+ d << ", write=" << m_write;
+ if (!m_reset.isEmpty())
+ d << ", reset=" << m_reset;
+ if (!m_designable.isEmpty())
+ d << ", designable=" << m_designable;
+}
+
+QDebug operator<<(QDebug d, const QPropertySpec &p)
+{
+ QDebugStateSaver s(d);
+ d.noquote();
+ d.nospace();
+ d << "QPropertySpec(";
+ p.formatDebug(d);
+ d << ')';
+ return d;
+}
+#endif // QT_NO_DEBUG_STREAM
diff --git a/sources/shiboken2/ApiExtractor/propertyspec.h b/sources/shiboken2/ApiExtractor/propertyspec.h
new file mode 100644
index 000000000..4abe75c84
--- /dev/null
+++ b/sources/shiboken2/ApiExtractor/propertyspec.h
@@ -0,0 +1,110 @@
+/****************************************************************************
+**
+** Copyright (C) 2020 The Qt Company Ltd.
+** Contact: https://www.qt.io/licensing/
+**
+** This file is part of Qt for Python.
+**
+** $QT_BEGIN_LICENSE:GPL-EXCEPT$
+** Commercial License Usage
+** Licensees holding valid commercial Qt licenses may use this file in
+** accordance with the commercial license agreement provided with the
+** Software or, alternatively, in accordance with the terms contained in
+** a written agreement between you and The Qt Company. For licensing terms
+** and conditions see https://www.qt.io/terms-conditions. For further
+** information use the contact form at https://www.qt.io/contact-us.
+**
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU
+** General Public License version 3 as published by the Free Software
+** Foundation with exceptions as appearing in the file LICENSE.GPL3-EXCEPT
+** included in the packaging of this file. Please review the following
+** information to ensure the GNU General Public License requirements will
+** be met: https://www.gnu.org/licenses/gpl-3.0.html.
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#ifndef PROPERTYSPEC_H
+#define PROPERTYSPEC_H
+
+#include <QtCore/QStringList>
+
+class AbstractMetaClass;
+class AbstractMetaBuilderPrivate;
+class AbstractMetaType;
+class TypeEntry;
+
+struct TypeSystemProperty;
+
+QT_FORWARD_DECLARE_CLASS(QDebug)
+
+class QPropertySpec
+{
+public:
+ Q_DISABLE_COPY_MOVE(QPropertySpec)
+
+ explicit QPropertySpec(const TypeSystemProperty &ts,
+ const AbstractMetaType *type);
+ ~QPropertySpec();
+
+ static TypeSystemProperty typeSystemPropertyFromQ_Property(const QString &declarationIn,
+ QString *errorMessage);
+
+ static QPropertySpec *fromTypeSystemProperty(AbstractMetaBuilderPrivate *b,
+ AbstractMetaClass *metaClass,
+ const TypeSystemProperty &ts,
+ const QStringList &scopes,
+ QString *errorMessage);
+
+ static QPropertySpec *parseQ_Property(AbstractMetaBuilderPrivate *b,
+ AbstractMetaClass *metaClass,
+ const QString &declarationIn,
+ const QStringList &scopes,
+ QString *errorMessage);
+
+ bool isValid() const;
+
+ const AbstractMetaType *type() const { return m_type; }
+ void setType(AbstractMetaType *t) { m_type = t; }
+
+ const TypeEntry *typeEntry() const;
+
+ QString name() const { return m_name; }
+ void setName(const QString &name) { m_name = name; }
+
+ QString read() const { return m_read; }
+ void setRead(const QString &read) { m_read = read; }
+
+ QString write() const { return m_write; }
+ void setWrite(const QString &write) { m_write = write; }
+
+ QString designable() const { return m_designable; }
+ void setDesignable(const QString &designable) { m_designable = designable; }
+
+ QString reset() const { return m_reset; }
+ void setReset(const QString &reset) { m_reset = reset; }
+
+ int index() const { return m_index; }
+ void setIndex(int index) {m_index = index; }
+
+#ifndef QT_NO_DEBUG_STREAM
+ void formatDebug(QDebug &d) const;
+#endif
+
+private:
+ QString m_name;
+ QString m_read;
+ QString m_write;
+ QString m_designable;
+ QString m_reset;
+ const AbstractMetaType *m_type = nullptr;
+ int m_index = -1;
+};
+
+#ifndef QT_NO_DEBUG_STREAM
+QDebug operator<<(QDebug d, const QPropertySpec &p);
+#endif
+
+#endif // PROPERTYSPEC_H
diff --git a/sources/shiboken2/ApiExtractor/qtdocparser.cpp b/sources/shiboken2/ApiExtractor/qtdocparser.cpp
index 512473131..40c04a403 100644
--- a/sources/shiboken2/ApiExtractor/qtdocparser.cpp
+++ b/sources/shiboken2/ApiExtractor/qtdocparser.cpp
@@ -29,6 +29,7 @@
#include "qtdocparser.h"
#include "abstractmetalang.h"
#include "messages.h"
+#include "propertyspec.h"
#include "reporthandler.h"
#include "typesystem.h"
#include "xmlutils.h"
diff --git a/sources/shiboken2/ApiExtractor/typesystem.h b/sources/shiboken2/ApiExtractor/typesystem.h
index 104d0b343..a4e96548b 100644
--- a/sources/shiboken2/ApiExtractor/typesystem.h
+++ b/sources/shiboken2/ApiExtractor/typesystem.h
@@ -553,6 +553,18 @@ private:
class CustomConversion;
class TypeSystemTypeEntry;
+struct TypeSystemProperty
+{
+ bool isValid() const { return !name.isEmpty() && !read.isEmpty() && !type.isEmpty(); }
+
+ QString type;
+ QString name;
+ QString read;
+ QString write;
+ QString reset;
+ QString designable;
+};
+
class TypeEntry
{
Q_GADGET
@@ -1256,6 +1268,9 @@ public:
return m_fieldMods;
}
+ const QList<TypeSystemProperty> &properties() const { return m_properties; }
+ void addProperty(const TypeSystemProperty &p) { m_properties.append(p); }
+
QString defaultSuperclass() const
{
return m_defaultSuperclass;
@@ -1362,6 +1377,7 @@ private:
AddedFunctionList m_addedFunctions;
FunctionModificationList m_functionMods;
FieldModificationList m_fieldMods;
+ QList<TypeSystemProperty> m_properties;
QString m_defaultConstructor;
QString m_defaultSuperclass;
QString m_qualifiedCppName;
diff --git a/sources/shiboken2/ApiExtractor/typesystemparser.cpp b/sources/shiboken2/ApiExtractor/typesystemparser.cpp
index df36689ed..f54ad50f4 100644
--- a/sources/shiboken2/ApiExtractor/typesystemparser.cpp
+++ b/sources/shiboken2/ApiExtractor/typesystemparser.cpp
@@ -366,6 +366,7 @@ ENUM_LOOKUP_BEGIN(StackElement::ElementType, Qt::CaseInsensitive,
{u"object-type", StackElement::ObjectTypeEntry},
{u"parent", StackElement::ParentOwner},
{u"primitive-type", StackElement::PrimitiveTypeEntry},
+ {u"property", StackElement::Property},
{u"reference-count", StackElement::ReferenceCount},
{u"reject-enum-value", StackElement::RejectEnumValue},
{u"rejection", StackElement::Rejection},
@@ -2238,6 +2239,36 @@ bool TypeSystemParser::parseAddFunction(const QXmlStreamReader &,
return true;
}
+bool TypeSystemParser::parseProperty(const QXmlStreamReader &, const StackElement &topElement,
+ QXmlStreamAttributes *attributes)
+{
+ if ((topElement.type & StackElement::ComplexTypeEntryMask) == 0) {
+ m_error = QString::fromLatin1("Add property requires a complex type as parent"
+ ", was=%1").arg(topElement.type, 0, 16);
+ return false;
+ }
+
+ TypeSystemProperty property;
+ for (int i = attributes->size() - 1; i >= 0; --i) {
+ const auto name = attributes->at(i).qualifiedName();
+ if (name == nameAttribute()) {
+ property.name = attributes->takeAt(i).value().toString();
+ } else if (name == QLatin1String("get")) {
+ property.read = attributes->takeAt(i).value().toString();
+ } else if (name == QLatin1String("type")) {
+ property.type = attributes->takeAt(i).value().toString();
+ } else if (name == QLatin1String("set")) {
+ property.write = attributes->takeAt(i).value().toString();
+ }
+ }
+ if (!property.isValid()) {
+ m_error = QLatin1String("<property> element is missing required attibutes (name/type/get).");
+ return false;
+ }
+ static_cast<ComplexTypeEntry *>(topElement.entry)->addProperty(property);
+ return true;
+}
+
bool TypeSystemParser::parseModifyFunction(const QXmlStreamReader &reader,
const StackElement &topElement,
QXmlStreamAttributes *attributes)
@@ -3006,6 +3037,10 @@ bool TypeSystemParser::startElement(const QXmlStreamReader &reader)
if (!parseAddFunction(reader, topElement, &attributes))
return false;
break;
+ case StackElement::Property:
+ if (!parseProperty(reader, topElement, &attributes))
+ return false;
+ break;
case StackElement::ModifyFunction:
if (!parseModifyFunction(reader, topElement, &attributes))
return false;
diff --git a/sources/shiboken2/ApiExtractor/typesystemparser.h b/sources/shiboken2/ApiExtractor/typesystemparser.h
index 49ef1f17d..3eaa74f04 100644
--- a/sources/shiboken2/ApiExtractor/typesystemparser.h
+++ b/sources/shiboken2/ApiExtractor/typesystemparser.h
@@ -88,6 +88,7 @@ class StackElement
TargetToNative = 0x1200,
AddConversion = 0x1300,
SystemInclude = 0x1400,
+ Property = 0x1500,
SimpleMask = 0x3f00,
// Code snip tags (0x1000, 0x2000, ... , 0xf000)
@@ -232,6 +233,8 @@ private:
bool parseModifyField(const QXmlStreamReader &, QXmlStreamAttributes *);
bool parseAddFunction(const QXmlStreamReader &, const StackElement &topElement,
QXmlStreamAttributes *);
+ bool parseProperty(const QXmlStreamReader &, const StackElement &topElement,
+ QXmlStreamAttributes *);
bool parseModifyFunction(const QXmlStreamReader &, const StackElement &topElement,
QXmlStreamAttributes *);
bool parseReplaceDefaultExpression(const QXmlStreamReader &,
diff --git a/sources/shiboken2/doc/typesystem_manipulating_objects.rst b/sources/shiboken2/doc/typesystem_manipulating_objects.rst
index c14c4e941..98f503074 100644
--- a/sources/shiboken2/doc/typesystem_manipulating_objects.rst
+++ b/sources/shiboken2/doc/typesystem_manipulating_objects.rst
@@ -233,3 +233,35 @@ conversion-rule
.. note:: You can also use the conversion-rule node to specify :ref:`how the conversion of a single function argument should be done in a function <conversion-rule>`.
The ``file`` and ``snippet`` attributes are also supported (see :ref:`inject-code` nodes).
+
+
+property
+^^^^^^^^
+
+ The ``property`` element allows you to add properties complementing the
+ properties obtained from the ``Q_PROPERTY`` macro in Qt-based code when using
+ the PySide2 extension. It may appear as a child of a complex type such as
+ ``object-type`` or ``value-type``.
+
+ .. code-block:: xml
+
+ <property name="..." type="..." get="..." set="..." since="..."/>
+
+ The ``name`` attribute specifies the name of the property, the ``type``
+ attribute specifies the C++ type and the ``get`` attribute specifies the
+ name of the accessor function.
+
+ The optional ``set`` attribute specifies name of the setter function.
+
+ The optional ``since`` attribute specifies the API version when this
+ property appears.
+
+ For example:
+
+ .. code-block:: xml
+
+ <object-type name="QMainWindow">
+ <property name="centralWidget" type="QWidget *" get="centralWidget" set="setCentralWidget"/>
+
+ specifies ``centralWidget`` to be a Python property in addition to the normal properties
+ of ``QMainWindow`` defined for Qt Designer usage.
diff --git a/sources/shiboken2/generator/qtdoc/qtdocgenerator.cpp b/sources/shiboken2/generator/qtdoc/qtdocgenerator.cpp
index 5cc5dcc67..1386fd3d9 100644
--- a/sources/shiboken2/generator/qtdoc/qtdocgenerator.cpp
+++ b/sources/shiboken2/generator/qtdoc/qtdocgenerator.cpp
@@ -30,6 +30,7 @@
#include "ctypenames.h"
#include <abstractmetalang.h>
#include <messages.h>
+#include <propertyspec.h>
#include <reporthandler.h>
#include <typesystem.h>
#include <qtdocparser.h>
diff --git a/sources/shiboken2/generator/shiboken2/cppgenerator.cpp b/sources/shiboken2/generator/shiboken2/cppgenerator.cpp
index 831d05d6a..851498f80 100644
--- a/sources/shiboken2/generator/shiboken2/cppgenerator.cpp
+++ b/sources/shiboken2/generator/shiboken2/cppgenerator.cpp
@@ -34,6 +34,7 @@
#include "overloaddata.h"
#include <abstractmetalang.h>
#include <messages.h>
+#include <propertyspec.h>
#include <reporthandler.h>
#include <typedatabase.h>
@@ -3531,12 +3532,13 @@ void CppGenerator::writeMethodCall(QTextStream &s, const AbstractMetaFunction *f
if (!avoidProtectedHack() || !func->isProtected()) {
QString virtualCall(methodCall);
QString normalCall(methodCall);
- virtualCall = virtualCall.replace(QLatin1String("%CLASS_NAME"),
- methodCallClassName);
+ virtualCall.replace(QLatin1String("%CLASS_NAME"),
+ methodCallClassName);
normalCall.remove(QLatin1String("::%CLASS_NAME::"));
methodCall.clear();
- mc << "Shiboken::Object::hasCppWrapper(reinterpret_cast<SbkObject *>(self)) ? ";
- mc << virtualCall << " : " << normalCall;
+ mc << "Shiboken::Object::hasCppWrapper(reinterpret_cast<SbkObject *>(self))\n"
+ << INDENT << " ? " << virtualCall << '\n'
+ << INDENT << " : " << normalCall;
}
}
}
diff --git a/sources/shiboken2/libshiboken/signature.cpp b/sources/shiboken2/libshiboken/signature.cpp
index 70f1e8de7..242fe18c1 100644
--- a/sources/shiboken2/libshiboken/signature.cpp
+++ b/sources/shiboken2/libshiboken/signature.cpp
@@ -43,6 +43,8 @@
#include "sbkstaticstrings.h"
#include "sbkstaticstrings_p.h"
+using namespace Shiboken;
+
extern "C"
{
@@ -100,8 +102,7 @@ static void init_module_1(void);
static void init_module_2(void);
static PyObject *_init_pyside_extension(PyObject * /* self */, PyObject * /* args */);
-static PyObject *
-CreateSignature(PyObject *props, PyObject *key)
+static PyObject *CreateSignature(PyObject *props, PyObject *key)
{
/*
* Here is the new function to create all signatures. It simply calls
@@ -115,8 +116,7 @@ CreateSignature(PyObject *props, PyObject *key)
typedef PyObject *(*signaturefunc)(PyObject *, PyObject *);
-static PyObject *
-_get_written_signature(signaturefunc sf, PyObject *ob, PyObject *modifier)
+static PyObject *_get_written_signature(signaturefunc sf, PyObject *ob, PyObject *modifier)
{
/*
* Be a writable Attribute, but have a computed value.
@@ -131,39 +131,35 @@ _get_written_signature(signaturefunc sf, PyObject *ob, PyObject *modifier)
* See pyside_set___signature
*/
PyObject *ret = PyDict_GetItem(pyside_globals->value_dict, ob);
- if (ret == nullptr) {
+ if (ret == nullptr)
return ob == nullptr ? nullptr : sf(ob, modifier);
- }
Py_INCREF(ret);
return ret;
}
-static PyObject *
-pyside_cf_get___signature__(PyObject *func, PyObject *modifier)
+static PyObject *pyside_cf_get___signature__(PyObject *func, PyObject *modifier)
{
init_module_2();
return _get_written_signature(GetSignature_Function, func, modifier);
}
-static PyObject *
-pyside_sm_get___signature__(PyObject *sm, PyObject *modifier)
+static PyObject *pyside_sm_get___signature__(PyObject *sm, PyObject *modifier)
{
init_module_2();
- Shiboken::AutoDecRef func(PyObject_GetAttr(sm, Shiboken::PyMagicName::func()));
+ AutoDecRef func(PyObject_GetAttr(sm, PyMagicName::func()));
if (Py_TYPE(func) == PepFunction_TypePtr)
- return PyObject_GetAttr(func, Shiboken::PyMagicName::signature());
+ return PyObject_GetAttr(func, PyMagicName::signature());
return _get_written_signature(GetSignature_Function, func, modifier);
}
-static PyObject *
-_get_class_of_cf(PyObject *ob_cf)
+static PyObject *_get_class_of_cf(PyObject *ob_cf)
{
PyObject *selftype = PyCFunction_GET_SELF(ob_cf);
if (selftype == nullptr) {
selftype = PyDict_GetItem(pyside_globals->map_dict, ob_cf);
if (selftype == nullptr) {
// This must be an overloaded function that we handled special.
- Shiboken::AutoDecRef special(Py_BuildValue("(OO)", ob_cf, Shiboken::PyName::overload()));
+ AutoDecRef special(Py_BuildValue("(OO)", ob_cf, PyName::overload()));
selftype = PyDict_GetItem(pyside_globals->map_dict, special);
if (selftype == nullptr) {
// This is probably a module function. We will return type(None).
@@ -173,26 +169,24 @@ _get_class_of_cf(PyObject *ob_cf)
}
PyObject *obtype_mod = (PyType_Check(selftype) || PyModule_Check(selftype))
- ? selftype : reinterpret_cast<PyObject *>(Py_TYPE(selftype));
+ ? selftype
+ : reinterpret_cast<PyObject *>(Py_TYPE(selftype));
Py_INCREF(obtype_mod);
return obtype_mod;
}
-static PyObject *
-_get_class_of_sm(PyObject *ob_sm)
+static PyObject *_get_class_of_sm(PyObject *ob_sm)
{
- Shiboken::AutoDecRef func(PyObject_GetAttr(ob_sm, Shiboken::PyMagicName::func()));
+ AutoDecRef func(PyObject_GetAttr(ob_sm, PyMagicName::func()));
return _get_class_of_cf(func);
}
-static PyObject *
-_get_class_of_descr(PyObject *ob)
+static PyObject *_get_class_of_descr(PyObject *ob)
{
- return PyObject_GetAttr(ob, Shiboken::PyMagicName::objclass());
+ return PyObject_GetAttr(ob, PyMagicName::objclass());
}
-static PyObject *
-GetClassOrModOf(PyObject *ob)
+static PyObject *GetClassOrModOf(PyObject *ob)
{
/*
* Return the type or module of a function or type.
@@ -215,33 +209,30 @@ GetClassOrModOf(PyObject *ob)
return nullptr;
}
-static PyObject *
-get_funcname(PyObject *ob)
+static PyObject *get_funcname(PyObject *ob)
{
PyObject *func = ob;
if (Py_TYPE(ob) == PepStaticMethod_TypePtr)
- func = PyObject_GetAttr(ob, Shiboken::PyMagicName::func());
+ func = PyObject_GetAttr(ob, PyMagicName::func());
else
Py_INCREF(func);
- PyObject *func_name = PyObject_GetAttr(func, Shiboken::PyMagicName::name());
+ PyObject *func_name = PyObject_GetAttr(func, PyMagicName::name());
Py_DECREF(func);
if (func_name == nullptr)
Py_FatalError("unexpected name problem in compute_name_key");
return func_name;
}
-static PyObject *
-compute_name_key(PyObject *ob)
+static PyObject *compute_name_key(PyObject *ob)
{
if (PyType_Check(ob))
return GetTypeKey(ob);
- Shiboken::AutoDecRef func_name(get_funcname(ob));
- Shiboken::AutoDecRef type_key(GetTypeKey(GetClassOrModOf(ob)));
+ AutoDecRef func_name(get_funcname(ob));
+ AutoDecRef type_key(GetTypeKey(GetClassOrModOf(ob)));
return Py_BuildValue("(OO)", type_key.object(), func_name.object());
}
-static int
-build_name_key_to_func(PyObject *obtype)
+static int build_name_key_to_func(PyObject *obtype)
{
auto *type = reinterpret_cast<PyTypeObject *>(obtype);
PyMethodDef *meth = type->tp_methods;
@@ -249,11 +240,11 @@ build_name_key_to_func(PyObject *obtype)
if (meth == nullptr)
return 0;
- Shiboken::AutoDecRef type_key(GetTypeKey(obtype));
+ AutoDecRef type_key(GetTypeKey(obtype));
for (; meth->ml_name != nullptr; meth++) {
- Shiboken::AutoDecRef func(PyCFunction_NewEx(meth, obtype, nullptr));
- Shiboken::AutoDecRef func_name(get_funcname(func));
- Shiboken::AutoDecRef name_key(Py_BuildValue("(OO)", type_key.object(), func_name.object()));
+ AutoDecRef func(PyCFunction_NewEx(meth, obtype, nullptr));
+ AutoDecRef func_name(get_funcname(func));
+ AutoDecRef name_key(Py_BuildValue("(OO)", type_key.object(), func_name.object()));
if (func.isNull() || name_key.isNull()
|| PyDict_SetItem(pyside_globals->map_dict, name_key, func) < 0)
return -1;
@@ -261,22 +252,21 @@ build_name_key_to_func(PyObject *obtype)
return 0;
}
-static PyObject *
-name_key_to_func(PyObject *ob)
+static PyObject *name_key_to_func(PyObject *ob)
{
/*
* We build a mapping from name_key to function.
* This could also be computed directly, but the Limited API
* makes this impossible. So we always build our own mapping.
*/
- Shiboken::AutoDecRef name_key(compute_name_key(ob));
+ AutoDecRef name_key(compute_name_key(ob));
if (name_key.isNull())
Py_RETURN_NONE;
PyObject *ret = PyDict_GetItem(pyside_globals->map_dict, name_key);
if (ret == nullptr) {
// do a lazy initialization
- Shiboken::AutoDecRef type_key(GetTypeKey(GetClassOrModOf(ob)));
+ AutoDecRef type_key(GetTypeKey(GetClassOrModOf(ob)));
PyObject *type = PyDict_GetItem(pyside_globals->map_dict,
type_key);
if (type == nullptr)
@@ -290,11 +280,10 @@ name_key_to_func(PyObject *ob)
return ret;
}
-static PyObject *
-pyside_md_get___signature__(PyObject *ob_md, PyObject *modifier)
+static PyObject *pyside_md_get___signature__(PyObject *ob_md, PyObject *modifier)
{
init_module_2();
- Shiboken::AutoDecRef func(name_key_to_func(ob_md));
+ AutoDecRef func(name_key_to_func(ob_md));
if (func.object() == Py_None)
return Py_None;
if (func.isNull())
@@ -302,40 +291,35 @@ pyside_md_get___signature__(PyObject *ob_md, PyObject *modifier)
return pyside_cf_get___signature__(func, modifier);
}
-static PyObject *
-pyside_wd_get___signature__(PyObject *ob, PyObject *modifier)
+static PyObject *pyside_wd_get___signature__(PyObject *ob, PyObject *modifier)
{
init_module_2();
return _get_written_signature(GetSignature_Wrapper, ob, modifier);
}
-static PyObject *
-pyside_tp_get___signature__(PyObject *obtype_mod, PyObject *modifier)
+static PyObject *pyside_tp_get___signature__(PyObject *obtype_mod, PyObject *modifier)
{
init_module_2();
return _get_written_signature(GetSignature_TypeMod, obtype_mod, modifier);
}
// forward
-static PyObject *
-GetSignature_Cached(PyObject *props, PyObject *func_kind, PyObject *modifier);
+static PyObject *GetSignature_Cached(PyObject *props, PyObject *func_kind, PyObject *modifier);
// Helper for __qualname__ which might not always exist in Python 2 (type).
-static PyObject *
-_get_qualname(PyObject *ob)
+static PyObject *_get_qualname(PyObject *ob)
{
// We support __qualname__ for types, only.
assert(PyType_Check(ob));
- PyObject *name = PyObject_GetAttr(ob, Shiboken::PyMagicName::qualname());
+ PyObject *name = PyObject_GetAttr(ob, PyMagicName::qualname());
if (name == nullptr) {
PyErr_Clear();
- name = PyObject_GetAttr(ob, Shiboken::PyMagicName::name());
+ name = PyObject_GetAttr(ob, PyMagicName::name());
}
return name;
}
-static PyObject *
-GetTypeKey(PyObject *ob)
+static PyObject *GetTypeKey(PyObject *ob)
{
assert(PyType_Check(ob) || PyModule_Check(ob));
/*
@@ -351,14 +335,14 @@ GetTypeKey(PyObject *ob)
* This is the PyCFunction behavior, as opposed to Python functions.
*/
// PYSIDE-1286: We use correct __module__ and __qualname__, now.
- Shiboken::AutoDecRef module_name(PyObject_GetAttr(ob, Shiboken::PyMagicName::module()));
+ AutoDecRef module_name(PyObject_GetAttr(ob, PyMagicName::module()));
if (module_name.isNull()) {
// We have no module_name because this is a module ;-)
PyErr_Clear();
- module_name.reset(PyObject_GetAttr(ob, Shiboken::PyMagicName::name()));
+ module_name.reset(PyObject_GetAttr(ob, PyMagicName::name()));
return Py_BuildValue("O", module_name.object());
}
- Shiboken::AutoDecRef class_name(_get_qualname(ob));
+ AutoDecRef class_name(_get_qualname(ob));
if (class_name.isNull()) {
Py_FatalError("Signature: missing class name in GetTypeKey");
return nullptr;
@@ -368,8 +352,7 @@ GetTypeKey(PyObject *ob)
static PyObject *empty_dict = nullptr;
-static PyObject *
-TypeKey_to_PropsDict(PyObject *type_key, PyObject *obtype)
+static PyObject *TypeKey_to_PropsDict(PyObject *type_key, PyObject *obtype)
{
PyObject *dict = PyDict_GetItem(pyside_globals->arg_dict, type_key);
if (dict == nullptr) {
@@ -382,20 +365,19 @@ TypeKey_to_PropsDict(PyObject *type_key, PyObject *obtype)
return dict;
}
-static PyObject *
-GetSignature_Function(PyObject *obfunc, PyObject *modifier)
+static PyObject *GetSignature_Function(PyObject *obfunc, PyObject *modifier)
{
// make sure that we look into PyCFunction, only...
if (Py_TYPE(obfunc) == PepFunction_TypePtr)
Py_RETURN_NONE;
- Shiboken::AutoDecRef obtype_mod(GetClassOrModOf(obfunc));
- Shiboken::AutoDecRef type_key(GetTypeKey(obtype_mod));
+ AutoDecRef obtype_mod(GetClassOrModOf(obfunc));
+ AutoDecRef type_key(GetTypeKey(obtype_mod));
if (type_key.isNull())
Py_RETURN_NONE;
PyObject *dict = TypeKey_to_PropsDict(type_key, obtype_mod);
if (dict == nullptr)
return nullptr;
- Shiboken::AutoDecRef func_name(PyObject_GetAttr(obfunc, Shiboken::PyMagicName::name()));
+ AutoDecRef func_name(PyObject_GetAttr(obfunc, PyMagicName::name()));
PyObject *props = !func_name.isNull() ? PyDict_GetItem(dict, func_name) : nullptr;
if (props == nullptr)
Py_RETURN_NONE;
@@ -403,22 +385,21 @@ GetSignature_Function(PyObject *obfunc, PyObject *modifier)
int flags = PyCFunction_GET_FLAGS(obfunc);
PyObject *func_kind;
if (PyModule_Check(obtype_mod))
- func_kind = Shiboken::PyName::function();
+ func_kind = PyName::function();
else if (flags & METH_CLASS)
- func_kind = Shiboken::PyName::classmethod();
+ func_kind = PyName::classmethod();
else if (flags & METH_STATIC)
- func_kind = Shiboken::PyName::staticmethod();
+ func_kind = PyName::staticmethod();
else
- func_kind = Shiboken::PyName::method();
+ func_kind = PyName::method();
return GetSignature_Cached(props, func_kind, modifier);
}
-static PyObject *
-GetSignature_Wrapper(PyObject *ob, PyObject *modifier)
+static PyObject *GetSignature_Wrapper(PyObject *ob, PyObject *modifier)
{
- Shiboken::AutoDecRef func_name(PyObject_GetAttr(ob, Shiboken::PyMagicName::name()));
- Shiboken::AutoDecRef objclass(PyObject_GetAttr(ob, Shiboken::PyMagicName::objclass()));
- Shiboken::AutoDecRef class_key(GetTypeKey(objclass));
+ AutoDecRef func_name(PyObject_GetAttr(ob, PyMagicName::name()));
+ AutoDecRef objclass(PyObject_GetAttr(ob, PyMagicName::objclass()));
+ AutoDecRef class_key(GetTypeKey(objclass));
if (func_name.isNull() || objclass.isNull() || class_key.isNull())
return nullptr;
PyObject *dict = TypeKey_to_PropsDict(class_key, objclass);
@@ -427,14 +408,13 @@ GetSignature_Wrapper(PyObject *ob, PyObject *modifier)
PyObject *props = PyDict_GetItem(dict, func_name);
if (props == nullptr)
Py_RETURN_NONE;
- return GetSignature_Cached(props, Shiboken::PyName::method(), modifier);
+ return GetSignature_Cached(props, PyName::method(), modifier);
}
-static PyObject *
-GetSignature_TypeMod(PyObject *ob, PyObject *modifier)
+static PyObject *GetSignature_TypeMod(PyObject *ob, PyObject *modifier)
{
- Shiboken::AutoDecRef ob_name(PyObject_GetAttr(ob, Shiboken::PyMagicName::name()));
- Shiboken::AutoDecRef ob_key(GetTypeKey(ob));
+ AutoDecRef ob_name(PyObject_GetAttr(ob, PyMagicName::name()));
+ AutoDecRef ob_key(GetTypeKey(ob));
PyObject *dict = TypeKey_to_PropsDict(ob_key, ob);
if (dict == nullptr)
@@ -442,11 +422,10 @@ GetSignature_TypeMod(PyObject *ob, PyObject *modifier)
PyObject *props = PyDict_GetItem(dict, ob_name);
if (props == nullptr)
Py_RETURN_NONE;
- return GetSignature_Cached(props, Shiboken::PyName::method(), modifier);
+ return GetSignature_Cached(props, PyName::method(), modifier);
}
-static PyObject *
-GetSignature_Cached(PyObject *props, PyObject *func_kind, PyObject *modifier)
+static PyObject *GetSignature_Cached(PyObject *props, PyObject *func_kind, PyObject *modifier)
{
// Special case: We want to know the func_kind.
if (modifier) {
@@ -455,13 +434,12 @@ GetSignature_Cached(PyObject *props, PyObject *func_kind, PyObject *modifier)
#else
PyString_InternInPlace(&modifier);
#endif
- if (modifier == Shiboken::PyMagicName::func_kind())
+ if (modifier == PyMagicName::func_kind())
return Py_BuildValue("O", func_kind);
}
- Shiboken::AutoDecRef key(modifier == nullptr
- ? Py_BuildValue("O", func_kind)
- : Py_BuildValue("(OO)", func_kind, modifier));
+ AutoDecRef key(modifier == nullptr ? Py_BuildValue("O", func_kind)
+ : Py_BuildValue("(OO)", func_kind, modifier));
PyObject *value = PyDict_GetItem(props, key);
if (value == nullptr) {
// we need to compute a signature object
@@ -493,8 +471,7 @@ static PyMethodDef init_methods[] = {
{nullptr, nullptr}
};
-static safe_globals_struc *
-init_phase_1(PyMethodDef *init_meth)
+static safe_globals_struc *init_phase_1(PyMethodDef *init_meth)
{
{
auto *p = reinterpret_cast<safe_globals_struc *>
@@ -509,29 +486,28 @@ init_phase_1(PyMethodDef *init_meth)
#ifdef Py_LIMITED_API
// We must work for multiple versions, so use source code.
#else
- Shiboken::AutoDecRef marshal_module(PyImport_Import(Shiboken::PyName::marshal()));
+ AutoDecRef marshal_module(PyImport_Import(PyName::marshal()));
if (marshal_module.isNull())
goto error;
- Shiboken::AutoDecRef loads(PyObject_GetAttr(marshal_module, Shiboken::PyName::loads()));
+ AutoDecRef loads(PyObject_GetAttr(marshal_module, PyName::loads()));
if (loads.isNull())
goto error;
#endif
char *bytes_cast = reinterpret_cast<char *>(
const_cast<unsigned char *>(PySide_SignatureLoader));
- Shiboken::AutoDecRef bytes(PyBytes_FromStringAndSize(bytes_cast,
- sizeof(PySide_SignatureLoader)));
+ AutoDecRef bytes(PyBytes_FromStringAndSize(bytes_cast, sizeof(PySide_SignatureLoader)));
if (bytes.isNull())
goto error;
#ifdef Py_LIMITED_API
PyObject *builtins = PyEval_GetBuiltins();
- PyObject *compile = PyDict_GetItem(builtins, Shiboken::PyName::compile());
+ PyObject *compile = PyDict_GetItem(builtins, PyName::compile());
if (compile == nullptr)
goto error;
- Shiboken::AutoDecRef code_obj(PyObject_CallFunction(compile, "Oss",
- bytes.object(), "(builtin)", "exec"));
+ AutoDecRef code_obj(PyObject_CallFunction(compile, "Oss",
+ bytes.object(), "(builtin)", "exec"));
#else
- Shiboken::AutoDecRef code_obj(PyObject_CallFunctionObjArgs(
- loads, bytes.object(), nullptr));
+ AutoDecRef code_obj(PyObject_CallFunctionObjArgs(
+ loads, bytes.object(), nullptr));
#endif
if (code_obj.isNull())
goto error;
@@ -541,7 +517,7 @@ init_phase_1(PyMethodDef *init_meth)
goto error;
// Initialize the module
PyObject *mdict = PyModule_GetDict(p->helper_module);
- if (PyDict_SetItem(mdict, Shiboken::PyMagicName::builtins(), PyEval_GetBuiltins()) < 0)
+ if (PyDict_SetItem(mdict, PyMagicName::builtins(), PyEval_GetBuiltins()) < 0)
goto error;
/*
* Unpack an embedded ZIP file with more signature modules.
@@ -590,7 +566,7 @@ init_phase_1(PyMethodDef *init_meth)
p->finish_import_func = nullptr;
// Initialize the explicit init function.
- Shiboken::AutoDecRef init(PyCFunction_NewEx(init_meth, nullptr, nullptr));
+ AutoDecRef init(PyCFunction_NewEx(init_meth, nullptr, nullptr));
if (init.isNull()
|| PyDict_SetItemString(PyEval_GetBuiltins(), init_meth->ml_name, init) != 0)
goto error;
@@ -603,8 +579,7 @@ error:
return nullptr;
}
-static int
-init_phase_2(safe_globals_struc *p, PyMethodDef *methods)
+static int init_phase_2(safe_globals_struc *p, PyMethodDef *methods)
{
{
PyMethodDef *ml;
@@ -648,8 +623,7 @@ error:
return -1;
}
-static int
-_fixup_getset(PyTypeObject *type, const char *name, PyGetSetDef *new_gsp)
+static int _fixup_getset(PyTypeObject *type, const char *name, PyGetSetDef *new_gsp)
{
/*
* This function pre-fills all fields of the new gsp. We then
@@ -676,8 +650,7 @@ _fixup_getset(PyTypeObject *type, const char *name, PyGetSetDef *new_gsp)
return 0;
}
-static int
-add_more_getsets(PyTypeObject *type, PyGetSetDef *gsp, PyObject **doc_descr)
+static int add_more_getsets(PyTypeObject *type, PyGetSetDef *gsp, PyObject **doc_descr)
{
/*
* This function is used to assign a new `__signature__` attribute,
@@ -697,7 +670,7 @@ add_more_getsets(PyTypeObject *type, PyGetSetDef *gsp, PyObject **doc_descr)
if (!_fixup_getset(type, gsp->name, gsp))
continue;
}
- Shiboken::AutoDecRef descr(PyDescr_NewGetSet(type, gsp));
+ AutoDecRef descr(PyDescr_NewGetSet(type, gsp));
if (descr.isNull())
return -1;
if (PyDict_SetItemString(dict, gsp->name, descr) < 0)
@@ -731,12 +704,11 @@ static PyObject *old_wd_doc_descr = nullptr;
static int handle_doc_in_progress = 0;
-static PyObject *
-handle_doc(PyObject *ob, PyObject *old_descr)
+static PyObject *handle_doc(PyObject *ob, PyObject *old_descr)
{
init_module_1();
init_module_2();
- Shiboken::AutoDecRef ob_type_mod(GetClassOrModOf(ob));
+ AutoDecRef ob_type_mod(GetClassOrModOf(ob));
const char *name;
if (PyModule_Check(ob_type_mod))
name = PyModule_GetName(ob_type_mod);
@@ -745,7 +717,7 @@ handle_doc(PyObject *ob, PyObject *old_descr)
if (handle_doc_in_progress || name == nullptr
|| strncmp(name, "PySide2.", 8) != 0)
return PyObject_CallMethodObjArgs(old_descr,
- Shiboken::PyMagicName::get(),
+ PyMagicName::get(),
ob, nullptr);
handle_doc_in_progress++;
PyObject *res = PyObject_CallFunction(
@@ -759,47 +731,40 @@ handle_doc(PyObject *ob, PyObject *old_descr)
return res;
}
-static PyObject *
-pyside_cf_get___doc__(PyObject *cf) {
+static PyObject *pyside_cf_get___doc__(PyObject *cf) {
return handle_doc(cf, old_cf_doc_descr);
}
-static PyObject *
-pyside_sm_get___doc__(PyObject *sm) {
+static PyObject *pyside_sm_get___doc__(PyObject *sm) {
return handle_doc(sm, old_sm_doc_descr);
}
-static PyObject *
-pyside_md_get___doc__(PyObject *md) {
+static PyObject *pyside_md_get___doc__(PyObject *md) {
return handle_doc(md, old_md_doc_descr);
}
-static PyObject *
-pyside_tp_get___doc__(PyObject *tp) {
+static PyObject *pyside_tp_get___doc__(PyObject *tp) {
return handle_doc(tp, old_tp_doc_descr);
}
-static PyObject *
-pyside_wd_get___doc__(PyObject *wd) {
+static PyObject *pyside_wd_get___doc__(PyObject *wd) {
return handle_doc(wd, old_wd_doc_descr);
}
// the default setter for all objects
-static int
-pyside_set___signature__(PyObject *op, PyObject *value)
+static int pyside_set___signature__(PyObject *op, PyObject *value)
{
// By this additional check, this function refuses write access.
// We consider both nullptr and Py_None as not been written.
- Shiboken::AutoDecRef has_val(get_signature_intern(op, nullptr));
+ AutoDecRef has_val(get_signature_intern(op, nullptr));
if (!(has_val.isNull() || has_val == Py_None)) {
PyErr_Format(PyExc_AttributeError,
"Attribute '__signature__' of '%.50s' object is not writable",
Py_TYPE(op)->tp_name);
return -1;
}
- int ret = value == nullptr
- ? PyDict_DelItem(pyside_globals->value_dict, op)
- : PyDict_SetItem(pyside_globals->value_dict, op, value);
+ int ret = value == nullptr ? PyDict_DelItem(pyside_globals->value_dict, op)
+ : PyDict_SetItem(pyside_globals->value_dict, op, value);
Py_XINCREF(value);
return ret;
}
@@ -849,8 +814,7 @@ static PyGetSetDef new_PyWrapperDescr_getsets[] = {
// Configuration what the modifiers mean is completely in Python.
//
-static PyObject *
-get_signature_intern(PyObject *ob, PyObject *modifier)
+static PyObject *get_signature_intern(PyObject *ob, PyObject *modifier)
{
if (PyType_IsSubtype(Py_TYPE(ob), &PyCFunction_Type))
return pyside_cf_get___signature__(ob, modifier);
@@ -865,8 +829,7 @@ get_signature_intern(PyObject *ob, PyObject *modifier)
return nullptr;
}
-static PyObject *
-get_signature(PyObject * /* self */, PyObject *args)
+static PyObject *get_signature(PyObject * /* self */, PyObject *args)
{
PyObject *ob;
PyObject *modifier = nullptr;
@@ -883,8 +846,7 @@ get_signature(PyObject * /* self */, PyObject *args)
Py_RETURN_NONE;
}
-static PyObject *
-_init_pyside_extension(PyObject * /* self */, PyObject * /* args */)
+static PyObject *_init_pyside_extension(PyObject * /* self */, PyObject * /* args */)
{
init_module_1();
init_module_2();
@@ -928,16 +890,15 @@ void handler(int sig) {
////////////////////////////////////////////////////////////////////////////
#endif // _WIN32
-static int
-PySide_PatchTypes(void)
+static int PySide_PatchTypes(void)
{
static int init_done = 0;
if (!init_done) {
- Shiboken::AutoDecRef meth_descr(PyObject_GetAttrString(
- reinterpret_cast<PyObject *>(&PyString_Type), "split"));
- Shiboken::AutoDecRef wrap_descr(PyObject_GetAttrString(
- reinterpret_cast<PyObject *>(Py_TYPE(Py_True)), "__add__"));
+ AutoDecRef meth_descr(PyObject_GetAttrString(
+ reinterpret_cast<PyObject *>(&PyString_Type), "split"));
+ AutoDecRef wrap_descr(PyObject_GetAttrString(
+ reinterpret_cast<PyObject *>(Py_TYPE(Py_True)), "__add__"));
// abbreviations for readability
auto md_gs = new_PyMethodDescr_getsets;
auto md_doc = &old_md_doc_descr;
@@ -970,8 +931,7 @@ PySide_PatchTypes(void)
return 0;
}
-static void
-init_module_1(void)
+static void init_module_1(void)
{
static int init_done = 0;
@@ -982,11 +942,10 @@ init_module_1(void)
}
}
-static int
-PySide_BuildSignatureArgs(PyObject *obtype_mod, const char *signatures[])
+static int PySide_BuildSignatureArgs(PyObject *obtype_mod, const char *signatures[])
{
init_module_1();
- Shiboken::AutoDecRef type_key(GetTypeKey(obtype_mod));
+ AutoDecRef type_key(GetTypeKey(obtype_mod));
/*
* PYSIDE-996: Avoid string overflow in MSVC, which has a limit of
* 2**15 unicode characters (64 K memory).
@@ -994,7 +953,7 @@ PySide_BuildSignatureArgs(PyObject *obtype_mod, const char *signatures[])
* address of a string array. It will not be turned into a real
* string list until really used by Python. This is quite optimal.
*/
- Shiboken::AutoDecRef numkey(Py_BuildValue("n", signatures));
+ AutoDecRef numkey(Py_BuildValue("n", signatures));
if (type_key.isNull() || numkey.isNull()
|| PyDict_SetItem(pyside_globals->arg_dict, type_key, numkey) < 0)
return -1;
@@ -1011,8 +970,7 @@ static PyMethodDef signature_methods[] = {
{nullptr, nullptr}
};
-static void
-init_module_2(void)
+static void init_module_2(void)
{
static int init_done = 0;
@@ -1024,8 +982,7 @@ init_module_2(void)
}
}
-static PyObject *
-_address_to_stringlist(PyObject *numkey)
+static PyObject *_address_to_stringlist(PyObject *numkey)
{
ssize_t address = PyNumber_AsSsize_t(numkey, PyExc_ValueError);
if (address == -1 && PyErr_Occurred())
@@ -1036,15 +993,14 @@ _address_to_stringlist(PyObject *numkey)
return nullptr;
for (; *sig_strings != nullptr; ++sig_strings) {
char *sig_str = *sig_strings;
- Shiboken::AutoDecRef pystr(Py_BuildValue("s", sig_str));
+ AutoDecRef pystr(Py_BuildValue("s", sig_str));
if (pystr.isNull() || PyList_Append(res_list, pystr) < 0)
return nullptr;
}
return res_list;
}
-static PyObject *
-PySide_BuildSignatureProps(PyObject *type_key)
+static PyObject *PySide_BuildSignatureProps(PyObject *type_key)
{
/*
* Here is the second part of the function.
@@ -1056,10 +1012,10 @@ PySide_BuildSignatureProps(PyObject *type_key)
if (type_key == nullptr)
return nullptr;
PyObject *numkey = PyDict_GetItem(pyside_globals->arg_dict, type_key);
- Shiboken::AutoDecRef strings(_address_to_stringlist(numkey));
+ AutoDecRef strings(_address_to_stringlist(numkey));
if (strings.isNull())
return nullptr;
- Shiboken::AutoDecRef arg_tup(Py_BuildValue("(OO)", type_key, strings.object()));
+ AutoDecRef arg_tup(Py_BuildValue("(OO)", type_key, strings.object()));
if (arg_tup.isNull())
return nullptr;
PyObject *dict = PyObject_CallObject(pyside_globals->pyside_type_init_func, arg_tup);
@@ -1080,8 +1036,7 @@ PySide_BuildSignatureProps(PyObject *type_key)
static int _finish_nested_classes(PyObject *dict);
static int _build_func_to_type(PyObject *obtype);
-static int
-PySide_FinishSignatures(PyObject *module, const char *signatures[])
+static int PySide_FinishSignatures(PyObject *module, const char *signatures[])
{
/*
* Initialization of module functions and resolving of static methods.
@@ -1118,13 +1073,12 @@ PySide_FinishSignatures(PyObject *module, const char *signatures[])
assert(strncmp(name, "PySide2.", 8) != 0);
return 0;
}
- Shiboken::AutoDecRef ret(PyObject_CallFunction(
+ AutoDecRef ret(PyObject_CallFunction(
pyside_globals->finish_import_func, const_cast<char *>("(O)"), module));
return ret.isNull() ? -1 : 0;
}
-static int
-_finish_nested_classes(PyObject *obdict)
+static int _finish_nested_classes(PyObject *obdict)
{
PyObject *key, *value, *obtype;
PyTypeObject *subtype;
@@ -1146,8 +1100,7 @@ _finish_nested_classes(PyObject *obdict)
return 0;
}
-static int
-_build_func_to_type(PyObject *obtype)
+static int _build_func_to_type(PyObject *obtype)
{
/*
* There is no general way to directly get the type of a static method.
@@ -1183,20 +1136,20 @@ _build_func_to_type(PyObject *obtype)
* "{name}.overload".
*/
PyObject *descr = PyDict_GetItemString(dict, meth->ml_name);
- PyObject *look_attr = meth->ml_flags & METH_STATIC
- ? Shiboken::PyMagicName::func() : Shiboken::PyMagicName::name();
+ PyObject *look_attr = meth->ml_flags & METH_STATIC ? PyMagicName::func()
+ : PyMagicName::name();
int check_name = meth->ml_flags & METH_STATIC ? 0 : 1;
if (descr == nullptr)
return -1;
// We first check all methods if one is hidden by something else.
- Shiboken::AutoDecRef look(PyObject_GetAttr(descr, look_attr));
- Shiboken::AutoDecRef given(Py_BuildValue("s", meth->ml_name));
+ AutoDecRef look(PyObject_GetAttr(descr, look_attr));
+ AutoDecRef given(Py_BuildValue("s", meth->ml_name));
if (look.isNull()
|| (check_name && PyObject_RichCompareBool(look, given, Py_EQ) != 1)) {
PyErr_Clear();
- Shiboken::AutoDecRef cfunc(PyCFunction_NewEx(meth,
- reinterpret_cast<PyObject *>(type), nullptr));
+ AutoDecRef cfunc(PyCFunction_NewEx(
+ meth, reinterpret_cast<PyObject *>(type), nullptr));
if (cfunc.isNull())
return -1;
if (meth->ml_flags & METH_STATIC)
@@ -1212,7 +1165,7 @@ _build_func_to_type(PyObject *obtype)
return -1;
if (meth->ml_flags & METH_STATIC) {
// This is the special case where a static method is hidden.
- Shiboken::AutoDecRef special(Py_BuildValue("(Os)", cfunc.object(), "overload"));
+ AutoDecRef special(Py_BuildValue("(Os)", cfunc.object(), "overload"));
if (PyDict_SetItem(pyside_globals->map_dict, special, obtype) < 0)
return -1;
}
@@ -1229,8 +1182,7 @@ _build_func_to_type(PyObject *obtype)
return 0;
}
-int
-SbkSpecial_Type_Ready(PyObject * /* module */, PyTypeObject *type,
+int SbkSpecial_Type_Ready(PyObject * /* module */, PyTypeObject *type,
const char *signatures[])
{
if (PyType_Ready(type) < 0)
@@ -1244,8 +1196,7 @@ SbkSpecial_Type_Ready(PyObject * /* module */, PyTypeObject *type,
return ret;
}
-void
-FinishSignatureInitialization(PyObject *module, const char *signatures[])
+void FinishSignatureInitialization(PyObject *module, const char *signatures[])
{
/*
* This function is called at the very end of a module initialization.
@@ -1262,8 +1213,7 @@ FinishSignatureInitialization(PyObject *module, const char *signatures[])
}
}
-void
-SetError_Argument(PyObject *args, const char *func_name)
+void SetError_Argument(PyObject *args, const char *func_name)
{
/*
* This function replaces the type error construction with extra
@@ -1272,9 +1222,8 @@ SetError_Argument(PyObject *args, const char *func_name)
*/
init_module_1();
init_module_2();
- Shiboken::AutoDecRef res(PyObject_CallFunction(
- pyside_globals->seterror_argument_func,
- const_cast<char *>("(Os)"), args, func_name));
+ AutoDecRef res(PyObject_CallFunction(pyside_globals->seterror_argument_func,
+ const_cast<char *>("(Os)"), args, func_name));
if (res.isNull()) {
PyErr_Print();
Py_FatalError("seterror_argument did not receive a result");
@@ -1296,8 +1245,7 @@ SetError_Argument(PyObject *args, const char *func_name)
* to the metatype.
*/
-PyObject *
-Sbk_TypeGet___signature__(PyObject *ob, PyObject *modifier)
+PyObject *Sbk_TypeGet___signature__(PyObject *ob, PyObject *modifier)
{
return pyside_tp_get___signature__(ob, modifier);
}