[Lldb-commits] [lldb] r134543 - /lldb/trunk/scripts/Python/modify-python-lldb.py

Johnny Chen johnny.chen at apple.com
Wed Jul 6 14:55:45 PDT 2011


Author: johnny
Date: Wed Jul  6 16:55:45 2011
New Revision: 134543

URL: http://llvm.org/viewvc/llvm-project?rev=134543&view=rev
Log:
Add post-processing step to transform the docstring from 'char', i.e., 'char *', to 'str', i.e., Python string.

Modified:
    lldb/trunk/scripts/Python/modify-python-lldb.py

Modified: lldb/trunk/scripts/Python/modify-python-lldb.py
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/scripts/Python/modify-python-lldb.py?rev=134543&r1=134542&r2=134543&view=diff
==============================================================================
--- lldb/trunk/scripts/Python/modify-python-lldb.py (original)
+++ lldb/trunk/scripts/Python/modify-python-lldb.py Wed Jul  6 16:55:45 2011
@@ -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 @@
 
 # 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 @@
 # 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 @@
         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):





More information about the lldb-commits mailing list