OLD | NEW |
1 # Copyright (C) 2013 Google Inc. All rights reserved. | 1 # Copyright (C) 2013 Google Inc. All rights reserved. |
2 # coding=utf-8 | 2 # coding=utf-8 |
3 # | 3 # |
4 # Redistribution and use in source and binary forms, with or without | 4 # Redistribution and use in source and binary forms, with or without |
5 # modification, are permitted provided that the following conditions are | 5 # modification, are permitted provided that the following conditions are |
6 # met: | 6 # met: |
7 # | 7 # |
8 # * Redistributions of source code must retain the above copyright | 8 # * Redistributions of source code must retain the above copyright |
9 # notice, this list of conditions and the following disclaimer. | 9 # notice, this list of conditions and the following disclaimer. |
10 # * Redistributions in binary form must reproduce the above | 10 # * Redistributions in binary form must reproduce the above |
(...skipping 223 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
234 context.update({ | 234 context.update({ |
235 'attributes': attributes, | 235 'attributes': attributes, |
236 'has_accessors': any(attribute['is_expose_js_accessors'] and attribute['
should_be_exposed_to_script'] for attribute in attributes), | 236 'has_accessors': any(attribute['is_expose_js_accessors'] and attribute['
should_be_exposed_to_script'] for attribute in attributes), |
237 'has_attribute_configuration': any( | 237 'has_attribute_configuration': any( |
238 not (attribute['is_expose_js_accessors'] or | 238 not (attribute['is_expose_js_accessors'] or |
239 attribute['is_static'] or | 239 attribute['is_static'] or |
240 attribute['runtime_enabled_function'] or | 240 attribute['runtime_enabled_function'] or |
241 attribute['per_context_enabled_function']) | 241 attribute['per_context_enabled_function']) |
242 and attribute['should_be_exposed_to_script'] | 242 and attribute['should_be_exposed_to_script'] |
243 for attribute in attributes), | 243 for attribute in attributes), |
| 244 'has_conditional_attributes': any(attribute['per_context_enabled_functio
n'] or attribute['exposed_test'] for attribute in attributes), |
244 'has_constructor_attributes': any(attribute['constructor_type'] for attr
ibute in attributes), | 245 'has_constructor_attributes': any(attribute['constructor_type'] for attr
ibute in attributes), |
245 'has_per_context_enabled_attributes': any(attribute['per_context_enabled
_function'] for attribute in attributes), | |
246 'has_replaceable_attributes': any(attribute['is_replaceable'] for attrib
ute in attributes), | 246 'has_replaceable_attributes': any(attribute['is_replaceable'] for attrib
ute in attributes), |
247 }) | 247 }) |
248 | 248 |
249 # Methods | 249 # Methods |
250 methods = [v8_methods.method_context(interface, method) | 250 methods = [v8_methods.method_context(interface, method) |
251 for method in interface.operations | 251 for method in interface.operations |
252 if method.name] # Skip anonymous special operations (methods) | 252 if method.name] # Skip anonymous special operations (methods) |
253 compute_method_overloads_context(methods) | 253 compute_method_overloads_context(methods) |
254 | 254 |
255 # Stringifier | 255 # Stringifier |
256 if interface.stringifier: | 256 if interface.stringifier: |
257 stringifier = interface.stringifier | 257 stringifier = interface.stringifier |
258 method = IdlOperation() | 258 method = IdlOperation() |
259 method.name = 'toString' | 259 method.name = 'toString' |
260 method.idl_type = IdlType('DOMString') | 260 method.idl_type = IdlType('DOMString') |
261 method.extended_attributes.update(stringifier.extended_attributes) | 261 method.extended_attributes.update(stringifier.extended_attributes) |
262 if stringifier.attribute: | 262 if stringifier.attribute: |
263 method.extended_attributes['ImplementedAs'] = stringifier.attribute.
name | 263 method.extended_attributes['ImplementedAs'] = stringifier.attribute.
name |
264 elif stringifier.operation: | 264 elif stringifier.operation: |
265 method.extended_attributes['ImplementedAs'] = stringifier.operation.
name | 265 method.extended_attributes['ImplementedAs'] = stringifier.operation.
name |
266 methods.append(v8_methods.method_context(interface, method)) | 266 methods.append(v8_methods.method_context(interface, method)) |
267 | 267 |
268 per_context_enabled_methods = [] | 268 conditionally_enabled_methods = [] |
269 custom_registration_methods = [] | 269 custom_registration_methods = [] |
270 method_configuration_methods = [] | 270 method_configuration_methods = [] |
271 | 271 |
272 for method in methods: | 272 for method in methods: |
273 # Skip all but one method in each set of overloaded methods. | 273 # Skip all but one method in each set of overloaded methods. |
274 if 'overload_index' in method and 'overloads' not in method: | 274 if 'overload_index' in method and 'overloads' not in method: |
275 continue | 275 continue |
276 | 276 |
277 if 'overloads' in method: | 277 if 'overloads' in method: |
278 overloads = method['overloads'] | 278 overloads = method['overloads'] |
279 per_context_enabled_function = overloads['per_context_enabled_functi
on_all'] | 279 per_context_enabled_function = overloads['per_context_enabled_functi
on_all'] |
| 280 conditionally_exposed_function = overloads['exposed_test_all'] |
280 runtime_enabled_function = overloads['runtime_enabled_function_all'] | 281 runtime_enabled_function = overloads['runtime_enabled_function_all'] |
281 has_custom_registration = overloads['has_custom_registration_all'] | 282 has_custom_registration = overloads['has_custom_registration_all'] |
282 else: | 283 else: |
283 per_context_enabled_function = method['per_context_enabled_function'
] | 284 per_context_enabled_function = method['per_context_enabled_function'
] |
| 285 conditionally_exposed_function = method['exposed_test'] |
284 runtime_enabled_function = method['runtime_enabled_function'] | 286 runtime_enabled_function = method['runtime_enabled_function'] |
285 has_custom_registration = method['has_custom_registration'] | 287 has_custom_registration = method['has_custom_registration'] |
286 | 288 |
287 if per_context_enabled_function: | 289 if per_context_enabled_function or conditionally_exposed_function: |
288 per_context_enabled_methods.append(method) | 290 conditionally_enabled_methods.append(method) |
289 continue | 291 continue |
290 if runtime_enabled_function or has_custom_registration: | 292 if runtime_enabled_function or has_custom_registration: |
291 custom_registration_methods.append(method) | 293 custom_registration_methods.append(method) |
292 continue | 294 continue |
293 if method['should_be_exposed_to_script']: | 295 if method['should_be_exposed_to_script']: |
294 method_configuration_methods.append(method) | 296 method_configuration_methods.append(method) |
295 | 297 |
296 for method in methods: | 298 for method in methods: |
297 # The value of the Function object’s “length” property is a Number | 299 # The value of the Function object’s “length” property is a Number |
298 # determined as follows: | 300 # determined as follows: |
299 # 1. Let S be the effective overload set for regular operations (if the | 301 # 1. Let S be the effective overload set for regular operations (if the |
300 # operation is a regular operation) or for static operations (if the | 302 # operation is a regular operation) or for static operations (if the |
301 # operation is a static operation) with identifier id on interface I and | 303 # operation is a static operation) with identifier id on interface I and |
302 # with argument count 0. | 304 # with argument count 0. |
303 # 2. Return the length of the shortest argument list of the entries in S
. | 305 # 2. Return the length of the shortest argument list of the entries in S
. |
304 # FIXME: This calculation doesn't take into account whether runtime | 306 # FIXME: This calculation doesn't take into account whether runtime |
305 # enabled overloads are actually enabled, so length may be incorrect. | 307 # enabled overloads are actually enabled, so length may be incorrect. |
306 # E.g., [RuntimeEnabled=Foo] void f(); void f(long x); | 308 # E.g., [RuntimeEnabled=Foo] void f(); void f(long x); |
307 # should have length 1 if Foo is not enabled, but length 0 if it is. | 309 # should have length 1 if Foo is not enabled, but length 0 if it is. |
308 method['length'] = (method['overloads']['minarg'] if 'overloads' in meth
od else | 310 method['length'] = (method['overloads']['minarg'] if 'overloads' in meth
od else |
309 method['number_of_required_arguments']) | 311 method['number_of_required_arguments']) |
310 | 312 |
311 context.update({ | 313 context.update({ |
| 314 'conditionally_enabled_methods': conditionally_enabled_methods, |
312 'custom_registration_methods': custom_registration_methods, | 315 'custom_registration_methods': custom_registration_methods, |
313 'has_origin_safe_method_setter': any( | 316 'has_origin_safe_method_setter': any( |
314 method['is_check_security_for_frame'] and not method['is_read_only'] | 317 method['is_check_security_for_frame'] and not method['is_read_only'] |
315 for method in methods), | 318 for method in methods), |
316 'has_private_script': any(attribute['is_implemented_in_private_script']
for attribute in attributes) or | 319 'has_private_script': any(attribute['is_implemented_in_private_script']
for attribute in attributes) or |
317 any(method['is_implemented_in_private_script'] for method in methods
), | 320 any(method['is_implemented_in_private_script'] for method in methods
), |
318 'method_configuration_methods': method_configuration_methods, | 321 'method_configuration_methods': method_configuration_methods, |
319 'per_context_enabled_methods': per_context_enabled_methods, | |
320 'methods': methods, | 322 'methods': methods, |
321 }) | 323 }) |
322 | 324 |
323 context.update({ | 325 context.update({ |
324 'indexed_property_getter': indexed_property_getter(interface), | 326 'indexed_property_getter': indexed_property_getter(interface), |
325 'indexed_property_setter': indexed_property_setter(interface), | 327 'indexed_property_setter': indexed_property_setter(interface), |
326 'indexed_property_deleter': indexed_property_deleter(interface), | 328 'indexed_property_deleter': indexed_property_deleter(interface), |
327 'is_override_builtins': 'OverrideBuiltins' in extended_attributes, | 329 'is_override_builtins': 'OverrideBuiltins' in extended_attributes, |
328 'named_property_getter': named_property_getter(interface), | 330 'named_property_getter': named_property_getter(interface), |
329 'named_property_setter': named_property_setter(interface), | 331 'named_property_setter': named_property_setter(interface), |
(...skipping 103 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
433 overload_extended_attributes = [ | 435 overload_extended_attributes = [ |
434 method['custom_registration_extended_attributes'] | 436 method['custom_registration_extended_attributes'] |
435 for method in overloads] | 437 for method in overloads] |
436 for extended_attribute in v8_methods.CUSTOM_REGISTRATION_EXTENDED_ATTRIB
UTES: | 438 for extended_attribute in v8_methods.CUSTOM_REGISTRATION_EXTENDED_ATTRIB
UTES: |
437 if common_key(overload_extended_attributes, extended_attribute) is N
one: | 439 if common_key(overload_extended_attributes, extended_attribute) is N
one: |
438 raise ValueError('Overloads of %s have conflicting extended attr
ibute %s' | 440 raise ValueError('Overloads of %s have conflicting extended attr
ibute %s' |
439 % (name, extended_attribute)) | 441 % (name, extended_attribute)) |
440 | 442 |
441 return { | 443 return { |
442 'deprecate_all_as': common_value(overloads, 'deprecate_as'), # [Depreca
teAs] | 444 'deprecate_all_as': common_value(overloads, 'deprecate_as'), # [Depreca
teAs] |
| 445 'exposed_test_all': common_value(overloads, 'exposed_test'), # [Exposed
] |
| 446 'has_custom_registration_all': common_value(overloads, 'has_custom_regis
tration'), |
443 'length_tests_methods': length_tests_methods(effective_overloads_by_leng
th), | 447 'length_tests_methods': length_tests_methods(effective_overloads_by_leng
th), |
444 'minarg': lengths[0], | |
445 # 1. Let maxarg be the length of the longest type list of the | 448 # 1. Let maxarg be the length of the longest type list of the |
446 # entries in S. | 449 # entries in S. |
447 'maxarg': lengths[-1], | 450 'maxarg': lengths[-1], |
448 'measure_all_as': common_value(overloads, 'measure_as'), # [MeasureAs] | 451 'measure_all_as': common_value(overloads, 'measure_as'), # [MeasureAs] |
449 'has_custom_registration_all': common_value(overloads, 'has_custom_regis
tration'), | 452 'minarg': lengths[0], |
450 'per_context_enabled_function_all': common_value(overloads, 'per_context
_enabled_function'), # [PerContextEnabled] | 453 'per_context_enabled_function_all': common_value(overloads, 'per_context
_enabled_function'), # [PerContextEnabled] |
451 'runtime_enabled_function_all': common_value(overloads, 'runtime_enabled
_function'), # [RuntimeEnabled] | 454 'runtime_enabled_function_all': common_value(overloads, 'runtime_enabled
_function'), # [RuntimeEnabled] |
452 'valid_arities': lengths | 455 'valid_arities': lengths |
453 # Only need to report valid arities if there is a gap in the | 456 # Only need to report valid arities if there is a gap in the |
454 # sequence of possible lengths, otherwise invalid length means | 457 # sequence of possible lengths, otherwise invalid length means |
455 # "not enough arguments". | 458 # "not enough arguments". |
456 if lengths[-1] - lengths[0] != len(lengths) - 1 else None, | 459 if lengths[-1] - lengths[0] != len(lengths) - 1 else None, |
457 } | 460 } |
458 | 461 |
459 | 462 |
(...skipping 645 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1105 deleter = next( | 1108 deleter = next( |
1106 method | 1109 method |
1107 for method in interface.operations | 1110 for method in interface.operations |
1108 if ('deleter' in method.specials and | 1111 if ('deleter' in method.specials and |
1109 len(method.arguments) == 1 and | 1112 len(method.arguments) == 1 and |
1110 str(method.arguments[0].idl_type) == 'DOMString')) | 1113 str(method.arguments[0].idl_type) == 'DOMString')) |
1111 except StopIteration: | 1114 except StopIteration: |
1112 return None | 1115 return None |
1113 | 1116 |
1114 return property_deleter(deleter) | 1117 return property_deleter(deleter) |
OLD | NEW |