diff options
author | Marcelo Lira <marcelo.lira@openbossa.org> | 2011-07-29 04:46:18 -0300 |
---|---|---|
committer | Hugo Parente Lima <hugo.pl@gmail.com> | 2012-03-08 16:17:06 -0300 |
commit | 808c7b33fe6aafc81c58ec4850c0e30dcfbd91e9 (patch) | |
tree | 5e263282be3a5a624cb75aa5956de9f1d28145d8 /generator/cppgenerator.h | |
parent | 3c39aa5f2e05ad34e67f07b2f7262f419f9ce3b6 (diff) |
Added the ErrorCode helper class to handle the current error code value.
Reviewed by Hugo Parente <hugo.lima@openbossa.org>
Reviewed by Renato Araújo <renato.filho@openbossa.org>
Diffstat (limited to 'generator/cppgenerator.h')
-rw-r--r-- | generator/cppgenerator.h | 19 |
1 files changed, 15 insertions, 4 deletions
diff --git a/generator/cppgenerator.h b/generator/cppgenerator.h index 8f8509030..9ab2fbab5 100644 --- a/generator/cppgenerator.h +++ b/generator/cppgenerator.h @@ -61,8 +61,6 @@ private: /// Writes the check section for the validity of wrapped C++ objects. void writeInvalidPyObjectCheck(QTextStream& s, const QString& pyObj); - void writeInvalidPyObjectCheck(QTextStream& s, const QString& pyObj, int errorCode); - void writeInvalidPyObjectCheck(QTextStream& s, const QString& pyObj, QString returnValue); void writeTypeCheck(QTextStream& s, const AbstractMetaType* argType, QString argumentName, bool isNumber = false, QString customType = ""); void writeTypeCheck(QTextStream& s, const OverloadData* overloadData, QString argumentName); @@ -244,8 +242,21 @@ private: // Mapping protocol structure members names. static QHash<QString, QString> m_mpFuncs; - int m_currentErrorCode; - + static int m_currentErrorCode; + + /// Helper class to set and restore the current error code. + class ErrorCode { + public: + explicit ErrorCode(int errorCode) { + m_savedErrorCode = CppGenerator::m_currentErrorCode; + CppGenerator::m_currentErrorCode = errorCode; + } + ~ErrorCode() { + CppGenerator::m_currentErrorCode = m_savedErrorCode; + } + private: + int m_savedErrorCode; + }; }; #endif // CPPGENERATOR_H |