diff options
author | Josh Matthews <josh@joshmatthews.net> | 2016-08-11 11:21:47 -0400 |
---|---|---|
committer | Josh Matthews <josh@joshmatthews.net> | 2016-08-24 11:25:58 -0400 |
commit | 221bc846935a321747fff30689218de7543c964b (patch) | |
tree | 6f701bc79c674b122a1c84bbcedcad16b5e4171c /components/script/dom/bindings/codegen/Configuration.py | |
parent | 49d483590e2e1b070271927132413e2078afe27f (diff) | |
download | servo-221bc846935a321747fff30689218de7543c964b.tar.gz servo-221bc846935a321747fff30689218de7543c964b.zip |
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.
Diffstat (limited to 'components/script/dom/bindings/codegen/Configuration.py')
-rw-r--r-- | components/script/dom/bindings/codegen/Configuration.py | 14 |
1 files changed, 10 insertions, 4 deletions
diff --git a/components/script/dom/bindings/codegen/Configuration.py b/components/script/dom/bindings/codegen/Configuration.py index 4074736a462..fd005bc6e05 100644 --- a/components/script/dom/bindings/codegen/Configuration.py +++ b/components/script/dom/bindings/codegen/Configuration.py @@ -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: |