summaryrefslogtreecommitdiff
path: root/cpp/src/Slice/JavaUtil.cpp
diff options
context:
space:
mode:
authorMark Spruiell <mes@zeroc.com>2005-02-08 20:12:12 +0000
committerMark Spruiell <mes@zeroc.com>2005-02-08 20:12:12 +0000
commit7f367e4ff47715aabd61d697f78d7206aab1f9d8 (patch)
tree4a74ad5c03148c72a41bdb69a3074cb7889eb098 /cpp/src/Slice/JavaUtil.cpp
parentRemoved -a option from usage (diff)
downloadice-7f367e4ff47715aabd61d697f78d7206aab1f9d8.tar.bz2
ice-7f367e4ff47715aabd61d697f78d7206aab1f9d8.tar.xz
ice-7f367e4ff47715aabd61d697f78d7206aab1f9d8.zip
changing sequence unmarshaling for fixed-length types
Diffstat (limited to 'cpp/src/Slice/JavaUtil.cpp')
-rw-r--r--cpp/src/Slice/JavaUtil.cpp73
1 files changed, 49 insertions, 24 deletions
diff --git a/cpp/src/Slice/JavaUtil.cpp b/cpp/src/Slice/JavaUtil.cpp
index 6ce91cf248f..5cd86656d14 100644
--- a/cpp/src/Slice/JavaUtil.cpp
+++ b/cpp/src/Slice/JavaUtil.cpp
@@ -869,12 +869,14 @@ Slice::JavaGenerator::writeSequenceMarshalUnmarshalCode(Output& out,
}
string origContentS = typeToString(origContent, TypeModeIn, package);
+ TypePtr type = seq->type();
+
if(!listType.empty())
{
//
// Marshal/unmarshal a custom sequence type
//
- BuiltinPtr b = BuiltinPtr::dynamicCast(seq->type());
+ BuiltinPtr b = BuiltinPtr::dynamicCast(type);
if(b && b->kind() != Builtin::KindObject && b->kind() != Builtin::KindObjectProxy)
{
if(marshal)
@@ -1086,7 +1088,7 @@ Slice::JavaGenerator::writeSequenceMarshalUnmarshalCode(Output& out,
out << nl << "while(" << it << ".hasNext())";
out << sb;
out << nl << origContentS << " __elem = (" << origContentS << ")" << it << ".next();";
- writeMarshalUnmarshalCode(out, package, seq->type(), "__elem", true, iter, false);
+ writeMarshalUnmarshalCode(out, package, type, "__elem", true, iter, false);
out << eb; // while
out << eb; // else
}
@@ -1101,7 +1103,14 @@ Slice::JavaGenerator::writeSequenceMarshalUnmarshalCode(Output& out,
}
out << nl << v << " = new " << listType << "();";
out << nl << "final int __len" << iter << " = " << stream << ".readSize();";
- out << nl << stream << ".startSeq(__len" << iter << ", " << seq->type()->minWireSize() << ");";
+ if(type->isVariableLength())
+ {
+ out << nl << stream << ".startSeq(__len" << iter << ", " << type->minWireSize() << ");";
+ }
+ else
+ {
+ out << nl << stream << ".checkFixedSeq(__len" << iter << ", " << type->minWireSize() << ");";
+ }
if(isObject)
{
if(builtin)
@@ -1134,13 +1143,13 @@ Slice::JavaGenerator::writeSequenceMarshalUnmarshalCode(Output& out,
ostringstream patchParams;
patchParams << "new IceInternal.ListPatcher(" << v << ", " << origContentS << ".class, __type"
<< iter << ", __i" << iter << ')';
- writeMarshalUnmarshalCode(out, package, seq->type(), "__elem", false, iter, false,
- StringList(), patchParams.str());
+ writeMarshalUnmarshalCode(out, package, type, "__elem", false, iter, false, StringList(),
+ patchParams.str());
}
else
{
out << nl << origContentS << " __elem;";
- writeMarshalUnmarshalCode(out, package, seq->type(), "__elem", false, iter, false);
+ writeMarshalUnmarshalCode(out, package, type, "__elem", false, iter, false);
}
if(!isObject)
{
@@ -1156,24 +1165,30 @@ Slice::JavaGenerator::writeSequenceMarshalUnmarshalCode(Output& out,
// (For fixed-length sequences, we don't need to do this because the prediction of how many
// bytes will be taken up by the sequence is accurate.)
//
- if(!SequencePtr::dynamicCast(seq->type()))
+ if(type->isVariableLength())
+ {
+ if(!SequencePtr::dynamicCast(seq->type()))
+ {
+ //
+ // No need to check for directly nested sequences because, at the at start of each
+ // sequence, we check anyway.
+ //
+ out << nl << stream << ".checkSeq();";
+ }
+ out << nl << stream << ".endElement();";
+ }
+ out << eb;
+ if(type->isVariableLength())
{
- //
- // No need to check for directly nested sequences because, at the at start of each
- // sequence, we check anyway.
- //
- out << nl << stream << ".checkSeq();";
+ out << nl << stream << ".endSeq(__len" << iter << ");";
}
- out << nl << stream << ".endElement();";
- out << eb;
- out << nl << stream << ".endSeq(__len" << iter << ");";
iter++;
}
}
}
else
{
- BuiltinPtr b = BuiltinPtr::dynamicCast(seq->type());
+ BuiltinPtr b = BuiltinPtr::dynamicCast(type);
if(b && b->kind() != Builtin::KindObject && b->kind() != Builtin::KindObjectProxy)
{
switch(b->kind())
@@ -1300,7 +1315,7 @@ Slice::JavaGenerator::writeSequenceMarshalUnmarshalCode(Output& out,
ostringstream o;
o << v << "[__i" << iter << "]";
iter++;
- writeMarshalUnmarshalCode(out, package, seq->type(), o.str(), true, iter, false);
+ writeMarshalUnmarshalCode(out, package, type, o.str(), true, iter, false);
out << eb;
out << eb;
}
@@ -1313,7 +1328,14 @@ Slice::JavaGenerator::writeSequenceMarshalUnmarshalCode(Output& out,
isObject = true;
}
out << nl << "final int __len" << iter << " = " << stream << ".readSize();";
- out << nl << stream << ".startSeq(__len" << iter << ", " << seq->type()->minWireSize() << ");";
+ if(type->isVariableLength())
+ {
+ out << nl << stream << ".startSeq(__len" << iter << ", " << type->minWireSize() << ");";
+ }
+ else
+ {
+ out << nl << stream << ".checkFixedSeq(__len" << iter << ", " << type->minWireSize() << ");";
+ }
if(isObject)
{
if(b)
@@ -1351,12 +1373,12 @@ Slice::JavaGenerator::writeSequenceMarshalUnmarshalCode(Output& out,
{
patchParams << "new IceInternal.SequencePatcher(" << v << ", " << origContentS
<< ".class, __type" << iter << ", __i" << iter << ')';
- writeMarshalUnmarshalCode(out, package, seq->type(), o.str(), false, iter, false,
- StringList(), patchParams.str());
+ writeMarshalUnmarshalCode(out, package, type, o.str(), false, iter, false, StringList(),
+ patchParams.str());
}
else
{
- writeMarshalUnmarshalCode(out, package, seq->type(), o.str(), false, iter, false);
+ writeMarshalUnmarshalCode(out, package, type, o.str(), false, iter, false);
}
//
@@ -1368,9 +1390,9 @@ Slice::JavaGenerator::writeSequenceMarshalUnmarshalCode(Output& out,
// (For fixed-length sequences, we don't need to do this because the prediction of how many
// bytes will be taken up by the sequence is accurate.)
//
- if(seq->type()->isVariableLength())
+ if(type->isVariableLength())
{
- if(!SequencePtr::dynamicCast(seq->type()))
+ if(!SequencePtr::dynamicCast(type))
{
//
// No need to check for directly nested sequences because, at the at start of each
@@ -1381,7 +1403,10 @@ Slice::JavaGenerator::writeSequenceMarshalUnmarshalCode(Output& out,
out << nl << stream << ".endElement();";
}
out << eb;
- out << nl << stream << ".endSeq(__len" << iter << ");";
+ if(type->isVariableLength())
+ {
+ out << nl << stream << ".endSeq(__len" << iter << ");";
+ }
iter++;
}
}