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/src | |
parent | Bug 764 (diff) | |
download | ice-673415d15e6f990d17de40d413b75ce6fc06a50d.tar.bz2 ice-673415d15e6f990d17de40d413b75ce6fc06a50d.tar.xz ice-673415d15e6f990d17de40d413b75ce6fc06a50d.zip |
Bug 764.
Diffstat (limited to 'cpp/src')
-rwxr-xr-x | cpp/src/slice2cs/Gen.cpp | 41 | ||||
-rwxr-xr-x | cpp/src/slice2vb/Gen.cpp | 47 |
2 files changed, 79 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"; |