diff --git a/components/script/dom/bindings/codegen/CodegenRust.py b/components/script/dom/bindings/codegen/CodegenRust.py index 2513b5b92eb..f6bb21932e6 100644 --- a/components/script/dom/bindings/codegen/CodegenRust.py +++ b/components/script/dom/bindings/codegen/CodegenRust.py @@ -8,6 +8,7 @@ from collections import defaultdict from itertools import groupby import operator +import os import re import string import textwrap @@ -6437,3 +6438,36 @@ impl %(base)s { # Done. return curr + + @staticmethod + def SupportedDomApis(config): + descriptors = config.getDescriptors(isExposedConditionally=False) + + base_path = os.path.join('dom', 'bindings', 'codegen') + with open(os.path.join(base_path, 'apis.html.template')) as f: + base_template = f.read() + with open(os.path.join(base_path, 'api.html.template')) as f: + api_template = f.read() + with open(os.path.join(base_path, 'property.html.template')) as f: + property_template = f.read() + with open(os.path.join(base_path, 'interface.html.template')) as f: + interface_template = f.read() + + apis = [] + interfaces = [] + for descriptor in descriptors: + props = [] + for m in descriptor.interface.members: + if PropertyDefiner.getStringAttr(m, 'Pref') or \ + PropertyDefiner.getStringAttr(m, 'Func') or \ + (m.isMethod() and m.isIdentifierLess()): + continue + display = m.identifier.name + ('()' if m.isMethod() else '') + props += [property_template.replace('${name}', display)] + name = descriptor.interface.identifier.name + apis += [(api_template.replace('${interface}', name) + .replace('${properties}', '\n'.join(props)))] + interfaces += [interface_template.replace('${interface}', name)] + + return CGGeneric((base_template.replace('${apis}', '\n'.join(apis)) + .replace('${interfaces}', '\n'.join(interfaces)))) diff --git a/components/script/dom/bindings/codegen/Configuration.py b/components/script/dom/bindings/codegen/Configuration.py index 9a39b1bc623..4074736a462 100644 --- a/components/script/dom/bindings/codegen/Configuration.py +++ b/components/script/dom/bindings/codegen/Configuration.py @@ -87,6 +87,8 @@ class Configuration: getter = lambda x: x.interface.isJSImplemented() elif key == 'isGlobal': getter = lambda x: x.isGlobal() + elif key == 'isExposedConditionally': + getter = lambda x: x.interface.isExposedConditionally() else: getter = lambda x: getattr(x, key) curr = filter(lambda x: getter(x) == val, curr) diff --git a/components/script/dom/bindings/codegen/GlobalGen.py b/components/script/dom/bindings/codegen/GlobalGen.py index 72a2faa71e4..23779d9e6d5 100644 --- a/components/script/dom/bindings/codegen/GlobalGen.py +++ b/components/script/dom/bindings/codegen/GlobalGen.py @@ -32,6 +32,8 @@ def main(): o = OptionParser(usage=usageString) o.add_option("--cachedir", dest='cachedir', default=None, help="Directory in which to cache lex/parse tables.") + o.add_option("--only-html", dest='only_html', action="store_true", + help="Only generate HTML from WebIDL inputs") (options, args) = o.parse_args() if len(args) < 2: @@ -51,24 +53,30 @@ def main(): parser.parse(''.join(lines), fullPath) parserResults = parser.finish() - # Write the parser results out to a pickle. - resultsPath = os.path.join(outputdir, 'ParserResults.pkl') - with open(resultsPath, 'wb') as resultsFile: - cPickle.dump(parserResults, resultsFile, -1) + if not options.only_html: + # Write the parser results out to a pickle. + resultsPath = os.path.join(outputdir, 'ParserResults.pkl') + with open(resultsPath, 'wb') as resultsFile: + cPickle.dump(parserResults, resultsFile, -1) # Load the configuration. config = Configuration(configFile, parserResults) to_generate = [ - ('PrototypeList', 'PrototypeList.rs'), - ('RegisterBindings', 'RegisterBindings.rs'), - ('InterfaceObjectMap', 'InterfaceObjectMap.rs'), - ('InterfaceTypes', 'InterfaceTypes.rs'), - ('InheritTypes', 'InheritTypes.rs'), - ('Bindings', os.path.join('Bindings', 'mod.rs')), - ('UnionTypes', 'UnionTypes.rs'), + ('SupportedDomApis', 'apis.html'), ] + if not options.only_html: + to_generate = [ + ('PrototypeList', 'PrototypeList.rs'), + ('RegisterBindings', 'RegisterBindings.rs'), + ('InterfaceObjectMap', 'InterfaceObjectMap.rs'), + ('InterfaceTypes', 'InterfaceTypes.rs'), + ('InheritTypes', 'InheritTypes.rs'), + ('Bindings', os.path.join('Bindings', 'mod.rs')), + ('UnionTypes', 'UnionTypes.rs'), + ] + for name, filename in to_generate: generate_file(config, name, os.path.join(outputdir, filename)) diff --git a/components/script/dom/bindings/codegen/api.html.template b/components/script/dom/bindings/codegen/api.html.template new file mode 100644 index 00000000000..807392693a4 --- /dev/null +++ b/components/script/dom/bindings/codegen/api.html.template @@ -0,0 +1,6 @@ +
${interface} | +
---|