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

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: rebased 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
« no previous file with comments | « no previous file | Source/bindings/tests/results/V8TestInterface.cpp » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: Source/bindings/scripts/CodeGeneratorV8.pm
diff --git a/Source/bindings/scripts/CodeGeneratorV8.pm b/Source/bindings/scripts/CodeGeneratorV8.pm
index 78e1320a71698345a736d8159068f13845390768..30fd8ac3e57ebdb1c8c19dcacd21b40ae9f352e6 100644
--- a/Source/bindings/scripts/CodeGeneratorV8.pm
+++ b/Source/bindings/scripts/CodeGeneratorV8.pm
@@ -3030,8 +3030,10 @@ sub GenerateIsNullExpression
}
if (IsRefPtrType($type)) {
return "!${variableName}";
- } else {
+ } elsif ($type eq "DOMString") {
return "${variableName}.isNull()";
+ } else {
+ return "";
}
}
@@ -3197,7 +3199,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;
@@ -4721,12 +4726,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') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698