diff options
author | Pavel Labath <pavel@labath.sk> | 2019-04-03 11:48:38 +0000 |
---|---|---|
committer | Pavel Labath <pavel@labath.sk> | 2019-04-03 11:48:38 +0000 |
commit | 4da5a1dbab579da5975de573719c50fd3c1faeab (patch) | |
tree | ebf2ba238469a703f9ab0aef2f3cb4c98b9f1d21 /lldb/scripts/Python/modify-python-lldb.py | |
parent | 02599de2e1e9688ed74e2d1080c4e4f73c6072af (diff) | |
download | llvm-4da5a1dbab579da5975de573719c50fd3c1faeab.zip llvm-4da5a1dbab579da5975de573719c50fd3c1faeab.tar.gz llvm-4da5a1dbab579da5975de573719c50fd3c1faeab.tar.bz2 |
modify-python-lldb.py: clean up __iter__ and __len__ support
Summary:
Instead of modifying the swig-generated code, just add the appropriate
methods to the interface files in order to get the swig to do the
generation for us.
This is a straight-forward move from the python script to the interface
files. The single class which has nontrivial handling in the script
(SBModule) has been left for a separate patch.
For the cases where I did not find any tests exercising the
iteration/length methods (i.e., no tests failed after I stopped emitting
them), I tried to add basic tests for that functionality.
Reviewers: zturner, jingham, amccarth
Subscribers: jdoerfert, lldb-commits
Differential Revision: https://reviews.llvm.org/D60119
llvm-svn: 357572
Diffstat (limited to 'lldb/scripts/Python/modify-python-lldb.py')
-rw-r--r-- | lldb/scripts/Python/modify-python-lldb.py | 39 |
1 files changed, 4 insertions, 35 deletions
diff --git a/lldb/scripts/Python/modify-python-lldb.py b/lldb/scripts/Python/modify-python-lldb.py index af51ae6..1e2784b 100644 --- a/lldb/scripts/Python/modify-python-lldb.py +++ b/lldb/scripts/Python/modify-python-lldb.py @@ -77,9 +77,6 @@ one_liner_docstring_pattern = re.compile( # This supports the iteration protocol. iter_def = " def __iter__(self): return lldb_iter(self, '%s', '%s')" -module_iter = " def module_iter(self): return lldb_iter(self, '%s', '%s')" -breakpoint_iter = " def breakpoint_iter(self): return lldb_iter(self, '%s', '%s')" -watchpoint_iter = " def watchpoint_iter(self): return lldb_iter(self, '%s', '%s')" section_iter = " def section_iter(self): return lldb_iter(self, '%s', '%s')" compile_unit_iter = " def compile_unit_iter(self): return lldb_iter(self, '%s', '%s')" @@ -100,28 +97,7 @@ symbol_in_section_iter_def = ''' # # This dictionary defines a mapping from classname to (getsize, getelem) tuple. # -d = {'SBBreakpoint': ('GetNumLocations', 'GetLocationAtIndex'), - 'SBCompileUnit': ('GetNumLineEntries', 'GetLineEntryAtIndex'), - 'SBDebugger': ('GetNumTargets', 'GetTargetAtIndex'), - 'SBModule': ('GetNumSymbols', 'GetSymbolAtIndex'), - 'SBProcess': ('GetNumThreads', 'GetThreadAtIndex'), - 'SBSection': ('GetNumSubSections', 'GetSubSectionAtIndex'), - 'SBThread': ('GetNumFrames', 'GetFrameAtIndex'), - - 'SBInstructionList': ('GetSize', 'GetInstructionAtIndex'), - 'SBStringList': ('GetSize', 'GetStringAtIndex',), - 'SBSymbolContextList': ('GetSize', 'GetContextAtIndex'), - 'SBTypeList': ('GetSize', 'GetTypeAtIndex'), - 'SBValueList': ('GetSize', 'GetValueAtIndex'), - - 'SBType': ('GetNumberChildren', 'GetChildAtIndex'), - 'SBValue': ('GetNumChildren', 'GetChildAtIndex'), - - # SBTarget needs special processing, see below. - 'SBTarget': {'module': ('GetNumModules', 'GetModuleAtIndex'), - 'breakpoint': ('GetNumBreakpoints', 'GetBreakpointAtIndex'), - 'watchpoint': ('GetNumWatchpoints', 'GetWatchpointAtIndex') - }, +d = {'SBModule': ('GetNumSymbols', 'GetSymbolAtIndex'), # SBModule has an additional section_iter(), see below. 'SBModule-section': ('GetNumSections', 'GetSectionAtIndex'), @@ -238,16 +214,9 @@ for line in content.splitlines(): if match: # We found the beginning of the __init__ method definition. # This is a good spot to insert the iter support. - # - # But note that SBTarget has three types of iterations. - if cls == "SBTarget": - new_content.add_line(module_iter % (d[cls]['module'])) - new_content.add_line(breakpoint_iter % (d[cls]['breakpoint'])) - new_content.add_line(watchpoint_iter % (d[cls]['watchpoint'])) - else: - if (state & DEFINING_ITERATOR): - new_content.add_line(iter_def % d[cls]) - new_content.add_line(len_def % d[cls][0]) + + new_content.add_line(iter_def % d[cls]) + new_content.add_line(len_def % d[cls][0]) # SBModule has extra SBSection, SBCompileUnit iterators and # symbol_in_section_iter()! |