aboutsummaryrefslogtreecommitdiffstats
path: root/tests
diff options
context:
space:
mode:
authorHugo Lima <hugo.lima@openbossa.org>2009-10-26 19:43:43 -0200
committerHugo Lima <hugo.lima@openbossa.org>2009-10-27 11:37:26 -0200
commit46619953316a8bc7b5cfc5ac5536187658069273 (patch)
tree5313b0fd05e5a42e883aac5a0b9aaca7c5f145a8 /tests
parente7e527ad998fa9c2dbb7d8bf93d105e7b916e755 (diff)
Added Converter<T>::isConvertible to replace the T_Check functions.
This allow the user to full custommize the type conversion. Note: This change added a known regression on test_derived
Diffstat (limited to 'tests')
-rw-r--r--tests/samplebinding/complex_conversions.h4
-rw-r--r--tests/samplebinding/list_conversions.h5
-rw-r--r--tests/samplebinding/map_conversions.h5
-rw-r--r--tests/samplebinding/oddbool_conversions.h5
-rw-r--r--tests/samplebinding/pair_conversions.h4
5 files changed, 23 insertions, 0 deletions
diff --git a/tests/samplebinding/complex_conversions.h b/tests/samplebinding/complex_conversions.h
index 375c2f63e..bd1f2cd2a 100644
--- a/tests/samplebinding/complex_conversions.h
+++ b/tests/samplebinding/complex_conversions.h
@@ -1,6 +1,10 @@
template<>
struct Converter<Complex>
{
+ static bool isConvertible(const PyObject* pyObj)
+ {
+ return PyComplex_Check(pyObj);
+ }
static PyObject* toPython(Complex cpx)
{
/*
diff --git a/tests/samplebinding/list_conversions.h b/tests/samplebinding/list_conversions.h
index 024f24b6e..97c7912c7 100644
--- a/tests/samplebinding/list_conversions.h
+++ b/tests/samplebinding/list_conversions.h
@@ -1,6 +1,11 @@
template <typename StdList>
struct Converter_std_list
{
+ static bool isConvertible(const PyObject* pyObj)
+ {
+ return PySequence_Check(const_cast<PyObject*>(pyObj));
+ }
+
static PyObject* toPython(StdList holder)
{
PyObject* result = PyList_New((int) holder.size());
diff --git a/tests/samplebinding/map_conversions.h b/tests/samplebinding/map_conversions.h
index a85aa909e..bd1b80f14 100644
--- a/tests/samplebinding/map_conversions.h
+++ b/tests/samplebinding/map_conversions.h
@@ -1,6 +1,11 @@
template <typename StdMap>
struct Converter_std_map
{
+ static bool isConvertible(const PyObject* pyObj)
+ {
+ return PyDict_Check(const_cast<PyObject*>(pyObj));
+ }
+
static PyObject* toPython(StdMap holder)
{
PyObject* result = PyDict_New();
diff --git a/tests/samplebinding/oddbool_conversions.h b/tests/samplebinding/oddbool_conversions.h
index 2e3f26414..7507cb52b 100644
--- a/tests/samplebinding/oddbool_conversions.h
+++ b/tests/samplebinding/oddbool_conversions.h
@@ -1,6 +1,11 @@
template <>
struct Converter<OddBool>
{
+ static bool isConvertible(const PyObject* pyObj)
+ {
+ return PyBool_Check(pyObj);
+ }
+
static PyObject* toPython(OddBool holder)
{
return PyBool_FromLong(holder.value());
diff --git a/tests/samplebinding/pair_conversions.h b/tests/samplebinding/pair_conversions.h
index d5f1431ca..aae68d061 100644
--- a/tests/samplebinding/pair_conversions.h
+++ b/tests/samplebinding/pair_conversions.h
@@ -1,6 +1,10 @@
template <typename StdPair>
struct Converter_std_pair
{
+ static bool isConvertible(const PyObject* pyObj)
+ {
+ return PySequence_Check(const_cast<PyObject*>(pyObj));
+ }
static PyObject* toPython(StdPair holder)
{
typename StdPair::first_type first(holder.first);