Skip to content

Commit 36848a3

Browse files
authored
[lldb] Remove bindings/python/python-typemaps.h (#167966)
The minimum supported SWIG version is 4.0 so there's no need for using a separate file anymore.
1 parent 513232f commit 36848a3

File tree

2 files changed

+12
-25
lines changed

2 files changed

+12
-25
lines changed

lldb/bindings/python/python-typemaps.h

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

lldb/bindings/python/python-typemaps.swig

Lines changed: 12 additions & 6 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)) {
@@ -640,6 +634,18 @@ template <> bool SetNumberFromPyObject<double>(double &number, PyObject *obj) {
640634
//
641635
// I've also moved the call to PyBuffer_Release to the end of the SWIG wrapper,
642636
// doing it right away is not legal according to the python buffer protocol.
637+
%inline %{
638+
struct Py_buffer_RAII {
639+
Py_buffer buffer = {};
640+
Py_buffer_RAII(){};
641+
Py_buffer &operator=(const Py_buffer_RAII &) = delete;
642+
Py_buffer_RAII(const Py_buffer_RAII &) = delete;
643+
~Py_buffer_RAII() {
644+
if (buffer.obj)
645+
PyBuffer_Release(&buffer);
646+
}
647+
};
648+
%}
643649

644650
%define %pybuffer_mutable_binary(TYPEMAP, SIZE)
645651
%typemap(in) (TYPEMAP, SIZE) (Py_buffer_RAII view) {

0 commit comments

Comments
 (0)