[Lldb-commits] [PATCH] D86381: Move Py_buffer_RAII to .h file so SWIG 2 doesnt have to parse it
António Afonso via Phabricator via lldb-commits
lldb-commits at lists.llvm.org
Fri Aug 21 15:32:15 PDT 2020
aadsm created this revision.
aadsm added reviewers: clayborg, wallace, lawrence_danna.
Herald added a project: LLDB.
Herald added a subscriber: lldb-commits.
aadsm requested review of this revision.
Herald added a subscriber: JDevlieghere.
`struct Py_buffer_RAII` definition uses explicit deleted functions which are not supported by SWIG 2 (only 3).
To get around this I moved this struct to an .h file that is included to avoid being parsed by swig.
Repository:
rG LLVM Github Monorepo
https://reviews.llvm.org/D86381
Files:
lldb/bindings/python/python-typemaps.h
lldb/bindings/python/python-typemaps.swig
Index: lldb/bindings/python/python-typemaps.swig
===================================================================
--- lldb/bindings/python/python-typemaps.swig
+++ lldb/bindings/python/python-typemaps.swig
@@ -1,5 +1,11 @@
/* Typemap definitions, to allow SWIG to properly handle 'char**' data types. */
+%inline %{
+
+#include "../bindings/python/python-typemaps.h"
+
+%}
+
%typemap(in) char ** {
/* Check if is a list */
if (PythonList::Check($input)) {
@@ -61,7 +67,7 @@
%typemap(in) lldb::tid_t {
PythonObject obj = Retain<PythonObject>($input);
- lldb::tid_t value = unwrapOrSetPythonException(As<unsigned long long>(obj));
+ lldb::tid_t value = unwrapOrSetPythonException(As<unsigned long long>(obj));
if (PyErr_Occurred())
return nullptr;
$1 = value;
@@ -476,21 +482,6 @@
}
}
-%inline %{
-
-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);
- }
-};
-
-%}
-
// These two pybuffer macros 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
Index: lldb/bindings/python/python-typemaps.h
===================================================================
--- /dev/null
+++ lldb/bindings/python/python-typemaps.h
@@ -0,0 +1,12 @@
+// Defined here instead of a .swig file because SWIG 2 doesn't support
+// explicit deleted functions.
+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);
+ }
+};
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D86381.287127.patch
Type: text/x-patch
Size: 1870 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/lldb-commits/attachments/20200821/d4cb18ba/attachment.bin>
More information about the lldb-commits
mailing list