aboutsummaryrefslogtreecommitdiffstats
path: root/libshiboken
diff options
context:
space:
mode:
authorHugo Parente Lima <hugo.pl@gmail.com>2010-09-01 14:40:15 -0300
committerHugo Parente Lima <hugo.pl@gmail.com>2010-09-01 16:38:59 -0300
commit7d38f877d69fe44dbe7c36fb15cd477acccb4500 (patch)
tree6a5972b53afc68327047785937a3ed53cf67b79d /libshiboken
parent2a5ad3e48e5a148bc87bd6dbb74c695dd352a79a (diff)
Fix bug#316 - "QAbstractItemModel.createIndex is broken"
Use SbkNumber_Check instead of PyNumber_Check, because PyNumber_Check returns true for all user types. This commit also disable the generation of _Check macros and replaces all entries with Converter<T>::checkType. Those changes are on the same commit because SbkNumber_Check conflicts with a macro generated by "other" binding which binds a type named "Number". Reviewer: Luciano Wolf <luciano.wolf@openbossa.org> Renato Araújo <renato.filho@openbossa.org>
Diffstat (limited to 'libshiboken')
-rw-r--r--libshiboken/conversions.h8
1 files changed, 5 insertions, 3 deletions
diff --git a/libshiboken/conversions.h b/libshiboken/conversions.h
index 8caa56c84..1806d63a9 100644
--- a/libshiboken/conversions.h
+++ b/libshiboken/conversions.h
@@ -50,6 +50,8 @@
#define PyObject_Check(X) true
#include "autodecref.h"
+#define SbkNumber_Check(X) (PyInt_Check(X) || PyFloat_Check(X) || PyLong_Check(X))
+
namespace Shiboken
{
/**
@@ -380,7 +382,7 @@ template <typename PyIntEquiv>
struct Converter_PyInt
{
static inline bool checkType(PyObject* pyobj) { return PyInt_Check(pyobj); }
- static inline bool isConvertible(PyObject* pyobj) { return PyNumber_Check(pyobj); }
+ static inline bool isConvertible(PyObject* pyobj) { return SbkNumber_Check(pyobj); }
static inline PyObject* toPython(void* cppobj) { return toPython(*reinterpret_cast<PyIntEquiv*>(cppobj)); }
static inline PyObject* toPython(const PyIntEquiv& cppobj) { return PyInt_FromLong((long) cppobj); }
static PyIntEquiv toCpp(PyObject* pyobj)
@@ -409,7 +411,7 @@ struct Converter_PyULongInt : Converter_PyInt<T>
/// Check if we can treat the pyobj as a char, i.e. it's a number or a string with just one character.
-#define SbkChar_Check(pyobj) (PyNumber_Check(pyobj) || (PyString_Check(pyobj) && PyString_Size(pyobj) == 1))
+#define SbkChar_Check(pyobj) (SbkNumber_Check(pyobj) || (PyString_Check(pyobj) && PyString_Size(pyobj) == 1))
/// Specialization to convert char and unsigned char, it accepts Python numbers and strings with just one character.
template <typename CharType>
@@ -478,7 +480,7 @@ template <typename PyFloatEquiv>
struct Converter_PyFloat
{
static inline bool checkType(PyObject* obj) { return PyFloat_Check(obj); }
- static inline bool isConvertible(PyObject* obj) { return PyNumber_Check(obj); }
+ static inline bool isConvertible(PyObject* obj) { return SbkNumber_Check(obj); }
static inline PyObject* toPython(void* cppobj) { return toPython(*reinterpret_cast<PyFloatEquiv*>(cppobj)); }
static inline PyObject* toPython(PyFloatEquiv cppobj) { return PyFloat_FromDouble((double) cppobj); }
static inline PyFloatEquiv toCpp(PyObject* pyobj)