Bug 1257037 part 10. Store only one descriptor per interface name in the configuration. r=khuey
authorBoris Zbarsky <bzbarsky@mit.edu>
Fri, 08 Jul 2016 00:37:54 -0400
changeset 304179 dfa4d5a42b52c6eaa6bcbbca54595713cc3131bd
parent 304178 4565bfc8b866fd71c33201179daeb9ead66419fd
child 304180 7b7cf5270426b8153bf86cca34152dff04cd1744
push id30414
push usercbook@mozilla.com
push dateFri, 08 Jul 2016 09:59:01 +0000
treeherdermozilla-central@45682df2d2d4 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewerskhuey
bugs1257037
milestone50.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 1257037 part 10. Store only one descriptor per interface name in the configuration. r=khuey
dom/bindings/Codegen.py
dom/bindings/Configuration.py
--- a/dom/bindings/Codegen.py
+++ b/dom/bindings/Codegen.py
@@ -13240,17 +13240,17 @@ class ForwardDeclarationBuilder:
     def build(self):
         return self._build(atTopLevel=True)
 
     def forwardDeclareForType(self, t, config):
         t = t.unroll()
         if t.isGeckoInterface():
             name = t.inner.identifier.name
             try:
-                desc = config.getDescriptor(name, False)
+                desc = config.getDescriptor(name)
                 self.add(desc.nativeType)
             except NoSuchDescriptorError:
                 pass
 
         # Note: Spidermonkey interfaces are typedefs, so can't be
         # forward-declared
         elif t.isCallback():
             self.addInMozillaDom(t.callback.identifier.name)
@@ -14337,18 +14337,17 @@ class CGExampleClass(CGBindingImplClass)
 
 class CGExampleRoot(CGThing):
     """
     Root codegen class for example implementation generation.  Instantiate the
     class and call declare or define to generate header or cpp code,
     respectively.
     """
     def __init__(self, config, interfaceName):
-        # Let's assume we're not doing workers stuff
-        descriptor = config.getDescriptor(interfaceName, False)
+        descriptor = config.getDescriptor(interfaceName)
 
         self.root = CGWrapper(CGExampleClass(descriptor),
                               pre="\n", post="\n")
 
         self.root = CGNamespace.build(["mozilla", "dom"], self.root)
 
         builder = ForwardDeclarationBuilder()
         for member in descriptor.interface.members:
@@ -16975,18 +16974,17 @@ class CGEventClass(CGBindingImplClass):
         else:
             raise TypeError("Don't know how to declare event member of type %s" %
                             type)
         return nativeType
 
 
 class CGEventRoot(CGThing):
     def __init__(self, config, interfaceName):
-        # Let's assume we're not doing workers stuff, for now
-        descriptor = config.getDescriptor(interfaceName, False)
+        descriptor = config.getDescriptor(interfaceName)
 
         self.root = CGWrapper(CGEventClass(descriptor),
                               pre="\n", post="\n")
 
         self.root = CGNamespace.build(["mozilla", "dom"], self.root)
 
         self.root = CGList([CGClassForwardDeclare("JSContext", isStruct=True),
                             self.root])
@@ -16995,17 +16993,17 @@ class CGEventRoot(CGThing):
 
         # Throw in our #includes
         self.root = CGHeaders(
             [descriptor],
             [],
             [],
             [],
             [
-                config.getDescriptor(parent, False).headerFile,
+                config.getDescriptor(parent).headerFile,
                 "mozilla/Attributes.h",
                 "mozilla/ErrorResult.h",
                 "mozilla/dom/%sBinding.h" % interfaceName,
                 'mozilla/dom/BindingUtils.h',
                 ],
             [
                 "%s.h" % interfaceName,
                 "js/GCAPI.h",
--- a/dom/bindings/Configuration.py
+++ b/dom/bindings/Configuration.py
@@ -72,44 +72,24 @@ class Configuration(DescriptorProvider):
                 # if they have no interface object because chances are we
                 # don't need to do anything interesting with them.
                 if iface.isConsequential() and not iface.hasInterfaceObject():
                     self.optimizedOutDescriptorNames.add(iface.identifier.name)
                     continue
                 entry = {}
             else:
                 entry = config[iface.identifier.name]
-            if not isinstance(entry, list):
-                assert isinstance(entry, dict)
-                entry = [entry]
-            elif len(entry) == 1:
-                if entry[0].get("workers", False):
-                    # List with only a workers descriptor means we should
-                    # infer a mainthread descriptor.  If you want only
-                    # workers bindings, don't use a list here.
-                    entry.append({})
-                else:
-                    raise TypeError("Don't use a single-element list for "
-                                    "non-worker-only interface " + iface.identifier.name +
-                                    " in Bindings.conf")
-            elif len(entry) == 2:
-                if entry[0].get("workers", False) == entry[1].get("workers", False):
-                    raise TypeError("The two entries for interface " + iface.identifier.name +
-                                    " in Bindings.conf should not have the same value for 'workers'")
-            else:
-                raise TypeError("Interface " + iface.identifier.name +
-                                " should have no more than two entries in Bindings.conf")
-            descs = [Descriptor(self, iface, x) for x in entry]
-            self.descriptors.extend(descs)
+            assert not isinstance(entry, list)
+            desc = Descriptor(self, iface, entry)
+            self.descriptors.append(desc)
             # Setting up descriptorsByName while iterating through interfaces
             # means we can get the nativeType of iterable interfaces without
             # having to do multiple loops.
-            for d in descs:
-                self.descriptorsByName.setdefault(d.interface.identifier.name,
-                                                  []).append(d)
+            assert desc.interface.identifier.name not in self.descriptorsByName
+            self.descriptorsByName[desc.interface.identifier.name] = desc
 
         # Keep the descriptor list sorted for determinism.
         self.descriptors.sort(lambda x, y: cmp(x.name, y.name))
 
 
         self.descriptorsByFile = {}
         for d in self.descriptors:
             self.descriptorsByFile.setdefault(d.interface.filename(),
@@ -235,32 +215,27 @@ class Configuration(DescriptorProvider):
         return filter(lambda e: e.filename() == webIDLFile, self.enums)
 
     def getDictionaries(self, webIDLFile):
         return filter(lambda d: d.filename() == webIDLFile, self.dictionaries)
 
     def getCallbacks(self, webIDLFile):
         return filter(lambda c: c.filename() == webIDLFile, self.callbacks)
 
-    def getDescriptor(self, interfaceName, workers=False):
+    def getDescriptor(self, interfaceName):
         """
-        Gets the appropriate descriptor for the given interface name
-        and the given workers boolean.
+        Gets the appropriate descriptor for the given interface name.
         """
         # We may have optimized out this descriptor, but the chances of anyone
         # asking about it are then slim.  Put the check for that _after_ we've
-        # done our normal lookups.  But that means we have to do our normal
-        # lookups in a way that will not throw if they fail.
-        for d in self.descriptorsByName.get(interfaceName, []):
-            if d.workers == workers:
-                return d
-
-        if workers:
-            for d in self.descriptorsByName.get(interfaceName, []):
-                return d
+        # done our normal lookup.  But that means we have to do our normal
+        # lookup in a way that will not throw if it fails.
+        d = self.descriptorsByName.get(interfaceName, None)
+        if d:
+            return d
 
         if interfaceName in self.optimizedOutDescriptorNames:
             raise NoSuchDescriptorError(
                 "No descriptor for '%s', which is a mixin ([NoInterfaceObject] "
                 "and a consequential interface) without an explicit "
                 "Bindings.conf annotation." % interfaceName)
 
         raise NoSuchDescriptorError("For " + interfaceName + " found no matches")
@@ -785,21 +760,19 @@ class Descriptor(DescriptorProvider):
         return (not self.interface.isExternal() and
                 self.interface.hasInterfaceObject() and
                 not self.workers and
                 self.interface.isExposedInWindow() and
                 self.register)
 
     def getDescriptor(self, interfaceName):
         """
-        Gets the appropriate descriptor for the given interface name given the
-        context of the current descriptor. This selects the appropriate
-        implementation for cases like workers.
+        Gets the appropriate descriptor for the given interface name.
         """
-        return self.config.getDescriptor(interfaceName, self.workers)
+        return self.config.getDescriptor(interfaceName)
 
 
 # Some utility methods
 def getTypesFromDescriptor(descriptor):
     """
     Get all argument and return types for all members of the descriptor
     """
     members = [m for m in descriptor.interface.members]