Bug 678479: Add a --regen argument to header.py and typelib.py to regenerate the IDL parser. r=ted

This commit is contained in:
Kyle Huey 2011-08-12 12:06:46 -04:00
parent 0eb13677f5
commit b7936f88be
3 changed files with 23 additions and 3 deletions

View File

@ -483,6 +483,8 @@ if __name__ == '__main__':
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
@ -491,6 +493,14 @@ if __name__ == '__main__':
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)

View File

@ -281,6 +281,8 @@ if __name__ == '__main__':
help="Output file")
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
@ -289,6 +291,14 @@ if __name__ == '__main__':
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)

View File

@ -1336,17 +1336,17 @@ class IDLParser(object):
location = Location(self.lexer, t.lineno, t.lexpos)
raise IDLError("invalid syntax", location)
def __init__(self, outputdir=''):
def __init__(self, outputdir='', regen=False):
self._doccomments = []
self.lexer = lex.lex(object=self,
outputdir=outputdir,
lextab='xpidllex',
optimize=1)
optimize=0 if regen else 1)
self.parser = yacc.yacc(module=self,
outputdir=outputdir,
debugfile='xpidl_debug',
tabmodule='xpidlyacc',
optimize=1)
optimize=0 if regen else 1)
def clearComments(self):
self._doccomments = []