[Lldb-commits] [PATCH] D72377: [ldlb/SWIG] Refactor extensions to be non Python-specific.

Jonas Devlieghere via Phabricator via lldb-commits lldb-commits at lists.llvm.org
Tue Jan 7 22:15:09 PST 2020


JDevlieghere updated this revision to Diff 236763.
JDevlieghere added a comment.

Include `ConstString.h` once in `extensions.swig`.


CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D72377/new/

https://reviews.llvm.org/D72377

Files:
  lldb/scripts/Python/python-extensions.swig
  lldb/scripts/extensions.swig
  lldb/scripts/lldb.swig
  lldb/scripts/lldb_lua.swig


Index: lldb/scripts/lldb_lua.swig
===================================================================
--- lldb/scripts/lldb_lua.swig
+++ lldb/scripts/lldb_lua.swig
@@ -15,4 +15,5 @@
 using namespace lldb;
 %}
 
+%include "./extensions.swig"
 %include "./interfaces.swig"
Index: lldb/scripts/lldb.swig
===================================================================
--- lldb/scripts/lldb.swig
+++ lldb/scripts/lldb.swig
@@ -105,6 +105,7 @@
 %}
 
 %include "./interfaces.swig"
+%include "./extensions.swig"
 %include "./Python/python-extensions.swig"
 %include "./Python/python-wrapper.swig"
 
Index: lldb/scripts/extensions.swig
===================================================================
--- /dev/null
+++ lldb/scripts/extensions.swig
@@ -0,0 +1,21 @@
+%{
+#include "../include/lldb/Utility/ConstString.h"
+%}
+
+%extend lldb::SBTarget {
+  %nothreadallow;
+  const char *lldb::SBTarget::__str__ (){
+    lldb::SBStream stream;
+    $self->GetDescription (stream, lldb::eDescriptionLevelBrief);
+
+    const char *desc = stream.GetData();
+    size_t desc_len = stream.GetSize();
+    if (desc_len > 0 && (desc[desc_len-1] == '\n' || desc[desc_len-1] == '\r'))
+      --desc_len;
+
+    lldb_private::ConstString str(desc, desc_len);
+    return str.GetCString();
+  }
+  %clearnothreadallow;
+}
+
Index: lldb/scripts/Python/python-extensions.swig
===================================================================
--- lldb/scripts/Python/python-extensions.swig
+++ lldb/scripts/Python/python-extensions.swig
@@ -502,18 +502,6 @@
 }
 
 %extend lldb::SBTarget {
-        %nothreadallow;
-        PyObject *lldb::SBTarget::__str__ (){
-                lldb::SBStream description;
-                $self->GetDescription (description, lldb::eDescriptionLevelBrief);
-                const char *desc = description.GetData();
-                size_t desc_len = description.GetSize();
-                if (desc_len > 0 && (desc[desc_len-1] == '\n' || desc[desc_len-1] == '\r'))
-                    --desc_len;
-                return PythonString(llvm::StringRef(desc, desc_len)).release();
-        }
-        %clearnothreadallow;
-
     %pythoncode %{
         def __eq__(self, rhs):
             if not isinstance(rhs, type(self)):


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D72377.236763.patch
Type: text/x-patch
Size: 2243 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/lldb-commits/attachments/20200108/ddaf3e48/attachment-0001.bin>


More information about the lldb-commits mailing list