diff options
author | Michi Henning <michi@zeroc.com> | 2004-10-27 04:42:20 +0000 |
---|---|---|
committer | Michi Henning <michi@zeroc.com> | 2004-10-27 04:42:20 +0000 |
commit | 0ef42dc2c6d04aa10b69f5719a9440b1705277d5 (patch) | |
tree | 95a91be789e3af24b5a73b7d3b05faaf86a564ad /cpp/src/slice2vb/Gen.cpp | |
parent | - Fixed a bug in slice2cs: the generated code was incorrect for (diff) | |
download | ice-0ef42dc2c6d04aa10b69f5719a9440b1705277d5.tar.bz2 ice-0ef42dc2c6d04aa10b69f5719a9440b1705277d5.tar.xz ice-0ef42dc2c6d04aa10b69f5719a9440b1705277d5.zip |
Fixed bug in code generator: dictionaries with value types that were
sequences mapped to arrays resulted in incorrect code.
Diffstat (limited to 'cpp/src/slice2vb/Gen.cpp')
-rwxr-xr-x | cpp/src/slice2vb/Gen.cpp | 21 |
1 files changed, 19 insertions, 2 deletions
diff --git a/cpp/src/slice2vb/Gen.cpp b/cpp/src/slice2vb/Gen.cpp index 26bb46dcf6b..2464b7b20d3 100755 --- a/cpp/src/slice2vb/Gen.cpp +++ b/cpp/src/slice2vb/Gen.cpp @@ -2593,10 +2593,27 @@ Slice::Gen::TypesVisitor::visitDictionary(const DictionaryPtr& p) _out << nl << "End If"; _out.dec(); _out << nl << "Next"; - _out << nl << "Dim __vlhs() As " << vs << " = New " << vs << "(Count - 1) {}"; + SequencePtr seq = SequencePtr::dynamicCast(p->valueType()); + bool valueIsArray = seq && !seq->hasMetaData("cs:collection"); + if(valueIsArray) + { + _out << nl << "Dim __vlhs As " << vs << "() = New " << toArrayAlloc(vs + "()", "Count - 1") << " {}"; + } + else + { + _out << nl << "Dim __vlhs As " << vs << " = New " << toArrayAlloc(vs, "Count - 1") << " {}"; + } _out << nl << "Values.CopyTo(__vlhs, 0)"; _out << nl << "_System.Array.Sort(__vlhs)"; - _out << nl << "Dim __vrhs() As " << vs << " = New " << vs << "(CType(other, " << name << ").Count - 1) {}"; + string vrhsCount = "Ctype(other, " + name + ").Count - 1"; + if(valueIsArray) + { + _out << nl << "Dim __vrhs As " << vs << "() = New " << toArrayAlloc(vs + "()", vrhsCount) << " {}"; + } + else + { + _out << nl << "Dim __vrhs As " << vs << " = New " << toArrayAlloc(vs, vrhsCount) << " {}"; + } _out << nl << "CType(other, " << name << ").Values.CopyTo(__vrhs, 0)"; _out << nl << "_System.Array.Sort(__vrhs)"; _out << nl << "For i As Integer = 0 To Count - 1"; |