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
This commit is contained in:
Johnny Chen 2011-05-24 22:29:49 +00:00
parent d4562566b4
commit 93e7b3a8bd
1 changed files with 8 additions and 8 deletions

View File

@ -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