1 STRING_EXTENSION_LEVEL_OUTSIDE(SBTypeMember, lldb::eDescriptionLevelBrief)
2 %extend lldb::SBTypeMember {
3 #ifdef SWIGPYTHON
4     %pythoncode %{
5         name = property(GetName, None, doc='''A read only property that returns the name for this member as a string.''')
6         type = property(GetType, None, doc='''A read only property that returns an lldb object that represents the type (lldb.SBType) for this member.''')
7         byte_offset = property(GetOffsetInBytes, None, doc='''A read only property that returns offset in bytes for this member as an integer.''')
8         bit_offset = property(GetOffsetInBits, None, doc='''A read only property that returns offset in bits for this member as an integer.''')
9         is_bitfield = property(IsBitfield, None, doc='''A read only property that returns true if this member is a bitfield.''')
10         bitfield_bit_size = property(GetBitfieldSizeInBits, None, doc='''A read only property that returns the bitfield size in bits for this member as an integer, or zero if this member is not a bitfield.''')
11     %}
12 #endif
13 }
14 
15 STRING_EXTENSION_LEVEL_OUTSIDE(SBTypeMemberFunction, lldb::eDescriptionLevelBrief)
16 
17 STRING_EXTENSION_LEVEL_OUTSIDE(SBType, lldb::eDescriptionLevelBrief)
18 
19 %extend lldb::SBType {
20 #ifdef SWIGPYTHON
21     %pythoncode %{
22         def template_arg_array(self):
23             num_args = self.num_template_args
24             if num_args:
25                 template_args = []
26                 for i in range(num_args):
27                     template_args.append(self.GetTemplateArgumentType(i))
28                 return template_args
29             return None
30 
31         module = property(GetModule, None, doc='''A read only property that returns the module in which type is defined.''')
32         name = property(GetName, None, doc='''A read only property that returns the name for this type as a string.''')
33         size = property(GetByteSize, None, doc='''A read only property that returns size in bytes for this type as an integer.''')
34         is_pointer = property(IsPointerType, None, doc='''A read only property that returns a boolean value that indicates if this type is a pointer type.''')
35         is_reference = property(IsReferenceType, None, doc='''A read only property that returns a boolean value that indicates if this type is a reference type.''')
36         is_reference = property(IsReferenceType, None, doc='''A read only property that returns a boolean value that indicates if this type is a function type.''')
37         num_fields = property(GetNumberOfFields, None, doc='''A read only property that returns number of fields in this type as an integer.''')
38         num_bases = property(GetNumberOfDirectBaseClasses, None, doc='''A read only property that returns number of direct base classes in this type as an integer.''')
39         num_vbases = property(GetNumberOfVirtualBaseClasses, None, doc='''A read only property that returns number of virtual base classes in this type as an integer.''')
40         num_template_args = property(GetNumberOfTemplateArguments, None, doc='''A read only property that returns number of template arguments in this type as an integer.''')
41         template_args = property(template_arg_array, None, doc='''A read only property that returns a list() of lldb.SBType objects that represent all template arguments in this type.''')
42         type = property(GetTypeClass, None, doc='''A read only property that returns an lldb enumeration value (see enumerations that start with "lldb.eTypeClass") that represents a classification for this type.''')
43         is_complete = property(IsTypeComplete, None, doc='''A read only property that returns a boolean value that indicates if this type is a complete type (True) or a forward declaration (False).''')
44 
45         def get_bases_array(self):
46             '''An accessor function that returns a list() that contains all direct base classes in a lldb.SBType object.'''
47             bases = []
48             for idx in range(self.GetNumberOfDirectBaseClasses()):
49                 bases.append(self.GetDirectBaseClassAtIndex(idx))
50             return bases
51 
52         def get_vbases_array(self):
53             '''An accessor function that returns a list() that contains all fields in a lldb.SBType object.'''
54             vbases = []
55             for idx in range(self.GetNumberOfVirtualBaseClasses()):
56                 vbases.append(self.GetVirtualBaseClassAtIndex(idx))
57             return vbases
58 
59         def get_fields_array(self):
60             '''An accessor function that returns a list() that contains all fields in a lldb.SBType object.'''
61             fields = []
62             for idx in range(self.GetNumberOfFields()):
63                 fields.append(self.GetFieldAtIndex(idx))
64             return fields
65 
66         def get_members_array(self):
67             '''An accessor function that returns a list() that contains all members (base classes and fields) in a lldb.SBType object in ascending bit offset order.'''
68             members = []
69             bases = self.get_bases_array()
70             fields = self.get_fields_array()
71             vbases = self.get_vbases_array()
72             for base in bases:
73                 bit_offset = base.bit_offset
74                 added = False
75                 for idx, member in enumerate(members):
76                     if member.bit_offset > bit_offset:
77                         members.insert(idx, base)
78                         added = True
79                         break
80                 if not added:
81                     members.append(base)
82             for vbase in vbases:
83                 bit_offset = vbase.bit_offset
84                 added = False
85                 for idx, member in enumerate(members):
86                     if member.bit_offset > bit_offset:
87                         members.insert(idx, vbase)
88                         added = True
89                         break
90                 if not added:
91                     members.append(vbase)
92             for field in fields:
93                 bit_offset = field.bit_offset
94                 added = False
95                 for idx, member in enumerate(members):
96                     if member.bit_offset > bit_offset:
97                         members.insert(idx, field)
98                         added = True
99                         break
100                 if not added:
101                     members.append(field)
102             return members
103 
104         def get_enum_members_array(self):
105             '''An accessor function that returns a list() that contains all enum members in an lldb.SBType object.'''
106             enum_members_list = []
107             sb_enum_members = self.GetEnumMembers()
108             for idx in range(sb_enum_members.GetSize()):
109                 enum_members_list.append(sb_enum_members.GetTypeEnumMemberAtIndex(idx))
110             return enum_members_list
111 
112         bases = property(get_bases_array, None, doc='''A read only property that returns a list() of lldb.SBTypeMember objects that represent all of the direct base classes for this type.''')
113         vbases = property(get_vbases_array, None, doc='''A read only property that returns a list() of lldb.SBTypeMember objects that represent all of the virtual base classes for this type.''')
114         fields = property(get_fields_array, None, doc='''A read only property that returns a list() of lldb.SBTypeMember objects that represent all of the fields for this type.''')
115         members = property(get_members_array, None, doc='''A read only property that returns a list() of all lldb.SBTypeMember objects that represent all of the base classes, virtual base classes and fields for this type in ascending bit offset order.''')
116         enum_members = property(get_enum_members_array, None, doc='''A read only property that returns a list() of all lldb.SBTypeEnumMember objects that represent the enum members for this type.''')
117         %}
118 #endif
119 }
120 
121 %extend lldb::SBTypeList {
122 #ifdef SWIGPYTHON
123     %pythoncode%{
124     def __iter__(self):
125         '''Iterate over all types in a lldb.SBTypeList object.'''
126         return lldb_iter(self, 'GetSize', 'GetTypeAtIndex')
127 
128     def __len__(self):
129         '''Return the number of types in a lldb.SBTypeList object.'''
130         return self.GetSize()
131     %}
132 #endif
133 }
134