summaryrefslogtreecommitdiff
path: root/lldb/source/API/SBError.cpp
diff options
context:
space:
mode:
authorCaroline Tice <ctice@apple.com>2010-09-20 05:20:02 +0000
committerCaroline Tice <ctice@apple.com>2010-09-20 05:20:02 +0000
commitdde9cff32aee03e98a5ed91fc8425f241058c771 (patch)
treed207dc97f063865b8addf9c4b01d6cbed2386f9e /lldb/source/API/SBError.cpp
parentfd02aa84dc5e5b96e44e1f93b4f57b206e6180b2 (diff)
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. llvm-svn: 114321
Diffstat (limited to 'lldb/source/API/SBError.cpp')
-rw-r--r--lldb/source/API/SBError.cpp28
1 files changed, 28 insertions, 0 deletions
diff --git a/lldb/source/API/SBError.cpp b/lldb/source/API/SBError.cpp
index e91c94d2c8fc..136561981b6e 100644
--- a/lldb/source/API/SBError.cpp
+++ b/lldb/source/API/SBError.cpp
@@ -8,7 +8,9 @@
//===----------------------------------------------------------------------===//
#include "lldb/API/SBError.h"
+#include "lldb/API/SBStream.h"
#include "lldb/Core/Error.h"
+
#include <stdarg.h>
using namespace lldb;
@@ -178,3 +180,29 @@ SBError::operator*() const
return *m_opaque_ap;
}
+bool
+SBError::GetDescription (SBStream &description)
+{
+ if (m_opaque_ap.get())
+ {
+ if (Success())
+ description.Printf ("Status: Success");
+ else
+ {
+ const char * err_string = GetCString();
+ description.Printf ("Status: Error: %s", (err_string != NULL ? err_string : ""));
+ }
+ }
+ else
+ description.Printf ("No value");
+
+ return true;
+}
+
+PyObject *
+SBError::__repr__ ()
+{
+ SBStream description;
+ GetDescription (description);
+ return PyString_FromString (description.GetData());
+}