def attribute_context(interface, attribute, interfaces): """Creates a Jinja template context for an attribute of an interface. Args: interface: An interface which |attribute| belongs to attribute: An attribute to create the context for interfaces: A dict which maps an interface name to the definition which can be referred if needed Returns: A Jinja template context for |attribute| """ idl_type = attribute.idl_type base_idl_type = idl_type.base_type extended_attributes = attribute.extended_attributes idl_type.add_includes_for_type(extended_attributes) if idl_type.enum_values: includes.add('core/inspector/console_message.h') # [CheckSecurity] is_cross_origin = 'CrossOrigin' in extended_attributes is_check_security_for_receiver = (has_extended_attribute_value( interface, 'CheckSecurity', 'Receiver') and is_cross_origin) is_check_security_for_return_value = (has_extended_attribute_value( attribute, 'CheckSecurity', 'ReturnValue')) if is_check_security_for_receiver or is_check_security_for_return_value: includes.add('bindings/core/v8/binding_security.h') if is_check_security_for_return_value: includes.add('core/frame/use_counter.h') # [CrossOrigin] if has_extended_attribute_value(attribute, 'CrossOrigin', 'Setter'): includes.add('bindings/core/v8/v8_cross_origin_setter_info.h') # [Constructor] # TODO(yukishiino): Constructors are much like methods although constructors # are not methods. Constructors must be data-type properties, and we can # support them as a kind of methods. constructor_type = idl_type.constructor_type_name if is_constructor_attribute( attribute) else None # [CEReactions] is_ce_reactions = 'CEReactions' in extended_attributes if is_ce_reactions: includes.add('core/html/custom/ce_reactions_scope.h') # [CustomElementCallbacks], [Reflect] is_custom_element_callbacks = 'CustomElementCallbacks' in extended_attributes is_reflect = 'Reflect' in extended_attributes if is_custom_element_callbacks or is_reflect: includes.add('core/html/custom/v0_custom_element_processing_stack.h') # [PerWorldBindings] if 'PerWorldBindings' in extended_attributes: assert idl_type.is_wrapper_type or 'LogActivity' in extended_attributes, '[PerWorldBindings] should only be used with wrapper types: %s.%s' % ( interface.name, attribute.name) # [SaveSameObject] is_save_same_object = ('SameObject' in attribute.extended_attributes and 'SaveSameObject' in attribute.extended_attributes) if is_save_same_object: includes.add('platform/bindings/v8_private_property.h') if (base_idl_type == 'EventHandler' and interface.name in ['Window', 'WorkerGlobalScope'] and attribute.name == 'onerror'): includes.add('bindings/core/v8/v8_error_handler.h') cached_attribute_validation_method = extended_attributes.get( 'CachedAttribute') keep_alive_for_gc = is_keep_alive_for_gc(interface, attribute) if cached_attribute_validation_method or keep_alive_for_gc: includes.add('platform/bindings/v8_private_property.h') # [CachedAccessor] is_cached_accessor = 'CachedAccessor' in extended_attributes if is_cached_accessor: includes.add('platform/bindings/v8_private_property.h') context = { 'activity_logging_world_list_for_getter': v8_utilities.activity_logging_world_list(attribute, 'Getter'), # [ActivityLogging] 'activity_logging_world_list_for_setter': v8_utilities.activity_logging_world_list(attribute, 'Setter'), # [ActivityLogging] 'activity_logging_world_check': v8_utilities.activity_logging_world_check(attribute), # [ActivityLogging] 'cached_attribute_validation_method': cached_attribute_validation_method, 'constructor_type': constructor_type, 'context_enabled_feature_name': v8_utilities.context_enabled_feature_name(attribute), 'cpp_name': cpp_name(attribute), 'cpp_type': idl_type.cpp_type, 'cpp_type_initializer': idl_type.cpp_type_initializer, 'deprecate_as': v8_utilities.deprecate_as(attribute), # [DeprecateAs] 'enum_type': idl_type.enum_type, 'enum_values': idl_type.enum_values, 'exposed_test': v8_utilities.exposed(attribute, interface), # [Exposed] 'has_cross_origin_getter': has_extended_attribute_value(attribute, 'CrossOrigin', None) or has_extended_attribute_value(attribute, 'CrossOrigin', 'Getter'), 'has_cross_origin_setter': has_extended_attribute_value(attribute, 'CrossOrigin', 'Setter'), 'has_custom_getter': has_custom_getter(attribute), 'has_custom_setter': has_custom_setter(attribute), 'has_promise_type': idl_type.name == 'Promise', 'has_setter': has_setter(interface, attribute), 'idl_type': str(idl_type), 'is_cached_accessor': is_cached_accessor, 'is_call_with_execution_context': has_extended_attribute_value(attribute, 'CallWith', 'ExecutionContext'), 'is_call_with_script_state': has_extended_attribute_value(attribute, 'CallWith', 'ScriptState'), 'is_ce_reactions': is_ce_reactions, 'is_check_security_for_receiver': is_check_security_for_receiver, 'is_check_security_for_return_value': is_check_security_for_return_value, 'is_custom_element_callbacks': is_custom_element_callbacks, # TODO(yukishiino): Make all DOM attributes accessor-type properties. 'is_data_type_property': is_data_type_property(interface, attribute), 'is_getter_raises_exception': # [RaisesException] 'RaisesException' in extended_attributes and extended_attributes['RaisesException'] in (None, 'Getter'), 'is_keep_alive_for_gc': keep_alive_for_gc, 'is_lenient_this': 'LenientThis' in extended_attributes, 'is_nullable': idl_type.is_nullable, 'is_explicit_nullable': idl_type.is_explicit_nullable, 'is_named_constructor': is_named_constructor_attribute(attribute), 'is_partial_interface_member': 'PartialInterfaceImplementedAs' in extended_attributes, 'is_per_world_bindings': 'PerWorldBindings' in extended_attributes, 'is_put_forwards': 'PutForwards' in extended_attributes, 'is_read_only': attribute.is_read_only, 'is_reflect': is_reflect, 'is_replaceable': 'Replaceable' in attribute.extended_attributes, 'is_save_same_object': is_save_same_object, 'is_static': attribute.is_static, 'is_url': 'URL' in extended_attributes, 'is_unforgeable': is_unforgeable(interface, attribute), 'on_instance': v8_utilities.on_instance(interface, attribute), 'on_interface': v8_utilities.on_interface(interface, attribute), 'on_prototype': v8_utilities.on_prototype(interface, attribute), 'origin_trial_feature_name': v8_utilities.origin_trial_feature_name(attribute), # [OriginTrialEnabled] 'use_output_parameter_for_result': idl_type.use_output_parameter_for_result, 'measure_as': v8_utilities.measure_as(attribute, interface), # [MeasureAs] 'name': attribute.name, 'property_attributes': property_attributes(interface, attribute), 'reflect_empty': extended_attributes.get('ReflectEmpty'), 'reflect_invalid': extended_attributes.get('ReflectInvalid', ''), 'reflect_missing': extended_attributes.get('ReflectMissing'), 'reflect_only': extended_attribute_value_as_list(attribute, 'ReflectOnly'), 'runtime_enabled_feature_name': v8_utilities.runtime_enabled_feature_name(attribute), # [RuntimeEnabled] 'secure_context_test': v8_utilities.secure_context(attribute, interface), # [SecureContext] 'cached_accessor_name': '%s%sCachedAccessor' % (interface.name, attribute.name.capitalize()), 'world_suffixes': ( ['', 'ForMainWorld'] if 'PerWorldBindings' in extended_attributes else ['']), # [PerWorldBindings] } if not has_custom_getter(attribute): getter_context(interface, attribute, context) if not has_custom_setter(attribute) and has_setter(interface, attribute): setter_context(interface, attribute, interfaces, context) # [RuntimeCallStatsCounter] runtime_call_stats_context(interface, attribute, context) # [CrossOrigin] is incompatible with a number of other attributes, so check # for them here. if is_cross_origin: if context['has_cross_origin_setter'] and context['has_custom_setter']: raise Exception( '[CrossOrigin] and [Custom] are incompatible on the same setter: %s.%s', interface.name, attribute.name) if context['is_per_world_bindings']: raise Exception( '[CrossOrigin] and [PerWorldBindings] are incompatible: %s.%s', interface.name, attribute.name) if context['constructor_type']: raise Exception( '[CrossOrigin] cannot be used for constructors: %s.%s', interface.name, attribute.name) return context
def attribute_context(interface, attribute, interfaces, component_info): """Creates a Jinja template context for an attribute of an interface. Args: interface: An interface which |attribute| belongs to attribute: An attribute to create the context for interfaces: A dict which maps an interface name to the definition which can be referred if needed component_info: A dict containing component wide information Returns: A Jinja template context for |attribute| """ idl_type = attribute.idl_type base_idl_type = idl_type.base_type extended_attributes = attribute.extended_attributes idl_type.add_includes_for_type(extended_attributes) if idl_type.enum_values: includes.add('core/inspector/console_message.h') includes.add('platform/heap/heap.h') # [CheckSecurity] is_cross_origin = 'CrossOrigin' in extended_attributes is_check_security_for_receiver = (has_extended_attribute_value( interface, 'CheckSecurity', 'Receiver') and is_cross_origin) is_check_security_for_return_value = (has_extended_attribute_value( attribute, 'CheckSecurity', 'ReturnValue')) if is_check_security_for_receiver or is_check_security_for_return_value: includes.add('bindings/core/v8/binding_security.h') if is_check_security_for_return_value: includes.add('core/frame/web_feature.h') includes.add('platform/instrumentation/use_counter.h') # [CrossOrigin] if has_extended_attribute_value(attribute, 'CrossOrigin', 'Setter'): includes.add('platform/bindings/v8_cross_origin_callback_info.h') # [Constructor] # TODO(yukishiino): Constructors are much like methods although constructors # are not methods. Constructors must be data-type properties, and we can # support them as a kind of methods. constructor_type = idl_type.constructor_type_name if is_constructor_attribute( attribute) else None # [CEReactions] is_ce_reactions = 'CEReactions' in extended_attributes if is_ce_reactions: includes.add('core/html/custom/ce_reactions_scope.h') # [CustomElementCallbacks], [Reflect] is_custom_element_callbacks = 'CustomElementCallbacks' in extended_attributes is_reflect = 'Reflect' in extended_attributes # [ReflectOnly] reflect_only = extended_attribute_value_as_list(attribute, 'ReflectOnly') if reflect_only: reflect_only = map( lambda v: cpp_content_attribute_value_name(interface, v), reflect_only) if is_custom_element_callbacks or is_reflect: includes.add('core/html/custom/v0_custom_element_processing_stack.h') # [PerWorldBindings] if 'PerWorldBindings' in extended_attributes: assert idl_type.is_wrapper_type or 'LogActivity' in \ extended_attributes, \ '[PerWorldBindings] should only be used with wrapper types: %s.%s' % \ (interface.name, attribute.name) # [SaveSameObject] is_save_same_object = ('SameObject' in attribute.extended_attributes and 'SaveSameObject' in attribute.extended_attributes) # [StringContext] if idl_type.has_string_context: includes.add('bindings/core/v8/generated_code_helper.h') # [CachedAccessor] is_cached_accessor = 'CachedAccessor' in extended_attributes # [LenientSetter] is_lenient_setter = 'LenientSetter' in extended_attributes # [CachedAttribute] cached_attribute_validation_method = extended_attributes.get( 'CachedAttribute') keep_alive_for_gc = is_keep_alive_for_gc(interface, attribute) does_generate_getter = (not has_custom_getter(attribute) and not constructor_type) does_generate_setter = ( has_setter(interface, attribute) and not (has_custom_setter(attribute) or is_lenient_setter)) use_private_property_in_getter = (does_generate_getter and (cached_attribute_validation_method or is_save_same_object or keep_alive_for_gc)) use_private_property_in_setter = (does_generate_setter and cached_attribute_validation_method) private_property_is_shared_between_getter_and_setter = ( use_private_property_in_getter and use_private_property_in_setter) does_use_private_property = (use_private_property_in_getter or use_private_property_in_setter or is_cached_accessor) if does_use_private_property: includes.add('platform/bindings/v8_private_property.h') # [LogActivity] if 'LogActivity' in extended_attributes: includes.add('platform/bindings/v8_per_context_data.h') # [DeprecateAs], [MeasureAs] deprecate_as = v8_utilities.deprecate_as(attribute) measure_as = v8_utilities.measure_as(attribute, interface) # [HighEntropy] high_entropy = v8_utilities.high_entropy(attribute) is_lazy_data_attribute = \ (constructor_type and not (measure_as or deprecate_as)) or \ (str(idl_type) == 'Window' and attribute.name in ('frames', 'self', 'window')) runtime_features = component_info['runtime_enabled_features'] internal_name = cpp_encoded_property_name(attribute) cpp_type = idl_type.cpp_type if idl_type.is_explicit_nullable: cpp_type = v8_types.cpp_template_type('base::Optional', cpp_type) context = { # [ActivityLogging] 'activity_logging_world_list_for_getter': v8_utilities.activity_logging_world_list(attribute, 'Getter'), # [ActivityLogging] 'activity_logging_world_list_for_setter': v8_utilities.activity_logging_world_list(attribute, 'Setter'), # [ActivityLogging] 'activity_logging_world_check': v8_utilities.activity_logging_world_check(attribute), 'cached_accessor_name': 'k%s%s' % (interface.name, attribute.name.capitalize()), 'cached_attribute_validation_method': cached_attribute_validation_method, 'camel_case_name': NameStyleConverter(internal_name).to_upper_camel_case(), 'constructor_type': constructor_type, 'context_enabled_feature_name': v8_utilities.context_enabled_feature_name(attribute), 'cpp_name': cpp_name(attribute), 'cpp_type': cpp_type, 'cpp_type_initializer': idl_type.cpp_type_initializer, 'deprecate_as': deprecate_as, 'does_generate_getter': does_generate_getter, 'does_generate_setter': does_generate_setter, 'enum_type': idl_type.enum_type, 'enum_values': idl_type.enum_values, # [Exposed] 'exposed_test': v8_utilities.exposed(attribute, interface), 'getter_has_no_side_effect': has_extended_attribute_value(attribute, 'Affects', 'Nothing'), 'has_cross_origin_getter': has_extended_attribute_value(attribute, 'CrossOrigin', None) or has_extended_attribute_value(attribute, 'CrossOrigin', 'Getter'), 'has_cross_origin_setter': has_extended_attribute_value(attribute, 'CrossOrigin', 'Setter'), 'has_custom_getter': has_custom_getter(attribute), 'has_custom_setter': has_custom_setter(attribute), 'has_promise_type': idl_type.name == 'Promise', 'has_setter': has_setter(interface, attribute), 'high_entropy': high_entropy, 'idl_type': str(idl_type), 'is_cached_accessor': is_cached_accessor, 'is_call_with_execution_context': has_extended_attribute_value(attribute, 'CallWith', 'ExecutionContext'), 'is_call_with_script_state': has_extended_attribute_value(attribute, 'CallWith', 'ScriptState'), 'is_ce_reactions': is_ce_reactions, 'is_check_security_for_receiver': is_check_security_for_receiver, 'is_check_security_for_return_value': is_check_security_for_return_value, 'is_custom_element_callbacks': is_custom_element_callbacks, # TODO(yukishiino): Make all DOM attributes accessor-type properties. 'is_data_type_property': is_data_type_property(interface, attribute), 'is_getter_raises_exception': # [RaisesException] 'RaisesException' in extended_attributes and extended_attributes['RaisesException'] in (None, 'Getter'), 'is_keep_alive_for_gc': keep_alive_for_gc, 'is_lazy_data_attribute': is_lazy_data_attribute, 'is_lenient_setter': is_lenient_setter, 'is_lenient_this': 'LegacyLenientThis' in extended_attributes, 'is_nullable': idl_type.is_nullable, 'is_explicit_nullable': idl_type.is_explicit_nullable, 'is_named_constructor': is_named_constructor_attribute(attribute), 'is_partial_interface_member': 'PartialInterfaceImplementedAs' in extended_attributes, 'is_per_world_bindings': 'PerWorldBindings' in extended_attributes, 'is_put_forwards': 'PutForwards' in extended_attributes, 'is_read_only': attribute.is_read_only, 'is_reflect': is_reflect, 'is_replaceable': 'Replaceable' in attribute.extended_attributes, 'is_save_same_object': is_save_same_object, 'is_static': attribute.is_static, 'is_url': 'URL' in extended_attributes, 'is_unforgeable': is_unforgeable(attribute), 'measure_as': measure_as, 'name': attribute.name, 'on_instance': v8_utilities.on_instance(interface, attribute), 'on_interface': v8_utilities.on_interface(interface, attribute), 'on_prototype': v8_utilities.on_prototype(interface, attribute), # [RuntimeEnabled] for origin trial 'origin_trial_feature_name': v8_utilities.origin_trial_feature_name(attribute, runtime_features), 'private_property_is_shared_between_getter_and_setter': private_property_is_shared_between_getter_and_setter, 'property_attributes': property_attributes(interface, attribute), 'reflect_empty': cpp_content_attribute_value_name( interface, extended_attributes.get('ReflectEmpty')), 'reflect_invalid': cpp_content_attribute_value_name( interface, extended_attributes.get('ReflectInvalid', '')), 'reflect_missing': cpp_content_attribute_value_name( interface, extended_attributes.get('ReflectMissing')), 'reflect_only': reflect_only, # [RuntimeEnabled] if not in origin trial 'runtime_enabled_feature_name': v8_utilities.runtime_enabled_feature_name(attribute, runtime_features), # [SecureContext] 'secure_context_test': v8_utilities.secure_context(attribute, interface), 'use_output_parameter_for_result': idl_type.use_output_parameter_for_result, 'world_suffixes': ( ['', 'ForMainWorld'] if 'PerWorldBindings' in extended_attributes else ['']), # [PerWorldBindings] } if not has_custom_getter(attribute): getter_context(interface, attribute, context) if not has_custom_setter(attribute) and has_setter(interface, attribute): setter_context(interface, attribute, interfaces, context) # [RuntimeCallStatsCounter] runtime_call_stats_context(interface, attribute, context) # [CrossOrigin] is incompatible with a number of other attributes, so check # for them here. if is_cross_origin: if context['has_cross_origin_setter'] and context['has_custom_setter']: raise Exception( '[CrossOrigin] and [Custom] are incompatible on the same setter: %s.%s', interface.name, attribute.name) if context['is_per_world_bindings']: raise Exception( '[CrossOrigin] and [PerWorldBindings] are incompatible: %s.%s', interface.name, attribute.name) if context['constructor_type']: raise Exception( '[CrossOrigin] cannot be used for constructors: %s.%s', interface.name, attribute.name) return context
def attribute_context(interface, attribute, interfaces): """Creates a Jinja template context for an attribute of an interface. Args: interface: An interface which |attribute| belongs to attribute: An attribute to create the context for interfaces: A dict which maps an interface name to the definition which can be referred if needed Returns: A Jinja template context for |attribute| """ idl_type = attribute.idl_type base_idl_type = idl_type.base_type extended_attributes = attribute.extended_attributes idl_type.add_includes_for_type(extended_attributes) if idl_type.enum_values: includes.add('core/inspector/ConsoleMessage.h') # [CheckSecurity] is_cross_origin = 'CrossOrigin' in extended_attributes is_check_security_for_receiver = ( has_extended_attribute_value(interface, 'CheckSecurity', 'Receiver') and is_cross_origin) is_check_security_for_return_value = ( has_extended_attribute_value(attribute, 'CheckSecurity', 'ReturnValue')) if is_check_security_for_receiver or is_check_security_for_return_value: includes.add('bindings/core/v8/BindingSecurity.h') # [CrossOrigin] if has_extended_attribute_value(attribute, 'CrossOrigin', 'Setter'): includes.add('bindings/core/v8/V8CrossOriginSetterInfo.h') # [Constructor] # TODO(yukishiino): Constructors are much like methods although constructors # are not methods. Constructors must be data-type properties, and we can # support them as a kind of methods. constructor_type = idl_type.constructor_type_name if is_constructor_attribute(attribute) else None # [CEReactions] is_ce_reactions = 'CEReactions' in extended_attributes if is_ce_reactions: includes.add('core/html/custom/CEReactionsScope.h') # [CustomElementCallbacks], [Reflect] is_custom_element_callbacks = 'CustomElementCallbacks' in extended_attributes is_reflect = 'Reflect' in extended_attributes if is_custom_element_callbacks or is_reflect: includes.add('core/html/custom/V0CustomElementProcessingStack.h') # [PerWorldBindings] if 'PerWorldBindings' in extended_attributes: assert idl_type.is_wrapper_type or 'LogActivity' in extended_attributes, '[PerWorldBindings] should only be used with wrapper types: %s.%s' % (interface.name, attribute.name) # [SaveSameObject] is_save_same_object = ( 'SameObject' in attribute.extended_attributes and 'SaveSameObject' in attribute.extended_attributes) if is_save_same_object: includes.add('platform/bindings/V8PrivateProperty.h') if (base_idl_type == 'EventHandler' and interface.name in ['Window', 'WorkerGlobalScope'] and attribute.name == 'onerror'): includes.add('bindings/core/v8/V8ErrorHandler.h') cached_attribute_validation_method = extended_attributes.get('CachedAttribute') keep_alive_for_gc = is_keep_alive_for_gc(interface, attribute) if cached_attribute_validation_method or keep_alive_for_gc: includes.add('platform/bindings/V8PrivateProperty.h') # [CachedAccessor] is_cached_accessor = 'CachedAccessor' in extended_attributes if is_cached_accessor: includes.add('platform/bindings/V8PrivateProperty.h') context = { 'activity_logging_world_list_for_getter': v8_utilities.activity_logging_world_list(attribute, 'Getter'), # [ActivityLogging] 'activity_logging_world_list_for_setter': v8_utilities.activity_logging_world_list(attribute, 'Setter'), # [ActivityLogging] 'activity_logging_world_check': v8_utilities.activity_logging_world_check(attribute), # [ActivityLogging] 'cached_attribute_validation_method': cached_attribute_validation_method, 'constructor_type': constructor_type, 'context_enabled_feature_name': v8_utilities.context_enabled_feature_name(attribute), 'cpp_name': cpp_name(attribute), 'cpp_type': idl_type.cpp_type, 'cpp_type_initializer': idl_type.cpp_type_initializer, 'deprecate_as': v8_utilities.deprecate_as(attribute), # [DeprecateAs] 'enum_type': idl_type.enum_type, 'enum_values': idl_type.enum_values, 'exposed_test': v8_utilities.exposed(attribute, interface), # [Exposed] 'has_cross_origin_getter': has_extended_attribute_value(attribute, 'CrossOrigin', None) or has_extended_attribute_value(attribute, 'CrossOrigin', 'Getter'), 'has_cross_origin_setter': has_extended_attribute_value(attribute, 'CrossOrigin', 'Setter'), 'has_custom_getter': has_custom_getter(attribute), 'has_custom_setter': has_custom_setter(attribute), 'has_setter': has_setter(interface, attribute), 'idl_type': str(idl_type), 'is_cached_accessor': is_cached_accessor, 'is_call_with_execution_context': has_extended_attribute_value(attribute, 'CallWith', 'ExecutionContext'), 'is_call_with_script_state': has_extended_attribute_value(attribute, 'CallWith', 'ScriptState'), 'is_ce_reactions': is_ce_reactions, 'is_check_security_for_receiver': is_check_security_for_receiver, 'is_check_security_for_return_value': is_check_security_for_return_value, 'is_custom_element_callbacks': is_custom_element_callbacks, # TODO(yukishiino): Make all DOM attributes accessor-type properties. 'is_data_type_property': is_data_type_property(interface, attribute), 'is_getter_raises_exception': # [RaisesException] 'RaisesException' in extended_attributes and extended_attributes['RaisesException'] in (None, 'Getter'), 'is_keep_alive_for_gc': keep_alive_for_gc, 'is_lenient_this': 'LenientThis' in extended_attributes, 'is_nullable': idl_type.is_nullable, 'is_explicit_nullable': idl_type.is_explicit_nullable, 'is_named_constructor': is_named_constructor_attribute(attribute), 'is_partial_interface_member': 'PartialInterfaceImplementedAs' in extended_attributes, 'is_per_world_bindings': 'PerWorldBindings' in extended_attributes, 'is_put_forwards': 'PutForwards' in extended_attributes, 'is_read_only': attribute.is_read_only, 'is_reflect': is_reflect, 'is_replaceable': 'Replaceable' in attribute.extended_attributes, 'is_save_same_object': is_save_same_object, 'is_static': attribute.is_static, 'is_url': 'URL' in extended_attributes, 'is_unforgeable': is_unforgeable(interface, attribute), 'on_instance': v8_utilities.on_instance(interface, attribute), 'on_interface': v8_utilities.on_interface(interface, attribute), 'on_prototype': v8_utilities.on_prototype(interface, attribute), 'origin_trial_enabled_function': v8_utilities.origin_trial_enabled_function_name(attribute), # [OriginTrialEnabled] 'origin_trial_feature_name': v8_utilities.origin_trial_feature_name(attribute), # [OriginTrialEnabled] 'use_output_parameter_for_result': idl_type.use_output_parameter_for_result, 'measure_as': v8_utilities.measure_as(attribute, interface), # [MeasureAs] 'name': attribute.name, 'property_attributes': property_attributes(interface, attribute), 'reflect_empty': extended_attributes.get('ReflectEmpty'), 'reflect_invalid': extended_attributes.get('ReflectInvalid', ''), 'reflect_missing': extended_attributes.get('ReflectMissing'), 'reflect_only': extended_attribute_value_as_list(attribute, 'ReflectOnly'), 'runtime_enabled_feature_name': v8_utilities.runtime_enabled_feature_name(attribute), # [RuntimeEnabled] 'secure_context_test': v8_utilities.secure_context(attribute, interface), # [SecureContext] 'cached_accessor_name': '%s%sCachedAccessor' % (interface.name, attribute.name.capitalize()), 'world_suffixes': ( ['', 'ForMainWorld'] if 'PerWorldBindings' in extended_attributes else ['']), # [PerWorldBindings] } if is_constructor_attribute(attribute): update_constructor_attribute_context(interface, attribute, context) if not has_custom_getter(attribute): getter_context(interface, attribute, context) if not has_custom_setter(attribute) and has_setter(interface, attribute): setter_context(interface, attribute, interfaces, context) # [RuntimeCallStatsCounter] runtime_call_stats_context(interface, attribute, context) # [CrossOrigin] is incompatible with a number of other attributes, so check # for them here. if is_cross_origin: if context['has_cross_origin_setter'] and context['has_custom_setter']: raise Exception('[CrossOrigin] and [Custom] are incompatible on the same setter: %s.%s', interface.name, attribute.name) if context['is_per_world_bindings']: raise Exception('[CrossOrigin] and [PerWorldBindings] are incompatible: %s.%s', interface.name, attribute.name) if context['constructor_type']: raise Exception('[CrossOrigin] cannot be used for constructors: %s.%s', interface.name, attribute.name) return context