diff options
author | Michi Henning <michi@zeroc.com> | 2006-01-18 01:23:57 +0000 |
---|---|---|
committer | Michi Henning <michi@zeroc.com> | 2006-01-18 01:23:57 +0000 |
commit | 673415d15e6f990d17de40d413b75ce6fc06a50d (patch) | |
tree | 073c6152b62a7de785ccf69a72c4486267113722 /cpp | |
parent | Bug 764 (diff) | |
download | ice-673415d15e6f990d17de40d413b75ce6fc06a50d.tar.bz2 ice-673415d15e6f990d17de40d413b75ce6fc06a50d.tar.xz ice-673415d15e6f990d17de40d413b75ce6fc06a50d.zip |
Bug 764.
Diffstat (limited to 'cpp')
-rwxr-xr-x | cpp/src/slice2cs/Gen.cpp | 41 | ||||
-rwxr-xr-x | cpp/src/slice2vb/Gen.cpp | 47 | ||||
-rw-r--r-- | cpp/test/Ice/operations/Twoways.cpp | 25 | ||||
-rw-r--r-- | cpp/test/Ice/operations/TwowaysAMI.cpp | 53 |
4 files changed, 157 insertions, 9 deletions
diff --git a/cpp/src/slice2cs/Gen.cpp b/cpp/src/slice2cs/Gen.cpp index b52f544a4ad..478ab219b86 100755 --- a/cpp/src/slice2cs/Gen.cpp +++ b/cpp/src/slice2cs/Gen.cpp @@ -1765,7 +1765,7 @@ Slice::Gen::TypesVisitor::visitSequence(const SequencePtr& p) _out << sp << nl << "public static " << name << " Repeat(" << s << " value, int count)"; _out << sb; - _out << nl << name << " r = new " << name << "();"; + _out << nl << name << " r = new " << name << "(count);"; _out << nl << "for(int i = 0; i < count; ++i)"; _out << sb; _out << nl << "r.Add(value);"; @@ -1879,7 +1879,9 @@ Slice::Gen::TypesVisitor::visitSequence(const SequencePtr& p) _out << sp << nl << "public object Clone()"; _out << sb; - _out << nl << "return MemberwiseClone();"; + _out << nl << name << " s = new " << name << "(Count);"; + _out << nl << "s.InnerList.AddRange(InnerList);"; + _out << nl << "return s;"; _out << eb; _out << sp << nl << "#endregion"; // ICloneable members @@ -1923,15 +1925,24 @@ Slice::Gen::TypesVisitor::visitSequence(const SequencePtr& p) _out << sb; if(!isValue) { - _out << nl << "if(InnerList[i__] == null && ((" << name << ")other)[i__] != null)"; + _out << nl << "if(InnerList[i__] == null)"; + _out << sb; + _out << nl << "if(((" << name << ")other)[i__] != null)"; _out << sb; _out << nl << "return false;"; _out << eb; + _out << eb; + _out << nl << "else"; + _out << sb; } _out << nl << "if(!((" << s << ")(InnerList[i__])).Equals(((" << name << ")other)[i__]))"; _out << sb; _out << nl << "return false;"; _out << eb; + if(!isValue) + { + _out << eb; + } _out << eb; _out << nl << "return true;"; _out << eb; @@ -2058,10 +2069,27 @@ Slice::Gen::TypesVisitor::visitExceptionEnd(const ExceptionPtr& p) for(q = dataMembers.begin(); q != dataMembers.end(); ++q) { string memberName = fixId((*q)->name(), DotNet::ApplicationException); + bool isValue = isValueType((*q)->type()); + if(!isValue) + { + _out << nl << "if(" << memberName << " == null)"; + _out << sb; + _out << nl << "if(((" << name << ")other__)." << memberName << " != null)"; + _out << sb; + _out << nl << "return false;"; + _out << eb; + _out << eb; + _out << nl << "else"; + _out << sb; + } _out << nl << "if(!" << memberName << ".Equals(((" << name << ")other__)." << memberName << "))"; _out << sb; _out << nl << "return false;"; _out << eb; + if(!isValue) + { + _out << eb; + } } _out << nl << "return true;"; _out << eb; @@ -2741,7 +2769,12 @@ Slice::Gen::TypesVisitor::visitDictionary(const DictionaryPtr& p) _out << sp << nl << "public object Clone()"; _out << sb; - _out << nl << "return MemberwiseClone();"; + _out << nl << name << " d = new " << name << "();"; + _out << nl << "foreach(_System.Collections.DictionaryEntry e in InnerHashtable)"; + _out << sb; + _out << nl << "d.InnerHashtable.Add(e.Key, e.Value);"; + _out << eb; + _out << nl << "return d;"; _out << eb; _out << sp << nl << "#endregion"; // ICloneable members diff --git a/cpp/src/slice2vb/Gen.cpp b/cpp/src/slice2vb/Gen.cpp index 1eb4a0ec495..bc5e5f1dba1 100755 --- a/cpp/src/slice2vb/Gen.cpp +++ b/cpp/src/slice2vb/Gen.cpp @@ -1845,8 +1845,8 @@ Slice::Gen::TypesVisitor::visitSequence(const SequencePtr& p) _out << sp << nl << "Public Shared Function Repeat(ByVal value As " << s << ", ByVal count As Integer) As " << name; _out.inc(); - _out << nl << "Dim r As " << name << " = New " << name << "()"; - _out << nl << "For i As Integer = 0 To Count - 1"; + _out << nl << "Dim r As " << name << " = New " << name << "(count)"; + _out << nl << "For i As Integer = 0 To count - 1"; _out.inc(); _out << nl << "r.Add(value)"; _out.dec(); @@ -1993,7 +1993,9 @@ Slice::Gen::TypesVisitor::visitSequence(const SequencePtr& p) _out << sp << nl << "Function Clone() As Object Implements _System.ICloneable.Clone"; _out.inc(); - _out << nl << "Return MemberwiseClone()"; + _out << nl << "Dim s As " << name << " = New " << name; + _out << nl << "s.InnerList.AddRange(InnerList)"; + _out << nl << "Return s"; _out.dec(); _out << nl << "End Function"; @@ -2046,11 +2048,16 @@ Slice::Gen::TypesVisitor::visitSequence(const SequencePtr& p) _out.inc(); if(!isValue) { - _out << nl << "If InnerList(i__) Is Nothing And Not CType(other, " << name << ")(i__) Is Nothing Then"; + _out << nl << "If InnerList(i__) Is Nothing Then"; + _out.inc(); + _out << nl << "If Not CType(other, " << name << ")(i__) Is Nothing Then"; _out.inc(); _out << nl << "Return False"; _out.dec(); _out << nl << "End If"; + _out.dec(); + _out << nl << "Else"; + _out.inc(); } _out << nl << "If Not InnerList(i__).Equals(CType(other, " << name << ")(i__)) Then"; _out.inc(); @@ -2058,6 +2065,11 @@ Slice::Gen::TypesVisitor::visitSequence(const SequencePtr& p) _out.dec(); _out << nl << "End If"; _out.dec(); + if(!isValue) + { + _out.dec(); + _out << nl << "End If"; + } _out << nl << "Next"; _out << nl << "Return True"; _out.dec(); @@ -2195,7 +2207,21 @@ Slice::Gen::TypesVisitor::visitExceptionEnd(const ExceptionPtr& p) for(q = dataMembers.begin(); q != dataMembers.end(); ++q) { string memberName = fixId((*q)->name(), DotNet::ApplicationException); + bool isValue = isValueType((*q)->type()); + if(!isValue) + { + _out << nl << "If " << memberName << " Is Nothing Then"; + _out.inc(); + _out << nl << "If Not (CType(other__, " + name + "))." << memberName << " Is Nothing"; + _out.inc(); + _out << nl << "Return False"; + _out.dec(); + _out << nl << "End If"; + _out.dec(); + _out << nl << "Else"; + _out.inc(); + } _out << nl << "If Not "; invokeObjectMethod((*q)->type(), memberName, "Equals", "CType(other__, " + name + ")." + memberName); _out << " Then"; @@ -2203,6 +2229,11 @@ Slice::Gen::TypesVisitor::visitExceptionEnd(const ExceptionPtr& p) _out << nl << "Return False"; _out.dec(); _out << nl << "End If"; + if(!isValue) + { + _out.dec(); + _out << nl << "End If"; + } } _out << nl << "Return True"; _out.dec(); @@ -2956,7 +2987,13 @@ Slice::Gen::TypesVisitor::visitDictionary(const DictionaryPtr& p) _out << sp << nl << "Function Clone() As Object Implements _System.ICloneable.Clone"; _out.inc(); - _out << nl << "Return MemberwiseClone()"; + _out << nl << "Dim d As " << name << " = New " << name; + _out << nl << "For Each e As _System.Collections.DictionaryEntry in d"; + _out.inc(); + _out << nl << "d.InnerHashtable.Add(e.Key, e.Value)"; + _out.dec(); + _out << nl << "Next"; + _out << nl << "Return d"; _out.dec(); _out << nl << "End Function"; diff --git a/cpp/test/Ice/operations/Twoways.cpp b/cpp/test/Ice/operations/Twoways.cpp index 86c7ab4c959..64e37f28d5e 100644 --- a/cpp/test/Ice/operations/Twoways.cpp +++ b/cpp/test/Ice/operations/Twoways.cpp @@ -658,6 +658,31 @@ twoways(const Ice::CommunicatorPtr& communicator, const Test::MyClassPrx& p) communicator->setDefaultContext(Ice::Context()); test(!p2->opContext().empty()); + + communicator->setDefaultContext(dflt); + Test::MyClassPrx c = Test::MyClassPrx::checkedCast( + communicator->stringToProxy("test:default -p 12345 -t 10000")); + test(c->opContext() == dflt); + + dflt["a"] = "c"; + Test::MyClassPrx c2 = Test::MyClassPrx::uncheckedCast(c->ice_newContext(dflt)); + test(c2->opContext()["a"] == "c"); + + dflt.clear(); + Test::MyClassPrx c3 = Test::MyClassPrx::uncheckedCast(c2->ice_newContext(dflt)); + Ice::Context tmp = c3->opContext(); + test(tmp.find("a") == tmp.end()); + + Test::MyClassPrx c4 = Test::MyClassPrx::uncheckedCast(c2->ice_defaultContext()); + test(c4->opContext()["a"] == "b"); + + dflt["a"] = "d"; + communicator->setDefaultContext(dflt); + + Test::MyClassPrx c5 = Test::MyClassPrx::uncheckedCast(c->ice_defaultContext()); + test(c5->opContext()["a"] == "d"); + + communicator->setDefaultContext(Ice::Context()); } } } diff --git a/cpp/test/Ice/operations/TwowaysAMI.cpp b/cpp/test/Ice/operations/TwowaysAMI.cpp index de7599c7223..59f58e47aad 100644 --- a/cpp/test/Ice/operations/TwowaysAMI.cpp +++ b/cpp/test/Ice/operations/TwowaysAMI.cpp @@ -1206,6 +1206,59 @@ twowaysAMI(const Ice::CommunicatorPtr& communicator, const Test::MyClassPrx& p) p2->opContext_async(cb); test(cb->check()); } + + communicator->setDefaultContext(dflt); + Test::MyClassPrx c = Test::MyClassPrx::checkedCast( + communicator->stringToProxy("test:default -p 12345 -t 10000")); + { + Ice::Context tmp; + tmp["a"] = "b"; + AMI_MyClass_opContextEqualIPtr cb = new AMI_MyClass_opContextEqualI(tmp); + c->opContext_async(cb); + test(cb->check()); + } + + dflt["a"] = "c"; + Test::MyClassPrx c2 = Test::MyClassPrx::uncheckedCast(c->ice_newContext(dflt)); + { + Ice::Context tmp; + tmp["a"] = "c"; + AMI_MyClass_opContextEqualIPtr cb = new AMI_MyClass_opContextEqualI(tmp); + c2->opContext_async(cb); + test(cb->check()); + } + + dflt.clear(); + Test::MyClassPrx c3 = Test::MyClassPrx::uncheckedCast(c2->ice_newContext(dflt)); + { + Ice::Context tmp; + AMI_MyClass_opContextEqualIPtr cb = new AMI_MyClass_opContextEqualI(tmp); + c3->opContext_async(cb); + test(cb->check()); + } + + Test::MyClassPrx c4 = Test::MyClassPrx::uncheckedCast(c2->ice_defaultContext()); + { + Ice::Context tmp; + tmp["a"] = "b"; + AMI_MyClass_opContextEqualIPtr cb = new AMI_MyClass_opContextEqualI(tmp); + c4->opContext_async(cb); + test(cb->check()); + } + + dflt["a"] = "d"; + communicator->setDefaultContext(dflt); + + Test::MyClassPrx c5 = Test::MyClassPrx::uncheckedCast(c->ice_defaultContext()); + { + Ice::Context tmp; + tmp["a"] = "d"; + AMI_MyClass_opContextEqualIPtr cb = new AMI_MyClass_opContextEqualI(tmp); + c5->opContext_async(cb); + test(cb->check()); + } + + communicator->setDefaultContext(Ice::Context()); } } |