aboutsummaryrefslogtreecommitdiffstats
path: root/libshiboken
diff options
context:
space:
mode:
authorMarcelo Lira <marcelo.lira@openbossa.org>2010-01-28 15:53:40 -0300
committerHugo Lima <hugo.lima@openbossa.org>2010-01-28 19:04:58 -0200
commit6daffa0a3452ee36ca8c39cf90fb0cefcbb5c205 (patch)
tree12faa27dcb6251f9b5ddd9b5ad458c66b371cc96 /libshiboken
parent22eb430cecf6ddc10eed04dd67c81485aba84ab6 (diff)
Adds support for void pointer conversions.
A new converter specialization was added to deal with 'void*' conversions. In the case of C++ generating a unknown void pointer a BaseWrapper is used to hold the said pointer. There is a new test for this situation. Reviewed by Renato Araújo <renato.filho@openbossa.org>
Diffstat (limited to 'libshiboken')
-rw-r--r--libshiboken/conversions.h24
1 files changed, 24 insertions, 0 deletions
diff --git a/libshiboken/conversions.h b/libshiboken/conversions.h
index cd94ffc66..0cb163441 100644
--- a/libshiboken/conversions.h
+++ b/libshiboken/conversions.h
@@ -191,6 +191,30 @@ struct Converter<T&> : Converter<T*>
};
template <typename T> struct Converter<const T&> : Converter<T&> {};
+// Void pointer conversions
+template<>
+struct Converter<void*>
+{
+ static inline bool isConvertible(PyObject* pyobj) { return false; }
+ static PyObject* toPython(const void* cppobj)
+ {
+ PyObject* pyobj = BindingManager::instance().retrieveWrapper(cppobj);
+ if (pyobj)
+ Py_INCREF(pyobj);
+ else
+ pyobj = SbkBaseWrapper_New(&SbkBaseWrapper_Type, cppobj, false, false);
+ return pyobj;
+ }
+ static void* toCpp(PyObject* pyobj)
+ {
+ if (pyobj == Py_None)
+ return 0;
+ return SbkBaseWrapper_cptr(pyobj);
+ }
+};
+template <> struct Converter<const void*> : Converter<void*> {};
+
+
// Primitive Conversions ------------------------------------------------------
template <>
struct Converter<bool>