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

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 bindings generator 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
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 867e653790dc0a635d5877009dde6a8a6c713f37..14081e932013b79727aa22426e86afd549cb1187 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,24 @@ END
$code .= <<END;
${implClassName}* imp = ${v8ClassName}::toNative(info.Holder());
END
+ } elsif($attrExt->{"PutForwards"}) {
+ my $attrType = $attribute->type;
haraken 2013/10/15 00:15:37 This is not necessary. $attrType is already define
+ 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") {

Powered by Google App Engine
This is Rietveld 408576698