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 66 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
77 {% else %} | 77 {% else %} |
78 {{generate_argument(method, argument, world_suffix) | indent}} | 78 {{generate_argument(method, argument, world_suffix) | indent}} |
79 {% endif %} | 79 {% endif %} |
80 {% endfor %} | 80 {% endfor %} |
81 } | 81 } |
82 {% endmacro %} | 82 {% endmacro %} |
83 | 83 |
84 | 84 |
85 {######################################} | 85 {######################################} |
86 {% macro generate_argument_var_declaration(argument) %} | 86 {% macro generate_argument_var_declaration(argument) %} |
87 {% if argument.is_callback_interface %} | |
88 {# FIXME: remove EventListener special case #} | 87 {# FIXME: remove EventListener special case #} |
89 {% if argument.idl_type == 'EventListener' %} | 88 {% if argument.idl_type == 'EventListener' %} |
90 RefPtr<{{argument.idl_type}}> {{argument.name}} | 89 RefPtr<{{argument.idl_type}}> {{argument.name}} |
91 {%- else %} | 90 {%- else %} |
92 OwnPtrWillBeRawPtr<{{argument.idl_type}}> {{argument.name}} = nullptr; | 91 {{argument.cpp_type}} {{argument.name}} |
93 {%- endif %}{# argument.idl_type == 'EventListener' #} | 92 {%- endif %}{# argument.idl_type == 'EventListener' #} |
94 {%- else %} | |
95 {{argument.cpp_type}} {{argument.name}} | |
96 {%- endif %} | |
97 {% endmacro %} | 93 {% endmacro %} |
98 | 94 |
99 | 95 |
100 {######################################} | 96 {######################################} |
101 {% macro generate_argument(method, argument, world_suffix) %} | 97 {% macro generate_argument(method, argument, world_suffix) %} |
102 {% if argument.is_optional and not argument.has_default and | 98 {% if argument.is_optional and not argument.has_default and |
103 not argument.is_dictionary and | 99 not argument.is_dictionary and |
104 not argument.is_callback_interface %} | 100 not argument.is_callback_interface %} |
105 {# Optional arguments without a default value generate an early call with | 101 {# Optional arguments without a default value generate an early call with |
106 fewer arguments if they are omitted. | 102 fewer arguments if they are omitted. |
(...skipping 26 matching lines...) Expand all Loading... |
133 {% if argument.idl_type == 'EventListener' %} | 129 {% if argument.idl_type == 'EventListener' %} |
134 {% if method.name == 'removeEventListener' or method.name == 'removeListener' %} | 130 {% if method.name == 'removeEventListener' or method.name == 'removeListener' %} |
135 {{argument.name}} = V8EventListenerList::getEventListener(ScriptState::current(i
nfo.GetIsolate()), info[{{argument.index}}], false, ListenerFindOnly); | 131 {{argument.name}} = V8EventListenerList::getEventListener(ScriptState::current(i
nfo.GetIsolate()), info[{{argument.index}}], false, ListenerFindOnly); |
136 {% else %}{# method.name == 'addEventListener' #} | 132 {% else %}{# method.name == 'addEventListener' #} |
137 {{argument.name}} = V8EventListenerList::getEventListener(ScriptState::current(i
nfo.GetIsolate()), info[{{argument.index}}], false, ListenerFindOrCreate); | 133 {{argument.name}} = V8EventListenerList::getEventListener(ScriptState::current(i
nfo.GetIsolate()), info[{{argument.index}}], false, ListenerFindOrCreate); |
138 {% endif %}{# method.name #} | 134 {% endif %}{# method.name #} |
139 {% else %}{# argument.idl_type == 'EventListener' #} | 135 {% else %}{# argument.idl_type == 'EventListener' #} |
140 {# Callback functions must be functions: | 136 {# Callback functions must be functions: |
141 http://www.w3.org/TR/WebIDL/#es-callback-function #} | 137 http://www.w3.org/TR/WebIDL/#es-callback-function #} |
142 {% if argument.is_optional %} | 138 {% if argument.is_optional %} |
143 if (info.Length() > {{argument.index}} && !isUndefinedOrNull(info[{{argument.ind
ex}}])) { | 139 if (!isUndefinedOrNull(info[{{argument.index}}])) { |
144 if (!info[{{argument.index}}]->IsFunction()) { | 140 if (!info[{{argument.index}}]->IsFunction()) { |
145 {{throw_type_error(method, | 141 {{throw_type_error(method, |
146 '"The callback provided as parameter %s is not a function."' % | 142 '"The callback provided as parameter %s is not a function."' % |
147 (argument.index + 1)) | indent(8)}} | 143 (argument.index + 1)) | indent(8)}} |
148 return; | 144 return; |
149 } | 145 } |
150 {{argument.name}} = V8{{argument.idl_type}}::create(v8::Handle<v8::Function>
::Cast(info[{{argument.index}}]), ScriptState::current(info.GetIsolate())); | 146 {{argument.name}} = V8{{argument.idl_type}}::create(v8::Handle<v8::Function>
::Cast(info[{{argument.index}}]), ScriptState::current(info.GetIsolate())); |
| 147 } else { |
| 148 {{argument.name}} = nullptr; |
151 } | 149 } |
152 {% else %}{# argument.is_optional #} | 150 {% else %}{# argument.is_optional #} |
153 if (info.Length() <= {{argument.index}} || !{% if argument.is_nullable %}(info[{
{argument.index}}]->IsFunction() || info[{{argument.index}}]->IsNull()){% else %
}info[{{argument.index}}]->IsFunction(){% endif %}) { | 151 if (info.Length() <= {{argument.index}} || !{% if argument.is_nullable %}(info[{
{argument.index}}]->IsFunction() || info[{{argument.index}}]->IsNull()){% else %
}info[{{argument.index}}]->IsFunction(){% endif %}) { |
154 {{throw_type_error(method, | 152 {{throw_type_error(method, |
155 '"The callback provided as parameter %s is not a function."' % | 153 '"The callback provided as parameter %s is not a function."' % |
156 (argument.index + 1)) | indent }} | 154 (argument.index + 1)) | indent }} |
157 return; | 155 return; |
158 } | 156 } |
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())); | 157 {{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())); |
160 {% endif %}{# argument.is_optional #} | 158 {% endif %}{# argument.is_optional #} |
(...skipping 461 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
622 if method.is_per_world_bindings else '0' %} | 620 if method.is_per_world_bindings else '0' %} |
623 {% set property_attribute = | 621 {% set property_attribute = |
624 'static_cast<v8::PropertyAttribute>(%s)' % ' | '.join(method.property_attribut
es) | 622 'static_cast<v8::PropertyAttribute>(%s)' % ' | '.join(method.property_attribut
es) |
625 if method.property_attributes else 'v8::None' %} | 623 if method.property_attributes else 'v8::None' %} |
626 {% set only_exposed_to_private_script = 'V8DOMConfiguration::OnlyExposedToPrivat
eScript' if method.only_exposed_to_private_script else 'V8DOMConfiguration::Expo
sedToAllScripts' %} | 624 {% set only_exposed_to_private_script = 'V8DOMConfiguration::OnlyExposedToPrivat
eScript' if method.only_exposed_to_private_script else 'V8DOMConfiguration::Expo
sedToAllScripts' %} |
627 static const V8DOMConfiguration::MethodConfiguration {{method.name}}MethodConfig
uration = { | 625 static const V8DOMConfiguration::MethodConfiguration {{method.name}}MethodConfig
uration = { |
628 "{{method.name}}", {{method_callback}}, {{method_callback_for_main_world}},
{{method.length}}, {{only_exposed_to_private_script}}, | 626 "{{method.name}}", {{method_callback}}, {{method_callback_for_main_world}},
{{method.length}}, {{only_exposed_to_private_script}}, |
629 }; | 627 }; |
630 V8DOMConfiguration::installMethod({{method.function_template}}, {{method.signatu
re}}, {{property_attribute}}, {{method.name}}MethodConfiguration, isolate); | 628 V8DOMConfiguration::installMethod({{method.function_template}}, {{method.signatu
re}}, {{property_attribute}}, {{method.name}}MethodConfiguration, isolate); |
631 {%- endmacro %} | 629 {%- endmacro %} |
OLD | NEW |