summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMarcelo Lira <marcelo.lira@openbossa.org>2009-11-26 09:21:14 -0300
committerMarcelo Lira <marcelo.lira@openbossa.org>2009-11-26 09:21:14 -0300
commit517d1c914879bcf243442aac4b393e8ee3c26ff9 (patch)
tree6bcd1d384addc06a2e19d104a18fb15341eb2a2e
parentffbb8bb1df621ab3f31f859e62d21e06f9ed8a80 (diff)
downloadshiboken-517d1c914879bcf243442aac4b393e8ee3c26ff9.tar.gz
shiboken-517d1c914879bcf243442aac4b393e8ee3c26ff9.tar.xz
shiboken-517d1c914879bcf243442aac4b393e8ee3c26ff9.zip
Renamed Shiboken's function cppObjectIsValid to cppObjectIsInvalid.
CppGenerator::writeInvalidCppObjectCheck receives the name of the PyObject to be checked and do not set the exception message anymore, since it is done by Shiboken::cppObjectIsInvalid.
-rw-r--r--cppgenerator.cpp7
-rw-r--r--cppgenerator.h2
-rw-r--r--libshiboken/basewrapper.cpp10
-rw-r--r--libshiboken/basewrapper.h11
4 files changed, 17 insertions, 13 deletions
diff --git a/cppgenerator.cpp b/cppgenerator.cpp
index 6ffbfe99..425f4f50 100644
--- a/cppgenerator.cpp
+++ b/cppgenerator.cpp
@@ -674,15 +674,14 @@ void CppGenerator::writeErrorSection(QTextStream& s, OverloadData& overloadData)
s << INDENT << "return 0;" << endl;
}
-void CppGenerator::writeInvalidCppObjectCheck(QTextStream& s)
+void CppGenerator::writeInvalidCppObjectCheck(QTextStream& s, QString pyArgName)
{
- s << INDENT << "if (!Shiboken::cppObjectIsValid((Shiboken::PyBaseWrapper*)self)) {" << endl;
+ s << INDENT << "if (Shiboken::cppObjectIsInvalid(" << pyArgName << "))" << endl;
{
Indentation indent(INDENT);
- s << INDENT << "PyErr_SetString(PyExc_RuntimeError, \"underlying C++ object was deleted.\");" << endl;
s << INDENT << "return 0;" << endl;
}
- s << INDENT << '}' << endl;
+ s << endl;
}
void CppGenerator::writeTypeCheck(QTextStream& s, const OverloadData* overloadData, QString argumentName)
diff --git a/cppgenerator.h b/cppgenerator.h
index a0e001f2..63935341 100644
--- a/cppgenerator.h
+++ b/cppgenerator.h
@@ -55,7 +55,7 @@ private:
void writeErrorSection(QTextStream& s, OverloadData& overloadData);
/// Writes the check section for the validity of wrapped C++ objects.
- void writeInvalidCppObjectCheck(QTextStream& s);
+ void writeInvalidCppObjectCheck(QTextStream& s, QString pyArgName = "self");
void writeTypeCheck(QTextStream& s, const OverloadData* overloadData, QString argumentName);
void writeTypeConverterImpl(QTextStream& s, const TypeEntry* type);
diff --git a/libshiboken/basewrapper.cpp b/libshiboken/basewrapper.cpp
index b0bb3d73..5aa042cb 100644
--- a/libshiboken/basewrapper.cpp
+++ b/libshiboken/basewrapper.cpp
@@ -62,6 +62,15 @@ PyBaseWrapper_New(PyTypeObject* instanceType, ShiboTypeObject* baseWrapperType,
return self;
}
+bool
+cppObjectIsInvalid(PyObject* wrapper)
+{
+ if (((Shiboken::PyBaseWrapper*)wrapper)->validCppObject)
+ return false;
+ PyErr_SetString(PyExc_RuntimeError, "internal C++ object already deleted.");
+ return true;
+}
+
void
PyBaseWrapper_Dealloc_PrivateDtor(PyObject* self)
{
@@ -70,3 +79,4 @@ PyBaseWrapper_Dealloc_PrivateDtor(PyObject* self)
}
} // namespace Shiboken
+
diff --git a/libshiboken/basewrapper.h b/libshiboken/basewrapper.h
index a98b77e3..f891adb2 100644
--- a/libshiboken/basewrapper.h
+++ b/libshiboken/basewrapper.h
@@ -128,14 +128,8 @@ LIBSHIBOKEN_API PyAPI_FUNC(PyObject*)
PyBaseWrapper_New(PyTypeObject* instanceType, ShiboTypeObject* baseWrapperType,
const void *cptr, unsigned int hasOwnership = 1);
-inline bool
-cppObjectIsValid(PyBaseWrapper* self)
-{
- if (self->validCppObject)
- return true;
- PyErr_SetString(PyExc_RuntimeError, "internal C++ object already deleted.");
- return false;
-}
+/// Returns true and sets a Python RuntimeError if the Python wrapper is not marked as valid.
+LIBSHIBOKEN_API bool cppObjectIsInvalid(PyObject* wrapper);
template <typename T>
void PyBaseWrapper_Dealloc(PyObject* self)
@@ -151,3 +145,4 @@ LIBSHIBOKEN_API PyAPI_FUNC(void) PyBaseWrapper_Dealloc_PrivateDtor(PyObject* sel
} // namespace Shiboken
#endif // BASEWRAPPER_H
+