summaryrefslogtreecommitdiffstats
path: root/lldb/source/API/SBCommandReturnObject.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/SBCommandReturnObject.cpp
parentfd02aa84dc5e5b96e44e1f93b4f57b206e6180b2 (diff)
downloadbcm5719-llvm-dde9cff32aee03e98a5ed91fc8425f241058c771.tar.gz
bcm5719-llvm-dde9cff32aee03e98a5ed91fc8425f241058c771.zip
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/SBCommandReturnObject.cpp')
-rw-r--r--lldb/source/API/SBCommandReturnObject.cpp40
1 files changed, 38 insertions, 2 deletions
diff --git a/lldb/source/API/SBCommandReturnObject.cpp b/lldb/source/API/SBCommandReturnObject.cpp
index 5742c5c93da..458ce504e3d 100644
--- a/lldb/source/API/SBCommandReturnObject.cpp
+++ b/lldb/source/API/SBCommandReturnObject.cpp
@@ -7,9 +7,10 @@
//
//===----------------------------------------------------------------------===//
-#include "lldb/Interpreter/CommandReturnObject.h"
-
#include "lldb/API/SBCommandReturnObject.h"
+#include "lldb/API/SBStream.h"
+
+#include "lldb/Interpreter/CommandReturnObject.h"
using namespace lldb;
using namespace lldb_private;
@@ -160,3 +161,38 @@ SBCommandReturnObject::SetLLDBObjectPtr (CommandReturnObject *ptr)
m_opaque_ap.reset (ptr);
}
+bool
+SBCommandReturnObject::GetDescription (SBStream &description)
+{
+ if (m_opaque_ap.get())
+ {
+ description.Printf ("Status: ");
+ lldb::ReturnStatus status = m_opaque_ap->GetStatus();
+ if (status == lldb::eReturnStatusStarted)
+ description.Printf ("Started");
+ else if (status == lldb::eReturnStatusInvalid)
+ description.Printf ("Invalid");
+ else if (m_opaque_ap->Succeeded())
+ description.Printf ("Success");
+ else
+ description.Printf ("Fail");
+
+ if (GetOutputSize() > 0)
+ description.Printf ("\nOutput Message:\n%s", GetOutput());
+
+ if (GetErrorSize() > 0)
+ description.Printf ("\nError Message:\n%s", GetError());
+ }
+ else
+ description.Printf ("No value");
+
+ return true;
+}
+
+PyObject *
+SBCommandReturnObject::__repr__ ()
+{
+ SBStream description;
+ GetDescription (description);
+ return PyString_FromString (description.GetData());
+}
OpenPOWER on IntegriCloud