1 %extend lldb::SBAddressRangeList { 2 #ifdef SWIGPYTHON 3 %pythoncode%{ 4 def __len__(self): 5 '''Return the number of address ranges in a lldb.SBAddressRangeList object.''' 6 return self.GetSize() 7 8 def __iter__(self): 9 '''Iterate over all the address ranges in a lldb.SBAddressRangeList object.''' 10 return lldb_iter(self, 'GetSize', 'GetAddressRangeAtIndex') 11 12 def __getitem__(self, idx): 13 '''Get the address range at a given index in an lldb.SBAddressRangeList object.''' 14 if not isinstance(idx, int): 15 raise TypeError("unsupported index type: %s" % type(idx)) 16 count = len(self) 17 if not (-count <= idx < count): 18 raise IndexError("list index out of range") 19 idx %= count 20 return self.GetAddressRangeAtIndex(idx) 21 22 def __repr__(self): 23 import lldb 24 stream = lldb.SBStream() 25 self.GetDescription(stream, lldb.target if lldb.target else lldb.SBTarget()) 26 return stream.GetData() 27 %} 28 #endif 29 } 30