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

Unified 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « Source/bindings/bindings.gypi ('k') | Source/bindings/tests/idls/TestInterface.idl » ('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 6497348f8c2d332f631f63f046a2c90ca19a66c8..5538553a44834602acfdc3d8d14995183736e428 100644
--- a/Source/bindings/scripts/code_generator_v8.pm
+++ b/Source/bindings/scripts/code_generator_v8.pm
@@ -8,7 +8,7 @@
# Copyright (C) Research In Motion Limited 2010. All rights reserved.
# Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies)
# Copyright (C) 2012 Ericsson AB. All rights reserved.
-# Copyright (C) 2013 Samsung Electronics. All rights reserved.
+# Copyright (C) 2013, 2014 Samsung Electronics. All rights reserved.
#
# This library is free software; you can redistribute it and/or
# modify it under the terms of the GNU Library General Public
@@ -3583,10 +3583,8 @@ sub GenerateIsNullExpression
my $types = $type->unionMemberTypes;
my @expression = ();
for my $i (0 .. scalar(@$types)-1) {
- my $unionMemberType = $types->[$i];
- my $unionMemberVariable = $variableName . $i;
- my $isNull = GenerateIsNullExpression($unionMemberType, $unionMemberVariable);
- push @expression, $isNull;
+ my $unionMemberEnabledVariable = $variableName . $i . "Enabled";
+ push @expression, "!${unionMemberEnabledVariable}";
}
return join " && ", @expression;
}
@@ -4099,14 +4097,9 @@ sub GenerateImplementationNamedPropertyGetter
$code .= " if (exceptionState.throwIfNeeded())\n";
$code .= " return;\n";
}
- if (IsUnionType($returnType)) {
- $code .= "${returnJSValueCode}\n";
- $code .= " return;\n";
- } else {
- $code .= " if (${isNull})\n";
- $code .= " return;\n";
- $code .= $returnJSValueCode . "\n";
- }
+ $code .= " if (${isNull})\n";
+ $code .= " return;\n";
+ $code .= $returnJSValueCode . "\n";
$code .= "}\n\n";
$implementation{nameSpaceInternal}->add($code);
}
@@ -5280,11 +5273,8 @@ sub GenerateFunctionCallString
my $implClassName = GetImplName($interface);
my $name = GetImplName($function);
my $returnType = $function->type;
- my $nativeReturnType = GetNativeType($returnType, {}, "");
my $code = "";
-
my $isSVGTearOffType = (IsSVGTypeNeedingTearOff($returnType) and not $interfaceName =~ /List$/);
- $nativeReturnType = GetSVGWrappedTypeNeedingTearOff($returnType) if $isSVGTearOffType;
my $index = 0;
my $humanFriendlyIndex = $index + 1;
@@ -5352,6 +5342,22 @@ END
$humanFriendlyIndex = $index + 1;
}
+ # Support for returning a union type.
+ if (IsUnionType($returnType)) {
+ my $types = $returnType->unionMemberTypes;
+ for my $i (0 .. scalar(@$types)-1) {
+ my $unionMemberType = $types->[$i];
+ my $unionMemberNativeType = GetNativeType($unionMemberType);
+ my $unionMemberNumber = $i + 1;
+ my $unionMemberVariable = "result" . $i;
+ my $unionMemberEnabledVariable = "result" . $i . "Enabled";
+ $code .= " bool ${unionMemberEnabledVariable} = false;\n";
+ $code .= " ${unionMemberNativeType} ${unionMemberVariable};\n";
+ push @arguments, $unionMemberEnabledVariable;
+ push @arguments, $unionMemberVariable;
+ }
+ }
+
if ($function->extendedAttributes->{"RaisesException"}) {
push @arguments, "exceptionState";
}
@@ -5361,9 +5367,12 @@ END
my $return = "result";
my $returnIsRef = IsRefPtrType($returnType);
- if ($returnType eq "void") {
+ if ($returnType eq "void" || IsUnionType($returnType)) {
$code .= $indent . "$functionString;\n";
} elsif (ExtendedAttributeContains($callWith, "ScriptState") or $function->extendedAttributes->{"RaisesException"}) {
+ my $nativeReturnType = GetNativeType($returnType, {}, "");
+ $nativeReturnType = GetSVGWrappedTypeNeedingTearOff($returnType) if $isSVGTearOffType;
+
$code .= $indent . $nativeReturnType . " result = $functionString;\n";
} else {
# Can inline the function call into the return statement to avoid overhead of using a Ref<> temporary
@@ -5729,6 +5738,10 @@ sub NativeToJSValue
}
push @codes, $code;
}
+ if ($isReturnValue) {
+ # Fall back to returning null if none of the union members results are returned.
+ push @codes, "${indent}v8SetReturnValueNull(${getCallbackInfo});";
+ }
return join "\n", @codes;
}
« 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