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

Unified 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « Source/bindings/scripts/v8_interface.py ('k') | Source/bindings/templates/methods.cpp » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: Source/bindings/templates/interface.cpp
diff --git a/Source/bindings/templates/interface.cpp b/Source/bindings/templates/interface.cpp
index 96ec20be5ae23b9977168259095534cd0916522a..4c1986fac604eee00b300092e8572a8ecf6caca3 100644
--- a/Source/bindings/templates/interface.cpp
+++ b/Source/bindings/templates/interface.cpp
@@ -609,15 +609,21 @@ static void constructor(const v8::FunctionCallbackInfo<v8::Value>& info)
{% endfor %}
break;
{% endfor %}
- }
- {# No match, throw error #}
- {% if interface_length %}
- if (UNLIKELY(info.Length() < {{interface_length}})) {
- exceptionState.throwTypeError(ExceptionMessages::notEnoughArguments({{interface_length}}, info.Length()));
+ default:
+ {# Invalid arity, throw error #}
+ {# Report full list of valid arities if gaps and above minimum #}
+ {% if constructor_overloads.valid_arities %}
+ if (info.Length() >= {{constructor_overloads.minarg}}) {
+ throwArityTypeError(exceptionState, "{{constructor_overloads.valid_arities}}", info.Length());
+ return;
+ }
+ {% endif %}
+ {# Otherwise just report "not enough arguments" #}
+ exceptionState.throwTypeError(ExceptionMessages::notEnoughArguments({{constructor_overloads.minarg}}, info.Length()));
exceptionState.throwIfNeeded();
return;
}
- {% endif %}
+ {# No match, throw error #}
exceptionState.throwTypeError("No matching constructor signature.");
exceptionState.throwIfNeeded();
}
« 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