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

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

Issue 211333004: Tidy up error reporting for calling-constructor-as-function. (Closed) Base URL: https://chromium.googlesource.com/chromium/blink.git@master
Patch Set: re-use failedToConstruct() in constructorNotCallableAsFunction(). Created 6 years, 9 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 {##############################################################################} 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 {% if method.number_of_required_arguments %} 10 {% if method.number_of_required_arguments %}
(...skipping 390 matching lines...) Expand 10 before | Expand all | Expand 10 after
401 v8SetReturnValue(info, wrapper); 401 v8SetReturnValue(info, wrapper);
402 } 402 }
403 {% endmacro %} 403 {% endmacro %}
404 404
405 405
406 {##############################################################################} 406 {##############################################################################}
407 {% macro named_constructor_callback(constructor) %} 407 {% macro named_constructor_callback(constructor) %}
408 static void {{v8_class}}ConstructorCallback(const v8::FunctionCallbackInfo<v8::V alue>& info) 408 static void {{v8_class}}ConstructorCallback(const v8::FunctionCallbackInfo<v8::V alue>& info)
409 { 409 {
410 if (!info.IsConstructCall()) { 410 if (!info.IsConstructCall()) {
411 throwTypeError(ExceptionMessages::failedToConstruct("{{constructor.name} }", "Please use the 'new' operator, this DOM object constructor cannot be called as a function."), info.GetIsolate()); 411 throwTypeError(ExceptionMessages::constructorNotCallableAsFunction("{{co nstructor.name}}"), info.GetIsolate());
412 return; 412 return;
413 } 413 }
414 414
415 if (ConstructorMode::current() == ConstructorMode::WrapExistingObject) { 415 if (ConstructorMode::current() == ConstructorMode::WrapExistingObject) {
416 v8SetReturnValue(info, info.Holder()); 416 v8SetReturnValue(info, info.Holder());
417 return; 417 return;
418 } 418 }
419 419
420 Document* document = currentDOMWindow(info.GetIsolate())->document(); 420 Document* document = currentDOMWindow(info.GetIsolate())->document();
421 ASSERT(document); 421 ASSERT(document);
(...skipping 24 matching lines...) Expand all
446 446
447 {% if has_custom_wrap %} 447 {% if has_custom_wrap %}
448 v8::Handle<v8::Object> wrapper = wrap(impl.get(), info.Holder(), info.GetIso late()); 448 v8::Handle<v8::Object> wrapper = wrap(impl.get(), info.Holder(), info.GetIso late());
449 {% else %} 449 {% else %}
450 v8::Handle<v8::Object> wrapper = info.Holder(); 450 v8::Handle<v8::Object> wrapper = info.Holder();
451 V8DOMWrapper::associateObjectWithWrapper<{{v8_class}}>(impl.release(), &{{v8 _class}}Constructor::wrapperTypeInfo, wrapper, info.GetIsolate(), {{wrapper_conf iguration}}); 451 V8DOMWrapper::associateObjectWithWrapper<{{v8_class}}>(impl.release(), &{{v8 _class}}Constructor::wrapperTypeInfo, wrapper, info.GetIsolate(), {{wrapper_conf iguration}});
452 {% endif %} 452 {% endif %}
453 v8SetReturnValue(info, wrapper); 453 v8SetReturnValue(info, wrapper);
454 } 454 }
455 {% endmacro %} 455 {% endmacro %}
OLDNEW
« no previous file with comments | « Source/bindings/templates/interface.cpp ('k') | Source/bindings/tests/results/V8TestInterface.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698