diff options
author | Michi Henning <michi@zeroc.com> | 2004-05-10 02:15:57 +0000 |
---|---|---|
committer | Michi Henning <michi@zeroc.com> | 2004-05-10 02:15:57 +0000 |
commit | a6a7f49b10372b9e4adf2ac2431b361c5638d156 (patch) | |
tree | 1b4e44d9ba7a0209a9faa35b35ce29bb8d4d0e4e /cpp/src/Slice/CsUtil.cpp | |
parent | Fixed VC6 build (diff) | |
download | ice-a6a7f49b10372b9e4adf2ac2431b361c5638d156.tar.bz2 ice-a6a7f49b10372b9e4adf2ac2431b361c5638d156.tar.xz ice-a6a7f49b10372b9e4adf2ac2431b361c5638d156.zip |
Merged changes from michi_pre_e3 branch
Diffstat (limited to 'cpp/src/Slice/CsUtil.cpp')
-rwxr-xr-x | cpp/src/Slice/CsUtil.cpp | 88 |
1 files changed, 62 insertions, 26 deletions
diff --git a/cpp/src/Slice/CsUtil.cpp b/cpp/src/Slice/CsUtil.cpp index 58f33144159..88a9fb2fd9c 100755 --- a/cpp/src/Slice/CsUtil.cpp +++ b/cpp/src/Slice/CsUtil.cpp @@ -444,7 +444,7 @@ Slice::CsGenerator::writeMarshalUnmarshalCode(Output &out, { string func; string cast; - int sz = en->getEnumerators().size(); + size_t sz = en->getEnumerators().size(); if(sz <= 0x7f) { func = marshal ? "writeByte" : "readByte"; @@ -540,25 +540,28 @@ Slice::CsGenerator::writeSequenceMarshalUnmarshalCode(Output& out, } else { - if(builtin->kind() == Builtin::KindObject) - { - out << nl << param << " = new Ice.ObjectSeq();"; - out << nl << "int __len = " << stream << ".readSize();"; - out << nl << "for(int __i = 0; __i < __len; ++__i)"; - out << sb; - out << nl << stream << ".readObject(new IceInternal.SequencePatcher(" - << param << ", typeof(Ice.Object), __i));"; - out << eb; - } - else - { - out << nl << param << " = new Ice.ObjectProxySeq();"; - out << nl << "int __len = " << stream << ".readSize();"; - out << nl << "for(int __i = 0; __i < __len; ++__i)"; - out << sb; - out << nl << param << ".Add(" << stream << ".readProxy());"; - out << eb; - } + if(builtin->kind() == Builtin::KindObject) + { + out << nl << param << " = new Ice.ObjectSeq();"; + out << nl << "int __len = " << stream << ".readSize();"; + out << nl << stream << ".startSeq(__len, " << static_cast<unsigned>(builtin->minWireSize()) << ");"; + out << nl << "for(int __i = 0; __i < __len; ++__i)"; + out << sb; + out << nl << stream << ".readObject(new IceInternal.SequencePatcher(" + << param << ", typeof(Ice.Object), __i));"; + } + else + { + out << nl << param << " = new Ice.ObjectProxySeq();"; + out << nl << "int __len = " << stream << ".readSize();"; + out << nl << stream << ".startSeq(__len, " << static_cast<unsigned>(builtin->minWireSize()) << ");"; + out << nl << "for(int __i = 0; __i < __len; ++__i)"; + out << sb; + out << nl << param << ".Add(" << stream << ".readProxy());"; + } + out << nl << stream << ".checkSeq();"; + out << nl << stream << ".endElement();"; + out << eb; } break; } @@ -609,12 +612,15 @@ Slice::CsGenerator::writeSequenceMarshalUnmarshalCode(Output& out, else { out << nl << "int sz = " << stream << ".readSize();"; + out << nl << stream << ".startSeq(sz, " << static_cast<unsigned>(type->minWireSize()) << ");"; out << nl << param << " = new " << fixId(seq->scoped()) << "(sz);"; out << nl << "for(int i = 0; i < sz; ++i)"; out << sb; out << nl << "IceInternal.SequencePatcher sp = new IceInternal.SequencePatcher(" << param << ", " << "typeof(" << typeToString(type) << "), i);"; out << nl << stream << ".readObject(sp);"; + out << nl << stream << ".checkSeq();"; + out << nl << stream << ".endElement();"; out << eb; } return; @@ -634,11 +640,17 @@ Slice::CsGenerator::writeSequenceMarshalUnmarshalCode(Output& out, else { out << nl << "int sz = " << stream << ".readSize();"; + out << nl << stream << ".startSeq(sz, " << static_cast<unsigned>(type->minWireSize()) << ");"; out << nl << "for(int __i = 0; __i < " << param << ".Count; ++__i)"; out << sb; string typeS = typeToString(st); out << nl << param << ".Add(new " << typeS << "());"; out << nl << param << "[__i].__read(" << stream << ");"; + if(st->isVariableLength()) + { + out << nl << stream << ".checkSeq();"; + out << nl << stream << ".endElement();"; + } out << eb; } return; @@ -660,6 +672,7 @@ Slice::CsGenerator::writeSequenceMarshalUnmarshalCode(Output& out, { out << nl << param << startAssign << "new " << fixId(seq->scoped()) << "()" << endAssign << ";"; out << nl << "int sz = " << stream << ".readSize();"; + out << nl << stream << ".startSeq(sz, " << static_cast<unsigned>(type->minWireSize()) << ");"; out << nl << "for(int __i = 0; __i < sz; ++__i)"; out << sb; writeMarshalUnmarshalCode(out, type, param, marshal, true); @@ -669,11 +682,12 @@ Slice::CsGenerator::writeSequenceMarshalUnmarshalCode(Output& out, } string typeS = typeToString(type); + bool seqIsArray = seq->hasMetaData("cs:array"); if(marshal) { string func = ProxyPtr::dynamicCast(type) ? "__write" : "write"; - out << nl << stream << ".writeSize(" << param << ".Count);"; - out << nl << "for(int __i = 0; __i < " << param << ".Count; ++__i)"; + out << nl << stream << ".writeSize(" << param << (seqIsArray ? ".Length);" : ".Count);"); + out << nl << "for(int __i = 0; __i < " << param << (seqIsArray ? ".Length" : ".Count") << "; ++__i)"; out << sb; out << nl << typeS << "Helper." << func << "(" << stream << ", " << param << "[__i]);"; out << eb; @@ -681,12 +695,36 @@ Slice::CsGenerator::writeSequenceMarshalUnmarshalCode(Output& out, else { string func = ProxyPtr::dynamicCast(type) ? "__read" : "read"; - out << nl << param << startAssign << "new " << fixId(seq->scoped()) << "()" << endAssign << ";"; + if(!seqIsArray) + { + out << nl << param << startAssign << "new " << fixId(seq->scoped()) << "()" << endAssign << ";"; + } out << sb; out << nl << "int sz = " << stream << ".readSize();"; + out << nl << stream << ".startSeq(sz, " << static_cast<unsigned>(type->minWireSize()) << ");"; + if(seqIsArray) + { + out << nl << param << " = new " << typeS << "[sz];"; + } out << nl << "for(int __i = 0; __i < sz; ++__i)"; out << sb; - out << nl << param << ".Add(" << typeS << "Helper." << func << "(" << stream << "));"; + if(!seqIsArray) + { + out << nl << param << ".Add(" << typeS << "Helper." << func << "(" << stream << "));"; + } + else + { + out << nl << param << "[__i]" << startAssign << typeS << "Helper." << func << "(" << stream << ")" + << endAssign << ";"; + } + if(type->isVariableLength()) + { + if(!SequencePtr::dynamicCast(type)) + { + out << nl << stream << ".checkSeq();"; + } + out << nl << stream << ".endElement();"; + } out << eb; out << eb; } @@ -815,13 +853,11 @@ Slice::CsGenerator::MetaDataVisitor::validate(const ContainedPtr& cont) { if(s.substr(prefix.size()) != "array") { - cerr << "2" << endl; valid = false; } } else { - cerr << "3" << endl; valid = false; } } |