1 //===-- SWIG Interface for SBTypeCategory---------------------------*- C++ -*-===//
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
7 //===----------------------------------------------------------------------===//
12 "Represents a category that can contain formatters for types.") SBTypeCategory;
20 SBTypeCategory (const lldb::SBTypeCategory &rhs);
27 explicit operator bool() const;
39 GetLanguageAtIndex (uint32_t idx);
45 AddLanguage (lldb::LanguageType language);
48 GetDescription (lldb::SBStream &description,
49 lldb::DescriptionLevel description_level);
63 lldb::SBTypeNameSpecifier
64 GetTypeNameSpecifierForFilterAtIndex (uint32_t);
66 lldb::SBTypeNameSpecifier
67 GetTypeNameSpecifierForFormatAtIndex (uint32_t);
69 lldb::SBTypeNameSpecifier
70 GetTypeNameSpecifierForSummaryAtIndex (uint32_t);
72 lldb::SBTypeNameSpecifier
73 GetTypeNameSpecifierForSyntheticAtIndex (uint32_t);
76 GetFilterForType (lldb::SBTypeNameSpecifier);
79 GetFormatForType (lldb::SBTypeNameSpecifier);
82 GetSummaryForType (lldb::SBTypeNameSpecifier);
85 GetSyntheticForType (lldb::SBTypeNameSpecifier);
88 GetFilterAtIndex (uint32_t);
91 GetFormatAtIndex (uint32_t);
94 GetSummaryAtIndex (uint32_t);
97 GetSyntheticAtIndex (uint32_t);
100 AddTypeFormat (lldb::SBTypeNameSpecifier,
104 DeleteTypeFormat (lldb::SBTypeNameSpecifier);
107 AddTypeSummary (lldb::SBTypeNameSpecifier,
108 lldb::SBTypeSummary);
111 DeleteTypeSummary (lldb::SBTypeNameSpecifier);
114 AddTypeFilter (lldb::SBTypeNameSpecifier,
118 DeleteTypeFilter (lldb::SBTypeNameSpecifier);
121 AddTypeSynthetic (lldb::SBTypeNameSpecifier,
122 lldb::SBTypeSynthetic);
125 DeleteTypeSynthetic (lldb::SBTypeNameSpecifier);
127 STRING_EXTENSION_LEVEL(SBTypeCategory, lldb::eDescriptionLevelBrief)
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('.'))
143 if self.sbcategory and self.get_count_function:
144 return int(self.get_count_function(self.sbcategory))
147 def __getitem__(self, key):
148 num_items = len(self)
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))
157 print("error: unsupported item type: %s" % type(key))
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)
164 def get_formats_array(self):
165 '''An accessor function that returns a list() that contains all formats in a lldb.SBCategory object.'''
167 for idx in range(self.GetNumFormats()):
168 formats.append(self.GetFormatAtIndex(idx))
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)
175 def get_summaries_array(self):
176 '''An accessor function that returns a list() that contains all summaries in a lldb.SBCategory object.'''
178 for idx in range(self.GetNumSummaries()):
179 summaries.append(self.GetSummaryAtIndex(idx))
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)
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.'''
189 for idx in range(self.GetNumSynthetics()):
190 synthetics.append(self.GetSyntheticAtIndex(idx))
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)
197 def get_filters_array(self):
198 '''An accessor function that returns a list() that contains all filters in a lldb.SBCategory object.'''
200 for idx in range(self.GetNumFilters()):
201 filters.append(self.GetFilterAtIndex(idx))
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)