Commit 9aa18b4e authored by peria's avatar peria Committed by Commit bot

Refactoring of binding code around runtime enabled features

It didn't make sense to use 'runtime_enabled_function_name'
to group runtime enabled features.
Plus, 'runtime_feature_name' was also used in few places. It
was so confusing.

So this CL unify them to use feature names to group contexts
and remove runtime_enabled_function_name() function.
This CL does not change generated code.

BUG=None

Review-Url: https://codereview.chromium.org/2578943002
Cr-Commit-Position: refs/heads/master@{#439088}
parent a9d34736
...@@ -16,6 +16,7 @@ from v8_globals import includes ...@@ -16,6 +16,7 @@ from v8_globals import includes
from v8_interface import constant_filters from v8_interface import constant_filters
from v8_types import set_component_dirs from v8_types import set_component_dirs
from v8_methods import method_filters from v8_methods import method_filters
import v8_utilities
from v8_utilities import capitalize, unique_by from v8_utilities import capitalize, unique_by
from utilities import (idl_filename_to_component, is_valid_component_dependency, from utilities import (idl_filename_to_component, is_valid_component_dependency,
format_remove_duplicates, format_blink_cpp_source_code) format_remove_duplicates, format_blink_cpp_source_code)
...@@ -64,10 +65,12 @@ def secure_context_if(code, secure_context_test): ...@@ -64,10 +65,12 @@ def secure_context_if(code, secure_context_test):
# [RuntimeEnabled] # [RuntimeEnabled]
def runtime_enabled_if(code, runtime_enabled_function_name): def runtime_enabled_if(code, name):
if not runtime_enabled_function_name: if not name:
return code return code
return generate_indented_conditional(code, '%s()' % runtime_enabled_function_name)
function = 'RuntimeEnabledFeatures::%sEnabled()' % v8_utilities.uncapitalize(name)
return generate_indented_conditional(code, function)
def initialize_jinja_env(cache_dir): def initialize_jinja_env(cache_dir):
......
...@@ -180,8 +180,7 @@ def attribute_context(interface, attribute, interfaces): ...@@ -180,8 +180,7 @@ def attribute_context(interface, attribute, interfaces):
'reflect_invalid': extended_attributes.get('ReflectInvalid', ''), 'reflect_invalid': extended_attributes.get('ReflectInvalid', ''),
'reflect_missing': extended_attributes.get('ReflectMissing'), 'reflect_missing': extended_attributes.get('ReflectMissing'),
'reflect_only': extended_attribute_value_as_list(attribute, 'ReflectOnly'), 'reflect_only': extended_attribute_value_as_list(attribute, 'ReflectOnly'),
'runtime_enabled_function': v8_utilities.runtime_enabled_function_name(attribute), # [RuntimeEnabled] 'runtime_enabled_feature_name': v8_utilities.runtime_enabled_feature_name(attribute), # [RuntimeEnabled]
'runtime_feature_name': v8_utilities.runtime_feature_name(attribute), # [RuntimeEnabled]
'secure_context_test': v8_utilities.secure_context(attribute, interface), # [SecureContext] 'secure_context_test': v8_utilities.secure_context(attribute, interface), # [SecureContext]
'cached_accessor_name': '%s%sCachedAccessor' % (interface.name, attribute.name.capitalize()), 'cached_accessor_name': '%s%sCachedAccessor' % (interface.name, attribute.name.capitalize()),
'world_suffixes': ( 'world_suffixes': (
...@@ -217,7 +216,7 @@ def filter_accessors(attributes): ...@@ -217,7 +216,7 @@ def filter_accessors(attributes):
not (attribute['exposed_test'] or not (attribute['exposed_test'] or
attribute['secure_context_test'] or attribute['secure_context_test'] or
attribute['origin_trial_enabled_function'] or attribute['origin_trial_enabled_function'] or
attribute['runtime_enabled_function']) and attribute['runtime_enabled_feature_name']) and
not attribute['is_data_type_property']] not attribute['is_data_type_property']]
...@@ -225,7 +224,7 @@ def is_data_attribute(attribute): ...@@ -225,7 +224,7 @@ def is_data_attribute(attribute):
return (not (attribute['exposed_test'] or return (not (attribute['exposed_test'] or
attribute['secure_context_test'] or attribute['secure_context_test'] or
attribute['origin_trial_enabled_function'] or attribute['origin_trial_enabled_function'] or
attribute['runtime_enabled_function']) and attribute['runtime_enabled_feature_name']) and
attribute['is_data_type_property']) attribute['is_data_type_property'])
...@@ -251,7 +250,7 @@ def filter_runtime_enabled(attributes): ...@@ -251,7 +250,7 @@ def filter_runtime_enabled(attributes):
return [attribute for attribute in attributes if return [attribute for attribute in attributes if
not (attribute['exposed_test'] or not (attribute['exposed_test'] or
attribute['secure_context_test']) and attribute['secure_context_test']) and
attribute['runtime_feature_name']] attribute['runtime_enabled_feature_name']]
################################################################################ ################################################################################
......
...@@ -63,7 +63,7 @@ def dictionary_context(dictionary, interfaces_info): ...@@ -63,7 +63,7 @@ def dictionary_context(dictionary, interfaces_info):
key=operator.attrgetter('name'))] key=operator.attrgetter('name'))]
for member in members: for member in members:
if member['runtime_enabled_function']: if member['runtime_enabled_feature_name']:
includes.add('platform/RuntimeEnabledFeatures.h') includes.add('platform/RuntimeEnabledFeatures.h')
break break
...@@ -134,7 +134,7 @@ def member_context(dictionary, member): ...@@ -134,7 +134,7 @@ def member_context(dictionary, member):
'is_object': unwrapped_idl_type.name == 'Object' or is_deprecated_dictionary, 'is_object': unwrapped_idl_type.name == 'Object' or is_deprecated_dictionary,
'is_required': member.is_required, 'is_required': member.is_required,
'name': member.name, 'name': member.name,
'runtime_enabled_function': v8_utilities.runtime_enabled_function_name(member), # [RuntimeEnabled] 'runtime_enabled_feature_name': v8_utilities.runtime_enabled_feature_name(member), # [RuntimeEnabled]
'setter_name': setter_name_for_dictionary_member(member), 'setter_name': setter_name_for_dictionary_member(member),
'null_setter_name': null_setter_name_for_dictionary_member(member), 'null_setter_name': null_setter_name_for_dictionary_member(member),
'v8_default_value': v8_default_value, 'v8_default_value': v8_default_value,
......
...@@ -46,7 +46,7 @@ import v8_methods ...@@ -46,7 +46,7 @@ import v8_methods
import v8_types import v8_types
import v8_utilities import v8_utilities
from v8_utilities import (cpp_name_or_partial, cpp_name, has_extended_attribute_value, from v8_utilities import (cpp_name_or_partial, cpp_name, has_extended_attribute_value,
runtime_enabled_function_name, is_legacy_interface_type_checking) runtime_enabled_feature_name, is_legacy_interface_type_checking)
INTERFACE_H_INCLUDES = frozenset([ INTERFACE_H_INCLUDES = frozenset([
...@@ -72,7 +72,7 @@ def filter_has_constant_configuration(constants): ...@@ -72,7 +72,7 @@ def filter_has_constant_configuration(constants):
return [constant for constant in constants if return [constant for constant in constants if
not constant['measure_as'] and not constant['measure_as'] and
not constant['deprecate_as'] and not constant['deprecate_as'] and
not constant['runtime_enabled_function'] and not constant['runtime_enabled_feature_name'] and
not constant['origin_trial_feature_name']] not constant['origin_trial_feature_name']]
...@@ -84,7 +84,7 @@ def filter_has_special_getter(constants): ...@@ -84,7 +84,7 @@ def filter_has_special_getter(constants):
def filter_runtime_enabled(constants): def filter_runtime_enabled(constants):
return [constant for constant in constants if return [constant for constant in constants if
constant['runtime_enabled_function']] constant['runtime_enabled_feature_name']]
def filter_origin_trial_enabled(constants): def filter_origin_trial_enabled(constants):
...@@ -283,7 +283,7 @@ def interface_context(interface, interfaces): ...@@ -283,7 +283,7 @@ def interface_context(interface, interfaces):
'parent_interface': parent_interface, 'parent_interface': parent_interface,
'pass_cpp_type': cpp_name(interface) + '*', 'pass_cpp_type': cpp_name(interface) + '*',
'active_scriptwrappable': active_scriptwrappable, 'active_scriptwrappable': active_scriptwrappable,
'runtime_enabled_function': runtime_enabled_function_name(interface), # [RuntimeEnabled] 'runtime_enabled_feature_name': runtime_enabled_feature_name(interface), # [RuntimeEnabled]
'set_wrapper_reference_from': set_wrapper_reference_from, 'set_wrapper_reference_from': set_wrapper_reference_from,
'set_wrapper_reference_to': set_wrapper_reference_to, 'set_wrapper_reference_to': set_wrapper_reference_to,
'v8_class': v8_class_name, 'v8_class': v8_class_name,
...@@ -337,10 +337,10 @@ def interface_context(interface, interfaces): ...@@ -337,10 +337,10 @@ def interface_context(interface, interfaces):
unscopables = [] unscopables = []
for attribute in interface.attributes: for attribute in interface.attributes:
if 'Unscopable' in attribute.extended_attributes: if 'Unscopable' in attribute.extended_attributes:
unscopables.append((attribute.name, v8_utilities.runtime_enabled_function_name(attribute))) unscopables.append((attribute.name, runtime_enabled_feature_name(attribute)))
for method in interface.operations: for method in interface.operations:
if 'Unscopable' in method.extended_attributes: if 'Unscopable' in method.extended_attributes:
unscopables.append((method.name, v8_utilities.runtime_enabled_function_name(method))) unscopables.append((method.name, runtime_enabled_feature_name(method)))
# [CEReactions] # [CEReactions]
setter_or_deleters = ( setter_or_deleters = (
...@@ -721,8 +721,7 @@ def constant_context(constant, interface): ...@@ -721,8 +721,7 @@ def constant_context(constant, interface):
'origin_trial_feature_name': v8_utilities.origin_trial_feature_name(constant), # [OriginTrialEnabled] 'origin_trial_feature_name': v8_utilities.origin_trial_feature_name(constant), # [OriginTrialEnabled]
# FIXME: use 'reflected_name' as correct 'name' # FIXME: use 'reflected_name' as correct 'name'
'reflected_name': extended_attributes.get('Reflect', reflected_name(constant.name)), 'reflected_name': extended_attributes.get('Reflect', reflected_name(constant.name)),
'runtime_enabled_function': runtime_enabled_function_name(constant), # [RuntimeEnabled] 'runtime_enabled_feature_name': runtime_enabled_feature_name(constant), # [RuntimeEnabled]
'runtime_feature_name': v8_utilities.runtime_feature_name(constant), # [RuntimeEnabled]
'value': constant.value, 'value': constant.value,
} }
...@@ -800,26 +799,26 @@ def overloads_context(interface, overloads): ...@@ -800,26 +799,26 @@ def overloads_context(interface, overloads):
# The special case handling below is not needed if all overloads are # The special case handling below is not needed if all overloads are
# runtime enabled by the same feature. # runtime enabled by the same feature.
if not common_value(overloads, 'runtime_enabled_function'): if not common_value(overloads, 'runtime_enabled_feature_name'):
# Check if all overloads with the shortest acceptable arguments list are # Check if all overloads with the shortest acceptable arguments list are
# runtime enabled, in which case we need to have a runtime determined # runtime enabled, in which case we need to have a runtime determined
# Function.length. # Function.length.
shortest_overloads = effective_overloads_by_length[0][1] shortest_overloads = effective_overloads_by_length[0][1]
if (all(method.get('runtime_enabled_function') if (all(method.get('runtime_enabled_feature_name')
for method, _, _ in shortest_overloads)): for method, _, _ in shortest_overloads)):
# Generate a list of (length, runtime_enabled_functions) tuples. # Generate a list of (length, runtime_enabled_feature_names) tuples.
runtime_determined_lengths = [] runtime_determined_lengths = []
for length, effective_overloads in effective_overloads_by_length: for length, effective_overloads in effective_overloads_by_length:
runtime_enabled_functions = set( runtime_enabled_feature_names = set(
method['runtime_enabled_function'] method['runtime_enabled_feature_name']
for method, _, _ in effective_overloads for method, _, _ in effective_overloads
if method.get('runtime_enabled_function')) if method.get('runtime_enabled_feature_name'))
if not runtime_enabled_functions: if not runtime_enabled_feature_names:
# This "length" is unconditionally enabled, so stop here. # This "length" is unconditionally enabled, so stop here.
runtime_determined_lengths.append((length, [None])) runtime_determined_lengths.append((length, [None]))
break break
runtime_determined_lengths.append( runtime_determined_lengths.append(
(length, sorted(runtime_enabled_functions))) (length, sorted(runtime_enabled_feature_names)))
function_length = ('%sV8Internal::%sMethodLength()' function_length = ('%sV8Internal::%sMethodLength()'
% (cpp_name_or_partial(interface), name)) % (cpp_name_or_partial(interface), name))
...@@ -827,22 +826,22 @@ def overloads_context(interface, overloads): ...@@ -827,22 +826,22 @@ def overloads_context(interface, overloads):
# runtime enabled, in which case we need to have a runtime determined # runtime enabled, in which case we need to have a runtime determined
# maximum distinguishing argument index. # maximum distinguishing argument index.
longest_overloads = effective_overloads_by_length[-1][1] longest_overloads = effective_overloads_by_length[-1][1]
if (not common_value(overloads, 'runtime_enabled_function') and if (not common_value(overloads, 'runtime_enabled_feature_name') and
all(method.get('runtime_enabled_function') all(method.get('runtime_enabled_feature_name')
for method, _, _ in longest_overloads)): for method, _, _ in longest_overloads)):
# Generate a list of (length, runtime_enabled_functions) tuples. # Generate a list of (length, runtime_enabled_feature_name) tuples.
runtime_determined_maxargs = [] runtime_determined_maxargs = []
for length, effective_overloads in reversed(effective_overloads_by_length): for length, effective_overloads in reversed(effective_overloads_by_length):
runtime_enabled_functions = set( runtime_enabled_feature_names = set(
method['runtime_enabled_function'] method['runtime_enabled_feature_name']
for method, _, _ in effective_overloads for method, _, _ in effective_overloads
if method.get('runtime_enabled_function')) if method.get('runtime_enabled_feature_name'))
if not runtime_enabled_functions: if not runtime_enabled_feature_names:
# This "length" is unconditionally enabled, so stop here. # This "length" is unconditionally enabled, so stop here.
runtime_determined_maxargs.append((length, [None])) runtime_determined_maxargs.append((length, [None]))
break break
runtime_determined_maxargs.append( runtime_determined_maxargs.append(
(length, sorted(runtime_enabled_functions))) (length, sorted(runtime_enabled_feature_names)))
maxarg = ('%sV8Internal::%sMethodMaxArg()' maxarg = ('%sV8Internal::%sMethodMaxArg()'
% (cpp_name_or_partial(interface), name)) % (cpp_name_or_partial(interface), name))
...@@ -879,7 +878,7 @@ def overloads_context(interface, overloads): ...@@ -879,7 +878,7 @@ def overloads_context(interface, overloads):
'returns_promise_all': promise_overload_count > 0, 'returns_promise_all': promise_overload_count > 0,
'runtime_determined_lengths': runtime_determined_lengths, 'runtime_determined_lengths': runtime_determined_lengths,
'runtime_determined_maxargs': runtime_determined_maxargs, 'runtime_determined_maxargs': runtime_determined_maxargs,
'runtime_enabled_function_all': common_value(overloads, 'runtime_enabled_function'), # [RuntimeEnabled] 'runtime_enabled_all': common_value(overloads, 'runtime_enabled_feature_name'), # [RuntimeEnabled]
'secure_context_test_all': common_value(overloads, 'secure_context_test'), # [SecureContext] 'secure_context_test_all': common_value(overloads, 'secure_context_test'), # [SecureContext]
'valid_arities': (lengths 'valid_arities': (lengths
# Only need to report valid arities if there is a gap in the # Only need to report valid arities if there is a gap in the
......
...@@ -68,8 +68,8 @@ def custom_registration(method): ...@@ -68,8 +68,8 @@ def custom_registration(method):
return True return True
if 'overloads' in method: if 'overloads' in method:
return (method['overloads']['runtime_determined_lengths'] or return (method['overloads']['runtime_determined_lengths'] or
(method['overloads']['runtime_enabled_function_all'] and not conditionally_exposed(method))) (method['overloads']['runtime_enabled_all'] and not conditionally_exposed(method)))
return method['runtime_enabled_function'] and not conditionally_exposed(method) return method['runtime_enabled_feature_name'] and not conditionally_exposed(method)
def filter_custom_registration(methods, interface_is_partial): def filter_custom_registration(methods, interface_is_partial):
...@@ -215,7 +215,7 @@ def method_context(interface, method, is_visible=True): ...@@ -215,7 +215,7 @@ def method_context(interface, method, is_visible=True):
'origin_trial_feature_name': v8_utilities.origin_trial_feature_name(method), # [OriginTrialEnabled] 'origin_trial_feature_name': v8_utilities.origin_trial_feature_name(method), # [OriginTrialEnabled]
'property_attributes': property_attributes(interface, method), 'property_attributes': property_attributes(interface, method),
'returns_promise': method.returns_promise, 'returns_promise': method.returns_promise,
'runtime_enabled_function': v8_utilities.runtime_enabled_function_name(method), # [RuntimeEnabled] 'runtime_enabled_feature_name': v8_utilities.runtime_enabled_feature_name(method), # [RuntimeEnabled]
'secure_context_test': v8_utilities.secure_context(method, interface), # [SecureContext] 'secure_context_test': v8_utilities.secure_context(method, interface), # [SecureContext]
'use_output_parameter_for_result': idl_type.use_output_parameter_for_result, 'use_output_parameter_for_result': idl_type.use_output_parameter_for_result,
'use_local_result': use_local_result(method), 'use_local_result': use_local_result(method),
......
...@@ -427,31 +427,13 @@ def origin_trial_feature_name(definition_or_member): ...@@ -427,31 +427,13 @@ def origin_trial_feature_name(definition_or_member):
return extended_attributes.get('OriginTrialEnabled') or extended_attributes.get('FeaturePolicy') return extended_attributes.get('OriginTrialEnabled') or extended_attributes.get('FeaturePolicy')
def runtime_feature_name(definition_or_member): # [RuntimeEnabled]
def runtime_enabled_feature_name(definition_or_member):
extended_attributes = definition_or_member.extended_attributes extended_attributes = definition_or_member.extended_attributes
if 'RuntimeEnabled' not in extended_attributes: if 'RuntimeEnabled' not in extended_attributes:
return None return None
return extended_attributes['RuntimeEnabled']
# [RuntimeEnabled]
def runtime_enabled_function_name(definition_or_member):
"""Returns the name of the RuntimeEnabledFeatures function.
The returned function checks if a method/attribute is enabled.
Given extended attribute RuntimeEnabled=FeatureName, return:
RuntimeEnabledFeatures::{featureName}Enabled
If the RuntimeEnabled extended attribute is found, the includes
are also updated as a side-effect.
"""
feature_name = runtime_feature_name(definition_or_member)
if not feature_name:
return
includes.add('platform/RuntimeEnabledFeatures.h') includes.add('platform/RuntimeEnabledFeatures.h')
return 'RuntimeEnabledFeatures::%sEnabled' % uncapitalize(feature_name) return extended_attributes['RuntimeEnabled']
# [Unforgeable] # [Unforgeable]
......
...@@ -30,8 +30,8 @@ const V8DOMConfiguration::ConstantConfiguration {{v8_class}}Constants[] = { ...@@ -30,8 +30,8 @@ const V8DOMConfiguration::ConstantConfiguration {{v8_class}}Constants[] = {
V8DOMConfiguration::installConstants(isolate, interfaceTemplate, prototypeTemplate, {{v8_class}}Constants, WTF_ARRAY_LENGTH({{v8_class}}Constants)); V8DOMConfiguration::installConstants(isolate, interfaceTemplate, prototypeTemplate, {{v8_class}}Constants, WTF_ARRAY_LENGTH({{v8_class}}Constants));
{% endif %} {% endif %}
{# Runtime-enabled constants #} {# Runtime-enabled constants #}
{% for group in constants | runtime_enabled_constants | groupby('runtime_feature_name') %} {% for group in constants | runtime_enabled_constants | groupby('runtime_enabled_feature_name') %}
{% filter runtime_enabled(group.list[0].runtime_enabled_function) %} {% filter runtime_enabled(group.list[0].runtime_enabled_feature_name) %}
{% for constant in group.list %} {% for constant in group.list %}
{% set constant_name = constant.name.title().replace('_', '') %} {% set constant_name = constant.name.title().replace('_', '') %}
const V8DOMConfiguration::ConstantConfiguration constant{{constant_name}}Configuration = {{constant_configuration(constant)}}; const V8DOMConfiguration::ConstantConfiguration constant{{constant_name}}Configuration = {{constant_configuration(constant)}};
......
...@@ -44,7 +44,7 @@ void {{v8_class}}::toImpl(v8::Isolate* isolate, v8::Local<v8::Value> v8Value, {{ ...@@ -44,7 +44,7 @@ void {{v8_class}}::toImpl(v8::Isolate* isolate, v8::Local<v8::Value> v8Value, {{
} }
{% endif %} {% endif %}
{% for member in members %} {% for member in members %}
{% filter runtime_enabled(member.runtime_enabled_function) %} {% filter runtime_enabled(member.runtime_enabled_feature_name) %}
v8::Local<v8::Value> {{member.name}}Value; v8::Local<v8::Value> {{member.name}}Value;
if (!v8Object->Get(isolate->GetCurrentContext(), v8String(isolate, "{{member.name}}")).ToLocal(&{{member.name}}Value)) { if (!v8Object->Get(isolate->GetCurrentContext(), v8String(isolate, "{{member.name}}")).ToLocal(&{{member.name}}Value)) {
exceptionState.rethrowV8Exception(block.Exception()); exceptionState.rethrowV8Exception(block.Exception());
......
...@@ -917,8 +917,8 @@ if (v8CallBoolean(prototypeObject->HasOwnProperty(context, unscopablesSymbol))) ...@@ -917,8 +917,8 @@ if (v8CallBoolean(prototypeObject->HasOwnProperty(context, unscopablesSymbol)))
unscopables = prototypeObject->Get(context, unscopablesSymbol).ToLocalChecked().As<v8::Object>(); unscopables = prototypeObject->Get(context, unscopablesSymbol).ToLocalChecked().As<v8::Object>();
else else
unscopables = v8::Object::New(isolate); unscopables = v8::Object::New(isolate);
{% for name, runtime_enabled_function in unscopables %} {% for name, runtime_enabled_feature_name in unscopables %}
{% filter runtime_enabled(runtime_enabled_function) %} {% filter runtime_enabled(runtime_enabled_feature_name) %}
unscopables->CreateDataProperty(context, v8AtomicString(isolate, "{{name}}"), v8::True(isolate)).FromJust(); unscopables->CreateDataProperty(context, v8AtomicString(isolate, "{{name}}"), v8::True(isolate)).FromJust();
{% endfilter %} {% endfilter %}
{% endfor %} {% endfor %}
...@@ -934,7 +934,7 @@ v8::Local<v8::Signature> signature = v8::Signature::New(isolate, interfaceTempla ...@@ -934,7 +934,7 @@ v8::Local<v8::Signature> signature = v8::Signature::New(isolate, interfaceTempla
{% for attribute in attributes if (attribute.exposed_test or attribute.secure_context_test) and attribute.on_prototype %} {% for attribute in attributes if (attribute.exposed_test or attribute.secure_context_test) and attribute.on_prototype %}
{% filter exposed(attribute.exposed_test) %} {% filter exposed(attribute.exposed_test) %}
{% filter secure_context(attribute.secure_context_test) %} {% filter secure_context(attribute.secure_context_test) %}
{% filter runtime_enabled(attribute.runtime_enabled_function) %} {% filter runtime_enabled(attribute.runtime_enabled_feature_name) %}
const V8DOMConfiguration::AccessorConfiguration accessorConfiguration = {{attribute_configuration(attribute)}}; const V8DOMConfiguration::AccessorConfiguration accessorConfiguration = {{attribute_configuration(attribute)}};
V8DOMConfiguration::installAccessor(isolate, world, v8::Local<v8::Object>(), prototypeObject, interfaceObject, signature, accessorConfiguration); V8DOMConfiguration::installAccessor(isolate, world, v8::Local<v8::Object>(), prototypeObject, interfaceObject, signature, accessorConfiguration);
{% endfilter %}{# runtime_enabled #} {% endfilter %}{# runtime_enabled #}
......
...@@ -427,7 +427,7 @@ static void install{{v8_class}}Template(v8::Isolate* isolate, const DOMWrapperWo ...@@ -427,7 +427,7 @@ static void install{{v8_class}}Template(v8::Isolate* isolate, const DOMWrapperWo
{% endif %} {% endif %}
// Register DOM constants, attributes and operations. // Register DOM constants, attributes and operations.
{% filter runtime_enabled(runtime_enabled_function) %} {% filter runtime_enabled(runtime_enabled_feature_name) %}
{% if constants %} {% if constants %}
{{install_constants() | indent(2)}} {{install_constants() | indent(2)}}
{% endif %} {% endif %}
...@@ -454,18 +454,18 @@ static void install{{v8_class}}Template(v8::Isolate* isolate, const DOMWrapperWo ...@@ -454,18 +454,18 @@ static void install{{v8_class}}Template(v8::Isolate* isolate, const DOMWrapperWo
instanceTemplate->SetAccessCheckCallbackAndHandler({{cpp_class}}V8Internal::securityCheck, v8::NamedPropertyHandlerConfiguration({{cross_origin_named_getter}}, {{cross_origin_named_setter}}, nullptr, nullptr, {{cross_origin_named_enumerator}}), v8::IndexedPropertyHandlerConfiguration({{cross_origin_indexed_getter}}), v8::External::New(isolate, const_cast<WrapperTypeInfo*>(&{{v8_class}}::wrapperTypeInfo))); instanceTemplate->SetAccessCheckCallbackAndHandler({{cpp_class}}V8Internal::securityCheck, v8::NamedPropertyHandlerConfiguration({{cross_origin_named_getter}}, {{cross_origin_named_setter}}, nullptr, nullptr, {{cross_origin_named_enumerator}}), v8::IndexedPropertyHandlerConfiguration({{cross_origin_indexed_getter}}), v8::External::New(isolate, const_cast<WrapperTypeInfo*>(&{{v8_class}}::wrapperTypeInfo)));
{% endif %} {% endif %}
{% for group in runtime_enabled_attributes | groupby('runtime_feature_name') %} {% for group in runtime_enabled_attributes | groupby('runtime_enabled_feature_name') %}
if ({{group.list[0].runtime_enabled_function}}()) { {% filter runtime_enabled(group.list[0].runtime_enabled_feature_name) %}
{% for attribute in group.list | unique_by('name') | sort %} {% for attribute in group.list | unique_by('name') | sort %}
{% if attribute.is_data_type_property %} {% if attribute.is_data_type_property %}
const V8DOMConfiguration::AttributeConfiguration attribute{{attribute.name}}Configuration = {{attribute_configuration(attribute)}}; const V8DOMConfiguration::AttributeConfiguration attribute{{attribute.name}}Configuration = {{attribute_configuration(attribute)}};
V8DOMConfiguration::installAttribute(isolate, world, instanceTemplate, prototypeTemplate, attribute{{attribute.name}}Configuration); V8DOMConfiguration::installAttribute(isolate, world, instanceTemplate, prototypeTemplate, attribute{{attribute.name}}Configuration);
{% else %} {% else %}
const V8DOMConfiguration::AccessorConfiguration accessor{{attribute.name}}Configuration = {{attribute_configuration(attribute)}}; const V8DOMConfiguration::AccessorConfiguration accessor{{attribute.name}}Configuration = {{attribute_configuration(attribute)}};
V8DOMConfiguration::installAccessor(isolate, world, instanceTemplate, prototypeTemplate, interfaceTemplate, signature, accessor{{attribute.name}}Configuration); V8DOMConfiguration::installAccessor(isolate, world, instanceTemplate, prototypeTemplate, interfaceTemplate, signature, accessor{{attribute.name}}Configuration);
{% endif %} {% endif %}
{% endfor %} {% endfor %}
} {% endfilter %}
{% endfor %} {% endfor %}
{% if (indexed_property_getter or named_property_getter) and not is_partial %} {% if (indexed_property_getter or named_property_getter) and not is_partial %}
...@@ -484,7 +484,7 @@ static void install{{v8_class}}Template(v8::Isolate* isolate, const DOMWrapperWo ...@@ -484,7 +484,7 @@ static void install{{v8_class}}Template(v8::Isolate* isolate, const DOMWrapperWo
{% if iterator_method %} {% if iterator_method %}
{% filter exposed(iterator_method.exposed_test) %} {% filter exposed(iterator_method.exposed_test) %}
{% filter runtime_enabled(iterator_method.runtime_enabled_function) %} {% filter runtime_enabled(iterator_method.runtime_enabled_feature_name) %}
// Iterator (@@iterator) // Iterator (@@iterator)
const V8DOMConfiguration::SymbolKeyedMethodConfiguration symbolKeyedIteratorConfiguration = { v8::Symbol::GetIterator, {{cpp_class_or_partial}}V8Internal::iteratorMethodCallback, 0, v8::DontEnum, V8DOMConfiguration::OnPrototype }; const V8DOMConfiguration::SymbolKeyedMethodConfiguration symbolKeyedIteratorConfiguration = { v8::Symbol::GetIterator, {{cpp_class_or_partial}}V8Internal::iteratorMethodCallback, 0, v8::DontEnum, V8DOMConfiguration::OnPrototype };
V8DOMConfiguration::installMethod(isolate, world, prototypeTemplate, signature, symbolKeyedIteratorConfiguration); V8DOMConfiguration::installMethod(isolate, world, prototypeTemplate, signature, symbolKeyedIteratorConfiguration);
...@@ -508,8 +508,8 @@ static void install{{v8_class}}Template(v8::Isolate* isolate, const DOMWrapperWo ...@@ -508,8 +508,8 @@ static void install{{v8_class}}Template(v8::Isolate* isolate, const DOMWrapperWo
{# install_custom_signature #} {# install_custom_signature #}
{% filter exposed(method.overloads.exposed_test_all {% filter exposed(method.overloads.exposed_test_all
if method.overloads else method.exposed_test) %} if method.overloads else method.exposed_test) %}
{% filter runtime_enabled(method.overloads.runtime_enabled_function_all {% filter runtime_enabled(method.overloads.runtime_enabled_all
if method.overloads else method.runtime_enabled_function) %} if method.overloads else method.runtime_enabled_feature_name) %}
{% if method.is_cross_origin %} {% if method.is_cross_origin %}
{# TODO(dcheng): Currently, bindings must create a function object for each {# TODO(dcheng): Currently, bindings must create a function object for each
realm as a hack to support the incumbent realm. Remove this when Blink realm as a hack to support the incumbent realm. Remove this when Blink
......
...@@ -318,9 +318,9 @@ V8ThrowException::throwTypeError(info.GetIsolate(), ExceptionMessages::failedToE ...@@ -318,9 +318,9 @@ V8ThrowException::throwTypeError(info.GetIsolate(), ExceptionMessages::failedToE
{##############################################################################} {##############################################################################}
{% macro runtime_determined_length_method(overloads) %} {% macro runtime_determined_length_method(overloads) %}
static int {{overloads.name}}MethodLength() { static int {{overloads.name}}MethodLength() {
{% for length, runtime_enabled_functions in overloads.runtime_determined_lengths %} {% for length, runtime_enabled_features in overloads.runtime_determined_lengths %}
{% for runtime_enabled_function in runtime_enabled_functions %} {% for runtime_enabled_feature in runtime_enabled_features %}
{% filter runtime_enabled(runtime_enabled_function) %} {% filter runtime_enabled(runtime_enabled_feature) %}
return {{length}}; return {{length}};
{% endfilter %} {% endfilter %}
{% endfor %} {% endfor %}
...@@ -332,9 +332,9 @@ static int {{overloads.name}}MethodLength() { ...@@ -332,9 +332,9 @@ static int {{overloads.name}}MethodLength() {
{##############################################################################} {##############################################################################}
{% macro runtime_determined_maxarg_method(overloads) %} {% macro runtime_determined_maxarg_method(overloads) %}
static int {{overloads.name}}MethodMaxArg() { static int {{overloads.name}}MethodMaxArg() {
{% for length, runtime_enabled_functions in overloads.runtime_determined_maxargs %} {% for length, runtime_enabled_features in overloads.runtime_determined_maxargs %}
{% for runtime_enabled_function in runtime_enabled_functions %} {% for name in runtime_enabled_features %}
{% filter runtime_enabled(runtime_enabled_function) %} {% filter runtime_enabled(name) %}
return {{length}}; return {{length}};
{% endfilter %} {% endfilter %}
{% endfor %} {% endfor %}
...@@ -368,8 +368,7 @@ static void {{overloads.name}}Method{{world_suffix}}(const v8::FunctionCallbackI ...@@ -368,8 +368,7 @@ static void {{overloads.name}}Method{{world_suffix}}(const v8::FunctionCallbackI
{# Then resolve by testing argument #} {# Then resolve by testing argument #}
{% for test, method in tests_methods %} {% for test, method in tests_methods %}
{% if method.visible %} {% if method.visible %}
{% filter runtime_enabled(not overloads.runtime_enabled_function_all and {% filter runtime_enabled(not overloads.runtime_enabled_all and method.runtime_enabled_feature_name) %}
method.runtime_enabled_function) %}
if ({{test}}) { if ({{test}}) {
{% if method.measure_as and not overloads.measure_all_as %} {% if method.measure_as and not overloads.measure_all_as %}
UseCounter::count(currentExecutionContext(info.GetIsolate()), UseCounter::{{method.measure_as('Method')}}); UseCounter::count(currentExecutionContext(info.GetIsolate()), UseCounter::{{method.measure_as('Method')}});
...@@ -634,9 +633,9 @@ DCHECK(executionContext); ...@@ -634,9 +633,9 @@ DCHECK(executionContext);
{% filter exposed(method.overloads.exposed_test_all {% filter exposed(method.overloads.exposed_test_all
if method.overloads else if method.overloads else
method.exposed_test) %} method.exposed_test) %}
{% filter runtime_enabled(method.overloads.runtime_enabled_function_all {% filter runtime_enabled(method.overloads.runtime_enabled_all
if method.overloads else if method.overloads else
method.runtime_enabled_function) %} method.runtime_enabled_feature_name) %}
const V8DOMConfiguration::MethodConfiguration {{method.name}}MethodConfiguration = {{method_configuration(method)}}; const V8DOMConfiguration::MethodConfiguration {{method.name}}MethodConfiguration = {{method_configuration(method)}};
V8DOMConfiguration::installMethod(isolate, world, v8::Local<v8::Object>(), prototypeObject, interfaceObject, signature, {{method.name}}MethodConfiguration); V8DOMConfiguration::installMethod(isolate, world, v8::Local<v8::Object>(), prototypeObject, interfaceObject, signature, {{method.name}}MethodConfiguration);
{% endfilter %}{# runtime_enabled() #} {% endfilter %}{# runtime_enabled() #}
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment