diff options
author | Marcelo Lira <marcelo.lira@openbossa.org> | 2011-06-15 16:08:00 -0300 |
---|---|---|
committer | Hugo Parente Lima <hugo.pl@gmail.com> | 2012-03-08 16:15:26 -0300 |
commit | 45a008604122af4e4ff4e7db440d9e65be3093fc (patch) | |
tree | d408e2a099208eff155b46e833cfbd8ba07078e2 | |
parent | 76c2be48edf50c573d1da94879d02c1b97f8c501 (diff) |
Added two new type system variables: %ISCONVERTIBLE and %CHECKTYPE.
Currently the variables are replaced as follows:
* %ISCONVERTIBLE[CPPTYPE] -> Shiboken::Converter<CPPTYPE>::isConvertible
* %CHECKTYPE[CPPTYPE] -> Shiboken::Converter<CPPTYPE>::checkType
Future improvements may change that, so having these variables is
a good thing.
The documentation was updated.
Reviewed by Luciano Wolf <luciano.wolf@openbossa.org>
Reviewed by Renato Araujo <renato.filho@openbossa.org>
-rw-r--r-- | doc/typesystemvariables.rst | 17 | ||||
-rw-r--r-- | generator/shibokengenerator.cpp | 12 |
2 files changed, 27 insertions, 2 deletions
diff --git a/doc/typesystemvariables.rst b/doc/typesystemvariables.rst index 307cb8ca5..205430550 100644 --- a/doc/typesystemvariables.rst +++ b/doc/typesystemvariables.rst @@ -136,6 +136,23 @@ Variables type indicated by ``CPPTYPE`` to the proper Python object. +.. _isconvertible: + +**%ISCONVERTIBLE[CPPTYPE]** + + Replaced by a |project| "isConvertible" call that checks if a Python + variable is convertible (via an implicit conversion or cast operator call) + to a C++ variable of the type indicated by ``CPPTYPE``. + + +.. _checktype: + +**%CHECKTYPE[CPPTYPE]** + + Replaced by a |project| "checkType" call that verifies if a Python + if of the type indicated by ``CPPTYPE``. + + .. _cppself: **%CPPSELF** diff --git a/generator/shibokengenerator.cpp b/generator/shibokengenerator.cpp index 73383335c..1f405bbc1 100644 --- a/generator/shibokengenerator.cpp +++ b/generator/shibokengenerator.cpp @@ -1140,6 +1140,8 @@ void ShibokenGenerator::writeCodeSnips(QTextStream& s, { static QRegExp toPythonRegex("%CONVERTTOPYTHON\\[([^\\[]*)\\]"); static QRegExp toCppRegex("%CONVERTTOCPP\\[([^\\[]*)\\]"); + static QRegExp isConvertibleRegex("%ISCONVERTIBLE\\[([^\\[]*)\\]"); + static QRegExp checkTypeRegex("%CHECKTYPE\\[([^\\[]*)\\]"); static QRegExp pyArgsRegex("%PYARG_(\\d+)"); // detect is we should use pyargs instead of args as variable name for python arguments @@ -1170,12 +1172,18 @@ void ShibokenGenerator::writeCodeSnips(QTextStream& s, code.replace("%CPPTYPE", context->name()); } - // replace "toPython "converters + // replace "toPython" converters code.replace(toPythonRegex, "Shiboken::Converter<\\1 >::toPython"); - // replace "toCpp "converters + // replace "toCpp" converters code.replace(toCppRegex, "Shiboken::Converter<\\1 >::toCpp"); + // replace "isConvertible" check + code.replace(isConvertibleRegex, "Shiboken::Converter<\\1 >::isConvertible"); + + // replace "checkType" check + code.replace(checkTypeRegex, "Shiboken::Converter<\\1 >::checkType"); + if (func) { // replace %PYARG_# variables code.replace("%PYARG_0", PYTHON_RETURN_VAR); |