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 {# Local variables #} | 6 {# Local variables #} |
7 {% if method.has_exception_state %} | 7 {% if method.has_exception_state %} |
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 {# Overloaded methods have length checked during overload resolution #} | 10 {# Overloaded methods have length checked during overload resolution #} |
(...skipping 73 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
84 | 84 |
85 {######################################} | 85 {######################################} |
86 {% macro generate_argument_var_declaration(argument) %} | 86 {% macro generate_argument_var_declaration(argument) %} |
87 {% if argument.is_callback_interface %} | 87 {% if argument.is_callback_interface %} |
88 {# FIXME: remove EventListener special case #} | 88 {# FIXME: remove EventListener special case #} |
89 {% if argument.idl_type == 'EventListener' %} | 89 {% if argument.idl_type == 'EventListener' %} |
90 RefPtr<{{argument.idl_type}}> {{argument.name}} | 90 RefPtr<{{argument.idl_type}}> {{argument.name}} |
91 {%- else %} | 91 {%- else %} |
92 OwnPtrWillBeRawPtr<{{argument.idl_type}}> {{argument.name}} = nullptr; | 92 OwnPtrWillBeRawPtr<{{argument.idl_type}}> {{argument.name}} = nullptr; |
93 {%- endif %}{# argument.idl_type == 'EventListener' #} | 93 {%- endif %}{# argument.idl_type == 'EventListener' #} |
94 {%- elif argument.is_clamp %}{# argument.is_callback_interface #} | |
95 {# NaN is treated as 0: http://www.w3.org/TR/WebIDL/#es-type-mapping #} | |
96 {{argument.cpp_type}} {{argument.name}} = 0 | |
97 {%- else %} | 94 {%- else %} |
98 {{argument.cpp_type}} {{argument.name}} | 95 {{argument.cpp_type}} {{argument.name}} |
99 {%- endif %} | 96 {%- endif %} |
100 {% endmacro %} | 97 {% endmacro %} |
101 | 98 |
102 | 99 |
103 {######################################} | 100 {######################################} |
104 {% macro generate_argument(method, argument, world_suffix) %} | 101 {% macro generate_argument(method, argument, world_suffix) %} |
105 {% if argument.is_optional and not argument.has_default and | 102 {% if argument.is_optional and not argument.has_default and |
106 argument.idl_type != 'Dictionary' and | 103 argument.idl_type != 'Dictionary' and |
(...skipping 48 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
155 {% else %}{# argument.is_optional #} | 152 {% else %}{# argument.is_optional #} |
156 if (info.Length() <= {{argument.index}} || !{% if argument.is_nullable %}(info[{
{argument.index}}]->IsFunction() || info[{{argument.index}}]->IsNull()){% else %
}info[{{argument.index}}]->IsFunction(){% endif %}) { | 153 if (info.Length() <= {{argument.index}} || !{% if argument.is_nullable %}(info[{
{argument.index}}]->IsFunction() || info[{{argument.index}}]->IsNull()){% else %
}info[{{argument.index}}]->IsFunction(){% endif %}) { |
157 {{throw_type_error(method, | 154 {{throw_type_error(method, |
158 '"The callback provided as parameter %s is not a function."' % | 155 '"The callback provided as parameter %s is not a function."' % |
159 (argument.index + 1)) | indent }} | 156 (argument.index + 1)) | indent }} |
160 return; | 157 return; |
161 } | 158 } |
162 {{argument.name}} = {% if argument.is_nullable %}info[{{argument.index}}]->IsNul
l() ? nullptr : {% endif %}V8{{argument.idl_type}}::create(v8::Handle<v8::Functi
on>::Cast(info[{{argument.index}}]), ScriptState::current(info.GetIsolate())); | 159 {{argument.name}} = {% if argument.is_nullable %}info[{{argument.index}}]->IsNul
l() ? nullptr : {% endif %}V8{{argument.idl_type}}::create(v8::Handle<v8::Functi
on>::Cast(info[{{argument.index}}]), ScriptState::current(info.GetIsolate())); |
163 {% endif %}{# argument.is_optional #} | 160 {% endif %}{# argument.is_optional #} |
164 {% endif %}{# argument.idl_type == 'EventListener' #} | 161 {% endif %}{# argument.idl_type == 'EventListener' #} |
165 {% elif argument.is_clamp %}{# argument.is_callback_interface #} | |
166 {# NaN is treated as 0: http://www.w3.org/TR/WebIDL/#es-type-mapping #} | |
167 double {{argument.name}}NativeValue; | |
168 {% if method.idl_type == 'Promise' %} | |
169 TONATIVE_VOID_PROMISE_INTERNAL({{argument.name}}NativeValue, info[{{argument.ind
ex}}]->NumberValue(), info); | |
170 {% else %} | |
171 TONATIVE_VOID_INTERNAL({{argument.name}}NativeValue, info[{{argument.index}}]->N
umberValue()); | |
172 {% endif %} | |
173 if (!std::isnan({{argument.name}}NativeValue)) | |
174 {# IDL type is used for clamping, for the right bounds, since different | |
175 IDL integer types have same internal C++ type (int or unsigned) #} | |
176 {{argument.name}} = clampTo<{{argument.idl_type}}>({{argument.name}}NativeVa
lue); | |
177 {% elif argument.idl_type == 'SerializedScriptValue' %} | 162 {% elif argument.idl_type == 'SerializedScriptValue' %} |
178 {{argument.name}} = SerializedScriptValue::create(info[{{argument.index}}], 0, 0
, exceptionState, info.GetIsolate()); | 163 {{argument.name}} = SerializedScriptValue::create(info[{{argument.index}}], 0, 0
, exceptionState, info.GetIsolate()); |
179 if (exceptionState.hadException()) { | 164 if (exceptionState.hadException()) { |
180 {{throw_from_exception_state(method)}}; | 165 {{throw_from_exception_state(method)}}; |
181 return; | 166 return; |
182 } | 167 } |
183 {% elif argument.is_variadic_wrapper_type %} | 168 {% elif argument.is_variadic_wrapper_type %} |
184 for (int i = {{argument.index}}; i < info.Length(); ++i) { | 169 for (int i = {{argument.index}}; i < info.Length(); ++i) { |
185 if (!V8{{argument.idl_type}}::hasInstance(info[i], info.GetIsolate())) { | 170 if (!V8{{argument.idl_type}}::hasInstance(info[i], info.GetIsolate())) { |
186 {{throw_type_error(method, '"parameter %s is not of type \'%s\'."' % | 171 {{throw_type_error(method, '"parameter %s is not of type \'%s\'."' % |
(...skipping 458 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
645 if method.is_per_world_bindings else '0' %} | 630 if method.is_per_world_bindings else '0' %} |
646 {% set property_attribute = | 631 {% set property_attribute = |
647 'static_cast<v8::PropertyAttribute>(%s)' % ' | '.join(method.property_attribut
es) | 632 'static_cast<v8::PropertyAttribute>(%s)' % ' | '.join(method.property_attribut
es) |
648 if method.property_attributes else 'v8::None' %} | 633 if method.property_attributes else 'v8::None' %} |
649 {% set only_exposed_to_private_script = 'V8DOMConfiguration::OnlyExposedToPrivat
eScript' if method.only_exposed_to_private_script else 'V8DOMConfiguration::Expo
sedToAllScripts' %} | 634 {% set only_exposed_to_private_script = 'V8DOMConfiguration::OnlyExposedToPrivat
eScript' if method.only_exposed_to_private_script else 'V8DOMConfiguration::Expo
sedToAllScripts' %} |
650 static const V8DOMConfiguration::MethodConfiguration {{method.name}}MethodConfig
uration = { | 635 static const V8DOMConfiguration::MethodConfiguration {{method.name}}MethodConfig
uration = { |
651 "{{method.name}}", {{method_callback}}, {{method_callback_for_main_world}},
{{method.length}}, {{only_exposed_to_private_script}}, | 636 "{{method.name}}", {{method_callback}}, {{method_callback_for_main_world}},
{{method.length}}, {{only_exposed_to_private_script}}, |
652 }; | 637 }; |
653 V8DOMConfiguration::installMethod({{method.function_template}}, {{method.signatu
re}}, {{property_attribute}}, {{method.name}}MethodConfiguration, isolate); | 638 V8DOMConfiguration::installMethod({{method.function_template}}, {{method.signatu
re}}, {{property_attribute}}, {{method.name}}MethodConfiguration, isolate); |
654 {%- endmacro %} | 639 {%- endmacro %} |
OLD | NEW |