summaryrefslogtreecommitdiff
path: root/cpp/src/slice2cs/Gen.cpp
diff options
context:
space:
mode:
authorMichi Henning <michi@zeroc.com>2004-10-27 03:23:42 +0000
committerMichi Henning <michi@zeroc.com>2004-10-27 03:23:42 +0000
commit0770a34e5ae37938a6dce437a112784867d747b7 (patch)
treeb109a0851f148d6beaa5e8411e80e17f15045beb /cpp/src/slice2cs/Gen.cpp
parentfixes for glacier2 change (diff)
downloadice-0770a34e5ae37938a6dce437a112784867d747b7.tar.bz2
ice-0770a34e5ae37938a6dce437a112784867d747b7.tar.xz
ice-0770a34e5ae37938a6dce437a112784867d747b7.zip
- Fixed a bug in slice2cs: the generated code was incorrect for
dictionaries with sequence value types, if that sequence value type was mapped to an array.
Diffstat (limited to 'cpp/src/slice2cs/Gen.cpp')
-rwxr-xr-xcpp/src/slice2cs/Gen.cpp21
1 files changed, 19 insertions, 2 deletions
diff --git a/cpp/src/slice2cs/Gen.cpp b/cpp/src/slice2cs/Gen.cpp
index 2d66c7d9103..b2554371d41 100755
--- a/cpp/src/slice2cs/Gen.cpp
+++ b/cpp/src/slice2cs/Gen.cpp
@@ -2292,10 +2292,27 @@ Slice::Gen::TypesVisitor::visitDictionary(const DictionaryPtr& p)
_out << nl << "return false;";
_out << eb;
_out << eb;
- _out << nl << vs << "[] __vlhs = new " << vs << "[Count];";
+ SequencePtr seq = SequencePtr::dynamicCast(p->valueType());
+ bool valueIsArray = seq && !seq->hasMetaData("cs:collection");
+ if(valueIsArray)
+ {
+ _out << nl << vs << "[] __vlhs = new " << toArrayAlloc(vs + "[]", "Count") << ';';
+ }
+ else
+ {
+ _out << nl << vs << "[] __vlhs = new " << vs << "[Count];";
+ }
_out << nl << "Values.CopyTo(__vlhs, 0);";
_out << nl << "_System.Array.Sort(__vlhs);";
- _out << nl << vs << "[] __vrhs = new " << vs << "[((" << name << ")other).Count];";
+ string vrhsCount = "((" + name + ")other).Count";
+ if(valueIsArray)
+ {
+ _out << nl << vs << "[] __vrhs = new " << toArrayAlloc(vs + "[]", vrhsCount) << ';';
+ }
+ else
+ {
+ _out << nl << vs << "[] __vrhs = new " << vs << '[' << vrhsCount << "];";
+ }
_out << nl << "((" << name << ")other).Values.CopyTo(__vrhs, 0);";
_out << nl << "_System.Array.Sort(__vrhs);";
_out << nl << "for(int i = 0; i < Count; ++i)";