[NFC][Coroutines] Use structured binding with llvm::enumerate in CoroSplit (#116879)
[llvm-project.git] / lldb / bindings / interface / SBAddressRangeListExtensions.i
blobe281a84d73d27dfeaeb718f6ee28b6af64575ae2
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()
8 def __iter__(self):
9 '''Iterate over all the address ranges in a lldb.SBAddressRangeList object.'''
10 return lldb_iter(self, 'GetSize', 'GetAddressRangeAtIndex')
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)
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()
28 #endif