summaryrefslogtreecommitdiff
path: root/py/modules/IcePy/Util.h
diff options
context:
space:
mode:
Diffstat (limited to 'py/modules/IcePy/Util.h')
-rw-r--r--py/modules/IcePy/Util.h18
1 files changed, 16 insertions, 2 deletions
diff --git a/py/modules/IcePy/Util.h b/py/modules/IcePy/Util.h
index 5520c1f07d9..9670b134f84 100644
--- a/py/modules/IcePy/Util.h
+++ b/py/modules/IcePy/Util.h
@@ -23,8 +23,8 @@
// 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()
+#define PyRETURN_FALSE return incFalse()
+#define PyRETURN_TRUE return incTrue()
#define PyRETURN_BOOL(b) if(b) PyRETURN_TRUE; else PyRETURN_FALSE
@@ -49,6 +49,20 @@ inline PyObject* getTrue()
return reinterpret_cast<PyObject*>(i);
}
+inline PyObject* incFalse()
+{
+ PyObject* f = getFalse();
+ Py_INCREF(f);
+ return f;
+}
+
+inline PyObject* incTrue()
+{
+ PyObject* t = getTrue();
+ Py_INCREF(t);
+ return t;
+}
+
inline PyObject* createString(const std::string& str)
{
return PyString_FromStringAndSize(str.c_str(), static_cast<Py_ssize_t>(str.size()));