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

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

Issue 959933002: Move IDLs to 39 roll (Closed) Base URL: https://dart.googlecode.com/svn/third_party/WebCore
Patch Set: 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 | « bindings/scripts/v8_types.py ('k') | bindings/tests/idls/SVGTestInterface.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 40 matching lines...) Expand 10 before | Expand all | Expand 10 after
51 'WOFF', 51 'WOFF',
52 'XML', 52 'XML',
53 'XSLT', 53 'XSLT',
54 ] 54 ]
55 55
56 56
57 ################################################################################ 57 ################################################################################
58 # Extended attribute parsing 58 # Extended attribute parsing
59 ################################################################################ 59 ################################################################################
60 60
61 def extended_attribute_value_contains(extended_attribute_value, value): 61 def extended_attribute_value_contains(extended_attribute_value, key):
62 return (extended_attribute_value and 62 return (extended_attribute_value == key or
63 value in re.split('[|,]', extended_attribute_value)) 63 (isinstance(extended_attribute_value, list) and
64 key in extended_attribute_value))
64 65
65 66
66 def has_extended_attribute(definition_or_member, extended_attribute_list): 67 def has_extended_attribute(definition_or_member, extended_attribute_list):
67 return any(extended_attribute in definition_or_member.extended_attributes 68 return any(extended_attribute in definition_or_member.extended_attributes
68 for extended_attribute in extended_attribute_list) 69 for extended_attribute in extended_attribute_list)
69 70
70 71
71 def has_extended_attribute_value(definition_or_member, name, value): 72 def has_extended_attribute_value(definition_or_member, name, value):
72 extended_attributes = definition_or_member.extended_attributes 73 extended_attributes = definition_or_member.extended_attributes
73 return (name in extended_attributes and 74 return (name in extended_attributes and
74 extended_attribute_value_contains(extended_attributes[name], value)) 75 extended_attribute_value_contains(extended_attributes[name], value))
75 76
76 77
77 def sorted_extended_attribute_set(definition_or_member, name): 78 def extended_attribute_value_as_list(definition_or_member, name):
78 extended_attributes = definition_or_member.extended_attributes 79 extended_attributes = definition_or_member.extended_attributes
79 if name not in extended_attributes: 80 if name not in extended_attributes:
80 return [] 81 return None
81 82 value = extended_attributes[name]
82 attribute_values = re.split('[|,]', extended_attributes[name]) 83 if isinstance(value, list):
83 return sorted(attribute_values) 84 return value
85 return [value]
84 86
85 87
86 ################################################################################ 88 ################################################################################
87 # String handling 89 # String handling
88 ################################################################################ 90 ################################################################################
89 91
90 def capitalize(name): 92 def capitalize(name):
91 """Capitalize first letter or initial acronym (used in setter names).""" 93 """Capitalize first letter or initial acronym (used in setter names)."""
92 for acronym in ACRONYMS: 94 for acronym in ACRONYMS:
93 if name.startswith(acronym.lower()): 95 if name.startswith(acronym.lower()):
(...skipping 121 matching lines...) Expand 10 before | Expand all | Expand 10 after
215 DELIMITER_TO_OPERATOR = { 217 DELIMITER_TO_OPERATOR = {
216 '|': '||', 218 '|': '||',
217 ',': '&&', 219 ',': '&&',
218 } 220 }
219 221
220 222
221 def conditional_string(definition_or_member): 223 def conditional_string(definition_or_member):
222 extended_attributes = definition_or_member.extended_attributes 224 extended_attributes = definition_or_member.extended_attributes
223 if 'Conditional' not in extended_attributes: 225 if 'Conditional' not in extended_attributes:
224 return None 226 return None
225 conditional = extended_attributes['Conditional'] 227 return 'ENABLE(%s)' % extended_attributes['Conditional']
226 for delimiter in ',|':
227 if delimiter in conditional:
228 conditions = conditional.split(delimiter)
229 operator_separator = ' %s ' % DELIMITER_TO_OPERATOR[delimiter]
230 return operator_separator.join('ENABLE(%s)' % expression for express ion in sorted(conditions))
231 return 'ENABLE(%s)' % conditional
232 228
233 229
234 # [DeprecateAs] 230 # [DeprecateAs]
235 def deprecate_as(member): 231 def deprecate_as(member):
236 extended_attributes = member.extended_attributes 232 extended_attributes = member.extended_attributes
237 if 'DeprecateAs' not in extended_attributes: 233 if 'DeprecateAs' not in extended_attributes:
238 return None 234 return None
239 includes.add('core/frame/UseCounter.h') 235 includes.add('core/frame/UseCounter.h')
240 return extended_attributes['DeprecateAs'] 236 return extended_attributes['DeprecateAs']
241 237
242 238
243 # [Exposed] 239 # [Exposed]
244 EXPOSED_EXECUTION_CONTEXT_METHOD = { 240 EXPOSED_EXECUTION_CONTEXT_METHOD = {
245 'DedicatedWorker': 'isDedicatedWorkerGlobalScope', 241 'DedicatedWorker': 'isDedicatedWorkerGlobalScope',
246 'ServiceWorker': 'isServiceWorkerGlobalScope', 242 'ServiceWorker': 'isServiceWorkerGlobalScope',
247 'SharedWorker': 'isSharedWorkerGlobalScope', 243 'SharedWorker': 'isSharedWorkerGlobalScope',
248 'Window': 'isDocument', 244 'Window': 'isDocument',
249 'Worker': 'isWorkerGlobalScope', 245 'Worker': 'isWorkerGlobalScope',
250 } 246 }
251 247
252 248
253 def exposed(definition_or_member, interface): 249 def exposed(definition_or_member, interface):
254 exposure_set = sorted_extended_attribute_set(definition_or_member, 'Exposed' ) 250 exposure_set = extended_attribute_value_as_list(definition_or_member, 'Expos ed')
255 if not exposure_set: 251 if not exposure_set:
256 return None 252 return None
257 253
258 interface_exposure_set = expanded_exposure_set_for_interface(interface) 254 interface_exposure_set = expanded_exposure_set_for_interface(interface)
259 255
260 # Methods must not be exposed to a broader scope than their interface. 256 # Methods must not be exposed to a broader scope than their interface.
261 if not set(exposure_set).issubset(interface_exposure_set): 257 if not set(exposure_set).issubset(interface_exposure_set):
262 raise ValueError('Interface members\' exposure sets must be a subset of the interface\'s.') 258 raise ValueError('Interface members\' exposure sets must be a subset of the interface\'s.')
263 259
264 exposure_checks = [] 260 exposure_checks = []
265 for environment in exposure_set: 261 for environment in exposure_set:
266 # Methods must be exposed on one of the scopes known to Blink. 262 # Methods must be exposed on one of the scopes known to Blink.
267 if environment not in EXPOSED_EXECUTION_CONTEXT_METHOD: 263 if environment not in EXPOSED_EXECUTION_CONTEXT_METHOD:
268 raise ValueError('Values for the [Exposed] annotation must reflect t o a valid exposure scope.') 264 raise ValueError('Values for the [Exposed] annotation must reflect t o a valid exposure scope.')
269 265
270 exposure_checks.append('context->%s()' % EXPOSED_EXECUTION_CONTEXT_METHO D[environment]) 266 exposure_checks.append('context->%s()' % EXPOSED_EXECUTION_CONTEXT_METHO D[environment])
271 267
272 return ' || '.join(exposure_checks) 268 return ' || '.join(exposure_checks)
273 269
274 270
275 def expanded_exposure_set_for_interface(interface): 271 def expanded_exposure_set_for_interface(interface):
276 exposure_set = sorted_extended_attribute_set(interface, 'Exposed') 272 exposure_set = extended_attribute_value_as_list(interface, 'Exposed')
277 273
278 # "Worker" is an aggregation for the different kinds of workers. 274 # "Worker" is an aggregation for the different kinds of workers.
279 if 'Worker' in exposure_set: 275 if 'Worker' in exposure_set:
280 exposure_set.extend(('DedicatedWorker', 'SharedWorker', 'ServiceWorker') ) 276 exposure_set.extend(('DedicatedWorker', 'SharedWorker', 'ServiceWorker') )
281 277
282 return sorted(set(exposure_set)) 278 return sorted(set(exposure_set))
283 279
284 280
285 # [GarbageCollected], [WillBeGarbageCollected] 281 # [GarbageCollected], [WillBeGarbageCollected]
286 def gc_type(definition): 282 def gc_type(definition):
(...skipping 45 matching lines...) Expand 10 before | Expand all | Expand 10 after
332 feature_name = extended_attributes['RuntimeEnabled'] 328 feature_name = extended_attributes['RuntimeEnabled']
333 return 'RuntimeEnabledFeatures::%sEnabled' % uncapitalize(feature_name) 329 return 'RuntimeEnabledFeatures::%sEnabled' % uncapitalize(feature_name)
334 330
335 331
336 ################################################################################ 332 ################################################################################
337 # Dart Specific extended attributes 333 # Dart Specific extended attributes
338 ################################################################################ 334 ################################################################################
339 def dart_custom_method(extended_attributes): 335 def dart_custom_method(extended_attributes):
340 return ('DartCustom' in extended_attributes and 336 return ('DartCustom' in extended_attributes and
341 extended_attribute_value_contains(extended_attributes['DartCustom'], 'New')) 337 extended_attribute_value_contains(extended_attributes['DartCustom'], 'New'))
OLDNEW
« no previous file with comments | « bindings/scripts/v8_types.py ('k') | bindings/tests/idls/SVGTestInterface.idl » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698