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

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

Issue 27207002: Add support for [PutForwards] IDL extended attribute (Closed) Base URL: svn://svn.chromium.org/blink/trunk
Patch Set: Fix nits 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 | « Source/bindings/scripts/IDLAttributes.txt ('k') | Source/bindings/tests/idls/TestNode.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 f053692c922f96e50389668ba3c3a168e7a8b952..886ed7d7003417adba21f53f45d0ac51515a35f9 100644
--- a/Source/bindings/scripts/code_generator_v8.pm
+++ b/Source/bindings/scripts/code_generator_v8.pm
@@ -1119,7 +1119,7 @@ sub IsReadonly
{
my $attribute = shift;
my $attrExt = $attribute->extendedAttributes;
- return $attribute->isReadOnly && !$attrExt->{"Replaceable"};
+ return $attribute->isReadOnly && !$attrExt->{"Replaceable"} && !$attrExt->{"PutForwards"};
}
sub GetV8ClassName
@@ -1789,6 +1789,18 @@ sub GenerateNormalAttributeSetterCallback
$implementation{nameSpaceInternal}->add($code);
}
+sub FindAttributeWithName
+{
+ my $interface = shift;
+ my $attrName = shift;
+
+ foreach my $attribute (@{$interface->attributes}) {
+ if ($attribute->name eq $attrName) {
+ return $attribute;
+ }
+ }
+}
+
sub GenerateNormalAttributeSetter
{
my $attribute = shift;
@@ -1850,6 +1862,23 @@ END
$code .= <<END;
${implClassName}* imp = ${v8ClassName}::toNative(info.Holder());
END
+ } elsif($attrExt->{"PutForwards"}) {
+ my $destinationAttrName = $attrExt->{"PutForwards"};
+ my $destinationInterface = ParseInterface($attrType);
+ die "[PutForwards=x] value must be a wrapper type" unless $destinationInterface;
+ my $destinationAttribute = FindAttributeWithName($destinationInterface, $destinationAttrName);
+ die "[PutForwards=x] could not find $destinationAttrName in interface $attrType" unless $destinationAttribute;
+ $code .= <<END;
+ ${implClassName}* proxyImp = ${v8ClassName}::toNative(info.Holder());
+ ${attrType}* imp = proxyImp->${attrName}();
+ if (!imp)
+ return;
+END
+ # Override attribute and fall through to forward setter call.
+ $attribute = $destinationAttribute;
+ $attrName = $attribute->name;
+ $attrType = $attribute->type;
+ $attrExt = $attribute->extendedAttributes;
} else {
my $reflect = $attribute->extendedAttributes->{"Reflect"};
if ($reflect && InheritsInterface($interface, "Node") && $attrType eq "DOMString") {
« no previous file with comments | « Source/bindings/scripts/IDLAttributes.txt ('k') | Source/bindings/tests/idls/TestNode.idl » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698