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

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

Issue 23479016: Introduce Promise mapping to the IDL generator (Closed) Base URL: https://chromium.googlesource.com/chromium/blink.git@master
Patch Set: Created 7 years, 3 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/deprecated_code_generator_v8.pm
diff --git a/Source/bindings/scripts/deprecated_code_generator_v8.pm b/Source/bindings/scripts/deprecated_code_generator_v8.pm
index d2d481b7ef8de9fed26fc84447f6f9a9378d78c0..bd0552e00f039605b24b7220eee799c2e7531738 100644
--- a/Source/bindings/scripts/deprecated_code_generator_v8.pm
+++ b/Source/bindings/scripts/deprecated_code_generator_v8.pm
@@ -148,9 +148,12 @@ my %header;
# NameSpaceInternal ... namespace ${implClassName}V8Internal in case of non-callback
my %implementation;
+# Promise is not yet in the Web IDL spec but is going to be speced
+# as primitive types in the future.
my %primitiveTypeHash = ("boolean" => 1,
"void" => 1,
"Date" => 1,
+ "Promise" => 1,
"byte" => 1,
"octet" => 1,
"short" => 1,
@@ -427,6 +430,8 @@ sub AddIncludesForType
AddToImplIncludes("bindings/v8/SerializedScriptValue.h");
} elsif ($type eq "any" || IsCallbackFunctionType($type)) {
AddToImplIncludes("bindings/v8/ScriptValue.h");
+ } elsif ($type eq "Promise") {
+ AddToImplIncludes("bindings/v8/ScriptPromise.h");
} elsif (IsTypedArrayType($type)) {
AddToImplIncludes("bindings/v8/custom/V8${type}Custom.h");
} else {
@@ -2458,7 +2463,7 @@ sub GenerateParametersCheck
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()");
- if ($nativeType eq 'Dictionary') {
+ if ($nativeType eq 'Dictionary' or $nativeType eq 'ScriptPromise') {
$parameterCheckString .= " if (!$parameterName.isUndefinedOrNull() && !$parameterName.isObject()) {\n";
$parameterCheckString .= " throwTypeError(\"Not an object.\", args.GetIsolate());\n";
$parameterCheckString .= " return;\n";
@@ -3161,6 +3166,8 @@ sub GenerateIsNullExpression
return "!${variableName}";
} elsif ($type eq "DOMString") {
return "${variableName}.isNull()";
+ } elsif ($type eq "Promise") {
+ return "${variableName}.isNull()";
} else {
return "";
}
@@ -5010,6 +5017,8 @@ sub GetNativeType
return "String" if $type eq "DOMString" or IsEnumType($type);
+ return "ScriptPromise" if $type eq "Promise";
+
return "Range::CompareHow" if $type eq "CompareHow";
return "DOMTimeStamp" if $type eq "DOMTimeStamp";
return "double" if $type eq "Date";
@@ -5138,6 +5147,11 @@ sub JSValueToNative
return "ScriptValue($value)";
}
+ if ($type eq "Promise") {
+ AddToImplIncludes("bindings/v8/ScriptPromise.h");
+ return "ScriptPromise($value)";
+ }
+
if ($type eq "NodeFilter") {
return "toNodeFilter($value, $getIsolate)";
}
@@ -5418,7 +5432,7 @@ sub NativeToJSValue
return "$indent$receiver v8::Number::New($nativeValue);";
}
- if ($nativeType eq "ScriptValue") {
+ if ($nativeType eq "ScriptValue" or $nativeType eq "ScriptPromise") {
return "${indent}v8SetReturnValue(${getCallbackInfo}, ${nativeValue}.v8Value());" if $isReturnValue;
return "$indent$receiver $nativeValue.v8Value();";
}

Powered by Google App Engine
This is Rietveld 408576698