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 | |
73 # [CustomElementCallbacks], [Reflect] | 68 # [CustomElementCallbacks], [Reflect] |
74 is_custom_element_callbacks = 'CustomElementCallbacks' in extended_attribute
s | 69 is_custom_element_callbacks = 'CustomElementCallbacks' in extended_attribute
s |
75 is_reflect = 'Reflect' in extended_attributes | 70 is_reflect = 'Reflect' in extended_attributes |
76 if is_custom_element_callbacks or is_reflect: | 71 if is_custom_element_callbacks or is_reflect: |
77 includes.add('core/dom/custom/CustomElementProcessingStack.h') | 72 includes.add('core/dom/custom/CustomElementProcessingStack.h') |
78 # [ImplementedInPrivateScript] | 73 # [ImplementedInPrivateScript] |
79 is_implemented_in_private_script = 'ImplementedInPrivateScript' in extended_
attributes | 74 is_implemented_in_private_script = 'ImplementedInPrivateScript' in extended_
attributes |
80 if is_implemented_in_private_script: | 75 if is_implemented_in_private_script: |
81 includes.add('bindings/core/v8/PrivateScriptRunner.h') | 76 includes.add('bindings/core/v8/PrivateScriptRunner.h') |
82 includes.add('core/frame/LocalFrame.h') | 77 includes.add('core/frame/LocalFrame.h') |
(...skipping 15 matching lines...) Expand all Loading... |
98 includes.add('bindings/core/v8/V8HiddenValue.h') | 93 includes.add('bindings/core/v8/V8HiddenValue.h') |
99 | 94 |
100 context = { | 95 context = { |
101 'access_control_list': access_control_list(interface, attribute), | 96 'access_control_list': access_control_list(interface, attribute), |
102 'activity_logging_world_list_for_getter': v8_utilities.activity_logging_
world_list(attribute, 'Getter'), # [ActivityLogging] | 97 'activity_logging_world_list_for_getter': v8_utilities.activity_logging_
world_list(attribute, 'Getter'), # [ActivityLogging] |
103 'activity_logging_world_list_for_setter': v8_utilities.activity_logging_
world_list(attribute, 'Setter'), # [ActivityLogging] | 98 'activity_logging_world_list_for_setter': v8_utilities.activity_logging_
world_list(attribute, 'Setter'), # [ActivityLogging] |
104 'activity_logging_world_check': v8_utilities.activity_logging_world_chec
k(attribute), # [ActivityLogging] | 99 'activity_logging_world_check': v8_utilities.activity_logging_world_chec
k(attribute), # [ActivityLogging] |
105 'argument_cpp_type': idl_type.cpp_type_args(used_as_rvalue_type=True), | 100 'argument_cpp_type': idl_type.cpp_type_args(used_as_rvalue_type=True), |
106 'cached_attribute_validation_method': cached_attribute_validation_method
, | 101 'cached_attribute_validation_method': cached_attribute_validation_method
, |
107 'conditional_string': v8_utilities.conditional_string(attribute), | 102 'conditional_string': v8_utilities.conditional_string(attribute), |
108 'constructor_type': constructor_type, | 103 'constructor_type': idl_type.constructor_type_name |
| 104 if is_constructor_attribute(attribute) else None, |
109 'cpp_name': cpp_name(attribute), | 105 'cpp_name': cpp_name(attribute), |
110 'cpp_type': idl_type.cpp_type, | 106 'cpp_type': idl_type.cpp_type, |
111 'cpp_type_initializer': idl_type.cpp_type_initializer, | 107 'cpp_type_initializer': idl_type.cpp_type_initializer, |
112 'deprecate_as': v8_utilities.deprecate_as(attribute), # [DeprecateAs] | 108 'deprecate_as': v8_utilities.deprecate_as(attribute), # [DeprecateAs] |
113 'enum_type': idl_type.enum_type, | 109 'enum_type': idl_type.enum_type, |
114 'enum_values': idl_type.enum_values, | 110 'enum_values': idl_type.enum_values, |
115 'exposed_test': v8_utilities.exposed(attribute, interface), # [Exposed] | 111 'exposed_test': v8_utilities.exposed(attribute, interface), # [Exposed] |
116 'has_custom_getter': has_custom_getter(attribute), | 112 'has_custom_getter': has_custom_getter(attribute), |
117 'has_custom_setter': has_custom_setter(attribute), | 113 'has_custom_setter': has_custom_setter(attribute), |
118 'has_setter': has_setter(attribute), | 114 'has_setter': has_setter(attribute), |
119 'idl_type': str(idl_type), # need trailing [] on array for Dictionary::
ConversionContext::setConversionType | 115 'idl_type': str(idl_type), # need trailing [] on array for Dictionary::
ConversionContext::setConversionType |
120 'is_call_with_execution_context': has_extended_attribute_value(attribute
, 'CallWith', 'ExecutionContext'), | 116 'is_call_with_execution_context': has_extended_attribute_value(attribute
, 'CallWith', 'ExecutionContext'), |
121 'is_call_with_script_state': has_extended_attribute_value(attribute, 'Ca
llWith', 'ScriptState'), | 117 'is_call_with_script_state': has_extended_attribute_value(attribute, 'Ca
llWith', 'ScriptState'), |
122 'is_check_security_for_frame': is_check_security_for_frame, | 118 'is_check_security_for_frame': is_check_security_for_frame, |
123 'is_check_security_for_node': is_check_security_for_node, | 119 'is_check_security_for_node': is_check_security_for_node, |
124 'is_check_security_for_window': is_check_security_for_window, | 120 'is_check_security_for_window': is_check_security_for_window, |
125 'is_custom_element_callbacks': is_custom_element_callbacks, | 121 'is_custom_element_callbacks': is_custom_element_callbacks, |
126 # TODO(yukishiino): Make all DOM attributes accessor-type properties. | 122 'is_expose_js_accessors': is_expose_js_accessors(interface, attribute), |
127 'is_data_type_property': constructor_type or interface.name == 'Window', | |
128 'is_getter_raises_exception': # [RaisesException] | 123 'is_getter_raises_exception': # [RaisesException] |
129 'RaisesException' in extended_attributes and | 124 'RaisesException' in extended_attributes and |
130 extended_attributes['RaisesException'] in (None, 'Getter'), | 125 extended_attributes['RaisesException'] in (None, 'Getter'), |
131 'is_implemented_in_private_script': is_implemented_in_private_script, | 126 'is_implemented_in_private_script': is_implemented_in_private_script, |
132 'is_keep_alive_for_gc': keep_alive_for_gc, | 127 'is_keep_alive_for_gc': keep_alive_for_gc, |
133 'is_lenient_this': 'LenientThis' in extended_attributes, | 128 'is_lenient_this': 'LenientThis' in extended_attributes, |
134 'is_nullable': idl_type.is_nullable, | 129 'is_nullable': idl_type.is_nullable, |
135 'is_explicit_nullable': idl_type.is_explicit_nullable, | 130 'is_explicit_nullable': idl_type.is_explicit_nullable, |
136 'is_partial_interface_member': | 131 'is_partial_interface_member': |
137 'PartialInterfaceImplementedAs' in extended_attributes, | 132 'PartialInterfaceImplementedAs' in extended_attributes, |
(...skipping 349 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
487 | 482 |
488 | 483 |
489 # [Custom], [Custom=Setter] | 484 # [Custom], [Custom=Setter] |
490 def has_custom_setter(attribute): | 485 def has_custom_setter(attribute): |
491 extended_attributes = attribute.extended_attributes | 486 extended_attributes = attribute.extended_attributes |
492 return (not attribute.is_read_only and | 487 return (not attribute.is_read_only and |
493 'Custom' in extended_attributes and | 488 'Custom' in extended_attributes and |
494 extended_attributes['Custom'] in [None, 'Setter']) | 489 extended_attributes['Custom'] in [None, 'Setter']) |
495 | 490 |
496 | 491 |
| 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 |
497 ################################################################################ | 529 ################################################################################ |
498 # Constructors | 530 # Constructors |
499 ################################################################################ | 531 ################################################################################ |
500 | 532 |
501 idl_types.IdlType.constructor_type_name = property( | 533 idl_types.IdlType.constructor_type_name = property( |
502 # FIXME: replace this with a [ConstructorAttribute] extended attribute | 534 # FIXME: replace this with a [ConstructorAttribute] extended attribute |
503 lambda self: strip_suffix(self.base_type, 'Constructor')) | 535 lambda self: strip_suffix(self.base_type, 'Constructor')) |
504 | 536 |
505 | 537 |
506 def is_constructor_attribute(attribute): | 538 def is_constructor_attribute(attribute): |
507 # FIXME: replace this with [ConstructorAttribute] extended attribute | 539 # FIXME: replace this with [ConstructorAttribute] extended attribute |
508 return attribute.idl_type.name.endswith('Constructor') | 540 return attribute.idl_type.name.endswith('Constructor') |
509 | 541 |
510 | 542 |
511 def update_constructor_attribute_context(interface, attribute, context): | 543 def update_constructor_attribute_context(interface, attribute, context): |
512 context['needs_constructor_getter_callback'] = context['measure_as'] or cont
ext['deprecate_as'] | 544 context['needs_constructor_getter_callback'] = context['measure_as'] or cont
ext['deprecate_as'] |
513 # When the attribute name is the same as the interface name, do not generate | 545 # When the attribute name is the same as the interface name, do not generate |
514 # callback functions for each attribute and use | 546 # callback functions for each attribute and use |
515 # {{cpp_class}}ConstructorAttributeSetterCallback. Otherwise, generate | 547 # {{cpp_class}}ConstructorAttributeSetterCallback. Otherwise, generate |
516 # a callback function in order to hard-code the attribute name. | 548 # a callback function in order to hard-code the attribute name. |
517 context['needs_constructor_setter_callback'] = context['name'] != context['c
onstructor_type'] | 549 context['needs_constructor_setter_callback'] = context['name'] != context['c
onstructor_type'] |
OLD | NEW |