aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorLauro Neto <lauro.neto@openbossa.org>2010-02-23 17:38:45 -0300
committerMarcelo Lira <marcelo.lira@openbossa.org>2010-02-23 20:59:47 -0300
commit32397a568e20d5b6860520cd45ff0833f27a8642 (patch)
treece133a45f25fecc93f5eb5c6b31ee4b7e8b5f767
parent506a97bad2ab5cf9b09f735a59f9dcea68bbd276 (diff)
Remove inplace operators of flags
Enums and flags are now treated as immutable types, so using a inplace operator will create a new flag object and attribute it to the name which the operator is called. flags = Qt.Window flags |= Qt.Dialog # This will create a new object and attribute # to flags This was done in order to prevent changing the original objects as the the inplace operator in line2 would modify the object pointed by Qt.Window. Reviewed by Marcelo Lira <marcelo.lira@openbossa.org>
-rw-r--r--cppgenerator.cpp28
-rw-r--r--cppgenerator.h2
2 files changed, 3 insertions, 27 deletions
diff --git a/cppgenerator.cpp b/cppgenerator.cpp
index ddf347581..7226f484e 100644
--- a/cppgenerator.cpp
+++ b/cppgenerator.cpp
@@ -2384,10 +2384,6 @@ void CppGenerator::writeFlagsMethods(QTextStream& s, const AbstractMetaEnum* cpp
writeFlagsBinaryOperator(s, cppEnum, "or", "|");
writeFlagsBinaryOperator(s, cppEnum, "xor", "^");
- writeFlagsInplaceOperator(s, cppEnum, "iand", "&=");
- writeFlagsInplaceOperator(s, cppEnum, "ior", "|=");
- writeFlagsInplaceOperator(s, cppEnum, "ixor", "^=");
-
writeFlagsUnaryOperator(s, cppEnum, "invert", "~");
writeFlagsUnaryOperator(s, cppEnum, "not", "!", true);
s << endl;
@@ -2429,9 +2425,9 @@ void CppGenerator::writeFlagsNumberMethodsDefinition(QTextStream& s, const Abstr
s << INDENT << "/*nb_inplace_power*/ 0," << endl;
s << INDENT << "/*nb_inplace_lshift*/ 0," << endl;
s << INDENT << "/*nb_inplace_rshift*/ 0," << endl;
- s << INDENT << "/*nb_inplace_and*/ (binaryfunc)" << cpythonName << "___iand__" << ',' << endl;
- s << INDENT << "/*nb_inplace_xor*/ (binaryfunc)" << cpythonName << "___ixor__" << ',' << endl;
- s << INDENT << "/*nb_inplace_or*/ (binaryfunc)" << cpythonName << "___ior__" << ',' << endl;
+ s << INDENT << "/*nb_inplace_and*/ 0," << endl;
+ s << INDENT << "/*nb_inplace_xor*/ 0," << endl;
+ s << INDENT << "/*nb_inplace_or*/ 0," << endl;
s << INDENT << "/*nb_floor_divide*/ 0," << endl;
s << INDENT << "/*nb_true_divide*/ 0," << endl;
s << INDENT << "/*nb_inplace_floor_divide*/ 0," << endl;
@@ -2525,24 +2521,6 @@ void CppGenerator::writeFlagsBinaryOperator(QTextStream& s, const AbstractMetaEn
s << '}' << endl << endl;
}
-void CppGenerator::writeFlagsInplaceOperator(QTextStream& s, const AbstractMetaEnum* cppEnum,
- QString pyOpName, QString cppOpName)
-{
- FlagsTypeEntry* flagsEntry = cppEnum->typeEntry()->flags();
- Q_ASSERT(flagsEntry);
-
- s << "PyObject*" << endl;
- s << cpythonEnumName(cppEnum) << "___" << pyOpName << "__(PyObject* self, PyObject* arg)" << endl;
- s << '{' << endl;
-
- s << INDENT << "((" << flagsEntry->originalName() << ") ((SbkEnumObject*)self)->ob_ival) " << cppOpName << endl;
- s << INDENT << "Shiboken::Converter< " << flagsEntry->originalName() << " >::toCpp(arg);" << endl;
-
- s << INDENT << "Py_INCREF(self);" << endl;
- s << INDENT << "return self;" << endl;
- s << '}' << endl << endl;
-}
-
void CppGenerator::writeFlagsUnaryOperator(QTextStream& s, const AbstractMetaEnum* cppEnum,
QString pyOpName, QString cppOpName, bool boolResult)
{
diff --git a/cppgenerator.h b/cppgenerator.h
index e11be7e8f..046d0c33a 100644
--- a/cppgenerator.h
+++ b/cppgenerator.h
@@ -143,8 +143,6 @@ private:
void writeFlagsNumberMethodsDefinition(QTextStream& s, const AbstractMetaEnum* cppEnum);
void writeFlagsBinaryOperator(QTextStream& s, const AbstractMetaEnum* cppEnum,
QString pyOpName, QString cppOpName);
- void writeFlagsInplaceOperator(QTextStream& s, const AbstractMetaEnum* cppEnum,
- QString pyOpName, QString cppOpName);
void writeFlagsUnaryOperator(QTextStream& s, const AbstractMetaEnum* cppEnum,
QString pyOpName, QString cppOpName, bool boolResult = false);