PageRenderTime 49ms CodeModel.GetById 23ms RepoModel.GetById 0ms app.codeStats 0ms

/scripts/Python/interface/SBTypeCategory.i

https://gitlab.com/jorjpimm/lldb
Swig | 237 lines | 174 code | 63 blank | 0 comment | 0 complexity | ca07c69ad5161ebf3edc7aa00b380301 MD5 | raw file
  1. //===-- SWIG Interface for SBTypeCategory---------------------------*- C++ -*-===//
  2. //
  3. // The LLVM Compiler Infrastructure
  4. //
  5. // This file is distributed under the University of Illinois Open Source
  6. // License. See LICENSE.TXT for details.
  7. //
  8. //===----------------------------------------------------------------------===//
  9. namespace lldb {
  10. %feature("docstring",
  11. "Represents a category that can contain formatters for types.
  12. ") SBTypeCategory;
  13. class SBTypeCategory
  14. {
  15. public:
  16. SBTypeCategory();
  17. SBTypeCategory (const lldb::SBTypeCategory &rhs);
  18. ~SBTypeCategory ();
  19. bool
  20. IsValid() const;
  21. bool
  22. GetEnabled ();
  23. void
  24. SetEnabled (bool);
  25. const char*
  26. GetName();
  27. bool
  28. GetDescription (lldb::SBStream &description,
  29. lldb::DescriptionLevel description_level);
  30. uint32_t
  31. GetNumFormats ();
  32. uint32_t
  33. GetNumSummaries ();
  34. uint32_t
  35. GetNumFilters ();
  36. uint32_t
  37. GetNumSynthetics ();
  38. lldb::SBTypeNameSpecifier
  39. GetTypeNameSpecifierForFilterAtIndex (uint32_t);
  40. lldb::SBTypeNameSpecifier
  41. GetTypeNameSpecifierForFormatAtIndex (uint32_t);
  42. lldb::SBTypeNameSpecifier
  43. GetTypeNameSpecifierForSummaryAtIndex (uint32_t);
  44. lldb::SBTypeNameSpecifier
  45. GetTypeNameSpecifierForSyntheticAtIndex (uint32_t);
  46. lldb::SBTypeFilter
  47. GetFilterForType (lldb::SBTypeNameSpecifier);
  48. lldb::SBTypeFormat
  49. GetFormatForType (lldb::SBTypeNameSpecifier);
  50. lldb::SBTypeSummary
  51. GetSummaryForType (lldb::SBTypeNameSpecifier);
  52. lldb::SBTypeSynthetic
  53. GetSyntheticForType (lldb::SBTypeNameSpecifier);
  54. lldb::SBTypeFilter
  55. GetFilterAtIndex (uint32_t);
  56. lldb::SBTypeFormat
  57. GetFormatAtIndex (uint32_t);
  58. lldb::SBTypeSummary
  59. GetSummaryAtIndex (uint32_t);
  60. lldb::SBTypeSynthetic
  61. GetSyntheticAtIndex (uint32_t);
  62. bool
  63. AddTypeFormat (lldb::SBTypeNameSpecifier,
  64. lldb::SBTypeFormat);
  65. bool
  66. DeleteTypeFormat (lldb::SBTypeNameSpecifier);
  67. bool
  68. AddTypeSummary (lldb::SBTypeNameSpecifier,
  69. lldb::SBTypeSummary);
  70. bool
  71. DeleteTypeSummary (lldb::SBTypeNameSpecifier);
  72. bool
  73. AddTypeFilter (lldb::SBTypeNameSpecifier,
  74. lldb::SBTypeFilter);
  75. bool
  76. DeleteTypeFilter (lldb::SBTypeNameSpecifier);
  77. bool
  78. AddTypeSynthetic (lldb::SBTypeNameSpecifier,
  79. lldb::SBTypeSynthetic);
  80. bool
  81. DeleteTypeSynthetic (lldb::SBTypeNameSpecifier);
  82. %pythoncode %{
  83. class formatters_access_class(object):
  84. '''A helper object that will lazily hand out formatters for a specific category.'''
  85. def __init__(self, sbcategory, get_count_function, get_at_index_function, get_by_name_function):
  86. self.sbcategory = sbcategory
  87. self.get_count_function = get_count_function
  88. self.get_at_index_function = get_at_index_function
  89. self.get_by_name_function = get_by_name_function
  90. self.regex_type = type(re.compile('.'))
  91. def __len__(self):
  92. if self.sbcategory and self.get_count_function:
  93. return int(self.get_count_function(self.sbcategory))
  94. return 0
  95. def __getitem__(self, key):
  96. num_items = len(self)
  97. if type(key) is int:
  98. if key < num_items:
  99. return self.get_at_index_function(self.sbcategory,key)
  100. elif type(key) is str:
  101. return self.get_by_name_function(self.sbcategory,SBTypeNameSpecifier(key))
  102. elif isinstance(key,self.regex_type):
  103. return self.get_by_name_function(self.sbcategory,SBTypeNameSpecifier(key.pattern,True))
  104. else:
  105. print "error: unsupported item type: %s" % type(key)
  106. return None
  107. def get_formats_access_object(self):
  108. '''An accessor function that returns an accessor object which allows lazy format access from a lldb.SBTypeCategory object.'''
  109. return self.formatters_access_class (self,self.__class__.GetNumFormats,self.__class__.GetFormatAtIndex,self.__class__.GetFormatForType)
  110. def get_formats_array(self):
  111. '''An accessor function that returns a list() that contains all formats in a lldb.SBCategory object.'''
  112. formats = []
  113. for idx in range(self.GetNumFormats()):
  114. formats.append(self.GetFormatAtIndex(idx))
  115. return formats
  116. def get_summaries_access_object(self):
  117. '''An accessor function that returns an accessor object which allows lazy summary access from a lldb.SBTypeCategory object.'''
  118. return self.formatters_access_class (self,self.__class__.GetNumSummaries,self.__class__.GetSummaryAtIndex,self.__class__.GetSummaryForType)
  119. def get_summaries_array(self):
  120. '''An accessor function that returns a list() that contains all summaries in a lldb.SBCategory object.'''
  121. summaries = []
  122. for idx in range(self.GetNumSummaries()):
  123. summaries.append(self.GetSummaryAtIndex(idx))
  124. return summaries
  125. def get_synthetics_access_object(self):
  126. '''An accessor function that returns an accessor object which allows lazy synthetic children provider access from a lldb.SBTypeCategory object.'''
  127. return self.formatters_access_class (self,self.__class__.GetNumSynthetics,self.__class__.GetSyntheticAtIndex,self.__class__.GetSyntheticForType)
  128. def get_synthetics_array(self):
  129. '''An accessor function that returns a list() that contains all synthetic children providers in a lldb.SBCategory object.'''
  130. synthetics = []
  131. for idx in range(self.GetNumSynthetics()):
  132. synthetics.append(self.GetSyntheticAtIndex(idx))
  133. return synthetics
  134. def get_filters_access_object(self):
  135. '''An accessor function that returns an accessor object which allows lazy filter access from a lldb.SBTypeCategory object.'''
  136. return self.formatters_access_class (self,self.__class__.GetNumFilters,self.__class__.GetFilterAtIndex,self.__class__.GetFilterForType)
  137. def get_filters_array(self):
  138. '''An accessor function that returns a list() that contains all filters in a lldb.SBCategory object.'''
  139. filters = []
  140. for idx in range(self.GetNumFilters()):
  141. filters.append(self.GetFilterAtIndex(idx))
  142. return filters
  143. __swig_getmethods__["formats"] = get_formats_array
  144. if _newclass: formats = property(get_formats_array, None, doc='''A read only property that returns a list() of lldb.SBTypeFormat objects contained in this category''')
  145. __swig_getmethods__["format"] = get_formats_access_object
  146. if _newclass: 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.''')
  147. __swig_getmethods__["summaries"] = get_summaries_array
  148. if _newclass: summaries = property(get_summaries_array, None, doc='''A read only property that returns a list() of lldb.SBTypeSummary objects contained in this category''')
  149. __swig_getmethods__["summary"] = get_summaries_access_object
  150. if _newclass: 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.''')
  151. __swig_getmethods__["filters"] = get_filters_array
  152. if _newclass: filters = property(get_filters_array, None, doc='''A read only property that returns a list() of lldb.SBTypeFilter objects contained in this category''')
  153. __swig_getmethods__["filter"] = get_filters_access_object
  154. if _newclass: 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.''')
  155. __swig_getmethods__["synthetics"] = get_synthetics_array
  156. if _newclass: synthetics = property(get_synthetics_array, None, doc='''A read only property that returns a list() of lldb.SBTypeSynthetic objects contained in this category''')
  157. __swig_getmethods__["synthetic"] = get_synthetics_access_object
  158. if _newclass: 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.''')
  159. __swig_getmethods__["num_formats"] = GetNumFormats
  160. if _newclass: num_formats = property(GetNumFormats, None)
  161. __swig_getmethods__["num_summaries"] = GetNumSummaries
  162. if _newclass: num_summaries = property(GetNumSummaries, None)
  163. __swig_getmethods__["num_filters"] = GetNumFilters
  164. if _newclass: num_filters = property(GetNumFilters, None)
  165. __swig_getmethods__["num_synthetics"] = GetNumSynthetics
  166. if _newclass: num_synthetics = property(GetNumSynthetics, None)
  167. __swig_getmethods__["name"] = GetName
  168. if _newclass: name = property(GetName, None)
  169. __swig_getmethods__["enabled"] = GetEnabled
  170. __swig_setmethods__["enabled"] = SetEnabled
  171. if _newclass: enabled = property(GetEnabled, SetEnabled)
  172. %}
  173. };
  174. } // namespace lldb