зеркало из https://github.com/mozilla/pjs.git
implement protocol manager support for all channel types, not just RPC
This commit is contained in:
Родитель
eb2de9cd73
Коммит
f9e219f619
|
@ -54,11 +54,12 @@ struct ActorHandle
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
|
template<class ListenerT>
|
||||||
class /*NS_INTERFACE_CLASS*/ IProtocolManager
|
class /*NS_INTERFACE_CLASS*/ IProtocolManager
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
virtual int32 Register(RPCChannel::RPCListener*) = 0;
|
virtual int32 Register(ListenerT*) = 0;
|
||||||
virtual RPCChannel::RPCListener* Lookup(int32) = 0;
|
virtual ListenerT* Lookup(int32) = 0;
|
||||||
virtual void Unregister(int32) = 0;
|
virtual void Unregister(int32) = 0;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
|
@ -206,7 +206,7 @@ class GenerateProtocolHeader(Visitor):
|
||||||
|
|
||||||
def visitMessageDecl(self, md):
|
def visitMessageDecl(self, md):
|
||||||
# where we squirrel away some common information
|
# where we squirrel away some common information
|
||||||
setattr(md, '_cxx', _struct())
|
md._cxx = _struct()
|
||||||
|
|
||||||
md._cxx.params = [ ]
|
md._cxx.params = [ ]
|
||||||
for param in md.inParams:
|
for param in md.inParams:
|
||||||
|
@ -411,6 +411,8 @@ class GenerateProtocolActorHeader(Visitor):
|
||||||
|
|
||||||
|
|
||||||
def visitProtocol(self, p):
|
def visitProtocol(self, p):
|
||||||
|
p._cxx = _struct()
|
||||||
|
|
||||||
if p.decl.type.isManager():
|
if p.decl.type.isManager():
|
||||||
self.file.addthing(cxx.CppDirective('include', '"base/id_map.h"'))
|
self.file.addthing(cxx.CppDirective('include', '"base/id_map.h"'))
|
||||||
|
|
||||||
|
@ -443,9 +445,11 @@ class GenerateProtocolActorHeader(Visitor):
|
||||||
self.ns.addstmt(cxx.Whitespace.NL)
|
self.ns.addstmt(cxx.Whitespace.NL)
|
||||||
|
|
||||||
channellistener = channelname +'::'+ channellistener
|
channellistener = channelname +'::'+ channellistener
|
||||||
|
p._cxx.managertype = (
|
||||||
|
'mozilla::ipc::IProtocolManager<'+ channellistener +'>')
|
||||||
inherits = [ cxx.Inherit(channellistener) ]
|
inherits = [ cxx.Inherit(channellistener) ]
|
||||||
if p.decl.type.isManager():
|
if p.decl.type.isManager():
|
||||||
inherits.append(cxx.Inherit('mozilla::ipc::IProtocolManager'))
|
inherits.append(cxx.Inherit(p._cxx.managertype))
|
||||||
cls = cxx.Class(self.clsname, inherits=inherits, abstract=True)
|
cls = cxx.Class(self.clsname, inherits=inherits, abstract=True)
|
||||||
|
|
||||||
if p.decl.type.isManaged():
|
if p.decl.type.isManaged():
|
||||||
|
@ -687,12 +691,11 @@ class GenerateProtocolActorHeader(Visitor):
|
||||||
if p.decl.type.isToplevel() and p.decl.type.isManager():
|
if p.decl.type.isToplevel() and p.decl.type.isManager():
|
||||||
cls.addstmt(cxx.StmtDecl(cxx.Decl(
|
cls.addstmt(cxx.StmtDecl(cxx.Decl(
|
||||||
cxx.Type('IDMap<ChannelListener>'), 'mActorMap')))
|
cxx.Type('IDMap<ChannelListener>'), 'mActorMap')))
|
||||||
else:
|
elif p.decl.type.isManaged():
|
||||||
cls.addstmt(cxx.StmtDecl(cxx.Decl(cxx.Type('int'), 'mId')))
|
cls.addstmt(cxx.StmtDecl(cxx.Decl(cxx.Type('int'), 'mId')))
|
||||||
cls.addstmt(cxx.StmtDecl(cxx.Decl(cxx.Type('int'), 'mPeerId')))
|
cls.addstmt(cxx.StmtDecl(cxx.Decl(cxx.Type('int'), 'mPeerId')))
|
||||||
cls.addstmt(cxx.StmtDecl(cxx.Decl(
|
cls.addstmt(cxx.StmtDecl(cxx.Decl(
|
||||||
cxx.Type('mozilla::ipc::IProtocolManager', ptr=1),
|
cxx.Type(p._cxx.managertype, ptr=1), 'mManager')))
|
||||||
'mManager')))
|
|
||||||
self.ns.addstmt(cls)
|
self.ns.addstmt(cls)
|
||||||
self.ns.addstmt(cxx.Whitespace.NL)
|
self.ns.addstmt(cxx.Whitespace.NL)
|
||||||
self.ns.addstmt(cxx.Whitespace.NL)
|
self.ns.addstmt(cxx.Whitespace.NL)
|
||||||
|
|
Загрузка…
Ссылка в новой задаче