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

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

Issue 284163002: Better arity checks for overloads (Closed) Base URL: svn://svn.chromium.org/blink/trunk
Patch Set: Return properly Created 6 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 | Annotate | Revision Log
« no previous file with comments | « Source/bindings/scripts/v8_interface.py ('k') | Source/bindings/templates/methods.cpp » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 {% extends 'interface_base.cpp' %} 1 {% extends 'interface_base.cpp' %}
2 2
3 3
4 {##############################################################################} 4 {##############################################################################}
5 {% macro attribute_configuration(attribute) %} 5 {% macro attribute_configuration(attribute) %}
6 {% set getter_callback = 6 {% set getter_callback =
7 '%sV8Internal::%sAttributeGetterCallback' % 7 '%sV8Internal::%sAttributeGetterCallback' %
8 (cpp_class, attribute.name) 8 (cpp_class, attribute.name)
9 if not attribute.constructor_type else 9 if not attribute.constructor_type else
10 ('%sV8Internal::%sConstructorGetterCallback' % 10 ('%sV8Internal::%sConstructorGetterCallback' %
(...skipping 591 matching lines...) Expand 10 before | Expand all | Expand 10 after
602 {# Then resolve by testing argument #} 602 {# Then resolve by testing argument #}
603 {% for test, constructor in tests_constructors %} 603 {% for test, constructor in tests_constructors %}
604 {# 10. If i = d, then: #} 604 {# 10. If i = d, then: #}
605 if ({{test}}) { 605 if ({{test}}) {
606 {{cpp_class}}V8Internal::constructor{{constructor.overload_index}}(i nfo); 606 {{cpp_class}}V8Internal::constructor{{constructor.overload_index}}(i nfo);
607 return; 607 return;
608 } 608 }
609 {% endfor %} 609 {% endfor %}
610 break; 610 break;
611 {% endfor %} 611 {% endfor %}
612 } 612 default:
613 {# No match, throw error #} 613 {# Invalid arity, throw error #}
614 {% if interface_length %} 614 {# Report full list of valid arities if gaps and above minimum #}
615 if (UNLIKELY(info.Length() < {{interface_length}})) { 615 {% if constructor_overloads.valid_arities %}
616 exceptionState.throwTypeError(ExceptionMessages::notEnoughArguments({{in terface_length}}, info.Length())); 616 if (info.Length() >= {{constructor_overloads.minarg}}) {
617 throwArityTypeError(exceptionState, "{{constructor_overloads.valid_a rities}}", info.Length());
618 return;
619 }
620 {% endif %}
621 {# Otherwise just report "not enough arguments" #}
622 exceptionState.throwTypeError(ExceptionMessages::notEnoughArguments({{co nstructor_overloads.minarg}}, info.Length()));
617 exceptionState.throwIfNeeded(); 623 exceptionState.throwIfNeeded();
618 return; 624 return;
619 } 625 }
620 {% endif %} 626 {# No match, throw error #}
621 exceptionState.throwTypeError("No matching constructor signature."); 627 exceptionState.throwTypeError("No matching constructor signature.");
622 exceptionState.throwIfNeeded(); 628 exceptionState.throwIfNeeded();
623 } 629 }
624 630
625 {% endif %} 631 {% endif %}
626 {% endblock %} 632 {% endblock %}
627 633
628 634
629 {##############################################################################} 635 {##############################################################################}
630 {% block event_constructor %} 636 {% block event_constructor %}
(...skipping 699 matching lines...) Expand 10 before | Expand all | Expand 10 after
1330 {% endif %} 1336 {% endif %}
1331 } 1337 }
1332 1338
1333 template<> 1339 template<>
1334 v8::Handle<v8::Value> toV8NoInline({{cpp_class}}* impl, v8::Handle<v8::Object> c reationContext, v8::Isolate* isolate) 1340 v8::Handle<v8::Value> toV8NoInline({{cpp_class}}* impl, v8::Handle<v8::Object> c reationContext, v8::Isolate* isolate)
1335 { 1341 {
1336 return toV8(impl, creationContext, isolate); 1342 return toV8(impl, creationContext, isolate);
1337 } 1343 }
1338 1344
1339 {% endblock %} 1345 {% endblock %}
OLDNEW
« no previous file with comments | « Source/bindings/scripts/v8_interface.py ('k') | Source/bindings/templates/methods.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698