| 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 29 matching lines...) Expand all Loading... |
| 40 from utilities import idl_filename_to_component, is_valid_component_dependency,
merge_dict_recursively | 40 from utilities import idl_filename_to_component, is_valid_component_dependency,
merge_dict_recursively |
| 41 | 41 |
| 42 # The following extended attributes can be applied to a dependency interface, | 42 # The following extended attributes can be applied to a dependency interface, |
| 43 # and are then applied to the individual members when merging. | 43 # and are then applied to the individual members when merging. |
| 44 # Note that this moves the extended attribute from the interface to the member, | 44 # Note that this moves the extended attribute from the interface to the member, |
| 45 # which changes the semantics and yields different code than the same extended | 45 # which changes the semantics and yields different code than the same extended |
| 46 # attribute on the main interface. | 46 # attribute on the main interface. |
| 47 DEPENDENCY_EXTENDED_ATTRIBUTES = frozenset([ | 47 DEPENDENCY_EXTENDED_ATTRIBUTES = frozenset([ |
| 48 'OriginTrialEnabled', | 48 'OriginTrialEnabled', |
| 49 'RuntimeEnabled', | 49 'RuntimeEnabled', |
| 50 'SecureContext', |
| 50 ]) | 51 ]) |
| 51 | 52 |
| 52 | 53 |
| 53 class InterfaceDependencyResolver(object): | 54 class InterfaceDependencyResolver(object): |
| 54 def __init__(self, interfaces_info, reader): | 55 def __init__(self, interfaces_info, reader): |
| 55 """Initialize dependency resolver. | 56 """Initialize dependency resolver. |
| 56 | 57 |
| 57 Args: | 58 Args: |
| 58 interfaces_info: | 59 interfaces_info: |
| 59 dict of interfaces information, from compute_dependencies.py | 60 dict of interfaces information, from compute_dependencies.py |
| (...skipping 196 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 256 The data storing consists of: | 257 The data storing consists of: |
| 257 * moving certain extended attributes from the dependency interface | 258 * moving certain extended attributes from the dependency interface |
| 258 to its members (deleting the extended attribute from the interface) | 259 to its members (deleting the extended attribute from the interface) |
| 259 * storing the C++ class of the implementation in an internal | 260 * storing the C++ class of the implementation in an internal |
| 260 extended attribute of each member, [PartialInterfaceImplementedAs] | 261 extended attribute of each member, [PartialInterfaceImplementedAs] |
| 261 | 262 |
| 262 No return: modifies dependency_interface in place. | 263 No return: modifies dependency_interface in place. |
| 263 """ | 264 """ |
| 264 merged_extended_attributes = {} | 265 merged_extended_attributes = {} |
| 265 for key in DEPENDENCY_EXTENDED_ATTRIBUTES: | 266 for key in DEPENDENCY_EXTENDED_ATTRIBUTES: |
| 266 value = dependency_interface.extended_attributes.get(key) | 267 if key not in dependency_interface.extended_attributes: |
| 267 if not value: | |
| 268 continue | 268 continue |
| 269 | 269 |
| 270 merged_extended_attributes[key] = value | 270 merged_extended_attributes[key] = dependency_interface.extended_attribut
es[key] |
| 271 # Remove the merged attributes from the original dependency interface. | 271 # Remove the merged attributes from the original dependency interface. |
| 272 # This ensures that if other dependency interfaces are merged onto this | 272 # This ensures that if other dependency interfaces are merged onto this |
| 273 # one, its extended_attributes do not leak through | 273 # one, its extended_attributes do not leak through |
| 274 # (https://crbug.com/603782). | 274 # (https://crbug.com/603782). |
| 275 del dependency_interface.extended_attributes[key] | 275 del dependency_interface.extended_attributes[key] |
| 276 | 276 |
| 277 # A partial interface's members are implemented as static member functions | 277 # A partial interface's members are implemented as static member functions |
| 278 # in a separate C++ class. This class name is stored in | 278 # in a separate C++ class. This class name is stored in |
| 279 # [PartialInterfaceImplementedAs] which defaults to the basename of | 279 # [PartialInterfaceImplementedAs] which defaults to the basename of |
| 280 # dependency IDL file. | 280 # dependency IDL file. |
| (...skipping 65 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 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 |