aboutsummaryrefslogtreecommitdiffstats
path: root/sources/shiboken2/generator
diff options
context:
space:
mode:
Diffstat (limited to 'sources/shiboken2/generator')
-rw-r--r--sources/shiboken2/generator/generator.cpp2
-rw-r--r--sources/shiboken2/generator/main.cpp2
-rw-r--r--sources/shiboken2/generator/qtdoc/qtdocgenerator.cpp64
-rw-r--r--sources/shiboken2/generator/shiboken2/cppgenerator.cpp69
-rw-r--r--sources/shiboken2/generator/shiboken2/headergenerator.cpp2
-rw-r--r--sources/shiboken2/generator/shiboken2/shibokengenerator.cpp2
6 files changed, 55 insertions, 86 deletions
diff --git a/sources/shiboken2/generator/generator.cpp b/sources/shiboken2/generator/generator.cpp
index e39ead258..487715a3c 100644
--- a/sources/shiboken2/generator/generator.cpp
+++ b/sources/shiboken2/generator/generator.cpp
@@ -553,7 +553,7 @@ void Generator::replaceTemplateVariables(QString &code, const AbstractMetaFuncti
QTextStream &formatCode(QTextStream &s, const QString &code, Indentor &indentor)
{
- const auto lines= code.splitRef(QLatin1Char('\n'));
+ const auto lines= QStringView{code}.split(QLatin1Char('\n'));
for (const auto &line : lines) {
// Do not indent preprocessor lines
if (!line.isEmpty() && !line.startsWith(QLatin1Char('#')))
diff --git a/sources/shiboken2/generator/main.cpp b/sources/shiboken2/generator/main.cpp
index 8d819c763..3c5c5876c 100644
--- a/sources/shiboken2/generator/main.cpp
+++ b/sources/shiboken2/generator/main.cpp
@@ -79,7 +79,7 @@ static void printOptions(QTextStream &s, const OptionDescriptions &options)
s << ", ";
} else {
s << Qt::endl;
- const auto lines = od.second.splitRef(QLatin1Char('\n'));
+ const auto lines = QStringView{od.second}.split(QLatin1Char('\n'));
for (const auto &line : lines)
s << " " << line << Qt::endl;
s << Qt::endl;
diff --git a/sources/shiboken2/generator/qtdoc/qtdocgenerator.cpp b/sources/shiboken2/generator/qtdoc/qtdocgenerator.cpp
index 826e8056c..282da6eca 100644
--- a/sources/shiboken2/generator/qtdoc/qtdocgenerator.cpp
+++ b/sources/shiboken2/generator/qtdoc/qtdocgenerator.cpp
@@ -149,12 +149,12 @@ static int writeEscapedRstText(QTextStream &str, const String &s)
class escape
{
public:
- explicit escape(const QStringRef &s) : m_string(s) {}
+ explicit escape(QStringView s) : m_string(s) {}
void write(QTextStream &str) const { writeEscapedRstText(str, m_string); }
private:
- const QStringRef m_string;
+ const QStringView m_string;
};
inline QTextStream &operator<<(QTextStream &str, const escape &e)
@@ -410,7 +410,7 @@ QString QtXmlToSphinx::expandFunction(const QString& function) const
const int firstDot = function.indexOf(QLatin1Char('.'));
const AbstractMetaClass *metaClass = nullptr;
if (firstDot != -1) {
- const QStringRef className = function.leftRef(firstDot);
+ const auto className = QStringView{function}.left(firstDot);
for (const AbstractMetaClass *cls : m_generator->classes()) {
if (cls->name() == className) {
metaClass = cls;
@@ -427,7 +427,7 @@ QString QtXmlToSphinx::expandFunction(const QString& function) const
QString QtXmlToSphinx::resolveContextForMethod(const QString& methodName) const
{
- const QStringRef currentClass = m_context.splitRef(QLatin1Char('.')).constLast();
+ const auto currentClass = QStringView{m_context}.split(QLatin1Char('.')).constLast();
const AbstractMetaClass *metaClass = nullptr;
for (const AbstractMetaClass *cls : m_generator->classes()) {
@@ -483,7 +483,7 @@ QString QtXmlToSphinx::transform(const QString& doc)
}
if (token == QXmlStreamReader::StartElement) {
- QStringRef tagName = reader.name();
+ const auto tagName = reader.name();
TagHandler handler = m_handlerMap.value(tagName.toString(), &QtXmlToSphinx::handleUnknownTag);
if (!m_handlers.isEmpty() && ( (m_handlers.top() == &QtXmlToSphinx::handleIgnoredTag) ||
(m_handlers.top() == &QtXmlToSphinx::handleRawTag)) )
@@ -630,7 +630,7 @@ void QtXmlToSphinx::handleParaTag(QXmlStreamReader& reader)
m_output << INDENT << result << Qt::endl << Qt::endl;
} else if (token == QXmlStreamReader::Characters) {
- const QStringRef text = reader.text();
+ const auto text = reader.text();
const QChar end = lastChar(m_output);
if (!text.isEmpty() && INDENT.indent == 0 && !end.isNull()) {
QChar start = text[0];
@@ -675,7 +675,7 @@ void QtXmlToSphinx::handleArgumentTag(QXmlStreamReader& reader)
static inline QString functionLinkType() { return QStringLiteral("function"); }
static inline QString classLinkType() { return QStringLiteral("class"); }
-static inline QString fixLinkType(const QStringRef &type)
+static inline QString fixLinkType(QStringView type)
{
// TODO: create a flag PROPERTY-AS-FUNCTION to ask if the properties
// are recognized as such or not in the binding
@@ -709,7 +709,7 @@ void QtXmlToSphinx::handleSeeAlsoTag(QXmlStreamReader& reader)
break;
case QXmlStreamReader::Characters: {
// Direct embedded link: <see-also>rootIsDecorated()</see-also>
- const QStringRef textR = reader.text().trimmed();
+ const auto textR = reader.text().trimmed();
if (!textR.isEmpty()) {
const QString text = textR.toString();
if (m_seeAlsoContext.isNull()) {
@@ -743,8 +743,8 @@ static inline bool snippetComparison()
template <class Indent> // const char*/class Indentor
void formatSnippet(QTextStream &str, Indent indent, const QString &snippet)
{
- const QVector<QStringRef> lines = snippet.splitRef(QLatin1Char('\n'));
- for (const QStringRef &line : lines) {
+ const auto lines = QStringView{snippet}.split(QLatin1Char('\n'));
+ for (const auto &line : lines) {
if (!line.trimmed().isEmpty())
str << indent << line;
str << Qt::endl;
@@ -902,7 +902,7 @@ void QtXmlToSphinx::handleRowTag(QXmlStreamReader& reader)
enum ListType { BulletList, OrderedList, EnumeratedList };
-static inline ListType webXmlListType(const QStringRef &t)
+static inline ListType webXmlListType(QStringView t)
{
if (t == QLatin1String("enum"))
return EnumeratedList;
@@ -934,7 +934,7 @@ void QtXmlToSphinx::handleListTag(QXmlStreamReader& reader)
const char *separator = listType == BulletList ? "* " : "#. ";
const char *indent = listType == BulletList ? " " : " ";
for (const TableCell &cell : m_currentTable.constFirst()) {
- const QVector<QStringRef> itemLines = cell.data.splitRef(QLatin1Char('\n'));
+ const auto itemLines = QStringView{cell.data}.split(QLatin1Char('\n'));
m_output << INDENT << separator << itemLines.constFirst() << Qt::endl;
for (int i = 1, max = itemLines.count(); i < max; ++i)
m_output << INDENT << indent << itemLines[i] << Qt::endl;
@@ -991,7 +991,7 @@ QtXmlToSphinx::LinkContext *QtXmlToSphinx::handleLinkStart(const QString &type,
if (type == functionLinkType() && !m_context.isEmpty()) {
result->type = LinkContext::Method;
- const QVector<QStringRef> rawlinklist = result->linkRef.splitRef(QLatin1Char('.'));
+ const auto rawlinklist = QStringView{result->linkRef}.split(QLatin1Char('.'));
if (rawlinklist.size() == 1 || rawlinklist.constFirst() == m_context) {
QString context = resolveContextForMethod(rawlinklist.constLast().toString());
if (!result->linkRef.startsWith(context))
@@ -1006,7 +1006,7 @@ QtXmlToSphinx::LinkContext *QtXmlToSphinx::handleLinkStart(const QString &type,
if (const TypeEntry *type = TypeDatabase::instance()->findType(result->linkRef)) {
result->linkRef = type->qualifiedTargetLangName();
} else { // fall back to the old heuristic if the type wasn't found.
- const QVector<QStringRef> rawlinklist = result->linkRef.splitRef(QLatin1Char('.'));
+ const auto rawlinklist = QStringView{result->linkRef}.split(QLatin1Char('.'));
QStringList splittedContext = m_context.split(QLatin1Char('.'));
if (rawlinklist.size() == 1 || rawlinklist.constFirst() == splittedContext.constLast()) {
splittedContext.removeLast();
@@ -1176,8 +1176,8 @@ void QtXmlToSphinx::handleRawTag(QXmlStreamReader& reader)
QString format = reader.attributes().value(QLatin1String("format")).toString();
m_output << INDENT << ".. raw:: " << format.toLower() << Qt::endl << Qt::endl;
} else if (token == QXmlStreamReader::Characters) {
- const QVector<QStringRef> lst(reader.text().split(QLatin1Char('\n')));
- for (const QStringRef &row : lst)
+ const auto lst(reader.text().split(QLatin1Char('\n')));
+ for (const auto &row : lst)
m_output << INDENT << INDENT << row << Qt::endl;
} else if (token == QXmlStreamReader::EndElement) {
m_output << Qt::endl << Qt::endl;
@@ -1191,8 +1191,8 @@ void QtXmlToSphinx::handleCodeTag(QXmlStreamReader& reader)
m_output << INDENT << "::\n\n";
INDENT.indent++;
} else if (token == QXmlStreamReader::Characters) {
- const QVector<QStringRef> lst(reader.text().split(QLatin1Char('\n')));
- for (const QStringRef &row : lst)
+ const auto lst(reader.text().split(QLatin1Char('\n')));
+ for (const auto &row : lst)
m_output << INDENT << INDENT << row << Qt::endl;
} else if (token == QXmlStreamReader::EndElement) {
m_output << Qt::endl << Qt::endl;
@@ -1226,11 +1226,11 @@ void QtXmlToSphinx::handlePageTag(QXmlStreamReader &reader)
if (reader.tokenType() != QXmlStreamReader::StartElement)
return;
- const QStringRef title = reader.attributes().value(titleAttribute());
+ const auto title = reader.attributes().value(titleAttribute());
if (!title.isEmpty())
m_output << rstLabel(title.toString());
- const QStringRef fullTitle = reader.attributes().value(fullTitleAttribute());
+ const auto fullTitle = reader.attributes().value(fullTitleAttribute());
const int size = fullTitle.isEmpty()
? writeEscapedRstText(m_output, title)
: writeEscapedRstText(m_output, fullTitle);
@@ -1242,7 +1242,7 @@ void QtXmlToSphinx::handleTargetTag(QXmlStreamReader &reader)
{
if (reader.tokenType() != QXmlStreamReader::StartElement)
return;
- const QStringRef name = reader.attributes().value(nameAttribute());
+ const auto name = reader.attributes().value(nameAttribute());
if (!name.isEmpty())
m_output << INDENT << rstLabel(name.toString());
}
@@ -1367,7 +1367,7 @@ void QtXmlToSphinx::Table::normalize()
newCell.rowSpan = -1;
int targetRow = row + 1;
const int targetEndRow =
- std::min(targetRow + cell.rowSpan - 1, m_rows.count());
+ std::min(targetRow + cell.rowSpan - 1, int(m_rows.count()));
cell.rowSpan = 0;
for ( ; targetRow < targetEndRow; ++targetRow)
m_rows[targetRow].insert(col, newCell);
@@ -1402,10 +1402,10 @@ void QtXmlToSphinx::Table::format (QTextStream& s) const
for (int i = 0, maxI = m_rows.count(); i < maxI; ++i) {
const QtXmlToSphinx::TableRow& row = m_rows.at(i);
for (int j = 0, maxJ = std::min(row.count(), colWidths.size()); j < maxJ; ++j) {
- const QVector<QStringRef> rowLines = row[j].data.splitRef(QLatin1Char('\n')); // cache this would be a good idea
- for (const QStringRef &str : rowLines)
- colWidths[j] = std::max(colWidths[j], str.count());
- rowHeights[i] = std::max(rowHeights[i], row[j].data.count(QLatin1Char('\n')) + 1);
+ const auto rowLines = QStringView{row[j].data}.split(QLatin1Char('\n')); // cache this would be a good idea
+ for (const auto &str : rowLines)
+ colWidths[j] = std::max(colWidths[j], int(str.size()));
+ rowHeights[i] = std::max(rowHeights[i], int(row[j].data.count(QLatin1Char('\n')) + 1));
}
}
@@ -1441,9 +1441,9 @@ void QtXmlToSphinx::Table::format (QTextStream& s) const
// Print the table cells
for (int rowLine = 0; rowLine < rowHeights[i]; ++rowLine) { // for each line in a row
int j = 0;
- for (int maxJ = std::min(row.count(), headerColumnCount); j < maxJ; ++j) { // for each column
+ for (int maxJ = std::min(int(row.count()), headerColumnCount); j < maxJ; ++j) { // for each column
const QtXmlToSphinx::TableCell& cell = row[j];
- const QVector<QStringRef> rowLines = cell.data.splitRef(QLatin1Char('\n')); // FIXME: Cache this!!!
+ const auto rowLines = QStringView{cell.data}.split(QLatin1Char('\n')); // FIXME: Cache this!!!
if (!j) // First column, so we need print the identation
s << INDENT;
@@ -1548,10 +1548,10 @@ void QtDocGenerator::writeFormattedText(QTextStream &s, const Documentation &doc
s << x;
} else {
const QString &value = doc.value(docType);
- const QVector<QStringRef> lines = value.splitRef(QLatin1Char('\n'));
+ const auto lines = QStringView{value}.split(QLatin1Char('\n'));
int typesystemIndentation = std::numeric_limits<int>::max();
// check how many spaces must be removed from the beginning of each line
- for (const QStringRef &line : lines) {
+ for (const auto &line : lines) {
const auto it = std::find_if(line.cbegin(), line.cend(),
[] (QChar c) { return !c.isSpace(); });
if (it != line.cend())
@@ -1559,7 +1559,7 @@ void QtDocGenerator::writeFormattedText(QTextStream &s, const Documentation &doc
}
if (typesystemIndentation == std::numeric_limits<int>::max())
typesystemIndentation = 0;
- for (const QStringRef &line : lines) {
+ for (const auto &line : lines) {
s << INDENT
<< (typesystemIndentation > 0 && typesystemIndentation < line.size()
? line.right(line.size() - typesystemIndentation) : line)
@@ -1938,7 +1938,7 @@ void QtDocGenerator::writeDocSnips(QTextStream &s,
break;
}
}
- s << row.midRef(offset) << Qt::endl;
+ s << QStringView{row}.mid(offset) << Qt::endl;
currentRow++;
}
diff --git a/sources/shiboken2/generator/shiboken2/cppgenerator.cpp b/sources/shiboken2/generator/shiboken2/cppgenerator.cpp
index 1ae1c72b4..388358249 100644
--- a/sources/shiboken2/generator/shiboken2/cppgenerator.cpp
+++ b/sources/shiboken2/generator/shiboken2/cppgenerator.cpp
@@ -293,7 +293,7 @@ static bool isStdSetterName(QString setterName, QString propertyName)
{
return setterName.size() == propertyName.size() + 3
&& setterName.startsWith(QLatin1String("set"))
- && setterName.endsWith(propertyName.rightRef(propertyName.size() - 1))
+ && setterName.endsWith(QStringView{propertyName}.right(propertyName.size() - 1))
&& setterName.at(3) == propertyName.at(0).toUpper();
}
@@ -912,11 +912,7 @@ QString CppGenerator::virtualMethodReturn(QTextStream &s,
const QRegularExpressionMatch match = regex.match(expr, offset);
if (!match.hasMatch())
break;
-#if QT_VERSION >= QT_VERSION_CHECK(6, 0, 0)
const int argId = match.capturedView(1).toInt() - 1;
-#else
- const int argId = match.capturedRef(1).toInt() - 1;
-#endif
if (argId < 0 || argId > func->arguments().count()) {
qCWarning(lcShiboken, "The expression used in return value contains an invalid index.");
break;
@@ -2390,6 +2386,8 @@ void CppGenerator::writeTypeCheck(QTextStream &s, const OverloadData *overloadDa
// This condition trusts that the OverloadData object will arrange for
// PyInt type to come after the more precise numeric types (e.g. float and bool)
const AbstractMetaType *argType = overloadData->argType();
+ if (auto viewOn = argType->viewOn())
+ argType = viewOn;
bool numberType = numericTypes.count() == 1 || ShibokenGenerator::isPyInt(argType);
QString customType = (overloadData->hasArgumentTypeReplace() ? overloadData->argumentTypeReplaced() : QString());
bool rejectNull = shouldRejectNullPointerArgument(overloadData->referenceFunction(), overloadData->argPos());
@@ -2420,12 +2418,15 @@ const AbstractMetaType *CppGenerator::getArgumentType(const AbstractMetaFunction
return nullptr;
}
- const AbstractMetaType *argType = nullptr;
QString typeReplaced = func->typeReplaced(argPos);
- if (typeReplaced.isEmpty())
- argType = (argPos == 0) ? func->type() : func->arguments().at(argPos-1)->type();
- else
- argType = buildAbstractMetaTypeFromString(typeReplaced);
+ if (typeReplaced.isEmpty()) {
+ if (argPos == 0)
+ return func->type();
+ auto argType = func->arguments().at(argPos - 1)->type();
+ return argType->viewOn() ? argType->viewOn() : argType;
+ }
+
+ auto argType = buildAbstractMetaTypeFromString(typeReplaced);
if (!argType && !m_knownPythonTypes.contains(typeReplaced)) {
qCWarning(lcShiboken).noquote().nospace()
<< QString::fromLatin1("Unknown type '%1' used as argument type replacement "\
@@ -4271,11 +4272,7 @@ void CppGenerator::writeTypeAsSequenceDefinition(QTextStream &s, const AbstractM
const QString &sqName = it.key();
if (funcs[sqName].isEmpty())
continue;
- if (it.value() == QLatin1String("sq_slice"))
- s << "#ifndef IS_PY3K\n";
s << INDENT << "{Py_" << it.value() << ", (void *)" << funcs[sqName] << "},\n";
- if (it.value() == QLatin1String("sq_slice"))
- s << "#endif\n";
}
}
@@ -4356,26 +4353,17 @@ void CppGenerator::writeTypeAsNumberDefinition(QTextStream &s, const AbstractMet
if (nb[nbName].isEmpty())
continue;
- // bool is special because the field name differs on Python 2 and 3 (nb_nonzero vs nb_bool)
- // so a shiboken macro is used.
if (nbName == QLatin1String("bool")) {
- s << "#ifdef IS_PY3K\n";
s << INDENT << "{Py_nb_bool, (void *)" << nb[nbName] << "},\n";
- s << "#else\n";
- s << INDENT << "{Py_nb_nonzero, (void *)" << nb[nbName] << "},\n";
- s << "#endif\n";
} else {
bool excludeFromPy3K = nbName == QLatin1String("__div__") || nbName == QLatin1String("__idiv__");
if (!excludeFromPy3K)
s << INDENT << "{Py_" << it.value() << ", (void *)" << nb[nbName] << "},\n";
}
}
- if (!nb[QLatin1String("__div__")].isEmpty()) {
+ if (!nb[QLatin1String("__div__")].isEmpty())
s << INDENT << "{Py_nb_true_divide, (void *)" << nb[QLatin1String("__div__")] << "},\n";
- s << "#ifndef IS_PY3K\n";
- s << INDENT << "{Py_nb_divide, (void *)" << nb[QLatin1String("__div__")] << "},\n";
- s << "#endif\n";
- }
+
if (!nb[QLatin1String("__idiv__")].isEmpty()) {
s << INDENT << "// This function is unused in Python 3. We reference it here.\n";
s << INDENT << "{0, (void *)" << nb[QLatin1String("__idiv__")] << "},\n";
@@ -4824,7 +4812,10 @@ void CppGenerator::writeSignatureInfo(QTextStream &s, const AbstractMetaFunction
args << QLatin1String("self");
const AbstractMetaArgumentList &arguments = f->arguments();
for (const AbstractMetaArgument *arg : arguments) {
- QString strArg = arg->type()->pythonSignature();
+ const auto *metaType = arg->type();
+ if (auto viewOn = metaType->viewOn())
+ metaType = viewOn;
+ QString strArg = metaType->pythonSignature();
if (!arg->defaultValueExpression().isEmpty()) {
strArg += QLatin1Char('=');
QString e = arg->defaultValueExpression();
@@ -5063,21 +5054,13 @@ void CppGenerator::writeFlagsNumberMethodsDefinition(QTextStream &s, const Abstr
QString cpythonName = cpythonEnumName(cppEnum);
s << "static PyType_Slot " << cpythonName << "_number_slots[] = {\n";
- s << "#ifdef IS_PY3K\n";
s << INDENT << "{Py_nb_bool, reinterpret_cast<void *>(" << cpythonName << "__nonzero)},\n";
- s << "#else\n";
- s << INDENT << "{Py_nb_nonzero, reinterpret_cast<void *>(" << cpythonName << "__nonzero)},\n";
- s << INDENT << "{Py_nb_long, reinterpret_cast<void *>(" << cpythonName << "_long)},\n";
- s << "#endif\n";
s << INDENT << "{Py_nb_invert, reinterpret_cast<void *>(" << cpythonName << "___invert__)},\n";
s << INDENT << "{Py_nb_and, reinterpret_cast<void *>(" << cpythonName << "___and__)},\n";
s << INDENT << "{Py_nb_xor, reinterpret_cast<void *>(" << cpythonName << "___xor__)},\n";
s << INDENT << "{Py_nb_or, reinterpret_cast<void *>(" << cpythonName << "___or__)},\n";
s << INDENT << "{Py_nb_int, reinterpret_cast<void *>(" << cpythonName << "_long)},\n";
s << INDENT << "{Py_nb_index, reinterpret_cast<void *>(" << cpythonName << "_long)},\n";
- s << "#ifndef IS_PY3K\n";
- s << INDENT << "{Py_nb_long, reinterpret_cast<void *>(" << cpythonName << "_long)},\n";
- s << "#endif\n";
s << INDENT << "{0, " << NULL_PTR << "} // sentinel\n";
s << "};\n\n";
}
@@ -5093,17 +5076,10 @@ void CppGenerator::writeFlagsBinaryOperator(QTextStream &s, const AbstractMetaEn
AbstractMetaType *flagsType = buildAbstractMetaTypeFromTypeEntry(flagsEntry);
s << INDENT << "::" << flagsEntry->originalName() << " cppResult, " << CPP_SELF_VAR << ", cppArg;\n";
- s << "#ifdef IS_PY3K\n";
s << INDENT << CPP_SELF_VAR << " = static_cast<::" << flagsEntry->originalName()
<< ">(int(PyLong_AsLong(self)));\n";
s << INDENT << "cppArg = static_cast<" << flagsEntry->originalName() << ">(int(PyLong_AsLong("
- << PYTHON_ARG << ")));\n";
- s << "#else\n";
- s << INDENT << CPP_SELF_VAR << " = static_cast<::" << flagsEntry->originalName()
- << ">(int(PyInt_AsLong(self)));\n";
- s << INDENT << "cppArg = static_cast<" << flagsEntry->originalName()
- << ">(int(PyInt_AsLong(" << PYTHON_ARG << ")));\n";
- s << "#endif\n\n";
+ << PYTHON_ARG << ")));\n\n";
s << INDENT << "cppResult = " << CPP_SELF_VAR << " " << cppOpName << " cppArg;\n";
s << INDENT << "return ";
writeToPythonConversion(s, flagsType, nullptr, QLatin1String("cppResult"));
@@ -5978,7 +5954,6 @@ bool CppGenerator::finishGeneration()
s << " #define SBK_EXPORT_MODULE\n";
s << "#endif\n\n";
- s << "#ifdef IS_PY3K\n";
s << "static struct PyModuleDef moduledef = {\n";
s << " /* m_base */ PyModuleDef_HEAD_INIT,\n";
s << " /* m_name */ \"" << moduleName() << "\",\n";
@@ -5990,7 +5965,6 @@ bool CppGenerator::finishGeneration()
s << " /* m_clear */ nullptr,\n";
s << " /* m_free */ nullptr\n";
s << "};\n\n";
- s << "#endif\n\n";
// PYSIDE-510: Create a signatures string for the introspection feature.
writeSignatureStrings(s, signatureStream, moduleName(), "global functions");
@@ -6025,12 +5999,7 @@ bool CppGenerator::finishGeneration()
s << INDENT << "static SbkConverter *sbkConverters[SBK_" << moduleName() << "_CONVERTERS_IDX_COUNT" << "];\n";
s << INDENT << convertersVariableName() << " = sbkConverters;\n\n";
- s << "#ifdef IS_PY3K\n";
- s << INDENT << "PyObject *module = Shiboken::Module::create(\"" << moduleName() << "\", &moduledef);\n";
- s << "#else\n";
- s << INDENT << "PyObject *module = Shiboken::Module::create(\"" << moduleName() << "\", ";
- s << moduleName() << "_methods);\n";
- s << "#endif\n\n";
+ s << INDENT << "PyObject *module = Shiboken::Module::create(\"" << moduleName() << "\", &moduledef);\n\n";
s << INDENT << "// Make module available from global scope\n";
s << INDENT << pythonModuleObjectName() << " = module;\n\n";
diff --git a/sources/shiboken2/generator/shiboken2/headergenerator.cpp b/sources/shiboken2/generator/shiboken2/headergenerator.cpp
index 2d1b41443..1d3a20447 100644
--- a/sources/shiboken2/generator/shiboken2/headergenerator.cpp
+++ b/sources/shiboken2/generator/shiboken2/headergenerator.cpp
@@ -366,7 +366,7 @@ static void formatTypeDefEntries(QTextStream &s)
for (const auto e : entries) {
const QString name = e->qualifiedCppName();
// Fixme: simplify by using nested namespaces in C++ 17.
- const auto components = name.splitRef(QLatin1String("::"));
+ const auto components = QStringView{name}.split(u"::");
const int nameSpaceCount = components.size() - 1;
for (int n = 0; n < nameSpaceCount; ++n)
s << "namespace " << components.at(n) << " {\n";
diff --git a/sources/shiboken2/generator/shiboken2/shibokengenerator.cpp b/sources/shiboken2/generator/shiboken2/shibokengenerator.cpp
index 4f3ca20c1..a6a175999 100644
--- a/sources/shiboken2/generator/shiboken2/shibokengenerator.cpp
+++ b/sources/shiboken2/generator/shiboken2/shibokengenerator.cpp
@@ -2783,7 +2783,7 @@ QString ShibokenGenerator::getTypeIndexVariableName(const TypeEntry *type) const
if (type->isNamespace()) {
QString package = type->targetLangPackage();
const int dot = package.lastIndexOf(QLatin1Char('.'));
- result += package.rightRef(package.size() - (dot + 1));
+ result += QStringView{package}.right(package.size() - (dot + 1));
}
result += _fixedCppTypeName(type->qualifiedCppName()).toUpper();
appendIndexSuffix(&result);