xref: /freebsd/contrib/llvm-project/lldb/bindings/python/python-typemaps.h (revision bdd1243df58e60e85101c09001d9812a789b6bc4)
1 #ifndef LLDB_BINDINGS_PYTHON_PYTHON_TYPEMAPS_H
2 #define LLDB_BINDINGS_PYTHON_PYTHON_TYPEMAPS_H
3 
4 #include <Python.h>
5 
6 // Defined here instead of a .swig file because SWIG 2 doesn't support
7 // explicit deleted functions.
8 struct Py_buffer_RAII {
9   Py_buffer buffer = {};
Py_buffer_RAIIPy_buffer_RAII10   Py_buffer_RAII(){};
11   Py_buffer &operator=(const Py_buffer_RAII &) = delete;
12   Py_buffer_RAII(const Py_buffer_RAII &) = delete;
~Py_buffer_RAIIPy_buffer_RAII13   ~Py_buffer_RAII() {
14     if (buffer.obj)
15       PyBuffer_Release(&buffer);
16   }
17 };
18 
19 #endif // LLDB_BINDINGS_PYTHON_PYTHON_TYPEMAPS_H
20