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

Side by Side Diff: Source/bindings/scripts/code_generator_v8.pm

Issue 141523002: Add null-correctness checking to [StrictTypeChecking] methods (Closed) Base URL: svn://svn.chromium.org/blink/trunk
Patch Set: Last test Created 6 years, 11 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
OLDNEW
1 # Copyright (C) 2005, 2006 Nikolas Zimmermann <zimmermann@kde.org> 1 # Copyright (C) 2005, 2006 Nikolas Zimmermann <zimmermann@kde.org>
2 # Copyright (C) 2006 Anders Carlsson <andersca@mac.com> 2 # Copyright (C) 2006 Anders Carlsson <andersca@mac.com>
3 # Copyright (C) 2006 Samuel Weinig <sam.weinig@gmail.com> 3 # Copyright (C) 2006 Samuel Weinig <sam.weinig@gmail.com>
4 # Copyright (C) 2006 Alexey Proskuryakov <ap@webkit.org> 4 # Copyright (C) 2006 Alexey Proskuryakov <ap@webkit.org>
5 # Copyright (C) 2006 Apple Computer, Inc. 5 # Copyright (C) 2006 Apple Computer, Inc.
6 # Copyright (C) 2007, 2008, 2009, 2012 Google Inc. 6 # Copyright (C) 2007, 2008, 2009, 2012 Google Inc.
7 # Copyright (C) 2009 Cameron McCormack <cam@mcc.id.au> 7 # Copyright (C) 2009 Cameron McCormack <cam@mcc.id.au>
8 # Copyright (C) Research In Motion Limited 2010. All rights reserved. 8 # Copyright (C) Research In Motion Limited 2010. All rights reserved.
9 # Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies) 9 # Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies)
10 # Copyright (C) 2012 Ericsson AB. All rights reserved. 10 # Copyright (C) 2012 Ericsson AB. All rights reserved.
(...skipping 2760 matching lines...) Expand 10 before | Expand all | Expand 10 after
2771 # If the "StrictTypeChecking" extended attribute is present, and the argument's type is an 2771 # If the "StrictTypeChecking" extended attribute is present, and the argument's type is an
2772 # interface type, then if the incoming value does not implement that interface, a TypeError 2772 # interface type, then if the incoming value does not implement that interface, a TypeError
2773 # is thrown rather than silently passing NULL to the C++ code. 2773 # is thrown rather than silently passing NULL to the C++ code.
2774 # Per the Web IDL and ECMAScript specifications, incoming values can always be converted 2774 # Per the Web IDL and ECMAScript specifications, incoming values can always be converted
2775 # to both strings and numbers, so do not throw TypeError if the argu ment is of these 2775 # to both strings and numbers, so do not throw TypeError if the argu ment is of these
2776 # types. 2776 # types.
2777 if ($function->extendedAttributes->{"StrictTypeChecking"}) { 2777 if ($function->extendedAttributes->{"StrictTypeChecking"}) {
2778 my $argValue = "info[$paramIndex]"; 2778 my $argValue = "info[$paramIndex]";
2779 my $argType = $parameter->type; 2779 my $argType = $parameter->type;
2780 if (IsWrapperType($argType)) { 2780 if (IsWrapperType($argType)) {
2781 $parameterCheckString .= " if (info.Length() > $paramInde x && !isUndefinedOrNull($argValue) && !V8${argType}::hasInstance($argValue, info .GetIsolate(), worldType(info.GetIsolate()))) {\n"; 2781 my $undefinedNullCheck = $parameter->isNullable ? "isUndefin edOrNull($argValue)" : "${argValue}->IsUndefined()";
2782 $parameterCheckString .= " if (info.Length() > $paramInde x && !$undefinedNullCheck && !V8${argType}::hasInstance($argValue, info.GetIsola te(), worldType(info.GetIsolate()))) {\n";
2782 if ($hasExceptionState) { 2783 if ($hasExceptionState) {
2783 $parameterCheckString .= " exceptionState.throwTy peError(\"parameter $humanFriendlyIndex is not of type \'$argType\'.\");\n"; 2784 $parameterCheckString .= " exceptionState.throwTy peError(\"parameter $humanFriendlyIndex is not of type \'$argType\'.\");\n";
2784 $parameterCheckString .= " exceptionState.throwIf Needed();\n"; 2785 $parameterCheckString .= " exceptionState.throwIf Needed();\n";
2785 }else { 2786 }else {
2786 $parameterCheckString .= " throwTypeError(Excepti onMessages::failedToExecute(\"$functionName\", \"$interfaceName\", \"parameter $ humanFriendlyIndex is not of type \'$argType\'.\"), info.GetIsolate());\n"; 2787 $parameterCheckString .= " throwTypeError(Excepti onMessages::failedToExecute(\"$functionName\", \"$interfaceName\", \"parameter $ humanFriendlyIndex is not of type \'$argType\'.\"), info.GetIsolate());\n";
2787 } 2788 }
2788 $parameterCheckString .= " return;\n"; 2789 $parameterCheckString .= " return;\n";
2789 $parameterCheckString .= " }\n"; 2790 $parameterCheckString .= " }\n";
2790 } 2791 }
2791 } 2792 }
(...skipping 3664 matching lines...) Expand 10 before | Expand all | Expand 10 after
6456 if ($parameter->type eq "SerializedScriptValue") { 6457 if ($parameter->type eq "SerializedScriptValue") {
6457 return 1; 6458 return 1;
6458 } elsif (IsIntegerType($parameter->type)) { 6459 } elsif (IsIntegerType($parameter->type)) {
6459 return 1; 6460 return 1;
6460 } 6461 }
6461 } 6462 }
6462 return 0; 6463 return 0;
6463 } 6464 }
6464 6465
6465 1; 6466 1;
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698