def update_uuids(self, path, interfaces): import os from xpidl import xpidl from mozpack.files import FileFinder import mozpack.path as mozpath from tempfile import mkdtemp finder = FileFinder(path, find_executables=False) # Avoid creating xpidllex and xpidlyacc in the current directory. tmpdir = mkdtemp() try: parser = xpidl.IDLParser(outputdir=tmpdir) registry = InterfaceRegistry() for p, f in finder.find('**/*.idl'): p = mozpath.join(path, p) try: content = f.open().read() idl = parser.parse(content, filename=p) except Exception: continue for prod in idl.productions: if isinstance(prod, xpidl.Interface): registry.add(Interface(p, prod)) finally: import shutil shutil.rmtree(tmpdir) updates = IDLUpdater(registry) for interface in interfaces: updates.add(interface) updates.update()
def setUp(self): self.p = xpidl.IDLParser()
def main(outputfile): xpidl.IDLParser()
import mozpack.path as mozpath from xpidl import xpidl # Load the webidl configuration file. glbl = {} exec( open( mozpath.join(buildconfig.topsrcdir, "dom", "bindings", "Bindings.conf")).read(), glbl, ) webidlconfig = glbl["DOMInterfaces"] # Instantiate the parser. p = xpidl.IDLParser() def findIDL(includePath, interfaceFileName): for d in includePath: path = mozpath.join(d, interfaceFileName) if os.path.exists(path): return path raise BaseException("No IDL file found for interface %s " "in include path %r" % (interfaceFileName, includePath)) def loadEventIDL(parser, includePath, eventname): eventidl = "nsIAccessible%s.idl" % eventname idlFile = findIDL(includePath, eventidl)
o.add_option('--regen', action='store_true', dest='regen', default=False, help="Regenerate IDL Parser cache") options, args = o.parse_args() file = args[0] if args else None if options.cachedir is not None: if not os.path.isdir(options.cachedir): os.mkdir(options.cachedir) sys.path.append(options.cachedir) if options.regen: if options.cachedir is None: print >>sys.stderr, "--regen requires --cachedir" sys.exit(1) p = xpidl.IDLParser(outputdir=options.cachedir, regen=True) sys.exit(0) if options.depfile is not None and options.outfile is None: print >>sys.stderr, "-d requires -o" sys.exit(1) if options.outfile is not None: outfd = open(options.outfile, 'wb') closeoutfd = True else: raise "typelib generation requires an output file" p = xpidl.IDLParser(outputdir=options.cachedir) idl = p.parse(open(file).read(), filename=file) idl.resolve(options.incdirs, p)
def main(): from optparse import OptionParser o = OptionParser() o.add_option('-I', action='append', dest='incdirs', default=['.'], help="Directory to search for imported files") o.add_option('--cachedir', dest='cachedir', default=None, help="Directory in which to cache lex/parse tables.") o.add_option('-o', dest='outfile', default=None, help="Output file (default is stdout)") o.add_option('-d', dest='depfile', default=None, help="Generate a make dependency file") o.add_option('--regen', action='store_true', dest='regen', default=False, help="Regenerate IDL Parser cache") options, args = o.parse_args() file = args[0] if args else None if options.cachedir is not None: if not os.path.isdir(options.cachedir): os.mkdir(options.cachedir) sys.path.append(options.cachedir) # The only thing special about a regen is that there are no input files. if options.regen: if options.cachedir is None: print >> sys.stderr, "--regen useless without --cachedir" # Delete the lex/yacc files. Ply is too stupid to regenerate them # properly for fileglobs in [ os.path.join(options.cachedir, f) for f in ["xpidllex.py*", "xpidlyacc.py*"] ]: for filename in glob.glob(fileglobs): os.remove(filename) # Instantiate the parser. p = xpidl.IDLParser(outputdir=options.cachedir) if options.regen: sys.exit(0) if options.depfile is not None and options.outfile is None: print >> sys.stderr, "-d requires -o" sys.exit(1) if options.outfile is not None: outfd = open(options.outfile, 'w') closeoutfd = True else: outfd = sys.stdout closeoutfd = False idl = p.parse(open(file).read(), filename=file) idl.resolve(options.incdirs, p) print_header(idl, outfd, file) if closeoutfd: outfd.close() if options.depfile is not None: dirname = os.path.dirname(options.depfile) if dirname: try: os.makedirs(dirname) except: pass depfd = open(options.depfile, 'w') deps = [dep.replace('\\', '/') for dep in idl.deps] print >> depfd, "%s: %s" % (options.outfile, " ".join(deps)) for dep in deps: print >> depfd, "%s:" % dep