summaryrefslogtreecommitdiffstats
path: root/lldb/scripts/Python/edit-swig-python-wrapper-file.py
diff options
context:
space:
mode:
authorChris Lattner <sabre@nondot.org>2010-06-08 16:52:24 +0000
committerChris Lattner <sabre@nondot.org>2010-06-08 16:52:24 +0000
commit30fdc8d841c9d24ac5f3d452b6ece84ee0ac991c (patch)
treef70013106f6a461a14abcd71c65f48a95a2979a6 /lldb/scripts/Python/edit-swig-python-wrapper-file.py
parent312c4c799da215b337f790fda330f70c4aa757cf (diff)
downloadbcm5719-llvm-30fdc8d841c9d24ac5f3d452b6ece84ee0ac991c.tar.gz
bcm5719-llvm-30fdc8d841c9d24ac5f3d452b6ece84ee0ac991c.zip
Initial checkin of lldb code from internal Apple repo.
llvm-svn: 105619
Diffstat (limited to 'lldb/scripts/Python/edit-swig-python-wrapper-file.py')
-rw-r--r--lldb/scripts/Python/edit-swig-python-wrapper-file.py58
1 files changed, 58 insertions, 0 deletions
diff --git a/lldb/scripts/Python/edit-swig-python-wrapper-file.py b/lldb/scripts/Python/edit-swig-python-wrapper-file.py
new file mode 100644
index 00000000000..a8c43239471
--- /dev/null
+++ b/lldb/scripts/Python/edit-swig-python-wrapper-file.py
@@ -0,0 +1,58 @@
+#
+# edit-swig-python-wrapper-file.py
+#
+# This script performs some post-processing editing on the C++ file that
+# SWIG generates for python, after running on 'lldb.swig'. In
+# particular, the types SWIGTYPE_p_SBThread and SWIGTYPE_p_SBTarget are
+# being used, when the types that *should* be used are
+# SWIGTYPE_p_lldb__SBThread and SWIGTYPE_p_lldb__SBTarget.
+# This script goes through the C++ file SWIG generated, reading it in line
+# by line and doing a search-and-replace for these strings.
+#
+
+
+import os
+
+full_input_name = os.environ["SCRIPT_INPUT_FILE_1"];
+full_output_name = full_input_name + ".edited"
+
+try:
+ f_in = open (full_input_name, 'r')
+except IOError:
+ print "Error: Unable to open file for reading: " + full_input_name
+else:
+ try:
+ f_out = open (full_output_name, 'w')
+ except IOError:
+ print "Error: Unable to open file for writing: " + full_output_name
+ else:
+ target_typedef_found = False
+ thread_typedef_found = False
+
+ try:
+ line = f_in.readline()
+ except IOError:
+ print "Error occurred while reading file."
+ else:
+ while line:
+ #
+ #
+ if (line.find ("SWIGTYPE_p_SBTarget")):
+ if (line.find ("define") < 0):
+ line = line.replace ("SWIGTYPE_p_SBTarget",
+ "SWIGTYPE_p_lldb__SBTarget")
+ if (line.find ("SWIGTYPE_p_SBThread")):
+ if (line.find ("define") < 0):
+ line = line.replace ("SWIGTYPE_p_SBThread",
+ "SWIGTYPE_p_lldb__SBThread")
+ f_out.write (line)
+ try:
+ line = f_in.readline()
+ except IOError:
+ print "Error occurred while reading file."
+
+ try:
+ f_in.close()
+ f_out.close()
+ except:
+ print "Error occurred while closing files"
OpenPOWER on IntegriCloud