[Lldb-commits] [lldb] r250303 - Change swig interface files to use PythonDataObjects.
Zachary Turner via lldb-commits
lldb-commits at lists.llvm.org
Wed Oct 14 09:59:32 PDT 2015
Author: zturner
Date: Wed Oct 14 11:59:32 2015
New Revision: 250303
URL: http://llvm.org/viewvc/llvm-project?rev=250303&view=rev
Log:
Change swig interface files to use PythonDataObjects.
Modified:
lldb/trunk/scripts/Python/python-extensions.swig
lldb/trunk/scripts/Python/python-typemaps.swig
lldb/trunk/scripts/lldb.swig
lldb/trunk/source/Plugins/ScriptInterpreter/Python/PythonDataObjects.h
lldb/trunk/source/Plugins/ScriptInterpreter/Python/ScriptInterpreterPython.cpp
Modified: lldb/trunk/scripts/Python/python-extensions.swig
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/scripts/Python/python-extensions.swig?rev=250303&r1=250302&r2=250303&view=diff
==============================================================================
--- lldb/trunk/scripts/Python/python-extensions.swig (original)
+++ lldb/trunk/scripts/Python/python-extensions.swig Wed Oct 14 11:59:32 2015
@@ -8,9 +8,9 @@
if (desc_len > 0 && (desc[desc_len-1] == '\n' || desc[desc_len-1] == '\r'))
--desc_len;
if (desc_len > 0)
- return PyString_FromStringAndSize (desc, desc_len);
+ return lldb_private::PythonString(llvm::StringRef(desc, desc_len)).release();
else
- return PyString_FromString("");
+ return lldb_private::PythonString("").release();
}
}
%extend lldb::SBBlock {
@@ -22,9 +22,9 @@
if (desc_len > 0 && (desc[desc_len-1] == '\n' || desc[desc_len-1] == '\r'))
--desc_len;
if (desc_len > 0)
- return PyString_FromStringAndSize (desc, desc_len);
+ return lldb_private::PythonString(llvm::StringRef(desc, desc_len)).release();
else
- return PyString_FromString("");
+ return lldb_private::PythonString("").release();
}
}
%extend lldb::SBBreakpoint {
@@ -36,9 +36,9 @@
if (desc_len > 0 && (desc[desc_len-1] == '\n' || desc[desc_len-1] == '\r'))
--desc_len;
if (desc_len > 0)
- return PyString_FromStringAndSize (desc, desc_len);
+ return lldb_private::PythonString(llvm::StringRef(desc, desc_len)).release();
else
- return PyString_FromString("");
+ return lldb_private::PythonString("").release();
}
%pythoncode %{
@@ -65,9 +65,9 @@
if (desc_len > 0 && (desc[desc_len-1] == '\n' || desc[desc_len-1] == '\r'))
--desc_len;
if (desc_len > 0)
- return PyString_FromStringAndSize (desc, desc_len);
+ return lldb_private::PythonString(llvm::StringRef(desc, desc_len)).release();
else
- return PyString_FromString("");
+ return lldb_private::PythonString("").release();
}
}
@@ -96,9 +96,9 @@
if (desc_len > 0 && (desc[desc_len-1] == '\n' || desc[desc_len-1] == '\r'))
--desc_len;
if (desc_len > 0)
- return PyString_FromStringAndSize (desc, desc_len);
+ return lldb_private::PythonString(llvm::StringRef(desc, desc_len)).release();
else
- return PyString_FromString("");
+ return lldb_private::PythonString("").release();
}
/* the write() and flush() calls are not part of the SB API proper, and are solely for Python usage
@@ -123,9 +123,9 @@
if (desc_len > 0 && (desc[desc_len-1] == '\n' || desc[desc_len-1] == '\r'))
--desc_len;
if (desc_len > 0)
- return PyString_FromStringAndSize (desc, desc_len);
+ return lldb_private::PythonString(llvm::StringRef(desc, desc_len)).release();
else
- return PyString_FromString("");
+ return lldb_private::PythonString("").release();
}
%pythoncode %{
def __eq__(self, rhs):
@@ -150,9 +150,9 @@
if (desc_len > 0 && (desc[desc_len-1] == '\n' || desc[desc_len-1] == '\r'))
--desc_len;
if (desc_len > 0)
- return PyString_FromStringAndSize (desc, desc_len);
+ return lldb_private::PythonString(llvm::StringRef(desc, desc_len)).release();
else
- return PyString_FromString("");
+ return lldb_private::PythonString("").release();
}
}
%extend lldb::SBDebugger {
@@ -164,9 +164,9 @@
if (desc_len > 0 && (desc[desc_len-1] == '\n' || desc[desc_len-1] == '\r'))
--desc_len;
if (desc_len > 0)
- return PyString_FromStringAndSize (desc, desc_len);
+ return lldb_private::PythonString(llvm::StringRef(desc, desc_len)).release();
else
- return PyString_FromString("");
+ return lldb_private::PythonString("").release();
}
}
%extend lldb::SBDeclaration {
@@ -178,9 +178,9 @@
if (desc_len > 0 && (desc[desc_len-1] == '\n' || desc[desc_len-1] == '\r'))
--desc_len;
if (desc_len > 0)
- return PyString_FromStringAndSize (desc, desc_len);
+ return lldb_private::PythonString(llvm::StringRef(desc, desc_len)).release();
else
- return PyString_FromString("");
+ return lldb_private::PythonString("").release();
}
%pythoncode %{
@@ -207,9 +207,9 @@
if (desc_len > 0 && (desc[desc_len-1] == '\n' || desc[desc_len-1] == '\r'))
--desc_len;
if (desc_len > 0)
- return PyString_FromStringAndSize (desc, desc_len);
+ return lldb_private::PythonString(llvm::StringRef(desc, desc_len)).release();
else
- return PyString_FromString("");
+ return lldb_private::PythonString("").release();
}
}
%extend lldb::SBFileSpec {
@@ -221,9 +221,9 @@
if (desc_len > 0 && (desc[desc_len-1] == '\n' || desc[desc_len-1] == '\r'))
--desc_len;
if (desc_len > 0)
- return PyString_FromStringAndSize (desc, desc_len);
+ return lldb_private::PythonString(llvm::StringRef(desc, desc_len)).release();
else
- return PyString_FromString("");
+ return lldb_private::PythonString("").release();
}
}
%extend lldb::SBFrame {
@@ -235,9 +235,9 @@
if (desc_len > 0 && (desc[desc_len-1] == '\n' || desc[desc_len-1] == '\r'))
--desc_len;
if (desc_len > 0)
- return PyString_FromStringAndSize (desc, desc_len);
+ return lldb_private::PythonString(llvm::StringRef(desc, desc_len)).release();
else
- return PyString_FromString("");
+ return lldb_private::PythonString("").release();
}
}
%extend lldb::SBFunction {
@@ -249,9 +249,9 @@
if (desc_len > 0 && (desc[desc_len-1] == '\n' || desc[desc_len-1] == '\r'))
--desc_len;
if (desc_len > 0)
- return PyString_FromStringAndSize (desc, desc_len);
+ return lldb_private::PythonString(llvm::StringRef(desc, desc_len)).release();
else
- return PyString_FromString("");
+ return lldb_private::PythonString("").release();
}
%pythoncode %{
@@ -278,9 +278,9 @@
if (desc_len > 0 && (desc[desc_len-1] == '\n' || desc[desc_len-1] == '\r'))
--desc_len;
if (desc_len > 0)
- return PyString_FromStringAndSize (desc, desc_len);
+ return lldb_private::PythonString(llvm::StringRef(desc, desc_len)).release();
else
- return PyString_FromString("");
+ return lldb_private::PythonString("").release();
}
}
%extend lldb::SBInstructionList {
@@ -292,9 +292,9 @@
if (desc_len > 0 && (desc[desc_len-1] == '\n' || desc[desc_len-1] == '\r'))
--desc_len;
if (desc_len > 0)
- return PyString_FromStringAndSize (desc, desc_len);
+ return lldb_private::PythonString(llvm::StringRef(desc, desc_len)).release();
else
- return PyString_FromString("");
+ return lldb_private::PythonString("").release();
}
}
%extend lldb::SBLineEntry {
@@ -306,9 +306,9 @@
if (desc_len > 0 && (desc[desc_len-1] == '\n' || desc[desc_len-1] == '\r'))
--desc_len;
if (desc_len > 0)
- return PyString_FromStringAndSize (desc, desc_len);
+ return lldb_private::PythonString(llvm::StringRef(desc, desc_len)).release();
else
- return PyString_FromString("");
+ return lldb_private::PythonString("").release();
}
%pythoncode %{
@@ -334,9 +334,9 @@
if (desc_len > 0 && (desc[desc_len-1] == '\n' || desc[desc_len-1] == '\r'))
--desc_len;
if (desc_len > 0)
- return PyString_FromStringAndSize (desc, desc_len);
+ return lldb_private::PythonString(llvm::StringRef(desc, desc_len)).release();
else
- return PyString_FromString("");
+ return lldb_private::PythonString("").release();
}
%pythoncode %{
@@ -363,9 +363,9 @@
if (desc_len > 0 && (desc[desc_len-1] == '\n' || desc[desc_len-1] == '\r'))
--desc_len;
if (desc_len > 0)
- return PyString_FromStringAndSize (desc, desc_len);
+ return lldb_private::PythonString(llvm::StringRef(desc, desc_len)).release();
else
- return PyString_FromString("");
+ return lldb_private::PythonString("").release();
}
}
@@ -378,9 +378,9 @@
if (desc_len > 0 && (desc[desc_len-1] == '\n' || desc[desc_len-1] == '\r'))
--desc_len;
if (desc_len > 0)
- return PyString_FromStringAndSize (desc, desc_len);
+ return lldb_private::PythonString(llvm::StringRef(desc, desc_len)).release();
else
- return PyString_FromString("");
+ return lldb_private::PythonString("").release();
}
}
@@ -393,9 +393,9 @@
if (desc_len > 0 && (desc[desc_len-1] == '\n' || desc[desc_len-1] == '\r'))
--desc_len;
if (desc_len > 0)
- return PyString_FromStringAndSize (desc, desc_len);
+ return lldb_private::PythonString(llvm::StringRef(desc, desc_len)).release();
else
- return PyString_FromString("");
+ return lldb_private::PythonString("").release();
}
}
%extend lldb::SBSection {
@@ -407,9 +407,9 @@
if (desc_len > 0 && (desc[desc_len-1] == '\n' || desc[desc_len-1] == '\r'))
--desc_len;
if (desc_len > 0)
- return PyString_FromStringAndSize (desc, desc_len);
+ return lldb_private::PythonString(llvm::StringRef(desc, desc_len)).release();
else
- return PyString_FromString("");
+ return lldb_private::PythonString("").release();
}
%pythoncode %{
@@ -449,9 +449,9 @@
if (desc_len > 0 && (desc[desc_len-1] == '\n' || desc[desc_len-1] == '\r'))
--desc_len;
if (desc_len > 0)
- return PyString_FromStringAndSize (desc, desc_len);
+ return lldb_private::PythonString(llvm::StringRef(desc, desc_len)).release();
else
- return PyString_FromString("");
+ return lldb_private::PythonString("").release();
}
%pythoncode %{
def __eq__(self, rhs):
@@ -476,9 +476,9 @@
if (desc_len > 0 && (desc[desc_len-1] == '\n' || desc[desc_len-1] == '\r'))
--desc_len;
if (desc_len > 0)
- return PyString_FromStringAndSize (desc, desc_len);
+ return lldb_private::PythonString(llvm::StringRef(desc, desc_len)).release();
else
- return PyString_FromString("");
+ return lldb_private::PythonString("").release();
}
}
%extend lldb::SBSymbolContextList {
@@ -490,9 +490,9 @@
if (desc_len > 0 && (desc[desc_len-1] == '\n' || desc[desc_len-1] == '\r'))
--desc_len;
if (desc_len > 0)
- return PyString_FromStringAndSize (desc, desc_len);
+ return lldb_private::PythonString(llvm::StringRef(desc, desc_len)).release();
else
- return PyString_FromString("");
+ return lldb_private::PythonString("").release();
}
}
@@ -505,9 +505,9 @@
if (desc_len > 0 && (desc[desc_len-1] == '\n' || desc[desc_len-1] == '\r'))
--desc_len;
if (desc_len > 0)
- return PyString_FromStringAndSize (desc, desc_len);
+ return lldb_private::PythonString(llvm::StringRef(desc, desc_len)).release();
else
- return PyString_FromString("");
+ return lldb_private::PythonString("").release();
}
%pythoncode %{
@@ -534,9 +534,9 @@
if (desc_len > 0 && (desc[desc_len-1] == '\n' || desc[desc_len-1] == '\r'))
--desc_len;
if (desc_len > 0)
- return PyString_FromStringAndSize (desc, desc_len);
+ return lldb_private::PythonString(llvm::StringRef(desc, desc_len)).release();
else
- return PyString_FromString("");
+ return lldb_private::PythonString("").release();
}
}
%extend lldb::SBTypeCategory {
@@ -548,9 +548,9 @@
if (desc_len > 0 && (desc[desc_len-1] == '\n' || desc[desc_len-1] == '\r'))
--desc_len;
if (desc_len > 0)
- return PyString_FromStringAndSize (desc, desc_len);
+ return lldb_private::PythonString(llvm::StringRef(desc, desc_len)).release();
else
- return PyString_FromString("");
+ return lldb_private::PythonString("").release();
}
}
%extend lldb::SBTypeFilter {
@@ -562,9 +562,9 @@
if (desc_len > 0 && (desc[desc_len-1] == '\n' || desc[desc_len-1] == '\r'))
--desc_len;
if (desc_len > 0)
- return PyString_FromStringAndSize (desc, desc_len);
+ return lldb_private::PythonString(llvm::StringRef(desc, desc_len)).release();
else
- return PyString_FromString("");
+ return lldb_private::PythonString("").release();
}
%pythoncode %{
def __eq__(self, rhs):
@@ -589,9 +589,9 @@
if (desc_len > 0 && (desc[desc_len-1] == '\n' || desc[desc_len-1] == '\r'))
--desc_len;
if (desc_len > 0)
- return PyString_FromStringAndSize (desc, desc_len);
+ return lldb_private::PythonString(llvm::StringRef(desc, desc_len)).release();
else
- return PyString_FromString("");
+ return lldb_private::PythonString("").release();
}
}
%extend lldb::SBTypeMember {
@@ -603,9 +603,9 @@
if (desc_len > 0 && (desc[desc_len-1] == '\n' || desc[desc_len-1] == '\r'))
--desc_len;
if (desc_len > 0)
- return PyString_FromStringAndSize (desc, desc_len);
+ return lldb_private::PythonString(llvm::StringRef(desc, desc_len)).release();
else
- return PyString_FromString("");
+ return lldb_private::PythonString("").release();
}
}
%extend lldb::SBTypeEnumMember {
@@ -617,9 +617,9 @@
if (desc_len > 0 && (desc[desc_len-1] == '\n' || desc[desc_len-1] == '\r'))
--desc_len;
if (desc_len > 0)
- return PyString_FromStringAndSize (desc, desc_len);
+ return lldb_private::PythonString(llvm::StringRef(desc, desc_len)).release();
else
- return PyString_FromString("");
+ return lldb_private::PythonString("").release();
}
}
%extend lldb::SBTypeNameSpecifier {
@@ -631,9 +631,9 @@
if (desc_len > 0 && (desc[desc_len-1] == '\n' || desc[desc_len-1] == '\r'))
--desc_len;
if (desc_len > 0)
- return PyString_FromStringAndSize (desc, desc_len);
+ return lldb_private::PythonString(llvm::StringRef(desc, desc_len)).release();
else
- return PyString_FromString("");
+ return lldb_private::PythonString("").release();
}
%pythoncode %{
def __eq__(self, rhs):
@@ -658,9 +658,9 @@
if (desc_len > 0 && (desc[desc_len-1] == '\n' || desc[desc_len-1] == '\r'))
--desc_len;
if (desc_len > 0)
- return PyString_FromStringAndSize (desc, desc_len);
+ return lldb_private::PythonString(llvm::StringRef(desc, desc_len)).release();
else
- return PyString_FromString("");
+ return lldb_private::PythonString("").release();
}
%pythoncode %{
def __eq__(self, rhs):
@@ -685,9 +685,9 @@
if (desc_len > 0 && (desc[desc_len-1] == '\n' || desc[desc_len-1] == '\r'))
--desc_len;
if (desc_len > 0)
- return PyString_FromStringAndSize (desc, desc_len);
+ return lldb_private::PythonString(llvm::StringRef(desc, desc_len)).release();
else
- return PyString_FromString("");
+ return lldb_private::PythonString("").release();
}
%pythoncode %{
def __eq__(self, rhs):
@@ -712,9 +712,9 @@
if (desc_len > 0 && (desc[desc_len-1] == '\n' || desc[desc_len-1] == '\r'))
--desc_len;
if (desc_len > 0)
- return PyString_FromStringAndSize (desc, desc_len);
+ return lldb_private::PythonString(llvm::StringRef(desc, desc_len)).release();
else
- return PyString_FromString("");
+ return lldb_private::PythonString("").release();
}
%pythoncode %{
def __eq__(self, rhs):
@@ -739,9 +739,9 @@
if (desc_len > 0 && (desc[desc_len-1] == '\n' || desc[desc_len-1] == '\r'))
--desc_len;
if (desc_len > 0)
- return PyString_FromStringAndSize (desc, desc_len);
+ return lldb_private::PythonString(llvm::StringRef(desc, desc_len)).release();
else
- return PyString_FromString("");
+ return lldb_private::PythonString("").release();
}
}
%extend lldb::SBValueList {
@@ -762,9 +762,9 @@
if (desc_len > 0 && (desc[desc_len-1] == '\n' || desc[desc_len-1] == '\r'))
--desc_len;
if (desc_len > 0)
- return PyString_FromStringAndSize (desc, desc_len);
+ return lldb_private::PythonString(llvm::StringRef(desc, desc_len)).release();
else
- return PyString_FromString("");
+ return lldb_private::PythonString("").release();
}
}
%extend lldb::SBWatchpoint {
@@ -776,9 +776,9 @@
if (desc_len > 0 && (desc[desc_len-1] == '\n' || desc[desc_len-1] == '\r'))
--desc_len;
if (desc_len > 0)
- return PyString_FromStringAndSize (desc, desc_len);
+ return lldb_private::PythonString(llvm::StringRef(desc, desc_len)).release();
else
- return PyString_FromString("");
+ return lldb_private::PythonString("").release();
}
}
Modified: lldb/trunk/scripts/Python/python-typemaps.swig
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/scripts/Python/python-typemaps.swig?rev=250303&r1=250302&r2=250303&view=diff
==============================================================================
--- lldb/trunk/scripts/Python/python-typemaps.swig (original)
+++ lldb/trunk/scripts/Python/python-typemaps.swig Wed Oct 14 11:59:32 2015
@@ -63,10 +63,10 @@
int i;
len = 0;
while ($1[len]) len++;
- $result = PyList_New(len);
- for (i = 0; i < len; i++) {
- PyList_SetItem($result, i, PyString_FromString($1[i]));
- }
+ lldb_private::PythonList list(len);
+ for (i = 0; i < len; i++)
+ list.SetItemAtIndex(i, lldb_private::PythonString($1[i]));
+ $result = list.release();
}
%typemap(in) char const ** {
@@ -147,7 +147,8 @@
// See also SBThread::GetStopDescription.
%typemap(argout) (char *dst, size_t dst_len) {
Py_XDECREF($result); /* Blow away any previous result */
- $result = PyString_FromStringAndSize(($1),result);
+ lldb_private::PythonString str($1);
+ $result = str.release();
free($1);
}
@@ -237,7 +238,9 @@
// See also SBProcess::ReadMemory.
%typemap(argout) (void *buf, size_t size) {
Py_XDECREF($result); /* Blow away any previous result */
- $result = PyString_FromStringAndSize(static_cast<const char*>($1),result);
+ llvm::StringRef ref(static_cast<const char*>($1), result);
+ lldb_private::PythonString string(ref);
+ $result = string.release();
free($1);
}
Modified: lldb/trunk/scripts/lldb.swig
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/scripts/lldb.swig?rev=250303&r1=250302&r2=250303&view=diff
==============================================================================
--- lldb/trunk/scripts/lldb.swig (original)
+++ lldb/trunk/scripts/lldb.swig Wed Oct 14 11:59:32 2015
@@ -111,8 +111,9 @@ import os
#include "lldb/API/SBWatchpoint.h"
#include "lldb/API/SBUnixSignals.h"
-#include "../scripts/Python/python-swigsafecast.swig"
+#include "../source/Plugins/ScriptInterpreter/Python/PythonDataObjects.h"
+#include "../scripts/Python/python-swigsafecast.swig"
%}
/* Various liblldb typedefs that SWIG needs to know about. */
@@ -121,6 +122,7 @@ import os
as INT32_MAX should only be defined if __STDC_LIMIT_MACROS is. */
#define __STDC_LIMIT_MACROS
%include "stdint.i"
+
%include "lldb/lldb-defines.h"
%include "lldb/lldb-enumerations.h"
%include "lldb/lldb-forward.h"
Modified: lldb/trunk/source/Plugins/ScriptInterpreter/Python/PythonDataObjects.h
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Plugins/ScriptInterpreter/Python/PythonDataObjects.h?rev=250303&r1=250302&r2=250303&view=diff
==============================================================================
--- lldb/trunk/source/Plugins/ScriptInterpreter/Python/PythonDataObjects.h (original)
+++ lldb/trunk/source/Plugins/ScriptInterpreter/Python/PythonDataObjects.h Wed Oct 14 11:59:32 2015
@@ -122,7 +122,7 @@ public:
{
// Avoid calling the virtual method if it's not necessary
// to actually validate the type of the PyObject.
- if (!rhs.get())
+ if (!rhs.IsValid())
Reset();
else
Reset(PyRefType::Borrowed, rhs.m_py_obj);
@@ -167,12 +167,21 @@ public:
Dump (Stream &strm) const;
PyObject*
- get () const
+ get() const
{
return m_py_obj;
}
- PyObjectType GetObjectType() const;
+ PyObject*
+ release()
+ {
+ PyObject *result = m_py_obj;
+ m_py_obj = nullptr;
+ return result;
+ }
+
+ PyObjectType
+ GetObjectType() const;
PythonString
Repr ();
Modified: lldb/trunk/source/Plugins/ScriptInterpreter/Python/ScriptInterpreterPython.cpp
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Plugins/ScriptInterpreter/Python/ScriptInterpreterPython.cpp?rev=250303&r1=250302&r2=250303&view=diff
==============================================================================
--- lldb/trunk/source/Plugins/ScriptInterpreter/Python/ScriptInterpreterPython.cpp (original)
+++ lldb/trunk/source/Plugins/ScriptInterpreter/Python/ScriptInterpreterPython.cpp Wed Oct 14 11:59:32 2015
@@ -478,7 +478,7 @@ PyFile_FromFile_Const(FILE *fp, const ch
int fd = fileno(fp);
#endif
- return PyRef(PyRefType::Owned,
+ return PythonObject(PyRefType::Owned,
PyFile_FromFd(fd, nullptr, cmode, -1, nullptr, "ignore", nullptr, 0));
#else
// Read through the Python source, doesn't seem to modify these strings
More information about the lldb-commits
mailing list