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

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

Issue 938403007: Support [TypeChecking] on dependent/partial interfaces. (Closed) Base URL: svn://svn.chromium.org/blink/trunk
Patch Set: Improve merging of attributes Created 5 years, 10 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 | Annotate | Revision Log
« no previous file with comments | « no previous file | Source/bindings/tests/idls/core/TestInterface3.idl » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 DEPENDENCY_EXTENDED_ATTRIBUTES = set([ 47 #
48 'Conditional', 48 # Paired with the extended attribute name is its value type; needed to be able
49 'PerContextEnabled', 49 # to correctly merge interface-level occurrences with ones that may
50 'RuntimeEnabled', 50 # be present on the method/attribute/constant.
51 ]) 51 DEPENDENCY_EXTENDED_ATTRIBUTES = {
52 'Conditional': 'string',
53 'PerContextEnabled': 'string',
54 'RuntimeEnabled': 'string',
55 'TypeChecking': 'list',
56 }
52 57
53 58
54 class InterfaceDependencyResolver(object): 59 class InterfaceDependencyResolver(object):
55 def __init__(self, interfaces_info, reader): 60 def __init__(self, interfaces_info, reader):
56 """Initialize dependency resolver. 61 """Initialize dependency resolver.
57 62
58 Args: 63 Args:
59 interfaces_info: 64 interfaces_info:
60 dict of interfaces information, from compute_dependencies.py 65 dict of interfaces information, from compute_dependencies.py
61 reader: 66 reader:
(...skipping 174 matching lines...) Expand 10 before | Expand all | Expand 10 after
236 * applying certain extended attributes from the dependency interface 241 * applying certain extended attributes from the dependency interface
237 to its members 242 to its members
238 * storing the C++ class of the implementation in an internal 243 * storing the C++ class of the implementation in an internal
239 extended attribute of each member, [PartialInterfaceImplementedAs] 244 extended attribute of each member, [PartialInterfaceImplementedAs]
240 245
241 No return: modifies dependency_interface in place. 246 No return: modifies dependency_interface in place.
242 """ 247 """
243 merged_extended_attributes = dict( 248 merged_extended_attributes = dict(
244 (key, value) 249 (key, value)
245 for key, value in dependency_interface.extended_attributes.iteritems() 250 for key, value in dependency_interface.extended_attributes.iteritems()
246 if key in DEPENDENCY_EXTENDED_ATTRIBUTES) 251 if key in DEPENDENCY_EXTENDED_ATTRIBUTES.keys())
247 252
248 # A partial interface's members are implemented as static member functions 253 # A partial interface's members are implemented as static member functions
249 # in a separate C++ class. This class name is stored in 254 # in a separate C++ class. This class name is stored in
250 # [PartialInterfaceImplementedAs] which defaults to the basename of 255 # [PartialInterfaceImplementedAs] which defaults to the basename of
251 # dependency IDL file. 256 # dependency IDL file.
252 # This class name can be overridden by [ImplementedAs] on the partial 257 # This class name can be overridden by [ImplementedAs] on the partial
253 # interface definition. 258 # interface definition.
254 # 259 #
255 # Note that implemented interfaces do *not* need [ImplementedAs], since 260 # Note that implemented interfaces do *not* need [ImplementedAs], since
256 # they are implemented on the C++ object |impl| itself, just like members of 261 # they are implemented on the C++ object |impl| itself, just like members of
(...skipping 10 matching lines...) Expand all
267 # and members: 272 # and members:
268 # for Blink class name and function name (or constant name), respectively. 273 # for Blink class name and function name (or constant name), respectively.
269 # Thus we do not want to copy this from the interface to the member, but 274 # Thus we do not want to copy this from the interface to the member, but
270 # instead extract it and handle it separately. 275 # instead extract it and handle it separately.
271 if (dependency_interface.is_partial or 276 if (dependency_interface.is_partial or
272 'LegacyTreatAsPartialInterface' in dependency_interface.extended_attribu tes): 277 'LegacyTreatAsPartialInterface' in dependency_interface.extended_attribu tes):
273 merged_extended_attributes['PartialInterfaceImplementedAs'] = ( 278 merged_extended_attributes['PartialInterfaceImplementedAs'] = (
274 dependency_interface.extended_attributes.get( 279 dependency_interface.extended_attributes.get(
275 'ImplementedAs', dependency_interface_basename)) 280 'ImplementedAs', dependency_interface_basename))
276 281
282 def update_attributes(attributes, extras):
283 def toList(x):
bashi 2015/02/23 01:54:11 nit: toList() -> to_list()
sof 2015/02/23 06:08:55 thanks, done.
284 if type(x) is list:
285 return x
286 else:
287 return [x]
288
289 for key, value in extras.items():
290 if key 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] = toList(attributes[key]) + toList(value)
296 else:
297 attributes[key] = value
298
277 for attribute in dependency_interface.attributes: 299 for attribute in dependency_interface.attributes:
278 attribute.extended_attributes.update(merged_extended_attributes) 300 update_attributes(attribute.extended_attributes, merged_extended_attribu tes)
279 for constant in dependency_interface.constants: 301 for constant in dependency_interface.constants:
280 constant.extended_attributes.update(merged_extended_attributes) 302 update_attributes(constant.extended_attributes, merged_extended_attribut es)
281 for operation in dependency_interface.operations: 303 for operation in dependency_interface.operations:
282 operation.extended_attributes.update(merged_extended_attributes) 304 update_attributes(operation.extended_attributes, merged_extended_attribu tes)
OLDNEW
« no previous file with comments | « no previous file | Source/bindings/tests/idls/core/TestInterface3.idl » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698