def argument_context(interface, method, argument, index, is_visible=True): extended_attributes = argument.extended_attributes idl_type = argument.idl_type if is_visible: idl_type.add_includes_for_type(extended_attributes) this_cpp_value = cpp_value(interface, method, index) is_variadic_wrapper_type = argument.is_variadic and idl_type.is_wrapper_type # [TypeChecking=Interface] / [LegacyInterfaceTypeChecking] has_type_checking_interface = ( not is_legacy_interface_type_checking(interface, method) and idl_type.is_wrapper_type) if ('ImplementedInPrivateScript' in extended_attributes and not idl_type.is_wrapper_type and not idl_type.is_basic_type): raise Exception('Private scripts supports only primitive types and DOM wrappers.') set_default_value = argument.set_default_value this_cpp_type = idl_type.cpp_type_args(extended_attributes=extended_attributes, raw_type=True, used_as_variadic_argument=argument.is_variadic) return { 'cpp_type': ( v8_types.cpp_template_type('Nullable', this_cpp_type) if idl_type.is_explicit_nullable and not argument.is_variadic else this_cpp_type), 'cpp_value': this_cpp_value, # FIXME: check that the default value's type is compatible with the argument's 'set_default_value': set_default_value, 'enum_type': idl_type.enum_type, 'enum_values': idl_type.enum_values, 'handle': '%sHandle' % argument.name, # FIXME: remove once [Default] removed and just use argument.default_value 'has_default': 'Default' in extended_attributes or set_default_value, 'has_type_checking_interface': has_type_checking_interface, # Dictionary is special-cased, but arrays and sequences shouldn't be 'idl_type': idl_type.base_type, 'idl_type_object': idl_type, 'index': index, 'is_callback_function': idl_type.is_callback_function, 'is_callback_interface': idl_type.is_callback_interface, # FIXME: Remove generic 'Dictionary' special-casing 'is_dictionary': idl_type.is_dictionary or idl_type.base_type == 'Dictionary', 'is_explicit_nullable': idl_type.is_explicit_nullable, 'is_nullable': idl_type.is_nullable, 'is_optional': argument.is_optional, 'is_variadic': argument.is_variadic, 'is_variadic_wrapper_type': is_variadic_wrapper_type, 'is_wrapper_type': idl_type.is_wrapper_type, 'name': argument.name, 'private_script_cpp_value_to_v8_value': idl_type.cpp_value_to_v8_value( argument.name, isolate='scriptState->isolate()', creation_context='scriptState->context()->Global()'), 'use_permissive_dictionary_conversion': 'PermissiveDictionaryConversion' in extended_attributes, 'v8_set_return_value': v8_set_return_value(interface.name, method, this_cpp_value), 'v8_set_return_value_for_main_world': v8_set_return_value(interface.name, method, this_cpp_value, for_main_world=True), 'v8_value_to_local_cpp_value': v8_value_to_local_cpp_value(method, argument, index), }
def argument_context(interface, method, argument, index, is_visible=True): extended_attributes = argument.extended_attributes idl_type = argument.idl_type if is_visible: idl_type.add_includes_for_type(extended_attributes) this_cpp_value = cpp_value(interface, method, index) is_variadic_wrapper_type = argument.is_variadic and idl_type.is_wrapper_type # [LegacyInterfaceTypeChecking] has_type_checking_interface = ( not is_legacy_interface_type_checking(interface, method) and idl_type.is_wrapper_type) set_default_value = argument.set_default_value this_cpp_type = idl_type.cpp_type_args(extended_attributes=extended_attributes, raw_type=True, used_as_variadic_argument=argument.is_variadic) context = { 'cpp_type': ( v8_types.cpp_template_type('Nullable', this_cpp_type) if idl_type.is_explicit_nullable and not argument.is_variadic else this_cpp_type), 'cpp_value': this_cpp_value, # FIXME: check that the default value's type is compatible with the argument's 'set_default_value': set_default_value, 'enum_type': idl_type.enum_type, 'enum_values': idl_type.enum_values, 'handle': '%sHandle' % argument.name, # FIXME: remove once [Default] removed and just use argument.default_value 'has_default': 'Default' in extended_attributes or set_default_value, 'has_type_checking_interface': has_type_checking_interface, # Dictionary is special-cased, but arrays and sequences shouldn't be 'idl_type': idl_type.base_type, 'idl_type_object': idl_type, 'index': index, 'is_callback_function': idl_type.is_callback_function, 'is_callback_interface': idl_type.is_callback_interface, # FIXME: Remove generic 'Dictionary' special-casing 'is_dictionary': idl_type.is_dictionary or idl_type.base_type == 'Dictionary', 'is_explicit_nullable': idl_type.is_explicit_nullable, 'is_nullable': idl_type.is_nullable, 'is_optional': argument.is_optional, 'is_variadic': argument.is_variadic, 'is_variadic_wrapper_type': is_variadic_wrapper_type, 'is_wrapper_type': idl_type.is_wrapper_type, 'name': argument.name, 'use_permissive_dictionary_conversion': 'PermissiveDictionaryConversion' in extended_attributes, 'v8_set_return_value': v8_set_return_value(interface.name, method, this_cpp_value), 'v8_set_return_value_for_main_world': v8_set_return_value(interface.name, method, this_cpp_value, for_main_world=True), 'v8_value_to_local_cpp_value': v8_value_to_local_cpp_value(interface.name, method, argument, index), } context.update({ 'is_optional_without_default_value': context['is_optional'] and not context['has_default'] and not context['is_dictionary'] and not context['is_callback_interface'], }) return context
def argument_context(interface, method, argument, index, is_visible=True): extended_attributes = argument.extended_attributes idl_type = argument.idl_type if is_visible: idl_type.add_includes_for_type(extended_attributes) this_cpp_value = cpp_value(interface, method, index) is_variadic_wrapper_type = argument.is_variadic and idl_type.is_wrapper_type # [LegacyInterfaceTypeChecking] has_type_checking_interface = ( not is_legacy_interface_type_checking(interface, method) and idl_type.is_wrapper_type) set_default_value = argument.set_default_value this_cpp_type = idl_type.cpp_type_args(extended_attributes=extended_attributes, raw_type=True, used_as_variadic_argument=argument.is_variadic) context = { 'cpp_type': ( v8_types.cpp_template_type('Nullable', this_cpp_type) if idl_type.is_explicit_nullable and not argument.is_variadic else this_cpp_type), 'cpp_value': this_cpp_value, # FIXME: check that the default value's type is compatible with the argument's 'set_default_value': set_default_value, 'enum_type': idl_type.enum_type, 'enum_values': idl_type.enum_values, 'handle': '%sHandle' % argument.name, # FIXME: remove once [Default] removed and just use argument.default_value 'has_default': 'Default' in extended_attributes or set_default_value, 'has_type_checking_interface': has_type_checking_interface, # Dictionary is special-cased, but arrays and sequences shouldn't be 'idl_type': idl_type.base_type, 'idl_type_object': idl_type, 'index': index, 'is_callback_function': idl_type.is_callback_function, 'is_callback_interface': idl_type.is_callback_interface, # FIXME: Remove generic 'Dictionary' special-casing 'is_dictionary': idl_type.is_dictionary or idl_type.base_type == 'Dictionary', 'is_explicit_nullable': idl_type.is_explicit_nullable, 'is_nullable': idl_type.is_nullable, 'is_optional': argument.is_optional, 'is_variadic': argument.is_variadic, 'is_variadic_wrapper_type': is_variadic_wrapper_type, 'is_wrapper_type': idl_type.is_wrapper_type, 'name': argument.name, 'use_permissive_dictionary_conversion': 'PermissiveDictionaryConversion' in extended_attributes, 'v8_set_return_value': v8_set_return_value(interface.name, method, this_cpp_value), 'v8_set_return_value_for_main_world': v8_set_return_value(interface.name, method, this_cpp_value, for_main_world=True), 'v8_value_to_local_cpp_value': v8_value_to_local_cpp_value(interface.name, method, argument, index), } context.update({ 'is_optional_without_default_value': context['is_optional'] and not context['has_default'] and not context['is_dictionary'] and not context['is_callback_interface'], }) return context
def setter_context(interface, attribute, interfaces, context): if 'PutForwards' in attribute.extended_attributes: # Make sure the target interface and attribute exist. target_interface_name = attribute.idl_type.base_type target_attribute_name = attribute.extended_attributes['PutForwards'] interface = interfaces[target_interface_name] try: next(candidate for candidate in interface.attributes if candidate.name == target_attribute_name) except StopIteration: raise Exception('[PutForward] target not found:\n' 'Attribute "%s" is not present in interface "%s"' % (target_attribute_name, target_interface_name)) context['target_attribute_name'] = target_attribute_name return if ('Replaceable' in attribute.extended_attributes): # Create the property, and early-return if an exception is thrown. # Subsequent cleanup code may not be prepared to handle a pending # exception. context['cpp_setter'] = ( 'if (info.Holder()->CreateDataProperty(' + 'info.GetIsolate()->GetCurrentContext(), property_name, v8_value).IsNothing())' + '\n return') return extended_attributes = attribute.extended_attributes idl_type = attribute.idl_type # [RaisesException], [RaisesException=Setter] is_setter_raises_exception = ('RaisesException' in extended_attributes and extended_attributes['RaisesException'] in [None, 'Setter']) # [LegacyInterfaceTypeChecking] has_type_checking_interface = ( not is_legacy_interface_type_checking(interface, attribute) and idl_type.is_wrapper_type) context.update({ 'has_setter_exception_state': is_setter_raises_exception or has_type_checking_interface or idl_type.v8_conversion_needs_exception_state, 'has_type_checking_interface': has_type_checking_interface, 'is_setter_call_with_execution_context': has_extended_attribute_value(attribute, 'SetterCallWith', 'ExecutionContext'), 'is_setter_call_with_script_state': has_extended_attribute_value(attribute, 'SetterCallWith', 'ScriptState'), 'is_setter_raises_exception': is_setter_raises_exception, 'v8_value_to_local_cpp_value': idl_type.v8_value_to_local_cpp_value(extended_attributes, 'v8_value', 'cpp_value'), }) # setter_expression() depends on context values we set above. context['cpp_setter'] = setter_expression(interface, attribute, context)
def argument_context(interface, method, argument, index, is_visible=True): extended_attributes = argument.extended_attributes idl_type = argument.idl_type if is_visible: idl_type.add_includes_for_type(extended_attributes) this_cpp_value = cpp_value(interface, method, index) is_variadic_wrapper_type = argument.is_variadic and idl_type.is_wrapper_type # [TypeChecking=Interface] / [LegacyInterfaceTypeChecking] has_type_checking_interface = ( not is_legacy_interface_type_checking(interface, method) and idl_type.is_wrapper_type) if ('ImplementedInPrivateScript' in extended_attributes and not idl_type.is_wrapper_type and not idl_type.is_basic_type): raise Exception('Private scripts supports only primitive types and DOM wrappers.') set_default_value = argument.set_default_value this_cpp_type = idl_type.cpp_type_args(extended_attributes=extended_attributes, raw_type=True, used_as_variadic_argument=argument.is_variadic) return { 'cpp_type': ( v8_types.cpp_template_type('Nullable', this_cpp_type) if idl_type.is_explicit_nullable and not argument.is_variadic else this_cpp_type), 'cpp_value': this_cpp_value, # FIXME: check that the default value's type is compatible with the argument's 'set_default_value': set_default_value, 'enum_type': idl_type.enum_type, 'enum_values': idl_type.enum_values, 'handle': '%sHandle' % argument.name, # FIXME: remove once [Default] removed and just use argument.default_value 'has_default': 'Default' in extended_attributes or set_default_value, 'has_type_checking_interface': has_type_checking_interface, # Dictionary is special-cased, but arrays and sequences shouldn't be 'idl_type': idl_type.base_type, 'idl_type_object': idl_type, 'index': index, 'is_callback_function': idl_type.is_callback_function, 'is_callback_interface': idl_type.is_callback_interface, # FIXME: Remove generic 'Dictionary' special-casing 'is_dictionary': idl_type.is_dictionary or idl_type.base_type == 'Dictionary', 'is_explicit_nullable': idl_type.is_explicit_nullable, 'is_nullable': idl_type.is_nullable, 'is_optional': argument.is_optional, 'is_variadic': argument.is_variadic, 'is_variadic_wrapper_type': is_variadic_wrapper_type, 'is_wrapper_type': idl_type.is_wrapper_type, 'name': argument.name, 'private_script_cpp_value_to_v8_value': idl_type.cpp_value_to_v8_value( argument.name, isolate='scriptState->isolate()', creation_context='scriptState->context()->Global()'), 'use_permissive_dictionary_conversion': 'PermissiveDictionaryConversion' in extended_attributes, 'v8_set_return_value': v8_set_return_value(interface.name, method, this_cpp_value), 'v8_set_return_value_for_main_world': v8_set_return_value(interface.name, method, this_cpp_value, for_main_world=True), 'v8_value_to_local_cpp_value': v8_value_to_local_cpp_value(method, argument, index), }
def setter_context(interface, attribute, context): if 'PutForwards' in attribute.extended_attributes: # Use target interface and attribute in place of original interface and # attribute from this point onwards. target_interface_name = attribute.idl_type.base_type target_attribute_name = attribute.extended_attributes['PutForwards'] interface = interfaces[target_interface_name] try: attribute = next(candidate for candidate in interface.attributes if candidate.name == target_attribute_name) except StopIteration: raise Exception('[PutForward] target not found:\n' 'Attribute "%s" is not present in interface "%s"' % (target_attribute_name, target_interface_name)) if ('Replaceable' in attribute.extended_attributes or is_constructor_attribute(attribute)): context[ 'cpp_setter'] = '%sCreateDataProperty(propertyName, v8Value, info)' % cpp_name( interface) return extended_attributes = attribute.extended_attributes idl_type = attribute.idl_type # [RaisesException], [RaisesException=Setter] is_setter_raises_exception = ('RaisesException' in extended_attributes and extended_attributes['RaisesException'] in [None, 'Setter']) # [LegacyInterfaceTypeChecking] has_type_checking_interface = ( not is_legacy_interface_type_checking(interface, attribute) and idl_type.is_wrapper_type) context.update({ 'has_setter_exception_state': is_setter_raises_exception or has_type_checking_interface or idl_type.v8_conversion_needs_exception_state, 'has_type_checking_interface': has_type_checking_interface, 'is_setter_call_with_execution_context': has_extended_attribute_value(attribute, 'SetterCallWith', 'ExecutionContext'), 'is_setter_raises_exception': is_setter_raises_exception, 'private_script_cpp_value_to_v8_value': idl_type.cpp_value_to_v8_value( 'cppValue', isolate='scriptState->isolate()', creation_context='scriptState->context()->Global()'), 'v8_value_to_local_cpp_value': idl_type.v8_value_to_local_cpp_value(extended_attributes, 'v8Value', 'cppValue'), }) # setter_expression() depends on context values we set above. context['cpp_setter'] = setter_expression(interface, attribute, context)
def setter_context(interface, attribute, interfaces, context): if "PutForwards" in attribute.extended_attributes: # Use target interface and attribute in place of original interface and # attribute from this point onwards. target_interface_name = attribute.idl_type.base_type target_attribute_name = attribute.extended_attributes["PutForwards"] interface = interfaces[target_interface_name] try: attribute = next(candidate for candidate in interface.attributes if candidate.name == target_attribute_name) except StopIteration: raise Exception( "[PutForward] target not found:\n" 'Attribute "%s" is not present in interface "%s"' % (target_attribute_name, target_interface_name) ) if "Replaceable" in attribute.extended_attributes: context[ "cpp_setter" ] = "v8CallBoolean(info.Holder()->CreateDataProperty(info.GetIsolate()->GetCurrentContext(), propertyName, v8Value))" return extended_attributes = attribute.extended_attributes idl_type = attribute.idl_type # [RaisesException], [RaisesException=Setter] is_setter_raises_exception = "RaisesException" in extended_attributes and extended_attributes[ "RaisesException" ] in [None, "Setter"] # [LegacyInterfaceTypeChecking] has_type_checking_interface = ( not is_legacy_interface_type_checking(interface, attribute) and idl_type.is_wrapper_type ) context.update( { "has_setter_exception_state": is_setter_raises_exception or has_type_checking_interface or idl_type.v8_conversion_needs_exception_state, "has_type_checking_interface": has_type_checking_interface, "is_setter_call_with_execution_context": has_extended_attribute_value( attribute, "SetterCallWith", "ExecutionContext" ), "is_setter_raises_exception": is_setter_raises_exception, "private_script_cpp_value_to_v8_value": idl_type.cpp_value_to_v8_value( "cppValue", isolate="scriptState->isolate()", creation_context="scriptState->context()->Global()" ), "v8_value_to_local_cpp_value": idl_type.v8_value_to_local_cpp_value( extended_attributes, "v8Value", "cppValue" ), } ) # setter_expression() depends on context values we set above. context["cpp_setter"] = setter_expression(interface, attribute, context)
def setter_context(interface, attribute, context): if 'PutForwards' in attribute.extended_attributes: # Use target interface and attribute in place of original interface and # attribute from this point onwards. target_interface_name = attribute.idl_type.base_type target_attribute_name = attribute.extended_attributes['PutForwards'] interface = interfaces[target_interface_name] try: attribute = next(candidate for candidate in interface.attributes if candidate.name == target_attribute_name) except StopIteration: raise Exception('[PutForward] target not found:\n' 'Attribute "%s" is not present in interface "%s"' % (target_attribute_name, target_interface_name)) if ('Replaceable' in attribute.extended_attributes or is_constructor_attribute(attribute)): context['cpp_setter'] = '%sCreateDataProperty(propertyName, v8Value, info)' % cpp_name(interface) return extended_attributes = attribute.extended_attributes idl_type = attribute.idl_type # [RaisesException], [RaisesException=Setter] is_setter_raises_exception = ( 'RaisesException' in extended_attributes and extended_attributes['RaisesException'] in [None, 'Setter']) # [TypeChecking=Interface] / [LegacyInterfaceTypeChecking] has_type_checking_interface = ( not is_legacy_interface_type_checking(interface, attribute) and idl_type.is_wrapper_type) context.update({ 'has_setter_exception_state': is_setter_raises_exception or has_type_checking_interface or idl_type.v8_conversion_needs_exception_state, 'has_type_checking_interface': has_type_checking_interface, 'is_setter_call_with_execution_context': has_extended_attribute_value( attribute, 'SetterCallWith', 'ExecutionContext'), 'is_setter_raises_exception': is_setter_raises_exception, 'private_script_cpp_value_to_v8_value': idl_type.cpp_value_to_v8_value( 'cppValue', isolate='scriptState->isolate()', creation_context='scriptState->context()->Global()'), 'v8_value_to_local_cpp_value': idl_type.v8_value_to_local_cpp_value( extended_attributes, 'v8Value', 'cppValue'), }) # setter_expression() depends on context values we set above. context['cpp_setter'] = setter_expression(interface, attribute, context)
def setter_context(interface, attribute, interfaces, context): if 'PutForwards' in attribute.extended_attributes: # Make sure the target interface and attribute exist. target_interface_name = attribute.idl_type.base_type target_attribute_name = attribute.extended_attributes['PutForwards'] interface = interfaces[target_interface_name] try: next(candidate for candidate in interface.attributes if candidate.name == target_attribute_name) except StopIteration: raise Exception('[PutForward] target not found:\n' 'Attribute "%s" is not present in interface "%s"' % (target_attribute_name, target_interface_name)) context['target_attribute_name'] = target_attribute_name return if ('Replaceable' in attribute.extended_attributes): context['cpp_setter'] = ( 'V8CallBoolean(info.Holder()->CreateDataProperty(' + 'info.GetIsolate()->GetCurrentContext(), propertyName, v8Value))') return extended_attributes = attribute.extended_attributes idl_type = attribute.idl_type # [RaisesException], [RaisesException=Setter] is_setter_raises_exception = ( 'RaisesException' in extended_attributes and extended_attributes['RaisesException'] in [None, 'Setter']) # [LegacyInterfaceTypeChecking] has_type_checking_interface = ( not is_legacy_interface_type_checking(interface, attribute) and idl_type.is_wrapper_type) context.update({ 'has_setter_exception_state': is_setter_raises_exception or has_type_checking_interface or idl_type.v8_conversion_needs_exception_state, 'has_type_checking_interface': has_type_checking_interface, 'is_setter_call_with_execution_context': has_extended_attribute_value( attribute, 'SetterCallWith', 'ExecutionContext'), 'is_setter_raises_exception': is_setter_raises_exception, 'v8_value_to_local_cpp_value': idl_type.v8_value_to_local_cpp_value( extended_attributes, 'v8Value', 'cppValue'), }) # setter_expression() depends on context values we set above. context['cpp_setter'] = setter_expression(interface, attribute, context)
def argument_context(interface, method, argument, index, is_visible=True): extended_attributes = argument.extended_attributes idl_type = argument.idl_type if is_visible: idl_type.add_includes_for_type(extended_attributes) this_cpp_value = cpp_value(interface, method, index) is_variadic_wrapper_type = argument.is_variadic and idl_type.is_wrapper_type # [LegacyInterfaceTypeChecking] has_type_checking_interface = not is_legacy_interface_type_checking(interface, method) and idl_type.is_wrapper_type if ( "ImplementedInPrivateScript" in extended_attributes and not idl_type.is_wrapper_type and not idl_type.is_basic_type ): raise Exception("Private scripts supports only primitive types and DOM wrappers.") set_default_value = argument.set_default_value this_cpp_type = idl_type.cpp_type_args( extended_attributes=extended_attributes, raw_type=True, used_as_variadic_argument=argument.is_variadic ) context = { "cpp_type": ( v8_types.cpp_template_type("Nullable", this_cpp_type) if idl_type.is_explicit_nullable and not argument.is_variadic else this_cpp_type ), "cpp_value": this_cpp_value, # FIXME: check that the default value's type is compatible with the argument's "set_default_value": set_default_value, "enum_type": idl_type.enum_type, "enum_values": idl_type.enum_values, "handle": "%sHandle" % argument.name, # FIXME: remove once [Default] removed and just use argument.default_value "has_default": "Default" in extended_attributes or set_default_value, "has_type_checking_interface": has_type_checking_interface, # Dictionary is special-cased, but arrays and sequences shouldn't be "idl_type": idl_type.base_type, "idl_type_object": idl_type, "index": index, "is_callback_function": idl_type.is_callback_function, "is_callback_interface": idl_type.is_callback_interface, # FIXME: Remove generic 'Dictionary' special-casing "is_dictionary": idl_type.is_dictionary or idl_type.base_type == "Dictionary", "is_explicit_nullable": idl_type.is_explicit_nullable, "is_nullable": idl_type.is_nullable, "is_optional": argument.is_optional, "is_variadic": argument.is_variadic, "is_variadic_wrapper_type": is_variadic_wrapper_type, "is_wrapper_type": idl_type.is_wrapper_type, "name": argument.name, "private_script_cpp_value_to_v8_value": idl_type.cpp_value_to_v8_value( argument.name, isolate="scriptState->isolate()", creation_context="scriptState->context()->Global()" ), "use_permissive_dictionary_conversion": "PermissiveDictionaryConversion" in extended_attributes, "v8_set_return_value": v8_set_return_value(interface.name, method, this_cpp_value), "v8_set_return_value_for_main_world": v8_set_return_value( interface.name, method, this_cpp_value, for_main_world=True ), "v8_value_to_local_cpp_value": v8_value_to_local_cpp_value(method, argument, index), } context.update( { "is_optional_without_default_value": context["is_optional"] and not context["has_default"] and not context["is_dictionary"] and not context["is_callback_interface"] } ) return context