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

Unified Diff: Source/bindings/scripts/code_generator_v8.pm

Issue 144463014: Add [StrictTypeChecking] to the SVGGeometryElement interface (Closed) Base URL: svn://svn.chromium.org/blink/trunk
Patch Set: Drop/change TC; Simplify generated code. 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « LayoutTests/svg/dom/undefined-null-expected.txt ('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/scripts/code_generator_v8.pm
diff --git a/Source/bindings/scripts/code_generator_v8.pm b/Source/bindings/scripts/code_generator_v8.pm
index 93b89b49e024fb333558513e1fb16dc652460e35..77d12637fd624bec9fa719e8834156505e54e463 100644
--- a/Source/bindings/scripts/code_generator_v8.pm
+++ b/Source/bindings/scripts/code_generator_v8.pm
@@ -2782,18 +2782,25 @@ END
$parameterCheckString .= " }\n";
}
} else {
- # If the "StrictTypeChecking" extended attribute is present, and the argument's type is an
- # interface type, then if the incoming value does not implement that interface, a TypeError
- # is thrown rather than silently passing NULL to the C++ code.
- # Per the Web IDL and ECMAScript specifications, incoming values can always be converted
- # to both strings and numbers, so do not throw TypeError if the argument is of these
- # types.
+ # If the [StrictTypeChecking] extended attribute is present, type
+ # check interface type arguments for correct type and nullability.
+ #
+ # If the argument is passed, and is not |undefined| or |null|, then
+ # it must implement the interface type, otherwise throw a TypeError
+ # If the parameter is nullable, then both |undefined| and |null|
+ # pass a NULL pointer to the C++ code, otherwise these also throw.
+ # Without [StrictTypeChecking], in all these cases NULL is silently
+ # passed to the C++ code.
+ #
+ # Per the Web IDL and ECMAScript specifications, incoming values
+ # can always be converted to primitive types and strings (including
+ # |undefined| and |null|), so do not throw TypeError for these.
if ($function->extendedAttributes->{"StrictTypeChecking"} || $interface->extendedAttributes->{"StrictTypeChecking"}) {
my $argValue = "info[$paramIndex]";
my $argType = $parameter->type;
if (IsWrapperType($argType)) {
- my $undefinedNullCheck = $parameter->isNullable ? "isUndefinedOrNull($argValue)" : "${argValue}->IsUndefined()";
- $parameterCheckString .= " if (info.Length() > $paramIndex && !$undefinedNullCheck && !V8${argType}::hasInstance($argValue, info.GetIsolate())) {\n";
+ my $undefinedNullCheck = $parameter->isNullable ? " !isUndefinedOrNull($argValue) &&" : "";
+ $parameterCheckString .= " if (info.Length() > $paramIndex &&$undefinedNullCheck !V8${argType}::hasInstance($argValue, info.GetIsolate())) {\n";
if ($hasExceptionState) {
$parameterCheckString .= " exceptionState.throwTypeError(\"parameter $humanFriendlyIndex is not of type \'$argType\'.\");\n";
$parameterCheckString .= " exceptionState.throwIfNeeded();\n";
« no previous file with comments | « LayoutTests/svg/dom/undefined-null-expected.txt ('k') | Source/bindings/templates/methods.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698