From 93e7b3a8bdbe1a9edb1c3d6524ed858377b35e62 Mon Sep 17 00:00:00 2001 From: Johnny Chen Date: Tue, 24 May 2011 22:29:49 +0000 Subject: [PATCH] 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. llvm-svn: 132016 --- lldb/scripts/Python/modify-python-lldb.py | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/lldb/scripts/Python/modify-python-lldb.py b/lldb/scripts/Python/modify-python-lldb.py index 426a31ad008e..fe7598e0f5ac 100644 --- a/lldb/scripts/Python/modify-python-lldb.py +++ b/lldb/scripts/Python/modify-python-lldb.py @@ -133,10 +133,9 @@ lldb_iter_defined = False; # 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 @@ for line in content.splitlines(): 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 @@ for line in content.splitlines(): # 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