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

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

Issue 27100003: Add support for nullable operation arguments in IDL files (Closed) Base URL: svn://svn.chromium.org/blink/trunk
Patch Set: Add test for optional argument Created 7 years, 2 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/idls/TestObject.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 3b6ffeb3d31a5e7db182dcc137091fec3f33ffe7..fe55583aa198c9b14ff762f0dd6f18a6bc76f14e 100644
--- a/Source/bindings/scripts/code_generator_v8.pm
+++ b/Source/bindings/scripts/code_generator_v8.pm
@@ -2475,7 +2475,14 @@ sub GenerateParametersCheck
} elsif ($nativeType =~ /^V8StringResource/) {
my $default = defined $parameter->extendedAttributes->{"Default"} ? $parameter->extendedAttributes->{"Default"} : "";
my $jsValue = $parameter->isOptional && $default eq "NullString" ? "argumentOrNull(args, $paramIndex)" : "args[$paramIndex]";
- $parameterCheckString .= JSValueToNativeStatement($parameter->type, $parameter->extendedAttributes, $jsValue, $parameterName, " ", "args.GetIsolate()");
+ my $stringResourceParameterName = $parameterName;
+ my $isNullable = $parameter->isNullable && !IsRefPtrType($parameter->type);
+ if ($isNullable) {
+ $parameterCheckString .= " bool ${parameterName}IsNull = $jsValue->IsNull();\n";
+ $stringResourceParameterName .= "StringResource";
+ }
+ $parameterCheckString .= JSValueToNativeStatement($parameter->type, $parameter->extendedAttributes, $jsValue, $stringResourceParameterName, " ", "args.GetIsolate()");
+ $parameterCheckString .= " String $parameterName = $stringResourceParameterName;\n" if $isNullable;
if (IsEnumType($parameter->type)) {
my @enumValues = ValidEnumValues($parameter->type);
my @validEqualities = ();
@@ -2508,6 +2515,8 @@ sub GenerateParametersCheck
}
my $default = defined $parameter->extendedAttributes->{"Default"} ? $parameter->extendedAttributes->{"Default"} : "";
my $jsValue = $parameter->isOptional && $default eq "NullString" ? "argumentOrNull(args, $paramIndex)" : "args[$paramIndex]";
+ my $isNullable = $parameter->isNullable && !IsRefPtrType($parameter->type);
+ $parameterCheckString .= " bool ${parameterName}IsNull = $jsValue->IsNull();\n" if $isNullable;
$parameterCheckString .= JSValueToNativeStatement($parameter->type, $parameter->extendedAttributes, $jsValue, $parameterName, " ", "args.GetIsolate()");
if ($nativeType eq 'Dictionary' or $nativeType eq 'ScriptPromise') {
my $humanFriendlyIndex = $paramIndex + 1;
@@ -5053,6 +5062,8 @@ sub GenerateFunctionCallString
$code .= $indent . "}\n";
} elsif ($parameter->type eq "SVGMatrix" and $interfaceName eq "SVGTransformList") {
push @arguments, "$paramName.get()";
+ } elsif ($parameter->isNullable && !IsRefPtrType($parameter->type)) {
+ push @arguments, "${paramName}IsNull ? 0 : &$paramName";
} else {
push @arguments, $paramName;
}
« no previous file with comments | « no previous file | Source/bindings/tests/idls/TestObject.idl » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698