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

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

Issue 1132243004: IDL: Determine maximum distinguishing argument index runtime, if needed (Closed) Base URL: https://chromium.googlesource.com/chromium/blink.git@master
Patch Set: Created 5 years, 7 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
OLDNEW
1 {% from 'conversions.cpp' import declare_enum_validation_variable, v8_value_to_l ocal_cpp_value %} 1 {% from 'conversions.cpp' import declare_enum_validation_variable, v8_value_to_l ocal_cpp_value %}
2 2
3 3
4 {##############################################################################} 4 {##############################################################################}
5 {% macro generate_method(method, world_suffix) %} 5 {% macro generate_method(method, world_suffix) %}
6 {% filter conditional(method.conditional_string) %} 6 {% filter conditional(method.conditional_string) %}
7 {% if method.returns_promise and method.has_exception_state %} 7 {% if method.returns_promise and method.has_exception_state %}
8 static void {{method.name}}{{method.overload_index}}Method{{world_suffix}}Promis e(const v8::FunctionCallbackInfo<v8::Value>& info, ExceptionState& exceptionStat e) 8 static void {{method.name}}{{method.overload_index}}Method{{world_suffix}}Promis e(const v8::FunctionCallbackInfo<v8::Value>& info, ExceptionState& exceptionStat e)
9 {% else %} 9 {% else %}
10 static void {{method.name}}{{method.overload_index}}Method{{world_suffix}}(const v8::FunctionCallbackInfo<v8::Value>& info) 10 static void {{method.name}}{{method.overload_index}}Method{{world_suffix}}(const v8::FunctionCallbackInfo<v8::Value>& info)
(...skipping 334 matching lines...) Expand 10 before | Expand all | Expand 10 after
345 {% filter runtime_enabled(runtime_enabled_function) %} 345 {% filter runtime_enabled(runtime_enabled_function) %}
346 return {{length}}; 346 return {{length}};
347 {% endfilter %} 347 {% endfilter %}
348 {% endfor %} 348 {% endfor %}
349 {% endfor %} 349 {% endfor %}
350 } 350 }
351 {% endmacro %} 351 {% endmacro %}
352 352
353 353
354 {##############################################################################} 354 {##############################################################################}
355 {% macro runtime_determined_maxarg_method(overloads) %}
356 static int {{overloads.name}}MethodMaxArg()
357 {
358 {% for length, runtime_enabled_functions in overloads.runtime_determined_max args %}
359 {% for runtime_enabled_function in runtime_enabled_functions %}
360 {% filter runtime_enabled(runtime_enabled_function) %}
361 return {{length}};
362 {% endfilter %}
363 {% endfor %}
364 {% endfor %}
365 }
366 {% endmacro %}
367
368
369 {##############################################################################}
355 {# FIXME: We should return a rejected Promise if an error occurs in this 370 {# FIXME: We should return a rejected Promise if an error occurs in this
356 function when ALL methods in this overload return Promise. In order to do so, 371 function when ALL methods in this overload return Promise. In order to do so,
357 we must ensure either ALL or NO methods in this overload return Promise #} 372 we must ensure either ALL or NO methods in this overload return Promise #}
358 {% macro overload_resolution_method(overloads, world_suffix) %} 373 {% macro overload_resolution_method(overloads, world_suffix) %}
359 static void {{overloads.name}}Method{{world_suffix}}(const v8::FunctionCallbackI nfo<v8::Value>& info) 374 static void {{overloads.name}}Method{{world_suffix}}(const v8::FunctionCallbackI nfo<v8::Value>& info)
360 { 375 {
361 ExceptionState exceptionState(ExceptionState::ExecutionContext, "{{overloads .name}}", "{{interface_name}}", info.Holder(), info.GetIsolate()); 376 ExceptionState exceptionState(ExceptionState::ExecutionContext, "{{overloads .name}}", "{{interface_name}}", info.Holder(), info.GetIsolate());
362 {% if overloads.measure_all_as %} 377 {% if overloads.measure_all_as %}
363 UseCounter::countIfNotPrivateScript(info.GetIsolate(), callingExecutionConte xt(info.GetIsolate()), UseCounter::{{overloads.measure_all_as}}); 378 UseCounter::countIfNotPrivateScript(info.GetIsolate(), callingExecutionConte xt(info.GetIsolate()), UseCounter::{{overloads.measure_all_as}});
364 {% endif %} 379 {% endif %}
(...skipping 29 matching lines...) Expand all
394 {% endfor %} 409 {% endfor %}
395 {% if is_partial or not overloads.has_partial_overloads %} 410 {% if is_partial or not overloads.has_partial_overloads %}
396 default: 411 default:
397 {# If methods are overloaded between interface and partial interface #} 412 {# If methods are overloaded between interface and partial interface #}
398 {# definitions, need to invoke methods defined in the partial #} 413 {# definitions, need to invoke methods defined in the partial #}
399 {# interface. #} 414 {# interface. #}
400 {# FIXME: we do not need to always generate this code. #} 415 {# FIXME: we do not need to always generate this code. #}
401 {# Invalid arity, throw error #} 416 {# Invalid arity, throw error #}
402 {# Report full list of valid arities if gaps and above minimum #} 417 {# Report full list of valid arities if gaps and above minimum #}
403 {% if overloads.valid_arities %} 418 {% if overloads.valid_arities %}
404 if (info.Length() >= {{overloads.minarg}}) { 419 if (info.Length() >= {{overloads.length}}) {
405 setArityTypeError(exceptionState, "{{overloads.valid_arities}}", inf o.Length()); 420 setArityTypeError(exceptionState, "{{overloads.valid_arities}}", inf o.Length());
406 {{propagate_error_with_exception_state(overloads) | indent(12)}} 421 {{propagate_error_with_exception_state(overloads) | indent(12)}}
407 } 422 }
408 {% endif %} 423 {% endif %}
409 break; 424 break;
410 {% endif %} 425 {% endif %}
411 } 426 }
412 {% if not is_partial and overloads.has_partial_overloads %} 427 {% if not is_partial and overloads.has_partial_overloads %}
413 ASSERT({{overloads.name}}MethodForPartialInterface); 428 ASSERT({{overloads.name}}MethodForPartialInterface);
414 ({{overloads.name}}MethodForPartialInterface)(info); 429 ({{overloads.name}}MethodForPartialInterface)(info);
(...skipping 226 matching lines...) Expand 10 before | Expand all | Expand 10 after
641 method.exposed_test) %} 656 method.exposed_test) %}
642 {% filter runtime_enabled(method.overloads.runtime_enabled_function_all 657 {% filter runtime_enabled(method.overloads.runtime_enabled_function_all
643 if method.overloads else 658 if method.overloads else
644 method.runtime_enabled_function) %} 659 method.runtime_enabled_function) %}
645 prototypeObject->Set(v8AtomicString(isolate, "{{method.name}}"), v8::FunctionTem plate::New(isolate, {{cpp_class_or_partial}}V8Internal::{{method.name}}MethodCal lback, v8Undefined(), defaultSignature, {{method.number_of_required_arguments}}) ->GetFunction(isolate->GetCurrentContext()).ToLocalChecked()); 660 prototypeObject->Set(v8AtomicString(isolate, "{{method.name}}"), v8::FunctionTem plate::New(isolate, {{cpp_class_or_partial}}V8Internal::{{method.name}}MethodCal lback, v8Undefined(), defaultSignature, {{method.number_of_required_arguments}}) ->GetFunction(isolate->GetCurrentContext()).ToLocalChecked());
646 {% endfilter %}{# runtime_enabled() #} 661 {% endfilter %}{# runtime_enabled() #}
647 {% endfilter %}{# exposed() #} 662 {% endfilter %}{# exposed() #}
648 {% endfor %} 663 {% endfor %}
649 {% endif %} 664 {% endif %}
650 {%- endmacro %} 665 {%- endmacro %}
OLDNEW
« no previous file with comments | « Source/bindings/templates/interface_base.cpp ('k') | Source/bindings/tests/idls/core/TestObject.idl » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698