Bug 521898, part 9: Backend support for .ipdlh. r=bent
authorChris Jones <jones.chris.g@gmail.com>
Fri, 08 Jun 2012 17:25:36 -0700
changeset 101031 02d6424b10b801c16ceae899a3b2955f1ffb2e22
parent 101030 1b4f5ef66e6edd7ab1501d45103a47cf59909960
child 101032 8b10a0c183f0dab8b9cc16146c434b07fb9ece58
push id1316
push userakeybl@mozilla.com
push dateMon, 27 Aug 2012 22:37:00 +0000
treeherdermozilla-beta@db4b09302ee2 [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 9: Backend support for .ipdlh. r=bent
ipc/ipdl/Makefile.in
ipc/ipdl/ipdl/lower.py
--- a/ipc/ipdl/Makefile.in
+++ b/ipc/ipdl/Makefile.in
@@ -47,16 +47,17 @@ IPDLDIRS += ipc/ipdl/test/cxx
 endif #}
 ##-----------------------------------------------------------------------------
 
 ifdef MOZ_IPDL_TESTS
 DIRS += test
 endif
 
 vpath %.ipdl $(topsrcdir)
+vpath %.ipdlh $(topsrcdir)
 
 define ADD_IPDLDIR
 include $(topsrcdir)/$(IPDLDIR)/ipdl.mk
 ALL_IPDLSRCS += $$(IPDLSRCS:%=$(IPDLDIR)/%)
 PROTOCOLS += $$(IPDLSRCS)
 endef
 
 ALL_IPDLSRCS :=
@@ -64,16 +65,17 @@ PROTOCOLS :=
 
 $(foreach IPDLDIR,$(IPDLDIRS),$(eval $(ADD_IPDLDIR)))
 
 
 CPPSRCS =					\
   $(PROTOCOLS:%.ipdl=%Parent.cpp)		\
   $(PROTOCOLS:%.ipdl=%Child.cpp)		\
   $(PROTOCOLS:%.ipdl=%.cpp)			\
+  $(PROTOCOLS:%.ipdlh=%.cpp)			\
   $(NULL)
 
 GARBAGE += $(CPPSRCS)
 
 LOCAL_INCLUDES += -I$(DEPTH)/ipc/ipdl/_ipdlheaders
 
 
 include $(topsrcdir)/config/config.mk
--- a/ipc/ipdl/ipdl/lower.py
+++ b/ipc/ipdl/ipdl/lower.py
@@ -61,24 +61,31 @@ lowered form of |tu|'''
 // Edit at your own risk
 //
 
 ''')
 
 
 class _struct: pass
 
+def _namespacedHeaderName(name, namespaces):
+    pfx = '/'.join([ ns.name for ns in namespaces ])
+    if pfx:
+        return pfx +'/'+ name
+    else:
+        return name
+
+def _ipdlhHeaderName(tu):
+    assert tu.filetype == 'header'
+    return _namespacedHeaderName(tu.name, tu.namespaces)
+
 def _protocolHeaderName(p, side=''):
     if side: side = side.title()
     base = p.name + side
-
-    
-    pfx = '/'.join([ ns.name for ns in p.namespaces ])
-    if pfx: return pfx +'/'+ base
-    else:   return base
+    return _namespacedHeaderName(base, p.namespaces)
 
 def _includeGuardMacroName(headerfile):
     return re.sub(r'[./]', '_', headerfile.name)
 
 def _includeGuardStart(headerfile):
     guard = _includeGuardMacroName(headerfile)
     return [ CppDirective('ifndef', guard),
              CppDirective('define', guard)  ]
@@ -1259,16 +1266,20 @@ with some new IPDL/C++ nodes that are tu
 
     def visitTranslationUnit(self, tu):
         if not isinstance(tu, TranslationUnit) and tu not in self.visitedTus:
             self.visitedTus.add(tu)
             ipdl.ast.Visitor.visitTranslationUnit(self, tu)
             TranslationUnit.upgrade(tu)
             self.typedefs[:] = sorted(list(self.typedefSet))
 
+    def visitInclude(self, inc):
+        if inc.tu.filetype == 'header':
+            inc.tu.accept(self)
+
     def visitProtocol(self, pro):
         self.protocolName = pro.name
         pro.decl.cxxtypedefs = self.typedefs
         Protocol.upgrade(pro)
         return ipdl.ast.Visitor.visitProtocol(self, pro)
 
 
     def visitUsingStmt(self, using):
@@ -1350,16 +1361,18 @@ class _GenerateProtocolCode(ipdl.ast.Vis
     def visitTranslationUnit(self, tu):
         hf = self.hdrfile
 
         hf.addthing(_DISCLAIMER)
         hf.addthings(_includeGuardStart(hf))
         hf.addthing(Whitespace.NL)
 
         ipdl.ast.Visitor.visitTranslationUnit(self, tu)
+        if tu.filetype == 'header':
+            self.cppIncludeHeaders.append(_ipdlhHeaderName(tu))
 
         hf.addthing(Whitespace.NL)
         hf.addthings(_includeGuardEnd(hf))
 
         cf = self.cppfile
         cf.addthings((
             [ _DISCLAIMER, Whitespace.NL ]
             + [ CppDirective('include','"'+h+'.h"')
@@ -1376,16 +1389,21 @@ class _GenerateProtocolCode(ipdl.ast.Vis
                          +[ Whitespace.NL ]))
 
         cf.addthings(self.structUnionDefns)
 
 
     def visitCxxInclude(self, inc):
         self.hdrfile.addthing(CppDirective('include', '"'+ inc.file +'"'))
 
+    def visitInclude(self, inc):
+        if inc.tu.filetype == 'header':
+            self.hdrfile.addthing(CppDirective(
+                    'include', '"'+ _ipdlhHeaderName(inc.tu) +'.h"'))
+
     def processStructOrUnionClass(self, su, which, forwarddecls, cls):
         clsdecl, methoddefns = _splitClassDeclDefn(cls)
         
         self.hdrfile.addthings(
             [  Whitespace.NL ]
             + forwarddecls
             + [ Whitespace("""
 //-----------------------------------------------------------------------------