| OLD | NEW |
| 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 47 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 58 is_check_security_for_frame = ( | 58 is_check_security_for_frame = ( |
| 59 has_extended_attribute_value(interface, 'CheckSecurity', 'Frame') and | 59 has_extended_attribute_value(interface, 'CheckSecurity', 'Frame') and |
| 60 not is_do_not_check_security) | 60 not is_do_not_check_security) |
| 61 is_check_security_for_node = ( | 61 is_check_security_for_node = ( |
| 62 has_extended_attribute_value(attribute, 'CheckSecurity', 'Node')) | 62 has_extended_attribute_value(attribute, 'CheckSecurity', 'Node')) |
| 63 is_check_security_for_window = ( | 63 is_check_security_for_window = ( |
| 64 has_extended_attribute_value(interface, 'CheckSecurity', 'Window') and | 64 has_extended_attribute_value(interface, 'CheckSecurity', 'Window') and |
| 65 not is_do_not_check_security) | 65 not is_do_not_check_security) |
| 66 if is_check_security_for_frame or is_check_security_for_node or is_check_sec
urity_for_window: | 66 if is_check_security_for_frame or is_check_security_for_node or is_check_sec
urity_for_window: |
| 67 includes.add('bindings/core/v8/BindingSecurity.h') | 67 includes.add('bindings/core/v8/BindingSecurity.h') |
| 68 # [Constructor] |
| 69 # TODO(yukishiino): Constructors are much like methods although constructors |
| 70 # are not methods. Constructors must be data-type properties, and we can |
| 71 # support them as a kind of methods. |
| 72 constructor_type = idl_type.constructor_type_name if is_constructor_attribut
e(attribute) else None |
| 68 # [CustomElementCallbacks], [Reflect] | 73 # [CustomElementCallbacks], [Reflect] |
| 69 is_custom_element_callbacks = 'CustomElementCallbacks' in extended_attribute
s | 74 is_custom_element_callbacks = 'CustomElementCallbacks' in extended_attribute
s |
| 70 is_reflect = 'Reflect' in extended_attributes | 75 is_reflect = 'Reflect' in extended_attributes |
| 71 if is_custom_element_callbacks or is_reflect: | 76 if is_custom_element_callbacks or is_reflect: |
| 72 includes.add('core/dom/custom/CustomElementProcessingStack.h') | 77 includes.add('core/dom/custom/CustomElementProcessingStack.h') |
| 73 # [ImplementedInPrivateScript] | 78 # [ImplementedInPrivateScript] |
| 74 is_implemented_in_private_script = 'ImplementedInPrivateScript' in extended_
attributes | 79 is_implemented_in_private_script = 'ImplementedInPrivateScript' in extended_
attributes |
| 75 if is_implemented_in_private_script: | 80 if is_implemented_in_private_script: |
| 76 includes.add('bindings/core/v8/PrivateScriptRunner.h') | 81 includes.add('bindings/core/v8/PrivateScriptRunner.h') |
| 77 includes.add('core/frame/LocalFrame.h') | 82 includes.add('core/frame/LocalFrame.h') |
| (...skipping 15 matching lines...) Expand all Loading... |
| 93 includes.add('bindings/core/v8/V8HiddenValue.h') | 98 includes.add('bindings/core/v8/V8HiddenValue.h') |
| 94 | 99 |
| 95 context = { | 100 context = { |
| 96 'access_control_list': access_control_list(interface, attribute), | 101 'access_control_list': access_control_list(interface, attribute), |
| 97 'activity_logging_world_list_for_getter': v8_utilities.activity_logging_
world_list(attribute, 'Getter'), # [ActivityLogging] | 102 'activity_logging_world_list_for_getter': v8_utilities.activity_logging_
world_list(attribute, 'Getter'), # [ActivityLogging] |
| 98 'activity_logging_world_list_for_setter': v8_utilities.activity_logging_
world_list(attribute, 'Setter'), # [ActivityLogging] | 103 'activity_logging_world_list_for_setter': v8_utilities.activity_logging_
world_list(attribute, 'Setter'), # [ActivityLogging] |
| 99 'activity_logging_world_check': v8_utilities.activity_logging_world_chec
k(attribute), # [ActivityLogging] | 104 'activity_logging_world_check': v8_utilities.activity_logging_world_chec
k(attribute), # [ActivityLogging] |
| 100 'argument_cpp_type': idl_type.cpp_type_args(used_as_rvalue_type=True), | 105 'argument_cpp_type': idl_type.cpp_type_args(used_as_rvalue_type=True), |
| 101 'cached_attribute_validation_method': cached_attribute_validation_method
, | 106 'cached_attribute_validation_method': cached_attribute_validation_method
, |
| 102 'conditional_string': v8_utilities.conditional_string(attribute), | 107 'conditional_string': v8_utilities.conditional_string(attribute), |
| 103 'constructor_type': idl_type.constructor_type_name | 108 'constructor_type': constructor_type, |
| 104 if is_constructor_attribute(attribute) else None, | |
| 105 'cpp_name': cpp_name(attribute), | 109 'cpp_name': cpp_name(attribute), |
| 106 'cpp_type': idl_type.cpp_type, | 110 'cpp_type': idl_type.cpp_type, |
| 107 'cpp_type_initializer': idl_type.cpp_type_initializer, | 111 'cpp_type_initializer': idl_type.cpp_type_initializer, |
| 108 'deprecate_as': v8_utilities.deprecate_as(attribute), # [DeprecateAs] | 112 'deprecate_as': v8_utilities.deprecate_as(attribute), # [DeprecateAs] |
| 109 'enum_type': idl_type.enum_type, | 113 'enum_type': idl_type.enum_type, |
| 110 'enum_values': idl_type.enum_values, | 114 'enum_values': idl_type.enum_values, |
| 111 'exposed_test': v8_utilities.exposed(attribute, interface), # [Exposed] | 115 'exposed_test': v8_utilities.exposed(attribute, interface), # [Exposed] |
| 112 'has_custom_getter': has_custom_getter(attribute), | 116 'has_custom_getter': has_custom_getter(attribute), |
| 113 'has_custom_setter': has_custom_setter(attribute), | 117 'has_custom_setter': has_custom_setter(attribute), |
| 114 'has_setter': has_setter(attribute), | 118 'has_setter': has_setter(attribute), |
| 115 'idl_type': str(idl_type), # need trailing [] on array for Dictionary::
ConversionContext::setConversionType | 119 'idl_type': str(idl_type), # need trailing [] on array for Dictionary::
ConversionContext::setConversionType |
| 116 'is_call_with_execution_context': has_extended_attribute_value(attribute
, 'CallWith', 'ExecutionContext'), | 120 'is_call_with_execution_context': has_extended_attribute_value(attribute
, 'CallWith', 'ExecutionContext'), |
| 117 'is_call_with_script_state': has_extended_attribute_value(attribute, 'Ca
llWith', 'ScriptState'), | 121 'is_call_with_script_state': has_extended_attribute_value(attribute, 'Ca
llWith', 'ScriptState'), |
| 118 'is_check_security_for_frame': is_check_security_for_frame, | 122 'is_check_security_for_frame': is_check_security_for_frame, |
| 119 'is_check_security_for_node': is_check_security_for_node, | 123 'is_check_security_for_node': is_check_security_for_node, |
| 120 'is_check_security_for_window': is_check_security_for_window, | 124 'is_check_security_for_window': is_check_security_for_window, |
| 121 'is_custom_element_callbacks': is_custom_element_callbacks, | 125 'is_custom_element_callbacks': is_custom_element_callbacks, |
| 122 'is_expose_js_accessors': is_expose_js_accessors(interface, attribute), | 126 # TODO(yukishiino): Make all DOM attributes accessor-type properties. |
| 127 'is_data_type_property': constructor_type or interface.name == 'Window', |
| 123 'is_getter_raises_exception': # [RaisesException] | 128 'is_getter_raises_exception': # [RaisesException] |
| 124 'RaisesException' in extended_attributes and | 129 'RaisesException' in extended_attributes and |
| 125 extended_attributes['RaisesException'] in (None, 'Getter'), | 130 extended_attributes['RaisesException'] in (None, 'Getter'), |
| 126 'is_implemented_in_private_script': is_implemented_in_private_script, | 131 'is_implemented_in_private_script': is_implemented_in_private_script, |
| 127 'is_keep_alive_for_gc': keep_alive_for_gc, | 132 'is_keep_alive_for_gc': keep_alive_for_gc, |
| 128 'is_lenient_this': 'LenientThis' in extended_attributes, | 133 'is_lenient_this': 'LenientThis' in extended_attributes, |
| 129 'is_nullable': idl_type.is_nullable, | 134 'is_nullable': idl_type.is_nullable, |
| 130 'is_explicit_nullable': idl_type.is_explicit_nullable, | 135 'is_explicit_nullable': idl_type.is_explicit_nullable, |
| 131 'is_partial_interface_member': | 136 'is_partial_interface_member': |
| 132 'PartialInterfaceImplementedAs' in extended_attributes, | 137 'PartialInterfaceImplementedAs' in extended_attributes, |
| (...skipping 349 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 482 | 487 |
| 483 | 488 |
| 484 # [Custom], [Custom=Setter] | 489 # [Custom], [Custom=Setter] |
| 485 def has_custom_setter(attribute): | 490 def has_custom_setter(attribute): |
| 486 extended_attributes = attribute.extended_attributes | 491 extended_attributes = attribute.extended_attributes |
| 487 return (not attribute.is_read_only and | 492 return (not attribute.is_read_only and |
| 488 'Custom' in extended_attributes and | 493 'Custom' in extended_attributes and |
| 489 extended_attributes['Custom'] in [None, 'Setter']) | 494 extended_attributes['Custom'] in [None, 'Setter']) |
| 490 | 495 |
| 491 | 496 |
| 492 # [ExposeJSAccessors] | |
| 493 def is_expose_js_accessors(interface, attribute): | |
| 494 # Default behavior | |
| 495 is_accessor = True | |
| 496 | |
| 497 if ('ExposeJSAccessors' in interface.extended_attributes and | |
| 498 'DoNotExposeJSAccessors' in interface.extended_attributes): | |
| 499 raise Exception('Both of ExposeJSAccessors and DoNotExposeJSAccessors ar
e specified at a time in an interface: ' + interface.name) | |
| 500 if 'ExposeJSAccessors' in interface.extended_attributes: | |
| 501 is_accessor = True | |
| 502 if 'DoNotExposeJSAccessors' in interface.extended_attributes: | |
| 503 is_accessor = False | |
| 504 | |
| 505 # Note that ExposeJSAccessors and DoNotExposeJSAccessors are more powerful | |
| 506 # than 'static', [Unforgeable] and [OverrideBuiltins]. | |
| 507 if ('ExposeJSAccessors' in attribute.extended_attributes and | |
| 508 'DoNotExposeJSAccessors' in attribute.extended_attributes): | |
| 509 raise Exception('Both of ExposeJSAccessors and DoNotExposeJSAccessors ar
e specified at a time on an attribute: ' + attribute.name + ' in an interface: '
+ interface.name) | |
| 510 if 'ExposeJSAccessors' in attribute.extended_attributes: | |
| 511 return True | |
| 512 if 'DoNotExposeJSAccessors' in attribute.extended_attributes: | |
| 513 return False | |
| 514 | |
| 515 # These attributes must not be accessors on prototype chains. | |
| 516 if (is_constructor_attribute(attribute) or | |
| 517 attribute.is_static or | |
| 518 is_unforgeable(interface, attribute) or | |
| 519 'OverrideBuiltins' in interface.extended_attributes): | |
| 520 return False | |
| 521 | |
| 522 # The members of Window interface must be placed on the instance object. | |
| 523 if interface.name == 'Window': | |
| 524 return False | |
| 525 | |
| 526 return is_accessor | |
| 527 | |
| 528 | |
| 529 ################################################################################ | 497 ################################################################################ |
| 530 # Constructors | 498 # Constructors |
| 531 ################################################################################ | 499 ################################################################################ |
| 532 | 500 |
| 533 idl_types.IdlType.constructor_type_name = property( | 501 idl_types.IdlType.constructor_type_name = property( |
| 534 # FIXME: replace this with a [ConstructorAttribute] extended attribute | 502 # FIXME: replace this with a [ConstructorAttribute] extended attribute |
| 535 lambda self: strip_suffix(self.base_type, 'Constructor')) | 503 lambda self: strip_suffix(self.base_type, 'Constructor')) |
| 536 | 504 |
| 537 | 505 |
| 538 def is_constructor_attribute(attribute): | 506 def is_constructor_attribute(attribute): |
| 539 # FIXME: replace this with [ConstructorAttribute] extended attribute | 507 # FIXME: replace this with [ConstructorAttribute] extended attribute |
| 540 return attribute.idl_type.name.endswith('Constructor') | 508 return attribute.idl_type.name.endswith('Constructor') |
| 541 | 509 |
| 542 | 510 |
| 543 def update_constructor_attribute_context(interface, attribute, context): | 511 def update_constructor_attribute_context(interface, attribute, context): |
| 544 context['needs_constructor_getter_callback'] = context['measure_as'] or cont
ext['deprecate_as'] | 512 context['needs_constructor_getter_callback'] = context['measure_as'] or cont
ext['deprecate_as'] |
| 545 # When the attribute name is the same as the interface name, do not generate | 513 # When the attribute name is the same as the interface name, do not generate |
| 546 # callback functions for each attribute and use | 514 # callback functions for each attribute and use |
| 547 # {{cpp_class}}ConstructorAttributeSetterCallback. Otherwise, generate | 515 # {{cpp_class}}ConstructorAttributeSetterCallback. Otherwise, generate |
| 548 # a callback function in order to hard-code the attribute name. | 516 # a callback function in order to hard-code the attribute name. |
| 549 context['needs_constructor_setter_callback'] = context['name'] != context['c
onstructor_type'] | 517 context['needs_constructor_setter_callback'] = context['name'] != context['c
onstructor_type'] |
| OLD | NEW |