Skip to content

Commit

Permalink
[swig] Don't mess with swig internals.
Browse files Browse the repository at this point in the history
As of SWIG 4.0, __swig_getmethods__ and __swig_setmethods__ are no
longer defined. It appears that there's no need to mess with these
internals, we can simplify define the corresponding properties inline.

Originally I wanted to use the swig extension %attribute and
%attributeref to define properties. However, I couldn't find a way to
add documentation to these attributes. Since we already had the
properties defined inline, we might as well keep them.

Differential revision: https://reviews.llvm.org/D63530

llvm-svn: 364974
  • Loading branch information
JDevlieghere committed Jul 2, 2019
1 parent 54c7907 commit 89b6584
Show file tree
Hide file tree
Showing 31 changed files with 287 additions and 842 deletions.
41 changes: 10 additions & 31 deletions lldb/scripts/interface/SBAddress.i
Original file line number Diff line number Diff line change
Expand Up @@ -162,37 +162,16 @@ public:
'''Convert the address to an hex string'''
return '0x%x' % int(self)

__swig_getmethods__["module"] = GetModule
if _newclass: module = property(GetModule, None, doc='''A read only property that returns an lldb object that represents the module (lldb.SBModule) that this address resides within.''')

__swig_getmethods__["compile_unit"] = GetCompileUnit
if _newclass: compile_unit = property(GetCompileUnit, None, doc='''A read only property that returns an lldb object that represents the compile unit (lldb.SBCompileUnit) that this address resides within.''')

__swig_getmethods__["line_entry"] = GetLineEntry
if _newclass: line_entry = property(GetLineEntry, None, doc='''A read only property that returns an lldb object that represents the line entry (lldb.SBLineEntry) that this address resides within.''')

__swig_getmethods__["function"] = GetFunction
if _newclass: function = property(GetFunction, None, doc='''A read only property that returns an lldb object that represents the function (lldb.SBFunction) that this address resides within.''')

__swig_getmethods__["block"] = GetBlock
if _newclass: block = property(GetBlock, None, doc='''A read only property that returns an lldb object that represents the block (lldb.SBBlock) that this address resides within.''')

__swig_getmethods__["symbol"] = GetSymbol
if _newclass: symbol = property(GetSymbol, None, doc='''A read only property that returns an lldb object that represents the symbol (lldb.SBSymbol) that this address resides within.''')

__swig_getmethods__["offset"] = GetOffset
if _newclass: offset = property(GetOffset, None, doc='''A read only property that returns the section offset in bytes as an integer.''')

__swig_getmethods__["section"] = GetSection
if _newclass: section = property(GetSection, None, doc='''A read only property that returns an lldb object that represents the section (lldb.SBSection) that this address resides within.''')

__swig_getmethods__["file_addr"] = GetFileAddress
if _newclass: file_addr = property(GetFileAddress, None, doc='''A read only property that returns file address for the section as an integer. This is the address that represents the address as it is found in the object file that defines it.''')

__swig_getmethods__["load_addr"] = __get_load_addr_property__
__swig_setmethods__["load_addr"] = __set_load_addr_property__
if _newclass: load_addr = property(__get_load_addr_property__, __set_load_addr_property__, doc='''A read/write property that gets/sets the SBAddress using load address. The setter resolves SBAddress using the SBTarget from lldb.target so this property can ONLY be used in the interactive script interpreter (i.e. under the lldb script command) and not in Python based commands, or breakpoint commands.''')

module = property(GetModule, None, doc='''A read only property that returns an lldb object that represents the module (lldb.SBModule) that this address resides within.''')
compile_unit = property(GetCompileUnit, None, doc='''A read only property that returns an lldb object that represents the compile unit (lldb.SBCompileUnit) that this address resides within.''')
line_entry = property(GetLineEntry, None, doc='''A read only property that returns an lldb object that represents the line entry (lldb.SBLineEntry) that this address resides within.''')
function = property(GetFunction, None, doc='''A read only property that returns an lldb object that represents the function (lldb.SBFunction) that this address resides within.''')
block = property(GetBlock, None, doc='''A read only property that returns an lldb object that represents the block (lldb.SBBlock) that this address resides within.''')
symbol = property(GetSymbol, None, doc='''A read only property that returns an lldb object that represents the symbol (lldb.SBSymbol) that this address resides within.''')
offset = property(GetOffset, None, doc='''A read only property that returns the section offset in bytes as an integer.''')
section = property(GetSection, None, doc='''A read only property that returns an lldb object that represents the section (lldb.SBSection) that this address resides within.''')
file_addr = property(GetFileAddress, None, doc='''A read only property that returns file address for the section as an integer. This is the address that represents the address as it is found in the object file that defines it.''')
load_addr = property(__get_load_addr_property__, __set_load_addr_property__, doc='''A read/write property that gets/sets the SBAddress using load address. The setter resolves SBAddress using the SBTarget from lldb.target so this property can ONLY be used in the interactive script interpreter (i.e. under the lldb script command) and not in Python based commands, or breakpoint commands.''')
%}

};
Expand Down
35 changes: 9 additions & 26 deletions lldb/scripts/interface/SBBlock.i
Original file line number Diff line number Diff line change
Expand Up @@ -143,32 +143,15 @@ public:
def get_call_site(self):
return declaration(self.GetInlinedCallSiteFile(), self.GetInlinedCallSiteLine(), self.GetInlinedCallSiteColumn())

__swig_getmethods__["parent"] = GetParent
if _newclass: parent = property(GetParent, None, doc='''A read only property that returns the same result as GetParent().''')

__swig_getmethods__["first_child"] = GetFirstChild
if _newclass: first_child = property(GetFirstChild, None, doc='''A read only property that returns the same result as GetFirstChild().''')

__swig_getmethods__["call_site"] = get_call_site
if _newclass: call_site = property(get_call_site, None, doc='''A read only property that returns a lldb.declaration object that contains the inlined call site file, line and column.''')

__swig_getmethods__["sibling"] = GetSibling
if _newclass: sibling = property(GetSibling, None, doc='''A read only property that returns the same result as GetSibling().''')

__swig_getmethods__["name"] = GetInlinedName
if _newclass: name = property(GetInlinedName, None, doc='''A read only property that returns the same result as GetInlinedName().''')

__swig_getmethods__["inlined_block"] = GetContainingInlinedBlock
if _newclass: inlined_block = property(GetContainingInlinedBlock, None, doc='''A read only property that returns the same result as GetContainingInlinedBlock().''')

__swig_getmethods__["range"] = get_ranges_access_object
if _newclass: range = property(get_ranges_access_object, None, doc='''A read only property that allows item access to the address ranges for a block by integer (range = block.range[0]) and by lldb.SBAdddress (find the range that contains the specified lldb.SBAddress like "pc_range = lldb.frame.block.range[frame.addr]").''')

__swig_getmethods__["ranges"] = get_ranges_array
if _newclass: ranges = property(get_ranges_array, None, doc='''A read only property that returns a list() object that contains all of the address ranges for the block.''')

__swig_getmethods__["num_ranges"] = GetNumRanges
if _newclass: num_ranges = property(GetNumRanges, None, doc='''A read only property that returns the same result as GetNumRanges().''')
parent = property(GetParent, None, doc='''A read only property that returns the same result as GetParent().''')
first_child = property(GetFirstChild, None, doc='''A read only property that returns the same result as GetFirstChild().''')
call_site = property(get_call_site, None, doc='''A read only property that returns a lldb.declaration object that contains the inlined call site file, line and column.''')
sibling = property(GetSibling, None, doc='''A read only property that returns the same result as GetSibling().''')
name = property(GetInlinedName, None, doc='''A read only property that returns the same result as GetInlinedName().''')
inlined_block = property(GetContainingInlinedBlock, None, doc='''A read only property that returns the same result as GetContainingInlinedBlock().''')
range = property(get_ranges_access_object, None, doc='''A read only property that allows item access to the address ranges for a block by integer (range = block.range[0]) and by lldb.SBAdddress (find the range that contains the specified lldb.SBAddress like "pc_range = lldb.frame.block.range[frame.addr]").''')
ranges = property(get_ranges_array, None, doc='''A read only property that returns a list() object that contains all of the address ranges for the block.''')
num_ranges = property(GetNumRanges, None, doc='''A read only property that returns the same result as GetNumRanges().''')
%}

};
Expand Down
26 changes: 6 additions & 20 deletions lldb/scripts/interface/SBBreakpoint.i
Original file line number Diff line number Diff line change
Expand Up @@ -286,26 +286,12 @@ public:
object.'''
return self.GetNumLocations()

__swig_getmethods__["locations"] = get_breakpoint_location_list
if _newclass: locations = property(get_breakpoint_location_list, None, doc='''A read only property that returns a list() of lldb.SBBreakpointLocation objects for this breakpoint.''')

__swig_getmethods__["location"] = get_locations_access_object
if _newclass: location = property(get_locations_access_object, None, doc='''A read only property that returns an object that can access locations by index (not location ID) (location = bkpt.location[12]).''')

__swig_getmethods__["id"] = GetID
if _newclass: id = property(GetID, None, doc='''A read only property that returns the ID of this breakpoint.''')

__swig_getmethods__["enabled"] = IsEnabled
__swig_setmethods__["enabled"] = SetEnabled
if _newclass: enabled = property(IsEnabled, SetEnabled, doc='''A read/write property that configures whether this breakpoint is enabled or not.''')

__swig_getmethods__["one_shot"] = IsOneShot
__swig_setmethods__["one_shot"] = SetOneShot
if _newclass: one_shot = property(IsOneShot, SetOneShot, doc='''A read/write property that configures whether this breakpoint is one-shot (deleted when hit) or not.''')

__swig_getmethods__["num_locations"] = GetNumLocations
if _newclass: num_locations = property(GetNumLocations, None, doc='''A read only property that returns the count of locations of this breakpoint.''')

locations = property(get_breakpoint_location_list, None, doc='''A read only property that returns a list() of lldb.SBBreakpointLocation objects for this breakpoint.''')
location = property(get_locations_access_object, None, doc='''A read only property that returns an object that can access locations by index (not location ID) (location = bkpt.location[12]).''')
id = property(GetID, None, doc='''A read only property that returns the ID of this breakpoint.''')
enabled = property(IsEnabled, SetEnabled, doc='''A read/write property that configures whether this breakpoint is enabled or not.''')
one_shot = property(IsOneShot, SetOneShot, doc='''A read/write property that configures whether this breakpoint is one-shot (deleted when hit) or not.''')
num_locations = property(GetNumLocations, None, doc='''A read only property that returns the count of locations of this breakpoint.''')
%}


Expand Down
7 changes: 2 additions & 5 deletions lldb/scripts/interface/SBCompileUnit.i
Original file line number Diff line number Diff line change
Expand Up @@ -126,11 +126,8 @@ public:
object.'''
return self.GetNumLineEntries()

__swig_getmethods__["file"] = GetFileSpec
if _newclass: file = property(GetFileSpec, None, doc='''A read only property that returns the same result an lldb object that represents the source file (lldb.SBFileSpec) for the compile unit.''')

__swig_getmethods__["num_line_entries"] = GetNumLineEntries
if _newclass: num_line_entries = property(GetNumLineEntries, None, doc='''A read only property that returns the number of line entries in a compile unit as an integer.''')
file = property(GetFileSpec, None, doc='''A read only property that returns the same result an lldb object that represents the source file (lldb.SBFileSpec) for the compile unit.''')
num_line_entries = property(GetNumLineEntries, None, doc='''A read only property that returns the number of line entries in a compile unit as an integer.''')
%}
};

Expand Down
Loading

0 comments on commit 89b6584

Please sign in to comment.