From b877576a5c32b6627854f54623268f31a28801ed Mon Sep 17 00:00:00 2001 From: Andi-Bogdan Postelnicu Date: Wed, 1 Feb 2017 17:54:49 +0200 Subject: [PATCH] Bug 1335000 - return type& for copy assignment operator. r=peterv MozReview-Commit-ID: 7kHt2l30ZP6 --HG-- extra : rebase_source : 3ef1cb0583238d9508153f4ddbbd402930f70706 --- dom/bindings/Codegen.py | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/dom/bindings/Codegen.py b/dom/bindings/Codegen.py index 886489132774..c12975673aa5 100644 --- a/dom/bindings/Codegen.py +++ b/dom/bindings/Codegen.py @@ -10234,10 +10234,13 @@ class CGUnionStruct(CGThing): visibility="public", explicit=True, body="*this = aOther;\n")) + op_body = CGList([]) + op_body.append(CGSwitch("aOther.mType", assignmentCases)) + op_body.append(CGGeneric("return *this;\n")) methods.append(ClassMethod( - "operator=", "void", + "operator=", "%s&" % selfName, [Argument("const %s&" % selfName, "aOther")], - body=CGSwitch("aOther.mType", assignmentCases).define())) + body=op_body.define())) disallowCopyConstruction = False else: disallowCopyConstruction = True @@ -10872,7 +10875,7 @@ class CGClass(CGThing): def declare(self, cgClass): name = cgClass.getNameString() return ("%s(const %s&) = delete;\n" - "void operator=(const %s&) = delete;\n" % (name, name, name)) + "%s& operator=(const %s&) = delete;\n" % (name, name, name, name)) disallowedCopyConstructors = [DisallowedCopyConstructor()] else: @@ -12993,8 +12996,9 @@ class CGDictionary(CGThing): memberAssign = CGGeneric( "%s = aOther.%s;\n" % (memberName, memberName)) body.append(memberAssign) + body.append(CGGeneric("return *this;\n")) return ClassMethod( - "operator=", "void", + "operator=", "%s&" % self.makeClassName(self.dictionary), [Argument("const %s&" % self.makeClassName(self.dictionary), "aOther")], body=body.define())