aboutsummaryrefslogtreecommitdiffstats
path: root/generator/cppgenerator.cpp
diff options
context:
space:
mode:
authorMarcelo Lira <marcelo.lira@openbossa.org>2011-08-05 13:55:56 -0300
committerHugo Parente Lima <hugo.pl@gmail.com>2012-03-08 16:17:08 -0300
commit50aef1dd4836b5019c60d31c54501ebcd37f72cd (patch)
tree3e9f41435c3ee0da5fdb5ee32b5b9900ad5a5259 /generator/cppgenerator.cpp
parent08f29f0d8f456eb1f994b05c21fd04468c95329c (diff)
Improved guessCPythonCheckFunction method to produce an AbstractMetaType for known types.
This is in opposition of simply returning a string with a custom type check. The details are in the docstring in ShibokenGenerator header. Also added a new modification test and refactored here and there in the sample binding type system.
Diffstat (limited to 'generator/cppgenerator.cpp')
-rw-r--r--generator/cppgenerator.cpp19
1 files changed, 14 insertions, 5 deletions
diff --git a/generator/cppgenerator.cpp b/generator/cppgenerator.cpp
index 9e8007f6d..687a24499 100644
--- a/generator/cppgenerator.cpp
+++ b/generator/cppgenerator.cpp
@@ -1471,12 +1471,21 @@ void CppGenerator::writeInvalidPyObjectCheck(QTextStream& s, const QString& pyOb
void CppGenerator::writeTypeCheck(QTextStream& s, const AbstractMetaType* argType, QString argumentName, bool isNumber, QString customType)
{
- if (!customType.isEmpty())
- s << guessCPythonCheckFunction(customType);
- else if (argType->isEnum())
- s << cpythonIsConvertibleFunction(argType, false);
+ AbstractMetaType* metaType;
+ std::auto_ptr<AbstractMetaType> metaType_autoptr;
+ QString customCheck;
+ if (!customType.isEmpty()) {
+ customCheck = guessCPythonCheckFunction(customType, &metaType);
+ if (metaType) {
+ metaType_autoptr = std::auto_ptr<AbstractMetaType>(metaType);
+ argType = metaType;
+ }
+ }
+
+ if (customCheck.isEmpty())
+ s << cpythonIsConvertibleFunction(argType, argType->isEnum() ? false : isNumber);
else
- s << cpythonIsConvertibleFunction(argType, isNumber);
+ s << customCheck;
s << '(' << argumentName << ')';
}