Bug 1262937 - part 7 - factor out union type deserialization errors; r=jld

This commit is contained in:
Nathan Froyd 2016-05-21 04:07:56 -04:00
Родитель dfe775eb9f
Коммит 647562c2d2
3 изменённых файлов: 20 добавлений и 2 удалений

Просмотреть файл

@ -511,5 +511,12 @@ MismatchedActorTypeError(const char* aActorDescription)
ProtocolErrorBreakpoint(message.get()); ProtocolErrorBreakpoint(message.get());
} }
void
UnionTypeReadError(const char* aUnionName)
{
nsPrintfCString message("error deserializing type of union %s", aUnionName);
NS_RUNTIMEABORT(message.get());
}
} // namespace ipc } // namespace ipc
} // namespace mozilla } // namespace mozilla

Просмотреть файл

@ -339,6 +339,9 @@ ActorLookupError(const char* aActorDescription);
MOZ_NEVER_INLINE void MOZ_NEVER_INLINE void
MismatchedActorTypeError(const char* aActorDescription); MismatchedActorTypeError(const char* aActorDescription);
MOZ_NEVER_INLINE void
UnionTypeReadError(const char* aUnionName);
struct PrivateIPDLInterface {}; struct PrivateIPDLInterface {};
nsresult nsresult

Просмотреть файл

@ -403,6 +403,11 @@ def _logicError(msg):
return StmtExpr( return StmtExpr(
ExprCall(ExprVar('mozilla::ipc::LogicError'), args=[ ExprLiteral.String(msg) ])) ExprCall(ExprVar('mozilla::ipc::LogicError'), args=[ ExprLiteral.String(msg) ]))
def _unionTypeReadError(unionname):
return StmtExpr(
ExprCall(ExprVar('mozilla::ipc::UnionTypeReadError'),
args=[ ExprLiteral.String(unionname) ]))
def _killProcess(pid): def _killProcess(pid):
return ExprCall( return ExprCall(
ExprVar('base::KillProcess'), ExprVar('base::KillProcess'),
@ -462,6 +467,9 @@ def errfnRecv(msg, errcode=_Result.ValuError):
def errfnRead(msg): def errfnRead(msg):
return [ _fatalError(msg), StmtReturn.FALSE ] return [ _fatalError(msg), StmtReturn.FALSE ]
def errfnUnionType(unionname):
return [ _unionTypeReadError(unionname), StmtReturn.FALSE ]
def _destroyMethod(): def _destroyMethod():
return ExprVar('ActorDestroy') return ExprVar('ActorDestroy')
@ -4632,8 +4640,8 @@ class _GenerateProtocolActorCode(ipdl.ast.Visitor):
uniontdef, uniontdef,
StmtDecl(Decl(Type.INT, typevar.name)), StmtDecl(Decl(Type.INT, typevar.name)),
self.checkedRead( self.checkedRead(
None, ExprAddrOf(typevar), msgvar, itervar, errfnRead, None, ExprAddrOf(typevar), msgvar, itervar, errfnUnionType,
'\'' + typevar.name + '\' (' + Type.INT.name + ') of union \'' + uniontype.name() + '\''), [ uniontype.name() ]),
Whitespace.NL, Whitespace.NL,
readswitch, readswitch,
]) ])