Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(365)

Side by Side Diff: Source/bindings/templates/methods.cpp

Issue 158663002: IDL compiler: sync Python to r166688 (and clean up special operations+union code) (Closed) Base URL: svn://svn.chromium.org/blink/trunk
Patch Set: Typo Created 6 years, 10 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
OLDNEW
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.has_exception_state %} 6 {% if method.has_exception_state %}
7 ExceptionState exceptionState(ExceptionState::ExecutionContext, "{{method.na me}}", "{{interface_name}}", info.Holder(), info.GetIsolate()); 7 ExceptionState exceptionState(ExceptionState::ExecutionContext, "{{method.na me}}", "{{interface_name}}", info.Holder(), info.GetIsolate());
8 {% endif %} 8 {% endif %}
9 {% if method.name in ['addEventListener', 'removeEventListener'] %} 9 {% if method.name in ['addEventListener', 'removeEventListener'] %}
10 {{add_remove_event_listener_method(method.name) | indent}} 10 {{add_remove_event_listener_method(method.name) | indent}}
(...skipping 183 matching lines...) Expand 10 before | Expand all | Expand 10 after
194 return; 194 return;
195 {% endif %} 195 {% endif %}
196 {% if method.is_call_with_script_state %} 196 {% if method.is_call_with_script_state %}
197 if (state.hadException()) { 197 if (state.hadException()) {
198 v8::Local<v8::Value> exception = state.exception(); 198 v8::Local<v8::Value> exception = state.exception();
199 state.clearException(); 199 state.clearException();
200 throwError(exception, info.GetIsolate()); 200 throwError(exception, info.GetIsolate());
201 return; 201 return;
202 } 202 }
203 {% endif %} 203 {% endif %}
204 {% if v8_set_return_value %}{{v8_set_return_value}};{% endif %}{# None for void #} 204 {% if method.union_arguments %}
205 {{union_type_method_call(method)}}
206 {% elif v8_set_return_value %}{{v8_set_return_value}};{% endif %}{# None for voi d #}
205 {% endmacro %} 207 {% endmacro %}
206 208
209 {######################################}
210 {% macro union_type_method_call(method) %}
211 {% for cpp_type in method.cpp_type %}
212 bool result{{loop.index0}}Enabled = false;
213 {{cpp_type}} result{{loop.index0}};
214 {% endfor %}
215 {{method.cpp_value}};
216 {% if method.is_null_expression %}{# used by getters #}
217 if ({{method.is_null_expression}})
218 return;
219 {% endif %}
220 {% for v8_set_return_value in method.v8_set_return_value %}
221 if (result{{loop.index0}}Enabled) {
222 {{v8_set_return_value}};
223 return;
224 }
225 {% endfor %}
226 {# Fall back to null if none of the union members results are returned #}
227 v8SetReturnValueNull(info);
228 {%- endmacro %}
229
207 230
208 {######################################} 231 {######################################}
209 {% macro throw_type_error(method, error_message) %} 232 {% macro throw_type_error(method, error_message) %}
210 {% if method.has_exception_state %} 233 {% if method.has_exception_state %}
211 exceptionState.throwTypeError({{error_message}}); 234 exceptionState.throwTypeError({{error_message}});
212 exceptionState.throwIfNeeded(); 235 exceptionState.throwIfNeeded();
213 {%- elif method.is_constructor %} 236 {%- elif method.is_constructor %}
214 throwTypeError(ExceptionMessages::failedToConstruct("{{interface_name}}", {{erro r_message}}), info.GetIsolate()); 237 throwTypeError(ExceptionMessages::failedToConstruct("{{interface_name}}", {{erro r_message}}), info.GetIsolate());
215 {%- else %} 238 {%- else %}
216 throwTypeError(ExceptionMessages::failedToExecute("{{method.name}}", "{{interfac e_name}}", {{error_message}}), info.GetIsolate()); 239 throwTypeError(ExceptionMessages::failedToExecute("{{method.name}}", "{{interfac e_name}}", {{error_message}}), info.GetIsolate());
(...skipping 184 matching lines...) Expand 10 before | Expand all | Expand 10 after
401 v8::Handle<v8::Object> wrapper = info.Holder(); 424 v8::Handle<v8::Object> wrapper = info.Holder();
402 {% if is_constructor_raises_exception %} 425 {% if is_constructor_raises_exception %}
403 if (exceptionState.throwIfNeeded()) 426 if (exceptionState.throwIfNeeded())
404 return; 427 return;
405 {% endif %} 428 {% endif %}
406 429
407 V8DOMWrapper::associateObjectWithWrapper<{{v8_class}}>(impl.release(), &{{v8 _class}}Constructor::wrapperTypeInfo, wrapper, info.GetIsolate(), WrapperConfigu ration::Dependent); 430 V8DOMWrapper::associateObjectWithWrapper<{{v8_class}}>(impl.release(), &{{v8 _class}}Constructor::wrapperTypeInfo, wrapper, info.GetIsolate(), WrapperConfigu ration::Dependent);
408 v8SetReturnValue(info, wrapper); 431 v8SetReturnValue(info, wrapper);
409 } 432 }
410 {% endmacro %} 433 {% endmacro %}
OLDNEW
« no previous file with comments | « Source/bindings/templates/interface.cpp ('k') | Source/bindings/tests/results/V8TestEventTarget.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698