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

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

Issue 146423002: Move [StrictTypeChecking] to interface (from members), where possible (Closed) Base URL: svn://svn.chromium.org/blink/trunk
Patch Set: Rebased 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
« no previous file with comments | « no previous file | Source/bindings/scripts/unstable/v8_attributes.py » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 1929 matching lines...) Expand 10 before | Expand all | Expand 10 after
1940 $code .= "#if ${conditionalString}\n" if $conditionalString; 1940 $code .= "#if ${conditionalString}\n" if $conditionalString;
1941 if ($exposeJSAccessors) { 1941 if ($exposeJSAccessors) {
1942 $code .= "static void ${attrName}AttributeSetter${forMainWorldSuffix}(v8 ::Local<v8::Value> jsValue, const v8::FunctionCallbackInfo<v8::Value>& info)\n"; 1942 $code .= "static void ${attrName}AttributeSetter${forMainWorldSuffix}(v8 ::Local<v8::Value> jsValue, const v8::FunctionCallbackInfo<v8::Value>& info)\n";
1943 } else { 1943 } else {
1944 $code .= "static void ${attrName}AttributeSetter${forMainWorldSuffix}(v8 ::Local<v8::Value> jsValue, const v8::PropertyCallbackInfo<void>& info)\n"; 1944 $code .= "static void ${attrName}AttributeSetter${forMainWorldSuffix}(v8 ::Local<v8::Value> jsValue, const v8::PropertyCallbackInfo<void>& info)\n";
1945 } 1945 }
1946 $code .= "{\n"; 1946 $code .= "{\n";
1947 1947
1948 my $raisesException = $attribute->extendedAttributes->{"RaisesException"}; 1948 my $raisesException = $attribute->extendedAttributes->{"RaisesException"};
1949 my $useExceptions = 1 if $raisesException && ($raisesException eq "VALUE_IS_ MISSING" or $raisesException eq "Setter"); 1949 my $useExceptions = 1 if $raisesException && ($raisesException eq "VALUE_IS_ MISSING" or $raisesException eq "Setter");
1950 my $hasStrictTypeChecking = 1 if $attribute->extendedAttributes->{"StrictTyp eChecking"} && IsWrapperType($attrType); # Currently only actually check interf ace types 1950 my $hasStrictTypeChecking = 1 if ($interface->extendedAttributes->{"StrictTy peChecking"} || $attribute->extendedAttributes->{"StrictTypeChecking"}) && IsWra pperType($attrType); # Currently only actually check interface types
1951 1951
1952 # Can throw exceptions from accessors or during type conversion. 1952 # Can throw exceptions from accessors or during type conversion.
1953 my $isIntegerType = IsIntegerType($attribute->type); 1953 my $isIntegerType = IsIntegerType($attribute->type);
1954 1954
1955 # We throw exceptions using 'ExceptionState' if the attribute explicitly 1955 # We throw exceptions using 'ExceptionState' if the attribute explicitly
1956 # claims that exceptions may be raised, or if a strict type check might 1956 # claims that exceptions may be raised, or if a strict type check might
1957 # fail, or if we're dealing with SVG, which does strange things with 1957 # fail, or if we're dealing with SVG, which does strange things with
1958 # tearoffs and read-only wrappers. 1958 # tearoffs and read-only wrappers.
1959 if ($useExceptions or $hasStrictTypeChecking or GetSVGTypeNeedingTearOff($in terfaceName) or GetSVGTypeNeedingTearOff($attrType) or $isIntegerType) { 1959 if ($useExceptions or $hasStrictTypeChecking or GetSVGTypeNeedingTearOff($in terfaceName) or GetSVGTypeNeedingTearOff($attrType) or $isIntegerType) {
1960 $code .= " ExceptionState exceptionState(ExceptionState::SetterContex t, \"${attrName}\", \"${interfaceName}\", info.Holder(), info.GetIsolate());\n"; 1960 $code .= " ExceptionState exceptionState(ExceptionState::SetterContex t, \"${attrName}\", \"${interfaceName}\", info.Holder(), info.GetIsolate());\n";
(...skipping 762 matching lines...) Expand 10 before | Expand all | Expand 10 after
2723 $parameterCheckString .= " return;\n"; 2723 $parameterCheckString .= " return;\n";
2724 $parameterCheckString .= " }\n"; 2724 $parameterCheckString .= " }\n";
2725 } 2725 }
2726 } else { 2726 } else {
2727 # If the "StrictTypeChecking" extended attribute is present, and the argument's type is an 2727 # If the "StrictTypeChecking" extended attribute is present, and the argument's type is an
2728 # interface type, then if the incoming value does not implement that interface, a TypeError 2728 # interface type, then if the incoming value does not implement that interface, a TypeError
2729 # is thrown rather than silently passing NULL to the C++ code. 2729 # is thrown rather than silently passing NULL to the C++ code.
2730 # Per the Web IDL and ECMAScript specifications, incoming values can always be converted 2730 # Per the Web IDL and ECMAScript specifications, incoming values can always be converted
2731 # to both strings and numbers, so do not throw TypeError if the argu ment is of these 2731 # to both strings and numbers, so do not throw TypeError if the argu ment is of these
2732 # types. 2732 # types.
2733 if ($function->extendedAttributes->{"StrictTypeChecking"}) { 2733 if ($function->extendedAttributes->{"StrictTypeChecking"} || $interf ace->extendedAttributes->{"StrictTypeChecking"}) {
2734 my $argValue = "info[$paramIndex]"; 2734 my $argValue = "info[$paramIndex]";
2735 my $argType = $parameter->type; 2735 my $argType = $parameter->type;
2736 if (IsWrapperType($argType)) { 2736 if (IsWrapperType($argType)) {
2737 my $undefinedNullCheck = $parameter->isNullable ? "isUndefin edOrNull($argValue)" : "${argValue}->IsUndefined()"; 2737 my $undefinedNullCheck = $parameter->isNullable ? "isUndefin edOrNull($argValue)" : "${argValue}->IsUndefined()";
2738 $parameterCheckString .= " if (info.Length() > $paramInde x && !$undefinedNullCheck && !V8${argType}::hasInstance($argValue, info.GetIsola te())) {\n"; 2738 $parameterCheckString .= " if (info.Length() > $paramInde x && !$undefinedNullCheck && !V8${argType}::hasInstance($argValue, info.GetIsola te())) {\n";
2739 if ($hasExceptionState) { 2739 if ($hasExceptionState) {
2740 $parameterCheckString .= " exceptionState.throwTy peError(\"parameter $humanFriendlyIndex is not of type \'$argType\'.\");\n"; 2740 $parameterCheckString .= " exceptionState.throwTy peError(\"parameter $humanFriendlyIndex is not of type \'$argType\'.\");\n";
2741 $parameterCheckString .= " exceptionState.throwIf Needed();\n"; 2741 $parameterCheckString .= " exceptionState.throwIf Needed();\n";
2742 }else { 2742 }else {
2743 $parameterCheckString .= " throwTypeError(Excepti onMessages::failedToExecute(\"$functionName\", \"$interfaceName\", \"parameter $ humanFriendlyIndex is not of type \'$argType\'.\"), info.GetIsolate());\n"; 2743 $parameterCheckString .= " throwTypeError(Excepti onMessages::failedToExecute(\"$functionName\", \"$interfaceName\", \"parameter $ humanFriendlyIndex is not of type \'$argType\'.\"), info.GetIsolate());\n";
(...skipping 3657 matching lines...) Expand 10 before | Expand all | Expand 10 after
6401 if ($parameter->type eq "SerializedScriptValue") { 6401 if ($parameter->type eq "SerializedScriptValue") {
6402 return 1; 6402 return 1;
6403 } elsif (IsIntegerType($parameter->type)) { 6403 } elsif (IsIntegerType($parameter->type)) {
6404 return 1; 6404 return 1;
6405 } 6405 }
6406 } 6406 }
6407 return 0; 6407 return 0;
6408 } 6408 }
6409 6409
6410 1; 6410 1;
OLDNEW
« no previous file with comments | « no previous file | Source/bindings/scripts/unstable/v8_attributes.py » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698