|
29 | 29 | my $idlFilesList; |
30 | 30 | my $supplementalDependencyFile; |
31 | 31 | my $windowConstructorsFile; |
| 32 | +my $workerContextConstructorsFile; |
32 | 33 | my $supplementalMakefileDeps; |
33 | 34 |
|
34 | 35 | GetOptions('defines=s' => \$defines, |
35 | 36 | 'preprocessor=s' => \$preprocessor, |
36 | 37 | 'idlFilesList=s' => \$idlFilesList, |
37 | 38 | 'supplementalDependencyFile=s' => \$supplementalDependencyFile, |
38 | 39 | 'windowConstructorsFile=s' => \$windowConstructorsFile, |
| 40 | + 'workerContextConstructorsFile=s' => \$workerContextConstructorsFile, |
39 | 41 | 'supplementalMakefileDeps=s' => \$supplementalMakefileDeps); |
40 | 42 |
|
41 | 43 | die('Must specify #define macros using --defines.') unless defined($defines); |
42 | 44 | die('Must specify an output file using --supplementalDependencyFile.') unless defined($supplementalDependencyFile); |
43 | 45 | die('Must specify an output file using --windowConstructorsFile.') unless defined($windowConstructorsFile); |
| 46 | +die('Must specify an output file using --workerContextConstructorsFile.') unless defined($workerContextConstructorsFile); |
44 | 47 | die('Must specify the file listing all IDLs using --idlFilesList.') unless defined($idlFilesList); |
45 | 48 |
|
46 | 49 | open FH, "< $idlFilesList" or die "Cannot open $idlFilesList\n"; |
|
53 | 56 | my %idlFileToInterfaceName; |
54 | 57 | my %supplementalDependencies; |
55 | 58 | my %supplementals; |
56 | | -my $constructorAttributesCode = ""; |
| 59 | +my $windowConstructorsCode = ""; |
| 60 | +my $workerContextConstructorsCode = ""; |
57 | 61 | # Get rid of duplicates in idlFiles array. |
58 | 62 | my %idlFileHash = map { $_, 1 } @idlFiles; |
59 | 63 | foreach my $idlFile (keys %idlFileHash) { |
|
68 | 72 | unless (isCallbackInterfaceFromIDL($idlFileContents)) { |
69 | 73 | my $extendedAttributes = getInterfaceExtendedAttributesFromIDL($idlFileContents); |
70 | 74 | unless ($extendedAttributes->{"NoInterfaceObject"}) { |
71 | | - $constructorAttributesCode .= GenerateConstructorAttribute($interfaceName, $extendedAttributes); |
| 75 | + my $globalContext = $extendedAttributes->{"GlobalContext"} || "WindowOnly"; |
| 76 | + my $attributeCode = GenerateConstructorAttribute($interfaceName, $extendedAttributes); |
| 77 | + $windowConstructorsCode .= $attributeCode unless $globalContext eq "WorkerOnly"; |
| 78 | + $workerContextConstructorsCode .= $attributeCode unless $globalContext eq "WindowOnly" |
72 | 79 | } |
73 | 80 | } |
74 | 81 | $interfaceNameToIdlFile{$interfaceName} = $fullPath; |
|
77 | 84 | } |
78 | 85 |
|
79 | 86 | # Generate DOMWindow Constructors partial interface. |
80 | | -open PARTIAL_WINDOW_FH, "> $windowConstructorsFile" or die "Cannot open $windowConstructorsFile\n"; |
81 | | -print PARTIAL_WINDOW_FH "partial interface DOMWindow {\n"; |
82 | | -print PARTIAL_WINDOW_FH $constructorAttributesCode; |
83 | | -print PARTIAL_WINDOW_FH "};\n"; |
84 | | -close PARTIAL_WINDOW_FH; |
85 | | -my $fullPath = Cwd::realpath($windowConstructorsFile); |
86 | | -$supplementalDependencies{$fullPath} = "DOMWindow" if $interfaceNameToIdlFile{"DOMWindow"}; |
| 87 | +GeneratePartialInterface("DOMWindow", $windowConstructorsCode, $windowConstructorsFile); |
| 88 | + |
| 89 | +# Generate WorkerContext Constructors partial interface. |
| 90 | +GeneratePartialInterface("WorkerContext", $workerContextConstructorsCode, $workerContextConstructorsFile); |
87 | 91 |
|
88 | 92 | # Resolves partial interfaces dependencies. |
89 | 93 | foreach my $idlFile (keys %supplementalDependencies) { |
|
132 | 136 | close MAKE_FH; |
133 | 137 | } |
134 | 138 |
|
| 139 | +sub GeneratePartialInterface |
| 140 | +{ |
| 141 | + my $interfaceName = shift; |
| 142 | + my $attributesCode = shift; |
| 143 | + my $destinationFile = shift; |
| 144 | + |
| 145 | + # Generate partial interface for global constructors. |
| 146 | + open PARTIAL_INTERFACE_FH, "> $destinationFile" or die "Cannot open $destinationFile\n"; |
| 147 | + print PARTIAL_INTERFACE_FH "partial interface ${interfaceName} {\n"; |
| 148 | + print PARTIAL_INTERFACE_FH $attributesCode; |
| 149 | + print PARTIAL_INTERFACE_FH "};\n"; |
| 150 | + close PARTIAL_INTERFACE_FH; |
| 151 | + my $fullPath = Cwd::realpath($destinationFile); |
| 152 | + $supplementalDependencies{$fullPath} = $interfaceName if $interfaceNameToIdlFile{$interfaceName}; |
| 153 | +} |
| 154 | + |
135 | 155 | sub GenerateConstructorAttribute |
136 | 156 | { |
137 | 157 | my $interfaceName = shift; |
|
0 commit comments