Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
19 changes: 0 additions & 19 deletions lldb/bindings/python/python-typemaps.h

This file was deleted.

26 changes: 16 additions & 10 deletions lldb/bindings/python/python-typemaps.swig
Original file line number Diff line number Diff line change
Expand Up @@ -6,12 +6,6 @@ AND call SWIG_fail at the same time, because it will result in a double free.

*/

%inline %{

#include "../bindings/python/python-typemaps.h"

%}

%typemap(in) char ** {
/* Check if is a list */
if (PythonList::Check($input)) {
Expand Down Expand Up @@ -634,12 +628,21 @@ template <> bool SetNumberFromPyObject<double>(double &number, PyObject *obj) {
}
}

// These two pybuffer macros are copied out of swig/Lib/python/pybuffer.i,
#if SWIG_VERSION < 0x040100
// The two pybuffer macros below are copied out of swig/Lib/python/pybuffer.i,
// and fixed so they will not crash if PyObject_GetBuffer fails.
// https://github.com/swig/swig/issues/1640
//
// I've also moved the call to PyBuffer_Release to the end of the SWIG wrapper,
// doing it right away is not legal according to the python buffer protocol.

struct Py_buffer_RAII {
Py_buffer buffer = {};
Py_buffer_RAII(){};
Py_buffer &operator=(const Py_buffer_RAII &) = delete;
Py_buffer_RAII(const Py_buffer_RAII &) = delete;
~Py_buffer_RAII() {
if (buffer.obj)
PyBuffer_Release(&buffer);
}
};

%define %pybuffer_mutable_binary(TYPEMAP, SIZE)
%typemap(in) (TYPEMAP, SIZE) (Py_buffer_RAII view) {
Expand Down Expand Up @@ -674,6 +677,9 @@ template <> bool SetNumberFromPyObject<double>(double &number, PyObject *obj) {
$2 = ($2_ltype)(size / sizeof($*1_type));
}
%enddef
#else
%include <pybuffer.i>
#endif

%pybuffer_binary(const uint8_t *buf, size_t num_bytes);
%pybuffer_mutable_binary(uint8_t *buf, size_t num_bytes);
Expand Down
Loading