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 155 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
166 | 166 |
167 # Handle partial interfaces | 167 # Handle partial interfaces |
168 partial_interface_name = get_partial_interface_name_from_idl(idl_file_conten ts) | 168 partial_interface_name = get_partial_interface_name_from_idl(idl_file_conten ts) |
169 if partial_interface_name: | 169 if partial_interface_name: |
170 add_paths_to_partials_dict(partial_interface_name, full_path, this_inclu de_path) | 170 add_paths_to_partials_dict(partial_interface_name, full_path, this_inclu de_path) |
171 return | 171 return |
172 | 172 |
173 # If not a partial interface, the basename is the interface name | 173 # If not a partial interface, the basename is the interface name |
174 interface_name, _ = os.path.splitext(os.path.basename(idl_filename)) | 174 interface_name, _ = os.path.splitext(os.path.basename(idl_filename)) |
175 | 175 |
176 # 'implements' statements can be included in either the file for the | |
177 # implement*ing* interface (lhs of 'implements') or implement*ed* interface | |
178 # (rhs of 'implements'). Store both for now, then merge to implement*ing* | |
179 # interface later. | |
176 left_interfaces, right_interfaces = get_implements_from_idl(idl_file_content s, interface_name) | 180 left_interfaces, right_interfaces = get_implements_from_idl(idl_file_content s, interface_name) |
177 | 181 |
178 interfaces_info[interface_name] = { | 182 interfaces_info[interface_name] = { |
179 'full_path': full_path, | 183 'full_path': full_path, |
180 'implemented_as': implemented_as, | 184 'implemented_as': implemented_as, |
185 'implemented_by_interfaces': left_interfaces, # private, merged to next | |
181 'implements_interfaces': right_interfaces, | 186 'implements_interfaces': right_interfaces, |
182 'include_path': this_include_path, | 187 'include_path': this_include_path, |
183 # FIXME: temporary private field, while removing old treatement of | 188 # FIXME: temporary private field, while removing old treatement of |
184 # 'implements': http://crbug.com/360435 | 189 # 'implements': http://crbug.com/360435 |
185 'is_legacy_treat_as_partial_interface': 'LegacyTreatAsPartialInterface' in extended_attributes, | 190 'is_legacy_treat_as_partial_interface': 'LegacyTreatAsPartialInterface' in extended_attributes, |
186 'is_callback_interface': is_callback_interface_from_idl(idl_file_content s), | 191 'is_callback_interface': is_callback_interface_from_idl(idl_file_content s), |
187 # Interfaces that are referenced (used as types) and that we introspect | 192 # Interfaces that are referenced (used as types) and that we introspect |
188 # during code generation (beyond interface-level data ([ImplementedAs], | 193 # during code generation (beyond interface-level data ([ImplementedAs], |
189 # is_callback_interface, ancestors, and inherited extended attributes): | 194 # is_callback_interface, ancestors, and inherited extended attributes): |
190 # deep dependencies. | 195 # deep dependencies. |
191 # These cause rebuilds of referrers, due to the dependency, so these | 196 # These cause rebuilds of referrers, due to the dependency, so these |
192 # should be minimized; currently only targets of [PutForwards]. | 197 # should be minimized; currently only targets of [PutForwards]. |
193 'referenced_interfaces': get_put_forward_interfaces_from_idl(idl_file_co ntents), | 198 'referenced_interfaces': get_put_forward_interfaces_from_idl(idl_file_co ntents), |
194 } | 199 } |
195 | 200 |
196 for left_interface_name in left_interfaces: | |
197 interface_info = interfaces_info[left_interface_name] | |
Nils Barth (inactive)
2014/05/08 06:31:45
This fails with
KeyError: 'Window'
...on r-b-t for
| |
198 interface_info['implements_interfaces'].append(interface_name) | |
199 | |
200 # Record inheritance information | 201 # Record inheritance information |
201 inherited_extended_attributes_by_interface[interface_name] = dict( | 202 inherited_extended_attributes_by_interface[interface_name] = dict( |
202 (key, value) | 203 (key, value) |
203 for key, value in extended_attributes.iteritems() | 204 for key, value in extended_attributes.iteritems() |
204 if key in INHERITED_EXTENDED_ATTRIBUTES) | 205 if key in INHERITED_EXTENDED_ATTRIBUTES) |
205 parent = get_parent_interface(idl_file_contents) | 206 parent = get_parent_interface(idl_file_contents) |
206 if parent: | 207 if parent: |
207 parent_interfaces[interface_name] = parent | 208 parent_interfaces[interface_name] = parent |
208 | 209 |
209 | 210 |
(...skipping 29 matching lines...) Expand all Loading... | |
239 compute_individual_info(idl_filename) | 240 compute_individual_info(idl_filename) |
240 | 241 |
241 # Once all individual files handled, can compute inheritance information | 242 # Once all individual files handled, can compute inheritance information |
242 # and dependencies | 243 # and dependencies |
243 | 244 |
244 # Compute inheritance info | 245 # Compute inheritance info |
245 for interface_name in interfaces_info: | 246 for interface_name in interfaces_info: |
246 compute_inheritance_info(interface_name) | 247 compute_inheritance_info(interface_name) |
247 | 248 |
248 # Compute dependencies | 249 # Compute dependencies |
250 # Move implements info from implement*ed* interface (rhs of 'implements') | |
251 # to implement*ing* interface (lhs of 'implements'). | |
252 # Note that moving an 'implements' statement between implementing and | |
253 # implemented files does not change the info (or hence cause a rebuild)! | |
254 for right_interface_name, interface_info in interfaces_info.iteritems(): | |
255 for left_interface_name in interface_info['implemented_by_interfaces']: | |
256 interfaces_info[left_interface_name]['implements_interfaces'].append (right_interface_name) | |
257 del interface_info['implemented_by_interfaces'] | |
Nils Barth (inactive)
2014/05/08 06:31:45
We *move* the info, not just copying it, which mea
| |
258 | |
249 # An IDL file's dependencies are partial interface files that extend it, | 259 # An IDL file's dependencies are partial interface files that extend it, |
250 # and files for other interfaces that this interfaces implements. | 260 # and files for other interfaces that this interfaces implements. |
251 for interface_name, interface_info in interfaces_info.iteritems(): | 261 for interface_name, interface_info in interfaces_info.iteritems(): |
252 partial_interface_paths = partial_interface_files[interface_name] | 262 partial_interface_paths = partial_interface_files[interface_name] |
253 partial_interfaces_full_paths = partial_interface_paths['full_paths'] | 263 partial_interfaces_full_paths = partial_interface_paths['full_paths'] |
254 # Partial interface definitions each need an include, as they are | 264 # Partial interface definitions each need an include, as they are |
255 # implemented in separate classes from the main interface. | 265 # implemented in separate classes from the main interface. |
256 partial_interfaces_include_paths = partial_interface_paths['include_path s'] | 266 partial_interfaces_include_paths = partial_interface_paths['include_path s'] |
257 | 267 |
258 implemented_interfaces = interface_info['implements_interfaces'] | 268 implemented_interfaces = interface_info['implements_interfaces'] |
(...skipping 44 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
303 idl_files.extend(args) | 313 idl_files.extend(args) |
304 | 314 |
305 compute_interfaces_info(idl_files) | 315 compute_interfaces_info(idl_files) |
306 write_pickle_file(options.interfaces_info_file, | 316 write_pickle_file(options.interfaces_info_file, |
307 interfaces_info, | 317 interfaces_info, |
308 options.write_file_only_if_changed) | 318 options.write_file_only_if_changed) |
309 | 319 |
310 | 320 |
311 if __name__ == '__main__': | 321 if __name__ == '__main__': |
312 sys.exit(main()) | 322 sys.exit(main()) |
OLD | NEW |