diff options
Diffstat (limited to 'lldb/scripts/Python')
-rw-r--r-- | lldb/scripts/Python/interface/SBCommandReturnObject.i | 10 | ||||
-rw-r--r-- | lldb/scripts/Python/python-extensions.swig | 20 |
2 files changed, 28 insertions, 2 deletions
diff --git a/lldb/scripts/Python/interface/SBCommandReturnObject.i b/lldb/scripts/Python/interface/SBCommandReturnObject.i index e5f062c2240..e72c1e2731f 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 84c719c6364..29eae6d331c 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; |