Bug 1346345 - Implement != operator for IPDL structs. r=kanru draft
authorAndrew McCreight <continuation@gmail.com>
Fri, 10 Mar 2017 11:42:07 -0800
changeset 496864 79755fe56f71f43008f2e03c5e140e13a6085634
parent 496863 e7768d5b05baa7d8febdaee7e126cf75a4461e0a
child 548723 e9b537fe533476c0d7565a8e7e45f08751811f2e
push id48716
push userbmo:continuation@gmail.com
push dateFri, 10 Mar 2017 19:55:09 +0000
reviewerskanru
bugs1346345
milestone55.0a1
Bug 1346345 - Implement != operator for IPDL structs. r=kanru MozReview-Commit-ID: H1CDbuXZ5U0
ipc/ipdl/ipdl/lower.py
--- 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()))