diff options
author | Caroline Tice <ctice@apple.com> | 2010-09-20 05:20:02 +0000 |
---|---|---|
committer | Caroline Tice <ctice@apple.com> | 2010-09-20 05:20:02 +0000 |
commit | dde9cff32aee03e98a5ed91fc8425f241058c771 (patch) | |
tree | d207dc97f063865b8addf9c4b01d6cbed2386f9e /lldb/source/API/SBFileSpec.cpp | |
parent | fd02aa84dc5e5b96e44e1f93b4f57b206e6180b2 (diff) | |
download | bcm5719-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/SBFileSpec.cpp')
-rw-r--r-- | lldb/source/API/SBFileSpec.cpp | 28 |
1 files changed, 28 insertions, 0 deletions
diff --git a/lldb/source/API/SBFileSpec.cpp b/lldb/source/API/SBFileSpec.cpp index 5ec93f3b4ff..1edd9468b50 100644 --- a/lldb/source/API/SBFileSpec.cpp +++ b/lldb/source/API/SBFileSpec.cpp @@ -8,6 +8,7 @@ //===----------------------------------------------------------------------===// #include "lldb/API/SBFileSpec.h" +#include "lldb/API/SBStream.h" #include "lldb/Core/FileSpec.h" using namespace lldb; @@ -138,3 +139,30 @@ SBFileSpec::SetFileSpec (const lldb_private::FileSpec& fs) m_opaque_ap.reset (new FileSpec (fs)); } +bool +SBFileSpec::GetDescription (SBStream &description) +{ + if (m_opaque_ap.get()) + { + const char *filename = GetFilename(); + const char *dir_name = GetDirectory(); + if (!filename && !dir_name) + description.Printf ("No value"); + else if (!dir_name) + description.Printf ("%s", filename); + else + description.Printf ("%s/%s", dir_name, filename); + } + else + description.Printf ("No value"); + + return true; +} + +PyObject * +SBFileSpec::__repr__ () +{ + SBStream description; + GetDescription (description); + return PyString_FromString (description.GetData()); +} |