[NFC][Coroutines] Use structured binding with llvm::enumerate in CoroSplit (#116879)
[llvm-project.git] / lldb / bindings / interface / SBTypeEnumMemberExtensions.i
blob9f0e16afcfd8af0087a812ea915f897e5b10de99
1 STRING_EXTENSION_LEVEL_OUTSIDE(SBTypeEnumMember, lldb::eDescriptionLevelBrief)
2 %extend lldb::SBTypeEnumMember {
3 #ifdef SWIGPYTHON
4 %pythoncode %{
5 def __iter__(self):
6 '''Iterate over all members in a lldb.SBTypeEnumMemberList object.'''
7 return lldb_iter(self, 'GetSize', 'GetTypeEnumMemberAtIndex')
9 def __len__(self):
10 '''Return the number of members in a lldb.SBTypeEnumMemberList object.'''
11 return self.GetSize()
13 name = property(GetName, None, doc='''A read only property that returns the name for this enum member as a string.''')
14 type = property(GetType, None, doc='''A read only property that returns an lldb object that represents the type (lldb.SBType) for this enum member.''')
15 signed = property(GetValueAsSigned, None, doc='''A read only property that returns the value of this enum member as a signed integer.''')
16 unsigned = property(GetValueAsUnsigned, None, doc='''A read only property that returns the value of this enum member as a unsigned integer.''')
18 #endif
21 %extend lldb::SBTypeEnumMemberList {
22 #ifdef SWIGPYTHON
23 %pythoncode %{
24 def __iter__(self):
25 '''Iterate over all members in a lldb.SBTypeEnumMemberList object.'''
26 return lldb_iter(self, 'GetSize', 'GetTypeEnumMemberAtIndex')
28 def __len__(self):
29 '''Return the number of members in a lldb.SBTypeEnumMemberList object.'''
30 return self.GetSize()
32 def __getitem__(self, key):
33 num_elements = self.GetSize()
34 if type(key) is int:
35 if -num_elements <= key < num_elements:
36 key %= num_elements
37 return self.GetTypeEnumMemberAtIndex(key)
38 elif type(key) is str:
39 for idx in range(num_elements):
40 item = self.GetTypeEnumMemberAtIndex(idx)
41 if item.name == key:
42 return item
43 return None
45 #endif