diff options
author | Marcelo Lira <marcelo.lira@openbossa.org> | 2011-01-28 17:51:05 -0300 |
---|---|---|
committer | Marcelo Lira <marcelo.lira@openbossa.org> | 2011-01-28 18:13:47 -0300 |
commit | 6674f8a265e882fbb1c381c9a7f8ed6e61807dc2 (patch) | |
tree | e63673502a0a4026598f7cddcda2de4952bd7889 | |
parent | a664eaa9fe791d5102f6089767e83acf3d5a5eba (diff) | |
download | shiboken-6674f8a265e882fbb1c381c9a7f8ed6e61807dc2.tar.gz shiboken-6674f8a265e882fbb1c381c9a7f8ed6e61807dc2.tar.xz shiboken-6674f8a265e882fbb1c381c9a7f8ed6e61807dc2.zip |
Added the "%CPPTYPE" type system variable.
%CPPTYPE will be converted to the original C++ name of a class,
without any "Wrapper" suffix or namespace prefix.
Documentation for the new variable was added as well.
Reviewed by Hugo Parente <hugo.lima@openbossa.org>
Reviewed by Luciano Wolf <luciano.wolf@openbossa.org>
-rw-r--r-- | doc/typesystemvariables.rst | 12 | ||||
-rw-r--r-- | generator/shibokengenerator.cpp | 4 |
2 files changed, 16 insertions, 0 deletions
diff --git a/doc/typesystemvariables.rst b/doc/typesystemvariables.rst index 9f31bce4..7e9beef6 100644 --- a/doc/typesystemvariables.rst +++ b/doc/typesystemvariables.rst @@ -143,6 +143,18 @@ Variables Replaced by the wrapped C++ object instance that owns the method in which the code with this variable was inserted. +.. _cpptype: + +**%CPPTYPE** + + Replaced by the original name of the C++ class, without any namespace prefix, + that owns the method in which the code with this variable was inserted. It will + work on class level code injections also. Notice that ``CPPTYPE`` differs from + the :ref:`%TYPE <type>` variable, for this latter may be translated to the original + C++ class name or to the C++ wrapper class name. + + Namespaces will are treated as classes, so ``CPPTYPE`` will work for them and their + enclosed functions as well. .. _function_name: diff --git a/generator/shibokengenerator.cpp b/generator/shibokengenerator.cpp index 72f396d0..387a8769 100644 --- a/generator/shibokengenerator.cpp +++ b/generator/shibokengenerator.cpp @@ -1145,6 +1145,7 @@ void ShibokenGenerator::writeCodeSnips(QTextStream& s, // class context in which the variable is used code.replace("%PYTHONTYPEOBJECT", cpythonTypeName(context) + ".super.ht_type"); code.replace("%TYPE", wrapperName(context)); + code.replace("%CPPTYPE", context->name()); } // replace "toPython "converters @@ -1325,6 +1326,9 @@ void ShibokenGenerator::writeCodeSnips(QTextStream& s, if (func->isConstructor() && shouldGenerateCppWrapper(func->ownerClass())) code.replace("%TYPE", wrapperName(func->ownerClass())); + if (func->ownerClass()) + code.replace("%CPPTYPE", func->ownerClass()->name()); + replaceTemplateVariables(code, func); } |