check that ctors and dtors have been declared for managed protocols
authorChris Jones <jones.chris.g@gmail.com>
Wed, 08 Jul 2009 10:37:32 -0500
changeset 35762 8524cccb39eb3b28e5e17542d8e30921459b1942
parent 35761 2c99c4920e6d46758bcc44b46662bc8988a5d189
child 35763 c9176c61346b625798d12c103b48f6a71ffbbd02
push id10694
push userbsmedberg@mozilla.com
push dateMon, 14 Dec 2009 15:23:10 +0000
treeherdermozilla-central@683dfdc4adf0 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
milestone1.9.2a1pre
check that ctors and dtors have been declared for managed protocols
ipc/ipdl/ipdl.py
ipc/ipdl/ipdl/parser.py
ipc/ipdl/ipdl/type.py
--- a/ipc/ipdl/ipdl.py
+++ b/ipc/ipdl/ipdl.py
@@ -39,17 +39,18 @@ def log(minv, fmt, *args):
     if _verbosity >= minv:
         print >>sys.stderr, fmt % args
 
 # process command line
 
 op = optparse.OptionParser(usage='ipdl.py [options] IPDLfiles...')
 op.add_option('-d', '--output-dir', dest='outputdir', default='.',
               help='Directory in which to put generated headers')
-op.add_option('-I', '--include', dest='includedirs', action='append',
+op.add_option('-I', '--include', dest='includedirs', default=[ ],
+              action='append',
               help='Additional directory to search for included protocol specifications')
 op.add_option('-v', '--verbose', dest='verbosity', default=1, action='count',
               help='Verbose logging (specify -vv or -vvv for very verbose logging)')
 op.add_option('-q', '--quiet', dest='verbosity', action='store_const', const=0,
               help="Suppress logging output")
 
 options, files = op.parse_args()
 _verbosity = options.verbosity
--- a/ipc/ipdl/ipdl/parser.py
+++ b/ipc/ipdl/ipdl/parser.py
@@ -94,17 +94,17 @@ class Parser:
         return ast
 
     def resolveIncludePath(self, filepath):
         '''Return the absolute path from which the possibly partial
 |filepath| should be read, or |None| if |filepath| can't be located.'''
         for incdir in self.includedirs +[ '' ]:
             realpath = os.path.join(incdir, filepath)
             if os.path.isfile(realpath):
-                return realpath
+                return os.path.abspath(realpath)
         return None
 
     # returns a GCC-style string representation of the include stack.
     # e.g.,
     #   in file included from 'foo.ipdl', line 120:
     #   in file included from 'bar.ipd', line 12:
     # which can be printed above a proper error message or warning
     @staticmethod
--- a/ipc/ipdl/ipdl/type.py
+++ b/ipc/ipdl/ipdl/type.py
@@ -405,25 +405,37 @@ class GatherDecls(Visitor):
             managed.manager = p
             managed.accept(self)
 
         setattr(self, 'currentProtocolDecl', p.decl)
         for msg in p.messageDecls:
             msg.accept(self)
         del self.currentProtocolDecl
 
+        for managed in p.managesStmts:
+            mgdname = managed.name
+            ctordecl = self.symtab.lookup(mgdname +'Constructor')
+            dtordecl = self.symtab.lookup(mgdname +'Destructor')
+
+            if not(ctordecl and dtordecl
+                   and ctordecl.type.isCtor() and dtordecl.type.isDtor()):
+                self.errors.append(
+                    errormsg(
+                        managed.loc,
+                        "constructor and destructor declarations are required for managed protocol `%s' (managed by protocol `%s')",
+                        mgdname, p.name))
+
         for trans in p.transitionStmts:
             trans.accept(self)
 
-        # declare all the little C++ thingies that will be generated.
-
-        # they're not relevant to IPDL itself, but those ("invisible")
-        # symbols can clash with others in the IPDL spec, and we'd like
-        # to catch those before C++ compilers are allowed to obfuscate
-        # the error
+        # FIXME/cjones declare all the little C++ thingies that will
+        # be generated.  they're not relevant to IPDL itself, but
+        # those ("invisible") symbols can clash with others in the
+        # IPDL spec, and we'd like to catch those before C++ compilers
+        # are allowed to obfuscate the error
 
         self.symtab.exitScope(p)
 
 
     def visitManagerStmt(self, mgr):
         mgrdecl = self.symtab.lookup(mgr.name)
         pdecl = mgr.of.decl
         assert pdecl