Bug 1318743 - Remove errout from IPDL parser. r=billm draft
authorAndrew McCreight <continuation@gmail.com>
Fri, 18 Nov 2016 11:07:06 -0800
changeset 441421 d45d24dd3fa933130232eee8d202acb3af353fd5
parent 441209 a103e1713a2eda3b4e88d71df82d140487c8db87
child 537550 6e1df7e6f4ec811a9e597cdd9ceae0bd3f8b8e29
push id36418
push userbmo:continuation@gmail.com
push dateFri, 18 Nov 2016 21:26:05 +0000
reviewersbillm
bugs1318743
milestone53.0a1
Bug 1318743 - Remove errout from IPDL parser. r=billm MozReview-Commit-ID: 922dDCgd6s6
ipc/ipdl/ipdl/__init__.py
ipc/ipdl/ipdl/parser.py
--- a/ipc/ipdl/ipdl/__init__.py
+++ b/ipc/ipdl/ipdl/__init__.py
@@ -23,33 +23,33 @@ def parse(specstring, filename='/stdin',
     prefix, ext = os.path.splitext(filename)
     name = os.path.basename(prefix)
     if ext == '.ipdlh':
         type = 'header'
     else:
         type = 'protocol'
 
     try:
-        return Parser(type, name).parse(specstring, os.path.abspath(filename), includedirs, errout)
+        return Parser(type, name).parse(specstring, os.path.abspath(filename), includedirs)
     except ParseError as p:
         print >>errout, p
         return None
 
 def typecheck(ast, errout=sys.stderr):
     '''Return True iff |ast| is well typed.  Print errors to |errout| if
     it is not.'''
     return TypeCheck().check(ast, errout)
 
 
 def gencxx(ipdlfilename, ast, outheadersdir, outcppdir):
     headers, cpps = LowerToCxx().lower(ast)
 
     def resolveHeader(hdr):
         return [
-            hdr, 
+            hdr,
             os.path.join(
                 outheadersdir,
                 *([ns.name for ns in ast.namespaces] + [hdr.name]))
         ]
     def resolveCpp(cpp):
         return [ cpp, os.path.join(outcppdir, cpp.name) ]
 
     for ast, filename in ([ resolveHeader(hdr) for hdr in headers ]
--- a/ipc/ipdl/ipdl/parser.py
+++ b/ipc/ipdl/ipdl/parser.py
@@ -47,34 +47,32 @@ class Parser:
         self.debug = debug
         self.filename = None
         self.includedirs = None
         self.loc = None         # not always up to date
         self.lexer = None
         self.parser = None
         self.tu = TranslationUnit(type, name)
         self.direction = None
-        self.errout = None
 
-    def parse(self, input, filename, includedirs, errout):
+    def parse(self, input, filename, includedirs):
         assert os.path.isabs(filename)
 
         if filename in Parser.parsed:
             return Parser.parsed[filename].tu
 
         self.lexer = lex.lex(debug=self.debug,
                              optimize=not self.debug,
                              lextab="ipdl_lextab")
         self.parser = yacc.yacc(debug=self.debug,
                                 optimize=not self.debug,
                                 tabmodule="ipdl_yacctab")
         self.filename = filename
         self.includedirs = includedirs
         self.tu.filename = filename
-        self.errout = errout
 
         Parser.parsed[filename] = self
         Parser.parseStack.append(Parser.current)
         Parser.current = self
 
         try:
             ast = self.parser.parse(input=input, lexer=self.lexer,
                                     debug=self.debug)
@@ -265,17 +263,17 @@ def p_IncludeStmt(p):
         type = 'header'
     inc = Include(loc, type, id)
 
     path = Parser.current.resolveIncludePath(inc.file)
     if path is None:
         raise ParseError(loc, "can't locate include file `%s'"% (
                 inc.file))
 
-    inc.tu = Parser(type, id).parse(open(path).read(), path, Parser.current.includedirs, Parser.current.errout)
+    inc.tu = Parser(type, id).parse(open(path).read(), path, Parser.current.includedirs)
     p[0] = inc
 
 def p_UsingStmt(p):
     """UsingStmt : USING CxxType FROM STRING
                  | USING CLASS CxxType FROM STRING
                  | USING STRUCT CxxType FROM STRING"""
     if 6 == len(p):
         header = p[5]