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 30 matching lines...) Expand all Loading... | |
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, conditional_string, c pp_name, gc_type, | 49 from v8_utilities import (cpp_name_or_partial, capitalize, conditional_string, c pp_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 experimental_api_name) | |
52 | 53 |
53 | 54 |
54 INTERFACE_H_INCLUDES = frozenset([ | 55 INTERFACE_H_INCLUDES = frozenset([ |
55 'bindings/core/v8/ScriptWrappable.h', | 56 'bindings/core/v8/ScriptWrappable.h', |
56 'bindings/core/v8/ToV8.h', | 57 'bindings/core/v8/ToV8.h', |
57 'bindings/core/v8/V8Binding.h', | 58 'bindings/core/v8/V8Binding.h', |
58 'bindings/core/v8/V8DOMWrapper.h', | 59 'bindings/core/v8/V8DOMWrapper.h', |
59 'bindings/core/v8/WrapperTypeInfo.h', | 60 'bindings/core/v8/WrapperTypeInfo.h', |
60 'platform/heap/Handle.h', | 61 'platform/heap/Handle.h', |
61 ]) | 62 ]) |
62 INTERFACE_CPP_INCLUDES = frozenset([ | 63 INTERFACE_CPP_INCLUDES = frozenset([ |
63 'bindings/core/v8/ExceptionState.h', | 64 'bindings/core/v8/ExceptionState.h', |
64 'bindings/core/v8/V8DOMConfiguration.h', | 65 'bindings/core/v8/V8DOMConfiguration.h', |
65 'bindings/core/v8/V8ObjectConstructor.h', | 66 'bindings/core/v8/V8ObjectConstructor.h', |
66 'core/dom/ContextFeatures.h', | 67 'core/dom/ContextFeatures.h', |
67 'core/dom/Document.h', | 68 'core/dom/Document.h', |
69 'core/experiments/Experiments.h', | |
haraken
2015/12/16 02:16:41
I feel that "Experiments" sounds a bit too general
Daniel Nishi
2015/12/16 21:42:02
core/experiments/* is already landed by a differen
| |
68 'platform/RuntimeEnabledFeatures.h', | 70 'platform/RuntimeEnabledFeatures.h', |
69 'platform/TraceEvent.h', | 71 'platform/TraceEvent.h', |
70 'wtf/GetPtr.h', | 72 'wtf/GetPtr.h', |
71 'wtf/RefPtr.h', | 73 'wtf/RefPtr.h', |
72 ]) | 74 ]) |
73 | 75 |
74 | 76 |
75 def interface_context(interface): | 77 def interface_context(interface): |
76 includes.clear() | 78 includes.clear() |
77 includes.update(INTERFACE_CPP_INCLUDES) | 79 includes.update(INTERFACE_CPP_INCLUDES) |
(...skipping 82 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
160 v8_class_name = v8_utilities.v8_class_name(interface) | 162 v8_class_name = v8_utilities.v8_class_name(interface) |
161 cpp_class_name = cpp_name(interface) | 163 cpp_class_name = cpp_name(interface) |
162 cpp_class_name_or_partial = cpp_name_or_partial(interface) | 164 cpp_class_name_or_partial = cpp_name_or_partial(interface) |
163 v8_class_name_or_partial = v8_utilities.v8_class_name_or_partial(interface) | 165 v8_class_name_or_partial = v8_utilities.v8_class_name_or_partial(interface) |
164 | 166 |
165 context = { | 167 context = { |
166 'conditional_string': conditional_string(interface), # [Conditional] | 168 'conditional_string': conditional_string(interface), # [Conditional] |
167 'cpp_class': cpp_class_name, | 169 'cpp_class': cpp_class_name, |
168 'cpp_class_or_partial': cpp_class_name_or_partial, | 170 'cpp_class_or_partial': cpp_class_name_or_partial, |
169 'event_target_inheritance': 'InheritFromEventTarget' if is_event_target else 'NotInheritFromEventTarget', | 171 'event_target_inheritance': 'InheritFromEventTarget' if is_event_target else 'NotInheritFromEventTarget', |
172 'experimental_api_name': v8_utilities.experimental_api_name(interface), | |
170 'gc_type': this_gc_type, | 173 'gc_type': this_gc_type, |
171 # FIXME: Remove 'EventTarget' special handling, http://crbug.com/383699 | 174 # FIXME: Remove 'EventTarget' special handling, http://crbug.com/383699 |
172 'has_access_check_callbacks': (is_check_security and | 175 'has_access_check_callbacks': (is_check_security and |
173 interface.name != 'Window' and | 176 interface.name != 'Window' and |
174 interface.name != 'EventTarget'), | 177 interface.name != 'EventTarget'), |
175 'has_custom_legacy_call_as_function': has_extended_attribute_value(inter face, 'Custom', 'LegacyCallAsFunction'), # [Custom=LegacyCallAsFunction] | 178 'has_custom_legacy_call_as_function': has_extended_attribute_value(inter face, 'Custom', 'LegacyCallAsFunction'), # [Custom=LegacyCallAsFunction] |
176 'has_partial_interface': len(interface.partial_interfaces) > 0, | 179 'has_partial_interface': len(interface.partial_interfaces) > 0, |
177 'has_visit_dom_wrapper': has_visit_dom_wrapper, | 180 'has_visit_dom_wrapper': has_visit_dom_wrapper, |
178 'header_includes': header_includes, | 181 'header_includes': header_includes, |
179 'interface_name': interface.name, | 182 'interface_name': interface.name, |
(...skipping 52 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
232 includes.add('bindings/core/v8/V8ObjectConstructor.h') | 235 includes.add('bindings/core/v8/V8ObjectConstructor.h') |
233 includes.add('core/frame/LocalDOMWindow.h') | 236 includes.add('core/frame/LocalDOMWindow.h') |
234 elif 'Measure' in extended_attributes or 'MeasureAs' in extended_attributes: | 237 elif 'Measure' in extended_attributes or 'MeasureAs' in extended_attributes: |
235 raise Exception('[Measure] or [MeasureAs] specified for interface withou t a constructor: ' | 238 raise Exception('[Measure] or [MeasureAs] specified for interface withou t a constructor: ' |
236 '%s' % interface.name) | 239 '%s' % interface.name) |
237 | 240 |
238 # [Unscopeable] attributes and methods | 241 # [Unscopeable] attributes and methods |
239 unscopeables = [] | 242 unscopeables = [] |
240 for attribute in interface.attributes: | 243 for attribute in interface.attributes: |
241 if 'Unscopeable' in attribute.extended_attributes: | 244 if 'Unscopeable' in attribute.extended_attributes: |
242 unscopeables.append((attribute.name, v8_utilities.runtime_enabled_fu nction_name(attribute))) | 245 unscopeables.append((attribute.name, v8_utilities.runtime_enabled_fu nction_name(attribute), v8_utilities.experimental_api_name(attribute))) |
243 for method in interface.operations: | 246 for method in interface.operations: |
244 if 'Unscopeable' in method.extended_attributes: | 247 if 'Unscopeable' in method.extended_attributes: |
245 unscopeables.append((method.name, v8_utilities.runtime_enabled_funct ion_name(method))) | 248 unscopeables.append((method.name, v8_utilities.runtime_enabled_funct ion_name(method), v8_utilities.experimental_api_name(method))) |
246 | 249 |
247 context.update({ | 250 context.update({ |
248 'constructors': constructors, | 251 'constructors': constructors, |
249 'has_custom_constructor': bool(custom_constructors), | 252 'has_custom_constructor': bool(custom_constructors), |
250 'interface_length': | 253 'interface_length': |
251 interface_length(interface, constructors + custom_constructors), | 254 interface_length(interface, constructors + custom_constructors), |
252 'is_constructor_raises_exception': extended_attributes.get('RaisesExcept ion') == 'Constructor', # [RaisesException=Constructor] | 255 'is_constructor_raises_exception': extended_attributes.get('RaisesExcept ion') == 'Constructor', # [RaisesException=Constructor] |
253 'named_constructor': named_constructor, | 256 'named_constructor': named_constructor, |
254 'unscopeables': sorted(unscopeables), | 257 'unscopeables': sorted(unscopeables), |
255 }) | 258 }) |
256 | 259 |
257 constants = [constant_context(constant, interface) for constant in interface .constants] | 260 constants = [constant_context(constant, interface) for constant in interface .constants] |
258 | 261 |
259 special_getter_constants = [] | 262 special_getter_constants = [] |
260 runtime_enabled_constants = dict() | 263 runtime_enabled_constants = dict() |
264 experimental_enabled_constants = dict() | |
265 experimental_only_enabled_constants = [] | |
261 constant_configuration_constants = [] | 266 constant_configuration_constants = [] |
262 | 267 |
263 for constant in constants: | 268 for constant in constants: |
269 experimental_api_name = constant['experimental_api_name'] | |
264 if constant['measure_as'] or constant['deprecate_as']: | 270 if constant['measure_as'] or constant['deprecate_as']: |
265 special_getter_constants.append(constant) | 271 special_getter_constants.append(constant) |
266 continue | 272 continue |
267 runtime_enabled_function = constant['runtime_enabled_function'] | 273 runtime_enabled_function = constant['runtime_enabled_function'] |
268 if runtime_enabled_function: | 274 if runtime_enabled_function: |
269 if runtime_enabled_function not in runtime_enabled_constants: | 275 if runtime_enabled_function not in runtime_enabled_constants: |
270 runtime_enabled_constants[runtime_enabled_function] = [] | 276 runtime_enabled_constants[runtime_enabled_function] = [] |
271 runtime_enabled_constants[runtime_enabled_function].append(constant) | 277 runtime_enabled_constants[runtime_enabled_function].append(constant) |
278 if experimental_api_name: | |
279 experimental_enabled_constants[constant['name']] = experimental_ api_name | |
280 continue | |
281 if experimental_api_name: | |
282 experimental_only_enabled_constants.append(constant) | |
272 continue | 283 continue |
273 constant_configuration_constants.append(constant) | 284 constant_configuration_constants.append(constant) |
274 | 285 |
275 # Constants | 286 # Constants |
276 context.update({ | 287 context.update({ |
277 'constant_configuration_constants': constant_configuration_constants, | 288 'constant_configuration_constants': constant_configuration_constants, |
278 'constants': constants, | 289 'constants': constants, |
279 'do_not_check_constants': 'DoNotCheckConstants' in extended_attributes, | 290 'do_not_check_constants': 'DoNotCheckConstants' in extended_attributes, |
291 'experimental_enabled_constants': experimental_enabled_constants, | |
292 'experimental_only_constants': experimental_only_enabled_constants, | |
280 'has_constant_configuration': any( | 293 'has_constant_configuration': any( |
281 not constant['runtime_enabled_function'] | 294 (constant['runtime_enabled_function'] is None and constant['experime ntal_api_name'] is None) |
282 for constant in constants), | 295 for constant in constants), |
283 'runtime_enabled_constants': sorted(runtime_enabled_constants.iteritems( )), | 296 'runtime_enabled_constants': sorted(runtime_enabled_constants.iteritems( )), |
284 'special_getter_constants': special_getter_constants, | 297 'special_getter_constants': special_getter_constants, |
285 }) | 298 }) |
286 | 299 |
287 # Attributes | 300 # Attributes |
288 attributes = [v8_attributes.attribute_context(interface, attribute) | 301 attributes = [v8_attributes.attribute_context(interface, attribute) |
289 for attribute in interface.attributes] | 302 for attribute in interface.attributes] |
290 | 303 |
291 has_conditional_attributes = any(attribute['exposed_test'] for attribute in attributes) | 304 has_conditional_attributes = any(attribute['exposed_test'] for attribute in attributes) |
(...skipping 224 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
516 | 529 |
517 if 'overloads' in method: | 530 if 'overloads' in method: |
518 overloads = method['overloads'] | 531 overloads = method['overloads'] |
519 if not overloads['visible']: | 532 if not overloads['visible']: |
520 continue | 533 continue |
521 # original interface will register instead of partial interface. | 534 # original interface will register instead of partial interface. |
522 if overloads['has_partial_overloads'] and interface.is_partial: | 535 if overloads['has_partial_overloads'] and interface.is_partial: |
523 continue | 536 continue |
524 conditionally_exposed_function = overloads['exposed_test_all'] | 537 conditionally_exposed_function = overloads['exposed_test_all'] |
525 runtime_enabled_function = overloads['runtime_enabled_function_all'] | 538 runtime_enabled_function = overloads['runtime_enabled_function_all'] |
539 experimental_api_name = overloads['experimental_api_name_all'] | |
526 has_custom_registration = (overloads['has_custom_registration_all'] or | 540 has_custom_registration = (overloads['has_custom_registration_all'] or |
527 overloads['runtime_determined_lengths']) | 541 overloads['runtime_determined_lengths']) |
528 else: | 542 else: |
529 if not method['visible']: | 543 if not method['visible']: |
530 continue | 544 continue |
531 conditionally_exposed_function = method['exposed_test'] | 545 conditionally_exposed_function = method['exposed_test'] |
532 runtime_enabled_function = method['runtime_enabled_function'] | 546 runtime_enabled_function = method['runtime_enabled_function'] |
547 experimental_api_name = method['experimental_api_name'] | |
533 has_custom_registration = method['has_custom_registration'] | 548 has_custom_registration = method['has_custom_registration'] |
534 | 549 |
535 if has_custom_registration: | 550 if has_custom_registration: |
536 custom_registration_methods.append(method) | 551 custom_registration_methods.append(method) |
537 continue | 552 continue |
538 if conditionally_exposed_function: | 553 if conditionally_exposed_function: |
539 conditionally_enabled_methods.append(method) | 554 conditionally_enabled_methods.append(method) |
540 continue | 555 continue |
541 if runtime_enabled_function: | 556 if runtime_enabled_function: |
542 custom_registration_methods.append(method) | 557 custom_registration_methods.append(method) |
543 continue | 558 continue |
559 if experimental_api_name: | |
560 custom_registration_methods.append(method) | |
561 continue | |
544 if method['should_be_exposed_to_script']: | 562 if method['should_be_exposed_to_script']: |
545 method_configuration_methods.append(method) | 563 method_configuration_methods.append(method) |
546 | 564 |
547 for method in methods: | 565 for method in methods: |
548 # The value of the Function object’s “length” property is a Number | 566 # The value of the Function object’s “length” property is a Number |
549 # determined as follows: | 567 # determined as follows: |
550 # 1. Let S be the effective overload set for regular operations (if the | 568 # 1. Let S be the effective overload set for regular operations (if the |
551 # operation is a regular operation) or for static operations (if the | 569 # operation is a regular operation) or for static operations (if the |
552 # operation is a static operation) with identifier id on interface I and | 570 # operation is a static operation) with identifier id on interface I and |
553 # with argument count 0. | 571 # with argument count 0. |
(...skipping 54 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
608 extended_attributes = constant.extended_attributes | 626 extended_attributes = constant.extended_attributes |
609 return { | 627 return { |
610 'cpp_class': extended_attributes.get('PartialInterfaceImplementedAs'), | 628 'cpp_class': extended_attributes.get('PartialInterfaceImplementedAs'), |
611 'deprecate_as': v8_utilities.deprecate_as(constant), # [DeprecateAs] | 629 'deprecate_as': v8_utilities.deprecate_as(constant), # [DeprecateAs] |
612 'idl_type': constant.idl_type.name, | 630 'idl_type': constant.idl_type.name, |
613 'measure_as': v8_utilities.measure_as(constant, interface), # [MeasureA s] | 631 'measure_as': v8_utilities.measure_as(constant, interface), # [MeasureA s] |
614 'name': constant.name, | 632 'name': constant.name, |
615 # FIXME: use 'reflected_name' as correct 'name' | 633 # FIXME: use 'reflected_name' as correct 'name' |
616 'reflected_name': extended_attributes.get('Reflect', constant.name), | 634 'reflected_name': extended_attributes.get('Reflect', constant.name), |
617 'runtime_enabled_function': runtime_enabled_function_name(constant), | 635 'runtime_enabled_function': runtime_enabled_function_name(constant), |
636 'experimental_api_name': extended_attributes.get('ExperimentEnabled'), | |
618 'value': constant.value, | 637 'value': constant.value, |
619 } | 638 } |
620 | 639 |
621 | 640 |
622 ################################################################################ | 641 ################################################################################ |
623 # Overloads | 642 # Overloads |
624 ################################################################################ | 643 ################################################################################ |
625 | 644 |
626 def compute_method_overloads_context(interface, methods): | 645 def compute_method_overloads_context(interface, methods): |
627 # Regular methods | 646 # Regular methods |
(...skipping 134 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
762 has_overload_not_visible = True | 781 has_overload_not_visible = True |
763 | 782 |
764 # If some overloads are not visible and others are visible, | 783 # If some overloads are not visible and others are visible, |
765 # the method is overloaded between core and modules. | 784 # the method is overloaded between core and modules. |
766 has_partial_overloads = has_overload_visible and has_overload_not_visible | 785 has_partial_overloads = has_overload_visible and has_overload_not_visible |
767 | 786 |
768 return { | 787 return { |
769 'deprecate_all_as': common_value(overloads, 'deprecate_as'), # [Depreca teAs] | 788 'deprecate_all_as': common_value(overloads, 'deprecate_as'), # [Depreca teAs] |
770 'exposed_test_all': common_value(overloads, 'exposed_test'), # [Exposed ] | 789 'exposed_test_all': common_value(overloads, 'exposed_test'), # [Exposed ] |
771 'has_custom_registration_all': common_value(overloads, 'has_custom_regis tration'), | 790 'has_custom_registration_all': common_value(overloads, 'has_custom_regis tration'), |
791 'experimental_api_name_all': common_value(overloads, 'experimental_api_n ame'), # [ExperimentEnabled] | |
772 'length': function_length, | 792 'length': function_length, |
773 'length_tests_methods': length_tests_methods(effective_overloads_by_leng th), | 793 'length_tests_methods': length_tests_methods(effective_overloads_by_leng th), |
774 # 1. Let maxarg be the length of the longest type list of the | 794 # 1. Let maxarg be the length of the longest type list of the |
775 # entries in S. | 795 # entries in S. |
776 'maxarg': maxarg, | 796 'maxarg': maxarg, |
777 'measure_all_as': common_value(overloads, 'measure_as'), # [MeasureAs] | 797 'measure_all_as': common_value(overloads, 'measure_as'), # [MeasureAs] |
778 'returns_promise_all': promise_overload_count > 0, | 798 'returns_promise_all': promise_overload_count > 0, |
779 'runtime_determined_lengths': runtime_determined_lengths, | 799 'runtime_determined_lengths': runtime_determined_lengths, |
780 'runtime_determined_maxargs': runtime_determined_maxargs, | 800 'runtime_determined_maxargs': runtime_determined_maxargs, |
781 'runtime_enabled_function_all': common_value(overloads, 'runtime_enabled _function'), # [RuntimeEnabled] | 801 'runtime_enabled_function_all': common_value(overloads, 'runtime_enabled _function'), # [RuntimeEnabled] |
(...skipping 603 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1385 | 1405 |
1386 extended_attributes = deleter.extended_attributes | 1406 extended_attributes = deleter.extended_attributes |
1387 idl_type = deleter.idl_type | 1407 idl_type = deleter.idl_type |
1388 is_call_with_script_state = v8_utilities.has_extended_attribute_value(delete r, 'CallWith', 'ScriptState') | 1408 is_call_with_script_state = v8_utilities.has_extended_attribute_value(delete r, 'CallWith', 'ScriptState') |
1389 return { | 1409 return { |
1390 'is_call_with_script_state': is_call_with_script_state, | 1410 'is_call_with_script_state': is_call_with_script_state, |
1391 'is_custom': 'Custom' in extended_attributes, | 1411 'is_custom': 'Custom' in extended_attributes, |
1392 'is_raises_exception': 'RaisesException' in extended_attributes, | 1412 'is_raises_exception': 'RaisesException' in extended_attributes, |
1393 'name': cpp_name(deleter), | 1413 'name': cpp_name(deleter), |
1394 } | 1414 } |
OLD | NEW |