aboutsummaryrefslogtreecommitdiffstats
path: root/tests/samplebinding/handle_conversions.h
diff options
context:
space:
mode:
authorHugo Parente Lima <hugo.pl@gmail.com>2011-09-16 14:27:32 -0300
committerHugo Parente Lima <hugo.pl@gmail.com>2012-03-08 16:17:15 -0300
commitfd5dd85d0d0dcc4faaf3a1ca5bd6a5df857f7844 (patch)
treecbbb5e773dc62b14e5e94e9c6217075ae6a2c41d /tests/samplebinding/handle_conversions.h
parent9785f258d93b4976872a17fbf61bd27a4c4123cd (diff)
Port libsample typesystem and glue codes to Python 3.
Diffstat (limited to 'tests/samplebinding/handle_conversions.h')
-rw-r--r--tests/samplebinding/handle_conversions.h13
1 files changed, 12 insertions, 1 deletions
diff --git a/tests/samplebinding/handle_conversions.h b/tests/samplebinding/handle_conversions.h
index 2c6008077..a6e561359 100644
--- a/tests/samplebinding/handle_conversions.h
+++ b/tests/samplebinding/handle_conversions.h
@@ -13,7 +13,11 @@ struct Converter<HANDLE>
static inline bool isConvertible(PyObject* pyObj)
{
+#ifdef IS_PY3K
+ return PyCapsule_CheckExact(pyObj);
+#else
return PyCObject_Check(pyObj);
+#endif
}
static inline PyObject* toPython(void* cppobj)
@@ -24,13 +28,20 @@ struct Converter<HANDLE>
static inline PyObject* toPython(HANDLE cppobj)
{
+#ifdef IS_PY3K
+ return PyCapsule_New(cppobj, 0, 0);
+#else
return PyCObject_FromVoidPtr(cppobj, 0);
+#endif
}
static inline HANDLE toCpp(PyObject* pyobj)
{
-
+#ifdef IS_PY3K
+ return (HANDLE) PyCapsule_GetPointer(pyobj, 0);
+#else
return (HANDLE) PyCObject_AsVoidPtr(pyobj);
+#endif
}
};
}