Add a convenience function to the API for creating a writable buffer object from a pointer and size.

git-svn-id: https://svn.wxwidgets.org/svn/wx/wxPython/Phoenix/trunk@71407 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775
This commit is contained in:
Robin Dunn
2012-05-10 22:39:08 +00:00
parent 4045293f9d
commit cb5e679b6d
2 changed files with 8 additions and 4 deletions

View File

@@ -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

View File

@@ -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
};