Initial checkin of lldb code from internal Apple repo.


git-svn-id: https://llvm.org/svn/llvm-project/llvdb/trunk@105619 91177308-0d34-0410-b5e6-96231b3b80d8
diff --git a/scripts/Python/edit-swig-python-wrapper-file.py b/scripts/Python/edit-swig-python-wrapper-file.py
new file mode 100644
index 0000000..a8c4323
--- /dev/null
+++ b/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"