SBTypeCategory.i revision 360784
1//===-- SWIG Interface for SBTypeCategory---------------------------*- C++ -*-===// 2// 3// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. 4// See https://llvm.org/LICENSE.txt for license information. 5// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception 6// 7//===----------------------------------------------------------------------===// 8 9namespace lldb { 10 11 %feature("docstring", 12 "Represents a category that can contain formatters for types.") SBTypeCategory; 13 14 class SBTypeCategory 15 { 16 public: 17 18 SBTypeCategory(); 19 20 SBTypeCategory (const lldb::SBTypeCategory &rhs); 21 22 ~SBTypeCategory (); 23 24 bool 25 IsValid() const; 26 27 explicit operator bool() const; 28 29 bool 30 GetEnabled (); 31 32 void 33 SetEnabled (bool); 34 35 const char* 36 GetName(); 37 38 lldb::LanguageType 39 GetLanguageAtIndex (uint32_t idx); 40 41 uint32_t 42 GetNumLanguages (); 43 44 void 45 AddLanguage (lldb::LanguageType language); 46 47 bool 48 GetDescription (lldb::SBStream &description, 49 lldb::DescriptionLevel description_level); 50 51 uint32_t 52 GetNumFormats (); 53 54 uint32_t 55 GetNumSummaries (); 56 57 uint32_t 58 GetNumFilters (); 59 60 uint32_t 61 GetNumSynthetics (); 62 63 lldb::SBTypeNameSpecifier 64 GetTypeNameSpecifierForFilterAtIndex (uint32_t); 65 66 lldb::SBTypeNameSpecifier 67 GetTypeNameSpecifierForFormatAtIndex (uint32_t); 68 69 lldb::SBTypeNameSpecifier 70 GetTypeNameSpecifierForSummaryAtIndex (uint32_t); 71 72 lldb::SBTypeNameSpecifier 73 GetTypeNameSpecifierForSyntheticAtIndex (uint32_t); 74 75 lldb::SBTypeFilter 76 GetFilterForType (lldb::SBTypeNameSpecifier); 77 78 lldb::SBTypeFormat 79 GetFormatForType (lldb::SBTypeNameSpecifier); 80 81 lldb::SBTypeSummary 82 GetSummaryForType (lldb::SBTypeNameSpecifier); 83 84 lldb::SBTypeSynthetic 85 GetSyntheticForType (lldb::SBTypeNameSpecifier); 86 87 lldb::SBTypeFilter 88 GetFilterAtIndex (uint32_t); 89 90 lldb::SBTypeFormat 91 GetFormatAtIndex (uint32_t); 92 93 lldb::SBTypeSummary 94 GetSummaryAtIndex (uint32_t); 95 96 lldb::SBTypeSynthetic 97 GetSyntheticAtIndex (uint32_t); 98 99 bool 100 AddTypeFormat (lldb::SBTypeNameSpecifier, 101 lldb::SBTypeFormat); 102 103 bool 104 DeleteTypeFormat (lldb::SBTypeNameSpecifier); 105 106 bool 107 AddTypeSummary (lldb::SBTypeNameSpecifier, 108 lldb::SBTypeSummary); 109 110 bool 111 DeleteTypeSummary (lldb::SBTypeNameSpecifier); 112 113 bool 114 AddTypeFilter (lldb::SBTypeNameSpecifier, 115 lldb::SBTypeFilter); 116 117 bool 118 DeleteTypeFilter (lldb::SBTypeNameSpecifier); 119 120 bool 121 AddTypeSynthetic (lldb::SBTypeNameSpecifier, 122 lldb::SBTypeSynthetic); 123 124 bool 125 DeleteTypeSynthetic (lldb::SBTypeNameSpecifier); 126 127 STRING_EXTENSION_LEVEL(SBTypeCategory, lldb::eDescriptionLevelBrief) 128 129#ifdef SWIGPYTHON 130 %pythoncode %{ 131 132 class formatters_access_class(object): 133 '''A helper object that will lazily hand out formatters for a specific category.''' 134 def __init__(self, sbcategory, get_count_function, get_at_index_function, get_by_name_function): 135 self.sbcategory = sbcategory 136 self.get_count_function = get_count_function 137 self.get_at_index_function = get_at_index_function 138 self.get_by_name_function = get_by_name_function 139 self.regex_type = type(re.compile('.')) 140 141 142 def __len__(self): 143 if self.sbcategory and self.get_count_function: 144 return int(self.get_count_function(self.sbcategory)) 145 return 0 146 147 def __getitem__(self, key): 148 num_items = len(self) 149 if type(key) is int: 150 if key < num_items: 151 return self.get_at_index_function(self.sbcategory,key) 152 elif type(key) is str: 153 return self.get_by_name_function(self.sbcategory,SBTypeNameSpecifier(key)) 154 elif isinstance(key,self.regex_type): 155 return self.get_by_name_function(self.sbcategory,SBTypeNameSpecifier(key.pattern,True)) 156 else: 157 print("error: unsupported item type: %s" % type(key)) 158 return None 159 160 def get_formats_access_object(self): 161 '''An accessor function that returns an accessor object which allows lazy format access from a lldb.SBTypeCategory object.''' 162 return self.formatters_access_class (self,self.__class__.GetNumFormats,self.__class__.GetFormatAtIndex,self.__class__.GetFormatForType) 163 164 def get_formats_array(self): 165 '''An accessor function that returns a list() that contains all formats in a lldb.SBCategory object.''' 166 formats = [] 167 for idx in range(self.GetNumFormats()): 168 formats.append(self.GetFormatAtIndex(idx)) 169 return formats 170 171 def get_summaries_access_object(self): 172 '''An accessor function that returns an accessor object which allows lazy summary access from a lldb.SBTypeCategory object.''' 173 return self.formatters_access_class (self,self.__class__.GetNumSummaries,self.__class__.GetSummaryAtIndex,self.__class__.GetSummaryForType) 174 175 def get_summaries_array(self): 176 '''An accessor function that returns a list() that contains all summaries in a lldb.SBCategory object.''' 177 summaries = [] 178 for idx in range(self.GetNumSummaries()): 179 summaries.append(self.GetSummaryAtIndex(idx)) 180 return summaries 181 182 def get_synthetics_access_object(self): 183 '''An accessor function that returns an accessor object which allows lazy synthetic children provider access from a lldb.SBTypeCategory object.''' 184 return self.formatters_access_class (self,self.__class__.GetNumSynthetics,self.__class__.GetSyntheticAtIndex,self.__class__.GetSyntheticForType) 185 186 def get_synthetics_array(self): 187 '''An accessor function that returns a list() that contains all synthetic children providers in a lldb.SBCategory object.''' 188 synthetics = [] 189 for idx in range(self.GetNumSynthetics()): 190 synthetics.append(self.GetSyntheticAtIndex(idx)) 191 return synthetics 192 193 def get_filters_access_object(self): 194 '''An accessor function that returns an accessor object which allows lazy filter access from a lldb.SBTypeCategory object.''' 195 return self.formatters_access_class (self,self.__class__.GetNumFilters,self.__class__.GetFilterAtIndex,self.__class__.GetFilterForType) 196 197 def get_filters_array(self): 198 '''An accessor function that returns a list() that contains all filters in a lldb.SBCategory object.''' 199 filters = [] 200 for idx in range(self.GetNumFilters()): 201 filters.append(self.GetFilterAtIndex(idx)) 202 return filters 203 204 formats = property(get_formats_array, None, doc='''A read only property that returns a list() of lldb.SBTypeFormat objects contained in this category''') 205 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.''') 206 summaries = property(get_summaries_array, None, doc='''A read only property that returns a list() of lldb.SBTypeSummary objects contained in this category''') 207 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.''') 208 filters = property(get_filters_array, None, doc='''A read only property that returns a list() of lldb.SBTypeFilter objects contained in this category''') 209 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.''') 210 synthetics = property(get_synthetics_array, None, doc='''A read only property that returns a list() of lldb.SBTypeSynthetic objects contained in this category''') 211 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.''') 212 num_formats = property(GetNumFormats, None) 213 num_summaries = property(GetNumSummaries, None) 214 num_filters = property(GetNumFilters, None) 215 num_synthetics = property(GetNumSynthetics, None) 216 name = property(GetName, None) 217 enabled = property(GetEnabled, SetEnabled) 218 %} 219#endif 220 221 }; 222 223 224} // namespace lldb 225 226