aboutsummaryrefslogtreecommitdiffstats
path: root/generator
diff options
context:
space:
mode:
authorRenato Filho <renato.filho@openbossa.org>2011-04-06 16:01:35 -0300
committerHugo Parente Lima <hugo.pl@gmail.com>2012-03-08 16:15:20 -0300
commit303f15a5bcbfc9625d3ac22ba61c5b2a57bd195c (patch)
tree5485a8c408f14c77ddc9e8bf2aed3d303960569e /generator
parent6ea5f0caa16f783d50221f817431d2cadc22f947 (diff)
Implement support to operator++;
Fixes bug #688. Reviewer: Marcelo Lira <marcelo.lira@openbossa.org> Luciano Wolf <luciano.wolf@openbossa.org>
Diffstat (limited to 'generator')
-rw-r--r--generator/cppgenerator.cpp8
-rw-r--r--generator/shibokengenerator.cpp2
2 files changed, 9 insertions, 1 deletions
diff --git a/generator/cppgenerator.cpp b/generator/cppgenerator.cpp
index cef8523be..7cb67253a 100644
--- a/generator/cppgenerator.cpp
+++ b/generator/cppgenerator.cpp
@@ -2091,7 +2091,13 @@ void CppGenerator::writeMethodCall(QTextStream& s, const AbstractMetaFunction* f
if (func->isBinaryOperator()) {
if (func->isReverseOperator())
std::swap(firstArg, secondArg);
- mc << firstArg << ' ' << op << ' ' << secondArg;
+
+ if (((op == "++") || (op == "--")) && !func->isReverseOperator()) {
+ s << endl << INDENT << "for(int i=0; i < " << secondArg << "; i++, " << firstArg << "++);" << endl;
+ mc << firstArg;
+ } else {
+ mc << firstArg << ' ' << op << ' ' << secondArg;
+ }
} else {
mc << op << ' ' << secondArg;
}
diff --git a/generator/shibokengenerator.cpp b/generator/shibokengenerator.cpp
index 43f4192d2..da48a8519 100644
--- a/generator/shibokengenerator.cpp
+++ b/generator/shibokengenerator.cpp
@@ -128,6 +128,8 @@ void ShibokenGenerator::initPrimitiveTypesCorrespondences()
// Inplace arithmetic operators
m_pythonOperators["operator+="] = "iadd";
m_pythonOperators["operator-="] = "isub";
+ m_pythonOperators["operator++"] = "iadd";
+ m_pythonOperators["operator--"] = "isub";
m_pythonOperators["operator*="] = "imul";
m_pythonOperators["operator/="] = "idiv";
m_pythonOperators["operator%="] = "imod";