[Lldb-commits] [lldb] r180930 - <rdar://problem/13499317>
Enrico Granata
egranata at apple.com
Thu May 2 10:29:04 PDT 2013
Author: enrico
Date: Thu May 2 12:29:04 2013
New Revision: 180930
URL: http://llvm.org/viewvc/llvm-project?rev=180930&view=rev
Log:
<rdar://problem/13499317>
Enabling Python commands to produce Unicode output via:
result.PutCString(u”whatever”)
Modified:
lldb/trunk/scripts/Python/interface/SBCommandReturnObject.i
lldb/trunk/scripts/Python/python-typemaps.swig
lldb/trunk/source/API/SBCommandReturnObject.cpp
Modified: lldb/trunk/scripts/Python/interface/SBCommandReturnObject.i
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/scripts/Python/interface/SBCommandReturnObject.i?rev=180930&r1=180929&r2=180930&view=diff
==============================================================================
--- lldb/trunk/scripts/Python/interface/SBCommandReturnObject.i (original)
+++ lldb/trunk/scripts/Python/interface/SBCommandReturnObject.i Thu May 2 12:29:04 2013
@@ -84,7 +84,7 @@ public:
SetImmediateErrorFile (FILE *fh);
void
- PutCString(const char* string, int len = -1);
+ PutCString(const char* string, int len);
// wrapping the variadic Printf() with a plain Print()
// because it is hard to support varargs in SWIG bridgings
Modified: lldb/trunk/scripts/Python/python-typemaps.swig
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/scripts/Python/python-typemaps.swig?rev=180930&r1=180929&r2=180930&view=diff
==============================================================================
--- lldb/trunk/scripts/Python/python-typemaps.swig (original)
+++ lldb/trunk/scripts/Python/python-typemaps.swig Thu May 2 12:29:04 2013
@@ -442,3 +442,26 @@
#endif
$result = PyFile_FromFile($1, const_cast<char*>(""), mode, fclose);
}
+
+%typemap(in) (const char* string, int len) {
+ if ($input == Py_None)
+ {
+ $1 = NULL;
+ $2 = 0;
+ }
+ else if (PyUnicode_Check($input))
+ {
+ $1 = PyString_AsString(PyUnicode_AsUTF8String($input));
+ $2 = strlen($1);
+ }
+ else if (PyString_Check($input))
+ {
+ $1 = PyString_AsString($input);
+ $2 = PyString_Size($input);
+ }
+ else
+ {
+ PyErr_SetString(PyExc_TypeError,"not a string-like object");
+ return NULL;
+ }
+}
Modified: lldb/trunk/source/API/SBCommandReturnObject.cpp
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/API/SBCommandReturnObject.cpp?rev=180930&r1=180929&r2=180930&view=diff
==============================================================================
--- lldb/trunk/source/API/SBCommandReturnObject.cpp (original)
+++ lldb/trunk/source/API/SBCommandReturnObject.cpp Thu May 2 12:29:04 2013
@@ -281,7 +281,7 @@ SBCommandReturnObject::PutCString(const
{
if (m_opaque_ap.get())
{
- if (len == 0)
+ if (len == 0 || string == NULL || *string == 0)
{
return;
}
More information about the lldb-commits
mailing list