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

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

Issue 1861433002: Make [OriginTrialEnabled] and [RuntimeEnabled] mutually exclusive (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@586594-separate-tests
Patch Set: Correct IDL for Web Bluetooth 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 (origin_trial_enabled_function, cpp_name_or_partial, ca pitalize, cpp_name, gc_type, 49 from v8_utilities import (cpp_name_or_partial, capitalize, cpp_name, gc_type,
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 92 matching lines...) Expand 10 before | Expand all | Expand 10 after
152 152
153 this_gc_type = gc_type(interface) 153 this_gc_type = gc_type(interface)
154 154
155 wrapper_class_id = ('NodeClassId' if inherits_interface(interface.name, 'Nod e') else 'ObjectClassId') 155 wrapper_class_id = ('NodeClassId' if inherits_interface(interface.name, 'Nod e') else 'ObjectClassId')
156 156
157 v8_class_name = v8_utilities.v8_class_name(interface) 157 v8_class_name = v8_utilities.v8_class_name(interface)
158 cpp_class_name = cpp_name(interface) 158 cpp_class_name = cpp_name(interface)
159 cpp_class_name_or_partial = cpp_name_or_partial(interface) 159 cpp_class_name_or_partial = cpp_name_or_partial(interface)
160 v8_class_name_or_partial = v8_utilities.v8_class_name_or_partial(interface) 160 v8_class_name_or_partial = v8_utilities.v8_class_name_or_partial(interface)
161 161
162 if 'RuntimeEnabled' in extended_attributes:
163 includes.add('platform/RuntimeEnabledFeatures.h')
164
165 if 'OriginTrialEnabled' in extended_attributes:
166 includes.add('core/inspector/ConsoleMessage.h')
167 includes.add('core/origin_trials/OriginTrials.h')
168
169 context = { 162 context = {
170 'cpp_class': cpp_class_name, 163 'cpp_class': cpp_class_name,
171 'cpp_class_or_partial': cpp_class_name_or_partial, 164 'cpp_class_or_partial': cpp_class_name_or_partial,
172 'event_target_inheritance': 'InheritFromEventTarget' if is_event_target else 'NotInheritFromEventTarget', 165 'event_target_inheritance': 'InheritFromEventTarget' if is_event_target else 'NotInheritFromEventTarget',
173 'gc_type': this_gc_type, 166 'gc_type': this_gc_type,
174 # FIXME: Remove 'EventTarget' special handling, http://crbug.com/383699 167 # FIXME: Remove 'EventTarget' special handling, http://crbug.com/383699
175 'has_access_check_callbacks': (is_check_security and 168 'has_access_check_callbacks': (is_check_security and
176 interface.name != 'Window' and 169 interface.name != 'Window' and
177 interface.name != 'EventTarget'), 170 interface.name != 'EventTarget'),
178 'has_custom_legacy_call_as_function': has_extended_attribute_value(inter face, 'Custom', 'LegacyCallAsFunction'), # [Custom=LegacyCallAsFunction] 171 'has_custom_legacy_call_as_function': has_extended_attribute_value(inter face, 'Custom', 'LegacyCallAsFunction'), # [Custom=LegacyCallAsFunction]
179 'has_partial_interface': len(interface.partial_interfaces) > 0, 172 'has_partial_interface': len(interface.partial_interfaces) > 0,
180 'has_visit_dom_wrapper': has_visit_dom_wrapper, 173 'has_visit_dom_wrapper': has_visit_dom_wrapper,
181 'header_includes': header_includes, 174 'header_includes': header_includes,
182 'interface_name': interface.name, 175 'interface_name': interface.name,
183 'is_array_buffer_or_view': is_array_buffer_or_view, 176 'is_array_buffer_or_view': is_array_buffer_or_view,
184 'is_check_security': is_check_security, 177 'is_check_security': is_check_security,
185 'is_event_target': is_event_target, 178 'is_event_target': is_event_target,
186 'is_exception': interface.is_exception, 179 'is_exception': interface.is_exception,
187 'is_global': is_global, 180 'is_global': is_global,
188 'is_node': inherits_interface(interface.name, 'Node'), 181 'is_node': inherits_interface(interface.name, 'Node'),
189 'is_partial': interface.is_partial, 182 'is_partial': interface.is_partial,
190 'is_typed_array_type': is_typed_array_type, 183 'is_typed_array_type': is_typed_array_type,
191 'lifetime': 'Dependent' if (has_visit_dom_wrapper or is_dependent_lifeti me) else 'Independent', 184 'lifetime': 'Dependent' if (has_visit_dom_wrapper or is_dependent_lifeti me) else 'Independent',
192 'measure_as': v8_utilities.measure_as(interface, None), # [MeasureAs] 185 'measure_as': v8_utilities.measure_as(interface, None), # [MeasureAs]
193 'origin_trial_name': v8_utilities.origin_trial_name(interface), 186 'origin_trial_enabled_function': v8_utilities.origin_trial_enabled_funct ion_name(interface, None),
194 'parent_interface': parent_interface, 187 'parent_interface': parent_interface,
195 'pass_cpp_type': cpp_template_type( 188 'pass_cpp_type': cpp_template_type(
196 cpp_ptr_type('PassRefPtr', 'RawPtr', this_gc_type), 189 cpp_ptr_type('PassRefPtr', 'RawPtr', this_gc_type),
197 cpp_name(interface)), 190 cpp_name(interface)),
198 'active_scriptwrappable': active_scriptwrappable, 191 'active_scriptwrappable': active_scriptwrappable,
199 'runtime_enabled_function': runtime_enabled_function_name(interface), # [RuntimeEnabled] 192 'runtime_enabled_function': runtime_enabled_function_name(interface), # [RuntimeEnabled]
200 'set_wrapper_reference_from': set_wrapper_reference_from, 193 'set_wrapper_reference_from': set_wrapper_reference_from,
201 'set_wrapper_reference_to': set_wrapper_reference_to, 194 'set_wrapper_reference_to': set_wrapper_reference_to,
202 'v8_class': v8_class_name, 195 'v8_class': v8_class_name,
203 'v8_class_or_partial': v8_class_name_or_partial, 196 'v8_class_or_partial': v8_class_name_or_partial,
(...skipping 50 matching lines...) Expand 10 before | Expand all | Expand 10 after
254 'unscopeables': sorted(unscopeables), 247 'unscopeables': sorted(unscopeables),
255 }) 248 })
256 249
257 constants = [constant_context(constant, interface) for constant in interface .constants] 250 constants = [constant_context(constant, interface) for constant in interface .constants]
258 251
259 special_getter_constants = [] 252 special_getter_constants = []
260 runtime_enabled_constants = dict() 253 runtime_enabled_constants = dict()
261 constant_configuration_constants = [] 254 constant_configuration_constants = []
262 255
263 for constant in constants: 256 for constant in constants:
264 if constant['measure_as'] or constant['deprecate_as'] or constant['origi n_trial_name']: 257 if constant['measure_as'] or constant['deprecate_as'] or constant['origi n_trial_enabled_function']:
265 special_getter_constants.append(constant) 258 special_getter_constants.append(constant)
266 continue 259 continue
267 runtime_enabled_function = constant['runtime_enabled_function'] 260 runtime_enabled_function = constant['runtime_enabled_function']
268 if runtime_enabled_function: 261 if runtime_enabled_function:
269 if runtime_enabled_function not in runtime_enabled_constants: 262 if runtime_enabled_function not in runtime_enabled_constants:
270 runtime_enabled_constants[runtime_enabled_function] = [] 263 runtime_enabled_constants[runtime_enabled_function] = []
271 runtime_enabled_constants[runtime_enabled_function].append(constant) 264 runtime_enabled_constants[runtime_enabled_function].append(constant)
272 continue 265 continue
273 constant_configuration_constants.append(constant) 266 constant_configuration_constants.append(constant)
274 267
(...skipping 330 matching lines...) Expand 10 before | Expand all | Expand 10 after
605 'has_named_properties_object': is_global and context['named_property_get ter'], 598 'has_named_properties_object': is_global and context['named_property_get ter'],
606 }) 599 })
607 600
608 return context 601 return context
609 602
610 603
611 # [DeprecateAs], [OriginTrialEnabled], [Reflect], [RuntimeEnabled] 604 # [DeprecateAs], [OriginTrialEnabled], [Reflect], [RuntimeEnabled]
612 def constant_context(constant, interface): 605 def constant_context(constant, interface):
613 extended_attributes = constant.extended_attributes 606 extended_attributes = constant.extended_attributes
614 607
615 if 'OriginTrialEnabled' in extended_attributes:
616 includes.add('core/inspector/ConsoleMessage.h')
617 includes.add('core/origin_trials/OriginTrials.h')
618
619 return { 608 return {
620 'cpp_class': extended_attributes.get('PartialInterfaceImplementedAs'), 609 'cpp_class': extended_attributes.get('PartialInterfaceImplementedAs'),
621 'deprecate_as': v8_utilities.deprecate_as(constant), # [DeprecateAs] 610 'deprecate_as': v8_utilities.deprecate_as(constant), # [DeprecateAs]
622 'idl_type': constant.idl_type.name, 611 'idl_type': constant.idl_type.name,
623 'is_origin_trial_enabled': v8_utilities.origin_trial_enabled_function(co nstant) or v8_utilities.origin_trial_enabled_function(interface), # [OriginTria lEnabled]
624 'measure_as': v8_utilities.measure_as(constant, interface), # [MeasureA s] 612 'measure_as': v8_utilities.measure_as(constant, interface), # [MeasureA s]
625 'name': constant.name, 613 'name': constant.name,
626 'origin_trial_enabled': v8_utilities.origin_trial_enabled_function(const ant), # [OriginTrialEnabled] 614 'origin_trial_enabled_function': v8_utilities.origin_trial_enabled_funct ion_name(constant, interface), # [OriginTrialEnabled]
627 'origin_trial_enabled_per_interface': v8_utilities.origin_trial_enabled_ function(interface), # [OriginTrialEnabled]
628 'origin_trial_name': extended_attributes.get('OriginTrialEnabled'), # [ OriginTrialEnabled]
629 # FIXME: use 'reflected_name' as correct 'name' 615 # FIXME: use 'reflected_name' as correct 'name'
630 'reflected_name': extended_attributes.get('Reflect', constant.name), 616 'reflected_name': extended_attributes.get('Reflect', constant.name),
631 'runtime_enabled_function': runtime_enabled_function_name(constant), # [RuntimeEnabled] 617 'runtime_enabled_function': runtime_enabled_function_name(constant), # [RuntimeEnabled]
632 'value': constant.value, 618 'value': constant.value,
633 } 619 }
634 620
635 621
636 ################################################################################ 622 ################################################################################
637 # Overloads 623 # Overloads
638 ################################################################################ 624 ################################################################################
(...skipping 760 matching lines...) Expand 10 before | Expand all | Expand 10 after
1399 1385
1400 extended_attributes = deleter.extended_attributes 1386 extended_attributes = deleter.extended_attributes
1401 idl_type = deleter.idl_type 1387 idl_type = deleter.idl_type
1402 is_call_with_script_state = v8_utilities.has_extended_attribute_value(delete r, 'CallWith', 'ScriptState') 1388 is_call_with_script_state = v8_utilities.has_extended_attribute_value(delete r, 'CallWith', 'ScriptState')
1403 return { 1389 return {
1404 'is_call_with_script_state': is_call_with_script_state, 1390 'is_call_with_script_state': is_call_with_script_state,
1405 'is_custom': 'Custom' in extended_attributes, 1391 'is_custom': 'Custom' in extended_attributes,
1406 'is_raises_exception': 'RaisesException' in extended_attributes, 1392 'is_raises_exception': 'RaisesException' in extended_attributes,
1407 'name': cpp_name(deleter), 1393 'name': cpp_name(deleter),
1408 } 1394 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698