diff options
author | Hugo Parente Lima <hugo.pl@gmail.com> | 2011-05-25 16:23:22 -0300 |
---|---|---|
committer | Hugo Parente Lima <hugo.pl@gmail.com> | 2012-03-08 16:15:24 -0300 |
commit | 0e6d4cc1d151724f56c6ccf8c431077e2c778b26 (patch) | |
tree | 3717e96dfd1e22bc75ce409cdca20c136d056c96 /tests | |
parent | 22bed1fb96a37bdf9d032a801f5577f81832fe76 (diff) |
Added Shiboken buffer interface.
This interface is just a wrapper to the differents API's provided by Python
to deal with memory buffers in various versions of Python, so is recommended
to use this API to deal with Python memory buffers instead of the CPython API.
If you want to have a Python buffer as argument of any function just change
the argument type to "PyBuffer" and the generator will handle it right regarding
to type checking.
Reviewer: Renato Araújo <renato.filho@openbossa.org>
Luciano Wolf <luciano.wolf@openbossa.org>
Diffstat (limited to 'tests')
-rw-r--r-- | tests/samplebinding/typesystem_sample.xml | 12 |
1 files changed, 2 insertions, 10 deletions
diff --git a/tests/samplebinding/typesystem_sample.xml b/tests/samplebinding/typesystem_sample.xml index 338719372..87ee5512f 100644 --- a/tests/samplebinding/typesystem_sample.xml +++ b/tests/samplebinding/typesystem_sample.xml @@ -1231,20 +1231,12 @@ </modify-function> <template name="buffer_argument"> - unsigned char* %out; - if (PyObject_CheckReadBuffer(%PYARG_1)) { - PyBufferProcs* bufferProcs = %PYARG_1->ob_type->tp_as_buffer; - void* ptr; - bufferProcs->bf_getreadbuffer(%PYARG_1, 0, &ptr); - %out = (unsigned char*) ptr; - } else { - PyErr_SetString(PyExc_TypeError, "The object must support buffer protocol with just one segment."); - } + unsigned char* %out = (unsigned char*) Shiboken::Buffer::getPointer(%PYARG_1); </template> <modify-function signature="strBufferOverloads(unsigned char*,int)"> <modify-argument index="1"> - <replace-type modified-type="PyObject"/> + <replace-type modified-type="PyBuffer"/> <conversion-rule class="native"> <insert-template name="buffer_argument" /> </conversion-rule> |