aboutsummaryrefslogtreecommitdiff
path: root/lldb/scripts/Python
diff options
context:
space:
mode:
authorEnrico Granata <egranata@apple.com>2013-03-25 17:37:39 +0000
committerEnrico Granata <egranata@apple.com>2013-03-25 17:37:39 +0000
commitceba071330ec0004d5d44cdb0ba9728df231c223 (patch)
treee67043d513f9fe2bf568d74840f0c0e8bfbfdcf3 /lldb/scripts/Python
parent51cb2fa1c3e867eef7df91135d56d33dded0fb39 (diff)
downloadllvm-ceba071330ec0004d5d44cdb0ba9728df231c223.zip
llvm-ceba071330ec0004d5d44cdb0ba9728df231c223.tar.gz
llvm-ceba071330ec0004d5d44cdb0ba9728df231c223.tar.bz2
- Masking out SBCommandReturnObject::Printf() from the Python layer because SWIG and varargs do not get along well.
It is replaced by a Print("str") call which is equivalent to Printf("%s","str") - Providing file-like behavior for SBStream with appropriate extension write() and flush() calls, plus documenting that these are only meant and only exist for Python Documenting the file-like behavior on our website llvm-svn: 177877
Diffstat (limited to 'lldb/scripts/Python')
-rw-r--r--lldb/scripts/Python/interface/SBCommandReturnObject.i10
-rw-r--r--lldb/scripts/Python/python-extensions.swig20
2 files changed, 28 insertions, 2 deletions
diff --git a/lldb/scripts/Python/interface/SBCommandReturnObject.i b/lldb/scripts/Python/interface/SBCommandReturnObject.i
index e5f062c..e72c1e2 100644
--- a/lldb/scripts/Python/interface/SBCommandReturnObject.i
+++ b/lldb/scripts/Python/interface/SBCommandReturnObject.i
@@ -86,8 +86,14 @@ public:
void
PutCString(const char* string, int len = -1);
- size_t
- Printf(const char* format, ...);
+ // wrapping the variadic Printf() with a plain Print()
+ // because it is hard to support varargs in SWIG bridgings
+ %extend {
+ void Print (const char* str)
+ {
+ self->Printf("%s", str);
+ }
+ }
};
diff --git a/lldb/scripts/Python/python-extensions.swig b/lldb/scripts/Python/python-extensions.swig
index 84c719c..29eae6d 100644
--- a/lldb/scripts/Python/python-extensions.swig
+++ b/lldb/scripts/Python/python-extensions.swig
@@ -68,6 +68,12 @@
else
return PyString_FromString("");
}
+
+ /* the write() and flush() calls are not part of the SB API proper, and are solely for Python usage
+ they are meant to make an SBCommandReturnObject into a file-like object so that instructions of the sort
+ print >>sb_command_return_object, "something"
+ will work correctly */
+
void lldb::SBCommandReturnObject::write (const char* str)
{
if (str)
@@ -272,6 +278,20 @@
return PyString_FromString("");
}
}
+%extend lldb::SBStream {
+ /* the write() and flush() calls are not part of the SB API proper, and are solely for Python usage
+ they are meant to make an SBStream into a file-like object so that instructions of the sort
+ print >>sb_stream, "something"
+ will work correctly */
+
+ void lldb::SBStream::write (const char* str)
+ {
+ if (str)
+ $self->Printf("%s",str);
+ }
+ void lldb::SBStream::flush ()
+ {}
+}
%extend lldb::SBSymbol {
PyObject *lldb::SBSymbol::__str__ (){
lldb::SBStream description;