aboutsummaryrefslogtreecommitdiff
path: root/lldb/scripts/Python/modify-python-lldb.py
diff options
context:
space:
mode:
authorJohnny Chen <johnny.chen@apple.com>2011-07-06 21:55:45 +0000
committerJohnny Chen <johnny.chen@apple.com>2011-07-06 21:55:45 +0000
commit102ac765f02bc29d2d47b2e3316cd29402dcdb28 (patch)
treefc06763952d71e401bc726ba28926708ff9ae065 /lldb/scripts/Python/modify-python-lldb.py
parent58f1c1275654dea46ec170da5734c91397b1855d (diff)
downloadllvm-102ac765f02bc29d2d47b2e3316cd29402dcdb28.zip
llvm-102ac765f02bc29d2d47b2e3316cd29402dcdb28.tar.gz
llvm-102ac765f02bc29d2d47b2e3316cd29402dcdb28.tar.bz2
Add post-processing step to transform the docstring from 'char', i.e., 'char *', to 'str', i.e., Python string.
llvm-svn: 134543
Diffstat (limited to 'lldb/scripts/Python/modify-python-lldb.py')
-rw-r--r--lldb/scripts/Python/modify-python-lldb.py24
1 files changed, 24 insertions, 0 deletions
diff --git a/lldb/scripts/Python/modify-python-lldb.py b/lldb/scripts/Python/modify-python-lldb.py
index 44aaf84..2e2c8be 100644
--- a/lldb/scripts/Python/modify-python-lldb.py
+++ b/lldb/scripts/Python/modify-python-lldb.py
@@ -13,6 +13,10 @@
# '#endif', the '#ifdef SWIG', the c comment marker, the trailing blank (SPC's)
# line, and the doxygen comment start marker.
#
+# In addition to the 'residues' removal during the cleanup step, it also
+# transforms the 'char' data type (which was actually 'char *' but the 'autodoc'
+# feature of swig removes ' *' from it into 'str' (as a Python str type).
+#
# It also calls SBDebugger.Initialize() to initialize the lldb debugger
# subsystem.
#
@@ -26,7 +30,9 @@ else:
# print "output_name is '" + output_name + "'"
+#
# Residues to be removed.
+#
c_endif_swig = "#endif"
c_ifdef_swig = "#ifdef SWIG"
c_comment_marker = "//------------"
@@ -37,6 +43,17 @@ doxygen_comment_start = re.compile("^\s*( /// ?)")
# When bracketed by the lines, the CLEANUP_DOCSTRING state (see below) is ON.
toggle_docstring_cleanup_line = ' """'
+def char_to_str_xform(line):
+ """This transforms the 'char', i.e, 'char *' to 'str', Python string."""
+ line = line.replace(' char', ' str')
+ line = line.replace('char ', 'str ')
+ return line
+
+#
+# The one-liner docstring also needs char_to_str transformation, btw.
+#
+one_liner_docstring_pattern = re.compile('^ """.*"""$')
+
#
# lldb_iter() should appear before our first SB* class definition.
#
@@ -236,9 +253,16 @@ for line in content.splitlines():
if doxygen_comment_match:
line = line.replace(doxygen_comment_match.group(1), '', 1)
+ line = char_to_str_xform(line)
+
# Note that the transition out of CLEANUP_DOCSTRING is handled at the
# beginning of this function already.
+ # This deals with one-liner docstring, for example, SBThread.GetName:
+ # """GetName(self) -> char""".
+ if one_liner_docstring_pattern.match(line):
+ line = char_to_str_xform(line)
+
# Look for 'def IsValid(*args):', and once located, add implementation
# of truth value testing for this object by delegation.
if isvalid_pattern.search(line):