OLD | NEW |
1 # Copyright 2014 The Chromium Authors. All rights reserved. | 1 # Copyright 2014 The Chromium Authors. All rights reserved. |
2 # Use of this source code is governed by a BSD-style license that can be | 2 # Use of this source code is governed by a BSD-style license that can be |
3 # found in the LICENSE file. | 3 # found in the LICENSE file. |
4 | 4 |
5 """Utility functions (file reading, simple IDL parsing by regexes) for IDL build
. | 5 """Utility functions (file reading, simple IDL parsing by regexes) for IDL build
. |
6 | 6 |
7 Design doc: http://www.chromium.org/developers/design-documents/idl-build | 7 Design doc: http://www.chromium.org/developers/design-documents/idl-build |
8 """ | 8 """ |
9 | 9 |
10 import os | 10 import os |
(...skipping 47 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
58 | 58 |
59 @property | 59 @property |
60 def interfaces_info(self): | 60 def interfaces_info(self): |
61 return {} | 61 return {} |
62 | 62 |
63 @property | 63 @property |
64 def component_info(self): | 64 def component_info(self): |
65 return {} | 65 return {} |
66 | 66 |
67 @property | 67 @property |
| 68 def enumerations(self): |
| 69 return {} |
| 70 |
| 71 @property |
68 def union_types(self): | 72 def union_types(self): |
69 return set() | 73 return set() |
70 | 74 |
71 | 75 |
72 class ComponentInfoProviderCore(ComponentInfoProvider): | 76 class ComponentInfoProviderCore(ComponentInfoProvider): |
73 def __init__(self, interfaces_info, component_info): | 77 def __init__(self, interfaces_info, component_info): |
74 super(ComponentInfoProviderCore, self).__init__() | 78 super(ComponentInfoProviderCore, self).__init__() |
75 self._interfaces_info = interfaces_info | 79 self._interfaces_info = interfaces_info |
76 self._component_info = component_info | 80 self._component_info = component_info |
77 | 81 |
78 @property | 82 @property |
79 def interfaces_info(self): | 83 def interfaces_info(self): |
80 return self._interfaces_info | 84 return self._interfaces_info |
81 | 85 |
82 @property | 86 @property |
83 def component_info(self): | 87 def component_info(self): |
84 return self._component_info | 88 return self._component_info |
85 | 89 |
86 @property | 90 @property |
| 91 def enumerations(self): |
| 92 return self._component_info['enumerations'] |
| 93 |
| 94 @property |
87 def union_types(self): | 95 def union_types(self): |
88 return self._component_info['union_types'] | 96 return self._component_info['union_types'] |
89 | 97 |
90 | 98 |
91 class ComponentInfoProviderModules(ComponentInfoProvider): | 99 class ComponentInfoProviderModules(ComponentInfoProvider): |
92 def __init__(self, interfaces_info, component_info_core, | 100 def __init__(self, interfaces_info, component_info_core, |
93 component_info_modules): | 101 component_info_modules): |
94 super(ComponentInfoProviderModules, self).__init__() | 102 super(ComponentInfoProviderModules, self).__init__() |
95 self._interfaces_info = interfaces_info | 103 self._interfaces_info = interfaces_info |
96 self._component_info_core = component_info_core | 104 self._component_info_core = component_info_core |
97 self._component_info_modules = component_info_modules | 105 self._component_info_modules = component_info_modules |
98 | 106 |
99 @property | 107 @property |
100 def interfaces_info(self): | 108 def interfaces_info(self): |
101 return self._interfaces_info | 109 return self._interfaces_info |
102 | 110 |
103 @property | 111 @property |
104 def component_info(self): | 112 def component_info(self): |
105 return self._component_info_modules | 113 return self._component_info_modules |
106 | 114 |
107 @property | 115 @property |
| 116 def enumerations(self): |
| 117 enums = self._component_info_core['enumerations'].copy() |
| 118 enums.update(self._component_info_modules['enumerations']) |
| 119 return enums |
| 120 |
| 121 @property |
108 def union_types(self): | 122 def union_types(self): |
109 # Remove duplicate union types from component_info_modules to avoid | 123 # Remove duplicate union types from component_info_modules to avoid |
110 # generating multiple container generation. | 124 # generating multiple container generation. |
111 return self._component_info_modules['union_types'] - self._component_inf
o_core['union_types'] | 125 return self._component_info_modules['union_types'] - self._component_inf
o_core['union_types'] |
112 | 126 |
113 | 127 |
114 def load_interfaces_info_overall_pickle(info_dir): | 128 def load_interfaces_info_overall_pickle(info_dir): |
115 with open(os.path.join(info_dir, 'modules', 'InterfacesInfoOverall.pickle'))
as interface_info_file: | 129 with open(os.path.join(info_dir, 'modules', 'InterfacesInfoOverall.pickle'))
as interface_info_file: |
116 return pickle.load(interface_info_file) | 130 return pickle.load(interface_info_file) |
117 | 131 |
(...skipping 156 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
274 extended_attributes_string = match.group(1) | 288 extended_attributes_string = match.group(1) |
275 match = re.search(r'[^=]\bExposed\(([^)]*)\)', file_contents) | 289 match = re.search(r'[^=]\bExposed\(([^)]*)\)', file_contents) |
276 if not match: | 290 if not match: |
277 return None | 291 return None |
278 arguments = [] | 292 arguments = [] |
279 for argument in map(string.strip, match.group(1).split(',')): | 293 for argument in map(string.strip, match.group(1).split(',')): |
280 exposed, runtime_enabled = argument.split() | 294 exposed, runtime_enabled = argument.split() |
281 arguments.append({'exposed': exposed, 'runtime_enabled': runtime_enabled
}) | 295 arguments.append({'exposed': exposed, 'runtime_enabled': runtime_enabled
}) |
282 | 296 |
283 return arguments | 297 return arguments |
OLD | NEW |