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 68 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
79 code changes (for inherited extended attributes). | 79 code changes (for inherited extended attributes). |
80 | 80 |
81 Design doc: http://www.chromium.org/developers/design-documents/idl-build | 81 Design doc: http://www.chromium.org/developers/design-documents/idl-build |
82 """ | 82 """ |
83 | 83 |
84 from collections import defaultdict | 84 from collections import defaultdict |
85 import cPickle as pickle | 85 import cPickle as pickle |
86 import optparse | 86 import optparse |
87 import sys | 87 import sys |
88 | 88 |
89 from utilities import idl_filename_to_component, read_pickle_files, write_pickle
_file | 89 from utilities import idl_filename_to_component, read_pickle_files, write_pickle
_file, merge_dict_recursively |
90 | 90 |
91 INHERITED_EXTENDED_ATTRIBUTES = set([ | 91 INHERITED_EXTENDED_ATTRIBUTES = set([ |
92 'ActiveDOMObject', | 92 'ActiveDOMObject', |
93 'DependentLifetime', | 93 'DependentLifetime', |
94 'GarbageCollected', | 94 'GarbageCollected', |
95 'WillBeGarbageCollected', | 95 'WillBeGarbageCollected', |
96 ]) | 96 ]) |
97 | 97 |
98 # Main variable (filled in and exported) | 98 # Main variable (filled in and exported) |
99 interfaces_info = {} | 99 interfaces_info = {} |
(...skipping 99 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
199 interfaces_info['will_be_garbage_collected_interfaces'] = will_be_garbage_co
llected_interfaces | 199 interfaces_info['will_be_garbage_collected_interfaces'] = will_be_garbage_co
llected_interfaces |
200 interfaces_info['component_dirs'] = component_dirs | 200 interfaces_info['component_dirs'] = component_dirs |
201 | 201 |
202 | 202 |
203 def compute_interfaces_info_overall(info_individuals): | 203 def compute_interfaces_info_overall(info_individuals): |
204 """Compute information about IDL files. | 204 """Compute information about IDL files. |
205 | 205 |
206 Information is stored in global interfaces_info. | 206 Information is stored in global interfaces_info. |
207 """ | 207 """ |
208 for info in info_individuals: | 208 for info in info_individuals: |
209 # No overlap between interface names, so ok to use dict.update | 209 merge_dict_recursively(interfaces_info, info['interfaces_info']) |
210 interfaces_info.update(info['interfaces_info']) | |
211 # Interfaces in one component may have partial interfaces in | 210 # Interfaces in one component may have partial interfaces in |
212 # another component. This is ok (not a layering violation), since | 211 # another component. This is ok (not a layering violation), since |
213 # partial interfaces are used to *extend* interfaces. | 212 # partial interfaces are used to *extend* interfaces. |
214 # We thus need to update or append if already present | 213 # We thus need to update or append if already present |
215 dict_of_dicts_of_lists_update_or_append( | 214 dict_of_dicts_of_lists_update_or_append( |
216 partial_interface_files, info['partial_interface_files']) | 215 partial_interface_files, info['partial_interface_files']) |
217 | 216 |
218 # Record inheritance information individually | 217 # Record inheritance information individually |
219 for interface_name, interface_info in interfaces_info.iteritems(): | 218 for interface_name, interface_info in interfaces_info.iteritems(): |
220 extended_attributes = interface_info['extended_attributes'] | 219 extended_attributes = interface_info['extended_attributes'] |
(...skipping 85 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
306 dependencies_other_component_full_paths, | 305 dependencies_other_component_full_paths, |
307 'dependencies_other_component_include_paths': | 306 'dependencies_other_component_include_paths': |
308 dependencies_other_component_include_paths, | 307 dependencies_other_component_include_paths, |
309 }) | 308 }) |
310 | 309 |
311 # Clean up temporary private information | 310 # Clean up temporary private information |
312 for interface_info in interfaces_info.itervalues(): | 311 for interface_info in interfaces_info.itervalues(): |
313 del interface_info['extended_attributes'] | 312 del interface_info['extended_attributes'] |
314 del interface_info['has_union_types'] | 313 del interface_info['has_union_types'] |
315 del interface_info['is_legacy_treat_as_partial_interface'] | 314 del interface_info['is_legacy_treat_as_partial_interface'] |
316 del interface_info['parent'] | |
317 | 315 |
318 # Compute global_type_info to interfaces_info so that idl_compiler does | 316 # Compute global_type_info to interfaces_info so that idl_compiler does |
319 # not need to always calculate the info in __init__. | 317 # not need to always calculate the info in __init__. |
320 compute_global_type_info() | 318 compute_global_type_info() |
321 | 319 |
322 | 320 |
323 ################################################################################ | 321 ################################################################################ |
324 | 322 |
325 def main(): | 323 def main(): |
326 options, args = parse_options() | 324 options, args = parse_options() |
327 # args = Input1, Input2, ..., Output | 325 # args = Input1, Input2, ..., Output |
328 interfaces_info_filename = args.pop() | 326 interfaces_info_filename = args.pop() |
329 info_individuals = read_pickle_files(args) | 327 info_individuals = read_pickle_files(args) |
330 | 328 |
331 compute_interfaces_info_overall(info_individuals) | 329 compute_interfaces_info_overall(info_individuals) |
332 write_pickle_file(interfaces_info_filename, | 330 write_pickle_file(interfaces_info_filename, |
333 interfaces_info, | 331 interfaces_info, |
334 options.write_file_only_if_changed) | 332 options.write_file_only_if_changed) |
335 | 333 |
336 | 334 |
337 if __name__ == '__main__': | 335 if __name__ == '__main__': |
338 sys.exit(main()) | 336 sys.exit(main()) |
OLD | NEW |