Support multiple WebIDL interfaces being generated in the same output binding file.

Each interface gets its own module named ${Interface}Binding. Structs, enums, and callbacks
continue to use the root module of the binding file. If there is only one interface in the
file, we generate reexports for several public APIs and types so that existing DOM implementations
don't need any modifications. When multiple interfaces exist, the reexported names get the interface
name prepended (eg. FooWrap instead of Wrap).

As part of this work, stop glob-importing all DOM types in every generated binding and start generating
more targeted lists of relevant types based on the methods, members, etc. of WebIDL types that are in use.
This commit is contained in:
Josh Matthews 2016-08-11 11:21:47 -04:00
parent 49d483590e
commit 221bc84693
5 changed files with 239 additions and 135 deletions

View file

@ -4,7 +4,7 @@
import os
from WebIDL import IDLExternalInterface, IDLInterface, WebIDLError
from WebIDL import IDLExternalInterface, IDLInterface, IDLWrapperType, WebIDLError
class Configuration:
@ -183,7 +183,8 @@ class Descriptor(DescriptorProvider):
# built-in rooting mechanisms for them.
if self.interface.isCallback():
self.needsRooting = False
ty = "%sBinding::%s" % (ifaceName, ifaceName)
ty = 'dom::bindings::codegen::Bindings::%sBinding::%s' % (ifaceName, ifaceName)
pathDefault = ty
self.returnType = "Rc<%s>" % ty
self.argumentType = "???"
self.nativeType = ty
@ -192,10 +193,12 @@ class Descriptor(DescriptorProvider):
self.returnType = "Root<%s>" % typeName
self.argumentType = "&%s" % typeName
self.nativeType = "*const %s" % typeName
pathDefault = 'dom::types::%s' % typeName
self.concreteType = typeName
self.register = desc.get('register', True)
self.path = desc.get('path', 'dom::types::%s' % typeName)
self.path = desc.get('path', pathDefault)
self.bindingPath = 'dom::bindings::codegen::Bindings::%s' % ('::'.join([ifaceName + 'Binding'] * 2))
self.outerObjectHook = desc.get('outerObjectHook', 'None')
self.proxy = False
self.weakReferenceable = desc.get('weakReferenceable', False)
@ -377,7 +380,8 @@ class Descriptor(DescriptorProvider):
# Some utility methods
def getModuleFromObject(object):
return os.path.basename(object.location.filename()).split('.webidl')[0] + 'Binding'
return ('dom::bindings::codegen::Bindings::' +
os.path.basename(object.location.filename()).split('.webidl')[0] + 'Binding')
def getTypesFromDescriptor(descriptor):
@ -404,6 +408,8 @@ def getTypesFromDictionary(dictionary):
"""
Get all member types for this dictionary
"""
if isinstance(dictionary, IDLWrapperType):
dictionary = dictionary.inner
types = []
curDict = dictionary
while curDict: