diff options
author | Marcelo Lira <marcelo.lira@openbossa.org> | 2009-12-01 10:15:42 -0300 |
---|---|---|
committer | Marcelo Lira <marcelo.lira@openbossa.org> | 2009-12-01 11:29:08 -0300 |
commit | f532dd366b70e39000e1431b9dc3ba805f29af57 (patch) | |
tree | 4edc1d00efa23e02ce8403bfeb2950c66af645d0 /libshiboken | |
parent | 106a1aceccb2ebac8b13e0b102ce4f015d9fee3d (diff) |
Converter's basic isConvertible and toCpp methods consider None as C++ NULL pointer.
Diffstat (limited to 'libshiboken')
-rw-r--r-- | libshiboken/conversions.h | 8 |
1 files changed, 6 insertions, 2 deletions
diff --git a/libshiboken/conversions.h b/libshiboken/conversions.h index 9cc166cf0..4ec04f510 100644 --- a/libshiboken/conversions.h +++ b/libshiboken/conversions.h @@ -55,7 +55,7 @@ struct ConverterBase { static PyObject* createWrapper(const T* cppobj) { return 0; } static T* copyCppObject(const T& cppobj) { return 0; } - static bool isConvertible(PyObject* pyobj) { return false; } + static bool isConvertible(PyObject* pyobj) { return pyobj == Py_None; } // Must be reimplemented. static PyObject* toPython(const T& cppobj); @@ -84,6 +84,8 @@ struct ConverterBase<T*> : ConverterBase<T> } static T* toCpp(PyObject* pyobj) { + if (pyobj == Py_None) + return 0; return (T*) ((Shiboken::PyBaseWrapper*) pyobj)->cptr; } }; @@ -106,7 +108,9 @@ struct Converter<T*> : Converter<T> } static T* toCpp(PyObject* pyobj) { - if (Converter<T>::isConvertible(pyobj)) + if (pyobj == Py_None) + return 0; + else if (Converter<T>::isConvertible(pyobj)) return Converter<T>::copyCppObject(Converter<T>::toCpp(pyobj)); return (T*) ((Shiboken::PyBaseWrapper*) pyobj)->cptr; } |