本文整理汇总了Python中v8_utilities.conditional_string函数的典型用法代码示例。如果您正苦于以下问题:Python conditional_string函数的具体用法?Python conditional_string怎么用?Python conditional_string使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了conditional_string函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: callback_interface_context
def callback_interface_context(callback_interface):
includes.clear()
includes.update(CALLBACK_INTERFACE_CPP_INCLUDES)
return {
"conditional_string": v8_utilities.conditional_string(callback_interface),
"cpp_class": callback_interface.name,
"v8_class": v8_utilities.v8_class_name(callback_interface),
"header_includes": set(CALLBACK_INTERFACE_H_INCLUDES),
"methods": [method_context(operation) for operation in callback_interface.operations],
}
示例2: generate_callback_interface
def generate_callback_interface(callback_interface):
includes.clear()
includes.update(CALLBACK_INTERFACE_CPP_INCLUDES)
return {
'conditional_string': v8_utilities.conditional_string(callback_interface),
'cpp_class': callback_interface.name,
'v8_class': v8_utilities.v8_class_name(callback_interface),
'header_includes': set(CALLBACK_INTERFACE_H_INCLUDES),
'methods': [generate_method(operation)
for operation in callback_interface.operations],
}
示例3: generate_attribute
def generate_attribute(interface, attribute):
idl_type = attribute.idl_type
extended_attributes = attribute.extended_attributes
has_custom_getter = ('Custom' in extended_attributes and
extended_attributes['Custom'] in [None, 'Getter'])
has_custom_setter = (not attribute.is_read_only and
'Custom' in extended_attributes and
extended_attributes['Custom'] in [None, 'Setter'])
contents = {
'access_control_list': access_control_list(attribute),
'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]
'cached_attribute_validation_method': extended_attributes.get('CachedAttribute'),
'conditional_string': v8_utilities.conditional_string(attribute),
'cpp_type': v8_types.cpp_type(idl_type),
'getter_callback_name': getter_callback_name(interface, attribute),
'getter_callback_name_for_main_world': getter_callback_name_for_main_world(interface, attribute),
'has_custom_getter': has_custom_getter,
'has_custom_setter': has_custom_setter,
'idl_type': idl_type,
'is_call_with_execution_context': v8_utilities.has_extended_attribute_value(attribute, 'CallWith', 'ExecutionContext'),
'is_constructor': is_constructor_attribute(attribute),
'is_getter_raises_exception': has_extended_attribute(attribute, ('GetterRaisesException', 'RaisesException')),
'is_keep_alive_for_gc': is_keep_alive_for_gc(attribute),
'is_nullable': attribute.is_nullable,
'is_read_only': attribute.is_read_only,
'is_replaceable': 'Replaceable' in attribute.extended_attributes,
'is_setter_raises_exception': has_extended_attribute(attribute, ('RaisesException', 'SetterRaisesException')),
'is_static': attribute.is_static,
'name': attribute.name,
'per_context_enabled_function_name': v8_utilities.per_context_enabled_function_name(attribute), # [PerContextEnabled]
'property_attributes': property_attributes(attribute),
'setter_callback_name': setter_callback_name(interface, attribute),
'setter_callback_name_for_main_world': setter_callback_name_for_main_world(interface, attribute),
'v8_type': v8_types.v8_type(idl_type),
'runtime_enabled_function_name': v8_utilities.runtime_enabled_function_name(attribute), # [RuntimeEnabled]
'world_suffixes': ['', 'ForMainWorld'] if 'PerWorldBindings' in extended_attributes else [''], # [PerWorldBindings]
'wrapper_type_info': wrapper_type_info(attribute),
}
if is_constructor_attribute(attribute):
includes.update(v8_types.includes_for_type(idl_type))
return contents
if not has_custom_getter:
generate_getter(interface, attribute, contents)
if not attribute.is_read_only and not has_custom_setter:
generate_setter(interface, attribute, contents)
return contents
示例4: generate_callback_interface
def generate_callback_interface(callback_interface):
includes.clear()
includes.update(CALLBACK_INTERFACE_CPP_INCLUDES)
name = callback_interface.name
methods = [generate_method(operation)
for operation in callback_interface.operations]
template_contents = {
'conditional_string': v8_utilities.conditional_string(callback_interface),
'cpp_class': name,
'v8_class': v8_utilities.v8_class_name(callback_interface),
'header_includes': CALLBACK_INTERFACE_H_INCLUDES,
'methods': methods,
}
return template_contents
示例5: write_header_and_cpp
def write_header_and_cpp(self):
interface = self.interface
template_contents = self.generate_contents(interface)
template_contents['conditional_string'] = conditional_string(interface)
template_contents['header_includes'].add(self.include_for_cpp_class)
template_contents['header_includes'] = sorted(template_contents['header_includes'])
template_contents['cpp_includes'] = sorted(includes)
header_basename = v8_class_name(interface) + '.h'
header_file_text = self.header_template.render(template_contents)
self.write_file(header_basename, header_file_text)
cpp_basename = v8_class_name(interface) + '.cpp'
cpp_file_text = self.cpp_template.render(template_contents)
self.write_file(cpp_basename, cpp_file_text)
示例6: generate_interface
def generate_interface(interface):
includes.clear()
includes.update(INTERFACE_CPP_INCLUDES)
header_includes = INTERFACE_H_INCLUDES
parent_interface = interface.parent
if parent_interface:
header_includes.update(v8_types.includes_for_type(parent_interface))
extended_attributes = interface.extended_attributes
# [CheckSecurity]
is_check_security = 'CheckSecurity' in extended_attributes
if is_check_security:
includes.update(['bindings/v8/BindingSecurity.h',
'bindings/v8/ExceptionState.h'])
# [GenerateVisitDOMWrapper]
generate_visit_dom_wrapper_function = extended_attributes.get('GenerateVisitDOMWrapper')
if generate_visit_dom_wrapper_function:
includes.update(['bindings/v8/V8GCController.h',
'core/dom/Element.h'])
# [MeasureAs]
is_measure_as = 'MeasureAs' in extended_attributes
if is_measure_as:
includes.add('core/frame/UseCounter.h')
# [RaisesException=Constructor]
is_constructor_raises_exception = extended_attributes.get('RaisesException') == 'Constructor'
if is_constructor_raises_exception:
includes.add('bindings/v8/ExceptionState.h')
# [SpecialWrapFor]
if 'SpecialWrapFor' in extended_attributes:
special_wrap_for = extended_attributes['SpecialWrapFor'].split('|')
else:
special_wrap_for = []
for special_wrap_interface in special_wrap_for:
v8_types.add_includes_for_type(special_wrap_interface)
# Constructors
# [Constructor]
has_constructor = 'Constructor' in extended_attributes
if has_constructor:
includes.add('bindings/v8/V8ObjectConstructor.h')
# [EventConstructor]
has_event_constructor = 'EventConstructor' in extended_attributes
has_any_type_attributes = any(attribute
for attribute in interface.attributes
if attribute.idl_type == 'any')
if has_event_constructor:
includes.update(['bindings/v8/Dictionary.h',
'bindings/v8/V8ObjectConstructor.h'])
if has_any_type_attributes:
includes.add('bindings/v8/SerializedScriptValue.h')
template_contents = {
'conditional_string': conditional_string(interface), # [Conditional]
'constructor_arguments': constructor_arguments(interface),
'cpp_class': cpp_name(interface),
'generate_visit_dom_wrapper_function': generate_visit_dom_wrapper_function,
'has_constructor': has_constructor,
'has_custom_legacy_call_as_function': has_extended_attribute_value(interface, 'Custom', 'LegacyCallAsFunction'), # [Custom=LegacyCallAsFunction]
'has_custom_to_v8': has_extended_attribute_value(interface, 'Custom', 'ToV8'), # [Custom=ToV8]
'has_custom_wrap': has_extended_attribute_value(interface, 'Custom', 'Wrap'), # [Custom=Wrap]
'has_event_constructor': has_event_constructor,
'has_any_type_attributes': has_any_type_attributes,
'has_visit_dom_wrapper': (
# [Custom=Wrap], [GenerateVisitDOMWrapper]
has_extended_attribute_value(interface, 'Custom', 'VisitDOMWrapper') or
'GenerateVisitDOMWrapper' in extended_attributes),
'header_includes': header_includes,
'interface_name': interface.name,
'is_active_dom_object': 'ActiveDOMObject' in extended_attributes, # [ActiveDOMObject]
'is_check_security': is_check_security,
'is_constructor_call_with_document': has_extended_attribute_value(
interface, 'ConstructorCallWith', 'Document'), # [ConstructorCallWith=Document]
'is_constructor_call_with_execution_context': has_extended_attribute_value(
interface, 'ConstructorCallWith', 'ExecutionContext'), # [ConstructorCallWith=ExeuctionContext]
'is_constructor_raises_exception': is_constructor_raises_exception,
'is_dependent_lifetime': 'DependentLifetime' in extended_attributes, # [DependentLifetime]
'length': 1 if has_event_constructor else 0, # FIXME: more complex in general, see discussion of length in http://heycam.github.io/webidl/#es-interface-call
'measure_as': v8_utilities.measure_as(interface), # [MeasureAs]
'parent_interface': parent_interface,
'runtime_enabled_function': runtime_enabled_function_name(interface), # [RuntimeEnabled]
'special_wrap_for': special_wrap_for,
'v8_class': v8_utilities.v8_class_name(interface),
}
template_contents.update({
'constants': [generate_constant(constant) for constant in interface.constants],
'do_not_check_constants': 'DoNotCheckConstants' in extended_attributes,
})
attributes = [v8_attributes.generate_attribute(interface, attribute)
for attribute in interface.attributes]
template_contents.update({
'attributes': attributes,
'has_accessors': any(attribute['is_expose_js_accessors'] for attribute in attributes),
#.........这里部分代码省略.........
示例7: method_context
def method_context(interface, method):
arguments = method.arguments
extended_attributes = method.extended_attributes
idl_type = method.idl_type
is_static = method.is_static
name = method.name
idl_type.add_includes_for_type()
this_cpp_value = cpp_value(interface, method, len(arguments))
def function_template():
if is_static:
return "functionTemplate"
if "Unforgeable" in extended_attributes:
return "instanceTemplate"
return "prototypeTemplate"
is_implemented_in_private_script = "ImplementedInPrivateScript" in extended_attributes
if is_implemented_in_private_script:
includes.add("bindings/core/v8/PrivateScriptRunner.h")
includes.add("core/frame/LocalFrame.h")
includes.add("platform/ScriptForbiddenScope.h")
# [OnlyExposedToPrivateScript]
is_only_exposed_to_private_script = "OnlyExposedToPrivateScript" in extended_attributes
is_call_with_script_arguments = has_extended_attribute_value(method, "CallWith", "ScriptArguments")
if is_call_with_script_arguments:
includes.update(["bindings/core/v8/ScriptCallStackFactory.h", "core/inspector/ScriptArguments.h"])
is_call_with_script_state = has_extended_attribute_value(method, "CallWith", "ScriptState")
if is_call_with_script_state:
includes.add("bindings/core/v8/ScriptState.h")
is_check_security_for_node = "CheckSecurity" in extended_attributes
if is_check_security_for_node:
includes.add("bindings/core/v8/BindingSecurity.h")
is_custom_element_callbacks = "CustomElementCallbacks" in extended_attributes
if is_custom_element_callbacks:
includes.add("core/dom/custom/CustomElementProcessingStack.h")
is_do_not_check_security = "DoNotCheckSecurity" in extended_attributes
is_check_security_for_frame = (
has_extended_attribute_value(interface, "CheckSecurity", "Frame") and not is_do_not_check_security
)
is_check_security_for_window = (
has_extended_attribute_value(interface, "CheckSecurity", "Window") and not is_do_not_check_security
)
is_raises_exception = "RaisesException" in extended_attributes
return {
"activity_logging_world_list": v8_utilities.activity_logging_world_list(method), # [ActivityLogging]
"arguments": [argument_context(interface, method, argument, index) for index, argument in enumerate(arguments)],
"argument_declarations_for_private_script": argument_declarations_for_private_script(interface, method),
"conditional_string": v8_utilities.conditional_string(method),
"cpp_type": (
v8_types.cpp_template_type("Nullable", idl_type.cpp_type)
if idl_type.is_explicit_nullable
else idl_type.cpp_type
),
"cpp_value": this_cpp_value,
"cpp_type_initializer": idl_type.cpp_type_initializer,
"custom_registration_extended_attributes": CUSTOM_REGISTRATION_EXTENDED_ATTRIBUTES.intersection(
extended_attributes.iterkeys()
),
"deprecate_as": v8_utilities.deprecate_as(method), # [DeprecateAs]
"exposed_test": v8_utilities.exposed(method, interface), # [Exposed]
"function_template": function_template(),
"has_custom_registration": is_static
or v8_utilities.has_extended_attribute(method, CUSTOM_REGISTRATION_EXTENDED_ATTRIBUTES),
"has_exception_state": is_raises_exception
or is_check_security_for_frame
or is_check_security_for_window
or any(
argument
for argument in arguments
if (
argument.idl_type.name == "SerializedScriptValue"
or argument_conversion_needs_exception_state(method, argument)
)
),
"idl_type": idl_type.base_type,
"is_call_with_execution_context": has_extended_attribute_value(method, "CallWith", "ExecutionContext"),
"is_call_with_script_arguments": is_call_with_script_arguments,
"is_call_with_script_state": is_call_with_script_state,
"is_check_security_for_frame": is_check_security_for_frame,
"is_check_security_for_node": is_check_security_for_node,
"is_check_security_for_window": is_check_security_for_window,
"is_custom": "Custom" in extended_attributes,
"is_custom_element_callbacks": is_custom_element_callbacks,
"is_do_not_check_security": is_do_not_check_security,
"is_do_not_check_signature": "DoNotCheckSignature" in extended_attributes,
"is_explicit_nullable": idl_type.is_explicit_nullable,
"is_implemented_in_private_script": is_implemented_in_private_script,
"is_partial_interface_member": "PartialInterfaceImplementedAs" in extended_attributes,
"is_per_world_bindings": "PerWorldBindings" in extended_attributes,
"is_raises_exception": is_raises_exception,
"is_read_only": "Unforgeable" in extended_attributes,
"is_static": is_static,
#.........这里部分代码省略.........
示例8: attribute_context
def attribute_context(interface, 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_do_not_check_security = "DoNotCheckSecurity" in extended_attributes
is_check_security_for_receiver = (
has_extended_attribute_value(interface, "CheckSecurity", "Receiver") and not is_do_not_check_security
)
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")
# [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
# [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/dom/custom/CustomElementProcessingStack.h")
# [ImplementedInPrivateScript]
is_implemented_in_private_script = "ImplementedInPrivateScript" in extended_attributes
if is_implemented_in_private_script:
includes.add("bindings/core/v8/PrivateScriptRunner.h")
includes.add("core/frame/LocalFrame.h")
includes.add("platform/ScriptForbiddenScope.h")
# [OnlyExposedToPrivateScript]
is_only_exposed_to_private_script = "OnlyExposedToPrivateScript" in extended_attributes
# [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)
if (
base_idl_type == "EventHandler"
and interface.name in ["Window", "WorkerGlobalScope"]
and attribute.name == "onerror"
):
includes.add("bindings/core/v8/V8ErrorHandler.h")
conditional_string = v8_utilities.conditional_string(attribute)
if conditional_string:
includes.add("wtf/build_config.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("bindings/core/v8/V8HiddenValue.h")
if "APIExperimentEnabled" in extended_attributes:
includes.add("core/experiments/ExperimentalFeatures.h")
includes.add("core/inspector/ConsoleMessage.h")
context = {
"access_control_list": access_control_list(interface, attribute),
"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]
"api_experiment_enabled": v8_utilities.api_experiment_enabled_function(attribute), # [APIExperimentEnabled]
"api_experiment_enabled_per_interface": v8_utilities.api_experiment_enabled_function(
interface
), # [APIExperimentEnabled]
"api_experiment_name": extended_attributes.get("APIExperimentEnabled"), # [APIExperimentEnabled]
"argument_cpp_type": idl_type.cpp_type_args(used_as_rvalue_type=True),
"cached_attribute_validation_method": cached_attribute_validation_method,
"conditional_string": conditional_string,
"constructor_type": constructor_type,
"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_custom_getter": has_custom_getter(attribute),
"has_custom_setter": has_custom_setter(attribute),
"has_setter": has_setter(attribute),
"idl_type": str(idl_type), # need trailing [] on array for Dictionary::ConversionContext::setConversionType
"is_api_experiment_enabled": v8_utilities.api_experiment_enabled_function(attribute)
or v8_utilities.api_experiment_enabled_function(interface), # [APIExperimentEnabled]
"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_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": constructor_type or interface.name == "Window" or interface.name == "Location",
"is_getter_raises_exception": "RaisesException" in extended_attributes # [RaisesException]
#.........这里部分代码省略.........
示例9: generate_method
def generate_method(interface, method):
arguments = method.arguments
extended_attributes = method.extended_attributes
idl_type = method.idl_type
is_static = method.is_static
name = method.name
v8_types.add_includes_for_type(idl_type)
this_cpp_value = cpp_value(interface, method, len(arguments))
def function_template():
if is_static:
return 'functionTemplate'
if 'Unforgeable' in extended_attributes:
return 'instanceTemplate'
return 'prototypeTemplate'
is_call_with_script_arguments = has_extended_attribute_value(method, 'CallWith', 'ScriptArguments')
if is_call_with_script_arguments:
includes.update(['bindings/v8/ScriptCallStackFactory.h',
'core/inspector/ScriptArguments.h'])
is_call_with_script_state = has_extended_attribute_value(method, 'CallWith', 'ScriptState')
if is_call_with_script_state:
includes.add('bindings/v8/ScriptState.h')
is_check_security_for_node = 'CheckSecurity' in extended_attributes
if is_check_security_for_node:
includes.add('bindings/v8/BindingSecurity.h')
is_custom_element_callbacks = 'CustomElementCallbacks' in extended_attributes
if is_custom_element_callbacks:
includes.add('core/dom/custom/CustomElementCallbackDispatcher.h')
is_check_security_for_frame = (
'CheckSecurity' in interface.extended_attributes and
'DoNotCheckSecurity' not in extended_attributes)
is_raises_exception = 'RaisesException' in extended_attributes
return {
'activity_logging_world_list': v8_utilities.activity_logging_world_list(method), # [ActivityLogging]
'arguments': [generate_argument(interface, method, argument, index)
for index, argument in enumerate(arguments)],
'conditional_string': v8_utilities.conditional_string(method),
'cpp_type': v8_types.cpp_type(idl_type),
'cpp_value': this_cpp_value,
'deprecate_as': v8_utilities.deprecate_as(method), # [DeprecateAs]
'do_not_check_signature': not(is_static or
v8_utilities.has_extended_attribute(method,
['DoNotCheckSecurity', 'DoNotCheckSignature', 'NotEnumerable',
'ReadOnly', 'RuntimeEnabled', 'Unforgeable'])),
'function_template': function_template(),
'idl_type': idl_type,
'has_exception_state':
is_raises_exception or
is_check_security_for_frame or
any(argument for argument in arguments
if argument.idl_type == 'SerializedScriptValue' or
v8_types.is_integer_type(argument.idl_type)) or
name in ['addEventListener', 'removeEventListener'],
'is_call_with_execution_context': has_extended_attribute_value(method, 'CallWith', 'ExecutionContext'),
'is_call_with_script_arguments': is_call_with_script_arguments,
'is_call_with_script_state': is_call_with_script_state,
'is_check_security_for_frame': is_check_security_for_frame,
'is_check_security_for_node': is_check_security_for_node,
'is_custom': 'Custom' in extended_attributes,
'is_custom_element_callbacks': is_custom_element_callbacks,
'is_do_not_check_security': 'DoNotCheckSecurity' in extended_attributes,
'is_do_not_check_signature': 'DoNotCheckSignature' in extended_attributes,
'is_per_world_bindings': 'PerWorldBindings' in extended_attributes,
'is_raises_exception': is_raises_exception,
'is_read_only': 'ReadOnly' in extended_attributes,
'is_static': is_static,
'is_strict_type_checking':
'StrictTypeChecking' in extended_attributes or
'StrictTypeChecking' in interface.extended_attributes,
'is_variadic': arguments and arguments[-1].is_variadic,
'measure_as': v8_utilities.measure_as(method), # [MeasureAs]
'name': name,
'number_of_arguments': len(arguments),
'number_of_required_arguments': len([
argument for argument in arguments
if not (argument.is_optional or argument.is_variadic)]),
'number_of_required_or_variadic_arguments': len([
argument for argument in arguments
if not argument.is_optional]),
'per_context_enabled_function': v8_utilities.per_context_enabled_function_name(method), # [PerContextEnabled]
'property_attributes': property_attributes(method),
'runtime_enabled_function': v8_utilities.runtime_enabled_function_name(method), # [RuntimeEnabled]
'signature': 'v8::Local<v8::Signature>()' if is_static or 'DoNotCheckSignature' in extended_attributes else 'defaultSignature',
'union_arguments': union_arguments(idl_type),
'v8_set_return_value_for_main_world': v8_set_return_value(interface.name, method, this_cpp_value, for_main_world=True),
'v8_set_return_value': v8_set_return_value(interface.name, method, this_cpp_value),
'world_suffixes': ['', 'ForMainWorld'] if 'PerWorldBindings' in extended_attributes else [''], # [PerWorldBindings]
}
示例10: generate_method
def generate_method(interface, method):
arguments = method.arguments
extended_attributes = method.extended_attributes
idl_type = method.idl_type
is_static = method.is_static
name = method.name
this_cpp_value = cpp_value(interface, method, len(arguments))
this_custom_signature = custom_signature(method, arguments)
def function_template():
# FIXME: Rename as follows (also in v8/V8DOMConfiguration):
# desc => functionTemplate
# instance => instanceTemplate
# proto => prototypeTemplate
if is_static:
return 'desc'
if 'Unforgeable' in extended_attributes:
return 'instance'
return 'proto'
def signature():
if this_custom_signature:
return name + 'Signature'
if is_static or 'DoNotCheckSignature' in extended_attributes:
return 'v8::Local<v8::Signature>()'
return 'defaultSignature'
is_call_with_script_arguments = has_extended_attribute_value(method, 'CallWith', 'ScriptArguments')
if is_call_with_script_arguments:
includes.update(['bindings/v8/ScriptCallStackFactory.h',
'core/inspector/ScriptArguments.h'])
is_call_with_script_state = has_extended_attribute_value(method, 'CallWith', 'ScriptState')
if is_call_with_script_state:
includes.add('bindings/v8/ScriptState.h')
is_check_security_for_node = 'CheckSecurityForNode' in extended_attributes
if is_check_security_for_node:
includes.add('bindings/v8/BindingSecurity.h')
is_custom_element_callbacks = 'CustomElementCallbacks' in extended_attributes
if is_custom_element_callbacks:
includes.add('core/dom/custom/CustomElementCallbackDispatcher.h')
is_raises_exception = 'RaisesException' in extended_attributes
if is_raises_exception:
includes.update(['bindings/v8/ExceptionMessages.h',
'bindings/v8/ExceptionState.h'])
contents = {
'activity_logging_world_list': v8_utilities.activity_logging_world_list(method), # [ActivityLogging]
'arguments': [generate_argument(interface, method, argument, index)
for index, argument in enumerate(arguments)],
'conditional_string': v8_utilities.conditional_string(method),
'cpp_type': v8_types.cpp_type(idl_type),
'cpp_value': this_cpp_value,
'custom_signature': this_custom_signature,
'deprecate_as': v8_utilities.deprecate_as(method), # [DeprecateAs]
'do_not_check_signature': not(this_custom_signature or is_static or
v8_utilities.has_extended_attribute(method,
['DoNotCheckSignature', 'NotEnumerable', 'ReadOnly',
'RuntimeEnabled', 'Unforgeable'])),
'function_template': function_template(),
'idl_type': idl_type,
'is_call_with_execution_context': has_extended_attribute_value(method, 'CallWith', 'ExecutionContext'),
'is_call_with_script_arguments': is_call_with_script_arguments,
'is_call_with_script_state': is_call_with_script_state,
'is_check_security_for_node': is_check_security_for_node,
'is_custom': 'Custom' in extended_attributes,
'is_custom_element_callbacks': is_custom_element_callbacks,
'is_per_world_bindings': 'PerWorldBindings' in extended_attributes,
'is_raises_exception': is_raises_exception,
'is_static': is_static,
'measure_as': v8_utilities.measure_as(method), # [MeasureAs]
'name': name,
'number_of_arguments': len(arguments),
'number_of_required_arguments': len([
argument for argument in arguments
if not (argument.is_optional or argument.is_variadic)]),
'number_of_required_or_variadic_arguments': len([
argument for argument in arguments
if not argument.is_optional]),
'per_context_enabled_function_name': v8_utilities.per_context_enabled_function_name(method), # [PerContextEnabled]
'property_attributes': property_attributes(method),
'runtime_enabled_function_name': v8_utilities.runtime_enabled_function_name(method), # [RuntimeEnabled]
'signature': signature(),
'v8_set_return_value': v8_set_return_value(method, this_cpp_value),
'world_suffixes': ['', 'ForMainWorld'] if 'PerWorldBindings' in extended_attributes else [''], # [PerWorldBindings]
}
return contents
示例11: method_context
def method_context(interface, method, is_visible=True):
arguments = method.arguments
extended_attributes = method.extended_attributes
idl_type = method.idl_type
is_static = method.is_static
name = method.name
if is_visible:
idl_type.add_includes_for_type(extended_attributes)
this_cpp_value = cpp_value(interface, method, len(arguments))
is_implemented_in_private_script = 'ImplementedInPrivateScript' in extended_attributes
if is_implemented_in_private_script:
includes.add('bindings/core/v8/PrivateScriptRunner.h')
includes.add('core/frame/LocalFrame.h')
includes.add('platform/ScriptForbiddenScope.h')
# [OnlyExposedToPrivateScript]
is_only_exposed_to_private_script = 'OnlyExposedToPrivateScript' in extended_attributes
is_call_with_script_arguments = has_extended_attribute_value(method, 'CallWith', 'ScriptArguments')
if is_call_with_script_arguments:
includes.update(['bindings/core/v8/ScriptCallStackFactory.h',
'core/inspector/ScriptArguments.h'])
is_call_with_script_state = has_extended_attribute_value(method, 'CallWith', 'ScriptState')
is_call_with_this_value = has_extended_attribute_value(method, 'CallWith', 'ThisValue')
if is_call_with_script_state or is_call_with_this_value:
includes.add('bindings/core/v8/ScriptState.h')
is_check_security_for_node = 'CheckSecurity' in extended_attributes
if is_check_security_for_node:
includes.add('bindings/core/v8/BindingSecurity.h')
is_custom_element_callbacks = 'CustomElementCallbacks' in extended_attributes
if is_custom_element_callbacks:
includes.add('core/dom/custom/CustomElementProcessingStack.h')
is_do_not_check_security = 'DoNotCheckSecurity' in extended_attributes
is_check_security_for_frame = (
has_extended_attribute_value(interface, 'CheckSecurity', 'Frame') and
not is_do_not_check_security)
is_check_security_for_window = (
has_extended_attribute_value(interface, 'CheckSecurity', 'Window') and
not is_do_not_check_security)
is_raises_exception = 'RaisesException' in extended_attributes
is_custom_call_prologue = has_extended_attribute_value(method, 'Custom', 'CallPrologue')
is_custom_call_epilogue = has_extended_attribute_value(method, 'Custom', 'CallEpilogue')
is_post_message = 'PostMessage' in extended_attributes
if is_post_message:
includes.add('bindings/core/v8/SerializedScriptValueFactory.h')
includes.add('core/dom/DOMArrayBuffer.h')
includes.add('core/dom/MessagePort.h')
if 'LenientThis' in extended_attributes:
raise Exception('[LenientThis] is not supported for operations.')
return {
'activity_logging_world_list': v8_utilities.activity_logging_world_list(method), # [ActivityLogging]
'arguments': [argument_context(interface, method, argument, index, is_visible=is_visible)
for index, argument in enumerate(arguments)],
'argument_declarations_for_private_script':
argument_declarations_for_private_script(interface, method),
'conditional_string': v8_utilities.conditional_string(method),
'cpp_type': (v8_types.cpp_template_type('Nullable', idl_type.cpp_type)
if idl_type.is_explicit_nullable else idl_type.cpp_type),
'cpp_value': this_cpp_value,
'cpp_type_initializer': idl_type.cpp_type_initializer,
'custom_registration_extended_attributes':
CUSTOM_REGISTRATION_EXTENDED_ATTRIBUTES.intersection(
extended_attributes.iterkeys()),
'deprecate_as': v8_utilities.deprecate_as(method), # [DeprecateAs]
'exposed_test': v8_utilities.exposed(method, interface), # [Exposed]
# TODO(yukishiino): Retire has_custom_registration flag. Should be
# replaced with V8DOMConfiguration::PropertyLocationConfiguration.
'has_custom_registration':
is_static or
is_unforgeable(interface, method) or
v8_utilities.has_extended_attribute(
method, CUSTOM_REGISTRATION_EXTENDED_ATTRIBUTES),
'has_exception_state':
is_raises_exception or
is_check_security_for_frame or
is_check_security_for_window or
any(argument for argument in arguments
if (argument.idl_type.name == 'SerializedScriptValue' or
argument_conversion_needs_exception_state(method, argument))),
'idl_type': idl_type.base_type,
'is_call_with_execution_context': has_extended_attribute_value(method, 'CallWith', 'ExecutionContext'),
'is_call_with_script_arguments': is_call_with_script_arguments,
'is_call_with_script_state': is_call_with_script_state,
'is_call_with_this_value': is_call_with_this_value,
'is_check_security_for_frame': is_check_security_for_frame,
'is_check_security_for_node': is_check_security_for_node,
'is_check_security_for_window': is_check_security_for_window,
'is_custom': 'Custom' in extended_attributes and
not (is_custom_call_prologue or is_custom_call_epilogue),
'is_custom_call_prologue': is_custom_call_prologue,
'is_custom_call_epilogue': is_custom_call_epilogue,
#.........这里部分代码省略.........
示例12: attribute_context
def attribute_context(interface, 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_do_not_check_security = 'DoNotCheckSecurity' in extended_attributes
is_check_security_for_frame = (
has_extended_attribute_value(interface, 'CheckSecurity', 'Frame') and
not is_do_not_check_security)
is_check_security_for_node = (
has_extended_attribute_value(attribute, 'CheckSecurity', 'Node'))
is_check_security_for_window = (
has_extended_attribute_value(interface, 'CheckSecurity', 'Window') and
not is_do_not_check_security)
if is_check_security_for_frame or is_check_security_for_node or is_check_security_for_window:
includes.add('bindings/core/v8/BindingSecurity.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
# [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/dom/custom/CustomElementProcessingStack.h')
# [ImplementedInPrivateScript]
is_implemented_in_private_script = 'ImplementedInPrivateScript' in extended_attributes
if is_implemented_in_private_script:
includes.add('bindings/core/v8/PrivateScriptRunner.h')
includes.add('core/frame/LocalFrame.h')
includes.add('platform/ScriptForbiddenScope.h')
# [OnlyExposedToPrivateScript]
is_only_exposed_to_private_script = 'OnlyExposedToPrivateScript' in extended_attributes
# [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)
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('bindings/core/v8/V8HiddenValue.h')
context = {
'access_control_list': access_control_list(interface, attribute),
'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]
'argument_cpp_type': idl_type.cpp_type_args(used_as_rvalue_type=True),
'cached_attribute_validation_method': cached_attribute_validation_method,
'conditional_string': v8_utilities.conditional_string(attribute),
'constructor_type': constructor_type,
'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_custom_getter': has_custom_getter(attribute),
'has_custom_setter': has_custom_setter(attribute),
'has_setter': has_setter(attribute),
'idl_type': str(idl_type), # need trailing [] on array for Dictionary::ConversionContext::setConversionType
'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_check_security_for_frame': is_check_security_for_frame,
'is_check_security_for_node': is_check_security_for_node,
'is_check_security_for_window': is_check_security_for_window,
'is_custom_element_callbacks': is_custom_element_callbacks,
# TODO(yukishiino): Make all DOM attributes accessor-type properties.
'is_data_type_property': constructor_type or interface.name == 'Window' or interface.name == 'Location',
'is_getter_raises_exception': # [RaisesException]
'RaisesException' in extended_attributes and
extended_attributes['RaisesException'] in (None, 'Getter'),
'is_implemented_in_private_script': is_implemented_in_private_script,
'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_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_static': attribute.is_static,
'is_url': 'URL' in extended_attributes,
'is_unforgeable': is_unforgeable(interface, attribute),
'on_instance': v8_utilities.on_instance(interface, attribute),
#.........这里部分代码省略.........
示例13: method_context
def method_context(interface, method):
arguments = method.arguments
extended_attributes = method.extended_attributes
idl_type = method.idl_type
is_static = method.is_static
name = method.name
return_promise = idl_type.name == 'Promise'
idl_type.add_includes_for_type()
this_cpp_value = cpp_value(interface, method, len(arguments))
def function_template():
if is_static:
return 'functionTemplate'
if 'Unforgeable' in extended_attributes:
return 'instanceTemplate'
return 'prototypeTemplate'
is_implemented_in_private_script = 'ImplementedInPrivateScript' in extended_attributes
if is_implemented_in_private_script:
includes.add('bindings/core/v8/PrivateScriptRunner.h')
includes.add('core/frame/LocalFrame.h')
includes.add('platform/ScriptForbiddenScope.h')
# [OnlyExposedToPrivateScript]
is_only_exposed_to_private_script = 'OnlyExposedToPrivateScript' in extended_attributes
is_call_with_script_arguments = has_extended_attribute_value(method, 'CallWith', 'ScriptArguments')
if is_call_with_script_arguments:
includes.update(['bindings/core/v8/ScriptCallStackFactory.h',
'core/inspector/ScriptArguments.h'])
is_call_with_script_state = has_extended_attribute_value(method, 'CallWith', 'ScriptState')
if is_call_with_script_state:
includes.add('bindings/core/v8/ScriptState.h')
is_check_security_for_node = 'CheckSecurity' in extended_attributes
if is_check_security_for_node:
includes.add('bindings/core/v8/BindingSecurity.h')
is_custom_element_callbacks = 'CustomElementCallbacks' in extended_attributes
if is_custom_element_callbacks:
includes.add('core/dom/custom/CustomElementCallbackDispatcher.h')
is_check_security_for_frame = (
'CheckSecurity' in interface.extended_attributes and
'DoNotCheckSecurity' not in extended_attributes)
is_raises_exception = 'RaisesException' in extended_attributes
arguments_need_try_catch = (
any(argument_needs_try_catch(argument, return_promise)
for argument in arguments))
return {
'activity_logging_world_list': v8_utilities.activity_logging_world_list(method), # [ActivityLogging]
'arguments': [argument_context(interface, method, argument, index)
for index, argument in enumerate(arguments)],
'argument_declarations_for_private_script':
argument_declarations_for_private_script(interface, method),
'arguments_need_try_catch': arguments_need_try_catch,
'conditional_string': v8_utilities.conditional_string(method),
'cpp_type': (v8_types.cpp_template_type('Nullable', idl_type.cpp_type)
if idl_type.is_explicit_nullable else idl_type.cpp_type),
'cpp_value': this_cpp_value,
'cpp_type_initializer': idl_type.cpp_type_initializer,
'custom_registration_extended_attributes':
CUSTOM_REGISTRATION_EXTENDED_ATTRIBUTES.intersection(
extended_attributes.iterkeys()),
'deprecate_as': v8_utilities.deprecate_as(method), # [DeprecateAs]
'exposed_test': v8_utilities.exposed(method, interface), # [Exposed]
'function_template': function_template(),
'has_custom_registration': is_static or
v8_utilities.has_extended_attribute(
method, CUSTOM_REGISTRATION_EXTENDED_ATTRIBUTES),
'has_exception_state':
is_raises_exception or
is_check_security_for_frame or
interface.name == 'EventTarget' or # FIXME: merge with is_check_security_for_frame http://crbug.com/383699
any(argument for argument in arguments
if argument.idl_type.name == 'SerializedScriptValue' or
argument.idl_type.may_raise_exception_on_conversion),
'idl_type': idl_type.base_type,
'is_call_with_execution_context': has_extended_attribute_value(method, 'CallWith', 'ExecutionContext'),
'is_call_with_script_arguments': is_call_with_script_arguments,
'is_call_with_script_state': is_call_with_script_state,
'is_check_security_for_frame': is_check_security_for_frame,
'is_check_security_for_node': is_check_security_for_node,
'is_custom': 'Custom' in extended_attributes,
'is_custom_element_callbacks': is_custom_element_callbacks,
'is_do_not_check_security': 'DoNotCheckSecurity' in extended_attributes,
'is_do_not_check_signature': 'DoNotCheckSignature' in extended_attributes,
'is_explicit_nullable': idl_type.is_explicit_nullable,
'is_implemented_in_private_script': is_implemented_in_private_script,
'is_partial_interface_member':
'PartialInterfaceImplementedAs' in extended_attributes,
'is_per_world_bindings': 'PerWorldBindings' in extended_attributes,
'is_raises_exception': is_raises_exception,
'is_read_only': 'Unforgeable' in extended_attributes,
'is_static': is_static,
'is_variadic': arguments and arguments[-1].is_variadic,
'measure_as': v8_utilities.measure_as(method), # [MeasureAs]
'name': name,
'number_of_arguments': len(arguments),
#.........这里部分代码省略.........
示例14: generate_interface
def generate_interface(interface):
includes.clear()
includes.update(INTERFACE_CPP_INCLUDES)
header_includes = set(INTERFACE_H_INCLUDES)
parent_interface = interface.parent
if parent_interface:
header_includes.update(v8_types.includes_for_interface(parent_interface))
extended_attributes = interface.extended_attributes
is_audio_buffer = inherits_interface(interface.name, 'AudioBuffer')
if is_audio_buffer:
includes.add('modules/webaudio/AudioBuffer.h')
is_document = inherits_interface(interface.name, 'Document')
if is_document:
includes.update(['bindings/v8/ScriptController.h',
'bindings/v8/V8WindowShell.h',
'core/frame/LocalFrame.h'])
# [ActiveDOMObject]
is_active_dom_object = 'ActiveDOMObject' in extended_attributes
# [CheckSecurity]
is_check_security = 'CheckSecurity' in extended_attributes
if is_check_security:
includes.add('bindings/v8/BindingSecurity.h')
# [DependentLifetime]
is_dependent_lifetime = 'DependentLifetime' in extended_attributes
# [MeasureAs]
is_measure_as = 'MeasureAs' in extended_attributes
if is_measure_as:
includes.add('core/frame/UseCounter.h')
# [SetWrapperReferenceFrom]
reachable_node_function = extended_attributes.get('SetWrapperReferenceFrom')
if reachable_node_function:
includes.update(['bindings/v8/V8GCController.h',
'core/dom/Element.h'])
# [SetWrapperReferenceTo]
set_wrapper_reference_to_list = [{
'name': argument.name,
# FIXME: properly should be:
# 'cpp_type': argument.idl_type.cpp_type_args(used_as_argument=True),
# (if type is non-wrapper type like NodeFilter, normally RefPtr)
# Raw pointers faster though, and NodeFilter hacky anyway.
'cpp_type': argument.idl_type.implemented_as + '*',
'idl_type': argument.idl_type,
'v8_type': v8_types.v8_type(argument.idl_type.name),
} for argument in extended_attributes.get('SetWrapperReferenceTo', [])]
for set_wrapper_reference_to in set_wrapper_reference_to_list:
set_wrapper_reference_to['idl_type'].add_includes_for_type()
# [SpecialWrapFor]
if 'SpecialWrapFor' in extended_attributes:
special_wrap_for = extended_attributes['SpecialWrapFor'].split('|')
else:
special_wrap_for = []
for special_wrap_interface in special_wrap_for:
v8_types.add_includes_for_interface(special_wrap_interface)
# [WillBeGarbageCollected]
is_will_be_garbage_collected = 'WillBeGarbageCollected' in extended_attributes
# [Custom=Wrap], [SetWrapperReferenceFrom]
has_visit_dom_wrapper = (
has_extended_attribute_value(interface, 'Custom', 'VisitDOMWrapper') or
reachable_node_function or
set_wrapper_reference_to_list)
template_contents = {
'conditional_string': conditional_string(interface), # [Conditional]
'cpp_class': cpp_name(interface),
'has_custom_legacy_call_as_function': has_extended_attribute_value(interface, 'Custom', 'LegacyCallAsFunction'), # [Custom=LegacyCallAsFunction]
'has_custom_to_v8': has_extended_attribute_value(interface, 'Custom', 'ToV8'), # [Custom=ToV8]
'has_custom_wrap': has_extended_attribute_value(interface, 'Custom', 'Wrap'), # [Custom=Wrap]
'has_visit_dom_wrapper': has_visit_dom_wrapper,
'header_includes': header_includes,
'interface_name': interface.name,
'is_active_dom_object': is_active_dom_object,
'is_audio_buffer': is_audio_buffer,
'is_check_security': is_check_security,
'is_dependent_lifetime': is_dependent_lifetime,
'is_document': is_document,
'is_event_target': inherits_interface(interface.name, 'EventTarget'),
'is_exception': interface.is_exception,
'is_will_be_garbage_collected': is_will_be_garbage_collected,
'is_node': inherits_interface(interface.name, 'Node'),
'measure_as': v8_utilities.measure_as(interface), # [MeasureAs]
'parent_interface': parent_interface,
'pass_ref_ptr': 'PassRefPtrWillBeRawPtr'
if is_will_be_garbage_collected else 'PassRefPtr',
'reachable_node_function': reachable_node_function,
'ref_ptr': 'RefPtrWillBeRawPtr'
if is_will_be_garbage_collected else 'RefPtr',
'runtime_enabled_function': runtime_enabled_function_name(interface), # [RuntimeEnabled]
'set_wrapper_reference_to_list': set_wrapper_reference_to_list,
#.........这里部分代码省略.........
示例15: attribute_context
def attribute_context(interface, attribute):
idl_type = attribute.idl_type
base_idl_type = idl_type.base_type
extended_attributes = attribute.extended_attributes
idl_type.add_includes_for_type()
# [CheckSecurity]
is_check_security_for_node = 'CheckSecurity' in extended_attributes
if is_check_security_for_node:
includes.add('bindings/core/v8/BindingSecurity.h')
# [Custom]
has_custom_getter = ('Custom' in extended_attributes and
extended_attributes['Custom'] in [None, 'Getter'])
has_custom_setter = (not attribute.is_read_only and
'Custom' in extended_attributes and
extended_attributes['Custom'] in [None, 'Setter'])
# [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/dom/custom/CustomElementCallbackDispatcher.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)
# [TypeChecking]
has_type_checking_unrestricted = (
(has_extended_attribute_value(interface, 'TypeChecking', 'Unrestricted') or
has_extended_attribute_value(attribute, 'TypeChecking', 'Unrestricted')) and
idl_type.name in ('Float', 'Double'))
# [ImplementedInPrivateScript]
is_implemented_in_private_script = 'ImplementedInPrivateScript' in extended_attributes
if is_implemented_in_private_script:
includes.add('bindings/core/v8/PrivateScriptRunner.h')
includes.add('core/frame/LocalFrame.h')
if (base_idl_type == 'EventHandler' and
interface.name in ['Window', 'WorkerGlobalScope'] and
attribute.name == 'onerror'):
includes.add('bindings/core/v8/V8ErrorHandler.h')
# Nullable type where the corresponding C++ type supports a null value.
is_nullable_simple = idl_type.is_nullable and (
(idl_type.is_string_type or idl_type.is_wrapper_type) and
not idl_type.array_or_sequence_type)
context = {
'access_control_list': access_control_list(attribute),
'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_include_old_value_for_setter': 'LogPreviousValue' in extended_attributes, # [ActivityLogging]
'activity_logging_world_check': v8_utilities.activity_logging_world_check(attribute), # [ActivityLogging]
'argument_cpp_type': idl_type.cpp_type_args(used_as_argument=True),
'cached_attribute_validation_method': extended_attributes.get('CachedAttribute'),
'conditional_string': v8_utilities.conditional_string(attribute),
'constructor_type': idl_type.constructor_type_name
if is_constructor_attribute(attribute) else None,
'cpp_name': cpp_name(attribute),
'cpp_type': idl_type.cpp_type,
'deprecate_as': v8_utilities.deprecate_as(attribute), # [DeprecateAs]
'enum_validation_expression': idl_type.enum_validation_expression,
'has_custom_getter': has_custom_getter,
'has_custom_setter': has_custom_setter,
'has_type_checking_unrestricted': has_type_checking_unrestricted,
'idl_type': str(idl_type), # need trailing [] on array for Dictionary::ConversionContext::setConversionType
'is_call_with_execution_context': v8_utilities.has_extended_attribute_value(attribute, 'CallWith', 'ExecutionContext'),
'is_call_with_script_state': v8_utilities.has_extended_attribute_value(attribute, 'CallWith', 'ScriptState'),
'is_check_security_for_node': is_check_security_for_node,
'is_custom_element_callbacks': is_custom_element_callbacks,
'is_expose_js_accessors': 'ExposeJSAccessors' in extended_attributes,
'is_getter_raises_exception': # [RaisesException]
'RaisesException' in extended_attributes and
extended_attributes['RaisesException'] in (None, 'Getter'),
'is_implemented_in_private_script': is_implemented_in_private_script,
'is_initialized_by_event_constructor':
'InitializedByEventConstructor' in extended_attributes,
'is_keep_alive_for_gc': is_keep_alive_for_gc(interface, attribute),
'is_nullable': idl_type.is_nullable,
'is_nullable_simple': is_nullable_simple,
'is_partial_interface_member':
'PartialInterfaceImplementedAs' in extended_attributes,
'is_per_world_bindings': 'PerWorldBindings' in extended_attributes,
'is_read_only': attribute.is_read_only,
'is_reflect': is_reflect,
'is_replaceable': 'Replaceable' in attribute.extended_attributes,
'is_static': attribute.is_static,
'is_url': 'URL' in extended_attributes,
'is_unforgeable': 'Unforgeable' in extended_attributes,
'measure_as': v8_utilities.measure_as(attribute), # [MeasureAs]
'name': attribute.name,
'per_context_enabled_function': v8_utilities.per_context_enabled_function_name(attribute), # [PerContextEnabled]
'private_script_v8_value_to_local_cpp_value': idl_type.v8_value_to_local_cpp_value(
extended_attributes, 'v8Value', 'cppValue', isolate='scriptState->isolate()', used_in_private_script=True),
'property_attributes': property_attributes(attribute),
'put_forwards': 'PutForwards' in extended_attributes,
'reflect_empty': extended_attributes.get('ReflectEmpty'),
'reflect_invalid': extended_attributes.get('ReflectInvalid', ''),
'reflect_missing': extended_attributes.get('ReflectMissing'),
'reflect_only': extended_attributes['ReflectOnly'].split('|')
if 'ReflectOnly' in extended_attributes else None,
#.........这里部分代码省略.........