aboutsummaryrefslogtreecommitdiffstats
path: root/PySide
diff options
context:
space:
mode:
authorHugo Parente Lima <hugo.pl@gmail.com>2011-02-03 18:04:16 -0200
committerHugo Parente Lima <hugo.pl@gmail.com>2012-03-08 16:53:52 -0300
commit702cd168e1af7ef854aad7091529e4ce6e9df833 (patch)
treeb00746d4576be00fc6fede0b27da3f69a05d7917 /PySide
parent4f4abdb2be8417ae5f75340e673341a833b9a14c (diff)
Fix comparisson of QByteArray with Python strings that have zeroes inside.
Diffstat (limited to 'PySide')
-rw-r--r--PySide/QtCore/qbytearray_conversions.h34
-rw-r--r--PySide/QtCore/typesystem_core.xml14
2 files changed, 48 insertions, 0 deletions
diff --git a/PySide/QtCore/qbytearray_conversions.h b/PySide/QtCore/qbytearray_conversions.h
new file mode 100644
index 000000000..daa16099f
--- /dev/null
+++ b/PySide/QtCore/qbytearray_conversions.h
@@ -0,0 +1,34 @@
+namespace Shiboken {
+
+inline bool Converter<QByteArray>::checkType(PyObject* pyObj)
+{
+ return ValueTypeConverter<QByteArray>::checkType(pyObj);
+}
+
+inline bool Converter<QByteArray>::isConvertible(PyObject* pyObj)
+{
+ if (ValueTypeConverter<QByteArray>::isConvertible(pyObj))
+ return true;
+ SbkObjectType* shiboType = reinterpret_cast<SbkObjectType*>(SbkType< ::QByteArray >());
+ return Shiboken::Converter<const char *>::checkType(pyObj)
+ || (ObjectType::isExternalConvertible(shiboType, pyObj));
+}
+
+inline QByteArray Converter<QByteArray>::toCpp(PyObject* pyObj)
+{
+ if (pyObj == Py_None)
+ return 0;
+ else if (PyObject_TypeCheck(pyObj, SbkType<QByteArray>()))
+ return *Converter<QByteArray*>::toCpp(pyObj);
+ else if (PyString_Check(pyObj))
+ return QByteArray(PyString_AS_STRING(pyObj), PyString_GET_SIZE(pyObj));
+ else
+ return ValueTypeConverter<QByteArray>::toCpp(pyObj);
+}
+
+inline PyObject* Converter<QByteArray>::toPython(const ::QByteArray& cppObj)
+{
+ return ValueTypeConverter<QByteArray>::toPython(cppObj);
+}
+
+}
diff --git a/PySide/QtCore/typesystem_core.xml b/PySide/QtCore/typesystem_core.xml
index 4979b566a..beac5175f 100644
--- a/PySide/QtCore/typesystem_core.xml
+++ b/PySide/QtCore/typesystem_core.xml
@@ -1442,6 +1442,8 @@
</add-function>
</value-type>
<value-type name="QByteArray" hash-function="qHash">
+ <conversion-rule file="qbytearray_conversions.h"/>
+
<extra-includes>
<include file-name="QNoImplicitBoolCast" location="global"/>
</extra-includes>
@@ -1499,6 +1501,18 @@
<modify-function signature="operator const char *()const" remove="all"/>
<modify-function signature="operator const void *()const" remove="all"/>
<modify-function signature="operator+=(const char*)" remove="all"/>
+ <modify-function signature="operator==(const char*,QByteArray)" remove="all" />
+ <modify-function signature="operator==(QByteArray,const char*)" remove="all" />
+ <modify-function signature="operator!=(const char*,QByteArray)" remove="all" />
+ <modify-function signature="operator!=(QByteArray,const char*)" remove="all" />
+ <modify-function signature="operator&lt;(const char*,QByteArray)" remove="all" />
+ <modify-function signature="operator&lt;(QByteArray,const char*)" remove="all" />
+ <modify-function signature="operator&lt;=(const char*,QByteArray)" remove="all" />
+ <modify-function signature="operator&lt;=(QByteArray,const char*)" remove="all" />
+ <modify-function signature="operator>(const char*,QByteArray)" remove="all" />
+ <modify-function signature="operator>(QByteArray,const char*)" remove="all" />
+ <modify-function signature="operator>=(const char*,QByteArray)" remove="all" />
+ <modify-function signature="operator>=(QByteArray,const char*)" remove="all" />
<modify-function signature="operator[](int)const" remove="all"/>
<modify-function signature="operator[](uint)const" remove="all"/>
<modify-function signature="push_back(char)" remove="all"/>