aboutsummaryrefslogtreecommitdiffstats
path: root/sources/shiboken2/ApiExtractor/typesystem.cpp
diff options
context:
space:
mode:
authorFriedemann Kleint <Friedemann.Kleint@qt.io>2018-11-23 12:17:10 +0100
committerAlexandru Croitor <alexandru.croitor@qt.io>2018-11-28 11:44:47 +0000
commitaddfdfb1ff195e36d412dc7aa3dde2f2d474c0ed (patch)
tree8ad1dc69e459d304f2cc264ac69b90e408aaeb28 /sources/shiboken2/ApiExtractor/typesystem.cpp
parentfce66005075ed04c99a313c243402d7bef2028ca (diff)
shiboken: Add file snippet handling to native-to-target and add-conversion
Task-number: PYSIDE-834 Change-Id: I3daad497ed32a56c05c8dc2b06271e243d579b99 Reviewed-by: Cristian Maureira-Fredes <cristian.maureira-fredes@qt.io>
Diffstat (limited to 'sources/shiboken2/ApiExtractor/typesystem.cpp')
-rw-r--r--sources/shiboken2/ApiExtractor/typesystem.cpp25
1 files changed, 20 insertions, 5 deletions
diff --git a/sources/shiboken2/ApiExtractor/typesystem.cpp b/sources/shiboken2/ApiExtractor/typesystem.cpp
index aa4147d76..e82221a40 100644
--- a/sources/shiboken2/ApiExtractor/typesystem.cpp
+++ b/sources/shiboken2/ApiExtractor/typesystem.cpp
@@ -1632,6 +1632,21 @@ bool Handler::parseCustomConversion(const QXmlStreamReader &,
return true;
}
+bool Handler::parseNativeToTarget(const QXmlStreamReader &,
+ const StackElement &topElement,
+ QXmlStreamAttributes *attributes)
+{
+ if (topElement.type != StackElement::ConversionRule) {
+ m_error = QLatin1String("Native to Target conversion code can only be specified for custom conversion rules.");
+ return false;
+ }
+ CodeSnip snip;
+ if (!readFileSnippet(attributes, &snip))
+ return false;
+ m_contextStack.top()->codeSnips.append(snip);
+ return true;
+}
+
bool Handler::parseAddConversion(const QXmlStreamReader &,
const StackElement &topElement,
QXmlStreamAttributes *attributes)
@@ -1642,6 +1657,9 @@ bool Handler::parseAddConversion(const QXmlStreamReader &,
}
QString sourceTypeName;
QString typeCheck;
+ CodeSnip snip;
+ if (!readFileSnippet(attributes, &snip))
+ return false;
for (int i = attributes->size() - 1; i >= 0; --i) {
const QStringRef name = attributes->at(i).qualifiedName();
if (name == QLatin1String("type"))
@@ -1654,7 +1672,7 @@ bool Handler::parseAddConversion(const QXmlStreamReader &,
return false;
}
m_current->entry->customConversion()->addTargetToNativeConversion(sourceTypeName, typeCheck);
- m_contextStack.top()->codeSnips << CodeSnip();
+ m_contextStack.top()->codeSnips.append(snip);
return true;
}
@@ -2670,11 +2688,8 @@ bool Handler::startElement(const QXmlStreamReader &reader)
return false;
break;
case StackElement::NativeToTarget:
- if (topElement.type != StackElement::ConversionRule) {
- m_error = QLatin1String("Native to Target conversion code can only be specified for custom conversion rules.");
+ if (!parseNativeToTarget(reader, topElement, &attributes))
return false;
- }
- m_contextStack.top()->codeSnips << CodeSnip();
break;
case StackElement::TargetToNative: {
if (topElement.type != StackElement::ConversionRule) {