OLD | NEW |
1 # Copyright (C) 2013 Google Inc. All rights reserved. | 1 # Copyright (C) 2013 Google Inc. All rights reserved. |
2 # | 2 # |
3 # Redistribution and use in source and binary forms, with or without | 3 # Redistribution and use in source and binary forms, with or without |
4 # modification, are permitted provided that the following conditions are | 4 # modification, are permitted provided that the following conditions are |
5 # met: | 5 # met: |
6 # | 6 # |
7 # * Redistributions of source code must retain the above copyright | 7 # * Redistributions of source code must retain the above copyright |
8 # notice, this list of conditions and the following disclaimer. | 8 # notice, this list of conditions and the following disclaimer. |
9 # * Redistributions in binary form must reproduce the above | 9 # * Redistributions in binary form must reproduce the above |
10 # copyright notice, this list of conditions and the following disclaimer | 10 # copyright notice, this list of conditions and the following disclaimer |
(...skipping 302 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
313 for constant in dependency_interface.constants: | 313 for constant in dependency_interface.constants: |
314 update_attributes(constant.extended_attributes, merged_extended_attribut
es) | 314 update_attributes(constant.extended_attributes, merged_extended_attribut
es) |
315 for operation in dependency_interface.operations: | 315 for operation in dependency_interface.operations: |
316 update_attributes(operation.extended_attributes, merged_extended_attribu
tes) | 316 update_attributes(operation.extended_attributes, merged_extended_attribu
tes) |
317 | 317 |
318 | 318 |
319 def inherit_unforgeable_attributes(resolved_definitions, interfaces_info): | 319 def inherit_unforgeable_attributes(resolved_definitions, interfaces_info): |
320 """Inherits [Unforgeable] attributes and updates the arguments accordingly. | 320 """Inherits [Unforgeable] attributes and updates the arguments accordingly. |
321 | 321 |
322 For each interface in |resolved_definitions|, collects all [Unforgeable] | 322 For each interface in |resolved_definitions|, collects all [Unforgeable] |
323 attributes in ancestor interfaces in the same component and adds them to | 323 attributes in ancestor interfaces and adds them to the interface. |
324 the interface. 'referenced_interfaces' and 'cpp_includes' in | 324 'referenced_interfaces' and 'cpp_includes' in |interfaces_info| are updated |
325 |interfaces_info| are updated accordingly. | 325 accordingly. |
326 """ | 326 """ |
327 def collect_unforgeable_attributes_in_ancestors(interface_name, component): | 327 def collect_unforgeable_attributes_in_ancestors(interface_name, component): |
328 if not interface_name: | 328 if not interface_name: |
329 # unforgeable_attributes, referenced_interfaces, cpp_includes | 329 # unforgeable_attributes, referenced_interfaces, cpp_includes |
330 return [], [], set() | 330 return [], [], set() |
331 interface = interfaces_info[interface_name] | 331 interface = interfaces_info[interface_name] |
332 unforgeable_attributes, referenced_interfaces, cpp_includes = collect_un
forgeable_attributes_in_ancestors(interface.get('parent'), component) | 332 unforgeable_attributes, referenced_interfaces, cpp_includes = collect_un
forgeable_attributes_in_ancestors(interface.get('parent'), component) |
333 this_unforgeable = interface.get('unforgeable_attributes', {}).get(compo
nent, []) | 333 this_unforgeable = interface.get('unforgeable_attributes', []) |
334 unforgeable_attributes.extend(this_unforgeable) | 334 unforgeable_attributes.extend(this_unforgeable) |
335 this_referenced = [attr.idl_type.base_type for attr in this_unforgeable | 335 this_referenced = [attr.idl_type.base_type for attr in this_unforgeable |
336 if attr.idl_type.base_type in | 336 if attr.idl_type.base_type in |
337 interface.get('referenced_interfaces', [])] | 337 interface.get('referenced_interfaces', [])] |
338 referenced_interfaces.extend(this_referenced) | 338 referenced_interfaces.extend(this_referenced) |
339 cpp_includes.update(interface.get('cpp_includes', {}).get(component, {})
) | 339 cpp_includes.update(interface.get('cpp_includes', {}).get(component, {})
) |
340 return unforgeable_attributes, referenced_interfaces, cpp_includes | 340 return unforgeable_attributes, referenced_interfaces, cpp_includes |
341 | 341 |
342 for component, definitions in resolved_definitions.iteritems(): | 342 for component, definitions in resolved_definitions.iteritems(): |
343 for interface_name, interface in definitions.interfaces.iteritems(): | 343 for interface_name, interface in definitions.interfaces.iteritems(): |
344 interface_info = interfaces_info[interface_name] | 344 interface_info = interfaces_info[interface_name] |
345 inherited_unforgeable_attributes, referenced_interfaces, cpp_include
s = collect_unforgeable_attributes_in_ancestors(interface_info.get('parent'), co
mponent) | 345 inherited_unforgeable_attributes, referenced_interfaces, cpp_include
s = collect_unforgeable_attributes_in_ancestors(interface_info.get('parent'), co
mponent) |
346 # This loop may process the same interface many times, so it's | 346 # This loop may process the same interface many times, so it's |
347 # possible that we're adding the same attributes twice or more. | 347 # possible that we're adding the same attributes twice or more. |
348 # So check if there is a duplicate. | 348 # So check if there is a duplicate. |
349 for attr in inherited_unforgeable_attributes: | 349 for attr in inherited_unforgeable_attributes: |
350 if attr not in interface.attributes: | 350 if attr not in interface.attributes: |
351 interface.attributes.append(attr) | 351 interface.attributes.append(attr) |
352 referenced_interfaces.extend(interface_info.get('referenced_interfac
es', [])) | 352 referenced_interfaces.extend(interface_info.get('referenced_interfac
es', [])) |
353 interface_info['referenced_interfaces'] = sorted(set(referenced_inte
rfaces)) | 353 interface_info['referenced_interfaces'] = sorted(set(referenced_inte
rfaces)) |
354 merge_dict_recursively(interface_info, | 354 merge_dict_recursively(interface_info, |
355 {'cpp_includes': {component: cpp_includes}}) | 355 {'cpp_includes': {component: cpp_includes}}) |
OLD | NEW |