diff --git a/src/wxpy_api.h b/src/wxpy_api.h index 9b631ffd..d36c5b5a 100644 --- a/src/wxpy_api.h +++ b/src/wxpy_api.h @@ -95,6 +95,13 @@ inline void wxPyEndAllowThreads(PyThreadState* saved) { #define RETURN_NONE() { wxPyBLOCK_THREADS(Py_INCREF(Py_None)); return Py_None; } +inline PyObject* wxPyMakeBuffer(void* ptr, Py_ssize_t len) { + Py_buffer view; + PyBuffer_FillInfo(&view, NULL, ptr, len, 0, PyBUF_WRITABLE|PyBUF_FORMAT|PyBUF_ND); + return PyMemoryView_FromBuffer(&view); +} + + //-------------------------------------------------------------------------- // These are the API items whose implementation can not or should not be // inline functions or macros. The implementations will instead be accessed diff --git a/src/wxpybuffer.sip b/src/wxpybuffer.sip index 5039b4db..702ce1ca 100644 --- a/src/wxpybuffer.sip +++ b/src/wxpybuffer.sip @@ -37,9 +37,6 @@ // This isn't being used anywhere yet, but it should work. %ConvertFromTypeCode - Py_buffer view; - PyBuffer_FillInfo(&view, NULL, sipCpp->m_ptr, sipCpp->m_len, 0, - PyBUF_WRITABLE|PyBUF_FORMAT|PyBUF_ND); - return PyMemoryView_FromBuffer(&view); + return wxPyMakeBuffer(sipCpp->m_ptr, sipCpp->m_len); %End };