Bug 1346345 - Implement != operator for IPDL structs. r=kanru
MozReview-Commit-ID: H1CDbuXZ5U0
--- a/ipc/ipdl/ipdl/lower.py
+++ b/ipc/ipdl/ipdl/lower.py
@@ -1836,16 +1836,26 @@ def _generateCxxStruct(sd):
ifneq = StmtIf(ExprNot(
ExprBinary(ExprCall(f.getMethod()), '==',
ExprCall(f.getMethod(ovar)))))
ifneq.addifstmt(StmtReturn.FALSE)
opeqeq.addstmt(ifneq)
opeqeq.addstmt(StmtReturn.TRUE)
struct.addstmts([ opeqeq, Whitespace.NL ])
+ # bool operator!=(const Struct& _o)
+ opneq = MethodDefn(MethodDecl(
+ 'operator!=',
+ params=[ Decl(constreftype, ovar.name) ],
+ ret=Type.BOOL,
+ const=1))
+ opneq.addstmt(StmtReturn(ExprNot(ExprCall(ExprVar('operator=='),
+ args=[ ovar ]))))
+ struct.addstmts([ opneq, Whitespace.NL ])
+
# field1& f1()
# const field1& f1() const
for f in sd.fields:
get = MethodDefn(MethodDecl(f.getMethod().name,
params=[ ],
ret=f.refType(),
force_inline=1))
get.addstmt(StmtReturn(f.refExpr()))