xref: /freebsd/contrib/llvm-project/lldb/bindings/interface/SBSymbolContextListExtensions.i (revision 06c3fb2749bda94cb5201f81ffdb8fa6c3161b2e)
1 STRING_EXTENSION_OUTSIDE(SBSymbolContextList)
2 
3 %extend lldb::SBSymbolContextList {
4 #ifdef SWIGPYTHON
5     %pythoncode %{
6         def __iter__(self):
7             '''Iterate over all symbol contexts in a lldb.SBSymbolContextList
8             object.'''
9             return lldb_iter(self, 'GetSize', 'GetContextAtIndex')
10 
11         def __len__(self):
12             return int(self.GetSize())
13 
14         def __getitem__(self, key):
15             count = len(self)
16             if isinstance(key, int):
17                 if -count <= key < count:
18                     key %= count
19                     return self.GetContextAtIndex(key)
20                 else:
21                     raise IndexError
22             raise TypeError
23 
24         def get_module_array(self):
25             a = []
26             for i in range(len(self)):
27                 obj = self.GetContextAtIndex(i).module
28                 if obj:
29                     a.append(obj)
30             return a
31 
32         def get_compile_unit_array(self):
33             a = []
34             for i in range(len(self)):
35                 obj = self.GetContextAtIndex(i).compile_unit
36                 if obj:
37                     a.append(obj)
38             return a
39         def get_function_array(self):
40             a = []
41             for i in range(len(self)):
42                 obj = self.GetContextAtIndex(i).function
43                 if obj:
44                     a.append(obj)
45             return a
46         def get_block_array(self):
47             a = []
48             for i in range(len(self)):
49                 obj = self.GetContextAtIndex(i).block
50                 if obj:
51                     a.append(obj)
52             return a
53         def get_symbol_array(self):
54             a = []
55             for i in range(len(self)):
56                 obj = self.GetContextAtIndex(i).symbol
57                 if obj:
58                     a.append(obj)
59             return a
60         def get_line_entry_array(self):
61             a = []
62             for i in range(len(self)):
63                 obj = self.GetContextAtIndex(i).line_entry
64                 if obj:
65                     a.append(obj)
66             return a
67 
68         modules = property(get_module_array, None, doc='''Returns a list() of lldb.SBModule objects, one for each module in each SBSymbolContext object in this list.''')
69         compile_units = property(get_compile_unit_array, None, doc='''Returns a list() of lldb.SBCompileUnit objects, one for each compile unit in each SBSymbolContext object in this list.''')
70         functions = property(get_function_array, None, doc='''Returns a list() of lldb.SBFunction objects, one for each function in each SBSymbolContext object in this list.''')
71         blocks = property(get_block_array, None, doc='''Returns a list() of lldb.SBBlock objects, one for each block in each SBSymbolContext object in this list.''')
72         line_entries = property(get_line_entry_array, None, doc='''Returns a list() of lldb.SBLineEntry objects, one for each line entry in each SBSymbolContext object in this list.''')
73         symbols = property(get_symbol_array, None, doc='''Returns a list() of lldb.SBSymbol objects, one for each symbol in each SBSymbolContext object in this list.''')
74     %}
75 #endif
76 }
77