| OLD | NEW |
| 1 {##############################################################################} | 1 {##############################################################################} |
| 2 {% macro generate_method(method, world_suffix) %} | 2 {% macro generate_method(method, world_suffix) %} |
| 3 {% filter conditional(method.conditional_string) %} | 3 {% filter conditional(method.conditional_string) %} |
| 4 static void {{method.name}}{{method.overload_index}}Method{{world_suffix}}(const
v8::FunctionCallbackInfo<v8::Value>& info) | 4 static void {{method.name}}{{method.overload_index}}Method{{world_suffix}}(const
v8::FunctionCallbackInfo<v8::Value>& info) |
| 5 { | 5 { |
| 6 {% if method.is_raises_exception or method.is_check_security_for_frame or | 6 {% if method.is_raises_exception or method.is_check_security_for_frame or |
| 7 method.name in ['addEventListener', 'removeEventListener'] %} | 7 method.name in ['addEventListener', 'removeEventListener'] %} |
| 8 ExceptionState exceptionState(ExceptionState::ExecutionContext, "{{method.na
me}}", "{{interface_name}}", info.Holder(), info.GetIsolate()); | 8 ExceptionState exceptionState(ExceptionState::ExecutionContext, "{{method.na
me}}", "{{interface_name}}", info.Holder(), info.GetIsolate()); |
| 9 {% endif %} | 9 {% endif %} |
| 10 {% if method.name in ['addEventListener', 'removeEventListener'] %} | 10 {% if method.name in ['addEventListener', 'removeEventListener'] %} |
| (...skipping 92 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 103 throwError(exception, info.GetIsolate()); | 103 throwError(exception, info.GetIsolate()); |
| 104 return; | 104 return; |
| 105 } | 105 } |
| 106 {% endif %} | 106 {% endif %} |
| 107 {% if v8_set_return_value %}{{v8_set_return_value}};{% endif %}{# None for void
#} | 107 {% if v8_set_return_value %}{{v8_set_return_value}};{% endif %}{# None for void
#} |
| 108 {% endmacro %} | 108 {% endmacro %} |
| 109 | 109 |
| 110 | 110 |
| 111 {######################################} | 111 {######################################} |
| 112 {% macro generate_argument(method, argument) %} | 112 {% macro generate_argument(method, argument) %} |
| 113 {% macro throw_type_error(error_message) %} |
| 114 {% if method.is_constructor %} |
| 115 throwTypeError(ExceptionMessages::failedToConstruct("{{interface_name}}", "{{err
or_message}}"), info.GetIsolate()); |
| 116 {%- else %} |
| 117 throwTypeError(ExceptionMessages::failedToExecute("{{method.name}}", "{{interfac
e_name}}", "{{error_message}}"), info.GetIsolate()); |
| 118 {%- endif %} |
| 119 {% endmacro %} |
| 113 {% if argument.is_optional and not argument.has_default and | 120 {% if argument.is_optional and not argument.has_default and |
| 114 argument.idl_type != 'Dictionary' %} | 121 argument.idl_type != 'Dictionary' %} |
| 115 {# Optional arguments without a default value generate an early call with | 122 {# Optional arguments without a default value generate an early call with |
| 116 fewer arguments if they are omitted. | 123 fewer arguments if they are omitted. |
| 117 Optional Dictionary arguments default to empty dictionary. #} | 124 Optional Dictionary arguments default to empty dictionary. #} |
| 118 if (UNLIKELY(info.Length() <= {{argument.index}})) { | 125 if (UNLIKELY(info.Length() <= {{argument.index}})) { |
| 119 {{cpp_method_call(method, argument.v8_set_return_value, argument.cpp_value)
| indent}} | 126 {{cpp_method_call(method, argument.v8_set_return_value, argument.cpp_value)
| indent}} |
| 120 return; | 127 return; |
| 121 } | 128 } |
| 122 {% endif %} | 129 {% endif %} |
| 123 {% if method.is_strict_type_checking and argument.is_wrapper_type %} | 130 {% if method.is_strict_type_checking and argument.is_wrapper_type %} |
| 124 {# Type checking for wrapper interface types (if interface not implemented, | 131 {# Type checking for wrapper interface types (if interface not implemented, |
| 125 throw TypeError), per http://www.w3.org/TR/WebIDL/#es-interface #} | 132 throw TypeError), per http://www.w3.org/TR/WebIDL/#es-interface #} |
| 126 if (info.Length() > {{argument.index}} && !isUndefinedOrNull(info[{{argument.ind
ex}}]) && !V8{{argument.idl_type}}::hasInstance(info[{{argument.index}}], info.G
etIsolate(), worldType(info.GetIsolate()))) { | 133 if (info.Length() > {{argument.index}} && !isUndefinedOrNull(info[{{argument.ind
ex}}]) && !V8{{argument.idl_type}}::hasInstance(info[{{argument.index}}], info.G
etIsolate(), worldType(info.GetIsolate()))) { |
| 127 throwTypeError(ExceptionMessages::failedToExecute("{{method.name}}", "{{inte
rface_name}}", "parameter {{argument.index + 1}} is not of type '{{argument.idl_
type}}'."), info.GetIsolate()); | 134 {{throw_type_error("parameter %s is not of type '%s'." % |
| 135 (argument.index + 1, argument.idl_type))}} |
| 128 return; | 136 return; |
| 129 } | 137 } |
| 130 {% endif %} | 138 {% endif %} |
| 131 {% if argument.is_clamp %} | 139 {% if argument.is_clamp %} |
| 132 {# NaN is treated as 0: http://www.w3.org/TR/WebIDL/#es-type-mapping #} | 140 {# NaN is treated as 0: http://www.w3.org/TR/WebIDL/#es-type-mapping #} |
| 133 {{argument.cpp_type}} {{argument.name}} = 0; | 141 {{argument.cpp_type}} {{argument.name}} = 0; |
| 134 V8TRYCATCH_VOID(double, {{argument.name}}NativeValue, info[{{argument.index}}]->
NumberValue()); | 142 V8TRYCATCH_VOID(double, {{argument.name}}NativeValue, info[{{argument.index}}]->
NumberValue()); |
| 135 if (!std::isnan({{argument.name}}NativeValue)) | 143 if (!std::isnan({{argument.name}}NativeValue)) |
| 136 {# IDL type is used for clamping, for the right bounds, since different | 144 {# IDL type is used for clamping, for the right bounds, since different |
| 137 IDL integer types have same internal C++ type (int or unsigned) #} | 145 IDL integer types have same internal C++ type (int or unsigned) #} |
| 138 {{argument.name}} = clampTo<{{argument.idl_type}}>({{argument.name}}NativeVa
lue); | 146 {{argument.name}} = clampTo<{{argument.idl_type}}>({{argument.name}}NativeVa
lue); |
| 139 {% elif argument.idl_type == 'SerializedScriptValue' %} | 147 {% elif argument.idl_type == 'SerializedScriptValue' %} |
| 140 bool {{argument.name}}DidThrow = false; | 148 bool {{argument.name}}DidThrow = false; |
| 141 {{argument.cpp_type}} {{argument.name}} = SerializedScriptValue::create(info[{{a
rgument.index}}], 0, 0, {{argument.name}}DidThrow, info.GetIsolate()); | 149 {{argument.cpp_type}} {{argument.name}} = SerializedScriptValue::create(info[{{a
rgument.index}}], 0, 0, {{argument.name}}DidThrow, info.GetIsolate()); |
| 142 if ({{argument.name}}DidThrow) | 150 if ({{argument.name}}DidThrow) |
| 143 return; | 151 return; |
| 144 {% elif argument.is_variadic_wrapper_type %} | 152 {% elif argument.is_variadic_wrapper_type %} |
| 145 Vector<{{argument.cpp_type}} > {{argument.name}}; | 153 Vector<{{argument.cpp_type}} > {{argument.name}}; |
| 146 for (int i = {{argument.index}}; i < info.Length(); ++i) { | 154 for (int i = {{argument.index}}; i < info.Length(); ++i) { |
| 147 if (!V8{{argument.idl_type}}::hasInstance(info[i], info.GetIsolate(), worldT
ype(info.GetIsolate()))) { | 155 if (!V8{{argument.idl_type}}::hasInstance(info[i], info.GetIsolate(), worldT
ype(info.GetIsolate()))) { |
| 148 throwTypeError(ExceptionMessages::failedToExecute("{{method.name}}", "{{
interface_name}}", "parameter {{argument.index + 1}} is not of type '{{argument.
idl_type}}'."), info.GetIsolate()); | 156 {{throw_type_error("parameter %s is not of type '%s'." % |
| 157 (argument.index + 1, argument.idl_type))}} |
| 149 return; | 158 return; |
| 150 } | 159 } |
| 151 {{argument.name}}.append(V8{{argument.idl_type}}::toNative(v8::Handle<v8::Ob
ject>::Cast(info[i]))); | 160 {{argument.name}}.append(V8{{argument.idl_type}}::toNative(v8::Handle<v8::Ob
ject>::Cast(info[i]))); |
| 152 } | 161 } |
| 153 {% else %} | 162 {% else %} |
| 154 {{argument.v8_value_to_local_cpp_value}}; | 163 {{argument.v8_value_to_local_cpp_value}}; |
| 155 {% endif %} | 164 {% endif %} |
| 156 {% if argument.enum_validation_expression %} | 165 {% if argument.enum_validation_expression %} |
| 157 {# Methods throw on invalid enum values: http://www.w3.org/TR/WebIDL/#idl-enums
#} | 166 {# Methods throw on invalid enum values: http://www.w3.org/TR/WebIDL/#idl-enums
#} |
| 158 String string = {{argument.name}}; | 167 String string = {{argument.name}}; |
| 159 if (!({{argument.enum_validation_expression}})) { | 168 if (!({{argument.enum_validation_expression}})) { |
| 160 throwTypeError(ExceptionMessages::failedToExecute("{{method.name}}", "{{inte
rface_name}}", "parameter {{argument.index + 1}} ('" + string + "') is not a val
id enum value."), info.GetIsolate()); | 169 {{throw_type_error("parameter %s ('\" + string + \"') is not a valid enum va
lue." % (argument.index + 1))}} |
| 161 return; | 170 return; |
| 162 } | 171 } |
| 163 {% endif %} | 172 {% endif %} |
| 164 {% if argument.idl_type in ['Dictionary', 'Promise'] %} | 173 {% if argument.idl_type in ['Dictionary', 'Promise'] %} |
| 165 if (!{{argument.name}}.isUndefinedOrNull() && !{{argument.name}}.isObject()) { | 174 if (!{{argument.name}}.isUndefinedOrNull() && !{{argument.name}}.isObject()) { |
| 166 throwTypeError(ExceptionMessages::failedToExecute("{{method.name}}", "{{inte
rface_name}}", "parameter {{argument.index + 1}} ('{{argument.name}}') is not an
object."), info.GetIsolate()); | 175 {{throw_type_error("parameter %s ('%s') is not an object." % |
| 176 (argument.index + 1, argument.name))}} |
| 167 return; | 177 return; |
| 168 } | 178 } |
| 169 {% endif %} | 179 {% endif %} |
| 170 {% endmacro %} | 180 {% endmacro %} |
| 171 | 181 |
| 172 | 182 |
| 173 {##############################################################################} | 183 {##############################################################################} |
| 174 {% macro overload_resolution_method(overloads, world_suffix) %} | 184 {% macro overload_resolution_method(overloads, world_suffix) %} |
| 175 static void {{overloads.name}}Method{{world_suffix}}(const v8::FunctionCallbackI
nfo<v8::Value>& info) | 185 static void {{overloads.name}}Method{{world_suffix}}(const v8::FunctionCallbackI
nfo<v8::Value>& info) |
| 176 { | 186 { |
| (...skipping 87 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 264 v8SetReturnValue(info, privateTemplate->GetFunction()); | 274 v8SetReturnValue(info, privateTemplate->GetFunction()); |
| 265 } | 275 } |
| 266 | 276 |
| 267 static void {{method.name}}OriginSafeMethodGetterCallback{{world_suffix}}(v8::Lo
cal<v8::String>, const v8::PropertyCallbackInfo<v8::Value>& info) | 277 static void {{method.name}}OriginSafeMethodGetterCallback{{world_suffix}}(v8::Lo
cal<v8::String>, const v8::PropertyCallbackInfo<v8::Value>& info) |
| 268 { | 278 { |
| 269 TRACE_EVENT_SET_SAMPLING_STATE("Blink", "DOMGetter"); | 279 TRACE_EVENT_SET_SAMPLING_STATE("Blink", "DOMGetter"); |
| 270 {{cpp_class}}V8Internal::{{method.name}}OriginSafeMethodGetter{{world_suffix
}}(info); | 280 {{cpp_class}}V8Internal::{{method.name}}OriginSafeMethodGetter{{world_suffix
}}(info); |
| 271 TRACE_EVENT_SET_SAMPLING_STATE("V8", "Execution"); | 281 TRACE_EVENT_SET_SAMPLING_STATE("V8", "Execution"); |
| 272 } | 282 } |
| 273 {% endmacro %} | 283 {% endmacro %} |
| OLD | NEW |