diff options
Diffstat (limited to 'tests/samplebinding/bytearray_conversions.h')
-rw-r--r-- | tests/samplebinding/bytearray_conversions.h | 28 |
1 files changed, 28 insertions, 0 deletions
diff --git a/tests/samplebinding/bytearray_conversions.h b/tests/samplebinding/bytearray_conversions.h new file mode 100644 index 000000000..79a070d7b --- /dev/null +++ b/tests/samplebinding/bytearray_conversions.h @@ -0,0 +1,28 @@ +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*>::checkType(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 (PyString_Check(pyObj)) + return ByteArray(PyString_AS_STRING(pyObj), PyString_GET_SIZE(pyObj)); + return ValueTypeConverter<ByteArray>::toCpp(pyObj); +} +inline PyObject* Converter<ByteArray>::toPython(const ByteArray& cppObj) +{ + return ValueTypeConverter<ByteArray>::toPython(cppObj); +} +} |