brintos

brintos / llvm-project-archived public Read only

0
0
Text · 8.9 KiB · 9c7d614 Raw
164 lines · plain
1STRING_EXTENSION_LEVEL_OUTSIDE(SBTypeMember, lldb::eDescriptionLevelBrief)2%extend lldb::SBTypeMember {3#ifdef SWIGPYTHON4    %pythoncode %{5        # operator== is a free function, which swig does not handle, so we inject6        # our own equality operator here7        def __eq__(self, other):8            return not self.__ne__(other)9 10        name = property(GetName, None, doc='''A read only property that returns the name for this member as a string.''')11        type = property(GetType, None, doc='''A read only property that returns an lldb object that represents the type (lldb.SBType) for this member.''')12        byte_offset = property(GetOffsetInBytes, None, doc='''A read only property that returns offset in bytes for this member as an integer.''')13        bit_offset = property(GetOffsetInBits, None, doc='''A read only property that returns offset in bits for this member as an integer.''')14        is_bitfield = property(IsBitfield, None, doc='''A read only property that returns true if this member is a bitfield.''')15        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.''')16    %}17#endif18}19 20STRING_EXTENSION_LEVEL_OUTSIDE(SBTypeMemberFunction, lldb::eDescriptionLevelBrief)21 22%extend lldb::SBTypeMemberFunction {23#ifdef SWIGPYTHON24    %pythoncode%{25      # operator== is a free function, which swig does not handle, so we inject26      # our own equality operator here27      def __eq__(self, other):28        return not self.__ne__(other)29 30    %}31#endif32}33 34STRING_EXTENSION_LEVEL_OUTSIDE(SBType, lldb::eDescriptionLevelBrief)35 36%extend lldb::SBType {37#ifdef SWIGPYTHON38    %pythoncode %{39        def template_arg_array(self):40            num_args = self.num_template_args41            if num_args:42                template_args = []43                for i in range(num_args):44                    template_args.append(self.GetTemplateArgumentType(i))45                return template_args46            return None47 48        # operator== is a free function, which swig does not handle, so we inject49        # our own equality operator here50        def __eq__(self, other):51            return not self.__ne__(other)52 53        def __len__(self):54            return self.GetByteSize()55 56        module = property(GetModule, None, doc='''A read only property that returns the module in which type is defined.''')57        name = property(GetName, None, doc='''A read only property that returns the name for this type as a string.''')58        size = property(GetByteSize, None, doc='''A read only property that returns size in bytes for this type as an integer.''')59        is_pointer = property(IsPointerType, None, doc='''A read only property that returns a boolean value that indicates if this type is a pointer type.''')60        is_reference = property(IsReferenceType, None, doc='''A read only property that returns a boolean value that indicates if this type is a reference type.''')61        is_reference = property(IsReferenceType, None, doc='''A read only property that returns a boolean value that indicates if this type is a function type.''')62        num_fields = property(GetNumberOfFields, None, doc='''A read only property that returns number of fields in this type as an integer.''')63        num_bases = property(GetNumberOfDirectBaseClasses, None, doc='''A read only property that returns number of direct base classes in this type as an integer.''')64        num_vbases = property(GetNumberOfVirtualBaseClasses, None, doc='''A read only property that returns number of virtual base classes in this type as an integer.''')65        num_template_args = property(GetNumberOfTemplateArguments, None, doc='''A read only property that returns number of template arguments in this type as an integer.''')66        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.''')67        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.''')68        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).''')69 70        def get_bases_array(self):71            '''An accessor function that returns a list() that contains all direct base classes in a lldb.SBType object.'''72            bases = []73            for idx in range(self.GetNumberOfDirectBaseClasses()):74                bases.append(self.GetDirectBaseClassAtIndex(idx))75            return bases76 77        def get_vbases_array(self):78            '''An accessor function that returns a list() that contains all fields in a lldb.SBType object.'''79            vbases = []80            for idx in range(self.GetNumberOfVirtualBaseClasses()):81                vbases.append(self.GetVirtualBaseClassAtIndex(idx))82            return vbases83 84        def get_fields_array(self):85            '''An accessor function that returns a list() that contains all fields in a lldb.SBType object.'''86            fields = []87            for idx in range(self.GetNumberOfFields()):88                fields.append(self.GetFieldAtIndex(idx))89            return fields90 91        def get_members_array(self):92            '''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.'''93            members = []94            bases = self.get_bases_array()95            fields = self.get_fields_array()96            vbases = self.get_vbases_array()97            for base in bases:98                bit_offset = base.bit_offset99                added = False100                for idx, member in enumerate(members):101                    if member.bit_offset > bit_offset:102                        members.insert(idx, base)103                        added = True104                        break105                if not added:106                    members.append(base)107            for vbase in vbases:108                bit_offset = vbase.bit_offset109                added = False110                for idx, member in enumerate(members):111                    if member.bit_offset > bit_offset:112                        members.insert(idx, vbase)113                        added = True114                        break115                if not added:116                    members.append(vbase)117            for field in fields:118                bit_offset = field.bit_offset119                added = False120                for idx, member in enumerate(members):121                    if member.bit_offset > bit_offset:122                        members.insert(idx, field)123                        added = True124                        break125                if not added:126                    members.append(field)127            return members128 129        def get_enum_members_array(self):130            '''An accessor function that returns a list() that contains all enum members in an lldb.SBType object.'''131            enum_members_list = []132            sb_enum_members = self.GetEnumMembers()133            for idx in range(sb_enum_members.GetSize()):134                enum_members_list.append(sb_enum_members.GetTypeEnumMemberAtIndex(idx))135            return enum_members_list136 137        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.''')138        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.''')139        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.''')140        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.''')141        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.''')142        %}143#endif144}145 146%extend lldb::SBTypeList {147#ifdef SWIGPYTHON148    %pythoncode%{149    # operator== is a free function, which swig does not handle, so we inject150    # our own equality operator here151    def __eq__(self, other):152        return not self.__ne__(other)153 154    def __iter__(self):155        '''Iterate over all types in a lldb.SBTypeList object.'''156        return lldb_iter(self, 'GetSize', 'GetTypeAtIndex')157 158    def __len__(self):159        '''Return the number of types in a lldb.SBTypeList object.'''160        return self.GetSize()161    %}162#endif163}164