Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(98)

Side by Side Diff: third_party/WebKit/Source/bindings/scripts/v8_interface.py

Issue 1873323002: Have bindings layer assume and insist that all interface types are GCed. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: rebased Created 4 years, 8 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
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 28 matching lines...) Expand all
39 import idl_definitions 39 import idl_definitions
40 from idl_definitions import IdlOperation, IdlArgument 40 from idl_definitions import IdlOperation, IdlArgument
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_ptr_type, cpp_template_type
48 import v8_utilities 48 import v8_utilities
49 from v8_utilities import (cpp_name_or_partial, capitalize, cpp_name, gc_type, 49 from v8_utilities import (cpp_name_or_partial, capitalize, 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, is_legacy_interface_ type_checking) 51 extended_attribute_value_as_list, is_legacy_interface_ type_checking)
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/ToV8.h', 56 'bindings/core/v8/ToV8.h',
57 'bindings/core/v8/V8Binding.h', 57 'bindings/core/v8/V8Binding.h',
58 'bindings/core/v8/V8DOMWrapper.h', 58 'bindings/core/v8/V8DOMWrapper.h',
59 'bindings/core/v8/WrapperTypeInfo.h', 59 'bindings/core/v8/WrapperTypeInfo.h',
(...skipping 83 matching lines...) Expand 10 before | Expand all | Expand 10 after
143 'idl_type': set_wrapper_reference_to_argument.idl_type, 143 'idl_type': set_wrapper_reference_to_argument.idl_type,
144 'v8_type': v8_types.v8_type(set_wrapper_reference_to_argument.idl_ty pe.name), 144 'v8_type': v8_types.v8_type(set_wrapper_reference_to_argument.idl_ty pe.name),
145 } 145 }
146 set_wrapper_reference_to['idl_type'].add_includes_for_type() 146 set_wrapper_reference_to['idl_type'].add_includes_for_type()
147 147
148 # [SetWrapperReferenceFrom] 148 # [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 set_wrapper_reference_from or set_wrapper_reference_to) 151 set_wrapper_reference_from or set_wrapper_reference_to)
152 152
153 this_gc_type = gc_type(interface)
154
155 wrapper_class_id = ('NodeClassId' if inherits_interface(interface.name, 'Nod e') else 'ObjectClassId') 153 wrapper_class_id = ('NodeClassId' if inherits_interface(interface.name, 'Nod e') else 'ObjectClassId')
156 154
157 v8_class_name = v8_utilities.v8_class_name(interface) 155 v8_class_name = v8_utilities.v8_class_name(interface)
158 cpp_class_name = cpp_name(interface) 156 cpp_class_name = cpp_name(interface)
159 cpp_class_name_or_partial = cpp_name_or_partial(interface) 157 cpp_class_name_or_partial = cpp_name_or_partial(interface)
160 v8_class_name_or_partial = v8_utilities.v8_class_name_or_partial(interface) 158 v8_class_name_or_partial = v8_utilities.v8_class_name_or_partial(interface)
161 159
162 context = { 160 context = {
163 'cpp_class': cpp_class_name, 161 'cpp_class': cpp_class_name,
164 'cpp_class_or_partial': cpp_class_name_or_partial, 162 'cpp_class_or_partial': cpp_class_name_or_partial,
165 'event_target_inheritance': 'InheritFromEventTarget' if is_event_target else 'NotInheritFromEventTarget', 163 'event_target_inheritance': 'InheritFromEventTarget' if is_event_target else 'NotInheritFromEventTarget',
166 'gc_type': this_gc_type, 164 'is_gc_type': True,
167 # FIXME: Remove 'EventTarget' special handling, http://crbug.com/383699 165 # FIXME: Remove 'EventTarget' special handling, http://crbug.com/383699
168 'has_access_check_callbacks': (is_check_security and 166 'has_access_check_callbacks': (is_check_security and
169 interface.name != 'Window' and 167 interface.name != 'Window' and
170 interface.name != 'EventTarget'), 168 interface.name != 'EventTarget'),
171 'has_custom_legacy_call_as_function': has_extended_attribute_value(inter face, 'Custom', 'LegacyCallAsFunction'), # [Custom=LegacyCallAsFunction] 169 'has_custom_legacy_call_as_function': has_extended_attribute_value(inter face, 'Custom', 'LegacyCallAsFunction'), # [Custom=LegacyCallAsFunction]
172 'has_partial_interface': len(interface.partial_interfaces) > 0, 170 'has_partial_interface': len(interface.partial_interfaces) > 0,
173 'has_visit_dom_wrapper': has_visit_dom_wrapper, 171 'has_visit_dom_wrapper': has_visit_dom_wrapper,
174 'header_includes': header_includes, 172 'header_includes': header_includes,
175 'interface_name': interface.name, 173 'interface_name': interface.name,
176 'is_array_buffer_or_view': is_array_buffer_or_view, 174 'is_array_buffer_or_view': is_array_buffer_or_view,
177 'is_check_security': is_check_security, 175 'is_check_security': is_check_security,
178 'is_event_target': is_event_target, 176 'is_event_target': is_event_target,
179 'is_exception': interface.is_exception, 177 'is_exception': interface.is_exception,
180 'is_global': is_global, 178 'is_global': is_global,
181 'is_node': inherits_interface(interface.name, 'Node'), 179 'is_node': inherits_interface(interface.name, 'Node'),
182 'is_partial': interface.is_partial, 180 'is_partial': interface.is_partial,
183 'is_typed_array_type': is_typed_array_type, 181 'is_typed_array_type': is_typed_array_type,
184 'lifetime': 'Dependent' if (has_visit_dom_wrapper or is_dependent_lifeti me) else 'Independent', 182 'lifetime': 'Dependent' if (has_visit_dom_wrapper or is_dependent_lifeti me) else 'Independent',
185 'measure_as': v8_utilities.measure_as(interface, None), # [MeasureAs] 183 'measure_as': v8_utilities.measure_as(interface, None), # [MeasureAs]
186 'origin_trial_enabled_function': v8_utilities.origin_trial_enabled_funct ion_name(interface, None), 184 'origin_trial_enabled_function': v8_utilities.origin_trial_enabled_funct ion_name(interface, None),
187 'parent_interface': parent_interface, 185 'parent_interface': parent_interface,
188 'pass_cpp_type': cpp_template_type( 186 'pass_cpp_type': cpp_name(interface) + '*',
189 cpp_ptr_type('PassRefPtr', 'RawPtr', this_gc_type),
190 cpp_name(interface)),
191 'active_scriptwrappable': active_scriptwrappable, 187 'active_scriptwrappable': active_scriptwrappable,
192 'runtime_enabled_function': runtime_enabled_function_name(interface), # [RuntimeEnabled] 188 'runtime_enabled_function': runtime_enabled_function_name(interface), # [RuntimeEnabled]
193 'set_wrapper_reference_from': set_wrapper_reference_from, 189 'set_wrapper_reference_from': set_wrapper_reference_from,
194 'set_wrapper_reference_to': set_wrapper_reference_to, 190 'set_wrapper_reference_to': set_wrapper_reference_to,
195 'v8_class': v8_class_name, 191 'v8_class': v8_class_name,
196 'v8_class_or_partial': v8_class_name_or_partial, 192 'v8_class_or_partial': v8_class_name_or_partial,
197 'wrapper_class_id': wrapper_class_id, 193 'wrapper_class_id': wrapper_class_id,
198 } 194 }
199 195
200 # Constructors 196 # Constructors
(...skipping 1016 matching lines...) Expand 10 before | Expand all | Expand 10 after
1217 # [RaisesException=Constructor] 1213 # [RaisesException=Constructor]
1218 is_constructor_raises_exception = \ 1214 is_constructor_raises_exception = \
1219 interface.extended_attributes.get('RaisesException') == 'Constructor' 1215 interface.extended_attributes.get('RaisesException') == 'Constructor'
1220 1216
1221 argument_contexts = [ 1217 argument_contexts = [
1222 v8_methods.argument_context(interface, constructor, argument, index) 1218 v8_methods.argument_context(interface, constructor, argument, index)
1223 for index, argument in enumerate(constructor.arguments)] 1219 for index, argument in enumerate(constructor.arguments)]
1224 1220
1225 return { 1221 return {
1226 'arguments': argument_contexts, 1222 'arguments': argument_contexts,
1227 'cpp_type': cpp_template_type( 1223 'cpp_type': cpp_name(interface) + '*',
1228 cpp_ptr_type('RefPtr', 'RawPtr', gc_type(interface)),
1229 cpp_name(interface)),
1230 'cpp_value': v8_methods.cpp_value( 1224 'cpp_value': v8_methods.cpp_value(
1231 interface, constructor, len(constructor.arguments)), 1225 interface, constructor, len(constructor.arguments)),
1232 'has_exception_state': 1226 'has_exception_state':
1233 is_constructor_raises_exception or 1227 is_constructor_raises_exception or
1234 any(argument for argument in constructor.arguments 1228 any(argument for argument in constructor.arguments
1235 if argument.idl_type.name == 'SerializedScriptValue' or 1229 if argument.idl_type.name == 'SerializedScriptValue' or
1236 argument.idl_type.v8_conversion_needs_exception_state), 1230 argument.idl_type.v8_conversion_needs_exception_state),
1237 'has_optional_argument_without_default_value': 1231 'has_optional_argument_without_default_value':
1238 any(True for argument_context in argument_contexts 1232 any(True for argument_context in argument_contexts
1239 if argument_context['is_optional_without_default_value']), 1233 if argument_context['is_optional_without_default_value']),
(...skipping 98 matching lines...) Expand 10 before | Expand all | Expand 10 after
1338 has_extended_attribute_value(getter, 'Custom', 'PropertyGetter')), 1332 has_extended_attribute_value(getter, 'Custom', 'PropertyGetter')),
1339 'is_custom_property_enumerator': has_extended_attribute_value( 1333 'is_custom_property_enumerator': has_extended_attribute_value(
1340 getter, 'Custom', 'PropertyEnumerator'), 1334 getter, 'Custom', 'PropertyEnumerator'),
1341 'is_custom_property_query': has_extended_attribute_value( 1335 'is_custom_property_query': has_extended_attribute_value(
1342 getter, 'Custom', 'PropertyQuery'), 1336 getter, 'Custom', 'PropertyQuery'),
1343 'is_enumerable': 'NotEnumerable' not in extended_attributes, 1337 'is_enumerable': 'NotEnumerable' not in extended_attributes,
1344 'is_null_expression': is_null_expression(idl_type), 1338 'is_null_expression': is_null_expression(idl_type),
1345 'is_raises_exception': is_raises_exception, 1339 'is_raises_exception': is_raises_exception,
1346 'name': cpp_name(getter), 1340 'name': cpp_name(getter),
1347 'use_output_parameter_for_result': use_output_parameter_for_result, 1341 'use_output_parameter_for_result': use_output_parameter_for_result,
1348 'v8_set_return_value': idl_type.v8_set_return_value('result', extended_a ttributes=extended_attributes, script_wrappable='impl', release=idl_type.release ), 1342 'v8_set_return_value': idl_type.v8_set_return_value('result', extended_a ttributes=extended_attributes, script_wrappable='impl'),
1349 } 1343 }
1350 1344
1351 1345
1352 def property_setter(setter, interface): 1346 def property_setter(setter, interface):
1353 if not setter: 1347 if not setter:
1354 return None 1348 return None
1355 1349
1356 extended_attributes = setter.extended_attributes 1350 extended_attributes = setter.extended_attributes
1357 idl_type = setter.arguments[1].idl_type 1351 idl_type = setter.arguments[1].idl_type
1358 idl_type.add_includes_for_type(extended_attributes) 1352 idl_type.add_includes_for_type(extended_attributes)
(...skipping 26 matching lines...) Expand all
1385 1379
1386 extended_attributes = deleter.extended_attributes 1380 extended_attributes = deleter.extended_attributes
1387 idl_type = deleter.idl_type 1381 idl_type = deleter.idl_type
1388 is_call_with_script_state = v8_utilities.has_extended_attribute_value(delete r, 'CallWith', 'ScriptState') 1382 is_call_with_script_state = v8_utilities.has_extended_attribute_value(delete r, 'CallWith', 'ScriptState')
1389 return { 1383 return {
1390 'is_call_with_script_state': is_call_with_script_state, 1384 'is_call_with_script_state': is_call_with_script_state,
1391 'is_custom': 'Custom' in extended_attributes, 1385 'is_custom': 'Custom' in extended_attributes,
1392 'is_raises_exception': 'RaisesException' in extended_attributes, 1386 'is_raises_exception': 'RaisesException' in extended_attributes,
1393 'name': cpp_name(deleter), 1387 'name': cpp_name(deleter),
1394 } 1388 }
OLDNEW
« no previous file with comments | « third_party/WebKit/Source/bindings/scripts/v8_dictionary.py ('k') | third_party/WebKit/Source/bindings/scripts/v8_methods.py » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698