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

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

Issue 426583003: Revert of Enable the WebIDL [Exposed] annotation on an interface's members. (Closed) Base URL: svn://svn.chromium.org/blink/trunk
Patch Set: Created 6 years, 4 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 | « Source/bindings/scripts/v8_methods.py ('k') | Source/bindings/templates/interface.h » ('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 56 matching lines...) Expand 10 before | Expand all | Expand 10 after
67 return any(extended_attribute in definition_or_member.extended_attributes 67 return any(extended_attribute in definition_or_member.extended_attributes
68 for extended_attribute in extended_attribute_list) 68 for extended_attribute in extended_attribute_list)
69 69
70 70
71 def has_extended_attribute_value(definition_or_member, name, value): 71 def has_extended_attribute_value(definition_or_member, name, value):
72 extended_attributes = definition_or_member.extended_attributes 72 extended_attributes = definition_or_member.extended_attributes
73 return (name in extended_attributes and 73 return (name in extended_attributes and
74 extended_attribute_value_contains(extended_attributes[name], value)) 74 extended_attribute_value_contains(extended_attributes[name], value))
75 75
76 76
77 def sorted_extended_attribute_set(definition_or_member, name):
78 extended_attributes = definition_or_member.extended_attributes
79 if name not in extended_attributes:
80 return []
81
82 attribute_values = re.split('[|&]', extended_attributes[name])
83 return sorted(attribute_values)
84
85
86 ################################################################################ 77 ################################################################################
87 # String handling 78 # String handling
88 ################################################################################ 79 ################################################################################
89 80
90 def capitalize(name): 81 def capitalize(name):
91 """Capitalize first letter or initial acronym (used in setter names).""" 82 """Capitalize first letter or initial acronym (used in setter names)."""
92 for acronym in ACRONYMS: 83 for acronym in ACRONYMS:
93 if name.startswith(acronym.lower()): 84 if name.startswith(acronym.lower()):
94 return name.replace(acronym.lower(), acronym) 85 return name.replace(acronym.lower(), acronym)
95 return name[0].upper() + name[1:] 86 return name[0].upper() + name[1:]
(...skipping 131 matching lines...) Expand 10 before | Expand all | Expand 10 after
227 218
228 # [DeprecateAs] 219 # [DeprecateAs]
229 def deprecate_as(member): 220 def deprecate_as(member):
230 extended_attributes = member.extended_attributes 221 extended_attributes = member.extended_attributes
231 if 'DeprecateAs' not in extended_attributes: 222 if 'DeprecateAs' not in extended_attributes:
232 return None 223 return None
233 includes.add('core/frame/UseCounter.h') 224 includes.add('core/frame/UseCounter.h')
234 return extended_attributes['DeprecateAs'] 225 return extended_attributes['DeprecateAs']
235 226
236 227
237 # [Exposed]
238 EXPOSED_EXECUTION_CONTEXT_METHOD = {
239 'DedicatedWorker': 'isDedicatedWorkerGlobalScope',
240 'ServiceWorker': 'isServiceWorkerGlobalScope',
241 'SharedWorker': 'isSharedWorkerGlobalScope',
242 'Window': 'isDocument',
243 'Worker': 'isWorkerGlobalScope',
244 }
245
246
247 def exposed(definition_or_member, interface):
248 exposure_set = sorted_extended_attribute_set(definition_or_member, 'Exposed' )
249 if not exposure_set:
250 return None
251
252 interface_exposure_set = expanded_exposure_set_for_interface(interface)
253
254 # Methods must not be exposed to a broader scope than their interface.
255 if not set(exposure_set).issubset(interface_exposure_set):
256 raise ValueError('Interface members\' exposure sets must be a subset of the interface\'s.')
257
258 exposure_checks = []
259 for environment in exposure_set:
260 # Methods must be exposed on one of the scopes known to Blink.
261 if environment not in EXPOSED_EXECUTION_CONTEXT_METHOD:
262 raise ValueError('Values for the [Exposed] annotation must reflect t o a valid exposure scope.')
263
264 exposure_checks.append('context->%s()' % EXPOSED_EXECUTION_CONTEXT_METHO D[environment])
265
266 return ' || '.join(exposure_checks)
267
268
269 def expanded_exposure_set_for_interface(interface):
270 exposure_set = sorted_extended_attribute_set(interface, 'Exposed')
271
272 # "Worker" is an aggregation for the different kinds of workers.
273 if 'Worker' in exposure_set:
274 exposure_set.extend(('DedicatedWorker', 'SharedWorker', 'ServiceWorker') )
275
276 return sorted(set(exposure_set))
277
278
279 # [GarbageCollected], [WillBeGarbageCollected] 228 # [GarbageCollected], [WillBeGarbageCollected]
280 def gc_type(definition): 229 def gc_type(definition):
281 extended_attributes = definition.extended_attributes 230 extended_attributes = definition.extended_attributes
282 if 'GarbageCollected' in extended_attributes: 231 if 'GarbageCollected' in extended_attributes:
283 return 'GarbageCollectedObject' 232 return 'GarbageCollectedObject'
284 elif 'WillBeGarbageCollected' in extended_attributes: 233 elif 'WillBeGarbageCollected' in extended_attributes:
285 return 'WillBeGarbageCollectedObject' 234 return 'WillBeGarbageCollectedObject'
286 return 'RefCountedObject' 235 return 'RefCountedObject'
287 236
288 237
(...skipping 29 matching lines...) Expand all
318 267
319 The returned function checks if a method/attribute is enabled. 268 The returned function checks if a method/attribute is enabled.
320 Given extended attribute RuntimeEnabled=FeatureName, return: 269 Given extended attribute RuntimeEnabled=FeatureName, return:
321 RuntimeEnabledFeatures::{featureName}Enabled 270 RuntimeEnabledFeatures::{featureName}Enabled
322 """ 271 """
323 extended_attributes = definition_or_member.extended_attributes 272 extended_attributes = definition_or_member.extended_attributes
324 if 'RuntimeEnabled' not in extended_attributes: 273 if 'RuntimeEnabled' not in extended_attributes:
325 return None 274 return None
326 feature_name = extended_attributes['RuntimeEnabled'] 275 feature_name = extended_attributes['RuntimeEnabled']
327 return 'RuntimeEnabledFeatures::%sEnabled' % uncapitalize(feature_name) 276 return 'RuntimeEnabledFeatures::%sEnabled' % uncapitalize(feature_name)
OLDNEW
« no previous file with comments | « Source/bindings/scripts/v8_methods.py ('k') | Source/bindings/templates/interface.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698