Bug 1132252. An interface with an interface object should not inherit from one that's [NoInterfaceObject]. r=smaug
authorBoris Zbarsky <bzbarsky@mit.edu>
Thu, 12 Feb 2015 18:39:26 -0500
changeset 228911 2a86d483ecfbb6fdcc275084e2cbcc83a295317e
parent 228910 41bae3906d5537dd0ff2a72623ab6a74f516e85a
child 228912 340f5b53053644af97ce12e7e03a57fa9cf2fe9f
push idunknown
push userunknown
push dateunknown
reviewerssmaug
bugs1132252
milestone38.0a1
Bug 1132252. An interface with an interface object should not inherit from one that's [NoInterfaceObject]. r=smaug
dom/bindings/Codegen.py
dom/bindings/parser/WebIDL.py
--- a/dom/bindings/Codegen.py
+++ b/dom/bindings/Codegen.py
@@ -682,22 +682,19 @@ def InterfaceObjectProtoGetter(descripto
 
         1) The name of the function to call to get the prototype to use for the
            interface object as a JSObject*.
 
         2) The name of the function to call to get the prototype to use for the
            interface prototype as a JS::Handle<JSObject*> or None if no such
            function exists.
     """
-    parentWithInterfaceObject = descriptor.interface.parent
-    while (parentWithInterfaceObject and
-           not parentWithInterfaceObject.hasInterfaceObject()):
-        parentWithInterfaceObject = parentWithInterfaceObject.parent
-    if parentWithInterfaceObject:
-        parentIfaceName = parentWithInterfaceObject.identifier.name
+    parentInterface = descriptor.interface.parent
+    if parentInterface:
+        parentIfaceName = parentInterface.identifier.name
         parentDesc = descriptor.getDescriptor(parentIfaceName)
         prefix = toBindingNamespace(parentDesc.name)
         protoGetter = prefix + "::GetConstructorObject"
         protoHandleGetter = prefix + "::GetConstructorObjectHandle"
     else:
         protoGetter = "JS_GetFunctionPrototype"
         protoHandleGetter = None
     return (protoGetter, protoHandleGetter)
--- a/dom/bindings/parser/WebIDL.py
+++ b/dom/bindings/parser/WebIDL.py
@@ -748,16 +748,27 @@ class IDLInterface(IDLObjectWithScope, I
                                       [self.location, self.parent.location])
             elif self.parent.isCallback():
                 raise WebIDLError("Non-callback interface %s inheriting from "
                                   "callback interface %s" %
                                   (self.identifier.name,
                                    self.parent.identifier.name),
                                   [self.location, self.parent.location])
 
+            # Interfaces which have interface objects can't inherit
+            # from [NoInterfaceObject] interfaces.
+            if (self.parent.getExtendedAttribute("NoInterfaceObject") and
+                not self.getExtendedAttribute("NoInterfaceObject")):
+                raise WebIDLError("Interface %s does not have "
+                                  "[NoInterfaceObject] but inherits from "
+                                  "interface %s which does" %
+                                  (self.identifier.name,
+                                   self.parent.identifier.name),
+                                  [self.location, self.parent.location])
+
         for iface in self.implementedInterfaces:
             iface.finish(scope)
 
         cycleInGraph = self.findInterfaceLoopPoint(self)
         if cycleInGraph:
             raise WebIDLError("Interface %s has itself as ancestor or "
                               "implemented interface" % self.identifier.name,
                               [self.location, cycleInGraph.location])