summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorEnrico Granata <egranata@apple.com>2013-07-12 21:11:02 +0000
committerEnrico Granata <egranata@apple.com>2013-07-12 21:11:02 +0000
commitb8b0bf9b81de68d4e6776265cb3db75ae6315336 (patch)
tree031f74f044737237af4c58a9c512fb1f438dffc9
parent456ed25149431b15be73869038702535176c5daf (diff)
downloadbcm5719-llvm-b8b0bf9b81de68d4e6776265cb3db75ae6315336.tar.gz
bcm5719-llvm-b8b0bf9b81de68d4e6776265cb3db75ae6315336.zip
Added Repr() and Str() member functions to our PythonObject class to allow easy conversion to-string of every PythonObject
llvm-svn: 186205
-rw-r--r--lldb/include/lldb/Interpreter/PythonDataObjects.h6
-rw-r--r--lldb/source/Interpreter/PythonDataObjects.cpp22
2 files changed, 28 insertions, 0 deletions
diff --git a/lldb/include/lldb/Interpreter/PythonDataObjects.h b/lldb/include/lldb/Interpreter/PythonDataObjects.h
index 3893e3bece9..b2c9240db09 100644
--- a/lldb/include/lldb/Interpreter/PythonDataObjects.h
+++ b/lldb/include/lldb/Interpreter/PythonDataObjects.h
@@ -99,6 +99,12 @@ namespace lldb_private {
return m_py_obj;
}
+ PythonString
+ Repr ();
+
+ PythonString
+ Str ();
+
operator bool () const
{
return m_py_obj != NULL;
diff --git a/lldb/source/Interpreter/PythonDataObjects.cpp b/lldb/source/Interpreter/PythonDataObjects.cpp
index e59e75aa215..2a1f348e14b 100644
--- a/lldb/source/Interpreter/PythonDataObjects.cpp
+++ b/lldb/source/Interpreter/PythonDataObjects.cpp
@@ -66,6 +66,28 @@ PythonObject::Dump (Stream &strm) const
strm.PutCString ("NULL");
}
+PythonString
+PythonObject::Repr ()
+{
+ if (!m_py_obj)
+ return PythonString ();
+ PyObject *repr = PyObject_Repr(m_py_obj);
+ if (!repr)
+ return PythonString ();
+ return PythonString(repr);
+}
+
+PythonString
+PythonObject::Str ()
+{
+ if (!m_py_obj)
+ return PythonString ();
+ PyObject *str = PyObject_Str(m_py_obj);
+ if (!str)
+ return PythonString ();
+ return PythonString(str);
+}
+
//----------------------------------------------------------------------
// PythonString
//----------------------------------------------------------------------
OpenPOWER on IntegriCloud