diff --git a/ipc/Makefile.in b/ipc/Makefile.in index f8ed34906fea..86729565012f 100644 --- a/ipc/Makefile.in +++ b/ipc/Makefile.in @@ -41,7 +41,11 @@ VPATH = @srcdir@ include $(DEPTH)/config/autoconf.mk -DIRS += testshell +# NB: chromium/ and glue/ are in tier_xpcom + +# tier_gecko: +DIRS += ipdl testshell + TOOL_DIRS = app include $(topsrcdir)/config/rules.mk diff --git a/ipc/glue/IPCMessageUtils.h b/ipc/glue/IPCMessageUtils.h index 8bb1d24dcb4c..031626543a25 100644 --- a/ipc/glue/IPCMessageUtils.h +++ b/ipc/glue/IPCMessageUtils.h @@ -45,10 +45,6 @@ #include "nsStringGlue.h" #include "nsTArray.h" -#include "IPCMessageStart.h" - -COMPILE_ASSERT(LastMsgIndex <= 64, need_to_update_IPC_MESSAGE_MACRO); - namespace IPC { template <> diff --git a/ipc/ipdl/Makefile.in b/ipc/ipdl/Makefile.in index 34a3357b1a72..34db63924fbb 100644 --- a/ipc/ipdl/Makefile.in +++ b/ipc/ipdl/Makefile.in @@ -44,8 +44,15 @@ include $(DEPTH)/config/autoconf.mk GARBAGE_DIRS += _ipdlheaders GARBAGE += ipdl_lextab.py ipdl_yacctab.py -include $(topsrcdir)/config/rules.mk +MODULE = ipdlgen +LIBRARY_NAME = mozipdlgen_s +FORCE_STATIC_LIB = 1 +LIBXUL_LIBRARY = 1 +EXPORT_LIBRARY = 1 +##----------------------------------------------------------------------------- +## When you add IPDL files to a source directory, list the directory here. +## IPDLDIRS = \ dom/plugins \ dom/ipc \ @@ -54,22 +61,46 @@ IPDLDIRS = \ ipc/ipdl/test/cxx \ ipc/testshell \ $(NULL) +##----------------------------------------------------------------------------- + +ifdef MOZ_IPDL_TESTS +DIRS += test +endif vpath %.ipdl $(topsrcdir) define ADD_IPDLDIR include $(topsrcdir)/$(IPDLDIR)/ipdl.mk ALL_IPDLSRCS += $$(IPDLSRCS:%=$(IPDLDIR)/%) +PROTOCOLS += $$(IPDLSRCS) endef ALL_IPDLSRCS := +PROTOCOLS := $(foreach IPDLDIR,$(IPDLDIRS),$(eval $(ADD_IPDLDIR))) + +CPPSRCS = \ + $(PROTOCOLS:%.ipdl=%Parent.cpp) \ + $(PROTOCOLS:%.ipdl=%Child.cpp) \ + $(NULL) + +LOCAL_INCLUDES += -I$(DEPTH)/ipc/ipdl/_ipdlheaders + + +include $(topsrcdir)/config/config.mk +include $(topsrcdir)/ipc/chromium/chromium-config.mk +include $(topsrcdir)/config/rules.mk + + +# NB: the IPDL compiler manages .ipdl-->.h/.cpp dependencies itself, +# which is why we don't have explicit .h/.cpp targets here export:: $(ALL_IPDLSRCS) - $(PYTHON) $(topsrcdir)/config/pythonpath.py \ - -I$(topsrcdir)/other-licenses/ply \ - $(srcdir)/ipdl.py \ - -d _ipdlheaders \ - $(IPDLDIRS:%=-I$(topsrcdir)/%) \ + $(PYTHON) $(topsrcdir)/config/pythonpath.py \ + -I$(topsrcdir)/other-licenses/ply \ + $(srcdir)/ipdl.py \ + --outheaders-dir=_ipdlheaders \ + --outcpp-dir=. \ + $(IPDLDIRS:%=-I$(topsrcdir)/%) \ $^ diff --git a/ipc/ipdl/ipdl.py b/ipc/ipdl/ipdl.py index 7913f2c0281e..d5ff31726c45 100755 --- a/ipc/ipdl/ipdl.py +++ b/ipc/ipdl/ipdl.py @@ -42,8 +42,6 @@ def log(minv, 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', default=[ ], action='append', help='Additional directory to search for included protocol specifications') @@ -51,16 +49,29 @@ 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") +op.add_option('-d', '--outheaders-dir', dest='headersdir', default='.', + help="""Director into which C++ headers will be generated. +A protocol Foo in the namespace bar will cause the headers + dir/bar/Foo.h, dir/bar/FooParent.h, and dir/bar/FooParent.h +to be generated""") +op.add_option('-o', '--outcpp-dir', dest='cppdir', default='.', + help="""Director into which C++ sources will be generated +A protocol Foo in the namespace bar will cause the sources + cppdir/FooParent.cpp, cppdir/FooChild.cpp +to be generated""") + options, files = op.parse_args() _verbosity = options.verbosity -codedir = options.outputdir +headersdir = options.headersdir +cppdir = options.cppdir includedirs = [ os.path.abspath(incdir) for incdir in options.includedirs ] if not len(files): op.error("No IPDL files specified") -log(1, 'Generated headers will be placed in "%s"', codedir) +log(1, 'Generated C++ headers will be generated relative to "%s"', headersdir) +log(1, 'Generated C++ sources will be generated relative to "%s"', cppdir) allprotocols = [] @@ -92,7 +103,7 @@ for f in files: log(3, ' pretty printed code:') ipdl.genipdl(ast, codedir) - ipdl.gencxx(ast, codedir) + ipdl.gencxx(filename, ast, headersdir, cppdir) allprotocols.sort() @@ -101,6 +112,9 @@ ipcmsgstart = StringIO() print >>ipcmsgstart, """ // CODE GENERATED by ipdl.py. Do not edit. +#ifndef IPCMessageStart_h +#define IPCMessageStart_h + enum IPCMessageStart { """ @@ -110,7 +124,11 @@ for name in allprotocols: print >>ipcmsgstart, """ LastMsgIndex }; + +COMPILE_ASSERT(LastMsgIndex <= 64, need_to_update_IPC_MESSAGE_MACRO); + +#endif // ifndef IPCMessageStart_h """ ipdl.writeifmodified(ipcmsgstart.getvalue(), - os.path.join(codedir, 'IPCMessageStart.h')) + os.path.join(headersdir, 'IPCMessageStart.h')) diff --git a/ipc/ipdl/ipdl/__init__.py b/ipc/ipdl/ipdl/__init__.py index 806e9f4a1f31..fa0cc7bf4ff0 100644 --- a/ipc/ipdl/ipdl/__init__.py +++ b/ipc/ipdl/ipdl/__init__.py @@ -42,29 +42,43 @@ from ipdl.type import TypeCheck from ipdl.cxx.cgen import CxxCodeGen + def parse(specstring, filename='/stdin', includedirs=[ ], errout=sys.stderr): '''Return an IPDL AST if parsing was successful. Print errors to |errout| if it is not.''' return Parser().parse(specstring, os.path.abspath(filename), includedirs, errout) + 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(ast, outdir): - for hdr in LowerToCxx().lower(ast): - file = os.path.join( - outdir, - *([ns.name for ns in ast.protocol.namespaces] + [hdr.name])) +def gencxx(ipdlfilename, ast, outheadersdir, outcppdir): + headers, cpps = LowerToCxx().lower(ast) + + def resolveHeader(hdr): + return [ + hdr, + os.path.join( + outheadersdir, + *([ns.name for ns in ast.protocol.namespaces] + [hdr.name])) + ] + def resolveCpp(cpp): + return [ cpp, os.path.join(outcppdir, cpp.name) ] + + for ast, filename in ([ resolveHeader(hdr) for hdr in headers ] + + [ resolveCpp(cpp) for cpp in cpps ]): tempfile = StringIO() - CxxCodeGen(tempfile).cgen(hdr) - writeifmodified(tempfile.getvalue(), file) + CxxCodeGen(tempfile).cgen(ast) + writeifmodified(tempfile.getvalue(), filename) + def genipdl(ast, outdir): return IPDLCodeGen().cgen(ast) + def writeifmodified(contents, file): dir = os.path.dirname(file) os.path.exists(dir) or os.makedirs(dir) diff --git a/ipc/ipdl/ipdl/builtin.py b/ipc/ipdl/ipdl/builtin.py index 05ae19e5f447..1dac5e2a4375 100644 --- a/ipc/ipdl/ipdl/builtin.py +++ b/ipc/ipdl/ipdl/builtin.py @@ -67,6 +67,7 @@ Includes = ( 'base/basictypes.h', 'prtime.h', 'nscore.h', + 'IPCMessageStart.h', 'IPC/IPCMessageUtils.h', 'nsStringGlue.h', 'nsTArray.h', diff --git a/ipc/ipdl/ipdl/cxx/ast.py b/ipc/ipdl/ipdl/cxx/ast.py index b2622858abea..0a25a24db980 100644 --- a/ipc/ipdl/ipdl/cxx/ast.py +++ b/ipc/ipdl/ipdl/cxx/ast.py @@ -77,6 +77,11 @@ class Visitor: def visitDecl(self, decl): decl.type.accept(self) + def visitParam(self, param): + self.visitDecl(param) + if param.default is not None: + param.default.accept(self) + def visitClass(self, cls): for inherit in cls.inherits: inherit.accept(self) @@ -398,6 +403,14 @@ class Decl(Node): def __deepcopy__(self, memo): return Decl(copy.deepcopy(self.type, memo), self.name) +class Param(Decl): + def __init__(self, type, name, default=None): + Decl.__init__(self, type, name) + self.default = default + def __deepcopy__(self, memo): + return Param(copy.deepcopy(self.type, memo), self.name, + copy.deepcopy(self.default, memo)) + ##------------------------------ # class stuff class Class(Block): @@ -486,6 +499,11 @@ class DestructorDecl(MethodDecl): def __init__(self, name, virtual=0): MethodDecl.__init__(self, name, params=[ ], ret=None, virtual=virtual) + + def __deepcopy__(self, memo): + return DestructorDecl(self.name, self.virtual) + + class DestructorDefn(MethodDefn): def __init__(self, decl): MethodDefn.__init__(self, decl) diff --git a/ipc/ipdl/ipdl/cxx/cgen.py b/ipc/ipdl/ipdl/cxx/cgen.py index 8053d902bbec..7e28e84ffd02 100644 --- a/ipc/ipdl/ipdl/cxx/cgen.py +++ b/ipc/ipdl/ipdl/cxx/cgen.py @@ -136,6 +136,12 @@ class CxxCodeGen(CodePrinter, Visitor): d.type.nmemb.accept(self) self.write(']') + def visitParam(self, p): + self.visitDecl(p) + if p.default is not None: + self.write(' = ') + p.default.accept(self) + def visitClass(self, c): if c.specializes is not None: self.printdentln('template<>') @@ -258,7 +264,12 @@ class CxxCodeGen(CodePrinter, Visitor): def visitDestructorDecl(self, dd): if dd.virtual: self.write('virtual ') - self.write('~'+ dd.name +'()') + + # hack alert + parts = dd.name.split('::') + parts[-1] = '~'+ parts[-1] + + self.write('::'.join(parts) +'()') def visitDestructorDefn(self, dd): self.printdent() diff --git a/ipc/ipdl/ipdl/lower.py b/ipc/ipdl/ipdl/lower.py index 928d84fbb438..531ad3aaa3f9 100644 --- a/ipc/ipdl/ipdl/lower.py +++ b/ipc/ipdl/ipdl/lower.py @@ -48,7 +48,8 @@ EMIT_LOGGING_CODE = ('win32' == sys.platform) ## class LowerToCxx: def lower(self, tu): - '''returns a list of File representing the lowered form of |tu|''' + '''returns |[ header: File ], [ cpp : File ]| representing the +lowered form of |tu|''' # annotate the AST with IPDL/C++ IR-type stuff used later tu.accept(_DecorateWithCxxStuff()) @@ -57,13 +58,15 @@ class LowerToCxx: pheader = File(pname +'.h') _GenerateProtocolHeader().lower(tu, pheader) - parentheader = File(pname +'Parent.h') - _GenerateProtocolParentHeader().lower(tu, pname+'Parent', parentheader) + parentheader, parentcpp = File(pname +'Parent.h'), File(pname +'Parent.cpp') + _GenerateProtocolParentCode().lower( + tu, pname+'Parent', parentheader, parentcpp) - childheader = File(pname +'Child.h') - _GenerateProtocolChildHeader().lower(tu, pname+'Child', childheader) + childheader, childcpp = File(pname +'Child.h'), File(pname +'Child.cpp') + _GenerateProtocolChildCode().lower( + tu, pname+'Child', childheader, childcpp) - return pheader, parentheader, childheader + return [ pheader, parentheader, childheader ], [ parentcpp, childcpp ] ##----------------------------------------------------------------------------- @@ -75,10 +78,14 @@ _FREED_ACTOR_ID = ExprLiteral.ONE class _struct: pass -def _protocolHeaderBaseFilename(p): +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 +'/'+ p.name - else: return p.name + if pfx: return pfx +'/'+ base + else: return base def _includeGuardMacroName(headerfile): return re.sub(r'[./]', '_', headerfile.name) @@ -356,7 +363,9 @@ def _killProcess(pid): # Results that IPDL-generated code returns back to *Channel code. # Users never see these class _Result: - Type = Type('Result') + @staticmethod + def Type(): + return Type('Result') Processed = ExprVar('MsgProcessed') NotKnown = ExprVar('MsgNotKnown') @@ -2270,58 +2279,138 @@ class _FindFriends(ipdl.ast.Visitor): yield actor -class _GenerateProtocolActorHeader(ipdl.ast.Visitor): +class _GenerateProtocolActorCode(ipdl.ast.Visitor): def __init__(self, myside): self.side = myside # "parent" or "child" self.prettyside = myside.title() self.clsname = None self.protocol = None - self.file = None + self.hdrfile = None + self.cppfile = None self.ns = None self.cls = None self.includedActorTypedefs = [ ] + self.protocolCxxIncludes = [ ] - def lower(self, tu, clsname, cxxHeaderFile): + def lower(self, tu, clsname, cxxHeaderFile, cxxFile): self.clsname = clsname - self.file = cxxHeaderFile + self.hdrfile = cxxHeaderFile + self.cppfile = cxxFile tu.accept(self) - def visitTranslationUnit(self, tu): - f = self.file + def standardTypedefs(self): + return [ + Typedef(Type('IPC::Message'), 'Message'), + Typedef(Type(self.protocol.channelName()), 'Channel'), + Typedef(Type(self.protocol.fqListenerName()), 'ChannelListener'), + Typedef(Type('base::ProcessHandle'), 'ProcessHandle') + ] - f.addthing(Whitespace('''// + + def visitTranslationUnit(self, tu): + self.protocol = tu.protocol + + hf = self.hdrfile + cf = self.cppfile + + disclaimer = Whitespace('''// // Automatically generated by ipdlc. // Edit at your own risk // -''')) - f.addthings(_includeGuardStart(f)) - f.addthings([ - Whitespace.NL, - CppDirective( - 'include', - '"'+ _protocolHeaderBaseFilename(tu.protocol) +'.h"') ]) - - self.protocol = tu.protocol +''') + # make the C++ header + hf.addthings( + [ disclaimer ] + + _includeGuardStart(hf) + +[ + Whitespace.NL, + CppDirective( + 'include', + '"'+ _protocolHeaderName(tu.protocol) +'.h"') + ]) for pinc in tu.protocolIncludes: pinc.accept(self) + # this generates the actor's full impl in self.cls tu.protocol.accept(self) - f.addthing(Whitespace.NL) - f.addthings(_includeGuardEnd(f)) + clsdecl, clsdefn = _ClassDeclDefn().split(self.cls) + + # XXX damn C++ ... return types in the method defn aren't in + # class scope + for stmt in clsdefn.stmts: + if isinstance(stmt, MethodDefn): + if stmt.decl.ret and stmt.decl.ret.name == 'Result': + stmt.decl.ret.name = clsdecl.name +'::'+ stmt.decl.ret.name + + def makeNamespace(p, file): + if 0 == len(p.namespaces): + return file + ns = Namespace(p.namespaces[-1].name) + outerns = _putInNamespaces(ns, p.namespaces[:-1]) + file.addthing(outerns) + return ns + + hdrns = makeNamespace(self.protocol, self.hdrfile) + hdrns.addstmts([ + Whitespace.NL, + Whitespace.NL, + clsdecl, + Whitespace.NL, + Whitespace.NL + ]) + + self.hdrfile.addthings( + ([ + Whitespace.NL, + CppDirective('if', '0') ]) + + _GenerateSkeletonImpl( + _actorName(self.protocol.name, self.side)[1:], + self.protocol.namespaces).fromclass(self.cls) + +([ + CppDirective('endif', '// if 0'), + Whitespace.NL ]) + + _includeGuardEnd(hf)) + + # make the .cpp file + cf.addthings(( + [ disclaimer, + Whitespace.NL, + CppDirective( + 'include', + '"'+ _protocolHeaderName(self.protocol, self.side) +'.h"'), + Whitespace.NL + ] + + self.protocolCxxIncludes + + [ Whitespace.NL ] + + self.standardTypedefs() + + self.includedActorTypedefs + + tu.protocol.decl.cxxtypedefs + + [ Whitespace.NL ])) + + cppns = makeNamespace(self.protocol, cf) + cppns.addstmts([ + Whitespace.NL, + Whitespace.NL, + clsdefn, + Whitespace.NL, + Whitespace.NL + ]) def visitProtocolInclude(self, pi): ip = pi.tu.protocol - if self.protocol.decl.type.isManagerOf(ip.decl.type): - self.file.addthing( - CppDirective( - 'include', - '"%s%s.h"'% (_protocolHeaderBaseFilename(ip), - self.prettyside))) + self.hdrfile.addthings([ + _makeForwardDecl(ip.decl.type, self.side), + Whitespace.NL + ]) + self.protocolCxxIncludes.append( + CppDirective( + 'include', + '"%s.h"'% (_protocolHeaderName(ip, self.side)))) if ip.decl.fullname is not None: self.includedActorTypedefs.append(Typedef( @@ -2330,7 +2419,7 @@ class _GenerateProtocolActorHeader(ipdl.ast.Visitor): def visitProtocol(self, p): - self.file.addthings([ + self.hdrfile.addthings([ CppDirective('ifdef', 'DEBUG'), CppDirective('include', '"prenv.h"'), CppDirective('endif', '// DEBUG') @@ -2340,9 +2429,9 @@ class _GenerateProtocolActorHeader(ipdl.ast.Visitor): # FIXME: all actors impl Iface for now if p.decl.type.isManager() or 1: - self.file.addthing(CppDirective('include', '"base/id_map.h"')) + self.hdrfile.addthing(CppDirective('include', '"base/id_map.h"')) - self.file.addthings([ + self.hdrfile.addthings([ CppDirective('include', '"'+ p.channelHeaderFile() +'"'), Whitespace.NL ]) @@ -2356,7 +2445,7 @@ class _GenerateProtocolActorHeader(ipdl.ast.Visitor): friends.add(p.decl.type.manager) for friend in friends: - self.file.addthings([ + self.hdrfile.addthings([ Whitespace.NL, _makeForwardDecl(friend, self.prettyside), Whitespace.NL @@ -2366,15 +2455,6 @@ class _GenerateProtocolActorHeader(ipdl.ast.Visitor): self.prettyside)), Whitespace.NL ]) - # construct the namespace into which we'll stick all our decls - if 0 == len(p.namespaces): - self.ns = self.file - else: - self.ns = Namespace(p.namespaces[-1].name) - outerns = _putInNamespaces(self.ns, p.namespaces[:-1]) - self.file.addthing(outerns) - self.ns.addstmts([ Whitespace.NL, Whitespace.NL ]) - self.cls.addstmt(Label.PROTECTED) for typedef in p.cxxTypedefs(): self.cls.addstmt(typedef) @@ -2420,14 +2500,11 @@ class _GenerateProtocolActorHeader(ipdl.ast.Visitor): self.cls.addstmt(Whitespace.NL) - self.cls.addstmts([ - Label.PRIVATE, - Typedef(Type('IPC::Message'), 'Message'), - Typedef(Type(p.channelName()), 'Channel'), - Typedef(Type(p.fqListenerName()), 'ChannelListener'), - Typedef(Type('base::ProcessHandle'), 'ProcessHandle'), - Whitespace.NL, - ]) + self.cls.addstmts(( + [ Label.PRIVATE ] + + self.standardTypedefs() + + [ Whitespace.NL ] + )) self.cls.addstmt(Label.PUBLIC) # Actor() @@ -2467,8 +2544,9 @@ class _GenerateProtocolActorHeader(ipdl.ast.Visitor): params=[ Decl(Type('Channel::Transport', ptr=True), aTransportVar.name), Decl(Type('ProcessHandle'), processvar.name), - Decl(Type('MessageLoop', ptr=True), - aThreadVar.name +' = 0') ], + Param(Type('MessageLoop', ptr=True), + aThreadVar.name, + default=ExprLiteral.NULL) ], ret=Type.BOOL)) openmeth.addstmts([ @@ -2530,7 +2608,7 @@ class _GenerateProtocolActorHeader(ipdl.ast.Visitor): replyvar.name)) method = MethodDefn(MethodDecl(name, virtual=True, - params=params, ret=_Result.Type)) + params=params, ret=_Result.Type())) if dispatches: routevar = ExprVar('__route') routedecl = StmtDecl( @@ -2649,17 +2727,6 @@ class _GenerateProtocolActorHeader(ipdl.ast.Visitor): StmtDecl(Decl(_shmemIdType(), p.lastShmemIdVar().name)) ]) - self.ns.addstmts([ self.cls, Whitespace.NL, Whitespace.NL ]) - - # generate skeleton implementation of abstract actor class - self.file.addthing(CppDirective('if', '0')) - - genskeleton = _GenerateSkeletonImpl() - genskeleton.fromclass(self.cls) - self.file.addthings(genskeleton.stuff) - - self.file.addthing(CppDirective('endif', '// if 0')) - def implementManagerIface(self): p = self.protocol @@ -3438,9 +3505,9 @@ class _GenerateProtocolActorHeader(ipdl.ast.Visitor): ExprVar('stderr') ])) ]) -class _GenerateProtocolParentHeader(_GenerateProtocolActorHeader): +class _GenerateProtocolParentCode(_GenerateProtocolActorCode): def __init__(self): - _GenerateProtocolActorHeader.__init__(self, 'parent') + _GenerateProtocolActorCode.__init__(self, 'parent') def sendsMessage(self, md): return not md.decl.type.isIn() @@ -3448,9 +3515,9 @@ class _GenerateProtocolParentHeader(_GenerateProtocolActorHeader): def receivesMessage(self, md): return md.decl.type.isInout() or md.decl.type.isIn() -class _GenerateProtocolChildHeader(_GenerateProtocolActorHeader): +class _GenerateProtocolChildCode(_GenerateProtocolActorCode): def __init__(self): - _GenerateProtocolActorHeader.__init__(self, 'child') + _GenerateProtocolActorCode.__init__(self, 'child') def sendsMessage(self, md): return not md.decl.type.isOut() @@ -3460,29 +3527,62 @@ class _GenerateProtocolChildHeader(_GenerateProtocolActorHeader): ##----------------------------------------------------------------------------- -## Bonus (inessential) passes +## Utility passes ## +class _ClassDeclDefn: + def split(self, cls): + """Warning: destructively splits |cls|!""" + defns = Block() + + for i, stmt in enumerate(cls.stmts): + if isinstance(stmt, MethodDefn): + decl, defn = self.splitMethodDefn(stmt, cls.name) + cls.stmts[i] = StmtDecl(decl) + defns.addstmts([ defn, Whitespace.NL ]) + + return cls, defns + + def splitMethodDefn(self, md, clsname): + saveddecl = deepcopy(md.decl) + md.decl.name = (clsname +'::'+ md.decl.name) + md.decl.virtual = 0 + md.decl.static = 0 + for param in md.decl.params: + if isinstance(param, Param): + param.default = None + return saveddecl, md + + +# XXX this is tantalizingly similar to _SplitDeclDefn, but just +# different enough that I don't see the need to define +# _GenerateSkeleton in terms of that class _GenerateSkeletonImpl(Visitor): - def __init__(self, name='ActorImpl'): + def __init__(self, name, namespaces): self.name = name - self.stuff = [ ] self.cls = None - self.methodimpls = [ ] + self.namespaces = namespaces + self.methodimpls = Block() def fromclass(self, cls): cls.accept(self) - self.stuff.append(Whitespace(''' + + nsclass = _putInNamespaces(self.cls, self.namespaces) + nsmethodimpls = _putInNamespaces(self.methodimpls, self.namespaces) + + return [ + Whitespace(''' //----------------------------------------------------------------------------- // Skeleton implementation of abstract actor class -''')) - self.stuff.append(Whitespace('// Header file contents\n')) - self.stuff.append(self.cls) +'''), + Whitespace('// Header file contents\n'), + nsclass, + Whitespace.NL, + Whitespace('\n// C++ file contents\n'), + nsmethodimpls + ] - self.stuff.append(Whitespace.NL) - self.stuff.append(Whitespace('\n// C++ file contents\n')) - self.stuff.extend(self.methodimpls) def visitClass(self, cls): self.cls = Class(self.name, inherits=[ Inherit(Type(cls.name)) ]) @@ -3521,8 +3621,7 @@ class _GenerateSkeletonImpl(Visitor): self.addmethodimpl(dtor) def addmethodimpl(self, impl): - self.methodimpls.append(impl) - self.methodimpls.append(Whitespace.NL) + self.methodimpls.addstmts([ impl, Whitespace.NL ]) def implname(self, method): return self.name +'::'+ method diff --git a/ipc/ipdl/test/cxx/IPDLUnitTestTypes.h b/ipc/ipdl/test/cxx/IPDLUnitTestTypes.h new file mode 100644 index 000000000000..2a8ecc00d2e4 --- /dev/null +++ b/ipc/ipdl/test/cxx/IPDLUnitTestTypes.h @@ -0,0 +1,76 @@ +/* -*- Mode: C++; c-basic-offset: 2; indent-tabs-mode: nil; tab-width: 8 -*- */ +/* ***** BEGIN LICENSE BLOCK ***** + * Version: MPL 1.1/GPL 2.0/LGPL 2.1 + * + * The contents of this file are subject to the Mozilla Public License Version + * 1.1 (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * http://www.mozilla.org/MPL/ + * + * Software distributed under the License is distributed on an "AS IS" basis, + * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License + * for the specific language governing rights and limitations under the + * License. + * + * The Original Code is Mozilla IPC. + * + * The Initial Developer of the Original Code is + * The Mozilla Foundation + * Portions created by the Initial Developer are Copyright (C) 2009 + * the Initial Developer. All Rights Reserved. + * + * Contributor(s): + * Chris Jones . + * + * Alternatively, the contents of this file may be used under the terms of + * either the GNU General Public License Version 2 or later (the "GPL"), or + * the GNU Lesser General Public License Version 2.1 or later (the "LGPL"), + * in which case the provisions of the GPL or the LGPL are applicable instead + * of those above. If you wish to allow use of your version of this file only + * under the terms of either the GPL or the LGPL, and not to allow others to + * use your version of this file under the terms of the MPL, indicate your + * decision by deleting the provisions above and replace them with the notice + * and other provisions required by the GPL or the LGPL. If you do not delete + * the provisions above, a recipient may use your version of this file under + * the terms of any one of the MPL, the GPL or the LGPL. + * + * ***** END LICENSE BLOCK ***** */ + +#ifndef mozilla__ipdltest_IPDLUnitTestTypes_h +#define mozilla__ipdltest_IPDLUnitTestTypes_h + + +namespace mozilla { +namespace _ipdltest { + +struct DirtyRect +{ + int x; int y; int w; int h; +}; + +} +} + +namespace IPC { +template<> +struct ParamTraits +{ + typedef mozilla::_ipdltest::DirtyRect paramType; + static void Write(Message* aMsg, const paramType& aParam) { + WriteParam(aMsg, aParam.x); + WriteParam(aMsg, aParam.y); + WriteParam(aMsg, aParam.w); + WriteParam(aMsg, aParam.h); + } + static bool Read(const Message* aMsg, void** aIter, paramType* aResult) + { + return (ReadParam(aMsg, aIter, &aResult->x) && + ReadParam(aMsg, aIter, &aResult->y) && + ReadParam(aMsg, aIter, &aResult->w) && + ReadParam(aMsg, aIter, &aResult->h)); + } +}; +} + + +#endif // ifndef mozilla__ipdltest_IPDLUnitTestTypes_h diff --git a/ipc/ipdl/test/cxx/Makefile.in b/ipc/ipdl/test/cxx/Makefile.in index 3fc1cf4e8b8f..3172a492b96f 100644 --- a/ipc/ipdl/test/cxx/Makefile.in +++ b/ipc/ipdl/test/cxx/Makefile.in @@ -49,6 +49,7 @@ EXPORTS_NAMESPACES = mozilla/_ipdltest EXPORTS_mozilla/_ipdltest = \ IPDLUnitTests.h \ IPDLUnitTestThreadChild.h \ + IPDLUnitTestTypes.h \ $(NULL) LIBRARY_NAME = $(MODULE)_s @@ -78,7 +79,6 @@ CPPSRCS = \ $(IPDLTESTSRCS) \ $(NULL) - include $(topsrcdir)/config/config.mk include $(topsrcdir)/ipc/chromium/chromium-config.mk include $(topsrcdir)/config/rules.mk diff --git a/toolkit/library/libxul-config.mk b/toolkit/library/libxul-config.mk index 8dd3ce9a403c..ce8294da2d6e 100644 --- a/toolkit/library/libxul-config.mk +++ b/toolkit/library/libxul-config.mk @@ -96,6 +96,7 @@ STATIC_LIBS += \ domipc_s \ domplugins_s \ mozipc_s \ + mozipdlgen_s \ chromium_s \ ipcshell_s \ gfxipc_s \ diff --git a/toolkit/toolkit-tiers.mk b/toolkit/toolkit-tiers.mk index 60f0f177825e..d1b1f8f79c1b 100644 --- a/toolkit/toolkit-tiers.mk +++ b/toolkit/toolkit-tiers.mk @@ -174,10 +174,6 @@ ifdef ACCESSIBILITY tier_gecko_dirs += accessible endif -ifdef MOZ_IPDL_TESTS -tier_gecko_dirs += ipc/ipdl/test -endif - # # tier "toolkit" - xpfe & toolkit # diff --git a/xpcom/build.mk b/xpcom/build.mk index a602888470d8..f5c70fe888aa 100644 --- a/xpcom/build.mk +++ b/xpcom/build.mk @@ -44,5 +44,5 @@ endif tier_xpcom_dirs += xpcom ifdef MOZ_IPC -tier_xpcom_dirs += ipc/ipdl ipc/chromium ipc/glue +tier_xpcom_dirs += ipc/chromium ipc/glue endif