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 352 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
363 if has_conditional_attributes and interface.is_partial: | 363 if has_conditional_attributes and interface.is_partial: |
364 raise Exception('Conditional attributes between partial interfaces in mo
dules and the original interfaces(%s) in core are not allowed.' % interface.name
) | 364 raise Exception('Conditional attributes between partial interfaces in mo
dules and the original interfaces(%s) in core are not allowed.' % interface.name
) |
365 | 365 |
366 context.update({ | 366 context.update({ |
367 'attributes': attributes, | 367 'attributes': attributes, |
368 }) | 368 }) |
369 | 369 |
370 # Methods | 370 # Methods |
371 methods, iterator_method = methods_context(interface) | 371 methods, iterator_method = methods_context(interface) |
372 context.update({ | 372 context.update({ |
373 'has_origin_safe_method_setter': is_global and any( | |
374 method['is_check_security_for_receiver'] and not method['is_unforgea
ble'] | |
375 for method in methods), | |
376 'has_private_script': (any(attribute['is_implemented_in_private_script']
for attribute in attributes) or | 373 'has_private_script': (any(attribute['is_implemented_in_private_script']
for attribute in attributes) or |
377 any(method['is_implemented_in_private_script'] fo
r method in methods)), | 374 any(method['is_implemented_in_private_script'] fo
r method in methods)), |
378 'iterator_method': iterator_method, | 375 'iterator_method': iterator_method, |
379 'methods': methods, | 376 'methods': methods, |
380 }) | 377 }) |
381 | 378 |
382 # Window.idl in Blink has indexed properties, but the spec says Window | 379 # Window.idl in Blink has indexed properties, but the spec says Window |
383 # interface doesn't have indexed properties, instead the WindowProxy exotic | 380 # interface doesn't have indexed properties, instead the WindowProxy exotic |
384 # object has indexed properties. Thus, Window interface must not support | 381 # object has indexed properties. Thus, Window interface must not support |
385 # iterators. | 382 # iterators. |
(...skipping 23 matching lines...) Expand all Loading... |
409 'named_property_deleter': property_deleter(interface.named_property_dele
ter), | 406 'named_property_deleter': property_deleter(interface.named_property_dele
ter), |
410 }) | 407 }) |
411 context.update({ | 408 context.update({ |
412 'has_named_properties_object': is_global and context['named_property_get
ter'], | 409 'has_named_properties_object': is_global and context['named_property_get
ter'], |
413 }) | 410 }) |
414 | 411 |
415 # Origin Trials | 412 # Origin Trials |
416 context.update({ | 413 context.update({ |
417 'origin_trial_features': origin_trial_features(interface, context['const
ants'], context['attributes'], context['methods']), | 414 'origin_trial_features': origin_trial_features(interface, context['const
ants'], context['attributes'], context['methods']), |
418 }) | 415 }) |
| 416 |
| 417 # Cross-origin interceptors |
| 418 has_cross_origin_named_getter = False |
| 419 has_cross_origin_named_setter = False |
| 420 has_cross_origin_indexed_getter = False |
| 421 |
| 422 for attribute in attributes: |
| 423 if attribute['has_cross_origin_getter']: |
| 424 has_cross_origin_named_getter = True |
| 425 if attribute['has_cross_origin_setter']: |
| 426 has_cross_origin_named_setter = True |
| 427 |
| 428 # Methods are exposed as getter attributes on the interface: e.g. |
| 429 # window.location gets the location attribute on the Window interface. For |
| 430 # the cross-origin case, this attribute getter is guaranteed to only return |
| 431 # a Function object, which the actual call is dispatched against. |
| 432 for method in methods: |
| 433 if method['is_cross_origin']: |
| 434 has_cross_origin_named_getter = True |
| 435 |
| 436 if context['named_property_getter'] and context['named_property_getter']['is
_cross_origin']: |
| 437 has_cross_origin_named_getter = True |
| 438 |
| 439 if context['indexed_property_getter'] and context['indexed_property_getter']
['is_cross_origin']: |
| 440 has_cross_origin_indexed_getter = True |
| 441 |
| 442 context.update({ |
| 443 'has_cross_origin_named_getter': has_cross_origin_named_getter, |
| 444 'has_cross_origin_named_setter': has_cross_origin_named_setter, |
| 445 'has_cross_origin_indexed_getter': has_cross_origin_indexed_getter, |
| 446 }) |
| 447 |
419 return context | 448 return context |
420 | 449 |
421 | 450 |
422 def methods_context(interface): | 451 def methods_context(interface): |
423 """Creates a list of Jinja template contexts for methods of an interface. | 452 """Creates a list of Jinja template contexts for methods of an interface. |
424 | 453 |
425 Args: | 454 Args: |
426 interface: An interface to create contexts for | 455 interface: An interface to create contexts for |
427 | 456 |
428 Returns: | 457 Returns: |
(...skipping 355 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
784 if method.get('runtime_enabled_function')) | 813 if method.get('runtime_enabled_function')) |
785 if not runtime_enabled_functions: | 814 if not runtime_enabled_functions: |
786 # This "length" is unconditionally enabled, so stop here. | 815 # This "length" is unconditionally enabled, so stop here. |
787 runtime_determined_maxargs.append((length, [None])) | 816 runtime_determined_maxargs.append((length, [None])) |
788 break | 817 break |
789 runtime_determined_maxargs.append( | 818 runtime_determined_maxargs.append( |
790 (length, sorted(runtime_enabled_functions))) | 819 (length, sorted(runtime_enabled_functions))) |
791 maxarg = ('%sV8Internal::%sMethodMaxArg()' | 820 maxarg = ('%sV8Internal::%sMethodMaxArg()' |
792 % (cpp_name_or_partial(interface), name)) | 821 % (cpp_name_or_partial(interface), name)) |
793 | 822 |
794 # Check and fail if overloads disagree on any of the extended attributes | |
795 # that affect how the method should be registered. | |
796 # Skip the check for overloaded constructors, since they don't support any | |
797 # of the extended attributes in question. | |
798 if not overloads[0].get('is_constructor'): | |
799 overload_extended_attributes = [ | |
800 method['custom_registration_extended_attributes'] | |
801 for method in overloads] | |
802 for extended_attribute in v8_methods.CUSTOM_REGISTRATION_EXTENDED_ATTRIB
UTES: | |
803 if common_key(overload_extended_attributes, extended_attribute) is N
one: | |
804 raise ValueError('Overloads of %s have conflicting extended attr
ibute %s' | |
805 % (name, extended_attribute)) | |
806 | |
807 # Check and fail if overloads disagree about whether the return type | 823 # Check and fail if overloads disagree about whether the return type |
808 # is a Promise or not. | 824 # is a Promise or not. |
809 promise_overload_count = sum(1 for method in overloads if method.get('return
s_promise')) | 825 promise_overload_count = sum(1 for method in overloads if method.get('return
s_promise')) |
810 if promise_overload_count not in (0, len(overloads)): | 826 if promise_overload_count not in (0, len(overloads)): |
811 raise ValueError('Overloads of %s have conflicting Promise/non-Promise t
ypes' | 827 raise ValueError('Overloads of %s have conflicting Promise/non-Promise t
ypes' |
812 % (name)) | 828 % (name)) |
813 | 829 |
814 has_overload_visible = False | 830 has_overload_visible = False |
815 has_overload_not_visible = False | 831 has_overload_not_visible = False |
816 for overload in overloads: | 832 for overload in overloads: |
817 if overload.get('visible', True): | 833 if overload.get('visible', True): |
818 # If there exists an overload which is visible, need to generate | 834 # If there exists an overload which is visible, need to generate |
819 # overload_resolution, i.e. overlods_visible should be True. | 835 # overload_resolution, i.e. overlods_visible should be True. |
820 has_overload_visible = True | 836 has_overload_visible = True |
821 else: | 837 else: |
822 has_overload_not_visible = True | 838 has_overload_not_visible = True |
823 | 839 |
824 # If some overloads are not visible and others are visible, | 840 # If some overloads are not visible and others are visible, |
825 # the method is overloaded between core and modules. | 841 # the method is overloaded between core and modules. |
826 has_partial_overloads = has_overload_visible and has_overload_not_visible | 842 has_partial_overloads = has_overload_visible and has_overload_not_visible |
827 | 843 |
828 return { | 844 return { |
829 'deprecate_all_as': common_value(overloads, 'deprecate_as'), # [Depreca
teAs] | 845 'deprecate_all_as': common_value(overloads, 'deprecate_as'), # [Depreca
teAs] |
830 'exposed_test_all': common_value(overloads, 'exposed_test'), # [Exposed
] | 846 'exposed_test_all': common_value(overloads, 'exposed_test'), # [Exposed
] |
831 'has_custom_registration_all': common_value(overloads, 'has_custom_regis
tration'), | |
832 'length': function_length, | 847 'length': function_length, |
833 'length_tests_methods': length_tests_methods(effective_overloads_by_leng
th), | 848 'length_tests_methods': length_tests_methods(effective_overloads_by_leng
th), |
834 # 1. Let maxarg be the length of the longest type list of the | 849 # 1. Let maxarg be the length of the longest type list of the |
835 # entries in S. | 850 # entries in S. |
836 'maxarg': maxarg, | 851 'maxarg': maxarg, |
837 'measure_all_as': common_value(overloads, 'measure_as'), # [MeasureAs] | 852 'measure_all_as': common_value(overloads, 'measure_as'), # [MeasureAs] |
838 'returns_promise_all': promise_overload_count > 0, | 853 'returns_promise_all': promise_overload_count > 0, |
839 'runtime_determined_lengths': runtime_determined_lengths, | 854 'runtime_determined_lengths': runtime_determined_lengths, |
840 'runtime_determined_maxargs': runtime_determined_maxargs, | 855 'runtime_determined_maxargs': runtime_determined_maxargs, |
841 'runtime_enabled_function_all': common_value(overloads, 'runtime_enabled
_function'), # [RuntimeEnabled] | 856 'runtime_enabled_function_all': common_value(overloads, 'runtime_enabled
_function'), # [RuntimeEnabled] |
(...skipping 543 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1385 if is_raises_exception: | 1400 if is_raises_exception: |
1386 cpp_arguments.append('exceptionState') | 1401 cpp_arguments.append('exceptionState') |
1387 if use_output_parameter_for_result: | 1402 if use_output_parameter_for_result: |
1388 cpp_arguments.append('result') | 1403 cpp_arguments.append('result') |
1389 | 1404 |
1390 cpp_value = '%s(%s)' % (cpp_method_name, ', '.join(cpp_arguments)) | 1405 cpp_value = '%s(%s)' % (cpp_method_name, ', '.join(cpp_arguments)) |
1391 | 1406 |
1392 return { | 1407 return { |
1393 'cpp_type': idl_type.cpp_type, | 1408 'cpp_type': idl_type.cpp_type, |
1394 'cpp_value': cpp_value, | 1409 'cpp_value': cpp_value, |
1395 'do_not_check_security': 'DoNotCheckSecurity' in extended_attributes, | |
1396 'is_call_with_script_state': is_call_with_script_state, | 1410 'is_call_with_script_state': is_call_with_script_state, |
| 1411 'is_cross_origin': 'CrossOrigin' in extended_attributes, |
1397 'is_custom': | 1412 'is_custom': |
1398 'Custom' in extended_attributes and | 1413 'Custom' in extended_attributes and |
1399 (not extended_attributes['Custom'] or | 1414 (not extended_attributes['Custom'] or |
1400 has_extended_attribute_value(getter, 'Custom', 'PropertyGetter')), | 1415 has_extended_attribute_value(getter, 'Custom', 'PropertyGetter')), |
1401 'is_custom_property_enumerator': has_extended_attribute_value( | 1416 'is_custom_property_enumerator': has_extended_attribute_value( |
1402 getter, 'Custom', 'PropertyEnumerator'), | 1417 getter, 'Custom', 'PropertyEnumerator'), |
1403 'is_custom_property_query': has_extended_attribute_value( | 1418 'is_custom_property_query': has_extended_attribute_value( |
1404 getter, 'Custom', 'PropertyQuery'), | 1419 getter, 'Custom', 'PropertyQuery'), |
1405 'is_enumerable': 'NotEnumerable' not in extended_attributes, | 1420 'is_enumerable': 'NotEnumerable' not in extended_attributes, |
1406 'is_null_expression': is_null_expression(idl_type), | 1421 'is_null_expression': is_null_expression(idl_type), |
(...skipping 43 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1450 extended_attributes = deleter.extended_attributes | 1465 extended_attributes = deleter.extended_attributes |
1451 is_call_with_script_state = v8_utilities.has_extended_attribute_value(delete
r, 'CallWith', 'ScriptState') | 1466 is_call_with_script_state = v8_utilities.has_extended_attribute_value(delete
r, 'CallWith', 'ScriptState') |
1452 is_ce_reactions = 'CEReactions' in extended_attributes | 1467 is_ce_reactions = 'CEReactions' in extended_attributes |
1453 return { | 1468 return { |
1454 'is_call_with_script_state': is_call_with_script_state, | 1469 'is_call_with_script_state': is_call_with_script_state, |
1455 'is_ce_reactions': is_ce_reactions, | 1470 'is_ce_reactions': is_ce_reactions, |
1456 'is_custom': 'Custom' in extended_attributes, | 1471 'is_custom': 'Custom' in extended_attributes, |
1457 'is_raises_exception': 'RaisesException' in extended_attributes, | 1472 'is_raises_exception': 'RaisesException' in extended_attributes, |
1458 'name': cpp_name(deleter), | 1473 'name': cpp_name(deleter), |
1459 } | 1474 } |
OLD | NEW |