Bug 521898, part 6: Refactor the way structs/unions are declared. r=bent
authorChris Jones <jones.chris.g@gmail.com>
Fri, 08 Jun 2012 17:25:36 -0700
changeset 96228 54a3bbdcfe04da3c89587181f19ce2ad7d184630
parent 96227 fece9a6bae3f360c8878362e91ae4fce46653aa7
child 96229 7befc650f055b8fd50f1cb3d0422e7450083e3c1
push id22883
push userryanvm@gmail.com
push dateSun, 10 Jun 2012 02:04:57 +0000
treeherdermozilla-central@dc410944aabc [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersbent
bugs521898
milestone16.0a1
first release with
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
last release without
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
Bug 521898, part 6: Refactor the way structs/unions are declared. r=bent
ipc/ipdl/ipdl/type.py
--- a/ipc/ipdl/ipdl/type.py
+++ b/ipc/ipdl/ipdl/type.py
@@ -655,51 +655,58 @@ class GatherDecls(TcheckVisitor):
 
         # declare imported (and builtin) C++ types
         for using in tu.using:
             using.accept(self)
 
         # first pass to "forward-declare" all structs and unions in
         # order to support recursive definitions
         for su in tu.structsAndUnions:
-            qname = su.qname()
-            if 0 == len(qname.quals):
-                fullname = None
-            else:
-                fullname = str(qname)
-
-            if isinstance(su, StructDecl):
-                sutype = StructType(qname, [ ])
-            elif isinstance(su, UnionDecl):
-                sutype = UnionType(qname, [ ])
-            else: assert 0 and 'unknown type'
-
-            # XXX more suckage.  this time for pickling structs/unions
-            # declared in headers.
-            sutype._ast = su
-
-            su.decl = self.declare(
-                loc=su.loc,
-                type=sutype,
-                shortname=su.name,
-                fullname=fullname)
+            self.declareStructOrUnion(su)
 
         # second pass to check each definition
         for su in tu.structsAndUnions:
             su.accept(self)
 
         if tu.protocol:
             # grab symbols in the protocol itself
             p.accept(self)
 
 
         tu.type = VOID
 
         self.symtab = savedSymtab
 
+    def declareStructOrUnion(self, su):
+        if hasattr(su, 'decl'):
+            self.symtab.declare(su.decl)
+            return
+
+        qname = su.qname()
+        if 0 == len(qname.quals):
+            fullname = None
+        else:
+            fullname = str(qname)
+
+        if isinstance(su, StructDecl):
+            sutype = StructType(qname, [ ])
+        elif isinstance(su, UnionDecl):
+            sutype = UnionType(qname, [ ])
+        else: assert 0 and 'unknown type'
+
+        # XXX more suckage.  this time for pickling structs/unions
+        # declared in headers.
+        sutype._ast = su
+
+        su.decl = self.declare(
+            loc=su.loc,
+            type=sutype,
+            shortname=su.name,
+            fullname=fullname)
+
 
     def visitInclude(self, inc):
         if inc.tu is None:
             self.error(
                 inc.loc,
                 "(type checking here will be unreliable because of an earlier error)")
             return
         inc.tu.accept(self)