aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorFriedemann Kleint <Friedemann.Kleint@qt.io>2021-05-26 07:56:43 +0200
committerQt Cherry-pick Bot <cherrypick_bot@qt-project.org>2021-05-26 13:32:09 +0000
commit8fde785b2f20ac10cb1628e6a110bc11fcbfa3e6 (patch)
tree1739eac1f20caafd7ecd9640ac7c509f1f4f05ad
parent7fb84b6d1c5f1f7cf99f27a7ce46cc8e1e9d06dc (diff)
shiboken6: Mark old syntax for conversion rules as deprecated
TypeEntry had a string member for conversion rules (besides the nested "target-to-native" and "native-to-target" attributes) that was populated from the "file" attribute depending on the "class" attribute ("target"/"native"). Remove code path and flags for "native" since they were not used. Rename the member to targetConversionRule() for clarity and add a warning and FIXME comments. Change-Id: I2a991d438e48c1cc0519d077cb3c0599f9800eb7 Reviewed-by: Christian Tismer <tismer@stackless.com> (cherry picked from commit 4394f6707702c9aa644586266400ae4ff5dea446) Reviewed-by: Qt Cherry-pick Bot <cherrypick_bot@qt-project.org>
-rw-r--r--sources/shiboken6/ApiExtractor/tests/testcodeinjection.cpp4
-rw-r--r--sources/shiboken6/ApiExtractor/tests/testconversionruletag.cpp7
-rw-r--r--sources/shiboken6/ApiExtractor/typesystem.cpp25
-rw-r--r--sources/shiboken6/ApiExtractor/typesystem.h20
-rw-r--r--sources/shiboken6/ApiExtractor/typesystemparser.cpp18
-rw-r--r--sources/shiboken6/generator/shiboken/cppgenerator.cpp2
6 files changed, 26 insertions, 50 deletions
diff --git a/sources/shiboken6/ApiExtractor/tests/testcodeinjection.cpp b/sources/shiboken6/ApiExtractor/tests/testcodeinjection.cpp
index 366b49799..1d7ba9666 100644
--- a/sources/shiboken6/ApiExtractor/tests/testcodeinjection.cpp
+++ b/sources/shiboken6/ApiExtractor/tests/testcodeinjection.cpp
@@ -71,7 +71,7 @@ void TestCodeInjections::testReadFile()
QString xmlCode = QLatin1String("\
<typesystem package=\"Foo\">\n\
<value-type name='A'>\n\
- <conversion-rule ") + attribute + QLatin1String("/>\n\
+ <conversion-rule class='target' ") + attribute + QLatin1String("/>\n\
<inject-code class='target' ") + attribute + QLatin1String("/>\n\
<value-type name='B'/>\n\
</value-type>\n\
@@ -83,7 +83,7 @@ void TestCodeInjections::testReadFile()
QCOMPARE(classA->typeEntry()->codeSnips().count(), 1);
QString code = classA->typeEntry()->codeSnips().constFirst().code();
QVERIFY(code.indexOf(expected) != -1);
- code = classA->typeEntry()->conversionRule();
+ code = classA->typeEntry()->targetConversionRule();
QVERIFY(code.indexOf(expected) != -1);
}
diff --git a/sources/shiboken6/ApiExtractor/tests/testconversionruletag.cpp b/sources/shiboken6/ApiExtractor/tests/testconversionruletag.cpp
index 15a9231ff..1f244bd83 100644
--- a/sources/shiboken6/ApiExtractor/tests/testconversionruletag.cpp
+++ b/sources/shiboken6/ApiExtractor/tests/testconversionruletag.cpp
@@ -36,6 +36,7 @@
void TestConversionRuleTag::testConversionRuleTagWithFile()
{
+ // FIXME PYSIDE7 remove
// temp file used later
const char conversionData[] = "Hi! I'm a conversion rule.";
QTemporaryFile file;
@@ -47,7 +48,7 @@ void TestConversionRuleTag::testConversionRuleTagWithFile()
QString xmlCode = QLatin1String("\
<typesystem package='Foo'>\n\
<value-type name='A'>\n\
- <conversion-rule file='") + file.fileName() + QLatin1String("'/>\n\
+ <conversion-rule class='target' file='") + file.fileName() + QLatin1String("'/>\n\
</value-type>\n\
</typesystem>\n");
QScopedPointer<AbstractMetaBuilder> builder(TestUtil::parse(cppCode, xmlCode.toLocal8Bit().data()));
@@ -56,8 +57,8 @@ void TestConversionRuleTag::testConversionRuleTagWithFile()
const AbstractMetaClass *classA = AbstractMetaClass::findClass(classes, QLatin1String("A"));
QVERIFY(classA);
const ComplexTypeEntry* typeEntry = classA->typeEntry();
- QVERIFY(typeEntry->hasConversionRule());
- QCOMPARE(typeEntry->conversionRule(), QLatin1String(conversionData));
+ QVERIFY(typeEntry->hasTargetConversionRule());
+ QCOMPARE(typeEntry->targetConversionRule(), QLatin1String(conversionData));
}
void TestConversionRuleTag::testConversionRuleTagReplace()
diff --git a/sources/shiboken6/ApiExtractor/typesystem.cpp b/sources/shiboken6/ApiExtractor/typesystem.cpp
index 29f7a5c91..55e5d3e8a 100644
--- a/sources/shiboken6/ApiExtractor/typesystem.cpp
+++ b/sources/shiboken6/ApiExtractor/typesystem.cpp
@@ -83,7 +83,7 @@ public:
DocModificationList m_docModifications;
IncludeList m_extraIncludes;
Include m_include;
- QString m_conversionRule;
+ QString m_targetConversionRule;
QVersionNumber m_version;
CustomConversion *m_customConversion = nullptr;
SourceLocation m_sourceLocation; // XML file
@@ -182,20 +182,14 @@ void TypeEntry::setInclude(const Include &inc)
}
}
-void TypeEntry::setConversionRule(const QString &conversionRule)
+void TypeEntry::setTargetConversionRule(const QString &conversionRule)
{
- m_d->m_conversionRule = conversionRule;
+ m_d->m_targetConversionRule = conversionRule;
}
-QString TypeEntry::conversionRule() const
+QString TypeEntry::targetConversionRule() const
{
- //skip conversions flag
- return m_d->m_conversionRule.mid(1);
-}
-
-bool TypeEntry::hasConversionRule() const
-{
- return !m_d->m_conversionRule.isEmpty();
+ return m_d->m_targetConversionRule;
}
QVersionNumber TypeEntry::version() const
@@ -203,14 +197,9 @@ QVersionNumber TypeEntry::version() const
return m_d->m_version;
}
-bool TypeEntry::hasNativeConversionRule() const
-{
- return m_d->m_conversionRule.startsWith(QLatin1String(NATIVE_CONVERSION_RULE_FLAG));
-}
-
bool TypeEntry::hasTargetConversionRule() const
{
- return m_d->m_conversionRule.startsWith(QLatin1String(TARGET_CONVERSION_RULE_FLAG));
+ return !m_d->m_targetConversionRule.isEmpty();
}
bool TypeEntry::isCppPrimitive() const
@@ -2061,7 +2050,7 @@ void TypeEntry::formatDebug(QDebug &debug) const
FORMAT_NONEMPTY_STRING("package", m_d->m_targetLangPackage)
FORMAT_BOOL("stream", m_d->m_stream)
FORMAT_LIST_SIZE("codeSnips", m_d->m_codeSnips)
- FORMAT_NONEMPTY_STRING("conversionRule", m_d->m_conversionRule)
+ FORMAT_NONEMPTY_STRING("targetConversionRule", m_d->m_targetConversionRule)
if (m_d->m_viewOn)
debug << ", views=" << m_d->m_viewOn->name();
if (!m_d->m_version.isNull() && m_d->m_version > QVersionNumber(0, 0))
diff --git a/sources/shiboken6/ApiExtractor/typesystem.h b/sources/shiboken6/ApiExtractor/typesystem.h
index fdddb458b..7d96c1bfb 100644
--- a/sources/shiboken6/ApiExtractor/typesystem.h
+++ b/sources/shiboken6/ApiExtractor/typesystem.h
@@ -36,10 +36,6 @@
#include <QtCore/QStringList>
#include <QtCore/QScopedPointer>
-//Used to identify the conversion rule to avoid break API
-extern const char *TARGET_CONVERSION_RULE_FLAG;
-extern const char *NATIVE_CONVERSION_RULE_FLAG;
-
class CustomFunction;
class CustomConversion;
class EnumValueTypeEntry;
@@ -218,22 +214,16 @@ public:
Include include() const;
void setInclude(const Include &inc);
- // Replace conversionRule arg to CodeSnip in future version
- /// Set the type convertion rule
- void setConversionRule(const QString& conversionRule);
-
- /// Returns the type convertion rule
- QString conversionRule() const;
+ // FIXME PYSIDE7: Remove
+ /// Set the target type conversion rule
+ void setTargetConversionRule(const QString& conversionRule);
- /// Returns true if there are any conversiton rule for this type, false otherwise.
- bool hasConversionRule() const;
+ /// Returns the target type conversion rule
+ QString targetConversionRule() const;
QVersionNumber version() const;
/// TODO-CONVERTER: mark as deprecated
- bool hasNativeConversionRule() const;
-
- /// TODO-CONVERTER: mark as deprecated
bool hasTargetConversionRule() const;
bool isCppPrimitive() const;
diff --git a/sources/shiboken6/ApiExtractor/typesystemparser.cpp b/sources/shiboken6/ApiExtractor/typesystemparser.cpp
index 64bb7a8a4..e21b97602 100644
--- a/sources/shiboken6/ApiExtractor/typesystemparser.cpp
+++ b/sources/shiboken6/ApiExtractor/typesystemparser.cpp
@@ -48,9 +48,6 @@
#include <optional>
#include <memory>
-const char *TARGET_CONVERSION_RULE_FLAG = "0";
-const char *NATIVE_CONVERSION_RULE_FLAG = "1";
-
static inline QString allowThreadAttribute() { return QStringLiteral("allow-thread"); }
static inline QString colonColon() { return QStringLiteral("::"); }
static inline QString copyableAttribute() { return QStringLiteral("copyable"); }
@@ -1911,20 +1908,19 @@ bool TypeSystemParser::parseCustomConversion(const QXmlStreamReader &,
return true;
}
- if (topElement.entry->hasConversionRule() || topElement.entry->hasCustomConversion()) {
+ if (topElement.entry->hasTargetConversionRule() || topElement.entry->hasCustomConversion()) {
m_error = QLatin1String("Types can have only one conversion rule");
return false;
}
// The old conversion rule tag that uses a file containing the conversion
- // will be kept temporarily for compatibility reasons.
+ // will be kept temporarily for compatibility reasons. FIXME PYSIDE7: Remove
if (!sourceFile.isEmpty()) {
if (m_generate != TypeEntry::GenerateForSubclass
&& m_generate != TypeEntry::GenerateNothing) {
-
- const char* conversionFlag = NATIVE_CONVERSION_RULE_FLAG;
- if (lang == TypeSystem::TargetLangCode)
- conversionFlag = TARGET_CONVERSION_RULE_FLAG;
+ qWarning(lcShiboken, "Specifying conversion rules by \"file\" is deprecated.");
+ if (lang != TypeSystem::TargetLangCode)
+ return true;
QFile conversionSource(sourceFile);
if (!conversionSource.open(QIODevice::ReadOnly | QIODevice::Text)) {
@@ -1937,9 +1933,9 @@ bool TypeSystemParser::parseCustomConversion(const QXmlStreamReader &,
m_error = msgCannotFindSnippet(sourceFile, snippetLabel);
return false;
}
- topElement.entry->setConversionRule(QLatin1String(conversionFlag)
- + conversionRuleOptional.value());
+ topElement.entry->setTargetConversionRule(conversionRuleOptional.value());
}
+ return true;
}
auto *customConversion = new CustomConversion(m_current->entry);
diff --git a/sources/shiboken6/generator/shiboken/cppgenerator.cpp b/sources/shiboken6/generator/shiboken/cppgenerator.cpp
index 7989b008d..cb218ee8b 100644
--- a/sources/shiboken6/generator/shiboken/cppgenerator.cpp
+++ b/sources/shiboken6/generator/shiboken/cppgenerator.cpp
@@ -449,7 +449,7 @@ void CppGenerator::generateClass(TextStream &s, const GeneratorContext &classCon
// python conversion rules
if (metaClass->typeEntry()->hasTargetConversionRule()) {
s << "// Python Conversion\n";
- s << metaClass->typeEntry()->conversionRule() << '\n';
+ s << metaClass->typeEntry()->targetConversionRule() << '\n';
}
if (classContext.useWrapper()) {