Bug 1444991 - Part 1: Read webidl's Bindings.conf, and pass it into xpidl, r=mccr8

This information is read in order to handle correctly selecting the native
type and header files for WebIDL types.
This commit is contained in:
Nika Layzell 2018-04-06 18:20:49 -04:00
Родитель 14da321a67
Коммит be8b24333a
5 изменённых файлов: 25 добавлений и 9 удалений

Просмотреть файл

@ -18,6 +18,13 @@ xpidl_cachedir = mozpath.join(buildconfig.topobjdir, 'xpcom', 'idl-parser',
sys.path.extend([xpidl_dir, xpidl_cachedir])
import xpidl
# Load the webidl configuration file.
glbl = {}
execfile(mozpath.join(buildconfig.topsrcdir,
'dom', 'bindings', 'Bindings.conf'),
glbl)
webidlconfig = glbl['DOMInterfaces']
# Instantiate the parser.
p = xpidl.IDLParser()
@ -34,7 +41,7 @@ def loadEventIDL(parser, includePath, eventname):
eventidl = ("nsIAccessible%s.idl" % eventname)
idlFile = findIDL(includePath, eventidl)
idl = p.parse(open(idlFile).read(), idlFile)
idl.resolve(includePath, p)
idl.resolve(includePath, p, webidlconfig)
return idl, idlFile
class Configuration:

Просмотреть файл

@ -40,6 +40,7 @@ code_gen_deps := $(topsrcdir)/xpcom/reflect/xptinfo/perfecthash.py
$(REPORT_BUILD)
$(PYTHON_PATH) $(PLY_INCLUDE) -I$(topsrcdir)/xpcom/idl-parser -I$(DEPTH)/xpcom/idl-parser/xpidl \
$(process_py) --cache-dir $(DEPTH)/xpcom/idl-parser/xpidl --depsdir $(idl_deps_dir) \
--bindings-conf $(topsrcdir)/dom/bindings/Bindings.conf \
$(dist_idl_dir) $(dist_include_dir) $(dist_xpcrs_dir) $(@D) \
$(basename $(notdir $@)) $($(basename $(notdir $@))_deps)
# When some IDL is added or removed, if the actual IDL file was already, or

Просмотреть файл

@ -27,14 +27,18 @@ from mozbuild.pythonutil import iter_modules_in_path
from mozbuild.util import FileAvoidWrite
def process(input_dir, inc_paths, cache_dir, header_dir, xpcrs_dir,
xpt_dir, deps_dir, module, stems):
def process(input_dir, inc_paths, bindings_conf, cache_dir, header_dir,
xpcrs_dir, xpt_dir, deps_dir, module, stems):
p = IDLParser(outputdir=cache_dir)
xpts = []
mk = Makefile()
rule = mk.create_rule()
glbl = {}
execfile(bindings_conf, glbl)
webidlconfig = glbl['DOMInterfaces']
# Write out dependencies for Python modules we import. If this list isn't
# up to date, we will not re-process XPIDL files if the processor changes.
rule.add_dependencies(iter_modules_in_path(topsrcdir))
@ -44,7 +48,7 @@ def process(input_dir, inc_paths, cache_dir, header_dir, xpcrs_dir,
idl_data = open(path).read()
idl = p.parse(idl_data, filename=path)
idl.resolve([input_dir] + inc_paths, p)
idl.resolve([input_dir] + inc_paths, p, webidlconfig)
header_path = os.path.join(header_dir, '%s.h' % stem)
rs_rt_path = os.path.join(xpcrs_dir, 'rt', '%s.rs' % stem)
@ -80,6 +84,8 @@ def main(argv):
help='Directory in which to find or write cached lexer data.')
parser.add_argument('--depsdir',
help='Directory in which to write dependency files.')
parser.add_argument('--bindings-conf',
help='Path to the WebIDL binding configuration file.')
parser.add_argument('inputdir',
help='Directory in which to find source .idl files.')
parser.add_argument('headerdir',
@ -96,8 +102,9 @@ def main(argv):
help='Extra directories where to look for included .idl files.')
args = parser.parse_args(argv)
process(args.inputdir, args.incpath, args.cache_dir, args.headerdir,
args.xpcrsdir, args.xptdir, args.depsdir, args.module, args.idls)
process(args.inputdir, args.incpath, args.bindings_conf, args.cache_dir,
args.headerdir, args.xpcrsdir, args.xptdir, args.depsdir, args.module,
args.idls)
if __name__ == '__main__':
main(sys.argv[1:])

Просмотреть файл

@ -65,7 +65,7 @@ void bar();
i = self.p.parse("""[uuid(abc)] interface foo {
long bar(in long a, in float b, [array] in long c);
};""", filename='f')
i.resolve([], self.p)
i.resolve([], self.p, {})
self.assertTrue(isinstance(i, xpidl.IDL))
self.assertTrue(isinstance(i.productions[0], xpidl.Interface))
iface = i.productions[0]

Просмотреть файл

@ -300,7 +300,7 @@ class Include(object):
continue
self.IDL = parent.parser.parse(open(file).read(), filename=file)
self.IDL.resolve(parent.incdirs, parent.parser)
self.IDL.resolve(parent.incdirs, parent.parser, parent.webidlconfig)
for type in self.IDL.getNames():
parent.setName(type)
parent.deps.extend(self.IDL.deps)
@ -332,10 +332,11 @@ class IDL(object):
def __str__(self):
return "".join([str(p) for p in self.productions])
def resolve(self, incdirs, parser):
def resolve(self, incdirs, parser, webidlconfig):
self.namemap = NameMap()
self.incdirs = incdirs
self.parser = parser
self.webidlconfig = webidlconfig
for p in self.productions:
p.resolve(self)