X-Git-Url: https://git.saurik.com/wxWidgets.git/blobdiff_plain/c8bc7bb84dcca816055d5876e4772551c48acda5..935b53f2fb175499ac1a8ed53ccd2b986dcdd43a:/wxPython/src/my_typemaps.i diff --git a/wxPython/src/my_typemaps.i b/wxPython/src/my_typemaps.i index 1c712edc4f..cd202b68fd 100644 --- a/wxPython/src/my_typemaps.i +++ b/wxPython/src/my_typemaps.i @@ -188,6 +188,32 @@ $function +//--------------------------------------------------------------------------- + + +%typemap(python, in) wxMemoryBuffer& { + if (!PyString_Check($source)) { + PyErr_SetString(PyExc_TypeError, "String buffer expected"); + return NULL; + } + char* str = PyString_AS_STRING($source); + int len = PyString_GET_SIZE($source); + $target = new wxMemoryBuffer(len); + memcpy($target->GetData(), str, len); +} + +%typemap(python, freearg) wxMemoryBuffer& { + if ($target) + delete $source; +} + +%typemap(python, out) wxMemoryBuffer { + $target = PyString_FromStringAndSize((char*)$source->GetData(), $source->GetDataLen()); +} + +%typemap(python, ret) wxMemoryBuffer { + delete $source; +} //---------------------------------------------------------------------------