Bug 521898, part 9: Backend support for .ipdlh. r=bent

This commit is contained in:
Chris Jones 2012-06-08 17:25:36 -07:00
parent 890dd1bd99
commit e1092179c7
2 changed files with 25 additions and 5 deletions

View File

@ -52,6 +52,7 @@ DIRS += test
endif
vpath %.ipdl $(topsrcdir)
vpath %.ipdlh $(topsrcdir)
define ADD_IPDLDIR
include $(topsrcdir)/$(IPDLDIR)/ipdl.mk
@ -69,6 +70,7 @@ CPPSRCS = \
$(PROTOCOLS:%.ipdl=%Parent.cpp) \
$(PROTOCOLS:%.ipdl=%Child.cpp) \
$(PROTOCOLS:%.ipdl=%.cpp) \
$(PROTOCOLS:%.ipdlh=%.cpp) \
$(NULL)
GARBAGE += $(CPPSRCS)

View File

@ -66,14 +66,21 @@ _DISCLAIMER = Whitespace('''//
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)
@ -1264,6 +1271,10 @@ with some new IPDL/C++ nodes that are tuned for C++ codegen."""
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
@ -1355,6 +1366,8 @@ class _GenerateProtocolCode(ipdl.ast.Visitor):
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))
@ -1381,6 +1394,11 @@ class _GenerateProtocolCode(ipdl.ast.Visitor):
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)