@@ -1077,9 +1077,20 @@ def finish(self, scope):
1077
1077
1078
1078
ctor = self .ctor ()
1079
1079
if ctor is not None :
1080
- assert len (ctor ._exposureGlobalNames ) == 0
1080
+ if not self .hasInterfaceObject ():
1081
+ raise WebIDLError (
1082
+ "Can't have both a constructor and [NoInterfaceObject]" ,
1083
+ [self .location , ctor .location ])
1084
+
1085
+ assert (len (ctor ._exposureGlobalNames ) == 0 or
1086
+ ctor ._exposureGlobalNames == self ._exposureGlobalNames )
1081
1087
ctor ._exposureGlobalNames .update (self ._exposureGlobalNames )
1082
- ctor .finish (scope )
1088
+ if ctor in self .members :
1089
+
1090
+ self .members .remove (ctor )
1091
+ else :
1092
+
1093
+ ctor .finish (scope )
1083
1094
1084
1095
for ctor in self .namedConstructors :
1085
1096
assert len (ctor ._exposureGlobalNames ) == 0
@@ -1741,19 +1752,15 @@ def addExtendedAttributes(self, attrs):
1741
1752
name = attr .value ()
1742
1753
allowForbidden = False
1743
1754
1744
- methodIdentifier = IDLUnresolvedIdentifier (self .location , name ,
1745
- allowForbidden = allowForbidden )
1755
+ method = IDLConstructor (
1756
+ attr .location , args , name ,
1757
+ htmlConstructor = (identifier == "HTMLConstructor" ))
1758
+ method .reallyInit (self )
1746
1759
1747
- method = IDLMethod (self .location , methodIdentifier , retType ,
1748
- args , static = True ,
1749
- htmlConstructor = (identifier == "HTMLConstructor" ))
1750
-
1751
-
1752
1760
1753
1761
1754
1762
method .addExtendedAttributes (
1755
- [IDLExtendedAttribute (self .location , ("NewObject" ,)),
1756
- IDLExtendedAttribute (self .location , ("Throws" ,))])
1763
+ [IDLExtendedAttribute (self .location , ("Throws" ,))])
1757
1764
if identifier == "ChromeConstructor" :
1758
1765
method .addExtendedAttributes (
1759
1766
[IDLExtendedAttribute (self .location , ("ChromeOnly" ,))])
@@ -1887,6 +1894,17 @@ def validate(self):
1887
1894
def isSerializable (self ):
1888
1895
return self .getExtendedAttribute ("Serializable" )
1889
1896
1897
+ def setNonPartial (self , location , parent , members ):
1898
+
1899
+
1900
+
1901
+
1902
+ for member in members :
1903
+ if isinstance (member , IDLConstructor ):
1904
+ member .reallyInit (self )
1905
+
1906
+ IDLInterfaceOrNamespace .setNonPartial (self , location , parent , members )
1907
+
1890
1908
1891
1909
class IDLNamespace (IDLInterfaceOrNamespace ):
1892
1910
def __init__ (self , location , parentScope , name , members , isKnownNonPartial ):
@@ -5481,6 +5499,52 @@ def _getDependentObjects(self):
5481
5499
return deps
5482
5500
5483
5501
5502
+ class IDLConstructor (IDLMethod ):
5503
+ def __init__ (self , location , args , name , htmlConstructor = False ):
5504
+
5505
+
5506
+
5507
+ self ._initLocation = location
5508
+ self ._initArgs = args
5509
+ self ._initName = name
5510
+ self ._htmlConstructor = htmlConstructor
5511
+ self ._inited = False
5512
+ self ._initExtendedAttrs = []
5513
+
5514
+ def addExtendedAttributes (self , attrs ):
5515
+ if self ._inited :
5516
+ return IDLMethod .addExtendedAttributes (self , attrs )
5517
+ self ._initExtendedAttrs .extend (attrs )
5518
+
5519
+ def handleExtendedAttribute (self , attr ):
5520
+ identifier = attr .identifier ()
5521
+ if (identifier == "BinaryName" or
5522
+ identifier == "ChromeOnly" or
5523
+ identifier == "NewObject" or
5524
+ identifier == "SecureContext" or
5525
+ identifier == "Throws" ):
5526
+ IDLMethod .handleExtendedAttribute (self , attr )
5527
+ else :
5528
+ raise WebIDLError ("Unknown extended attribute %s on method" % identifier ,
5529
+ [attr .location ])
5530
+
5531
+ def reallyInit (self , parentInterface ):
5532
+ name = self ._initName
5533
+ location = self ._initLocation
5534
+ identifier = IDLUnresolvedIdentifier (location , name , allowForbidden = True )
5535
+ retType = IDLWrapperType (parentInterface .location , parentInterface )
5536
+ IDLMethod .__init__ (self , location , identifier , retType , self ._initArgs ,
5537
+ static = True , htmlConstructor = self ._htmlConstructor )
5538
+ self ._inited = True ;
5539
+
5540
+ self .addExtendedAttributes (self ._initExtendedAttrs )
5541
+ self ._initExtendedAttrs = []
5542
+
5543
+
5544
+ self .addExtendedAttributes (
5545
+ [IDLExtendedAttribute (self .location , ("NewObject" ,))])
5546
+
5547
+
5484
5548
class IDLImplementsStatement (IDLObject ):
5485
5549
def __init__ (self , location , implementor , implementee ):
5486
5550
IDLObject .__init__ (self , location )
@@ -6061,7 +6125,7 @@ def p_PartialInterfaceOrPartialMixin(self, p):
6061
6125
6062
6126
def p_PartialInterfaceRest (self , p ):
6063
6127
"""
6064
- PartialInterfaceRest : IDENTIFIER LBRACE InterfaceMembers RBRACE SEMICOLON
6128
+ PartialInterfaceRest : IDENTIFIER LBRACE PartialInterfaceMembers RBRACE SEMICOLON
6065
6129
"""
6066
6130
location = self .getLocation (p , 1 )
6067
6131
identifier = IDLUnresolvedIdentifier (location , p [1 ])
@@ -6142,8 +6206,38 @@ def p_InterfaceMembersEmpty(self, p):
6142
6206
6143
6207
def p_InterfaceMember (self , p ):
6144
6208
"""
6145
- InterfaceMember : Const
6146
- | AttributeOrOperationOrMaplikeOrSetlikeOrIterable
6209
+ InterfaceMember : PartialInterfaceMember
6210
+ | Constructor
6211
+ """
6212
+ p [0 ] = p [1 ]
6213
+
6214
+ def p_Constructor (self , p ):
6215
+ """
6216
+ Constructor : CONSTRUCTOR LPAREN ArgumentList RPAREN SEMICOLON
6217
+ """
6218
+ p [0 ] = IDLConstructor (self .getLocation (p , 1 ), p [3 ], "constructor" )
6219
+
6220
+ def p_PartialInterfaceMembers (self , p ):
6221
+ """
6222
+ PartialInterfaceMembers : ExtendedAttributeList PartialInterfaceMember PartialInterfaceMembers
6223
+ """
6224
+ p [0 ] = [p [2 ]]
6225
+
6226
+ assert not p [1 ] or p [2 ]
6227
+ p [2 ].addExtendedAttributes (p [1 ])
6228
+
6229
+ p [0 ].extend (p [3 ])
6230
+
6231
+ def p_PartialInterfaceMembersEmpty (self , p ):
6232
+ """
6233
+ PartialInterfaceMembers :
6234
+ """
6235
+ p [0 ] = []
6236
+
6237
+ def p_PartialInterfaceMember (self , p ):
6238
+ """
6239
+ PartialInterfaceMember : Const
6240
+ | AttributeOrOperationOrMaplikeOrSetlikeOrIterable
6147
6241
"""
6148
6242
p [0 ] = p [1 ]
6149
6243
0 commit comments