diff options
author | Marcelo Lira <marcelo.lira@openbossa.org> | 2011-12-11 23:13:29 -0300 |
---|---|---|
committer | Hugo Parente Lima <hugo.pl@gmail.com> | 2012-03-08 16:18:34 -0300 |
commit | bebb9009a1f400fae548ba2a6e0553fc2643c6e2 (patch) | |
tree | 26f49d5e702af121b838b533275c99b20a2c0e4e /tests/samplebinding | |
parent | fb37b84fa723af8fa911910932090b6569589e0f (diff) |
Removed the last pieces of code generation that uses the old template Converters.
Diffstat (limited to 'tests/samplebinding')
-rw-r--r-- | tests/samplebinding/bytearray_conversions.h | 36 | ||||
-rw-r--r-- | tests/samplebinding/complex_conversions.h | 32 | ||||
-rw-r--r-- | tests/samplebinding/date_conversions.h | 35 | ||||
-rw-r--r-- | tests/samplebinding/list_conversions.h | 4 | ||||
-rw-r--r-- | tests/samplebinding/map_conversions.h | 4 | ||||
-rw-r--r-- | tests/samplebinding/null_conversions.h | 32 | ||||
-rw-r--r-- | tests/samplebinding/oddbool_conversions.h | 21 | ||||
-rw-r--r-- | tests/samplebinding/pair_conversions.h | 4 | ||||
-rw-r--r-- | tests/samplebinding/primitivestructpointer_conversions.h | 44 | ||||
-rw-r--r-- | tests/samplebinding/typesystem_sample.xml | 18 |
10 files changed, 9 insertions, 221 deletions
diff --git a/tests/samplebinding/bytearray_conversions.h b/tests/samplebinding/bytearray_conversions.h deleted file mode 100644 index 0fd9a2b7d..000000000 --- a/tests/samplebinding/bytearray_conversions.h +++ /dev/null @@ -1,36 +0,0 @@ -namespace Shiboken { -inline bool Converter<ByteArray>::checkType(PyObject* pyObj) -{ - return ValueTypeConverter<ByteArray>::checkType(pyObj); -} -inline bool Converter<ByteArray>::isConvertible(PyObject* pyObj) -{ - if (ValueTypeConverter<ByteArray>::isConvertible(pyObj)) - return true; - SbkObjectType* shiboType = reinterpret_cast<SbkObjectType*>(SbkType<ByteArray>()); - - return Shiboken::Converter<const char*>::isConvertible(pyObj) - || PyBytes_Check(pyObj) - || (ObjectType::isExternalConvertible(shiboType, pyObj)); -} -inline ByteArray Converter<ByteArray>::toCpp(PyObject* pyObj) -{ - if (pyObj == Py_None) { - return ByteArray(); - } else if (PyObject_TypeCheck(pyObj, SbkType<ByteArray>())) { - return *Converter<ByteArray*>::toCpp(pyObj); - } else if (PyBytes_Check(pyObj)) { - return ByteArray(PyBytes_AS_STRING(pyObj), PyBytes_GET_SIZE(pyObj)); - } else if (PyUnicode_Check(pyObj)) { - Shiboken::AutoDecRef data(PyUnicode_AsASCIIString(pyObj)); - return ByteArray(PyBytes_AsString(data.object()), PyBytes_GET_SIZE(data.object())); - } else if (Shiboken::String::check(pyObj)) { - return ByteArray(Shiboken::String::toCString(pyObj)); - } - return ValueTypeConverter<ByteArray>::toCpp(pyObj); -} -inline PyObject* Converter<ByteArray>::toPython(const ByteArray& cppObj) -{ - return ValueTypeConverter<ByteArray>::toPython(cppObj); -} -} diff --git a/tests/samplebinding/complex_conversions.h b/tests/samplebinding/complex_conversions.h deleted file mode 100644 index 0e5e2cfaf..000000000 --- a/tests/samplebinding/complex_conversions.h +++ /dev/null @@ -1,32 +0,0 @@ -namespace Shiboken { -template<> -struct Converter<Complex> -{ - static inline bool checkType(PyObject* pyObj) - { - return PyComplex_Check(pyObj); - } - - static inline bool isConvertible(PyObject* pyObj) - { - return PyComplex_Check(pyObj); - } - - static inline PyObject* toPython(void* cppobj) - { - return toPython(*reinterpret_cast<Complex*>(cppobj)); - } - - static inline PyObject* toPython(const Complex& cpx) - { - return PyComplex_FromDoubles(cpx.real(), cpx.imag()); - } - - static inline Complex toCpp(PyObject* pyobj) - { - double real = PyComplex_RealAsDouble(pyobj); - double imag = PyComplex_ImagAsDouble(pyobj); - return Complex(real, imag); - } -}; -} diff --git a/tests/samplebinding/date_conversions.h b/tests/samplebinding/date_conversions.h deleted file mode 100644 index ef459114a..000000000 --- a/tests/samplebinding/date_conversions.h +++ /dev/null @@ -1,35 +0,0 @@ -namespace Shiboken { -template <> -struct PythonConverter<SbkDate> -{ - static bool isPythonConvertible(PyObject* pyObj) - { - if (!PyDateTimeAPI) - PyDateTime_IMPORT; - - return PyDate_Check(pyObj); - } - - static SbkDate* transformFromPython(PyObject* obj) - { - if (isPythonConvertible(obj)) { - int day = PyDateTime_GET_DAY(obj); - int month = PyDateTime_GET_MONTH(obj); - int year = PyDateTime_GET_YEAR(obj); - return new SbkDate(day, month, year); - } - return 0; - } - - static PyObject* transformToPython(SbkDate* d) - { - if (d) { - if (!PyDateTimeAPI) - PyDateTime_IMPORT; - - return PyDate_FromDate(d->day(), d->month(), d->year()); - } - return 0; - } -}; -} diff --git a/tests/samplebinding/list_conversions.h b/tests/samplebinding/list_conversions.h deleted file mode 100644 index 6ed8d9647..000000000 --- a/tests/samplebinding/list_conversions.h +++ /dev/null @@ -1,4 +0,0 @@ -namespace Shiboken { -template<typename T> -struct Converter<std::list<T> > : StdListConverter<std::list<T> > {}; -} diff --git a/tests/samplebinding/map_conversions.h b/tests/samplebinding/map_conversions.h deleted file mode 100644 index 005b40ed1..000000000 --- a/tests/samplebinding/map_conversions.h +++ /dev/null @@ -1,4 +0,0 @@ -namespace Shiboken { -template<typename KT, typename VT> -struct Converter<std::map<KT, VT> > : StdMapConverter<std::map<KT, VT> > {}; -} diff --git a/tests/samplebinding/null_conversions.h b/tests/samplebinding/null_conversions.h deleted file mode 100644 index cbe159f85..000000000 --- a/tests/samplebinding/null_conversions.h +++ /dev/null @@ -1,32 +0,0 @@ -namespace Shiboken { -template<> -struct Converter<Null> -{ - static inline bool checkType(PyObject* pyObj) - { - return false; - } - - static inline bool isConvertible(PyObject* pyObj) - { - if (pyObj == 0 || pyObj == Py_None) - return true; - return false; - } - - static inline PyObject* toPython(void* cppobj) - { - Py_RETURN_NONE; - } - - static inline PyObject* toPython(const Null& cpx) - { - Py_RETURN_NONE; - } - - static inline Null toCpp(PyObject* pyobj) - { - return Null(pyobj == 0); - } -}; -} diff --git a/tests/samplebinding/oddbool_conversions.h b/tests/samplebinding/oddbool_conversions.h deleted file mode 100644 index 74ecef24d..000000000 --- a/tests/samplebinding/oddbool_conversions.h +++ /dev/null @@ -1,21 +0,0 @@ -namespace Shiboken { -template <> -struct Converter<OddBool> : public ValueTypeConverter<OddBool> -{ - static bool isConvertible(PyObject* pyObj) - { - return PyBool_Check(pyObj); - } - - using ValueTypeConverter<OddBool>::toPython; - - static PyObject* toPython(const OddBool& holder) - { - return PyBool_FromLong(holder.value()); - } - static OddBool toCpp(PyObject* pyobj) - { - return OddBool(pyobj == Py_True); - } -}; -} diff --git a/tests/samplebinding/pair_conversions.h b/tests/samplebinding/pair_conversions.h deleted file mode 100644 index 47e46d416..000000000 --- a/tests/samplebinding/pair_conversions.h +++ /dev/null @@ -1,4 +0,0 @@ -namespace Shiboken { -template<typename FT, typename ST> -struct Converter<std::pair<FT, ST> > : StdPairConverter<std::pair<FT, ST> > {}; -} diff --git a/tests/samplebinding/primitivestructpointer_conversions.h b/tests/samplebinding/primitivestructpointer_conversions.h deleted file mode 100644 index c674215f3..000000000 --- a/tests/samplebinding/primitivestructpointer_conversions.h +++ /dev/null @@ -1,44 +0,0 @@ -namespace Shiboken { -template <> -struct Converter<PrimitiveStructPtr> -{ - static bool checkType(PyObject* pyObj) - { - return false; - } - - static bool isConvertible(PyObject* pyobj) - { -#ifdef IS_PY3K - return PyCapsule_CheckExact(pyobj); -#else - return PyCObject_Check(pyobj); -#endif - } - - static inline PyObject* toPython(void* cppobj) - { - return 0; - } - - static PyObject* toPython(PrimitiveStructPtr cppobj) - { -#ifdef IS_PY3K - return PyCapsule_New(cppobj, 0, 0); -#else - return PyCObject_FromVoidPtr(cppobj, 0); -#endif - } - - static PrimitiveStructPtr toCpp(PyObject* pyobj) - { - void* ptr; -#ifdef IS_PY3K - ptr = PyCapsule_GetPointer(pyobj, 0); -#else - ptr = PyCObject_AsVoidPtr(pyobj); -#endif - return (PrimitiveStructPtr) ptr; - } -}; -} diff --git a/tests/samplebinding/typesystem_sample.xml b/tests/samplebinding/typesystem_sample.xml index d3ae3e4d1..c5ac460e6 100644 --- a/tests/samplebinding/typesystem_sample.xml +++ b/tests/samplebinding/typesystem_sample.xml @@ -33,7 +33,7 @@ <primitive-type name="Complex" target-lang-api-name="PyComplex"> <include file-name="complex.h" location="global"/> - <conversion-rule file="complex_conversions.h"> + <conversion-rule> <native-to-target> return PyComplex_FromDoubles(%in.real(), %in.imag()); </native-to-target> @@ -51,7 +51,7 @@ <primitive-type name="Null"> <include file-name="null.h" location="global"/> - <conversion-rule file="null_conversions.h"> + <conversion-rule> <native-to-target> SBK_UNUSED(%in); Py_RETURN_NONE; @@ -106,7 +106,7 @@ <primitive-type name="PrimitiveStructPtr"> <include file-name="handle.h" location="local"/> - <conversion-rule file="primitivestructpointer_conversions.h"> + <conversion-rule> <native-to-target> #ifdef IS_PY3K return PyCapsule_New(&%in, 0, 0); @@ -131,7 +131,7 @@ <primitive-type name="OddBool" target-lang-api-name="PyBool" default-constructor="OddBool(false)"> <include file-name="oddbool.h" location="global"/> <include file-name="complex.h" location="global"/> - <conversion-rule file="oddbool_conversions.h"> + <conversion-rule> <native-to-target> return PyBool_FromLong(%in.value()); </native-to-target> @@ -348,7 +348,7 @@ <container-type name="std::pair" type="pair"> <include file-name="utility" location="global"/> - <conversion-rule file="pair_conversions.h"> + <conversion-rule> <native-to-target> PyObject* %out = PyTuple_New(2); PyTuple_SET_ITEM(%out, 0, %CONVERTTOPYTHON[%INTYPE_0](%in.first)); @@ -382,7 +382,7 @@ </template> <container-type name="std::list" type="list"> <include file-name="list" location="global"/> - <conversion-rule file="list_conversions.h"> + <conversion-rule> <native-to-target> <insert-template name="cpplist_to_pylist_convertion"/> </native-to-target> @@ -408,7 +408,7 @@ </container-type> <container-type name="std::map" type="map"> <include file-name="map" location="global"/> - <conversion-rule file="map_conversions.h"> + <conversion-rule> <native-to-target> PyObject* %out = PyDict_New(); %INTYPE::const_iterator it = %in.begin(); @@ -1956,7 +1956,7 @@ </value-type> <value-type name="ByteArray" hash-function="ByteArray::hash"> - <conversion-rule file="bytearray_conversions.h"> + <conversion-rule> <target-to-native> <add-conversion type="Py_None"> %out = %OUTTYPE(); @@ -2217,7 +2217,7 @@ return PyDate_Check(pyIn); } </inject-code> - <conversion-rule class="target" file="date_conversions.h"> + <conversion-rule> <target-to-native> <add-conversion type="PyDate" check="PyDate_ImportAndCheck(%in)"> int day = PyDateTime_GET_DAY(%in); |