================
@@ -0,0 +1,13 @@
+%extend lldb::SBAddressRangeList {
+#ifdef SWIGPYTHON
+    %pythoncode%{
+    def __len__(self):
+      '''Return the number of address ranges in a lldb.SBAddressRangeList 
object.'''
+      return self.GetSize()
+
+    def __iter__(self):
+      '''Iterate over all the address ranges in a lldb.SBAddressRangeList 
object.'''
+      return lldb_iter(self, 'GetSize', 'GetAddressRangeAtIndex')
+    %}
----------------
clayborg wrote:

We should add the ability to subscript a `SBAddressRangeList` object, and also 
use it as an iterable. So something like this should work in python:
```
function = ...; # Get a lldb.SBFunction somehow
ranges = function.GetRanges()
for range in ranges: # Implement iterable for this object
  print(range)
for i in ranges.GetSize():
  range = ranges[i] # Implement the subscripting extension
```
Other classes do this, we should copy that kind of code into this .i file

https://github.com/llvm/llvm-project/pull/92014
_______________________________________________
lldb-commits mailing list
lldb-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits

Reply via email to