summaryrefslogtreecommitdiff
path: root/py/modules/IcePy/Util.h
diff options
context:
space:
mode:
authorMark Spruiell <mes@zeroc.com>2007-04-18 17:19:06 +0000
committerMark Spruiell <mes@zeroc.com>2007-04-18 17:19:06 +0000
commit1129b050e2c513f1d0b87d5b29bae7699e35778b (patch)
tree2c1076967a445ce0e26948a03f283337ea80aab4 /py/modules/IcePy/Util.h
parentAdded nmake support for WinCE (diff)
downloadice-1129b050e2c513f1d0b87d5b29bae7699e35778b.tar.bz2
ice-1129b050e2c513f1d0b87d5b29bae7699e35778b.tar.xz
ice-1129b050e2c513f1d0b87d5b29bae7699e35778b.zip
bug 1493: removing use of NULL bug 1852: fixing compiler warnings bug 1853:
fixing compiler warnings bug 2098: change proxy factory methods to return object of same class
Diffstat (limited to 'py/modules/IcePy/Util.h')
-rw-r--r--py/modules/IcePy/Util.h28
1 files changed, 27 insertions, 1 deletions
diff --git a/py/modules/IcePy/Util.h b/py/modules/IcePy/Util.h
index 61056b40caa..ea246c1f461 100644
--- a/py/modules/IcePy/Util.h
+++ b/py/modules/IcePy/Util.h
@@ -18,17 +18,43 @@
#include <IceUtil/Monitor.h>
#include <IceUtil/Mutex.h>
+//
+// These macros replace Py_RETURN_FALSE and Py_RETURN TRUE. We use these
+// instead of the standard ones in order to avoid GCC warnings about
+// strict aliasing and type punning.
+//
+#define PyRETURN_FALSE return Py_INCREF(getFalse()), getFalse()
+#define PyRETURN_TRUE return Py_INCREF(getTrue()), getTrue()
+
namespace IcePy
{
//
+// This should be used instead of Py_False to avoid GCC compiler warnings.
+//
+inline PyObject* getFalse()
+{
+ PyIntObject* i = &_Py_ZeroStruct;
+ return reinterpret_cast<PyObject*>(i);
+}
+
+//
+// This should be used instead of Py_True to avoid GCC compiler warnings.
+//
+inline PyObject* getTrue()
+{
+ PyIntObject* i = &_Py_TrueStruct;
+ return reinterpret_cast<PyObject*>(i);
+}
+
+//
// Invokes Py_DECREF on a Python object.
//
class PyObjectHandle
{
public:
- PyObjectHandle(PyObject* = NULL);
+ PyObjectHandle(PyObject* = 0);
PyObjectHandle(const PyObjectHandle&);
~PyObjectHandle();