summaryrefslogtreecommitdiff
path: root/cpp/src/Slice/CsUtil.cpp
diff options
context:
space:
mode:
authorMichi Henning <michi@zeroc.com>2004-09-17 05:23:37 +0000
committerMichi Henning <michi@zeroc.com>2004-09-17 05:23:37 +0000
commitb7d910a615587cf296fac580b138d9a5b7d1c44b (patch)
tree4be272d17b0a85a9b157283d44f3fe5bf49f2e8a /cpp/src/Slice/CsUtil.cpp
parenttransfer data members of more local exceptions (diff)
downloadice-b7d910a615587cf296fac580b138d9a5b7d1c44b.tar.bz2
ice-b7d910a615587cf296fac580b138d9a5b7d1c44b.tar.xz
ice-b7d910a615587cf296fac580b138d9a5b7d1c44b.zip
Fixed bugs in sequence code generation for slice2cs and slice2vb.
Diffstat (limited to 'cpp/src/Slice/CsUtil.cpp')
-rwxr-xr-xcpp/src/Slice/CsUtil.cpp30
1 files changed, 26 insertions, 4 deletions
diff --git a/cpp/src/Slice/CsUtil.cpp b/cpp/src/Slice/CsUtil.cpp
index 075274b38fe..c5c94d78366 100755
--- a/cpp/src/Slice/CsUtil.cpp
+++ b/cpp/src/Slice/CsUtil.cpp
@@ -181,6 +181,23 @@ Slice::CsGenerator::typeToString(const TypePtr& type)
return "???";
}
+static string
+toArrayAlloc(const string& decl, const string& sz)
+{
+ int count = 0;
+ string::size_type pos = decl.size();
+ while(pos > 1 && decl.substr(pos - 2, 2) == "[]")
+ {
+ ++count;
+ pos -= 2;
+ }
+ assert(count > 0);
+
+ ostringstream o;
+ o << decl.substr(0, pos) << '[' << sz << ']' << decl.substr(pos + 2);
+ return o.str();
+}
+
bool
Slice::CsGenerator::isValueType(const TypePtr& type)
{
@@ -550,6 +567,7 @@ Slice::CsGenerator::writeSequenceMarshalUnmarshalCode(Output& out,
out << nl << stream << ".checkSeq();";
out << nl << stream << ".endElement();";
out << eb;
+ out << nl << stream << ".endSeq(__len);";
}
break;
}
@@ -602,7 +620,7 @@ Slice::CsGenerator::writeSequenceMarshalUnmarshalCode(Output& out,
out << nl << param << " = new ";
if(isArray)
{
- out << typeS << "[sz]";
+ out << toArrayAlloc(typeS + "[]", "sz");
}
else
{
@@ -617,6 +635,7 @@ Slice::CsGenerator::writeSequenceMarshalUnmarshalCode(Output& out,
out << nl << stream << ".checkSeq();";
out << nl << stream << ".endElement();";
out << eb;
+ out << nl << stream << ".endSeq(sz);";
out << eb;
}
return;
@@ -641,7 +660,7 @@ Slice::CsGenerator::writeSequenceMarshalUnmarshalCode(Output& out,
out << nl << param << " = new ";
if(isArray)
{
- out << typeS << "[sz]";
+ out << toArrayAlloc(typeS + "[]", "sz");
}
else
{
@@ -657,6 +676,7 @@ Slice::CsGenerator::writeSequenceMarshalUnmarshalCode(Output& out,
out << nl << stream << ".endElement();";
}
out << eb;
+ out << nl << stream << ".endSeq(sz);";
out << eb;
}
return;
@@ -682,7 +702,7 @@ Slice::CsGenerator::writeSequenceMarshalUnmarshalCode(Output& out,
out << nl << param << " = new ";
if(isArray)
{
- out << typeS << "[sz]";
+ out << toArrayAlloc(typeS + "[]", "sz");
}
else
{
@@ -700,6 +720,7 @@ Slice::CsGenerator::writeSequenceMarshalUnmarshalCode(Output& out,
out << nl << param << ".Add((" << typeS << ')' << stream << ".readByte());";
}
out << eb;
+ out << nl << stream << ".endSeq(sz);";
out << eb;
}
return;
@@ -723,7 +744,7 @@ Slice::CsGenerator::writeSequenceMarshalUnmarshalCode(Output& out,
out << nl << param << " = new ";
if(isArray)
{
- out << typeS << "[sz]";
+ out << toArrayAlloc(typeS + "[]", "sz");
}
else
{
@@ -749,6 +770,7 @@ Slice::CsGenerator::writeSequenceMarshalUnmarshalCode(Output& out,
out << nl << stream << ".endElement();";
}
out << eb;
+ out << nl << stream << ".endSeq(sz);";
out << eb;
}