OLD | NEW |
1 #!/usr/bin/python | 1 #!/usr/bin/python |
2 # | 2 # |
3 # Copyright (C) 2013 Google Inc. All rights reserved. | 3 # Copyright (C) 2013 Google Inc. All rights reserved. |
4 # | 4 # |
5 # Redistribution and use in source and binary forms, with or without | 5 # Redistribution and use in source and binary forms, with or without |
6 # modification, are permitted provided that the following conditions are | 6 # modification, are permitted provided that the following conditions are |
7 # met: | 7 # met: |
8 # | 8 # |
9 # * Redistributions of source code must retain the above copyright | 9 # * Redistributions of source code must retain the above copyright |
10 # notice, this list of conditions and the following disclaimer. | 10 # notice, this list of conditions and the following disclaimer. |
(...skipping 63 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
74 code changes (for inherited extended attributes). | 74 code changes (for inherited extended attributes). |
75 | 75 |
76 Design doc: http://www.chromium.org/developers/design-documents/idl-build | 76 Design doc: http://www.chromium.org/developers/design-documents/idl-build |
77 """ | 77 """ |
78 | 78 |
79 from collections import defaultdict | 79 from collections import defaultdict |
80 import cPickle as pickle | 80 import cPickle as pickle |
81 import optparse | 81 import optparse |
82 import sys | 82 import sys |
83 | 83 |
84 from utilities import read_pickle_files, write_pickle_file | 84 from utilities import idl_filename_to_component, read_pickle_files, write_pickle
_file |
85 | 85 |
86 INHERITED_EXTENDED_ATTRIBUTES = set([ | 86 INHERITED_EXTENDED_ATTRIBUTES = set([ |
87 'ActiveDOMObject', | 87 'ActiveDOMObject', |
88 'DependentLifetime', | 88 'DependentLifetime', |
89 'GarbageCollected', | 89 'GarbageCollected', |
| 90 'NotScriptWrappable', |
90 'WillBeGarbageCollected', | 91 'WillBeGarbageCollected', |
91 ]) | 92 ]) |
92 | 93 |
93 # Main variable (filled in and exported) | 94 # Main variable (filled in and exported) |
94 interfaces_info = {} | 95 interfaces_info = {} |
95 | 96 |
96 # Auxiliary variables (not visible to future build steps) | 97 # Auxiliary variables (not visible to future build steps) |
97 partial_interface_files = defaultdict(lambda: { | 98 partial_interface_files = defaultdict(lambda: { |
98 'full_paths': [], | 99 'full_paths': [], |
99 'include_paths': [], | 100 'include_paths': [], |
(...skipping 52 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
152 # where we don't generate these files. | 153 # where we don't generate these files. |
153 ancestor_extended_attributes = inherited_extended_attributes_by_interfac
e.get(ancestor, {}) | 154 ancestor_extended_attributes = inherited_extended_attributes_by_interfac
e.get(ancestor, {}) |
154 inherited_extended_attributes.update(ancestor_extended_attributes) | 155 inherited_extended_attributes.update(ancestor_extended_attributes) |
155 | 156 |
156 interfaces_info[interface_name].update({ | 157 interfaces_info[interface_name].update({ |
157 'ancestors': ancestors, | 158 'ancestors': ancestors, |
158 'inherited_extended_attributes': inherited_extended_attributes, | 159 'inherited_extended_attributes': inherited_extended_attributes, |
159 }) | 160 }) |
160 | 161 |
161 | 162 |
| 163 def compute_global_type_info(): |
| 164 ancestors = {} |
| 165 dictionaries = {} |
| 166 component_dirs = {} |
| 167 implemented_as_interfaces = {} |
| 168 will_be_garbage_collected_interfaces = set() |
| 169 garbage_collected_interfaces = set() |
| 170 callback_interfaces = set() |
| 171 |
| 172 for interface_name, interface_info in interfaces_info.iteritems(): |
| 173 component_dirs[interface_name] = idl_filename_to_component(interface_inf
o['full_path']) |
| 174 |
| 175 if interface_info['ancestors']: |
| 176 ancestors[interface_name] = interface_info['ancestors'] |
| 177 if interface_info['is_callback_interface']: |
| 178 callback_interfaces.add(interface_name) |
| 179 if interface_info['is_dictionary']: |
| 180 dictionaries[interface_name] = interface_info['is_dictionary'] |
| 181 if interface_info['implemented_as']: |
| 182 implemented_as_interfaces[interface_name] = interface_info['implemen
ted_as'] |
| 183 |
| 184 inherited_extended_attributes = interface_info['inherited_extended_attri
butes'] |
| 185 if 'WillBeGarbageCollected' in inherited_extended_attributes: |
| 186 will_be_garbage_collected_interfaces.add(interface_name) |
| 187 if 'GarbageCollected' in inherited_extended_attributes: |
| 188 garbage_collected_interfaces.add(interface_name) |
| 189 |
| 190 interfaces_info['ancestors'] = ancestors |
| 191 interfaces_info['callback_interfaces'] = callback_interfaces |
| 192 interfaces_info['dictionaries'] = dictionaries |
| 193 interfaces_info['implemented_as_interfaces'] = implemented_as_interfaces |
| 194 interfaces_info['garbage_collected_interfaces'] = garbage_collected_interfac
es |
| 195 interfaces_info['will_be_garbage_collected_interfaces'] = will_be_garbage_co
llected_interfaces |
| 196 interfaces_info['component_dirs'] = component_dirs |
| 197 |
| 198 |
162 def compute_interfaces_info_overall(info_individuals): | 199 def compute_interfaces_info_overall(info_individuals): |
163 """Compute information about IDL files. | 200 """Compute information about IDL files. |
164 | 201 |
165 Information is stored in global interfaces_info. | 202 Information is stored in global interfaces_info. |
166 """ | 203 """ |
167 for info in info_individuals: | 204 for info in info_individuals: |
168 # No overlap between interface names, so ok to use dict.update | 205 # No overlap between interface names, so ok to use dict.update |
169 interfaces_info.update(info['interfaces_info']) | 206 interfaces_info.update(info['interfaces_info']) |
170 # Interfaces in one component may have partial interfaces in | 207 # Interfaces in one component may have partial interfaces in |
171 # another component. This is ok (not a layering violation), since | 208 # another component. This is ok (not a layering violation), since |
(...skipping 48 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
220 raise IdlInterfaceFileNotFoundError('Could not find the IDL file whe
re the following implemented interface is defined: %s' % key_name) | 257 raise IdlInterfaceFileNotFoundError('Could not find the IDL file whe
re the following implemented interface is defined: %s' % key_name) |
221 implemented_interfaces_full_paths = [ | 258 implemented_interfaces_full_paths = [ |
222 implemented_interface_info['full_path'] | 259 implemented_interface_info['full_path'] |
223 for implemented_interface_info in implemented_interfaces_info] | 260 for implemented_interface_info in implemented_interfaces_info] |
224 # Implemented interfaces don't need includes, as this is handled in | 261 # Implemented interfaces don't need includes, as this is handled in |
225 # the Blink implementation (they are implemented on |impl| itself, | 262 # the Blink implementation (they are implemented on |impl| itself, |
226 # hence header is included in implementing class). | 263 # hence header is included in implementing class). |
227 # However, they are needed for legacy implemented interfaces that | 264 # However, they are needed for legacy implemented interfaces that |
228 # are being treated as partial interfaces, until we remove these. | 265 # are being treated as partial interfaces, until we remove these. |
229 # http://crbug.com/360435 | 266 # http://crbug.com/360435 |
230 implemented_interfaces_include_paths = [ | 267 implemented_interfaces_include_paths = [] |
231 implemented_interface_info['include_path'] | 268 for implemented_interface_info in implemented_interfaces_info: |
232 for implemented_interface_info in implemented_interfaces_info | 269 if (implemented_interface_info['is_legacy_treat_as_partial_interface
'] and |
233 if implemented_interface_info['is_legacy_treat_as_partial_interface'
]] | 270 implemented_interface_info['include_path']): |
| 271 implemented_interfaces_include_paths.append(implemented_interfac
e_info['include_path']) |
234 | 272 |
235 interface_info.update({ | 273 interface_info.update({ |
236 'dependencies_full_paths': (partial_interfaces_full_paths + | 274 'dependencies_full_paths': (partial_interfaces_full_paths + |
237 implemented_interfaces_full_paths), | 275 implemented_interfaces_full_paths), |
238 'dependencies_include_paths': (partial_interfaces_include_paths + | 276 'dependencies_include_paths': (partial_interfaces_include_paths + |
239 implemented_interfaces_include_paths)
, | 277 implemented_interfaces_include_paths)
, |
240 }) | 278 }) |
241 | 279 |
242 # Clean up temporary private information | 280 # Clean up temporary private information |
243 for interface_info in interfaces_info.itervalues(): | 281 for interface_info in interfaces_info.itervalues(): |
244 del interface_info['extended_attributes'] | 282 del interface_info['extended_attributes'] |
245 del interface_info['is_legacy_treat_as_partial_interface'] | 283 del interface_info['is_legacy_treat_as_partial_interface'] |
246 del interface_info['parent'] | 284 del interface_info['parent'] |
247 | 285 |
| 286 # Compute global_type_info to interfaces_info so that idl_compiler does |
| 287 # not need to always calculate the info in __init__. |
| 288 compute_global_type_info() |
| 289 |
248 | 290 |
249 ################################################################################ | 291 ################################################################################ |
250 | 292 |
251 def main(): | 293 def main(): |
252 options, args = parse_options() | 294 options, args = parse_options() |
253 # args = Input1, Input2, ..., Output | 295 # args = Input1, Input2, ..., Output |
254 interfaces_info_filename = args.pop() | 296 interfaces_info_filename = args.pop() |
255 info_individuals = read_pickle_files(args) | 297 info_individuals = read_pickle_files(args) |
256 | 298 |
257 compute_interfaces_info_overall(info_individuals) | 299 compute_interfaces_info_overall(info_individuals) |
258 write_pickle_file(interfaces_info_filename, | 300 write_pickle_file(interfaces_info_filename, |
259 interfaces_info, | 301 interfaces_info, |
260 options.write_file_only_if_changed) | 302 options.write_file_only_if_changed) |
261 | 303 |
262 | 304 |
263 if __name__ == '__main__': | 305 if __name__ == '__main__': |
264 sys.exit(main()) | 306 sys.exit(main()) |
OLD | NEW |