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/SBTarget.cpp b/source/API/SBTarget.cpp
index 9e5c1ab..f779c33 100644
--- a/source/API/SBTarget.cpp
+++ b/source/API/SBTarget.cpp
@@ -13,6 +13,7 @@
#include "lldb/API/SBFileSpec.h"
#include "lldb/API/SBModule.h"
+#include "lldb/API/SBStream.h"
#include "lldb/Breakpoint/BreakpointID.h"
#include "lldb/Breakpoint/BreakpointIDList.h"
#include "lldb/Breakpoint/BreakpointList.h"
@@ -500,3 +501,25 @@
out_stream);
}
}
+
+bool
+SBTarget::GetDescription (SBStream &description)
+{
+ if (m_opaque_sp)
+ {
+ m_opaque_sp->Dump (description.get());
+ }
+ else
+ description.Printf ("No value");
+
+ return true;
+}
+
+PyObject *
+SBTarget::__repr__ ()
+{
+ SBStream description;
+ description.ref();
+ GetDescription (description);
+ return PyString_FromString (description.GetData());
+}