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

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

Issue 26694003: Add support for [TreatNullAs] extended attribute for reflected attributes (Closed) Base URL: svn://svn.chromium.org/blink/trunk
Patch Set: Move code to a subroutine 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 9185d92b90bad683c4c95297deab675db1f0b256..5dd3f0ba24ca12665acd48a89f55a3406625649e 100644
--- a/Source/bindings/scripts/code_generator_v8.pm
+++ b/Source/bindings/scripts/code_generator_v8.pm
@@ -588,6 +588,23 @@ sub GetSpecialAccessorFunctionForType
return 0;
}
+sub GetV8StringResourceMode
+{
+ my $extendedAttributes = shift;
+
+ # Blink uses the non-standard identifier NullString instead of Web IDL
+ # standard EmptyString, in [TreatNullAs=NullString] and [TreatUndefinedAs=NullString],
+ # and does not support [TreatUndefinedAs=Null] or [TreatUndefinedAs=Missing]
+ # https://sites.google.com/a/chromium.org/dev/blink/webidl/blink-idl-extended-attributes#TOC-TreatNullAs-a-p-TreatUndefinedAs-a-p-
+ my $mode = "";
+ if (($extendedAttributes->{"TreatNullAs"} and $extendedAttributes->{"TreatNullAs"} eq "NullString") and ($extendedAttributes->{"TreatUndefinedAs"} and $extendedAttributes->{"TreatUndefinedAs"} eq "NullString")) {
+ $mode = "WithUndefinedOrNullCheck";
+ } elsif ($extendedAttributes->{"TreatNullAs"} and $extendedAttributes->{"TreatNullAs"} eq "NullString") {
+ $mode = "WithNullCheck";
+ }
+ return $mode;
+}
+
sub GenerateHeader
{
my $object = shift;
@@ -1840,9 +1857,10 @@ END
# Generate super-compact call for regular attribute setter:
my $contentAttributeName = $reflect eq "VALUE_IS_MISSING" ? lc $attrName : $reflect;
my $namespace = NamespaceForAttributeName($interfaceName, $contentAttributeName);
+ my $mode = GetV8StringResourceMode($attribute->extendedAttributes);
AddToImplIncludes("${namespace}.h");
$code .= " Element* imp = V8Element::toNative(info.Holder());\n";
- $code .= " V8TRYCATCH_FOR_V8STRINGRESOURCE_VOID(V8StringResource<WithNullCheck>, stringResource, value);\n";
+ $code .= " V8TRYCATCH_FOR_V8STRINGRESOURCE_VOID(V8StringResource<$mode>, stringResource, value);\n";
# Attr (not Attribute) used in content attributes
$code .= " imp->setAttribute(${namespace}::${contentAttributeName}Attr, stringResource);\n";
$code .= "}\n\n";
@@ -5144,16 +5162,7 @@ sub GetNativeType
return "bool" if $type eq "boolean";
if (($type eq "DOMString" || IsEnumType($type)) and $isParameter) {
- # Blink uses the non-standard identifier NullString instead of Web IDL
- # standard EmptyString, in [TreatNullAs=NullString] and [TreatUndefinedAs=NullString],
- # and does not support [TreatUndefinedAs=Null] or [TreatUndefinedAs=Missing]
- # https://sites.google.com/a/chromium.org/dev/blink/webidl/blink-idl-extended-attributes#TOC-TreatNullAs-a-p-TreatUndefinedAs-a-p-
- my $mode = "";
- if (($extendedAttributes->{"TreatNullAs"} and $extendedAttributes->{"TreatNullAs"} eq "NullString") and ($extendedAttributes->{"TreatUndefinedAs"} and $extendedAttributes->{"TreatUndefinedAs"} eq "NullString")) {
- $mode = "WithUndefinedOrNullCheck";
- } elsif (($extendedAttributes->{"TreatNullAs"} and $extendedAttributes->{"TreatNullAs"} eq "NullString") or $extendedAttributes->{"Reflect"}) {
- $mode = "WithNullCheck";
- }
+ my $mode = GetV8StringResourceMode($extendedAttributes);
# FIXME: Add the case for 'elsif ($attributeOrParameter->extendedAttributes->{"TreatUndefinedAs"} and $attributeOrParameter->extendedAttributes->{"TreatUndefinedAs"} eq "NullString"))'.
return "V8StringResource<$mode>";
}
« 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