From 32397a568e20d5b6860520cd45ff0833f27a8642 Mon Sep 17 00:00:00 2001 From: Lauro Neto Date: Tue, 23 Feb 2010 17:38:45 -0300 Subject: 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 --- cppgenerator.cpp | 28 +++------------------------- cppgenerator.h | 2 -- 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); -- cgit v1.2.3