Add GetDescription() and __repr__ () methods to most API classes, to allow
"print" from inside Python to print out the objects in a more useful
manner.
git-svn-id: https://llvm.org/svn/llvm-project/llvdb/trunk@114321 91177308-0d34-0410-b5e6-96231b3b80d8
diff --git a/source/API/SBSymbolContext.cpp b/source/API/SBSymbolContext.cpp
index 1c2b52c..4381994 100644
--- a/source/API/SBSymbolContext.cpp
+++ b/source/API/SBSymbolContext.cpp
@@ -8,6 +8,7 @@
//===----------------------------------------------------------------------===//
#include "lldb/API/SBSymbolContext.h"
+#include "lldb/API/SBStream.h"
#include "lldb/Symbol/SymbolContext.h"
using namespace lldb;
@@ -146,5 +147,24 @@
return m_opaque_ap.get();
}
+bool
+SBSymbolContext::GetDescription (SBStream &description)
+{
+ if (m_opaque_ap.get())
+ {
+ m_opaque_ap->GetDescription (description.get(), lldb::eDescriptionLevelFull, NULL);
+ }
+ else
+ description.Printf ("No value");
+ return true;
+}
+PyObject *
+SBSymbolContext::__repr__ ()
+{
+ SBStream description;
+ description.ref();
+ GetDescription (description);
+ return PyString_FromString (description.GetData());
+}