зеркало из https://github.com/mozilla/gecko-dev.git
generate skeleton IPDL actor impls, like the IDL compiler does for interfaces. also fix the C++ visitor.
This commit is contained in:
Родитель
55c13c871a
Коммит
51d8168a20
|
@ -142,5 +142,55 @@ private:
|
|||
};
|
||||
|
||||
|
||||
#if 0
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
// Skeleton implementation of abstract actor class
|
||||
|
||||
// Header file contents
|
||||
class ActorImpl :
|
||||
public IFrameEmbeddingProtocolChild
|
||||
{
|
||||
virtual nsresult Answerinit(const MagicWindowHandle& parentWidget);
|
||||
virtual nsresult AnswerloadURL(const String& uri);
|
||||
virtual nsresult Answermove(
|
||||
const PRUint32& x,
|
||||
const PRUint32& y,
|
||||
const PRUint32& width,
|
||||
const PRUint32& height);
|
||||
ActorImpl();
|
||||
virtual ~ActorImpl();
|
||||
};
|
||||
|
||||
|
||||
// C++ file contents
|
||||
nsresult ActorImpl::Answerinit(const MagicWindowHandle& parentWidget)
|
||||
{
|
||||
return NS_ERROR_NOT_IMPLEMENTED;
|
||||
}
|
||||
|
||||
nsresult ActorImpl::AnswerloadURL(const String& uri)
|
||||
{
|
||||
return NS_ERROR_NOT_IMPLEMENTED;
|
||||
}
|
||||
|
||||
nsresult ActorImpl::Answermove(
|
||||
const PRUint32& x,
|
||||
const PRUint32& y,
|
||||
const PRUint32& width,
|
||||
const PRUint32& height)
|
||||
{
|
||||
return NS_ERROR_NOT_IMPLEMENTED;
|
||||
}
|
||||
|
||||
ActorImpl::ActorImpl()
|
||||
{
|
||||
}
|
||||
|
||||
ActorImpl::~ActorImpl()
|
||||
{
|
||||
}
|
||||
|
||||
#endif // if 0
|
||||
|
||||
#endif // ifndef IFrameEmbeddingProtocolChild_h
|
||||
|
|
|
@ -136,5 +136,29 @@ private:
|
|||
};
|
||||
|
||||
|
||||
#if 0
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
// Skeleton implementation of abstract actor class
|
||||
|
||||
// Header file contents
|
||||
class ActorImpl :
|
||||
public IFrameEmbeddingProtocolParent
|
||||
{
|
||||
ActorImpl();
|
||||
virtual ~ActorImpl();
|
||||
};
|
||||
|
||||
|
||||
// C++ file contents
|
||||
ActorImpl::ActorImpl()
|
||||
{
|
||||
}
|
||||
|
||||
ActorImpl::~ActorImpl()
|
||||
{
|
||||
}
|
||||
|
||||
#endif // if 0
|
||||
|
||||
#endif // ifndef IFrameEmbeddingProtocolParent_h
|
||||
|
|
|
@ -192,5 +192,61 @@ private:
|
|||
|
||||
} // namespace plugins
|
||||
} // namespace mozilla
|
||||
#if 0
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
// Skeleton implementation of abstract actor class
|
||||
|
||||
// Header file contents
|
||||
class ActorImpl :
|
||||
public NPAPIProtocolChild
|
||||
{
|
||||
virtual nsresult AnswerNP_Initialize(NPError* rv);
|
||||
virtual NPPProtocolChild* NPPConstructor(
|
||||
const String& aMimeType,
|
||||
const uint16_t& aMode,
|
||||
const StringArray& aNames,
|
||||
const StringArray& aValues,
|
||||
NPError* rv);
|
||||
virtual nsresult NPPDestructor(
|
||||
NPPProtocolChild* __a,
|
||||
NPError* rv);
|
||||
ActorImpl();
|
||||
virtual ~ActorImpl();
|
||||
};
|
||||
|
||||
|
||||
// C++ file contents
|
||||
nsresult ActorImpl::AnswerNP_Initialize(NPError* rv)
|
||||
{
|
||||
return NS_ERROR_NOT_IMPLEMENTED;
|
||||
}
|
||||
|
||||
NPPProtocolChild* ActorImpl::NPPConstructor(
|
||||
const String& aMimeType,
|
||||
const uint16_t& aMode,
|
||||
const StringArray& aNames,
|
||||
const StringArray& aValues,
|
||||
NPError* rv)
|
||||
{
|
||||
return NS_ERROR_NOT_IMPLEMENTED;
|
||||
}
|
||||
|
||||
nsresult ActorImpl::NPPDestructor(
|
||||
NPPProtocolChild* __a,
|
||||
NPError* rv)
|
||||
{
|
||||
return NS_ERROR_NOT_IMPLEMENTED;
|
||||
}
|
||||
|
||||
ActorImpl::ActorImpl()
|
||||
{
|
||||
}
|
||||
|
||||
ActorImpl::~ActorImpl()
|
||||
{
|
||||
}
|
||||
|
||||
#endif // if 0
|
||||
|
||||
#endif // ifndef mozilla_plugins_NPAPIProtocolChild_h
|
||||
|
|
|
@ -206,5 +206,55 @@ private:
|
|||
|
||||
} // namespace plugins
|
||||
} // namespace mozilla
|
||||
#if 0
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
// Skeleton implementation of abstract actor class
|
||||
|
||||
// Header file contents
|
||||
class ActorImpl :
|
||||
public NPAPIProtocolParent
|
||||
{
|
||||
virtual NPPProtocolParent* NPPConstructor(
|
||||
const String& aMimeType,
|
||||
const uint16_t& aMode,
|
||||
const StringArray& aNames,
|
||||
const StringArray& aValues,
|
||||
NPError* rv);
|
||||
virtual nsresult NPPDestructor(
|
||||
NPPProtocolParent* __a,
|
||||
NPError* rv);
|
||||
ActorImpl();
|
||||
virtual ~ActorImpl();
|
||||
};
|
||||
|
||||
|
||||
// C++ file contents
|
||||
NPPProtocolParent* ActorImpl::NPPConstructor(
|
||||
const String& aMimeType,
|
||||
const uint16_t& aMode,
|
||||
const StringArray& aNames,
|
||||
const StringArray& aValues,
|
||||
NPError* rv)
|
||||
{
|
||||
return NS_ERROR_NOT_IMPLEMENTED;
|
||||
}
|
||||
|
||||
nsresult ActorImpl::NPPDestructor(
|
||||
NPPProtocolParent* __a,
|
||||
NPError* rv)
|
||||
{
|
||||
return NS_ERROR_NOT_IMPLEMENTED;
|
||||
}
|
||||
|
||||
ActorImpl::ActorImpl()
|
||||
{
|
||||
}
|
||||
|
||||
ActorImpl::~ActorImpl()
|
||||
{
|
||||
}
|
||||
|
||||
#endif // if 0
|
||||
|
||||
#endif // ifndef mozilla_plugins_NPAPIProtocolParent_h
|
||||
|
|
|
@ -135,5 +135,49 @@ private:
|
|||
|
||||
} // namespace plugins
|
||||
} // namespace mozilla
|
||||
#if 0
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
// Skeleton implementation of abstract actor class
|
||||
|
||||
// Header file contents
|
||||
class ActorImpl :
|
||||
public NPPProtocolChild
|
||||
{
|
||||
virtual nsresult AnswerNPP_SetWindow(
|
||||
const NPWindow& window,
|
||||
NPError* rv);
|
||||
virtual nsresult AnswerNPP_GetValue(
|
||||
const String& key,
|
||||
String* value);
|
||||
ActorImpl();
|
||||
virtual ~ActorImpl();
|
||||
};
|
||||
|
||||
|
||||
// C++ file contents
|
||||
nsresult ActorImpl::AnswerNPP_SetWindow(
|
||||
const NPWindow& window,
|
||||
NPError* rv)
|
||||
{
|
||||
return NS_ERROR_NOT_IMPLEMENTED;
|
||||
}
|
||||
|
||||
nsresult ActorImpl::AnswerNPP_GetValue(
|
||||
const String& key,
|
||||
String* value)
|
||||
{
|
||||
return NS_ERROR_NOT_IMPLEMENTED;
|
||||
}
|
||||
|
||||
ActorImpl::ActorImpl()
|
||||
{
|
||||
}
|
||||
|
||||
ActorImpl::~ActorImpl()
|
||||
{
|
||||
}
|
||||
|
||||
#endif // if 0
|
||||
|
||||
#endif // ifndef mozilla_plugins_NPPProtocolChild_h
|
||||
|
|
|
@ -133,5 +133,39 @@ private:
|
|||
|
||||
} // namespace plugins
|
||||
} // namespace mozilla
|
||||
#if 0
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
// Skeleton implementation of abstract actor class
|
||||
|
||||
// Header file contents
|
||||
class ActorImpl :
|
||||
public NPPProtocolParent
|
||||
{
|
||||
virtual nsresult AnswerNPN_GetValue(
|
||||
const String& key,
|
||||
String* value);
|
||||
ActorImpl();
|
||||
virtual ~ActorImpl();
|
||||
};
|
||||
|
||||
|
||||
// C++ file contents
|
||||
nsresult ActorImpl::AnswerNPN_GetValue(
|
||||
const String& key,
|
||||
String* value)
|
||||
{
|
||||
return NS_ERROR_NOT_IMPLEMENTED;
|
||||
}
|
||||
|
||||
ActorImpl::ActorImpl()
|
||||
{
|
||||
}
|
||||
|
||||
ActorImpl::~ActorImpl()
|
||||
{
|
||||
}
|
||||
|
||||
#endif // if 0
|
||||
|
||||
#endif // ifndef mozilla_plugins_NPPProtocolParent_h
|
||||
|
|
|
@ -62,19 +62,22 @@ class Visitor:
|
|||
|
||||
def visitTypedef(self, tdef):
|
||||
tdef.fromtype.accept(self)
|
||||
tdef.tottype.accept(self)
|
||||
tdef.totype.accept(self)
|
||||
|
||||
def visitDecl(self, decl):
|
||||
decl.type.accept(self)
|
||||
|
||||
def visitClass(self, cls):
|
||||
for viz, parent in cls.inherits:
|
||||
parent.accept(self)
|
||||
for inherit in cls.inherits:
|
||||
inherit.accept(self)
|
||||
self.visitBlock(cls)
|
||||
|
||||
def visitInherit(self, inh):
|
||||
pass
|
||||
|
||||
def visitFriendClassDecl(self, fcd):
|
||||
pass
|
||||
|
||||
def visitMethodDecl(self, meth):
|
||||
for param in meth.params:
|
||||
param.accept(self)
|
||||
|
@ -101,6 +104,9 @@ class Visitor:
|
|||
dd.decl.accept(self)
|
||||
self.visitBlock(dd)
|
||||
|
||||
def visitExprLiteral(self, l):
|
||||
pass
|
||||
|
||||
def visitExprVar(self, v):
|
||||
pass
|
||||
|
||||
|
@ -117,6 +123,9 @@ class Visitor:
|
|||
def visitExprDeref(self, ed):
|
||||
self.visitExprPrefixUnop(ed)
|
||||
|
||||
def visitExprCast(self, ec):
|
||||
ec.expr.accept(self)
|
||||
|
||||
def visitExprSelect(self, es):
|
||||
es.obj.accept(self)
|
||||
|
||||
|
@ -153,6 +162,12 @@ class Visitor:
|
|||
def visitDefaultLabel(self, dl):
|
||||
pass
|
||||
|
||||
def visitStmtIf(self, si):
|
||||
si.cond.accept(self)
|
||||
si.ifb.accept(self)
|
||||
if si.elseb is not None:
|
||||
si.elseb.accept(self)
|
||||
|
||||
def visitStmtSwitch(self, ss):
|
||||
ss.expr.accept(self)
|
||||
self.visitBlock(ss)
|
||||
|
@ -268,7 +283,7 @@ class Class(Block):
|
|||
|
||||
Block.__init__(self)
|
||||
self.name = name
|
||||
self.inherits = inherits # array of (viz, Type) pairs
|
||||
self.inherits = inherits
|
||||
self.interface = interface
|
||||
self.abstract = abstract
|
||||
self.final = final
|
||||
|
|
|
@ -688,6 +688,15 @@ class GenerateProtocolActorHeader(Visitor):
|
|||
self.ns.addstmt(cxx.Whitespace.NL)
|
||||
self.ns.addstmt(cxx.Whitespace.NL)
|
||||
|
||||
# generate skeleton implementation of abstract actor class
|
||||
self.file.addthing(cxx.CppDirective('if', '0'))
|
||||
|
||||
genskeleton = GenerateSkeletonImpl()
|
||||
genskeleton.fromclass(cls)
|
||||
[ self.file.addthing(thing) for thing in genskeleton.stuff ]
|
||||
|
||||
self.file.addthing(cxx.CppDirective('endif', '// if 0'))
|
||||
|
||||
|
||||
def visitMessageDecl(self, md):
|
||||
# TODO special handling of constructor messages
|
||||
|
@ -1038,3 +1047,61 @@ class GenerateProtocolChildHeader(GenerateProtocolActorHeader):
|
|||
|
||||
def receivesMessage(self, md):
|
||||
return md.decl.type.isInout() or md.decl.type.isOut()
|
||||
|
||||
|
||||
class GenerateSkeletonImpl(cxx.Visitor):
|
||||
def __init__(self, name='ActorImpl'):
|
||||
self.name = name
|
||||
self.stuff = [ ]
|
||||
self.cls = None
|
||||
self.methodimpls = [ ]
|
||||
|
||||
def fromclass(self, cls):
|
||||
cls.accept(self)
|
||||
self.stuff.append(cxx.Whitespace('''
|
||||
//-----------------------------------------------------------------------------
|
||||
// Skeleton implementation of abstract actor class
|
||||
|
||||
'''))
|
||||
self.stuff.append(cxx.Whitespace('// Header file contents\n'))
|
||||
self.stuff.append(self.cls)
|
||||
|
||||
self.stuff.append(cxx.Whitespace.NL)
|
||||
self.stuff.append(cxx.Whitespace('\n// C++ file contents\n'))
|
||||
self.stuff.extend(self.methodimpls)
|
||||
|
||||
def visitClass(self, cls):
|
||||
self.cls = cxx.Class(self.name, inherits=[ cxx.Inherit(cls.name) ])
|
||||
cxx.Visitor.visitClass(self, cls)
|
||||
|
||||
def visitMethodDecl(self, md):
|
||||
if not md.pure:
|
||||
return
|
||||
decl = deepcopy(md)
|
||||
decl.pure = 0
|
||||
impl = cxx.MethodDefn(cxx.MethodDecl(self.implname(md.name),
|
||||
params=md.params,
|
||||
ret=md.ret))
|
||||
impl.addstmt(cxx.StmtReturn(cxx.ExprVar('NS_ERROR_NOT_IMPLEMENTED')))
|
||||
|
||||
self.cls.addstmt(cxx.StmtDecl(decl))
|
||||
self.addmethodimpl(impl)
|
||||
|
||||
def visitConstructorDecl(self, cd):
|
||||
self.cls.addstmt(cxx.StmtDecl(cxx.ConstructorDecl(self.name)))
|
||||
self.addmethodimpl(
|
||||
cxx.ConstructorDefn(cxx.ConstructorDecl(self.implname(self.name))))
|
||||
|
||||
def visitDestructorDecl(self, dd):
|
||||
self.cls.addstmt(
|
||||
cxx.StmtDecl(cxx.DestructorDecl(self.name, virtual=1)))
|
||||
# FIXME/cjones: hack!
|
||||
self.addmethodimpl(
|
||||
cxx.DestructorDefn(cxx.ConstructorDecl(self.implname('~' +self.name))))
|
||||
|
||||
def addmethodimpl(self, impl):
|
||||
self.methodimpls.append(impl)
|
||||
self.methodimpls.append(cxx.Whitespace.NL)
|
||||
|
||||
def implname(self, method):
|
||||
return self.name +'::'+ method
|
||||
|
|
Загрузка…
Ссылка в новой задаче