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

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

Issue 15841004: [Binding] Support primitive type for union member (Closed) Base URL: https://chromium.googlesource.com/chromium/blink@master
Patch Set: Created 7 years, 7 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
Index: Source/bindings/scripts/CodeGeneratorV8.pm
diff --git a/Source/bindings/scripts/CodeGeneratorV8.pm b/Source/bindings/scripts/CodeGeneratorV8.pm
index 6604cd55774e47f935bae5094c0c56a575d48261..137e5eb96061df4c2cf83550a792cf70397bc16a 100644
--- a/Source/bindings/scripts/CodeGeneratorV8.pm
+++ b/Source/bindings/scripts/CodeGeneratorV8.pm
@@ -3031,8 +3031,10 @@ sub GenerateIsNullExpression
}
if (IsRefPtrType($type)) {
return "!${variableName}";
- } else {
+ } elsif ($type eq "DOMString") {
return "${variableName}.isNull()";
+ } else {
+ return "";
}
}
@@ -3198,7 +3200,10 @@ sub GenerateMethodCall
my $unionMemberType = $returnType->unionMemberTypes->[$i];
my $nativeType = GetNativeType($unionMemberType);
my $unionMemberVariable = $returnName . $i;
+ my $unionMemberEnabledVariable = $returnName . $i . "Enabled";
+ $code .= " bool ${unionMemberEnabledVariable} = false;\n";
$code .= " ${nativeType} ${unionMemberVariable};\n";
+ push @extraArguments, $unionMemberEnabledVariable;
push @extraArguments, $unionMemberVariable;
}
push @arguments, @extraArguments;
@@ -4732,12 +4737,14 @@ sub NativeToJSValue
my $unionMemberType = $types->[$i];
my $unionMemberNumber = $i + 1;
my $unionMemberVariable = $nativeValue . $i;
+ my $unionMemberEnabledVariable = $nativeValue . $i . "Enabled";
my $unionMemberNativeValue = $unionMemberVariable;
$unionMemberNativeValue .= ".release()" if (IsRefPtrType($unionMemberType));
my $returnJSValueCode = NativeToJSValue($unionMemberType, $extendedAttributes, $unionMemberNativeValue, $indent . " ", $receiver, $getCreationContext, $getIsolate, $getHolderContainer, $getScriptWrappable, $returnHandleType, $forMainWorldSuffix);
- my $isNotNull = "!" . GenerateIsNullExpression($unionMemberType, $unionMemberVariable);
+ my $isNotNull = GenerateIsNullExpression($unionMemberType, $unionMemberVariable);
+ $isNotNull = " && !" . $isNotNull if $isNotNull;
my $code = "";
- $code .= "${indent}if (${isNotNull})\n";
+ $code .= "${indent}if (${unionMemberEnabledVariable}${isNotNull})\n";
$code .= "${returnJSValueCode}";
push @codes, $code;
}
« no previous file with comments | « no previous file | Source/bindings/tests/results/V8TestInterface.cpp » ('j') | Source/bindings/tests/results/V8TestInterface.cpp » ('J')

Powered by Google App Engine
This is Rietveld 408576698