diff options
Diffstat (limited to 'PySide/QtCore')
-rw-r--r-- | PySide/QtCore/typesystem_core.xml | 22 |
1 files changed, 20 insertions, 2 deletions
diff --git a/PySide/QtCore/typesystem_core.xml b/PySide/QtCore/typesystem_core.xml index 692cf9ad7..51019778c 100644 --- a/PySide/QtCore/typesystem_core.xml +++ b/PySide/QtCore/typesystem_core.xml @@ -2014,8 +2014,26 @@ <enum-type name="State"/> </object-type> <object-type name="QTranslator"> - <modify-function signature="translate(const char*,const char*,const char*,int)const" remove="all" /> - <modify-function signature="load(const uchar*, int)" remove="all" /> + <modify-function signature="load(const uchar*, int)"> + <modify-argument index="1"> + <replace-type modified-type="PyObject" /> + </modify-argument> + <modify-argument index="2"> + <remove-argument /> + </modify-argument> + <inject-code> + PyTypeObject* pyType = %PYARG_1->ob_type; + if (pyType->tp_as_buffer + && pyType->tp_as_buffer->bf_getreadbuffer + && pyType->tp_as_buffer->bf_getsegcount(%PYARG_1, 0) == 1) { + void* ptr; + Py_ssize_t size = pyType->tp_as_buffer->bf_getreadbuffer(%PYARG_1, 0, &ptr); + %PYARG_0 = %CONVERTTOPYTHON[bool](%CPPSELF.%FUNCTION_NAME(const_cast<const uchar*>((uchar*)ptr), size)); + } else { + PyErr_SetString(PyExc_TypeError, "The object must support buffer protocol with just one segment."); + } + </inject-code> + </modify-function> </object-type> <object-type name="QWaitCondition"> <modify-function signature="wait(QMutex*, unsigned long)" allow-thread="yes"/> |