| 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 26 matching lines...) Expand all Loading... |
| 37 from operator import itemgetter | 37 from operator import itemgetter |
| 38 | 38 |
| 39 import idl_definitions | 39 import idl_definitions |
| 40 from idl_definitions import IdlOperation | 40 from idl_definitions import IdlOperation |
| 41 import idl_types | 41 import idl_types |
| 42 from idl_types import IdlType, inherits_interface | 42 from idl_types import IdlType, inherits_interface |
| 43 import v8_attributes | 43 import v8_attributes |
| 44 from v8_globals import includes | 44 from v8_globals import includes |
| 45 import v8_methods | 45 import v8_methods |
| 46 import v8_types | 46 import v8_types |
| 47 from v8_types import cpp_ptr_type, cpp_template_type | 47 from v8_types import cpp_template_type |
| 48 import v8_utilities | 48 import v8_utilities |
| 49 from v8_utilities import (capitalize, conditional_string, cpp_name, gc_type, | 49 from v8_utilities import (capitalize, conditional_string, cpp_name, |
| 50 has_extended_attribute_value, runtime_enabled_function
_name, | 50 has_extended_attribute_value, runtime_enabled_function
_name, |
| 51 extended_attribute_value_as_list) | 51 extended_attribute_value_as_list) |
| 52 | 52 |
| 53 | 53 |
| 54 INTERFACE_H_INCLUDES = frozenset([ | 54 INTERFACE_H_INCLUDES = frozenset([ |
| 55 'bindings/core/v8/ScriptWrappable.h', | 55 'bindings/core/v8/ScriptWrappable.h', |
| 56 'bindings/core/v8/V8Binding.h', | 56 'bindings/core/v8/V8Binding.h', |
| 57 'bindings/core/v8/V8DOMWrapper.h', | 57 'bindings/core/v8/V8DOMWrapper.h', |
| 58 'bindings/core/v8/WrapperTypeInfo.h', | 58 'bindings/core/v8/WrapperTypeInfo.h', |
| 59 'platform/heap/Handle.h', | 59 'platform/heap/Handle.h', |
| (...skipping 84 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 144 special_wrap_for = [] | 144 special_wrap_for = [] |
| 145 for special_wrap_interface in special_wrap_for: | 145 for special_wrap_interface in special_wrap_for: |
| 146 v8_types.add_includes_for_interface(special_wrap_interface) | 146 v8_types.add_includes_for_interface(special_wrap_interface) |
| 147 | 147 |
| 148 # [Custom=Wrap], [SetWrapperReferenceFrom] | 148 # [Custom=Wrap], [SetWrapperReferenceFrom] |
| 149 has_visit_dom_wrapper = ( | 149 has_visit_dom_wrapper = ( |
| 150 has_extended_attribute_value(interface, 'Custom', 'VisitDOMWrapper') or | 150 has_extended_attribute_value(interface, 'Custom', 'VisitDOMWrapper') or |
| 151 reachable_node_function or | 151 reachable_node_function or |
| 152 set_wrapper_reference_to_list) | 152 set_wrapper_reference_to_list) |
| 153 | 153 |
| 154 this_gc_type = gc_type(interface) | |
| 155 | |
| 156 wrapper_class_id = ('NodeClassId' if inherits_interface(interface.name, 'Nod
e') else 'ObjectClassId') | 154 wrapper_class_id = ('NodeClassId' if inherits_interface(interface.name, 'Nod
e') else 'ObjectClassId') |
| 157 | 155 |
| 158 context = { | 156 context = { |
| 159 'conditional_string': conditional_string(interface), # [Conditional] | 157 'conditional_string': conditional_string(interface), # [Conditional] |
| 160 'cpp_class': cpp_name(interface), | 158 'cpp_class': cpp_name(interface), |
| 161 'gc_type': this_gc_type, | |
| 162 # FIXME: Remove 'EventTarget' special handling, http://crbug.com/383699 | 159 # FIXME: Remove 'EventTarget' special handling, http://crbug.com/383699 |
| 163 'has_access_check_callbacks': (is_check_security and | 160 'has_access_check_callbacks': (is_check_security and |
| 164 interface.name != 'Window' and | 161 interface.name != 'Window' and |
| 165 interface.name != 'EventTarget'), | 162 interface.name != 'EventTarget'), |
| 166 'has_custom_legacy_call_as_function': has_extended_attribute_value(inter
face, 'Custom', 'LegacyCallAsFunction'), # [Custom=LegacyCallAsFunction] | 163 'has_custom_legacy_call_as_function': has_extended_attribute_value(inter
face, 'Custom', 'LegacyCallAsFunction'), # [Custom=LegacyCallAsFunction] |
| 167 'has_custom_to_v8': has_extended_attribute_value(interface, 'Custom', 'T
oV8'), # [Custom=ToV8] | 164 'has_custom_to_v8': has_extended_attribute_value(interface, 'Custom', 'T
oV8'), # [Custom=ToV8] |
| 168 'has_custom_wrap': has_extended_attribute_value(interface, 'Custom', 'Wr
ap'), # [Custom=Wrap] | 165 'has_custom_wrap': has_extended_attribute_value(interface, 'Custom', 'Wr
ap'), # [Custom=Wrap] |
| 169 'has_visit_dom_wrapper': has_visit_dom_wrapper, | 166 'has_visit_dom_wrapper': has_visit_dom_wrapper, |
| 170 'header_includes': header_includes, | 167 'header_includes': header_includes, |
| 171 'interface_name': interface.name, | 168 'interface_name': interface.name, |
| 172 'is_active_dom_object': is_active_dom_object, | 169 'is_active_dom_object': is_active_dom_object, |
| 173 'is_check_security': is_check_security, | 170 'is_check_security': is_check_security, |
| 174 'is_dependent_lifetime': is_dependent_lifetime, | 171 'is_dependent_lifetime': is_dependent_lifetime, |
| 175 'is_document': is_document, | 172 'is_document': is_document, |
| 176 'is_event_target': inherits_interface(interface.name, 'EventTarget'), | 173 'is_event_target': inherits_interface(interface.name, 'EventTarget'), |
| 177 'is_exception': interface.is_exception, | 174 'is_exception': interface.is_exception, |
| 178 'is_node': inherits_interface(interface.name, 'Node'), | 175 'is_node': inherits_interface(interface.name, 'Node'), |
| 179 'is_script_wrappable': is_script_wrappable, | 176 'is_script_wrappable': is_script_wrappable, |
| 180 'iterator_method': iterator_method, | 177 'iterator_method': iterator_method, |
| 181 'lifetime': 'Dependent' | 178 'lifetime': 'Dependent' |
| 182 if (has_visit_dom_wrapper or | 179 if (has_visit_dom_wrapper or |
| 183 is_active_dom_object or | 180 is_active_dom_object or |
| 184 is_dependent_lifetime) | 181 is_dependent_lifetime) |
| 185 else 'Independent', | 182 else 'Independent', |
| 186 'measure_as': v8_utilities.measure_as(interface), # [MeasureAs] | 183 'measure_as': v8_utilities.measure_as(interface), # [MeasureAs] |
| 187 'parent_interface': parent_interface, | 184 'parent_interface': parent_interface, |
| 188 'pass_cpp_type': cpp_template_type( | 185 'pass_cpp_type': cpp_template_type( |
| 189 cpp_ptr_type('PassRefPtr', 'RawPtr', this_gc_type), | 186 'PassRefPtr', |
| 190 cpp_name(interface)), | 187 cpp_name(interface)), |
| 191 'reachable_node_function': reachable_node_function, | 188 'reachable_node_function': reachable_node_function, |
| 192 'runtime_enabled_function': runtime_enabled_function_name(interface), #
[RuntimeEnabled] | 189 'runtime_enabled_function': runtime_enabled_function_name(interface), #
[RuntimeEnabled] |
| 193 'set_wrapper_reference_to_list': set_wrapper_reference_to_list, | 190 'set_wrapper_reference_to_list': set_wrapper_reference_to_list, |
| 194 'special_wrap_for': special_wrap_for, | 191 'special_wrap_for': special_wrap_for, |
| 195 'v8_class': v8_utilities.v8_class_name(interface), | 192 'v8_class': v8_utilities.v8_class_name(interface), |
| 196 'wrapper_class_id': wrapper_class_id, | 193 'wrapper_class_id': wrapper_class_id, |
| 197 } | 194 } |
| 198 | 195 |
| 199 # Constructors | 196 # Constructors |
| (...skipping 686 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 886 | 883 |
| 887 # [RaisesException=Constructor] | 884 # [RaisesException=Constructor] |
| 888 is_constructor_raises_exception = \ | 885 is_constructor_raises_exception = \ |
| 889 interface.extended_attributes.get('RaisesException') == 'Constructor' | 886 interface.extended_attributes.get('RaisesException') == 'Constructor' |
| 890 | 887 |
| 891 return { | 888 return { |
| 892 'arguments': [v8_methods.argument_context(interface, constructor, argume
nt, index) | 889 'arguments': [v8_methods.argument_context(interface, constructor, argume
nt, index) |
| 893 for index, argument in enumerate(constructor.arguments)], | 890 for index, argument in enumerate(constructor.arguments)], |
| 894 'arguments_need_try_catch': arguments_need_try_catch, | 891 'arguments_need_try_catch': arguments_need_try_catch, |
| 895 'cpp_type': cpp_template_type( | 892 'cpp_type': cpp_template_type( |
| 896 cpp_ptr_type('RefPtr', 'RawPtr', gc_type(interface)), | 893 'RefPtr', |
| 897 cpp_name(interface)), | 894 cpp_name(interface)), |
| 898 'cpp_value': v8_methods.cpp_value( | 895 'cpp_value': v8_methods.cpp_value( |
| 899 interface, constructor, len(constructor.arguments)), | 896 interface, constructor, len(constructor.arguments)), |
| 900 'has_exception_state': | 897 'has_exception_state': |
| 901 is_constructor_raises_exception or | 898 is_constructor_raises_exception or |
| 902 any(argument for argument in constructor.arguments | 899 any(argument for argument in constructor.arguments |
| 903 if argument.idl_type.name == 'SerializedScriptValue' or | 900 if argument.idl_type.name == 'SerializedScriptValue' or |
| 904 argument.idl_type.may_raise_exception_on_conversion), | 901 argument.idl_type.may_raise_exception_on_conversion), |
| 905 'is_call_with_document': | 902 'is_call_with_document': |
| 906 # [ConstructorCallWith=Document] | 903 # [ConstructorCallWith=Document] |
| (...skipping 229 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1136 deleter = next( | 1133 deleter = next( |
| 1137 method | 1134 method |
| 1138 for method in interface.operations | 1135 for method in interface.operations |
| 1139 if ('deleter' in method.specials and | 1136 if ('deleter' in method.specials and |
| 1140 len(method.arguments) == 1 and | 1137 len(method.arguments) == 1 and |
| 1141 str(method.arguments[0].idl_type) == 'DOMString')) | 1138 str(method.arguments[0].idl_type) == 'DOMString')) |
| 1142 except StopIteration: | 1139 except StopIteration: |
| 1143 return None | 1140 return None |
| 1144 | 1141 |
| 1145 return property_deleter(deleter) | 1142 return property_deleter(deleter) |
| OLD | NEW |