| Index: Source/bindings/scripts/CodeGenerator.pm
|
| diff --git a/Source/bindings/scripts/CodeGenerator.pm b/Source/bindings/scripts/CodeGenerator.pm
|
| index 094b08125197c7c94570ffda2154e34257a27c83..fc43e4955f680b420987b274feaf41b4018c1859 100644
|
| --- a/Source/bindings/scripts/CodeGenerator.pm
|
| +++ b/Source/bindings/scripts/CodeGenerator.pm
|
| @@ -27,6 +27,7 @@ package CodeGenerator;
|
|
|
| use strict;
|
|
|
| +use File::Basename;
|
| use File::Find;
|
|
|
| my $useDocument = "";
|
| @@ -242,10 +243,8 @@ sub FindSuperMethod
|
| return $indexer;
|
| }
|
|
|
| -sub IDLFileForInterface
|
| -{
|
| +sub PopulateIDLFiles {
|
| my $object = shift;
|
| - my $interfaceName = shift;
|
|
|
| unless ($idlFiles) {
|
| my $sourceRoot = $ENV{SOURCE_ROOT};
|
| @@ -260,6 +259,85 @@ sub IDLFileForInterface
|
| };
|
| find($wanted, @directories);
|
| }
|
| +}
|
| +
|
| +# As per Web IDL specification, for each interface that is a non-callback interface that is
|
| +# not declared with the [NoInterfaceObject] extended attribute, a corresponding property must
|
| +# exist on the ECMAScript global object.
|
| +sub GenerateDOMWindowConstructorAttributes
|
| +{
|
| + my $object = shift;
|
| +
|
| + $object->PopulateIDLFiles();
|
| +
|
| + my @normalAttributes;
|
| + my @enabledAtRuntimeAttributes;
|
| + my @enabledPerContextAttributes;
|
| +
|
| + foreach my $idlFile (values $idlFiles) {
|
| + my $interfaceName = fileparse(basename($idlFile), ".idl");
|
| + # Ignore test IDL files.
|
| + next if $interfaceName =~ /^Test/;
|
| +
|
| + # Optimization: we avoid full Web IDL parsing since we are merely interested
|
| + # in the interface / exception's extended attributes.
|
| + my $parser = IDLParser->new(1);
|
| + my $extendedAttributes = $parser->ParseOnlyExtendedAttributes($idlFile, $defines, $preprocessor);
|
| +
|
| + next if ($extendedAttributes->{"NoInterfaceObject"} || $extendedAttributes->{"Callback"});
|
| +
|
| + my $attribute = domAttribute->new();
|
| + $attribute->type("attribute");
|
| + $attribute->signature(domSignature->new());
|
| + $attribute->signature->type("${interfaceName}Constructor");
|
| +
|
| + if ($extendedAttributes->{"InterfaceName"}) {
|
| + $attribute->signature->name($extendedAttributes->{"InterfaceName"});
|
| + } else {
|
| + $attribute->signature->name($interfaceName);
|
| + }
|
| +
|
| + # In addition to the regular property, for every [NamedConstructor] extended attribute on an interface,
|
| + # a corresponding property MUST exist on the ECMAScript global object.
|
| + my $namedConstructorAttribute;
|
| + if ($extendedAttributes->{"NamedConstructor"}) {
|
| + $namedConstructorAttribute = domAttribute->new();
|
| + $namedConstructorAttribute->type("attribute");
|
| + $namedConstructorAttribute->signature(domSignature->new());
|
| + $namedConstructorAttribute->signature->type("${interfaceName}ConstructorConstructor");
|
| + my $constructorName = (keys $extendedAttributes->{"NamedConstructor"})[0];
|
| + $namedConstructorAttribute->signature->name($constructorName);
|
| + }
|
| +
|
| + my $attrExtendedAttributeList = {};
|
| + if ($extendedAttributes->{"Conditional"}) {
|
| + $attrExtendedAttributeList->{"Conditional"} = $extendedAttributes->{"Conditional"};
|
| + }
|
| + if ($extendedAttributes->{"EnabledAtRuntime"}) {
|
| + $attrExtendedAttributeList->{"EnabledAtRuntime"} = $extendedAttributes->{"EnabledAtRuntime"};
|
| + push(@enabledAtRuntimeAttributes, $attribute);
|
| + push(@enabledAtRuntimeAttributes, $namedConstructorAttribute) if $namedConstructorAttribute;
|
| + } elsif ($extendedAttributes->{"EnabledPerContext"}) {
|
| + $attrExtendedAttributeList->{"EnabledPerContext"} = $extendedAttributes->{"EnabledPerContext"};
|
| + push(@enabledPerContextAttributes, $attribute);
|
| + push(@enabledPerContextAttributes, $namedConstructorAttribute) if $namedConstructorAttribute;
|
| + } else {
|
| + push(@normalAttributes, $attribute);
|
| + push(@normalAttributes, $namedConstructorAttribute) if $namedConstructorAttribute;
|
| + }
|
| + $attribute->signature->extendedAttributes($attrExtendedAttributeList);
|
| + $namedConstructorAttribute->signature->extendedAttributes($attrExtendedAttributeList) if $namedConstructorAttribute;
|
| + }
|
| +
|
| + return (\@normalAttributes, \@enabledAtRuntimeAttributes, \@enabledPerContextAttributes);
|
| +}
|
| +
|
| +sub IDLFileForInterface
|
| +{
|
| + my $object = shift;
|
| + my $interfaceName = shift;
|
| +
|
| + $object->PopulateIDLFiles();
|
|
|
| return $idlFiles->{$interfaceName};
|
| }
|
|
|