1 STRING_EXTENSION_LEVEL_OUTSIDE(SBTypeCategory, lldb::eDescriptionLevelBrief) 2 3 %extend lldb::SBTypeCategory { 4 #ifdef SWIGPYTHON 5 %pythoncode %{ 6 7 class formatters_access_class(object): 8 '''A helper object that will lazily hand out formatters for a specific category.''' 9 def __init__(self, sbcategory, get_count_function, get_at_index_function, get_by_name_function): 10 self.sbcategory = sbcategory 11 self.get_count_function = get_count_function 12 self.get_at_index_function = get_at_index_function 13 self.get_by_name_function = get_by_name_function 14 self.regex_type = type(re.compile('.')) 15 16 17 def __len__(self): 18 if self.sbcategory and self.get_count_function: 19 return int(self.get_count_function(self.sbcategory)) 20 return 0 21 22 def __getitem__(self, key): 23 num_items = len(self) 24 if type(key) is int: 25 if -num_items <= key < num_items: 26 key %= num_items 27 return self.get_at_index_function(self.sbcategory,key) 28 elif type(key) is str: 29 return self.get_by_name_function(self.sbcategory,SBTypeNameSpecifier(key)) 30 elif isinstance(key,self.regex_type): 31 return self.get_by_name_function(self.sbcategory,SBTypeNameSpecifier(key.pattern,True)) 32 else: 33 print("error: unsupported item type: %s" % type(key)) 34 return None 35 36 def get_formats_access_object(self): 37 '''An accessor function that returns an accessor object which allows lazy format access from a lldb.SBTypeCategory object.''' 38 return self.formatters_access_class (self,self.__class__.GetNumFormats,self.__class__.GetFormatAtIndex,self.__class__.GetFormatForType) 39 40 def get_formats_array(self): 41 '''An accessor function that returns a list() that contains all formats in a lldb.SBCategory object.''' 42 formats = [] 43 for idx in range(self.GetNumFormats()): 44 formats.append(self.GetFormatAtIndex(idx)) 45 return formats 46 47 def get_summaries_access_object(self): 48 '''An accessor function that returns an accessor object which allows lazy summary access from a lldb.SBTypeCategory object.''' 49 return self.formatters_access_class (self,self.__class__.GetNumSummaries,self.__class__.GetSummaryAtIndex,self.__class__.GetSummaryForType) 50 51 def get_summaries_array(self): 52 '''An accessor function that returns a list() that contains all summaries in a lldb.SBCategory object.''' 53 summaries = [] 54 for idx in range(self.GetNumSummaries()): 55 summaries.append(self.GetSummaryAtIndex(idx)) 56 return summaries 57 58 def get_synthetics_access_object(self): 59 '''An accessor function that returns an accessor object which allows lazy synthetic children provider access from a lldb.SBTypeCategory object.''' 60 return self.formatters_access_class (self,self.__class__.GetNumSynthetics,self.__class__.GetSyntheticAtIndex,self.__class__.GetSyntheticForType) 61 62 def get_synthetics_array(self): 63 '''An accessor function that returns a list() that contains all synthetic children providers in a lldb.SBCategory object.''' 64 synthetics = [] 65 for idx in range(self.GetNumSynthetics()): 66 synthetics.append(self.GetSyntheticAtIndex(idx)) 67 return synthetics 68 69 def get_filters_access_object(self): 70 '''An accessor function that returns an accessor object which allows lazy filter access from a lldb.SBTypeCategory object.''' 71 return self.formatters_access_class (self,self.__class__.GetNumFilters,self.__class__.GetFilterAtIndex,self.__class__.GetFilterForType) 72 73 def get_filters_array(self): 74 '''An accessor function that returns a list() that contains all filters in a lldb.SBCategory object.''' 75 filters = [] 76 for idx in range(self.GetNumFilters()): 77 filters.append(self.GetFilterAtIndex(idx)) 78 return filters 79 80 formats = property(get_formats_array, None, doc='''A read only property that returns a list() of lldb.SBTypeFormat objects contained in this category''') 81 format = property(get_formats_access_object, None, doc=r'''A read only property that returns an object that you can use to look for formats by index or type name.''') 82 summaries = property(get_summaries_array, None, doc='''A read only property that returns a list() of lldb.SBTypeSummary objects contained in this category''') 83 summary = property(get_summaries_access_object, None, doc=r'''A read only property that returns an object that you can use to look for summaries by index or type name or regular expression.''') 84 filters = property(get_filters_array, None, doc='''A read only property that returns a list() of lldb.SBTypeFilter objects contained in this category''') 85 filter = property(get_filters_access_object, None, doc=r'''A read only property that returns an object that you can use to look for filters by index or type name or regular expression.''') 86 synthetics = property(get_synthetics_array, None, doc='''A read only property that returns a list() of lldb.SBTypeSynthetic objects contained in this category''') 87 synthetic = property(get_synthetics_access_object, None, doc=r'''A read only property that returns an object that you can use to look for synthetic children provider by index or type name or regular expression.''') 88 num_formats = property(GetNumFormats, None) 89 num_summaries = property(GetNumSummaries, None) 90 num_filters = property(GetNumFilters, None) 91 num_synthetics = property(GetNumSynthetics, None) 92 name = property(GetName, None) 93 enabled = property(GetEnabled, SetEnabled) 94 %} 95 #endif 96 } 97