Fix a potential bug resulting from the wrong assumption that SWIG puts out the __init__
method definition before other method definitions.  Instead, do without it and process
the class with IsValid() method definition in all possible states.


git-svn-id: https://llvm.org/svn/llvm-project/llvdb/trunk@132016 91177308-0d34-0410-b5e6-96231b3b80d8
diff --git a/scripts/Python/modify-python-lldb.py b/scripts/Python/modify-python-lldb.py
index 426a31a..fe7598e 100644
--- a/scripts/Python/modify-python-lldb.py
+++ b/scripts/Python/modify-python-lldb.py
@@ -133,10 +133,9 @@
 # method definition in order to insert the appropriate method(s) into the lldb
 # module.
 #
-# Assuming that SWIG puts out the __init__ method definition before other method
-# definitions, the FSM, while in NORMAL state, also checks the current input for
-# IsValid() definition, and inserts a __nonzero__() method definition to
-# implement truth value testing and the built-in operation bool().
+# The FSM, in all possible states, also checks the current input for IsValid()
+# definition, and inserts a __nonzero__() method definition to implement truth
+# value testing and the built-in operation bool().
 state = NORMAL
 for line in content.splitlines():
     if state == NORMAL:
@@ -157,10 +156,6 @@
             if cls in e:
                 # Adding support for eq and ne for the matched SB class.
                 state = (state | DEFINING_EQUALITY)
-        # Look for 'def IsValid(*args):', and once located, add implementation
-        # of truth value testing for objects by delegation.
-        elif isvalid_pattern.search(line):
-            print >> new_content, nonzero_def
     elif state > NORMAL:
         match = init_pattern.search(line)
         if match:
@@ -182,6 +177,11 @@
             # Next state will be NORMAL.
             state = NORMAL
 
+    # Look for 'def IsValid(*args):', and once located, add implementation
+    # of truth value testing for this object by delegation.
+    if isvalid_pattern.search(line):
+        print >> new_content, nonzero_def
+
     # Pass the original line of content to new_content.
     print >> new_content, line