aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorFriedemann Kleint <Friedemann.Kleint@qt.io>2023-09-19 20:37:27 +0200
committerFriedemann Kleint <Friedemann.Kleint@qt.io>2023-09-21 10:28:06 +0200
commit81bcde91818d3cf36c3f1c95a448a10de8aca4ad (patch)
tree94f4b7502dd1b829b5f99b5bf6cc432e32ff9953
parentc7df6c4acc5be75349361f3010365d02e75fd261 (diff)
shiboken6: Fix calling conventions in TextStream/formatting
Pass enum by value and a large struct by const-ref. As a drive-by, change sbkUnusedVariableCast() to use QStringView so that it works with UTF-16 literals as well. Change-Id: I8e1ed8fce872ea0d346b8ade1d0e1e857cacd73f Reviewed-by: Shyamnath Premnadh <Shyamnath.Premnadh@qt.io> (cherry picked from commit aa2bf383ac764c1da5e5c6d7a3e45cd3370a7fc8)
-rw-r--r--sources/shiboken6/ApiExtractor/textstream.h4
-rw-r--r--sources/shiboken6/generator/shiboken/cppgenerator.cpp12
2 files changed, 8 insertions, 8 deletions
diff --git a/sources/shiboken6/ApiExtractor/textstream.h b/sources/shiboken6/ApiExtractor/textstream.h
index 074e23858..940dda9a9 100644
--- a/sources/shiboken6/ApiExtractor/textstream.h
+++ b/sources/shiboken6/ApiExtractor/textstream.h
@@ -31,7 +31,7 @@ public:
virtual ~TextStream();
Language language() const { return m_language; }
- void setLanguage(const Language &language) { m_language = language; }
+ void setLanguage(Language language) { m_language = language; }
bool isIndentationEnabled() const { return m_indentationEnabled; }
void setIndentationEnabled(bool m)
@@ -85,7 +85,7 @@ public:
TextStream &operator<<(qsizetype t) { putSizeType(t); return *this; }
#endif
- inline TextStream &operator<<(QTextStreamManipulator m) { m_str << m; return *this; }
+ inline TextStream &operator<<(const QTextStreamManipulator &m) { m_str << m; return *this; }
inline TextStream &operator<<(ManipulatorFunc f) { f(*this); return *this; }
void putRepetitiveChars(char c, int count);
diff --git a/sources/shiboken6/generator/shiboken/cppgenerator.cpp b/sources/shiboken6/generator/shiboken/cppgenerator.cpp
index dac4ab994..961d410a4 100644
--- a/sources/shiboken6/generator/shiboken/cppgenerator.cpp
+++ b/sources/shiboken6/generator/shiboken/cppgenerator.cpp
@@ -64,9 +64,9 @@ static QString mangleName(QString name)
struct sbkUnusedVariableCast
{
- explicit sbkUnusedVariableCast(QString name) : m_name(name) {}
+ explicit sbkUnusedVariableCast(QStringView name) : m_name(name) {}
- const QString m_name;
+ const QStringView m_name;
};
TextStream &operator<<(TextStream &str, const sbkUnusedVariableCast &c)
@@ -2370,9 +2370,9 @@ void CppGenerator::writeMethodWrapper(TextStream &s, const OverloadData &overloa
}
s << ")\n{\n" << indent;
if (rfunc->ownerClass() == nullptr || overloadData.hasStaticFunction())
- s << sbkUnusedVariableCast(u"self"_s);
+ s << sbkUnusedVariableCast(u"self");
if (hasKwdArgs)
- s << sbkUnusedVariableCast(u"kwds"_s);
+ s << sbkUnusedVariableCast(u"kwds");
writeMethodWrapperPreamble(s, overloadData, classContext);
@@ -3487,7 +3487,7 @@ void CppGenerator::writeIsPythonConvertibleToCppFunction(TextStream &s,
<< "return Shiboken::Conversions::nonePythonToCppNullPtr;\n" << outdent;
} else {
if (!condition.contains(u"pyIn"))
- s << sbkUnusedVariableCast(u"pyIn"_s);
+ s << sbkUnusedVariableCast(u"pyIn");
}
s << "if (" << condition << ")\n" << indent
<< "return " << pythonToCppFuncName << ";\n" << outdent
@@ -6180,7 +6180,7 @@ void CppGenerator::writeTypeDiscoveryFunction(TextStream &s,
s << "static void *" << cpythonBaseName(metaClass)
<< "_typeDiscovery(void *cptr, PyTypeObject *instanceType)\n{\n" << indent
<< sbkUnusedVariableCast(u"cptr"_s)
- << sbkUnusedVariableCast(u"instanceType"_s);
+ << sbkUnusedVariableCast(u"instanceType");
if (!polymorphicExpr.isEmpty()) {
polymorphicExpr = polymorphicExpr.replace(u"%1"_s,