Bug 849307. When generating code for a WebIDL dictionary with interface members, include the relevant headers for those interfaces in the binding header file, not just the binding implementation file. r=peterv
authorBoris Zbarsky <bzbarsky@mit.edu>
Thu, 14 Mar 2013 15:42:59 -0400
changeset 124826 083ae059a5f161cfb15769e9a4bc1d8d0d6e926b
parent 124825 7dc016fc39bfa566c810ee4e242ae50cd46e18d0
child 124827 a3fcc4ba944ccad1da2ff3801ac7326dc702575a
push id24436
push userryanvm@gmail.com
push dateFri, 15 Mar 2013 11:52:55 +0000
treeherdermozilla-central@8f5b1f9f5804 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewerspeterv
bugs849307
milestone22.0a1
first release with
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
last release without
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
Bug 849307. When generating code for a WebIDL dictionary with interface members, include the relevant headers for those interfaces in the binding header file, not just the binding implementation file. r=peterv An alternative would be using out-of-line constructors and destructors for such dictionaries.
dom/bindings/Codegen.py
--- a/dom/bindings/Codegen.py
+++ b/dom/bindings/Codegen.py
@@ -502,16 +502,17 @@ class CGHeaders(CGWrapper):
         hasInstanceIncludes = set("nsIDOM" + d.interface.identifier.name + ".h" for d
                                   in descriptors if
                                   NeedsGeneratedHasInstance(d) and
                                   d.interface.hasInterfaceObject())
 
         # Now find all the things we'll need as arguments because we
         # need to wrap or unwrap them.
         bindingHeaders = set()
+        declareIncludes = set(declareIncludes)
         def addHeadersForType(t, descriptor=None, dictionary=None):
             """
             Add the relevant headers for this type.  We use descriptor and
             dictionary, if passed, to decide what to do with interface types.
             """
             assert not descriptor or not dictionary
             unrolled = t.unroll()
             if unrolled.isUnion():
@@ -524,17 +525,29 @@ class CGHeaders(CGWrapper):
                 else:
                     providers = getRelevantProviders(descriptor, dictionary,
                                                      config)
                     for p in providers:
                         try:
                             typeDesc = p.getDescriptor(unrolled.inner.identifier.name)
                         except NoSuchDescriptorError:
                             continue
-                        implementationIncludes.add(typeDesc.headerFile)
+                        if dictionary:
+                            # Dictionaries with interface members rely on the
+                            # actual class definition of that interface member
+                            # being visible in the binding header, because they
+                            # store them in nsRefPtr and have inline
+                            # constructors/destructors.
+                            #
+                            # XXXbz maybe dictionaries with interface members
+                            # should just have out-of-line constructors and
+                            # destructors?
+                            declareIncludes.add(typeDesc.headerFile)
+                        else:
+                            implementationIncludes.add(typeDesc.headerFile)
                         bindingHeaders.add(self.getDeclarationFilename(typeDesc.interface))
             elif unrolled.isDictionary():
                 bindingHeaders.add(self.getDeclarationFilename(unrolled.inner))
             elif unrolled.isCallback():
                 # Callbacks are both a type and an object
                 bindingHeaders.add(self.getDeclarationFilename(t.unroll()))
             elif unrolled.isFloat() and not unrolled.isUnrestricted():
                 # Restricted floats are tested for finiteness
@@ -551,17 +564,16 @@ class CGHeaders(CGWrapper):
             for m in desc.interface.members:
                 func = PropertyDefiner.getStringAttr(m, "Func")
                 # Include the right class header, which we can only do
                 # if this is a class member function.
                 if func is not None and "::" in func:
                     # Strip out the function name and convert "::" to "/"
                     bindingHeaders.add("/".join(func.split("::")[:-1]) + ".h")
 
-        declareIncludes = set(declareIncludes)
         for d in dictionaries:
             if d.parent:
                 declareIncludes.add(self.getDeclarationFilename(d.parent))
             bindingHeaders.add(self.getDeclarationFilename(d))
 
         for c in callbacks:
             bindingHeaders.add(self.getDeclarationFilename(c))