Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(146)

Side by Side Diff: Source/bindings/scripts/interface_dependency_resolver.py

Issue 971783002: IDL: Remove last traces of [TypeChecking=Unrestricted] (Closed) Base URL: https://chromium.googlesource.com/chromium/blink.git@master
Patch Set: Created 5 years, 9 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
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 26 matching lines...) Expand all
37 """ 37 """
38 38
39 import os.path 39 import os.path
40 from utilities import idl_filename_to_component, is_valid_component_dependency 40 from utilities import idl_filename_to_component, is_valid_component_dependency
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 # 47 DEPENDENCY_EXTENDED_ATTRIBUTES = frozenset([
48 # Paired with the extended attribute name is its value type; needed to be able 48 'Conditional',
49 # to correctly merge interface-level occurrences with ones that may 49 'PerContextEnabled',
50 # be present on the method/attribute/constant. 50 'RuntimeEnabled',
51 DEPENDENCY_EXTENDED_ATTRIBUTES = { 51 'TypeChecking',
52 'Conditional': 'string', 52 ])
53 'PerContextEnabled': 'string',
54 'RuntimeEnabled': 'string',
55 'TypeChecking': 'list',
56 }
57 53
58 54
59 class InterfaceDependencyResolver(object): 55 class InterfaceDependencyResolver(object):
60 def __init__(self, interfaces_info, reader): 56 def __init__(self, interfaces_info, reader):
61 """Initialize dependency resolver. 57 """Initialize dependency resolver.
62 58
63 Args: 59 Args:
64 interfaces_info: 60 interfaces_info:
65 dict of interfaces information, from compute_dependencies.py 61 dict of interfaces information, from compute_dependencies.py
66 reader: 62 reader:
(...skipping 174 matching lines...) Expand 10 before | Expand all | Expand 10 after
241 * applying certain extended attributes from the dependency interface 237 * applying certain extended attributes from the dependency interface
242 to its members 238 to its members
243 * storing the C++ class of the implementation in an internal 239 * storing the C++ class of the implementation in an internal
244 extended attribute of each member, [PartialInterfaceImplementedAs] 240 extended attribute of each member, [PartialInterfaceImplementedAs]
245 241
246 No return: modifies dependency_interface in place. 242 No return: modifies dependency_interface in place.
247 """ 243 """
248 merged_extended_attributes = dict( 244 merged_extended_attributes = dict(
249 (key, value) 245 (key, value)
250 for key, value in dependency_interface.extended_attributes.iteritems() 246 for key, value in dependency_interface.extended_attributes.iteritems()
251 if key in DEPENDENCY_EXTENDED_ATTRIBUTES.keys()) 247 if key in DEPENDENCY_EXTENDED_ATTRIBUTES)
252 248
253 # A partial interface's members are implemented as static member functions 249 # A partial interface's members are implemented as static member functions
254 # in a separate C++ class. This class name is stored in 250 # in a separate C++ class. This class name is stored in
255 # [PartialInterfaceImplementedAs] which defaults to the basename of 251 # [PartialInterfaceImplementedAs] which defaults to the basename of
256 # dependency IDL file. 252 # dependency IDL file.
257 # This class name can be overridden by [ImplementedAs] on the partial 253 # This class name can be overridden by [ImplementedAs] on the partial
258 # interface definition. 254 # interface definition.
259 # 255 #
260 # Note that implemented interfaces do *not* need [ImplementedAs], since 256 # Note that implemented interfaces do *not* need [ImplementedAs], since
261 # they are implemented on the C++ object |impl| itself, just like members of 257 # they are implemented on the C++ object |impl| itself, just like members of
(...skipping 11 matching lines...) Expand all
273 # for Blink class name and function name (or constant name), respectively. 269 # for Blink class name and function name (or constant name), respectively.
274 # Thus we do not want to copy this from the interface to the member, but 270 # Thus we do not want to copy this from the interface to the member, but
275 # instead extract it and handle it separately. 271 # instead extract it and handle it separately.
276 if (dependency_interface.is_partial or 272 if (dependency_interface.is_partial or
277 'LegacyTreatAsPartialInterface' in dependency_interface.extended_attribu tes): 273 'LegacyTreatAsPartialInterface' in dependency_interface.extended_attribu tes):
278 merged_extended_attributes['PartialInterfaceImplementedAs'] = ( 274 merged_extended_attributes['PartialInterfaceImplementedAs'] = (
279 dependency_interface.extended_attributes.get( 275 dependency_interface.extended_attributes.get(
280 'ImplementedAs', dependency_interface_basename)) 276 'ImplementedAs', dependency_interface_basename))
281 277
282 def update_attributes(attributes, extras): 278 def update_attributes(attributes, extras):
283 def to_list(x):
284 if type(x) is list:
285 return x
286 else:
287 return [x]
288
289 for key, value in extras.items(): 279 for key, value in extras.items():
290 if key in attributes: 280 if key not in attributes:
291 # Interface-level extended attributes do not take precedence
292 # over same attribute at the method/attribute/const-level.
293 # If the attribute value is a list, the two are combined.
294 if DEPENDENCY_EXTENDED_ATTRIBUTES[key] == 'list':
295 attributes[key] = to_list(attributes[key]) + to_list(value)
296 else:
297 attributes[key] = value 281 attributes[key] = value
298 282
299 for attribute in dependency_interface.attributes: 283 for attribute in dependency_interface.attributes:
300 update_attributes(attribute.extended_attributes, merged_extended_attribu tes) 284 update_attributes(attribute.extended_attributes, merged_extended_attribu tes)
301 for constant in dependency_interface.constants: 285 for constant in dependency_interface.constants:
302 update_attributes(constant.extended_attributes, merged_extended_attribut es) 286 update_attributes(constant.extended_attributes, merged_extended_attribut es)
303 for operation in dependency_interface.operations: 287 for operation in dependency_interface.operations:
304 update_attributes(operation.extended_attributes, merged_extended_attribu tes) 288 update_attributes(operation.extended_attributes, merged_extended_attribu tes)
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698