<rdar://problem/12462744> Implement a new SBDeclaration class to wrap an lldb_private::Declaration - make a GetDeclaration() API on SBValue to return a declaration. This will only work for vroot variables as they are they only objects for which we currently provide a valid Declaration
git-svn-id: https://llvm.org/svn/llvm-project/lldb/trunk@165672 91177308-0d34-0410-b5e6-96231b3b80d8
diff --git a/scripts/Python/python-extensions.swig b/scripts/Python/python-extensions.swig
index 19868fb..89ad1b2 100644
--- a/scripts/Python/python-extensions.swig
+++ b/scripts/Python/python-extensions.swig
@@ -111,6 +111,20 @@
return PyString_FromString("");
}
}
+%extend lldb::SBDeclaration {
+ PyObject *lldb::SBDeclaration::__str__ (){
+ lldb::SBStream description;
+ $self->GetDescription (description);
+ const char *desc = description.GetData();
+ size_t desc_len = description.GetSize();
+ if (desc_len > 0 && (desc[desc_len-1] == '\n' || desc[desc_len-1] == '\r'))
+ --desc_len;
+ if (desc_len > 0)
+ return PyString_FromStringAndSize (desc, desc_len);
+ else
+ return PyString_FromString("");
+ }
+}
%extend lldb::SBError {
PyObject *lldb::SBError::__str__ (){
lldb::SBStream description;