diff options
author | Enrico Granata <egranata@apple.com> | 2013-05-02 17:29:04 +0000 |
---|---|---|
committer | Enrico Granata <egranata@apple.com> | 2013-05-02 17:29:04 +0000 |
commit | e55f77aec8937d73c2268d5a01c1eb8adb49757c (patch) | |
tree | 9171888d38af4009feb4070e0ae960fb3c65e503 /lldb/scripts | |
parent | 9ee5840de4e739bd1f03b54254aac92a4c8ea26a (diff) | |
download | bcm5719-llvm-e55f77aec8937d73c2268d5a01c1eb8adb49757c.tar.gz bcm5719-llvm-e55f77aec8937d73c2268d5a01c1eb8adb49757c.zip |
<rdar://problem/13499317>
Enabling Python commands to produce Unicode output via:
result.PutCString(u”whatever”)
llvm-svn: 180930
Diffstat (limited to 'lldb/scripts')
-rw-r--r-- | lldb/scripts/Python/interface/SBCommandReturnObject.i | 2 | ||||
-rw-r--r-- | lldb/scripts/Python/python-typemaps.swig | 23 |
2 files changed, 24 insertions, 1 deletions
diff --git a/lldb/scripts/Python/interface/SBCommandReturnObject.i b/lldb/scripts/Python/interface/SBCommandReturnObject.i index e72c1e2731f..7cec06943bf 100644 --- a/lldb/scripts/Python/interface/SBCommandReturnObject.i +++ b/lldb/scripts/Python/interface/SBCommandReturnObject.i @@ -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 diff --git a/lldb/scripts/Python/python-typemaps.swig b/lldb/scripts/Python/python-typemaps.swig index 1a67f7b4971..8af1446aef3 100644 --- a/lldb/scripts/Python/python-typemaps.swig +++ b/lldb/scripts/Python/python-typemaps.swig @@ -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; + } +} |