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
This commit is contained in:
Caroline Tice
2010-09-20 05:20:02 +00:00
parent fd02aa84dc
commit dde9cff32a
49 changed files with 822 additions and 28 deletions

View File

@@ -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 @@ SBTarget::Disassemble (const char *function_name, const char *module_name)
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());
}