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/SBBreakpointLocation.cpp b/source/API/SBBreakpointLocation.cpp
index 948b78f..f7e059b 100644
--- a/source/API/SBBreakpointLocation.cpp
+++ b/source/API/SBBreakpointLocation.cpp
@@ -7,9 +7,15 @@
//
//===----------------------------------------------------------------------===//
+// In order to guarantee correct working with Python, Python.h *MUST* be
+// the *FIRST* header file included:
+
+#include <Python.h>
+
#include "lldb/API/SBBreakpointLocation.h"
#include "lldb/API/SBDefines.h"
#include "lldb/API/SBDebugger.h"
+#include "lldb/API/SBStream.h"
#include "lldb/lldb-types.h"
#include "lldb/lldb-defines.h"
@@ -191,12 +197,9 @@
m_opaque_sp = break_loc_sp;
}
-void
-SBBreakpointLocation::GetDescription (FILE *f, const char *description_level)
+bool
+SBBreakpointLocation::GetDescription (const char *description_level, SBStream &description)
{
- if (f == NULL)
- return;
-
if (m_opaque_sp)
{
DescriptionLevel level;
@@ -209,11 +212,22 @@
else
level = eDescriptionLevelBrief;
- StreamFile str (f);
-
- m_opaque_sp->GetDescription (&str, level);
- str.EOL();
+ m_opaque_sp->GetDescription (description.get(), level);
+ description.get()->EOL();
}
+ else
+ description.Printf ("No value");
+
+ return true;
+}
+
+PyObject *
+SBBreakpointLocation::__repr__ ()
+{
+ SBStream description;
+ description.ref();
+ GetDescription ("full", description);
+ return PyString_FromString (description.GetData());
}
SBBreakpoint