Skip to content

Commit 0df6a18

Browse files
committed
Eliminate python-typemaps.h
1 parent 169d7d8 commit 0df6a18

File tree

2 files changed

+13
-28
lines changed

2 files changed

+13
-28
lines changed

lldb/bindings/python/python-typemaps.h

Lines changed: 0 additions & 21 deletions
This file was deleted.

lldb/bindings/python/python-typemaps.swig

Lines changed: 13 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -6,12 +6,6 @@ AND call SWIG_fail at the same time, because it will result in a double free.
66
77
*/
88

9-
%inline %{
10-
11-
#include "../bindings/python/python-typemaps.h"
12-
13-
%}
14-
159
%typemap(in) char ** {
1610
/* Check if is a list */
1711
if (PythonList::Check($input)) {
@@ -635,9 +629,21 @@ template <> bool SetNumberFromPyObject<double>(double &number, PyObject *obj) {
635629
}
636630

637631
#if SWIG_VERSION < 0x040100
638-
// These two pybuffer macros are copied out of swig/Lib/python/pybuffer.i,
632+
// The two pybuffer macros below are copied out of swig/Lib/python/pybuffer.i,
639633
// and fixed so they will not crash if PyObject_GetBuffer fails.
640634
// https://github.com/swig/swig/issues/1640
635+
636+
struct Py_buffer_RAII {
637+
Py_buffer buffer = {};
638+
Py_buffer_RAII(){};
639+
Py_buffer &operator=(const Py_buffer_RAII &) = delete;
640+
Py_buffer_RAII(const Py_buffer_RAII &) = delete;
641+
~Py_buffer_RAII() {
642+
if (buffer.obj)
643+
PyBuffer_Release(&buffer);
644+
}
645+
};
646+
641647
%define %pybuffer_mutable_binary(TYPEMAP, SIZE)
642648
%typemap(in) (TYPEMAP, SIZE) (Py_buffer_RAII view) {
643649
int res;

0 commit comments

Comments
 (0)