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

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

Issue 157013006: Update HTMLFormControlsCollection's named getter to behave according to spec (Closed) Base URL: svn://svn.chromium.org/blink/trunk
Patch Set: Remove legacycaller 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 unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « Source/bindings/bindings.gypi ('k') | Source/bindings/tests/idls/TestInterface.idl » ('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.
11 # Copyright (C) 2013 Samsung Electronics. All rights reserved. 11 # Copyright (C) 2013, 2014 Samsung Electronics. All rights reserved.
12 # 12 #
13 # This library is free software; you can redistribute it and/or 13 # This library is free software; you can redistribute it and/or
14 # modify it under the terms of the GNU Library General Public 14 # modify it under the terms of the GNU Library General Public
15 # License as published by the Free Software Foundation; either 15 # License as published by the Free Software Foundation; either
16 # version 2 of the License, or (at your option) any later version. 16 # version 2 of the License, or (at your option) any later version.
17 # 17 #
18 # This library is distributed in the hope that it will be useful, 18 # This library is distributed in the hope that it will be useful,
19 # but WITHOUT ANY WARRANTY; without even the implied warranty of 19 # but WITHOUT ANY WARRANTY; without even the implied warranty of
20 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 20 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
21 # Library General Public License for more details. 21 # Library General Public License for more details.
(...skipping 3554 matching lines...) Expand 10 before | Expand all | Expand 10 after
3576 } 3576 }
3577 3577
3578 sub GenerateIsNullExpression 3578 sub GenerateIsNullExpression
3579 { 3579 {
3580 my $type = shift; 3580 my $type = shift;
3581 my $variableName = shift; 3581 my $variableName = shift;
3582 if (IsUnionType($type)) { 3582 if (IsUnionType($type)) {
3583 my $types = $type->unionMemberTypes; 3583 my $types = $type->unionMemberTypes;
3584 my @expression = (); 3584 my @expression = ();
3585 for my $i (0 .. scalar(@$types)-1) { 3585 for my $i (0 .. scalar(@$types)-1) {
3586 my $unionMemberType = $types->[$i]; 3586 my $unionMemberEnabledVariable = $variableName . $i . "Enabled";
3587 my $unionMemberVariable = $variableName . $i; 3587 push @expression, "!${unionMemberEnabledVariable}";
3588 my $isNull = GenerateIsNullExpression($unionMemberType, $unionMember Variable);
3589 push @expression, $isNull;
3590 } 3588 }
3591 return join " && ", @expression; 3589 return join " && ", @expression;
3592 } 3590 }
3593 if (IsRefPtrType($type)) { 3591 if (IsRefPtrType($type)) {
3594 return "!${variableName}"; 3592 return "!${variableName}";
3595 } elsif ($type eq "DOMString") { 3593 } elsif ($type eq "DOMString") {
3596 return "${variableName}.isNull()"; 3594 return "${variableName}.isNull()";
3597 } elsif ($type eq "Promise") { 3595 } elsif ($type eq "Promise") {
3598 return "${variableName}.isNull()"; 3596 return "${variableName}.isNull()";
3599 } else { 3597 } else {
(...skipping 492 matching lines...) Expand 10 before | Expand all | Expand 10 after
4092 $code .= " ${implClassName}* collection = ${v8ClassName}::toNative(info.H older());\n"; 4090 $code .= " ${implClassName}* collection = ${v8ClassName}::toNative(info.H older());\n";
4093 $code .= " AtomicString propertyName = toCoreAtomicString(name);\n"; 4091 $code .= " AtomicString propertyName = toCoreAtomicString(name);\n";
4094 if ($raisesExceptions) { 4092 if ($raisesExceptions) {
4095 $code .= " ExceptionState exceptionState(info.Holder(), info.GetIsola te());\n"; 4093 $code .= " ExceptionState exceptionState(info.Holder(), info.GetIsola te());\n";
4096 } 4094 }
4097 $code .= $methodCallCode . "\n"; 4095 $code .= $methodCallCode . "\n";
4098 if ($raisesExceptions) { 4096 if ($raisesExceptions) {
4099 $code .= " if (exceptionState.throwIfNeeded())\n"; 4097 $code .= " if (exceptionState.throwIfNeeded())\n";
4100 $code .= " return;\n"; 4098 $code .= " return;\n";
4101 } 4099 }
4102 if (IsUnionType($returnType)) { 4100 $code .= " if (${isNull})\n";
4103 $code .= "${returnJSValueCode}\n"; 4101 $code .= " return;\n";
4104 $code .= " return;\n"; 4102 $code .= $returnJSValueCode . "\n";
4105 } else {
4106 $code .= " if (${isNull})\n";
4107 $code .= " return;\n";
4108 $code .= $returnJSValueCode . "\n";
4109 }
4110 $code .= "}\n\n"; 4103 $code .= "}\n\n";
4111 $implementation{nameSpaceInternal}->add($code); 4104 $implementation{nameSpaceInternal}->add($code);
4112 } 4105 }
4113 4106
4114 sub GenerateImplementationNamedPropertySetter 4107 sub GenerateImplementationNamedPropertySetter
4115 { 4108 {
4116 my $interface = shift; 4109 my $interface = shift;
4117 my $namedSetterFunction = shift; 4110 my $namedSetterFunction = shift;
4118 my $implClassName = GetImplName($interface); 4111 my $implClassName = GetImplName($interface);
4119 my $v8ClassName = GetV8ClassName($interface); 4112 my $v8ClassName = GetV8ClassName($interface);
(...skipping 1153 matching lines...) Expand 10 before | Expand all | Expand 10 after
5273 my $indent = shift; 5266 my $indent = shift;
5274 my $interface = shift; 5267 my $interface = shift;
5275 my $forMainWorldSuffix = shift; 5268 my $forMainWorldSuffix = shift;
5276 my $hasExceptionState = shift; 5269 my $hasExceptionState = shift;
5277 my %replacements = @_; 5270 my %replacements = @_;
5278 5271
5279 my $interfaceName = $interface->name; 5272 my $interfaceName = $interface->name;
5280 my $implClassName = GetImplName($interface); 5273 my $implClassName = GetImplName($interface);
5281 my $name = GetImplName($function); 5274 my $name = GetImplName($function);
5282 my $returnType = $function->type; 5275 my $returnType = $function->type;
5283 my $nativeReturnType = GetNativeType($returnType, {}, "");
5284 my $code = ""; 5276 my $code = "";
5285
5286 my $isSVGTearOffType = (IsSVGTypeNeedingTearOff($returnType) and not $interf aceName =~ /List$/); 5277 my $isSVGTearOffType = (IsSVGTypeNeedingTearOff($returnType) and not $interf aceName =~ /List$/);
5287 $nativeReturnType = GetSVGWrappedTypeNeedingTearOff($returnType) if $isSVGTe arOffType;
5288 5278
5289 my $index = 0; 5279 my $index = 0;
5290 my $humanFriendlyIndex = $index + 1; 5280 my $humanFriendlyIndex = $index + 1;
5291 5281
5292 my @arguments; 5282 my @arguments;
5293 my $functionName; 5283 my $functionName;
5294 my $implementedBy = $function->extendedAttributes->{"ImplementedBy"}; 5284 my $implementedBy = $function->extendedAttributes->{"ImplementedBy"};
5295 if ($implementedBy) { 5285 if ($implementedBy) {
5296 my $implementedByImplName = GetImplNameFromImplementedBy($implementedBy) ; 5286 my $implementedByImplName = GetImplNameFromImplementedBy($implementedBy) ;
5297 AddToImplIncludes(HeaderFilesForInterface($implementedBy, $implementedBy ImplName)); 5287 AddToImplIncludes(HeaderFilesForInterface($implementedBy, $implementedBy ImplName));
(...skipping 47 matching lines...) Expand 10 before | Expand all | Expand 10 after
5345 push @arguments, "${paramName}IsNull ? 0 : &$paramName"; 5335 push @arguments, "${paramName}IsNull ? 0 : &$paramName";
5346 } elsif (IsCallbackInterface($paramType) or $paramType eq "NodeFilter" o r $paramType eq "XPathNSResolver") { 5336 } elsif (IsCallbackInterface($paramType) or $paramType eq "NodeFilter" o r $paramType eq "XPathNSResolver") {
5347 push @arguments, "$paramName.release()"; 5337 push @arguments, "$paramName.release()";
5348 } else { 5338 } else {
5349 push @arguments, $paramName; 5339 push @arguments, $paramName;
5350 } 5340 }
5351 $index++; 5341 $index++;
5352 $humanFriendlyIndex = $index + 1; 5342 $humanFriendlyIndex = $index + 1;
5353 } 5343 }
5354 5344
5345 # Support for returning a union type.
5346 if (IsUnionType($returnType)) {
5347 my $types = $returnType->unionMemberTypes;
5348 for my $i (0 .. scalar(@$types)-1) {
5349 my $unionMemberType = $types->[$i];
5350 my $unionMemberNativeType = GetNativeType($unionMemberType);
5351 my $unionMemberNumber = $i + 1;
5352 my $unionMemberVariable = "result" . $i;
5353 my $unionMemberEnabledVariable = "result" . $i . "Enabled";
5354 $code .= " bool ${unionMemberEnabledVariable} = false;\n";
5355 $code .= " ${unionMemberNativeType} ${unionMemberVariable};\n";
5356 push @arguments, $unionMemberEnabledVariable;
5357 push @arguments, $unionMemberVariable;
5358 }
5359 }
5360
5355 if ($function->extendedAttributes->{"RaisesException"}) { 5361 if ($function->extendedAttributes->{"RaisesException"}) {
5356 push @arguments, "exceptionState"; 5362 push @arguments, "exceptionState";
5357 } 5363 }
5358 5364
5359 my $functionString = "$functionName(" . join(", ", @arguments) . ")"; 5365 my $functionString = "$functionName(" . join(", ", @arguments) . ")";
5360 5366
5361 my $return = "result"; 5367 my $return = "result";
5362 my $returnIsRef = IsRefPtrType($returnType); 5368 my $returnIsRef = IsRefPtrType($returnType);
5363 5369
5364 if ($returnType eq "void") { 5370 if ($returnType eq "void" || IsUnionType($returnType)) {
5365 $code .= $indent . "$functionString;\n"; 5371 $code .= $indent . "$functionString;\n";
5366 } elsif (ExtendedAttributeContains($callWith, "ScriptState") or $function->e xtendedAttributes->{"RaisesException"}) { 5372 } elsif (ExtendedAttributeContains($callWith, "ScriptState") or $function->e xtendedAttributes->{"RaisesException"}) {
5373 my $nativeReturnType = GetNativeType($returnType, {}, "");
5374 $nativeReturnType = GetSVGWrappedTypeNeedingTearOff($returnType) if $isS VGTearOffType;
5375
5367 $code .= $indent . $nativeReturnType . " result = $functionString;\n"; 5376 $code .= $indent . $nativeReturnType . " result = $functionString;\n";
5368 } else { 5377 } else {
5369 # Can inline the function call into the return statement to avoid overhe ad of using a Ref<> temporary 5378 # Can inline the function call into the return statement to avoid overhe ad of using a Ref<> temporary
5370 $return = $functionString; 5379 $return = $functionString;
5371 $returnIsRef = 0; 5380 $returnIsRef = 0;
5372 5381
5373 if ($interfaceName eq "SVGTransformList" and IsRefPtrType($returnType)) { 5382 if ($interfaceName eq "SVGTransformList" and IsRefPtrType($returnType)) {
5374 $return = "WTF::getPtr(" . $return . ")"; 5383 $return = "WTF::getPtr(" . $return . ")";
5375 } 5384 }
5376 } 5385 }
(...skipping 345 matching lines...) Expand 10 before | Expand all | Expand 10 after
5722 $code .= "${indent}if (${unionMemberEnabledVariable}) {\n"; 5731 $code .= "${indent}if (${unionMemberEnabledVariable}) {\n";
5723 $code .= "${returnJSValueCode}\n"; 5732 $code .= "${returnJSValueCode}\n";
5724 $code .= "${indent} return;\n"; 5733 $code .= "${indent} return;\n";
5725 $code .= "${indent}}\n"; 5734 $code .= "${indent}}\n";
5726 } else { 5735 } else {
5727 $code .= "${indent}if (${unionMemberEnabledVariable})\n"; 5736 $code .= "${indent}if (${unionMemberEnabledVariable})\n";
5728 $code .= "${returnJSValueCode}"; 5737 $code .= "${returnJSValueCode}";
5729 } 5738 }
5730 push @codes, $code; 5739 push @codes, $code;
5731 } 5740 }
5741 if ($isReturnValue) {
5742 # Fall back to returning null if none of the union members results a re returned.
5743 push @codes, "${indent}v8SetReturnValueNull(${getCallbackInfo});";
5744 }
5732 return join "\n", @codes; 5745 return join "\n", @codes;
5733 } 5746 }
5734 5747
5735 if ($type eq "boolean") { 5748 if ($type eq "boolean") {
5736 return "${indent}v8SetReturnValueBool(${getCallbackInfo}, ${nativeValue} );" if $isReturnValue; 5749 return "${indent}v8SetReturnValueBool(${getCallbackInfo}, ${nativeValue} );" if $isReturnValue;
5737 return "$indent$receiver v8Boolean($nativeValue, $getIsolate);"; 5750 return "$indent$receiver v8Boolean($nativeValue, $getIsolate);";
5738 } 5751 }
5739 5752
5740 if ($type eq "void") { # equivalent to v8Undefined() 5753 if ($type eq "void") { # equivalent to v8Undefined()
5741 return "" if $isReturnValue; 5754 return "" if $isReturnValue;
(...skipping 725 matching lines...) Expand 10 before | Expand all | Expand 10 after
6467 if ($parameter->type eq "SerializedScriptValue") { 6480 if ($parameter->type eq "SerializedScriptValue") {
6468 return 1; 6481 return 1;
6469 } elsif (IsIntegerType($parameter->type)) { 6482 } elsif (IsIntegerType($parameter->type)) {
6470 return 1; 6483 return 1;
6471 } 6484 }
6472 } 6485 }
6473 return 0; 6486 return 0;
6474 } 6487 }
6475 6488
6476 1; 6489 1;
OLDNEW
« no previous file with comments | « Source/bindings/bindings.gypi ('k') | Source/bindings/tests/idls/TestInterface.idl » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698