diff options
author | Dwayne Boone <dwayne@zeroc.com> | 2006-02-08 14:44:10 +0000 |
---|---|---|
committer | Dwayne Boone <dwayne@zeroc.com> | 2006-02-08 14:44:10 +0000 |
commit | 99028ae4feebf092ef2b68cd93d979172e8c0463 (patch) | |
tree | bc8c11335563b0351ae7f5accfc7fc080606bc10 /cpp/src | |
parent | Added missing dependencies on slice2cpp (diff) | |
download | ice-99028ae4feebf092ef2b68cd93d979172e8c0463.tar.bz2 ice-99028ae4feebf092ef2b68cd93d979172e8c0463.tar.xz ice-99028ae4feebf092ef2b68cd93d979172e8c0463.zip |
Fixes to alternate sequence code to get around Sun issues.
Diffstat (limited to 'cpp/src')
-rw-r--r-- | cpp/src/Slice/CPlusPlusUtil.cpp | 232 | ||||
-rw-r--r-- | cpp/src/slice2cpp/Gen.cpp | 2 | ||||
-rw-r--r-- | cpp/src/slice2cppe/Gen.cpp | 2 |
3 files changed, 44 insertions, 192 deletions
diff --git a/cpp/src/Slice/CPlusPlusUtil.cpp b/cpp/src/Slice/CPlusPlusUtil.cpp index a3ec06913c4..af5f4be10c2 100644 --- a/cpp/src/Slice/CPlusPlusUtil.cpp +++ b/cpp/src/Slice/CPlusPlusUtil.cpp @@ -640,7 +640,7 @@ Slice::writeMarshalUnmarshalCode(Output& out, const TypePtr& type, const string& { seqType = fixKwd(seq->scoped()); } - out << nl << stream << deref << "writeSize(static_cast< ::Ice::Int>(::std::distance(" + out << nl << stream << deref << "writeSize(static_cast< ::Ice::Int>(ice_distance(" << fixedParam << ".first, " << fixedParam << ".second)));"; out << nl << "for(" << seqType << "::const_iterator __" << fixedParam << " = " << fixedParam << ".first; __" << fixedParam << " != " << fixedParam << ".second; ++__" @@ -651,106 +651,13 @@ Slice::writeMarshalUnmarshalCode(Output& out, const TypePtr& type, const string& } else if(!seqType.empty()) { - // - // Using alternate sequence type. In this case we use the templated writeSequence functions, - // choosing the appropriate function depending on the type contained in the sequence, which - // have differing write semantics. - // - string typeStr = typeToString(type, metaData); - if(typeStr[0] == ':') - { - typeStr = " " + typeStr; - } - if(typeStr[typeStr.size() - 1] == '>') - { - typeStr += " "; - } - if(!builtin || builtin->kind() == Builtin::KindObject || builtin->kind() == Builtin::KindObjectProxy) - { - SequencePtr innerSeq = SequencePtr::dynamicCast(seq->type()); - if(innerSeq) - { - string innerScope = fixKwd(innerSeq->scope()); - StringList l = innerSeq->getMetaData(); - seqType = findMetaData(l, false); - builtin = BuiltinPtr::dynamicCast(innerSeq->type()); - if(!seqType.empty()) - { - out << nl << "::IceInternal::writeSequence5<" << typeStr << ", " << innerScope - << fixKwd(innerSeq->name()) << ", " << innerScope << "__U__" - << fixKwd(innerSeq->name()) << ">(" << stream << ", " << fixedParam << ", " - << innerScope << "__write);"; - } - else if(!builtin || builtin->kind() == Builtin::KindObject || - builtin->kind() == Builtin::KindObjectProxy) - { - out << nl << "::IceInternal::writeSequence4<" << typeStr << ", " - << typeToString(innerSeq->type()) << ", " << innerScope << "__U__" - << fixKwd(innerSeq->name()) << ">(" << stream << ", " << fixedParam << ", " - << innerScope << "__write);"; - } - else if(builtin->kind() == Builtin::KindBool) - { - out << nl << "::IceInternal::writeSequence1<" << typeStr << ">(" << stream << ", " - << fixedParam << ");"; - } - else - { - out << nl << "::IceInternal::writeSequence3<" << typeStr << ">(" << stream << ", " - << fixedParam << ");"; - } - return; - } - - DictionaryPtr innerDict = DictionaryPtr::dynamicCast(seq->type()); - if(innerDict) - { - string innerScope = fixKwd(innerDict->scope()); - out << nl << "::IceInternal::writeSequence5<" << typeStr << ", " << innerScope - << fixKwd(innerDict->name()) << ", " << innerScope << "__U__" << fixKwd(innerDict->name()) - << ">(" << stream << ", " << fixedParam << ", " << innerScope << "__write);"; - return; - } - - EnumPtr innerEnum = EnumPtr::dynamicCast(seq->type()); - if(innerEnum) - { - string innerScope = fixKwd(innerEnum->scope()); - out << nl << "::IceInternal::writeSequence6<" << typeStr << ", " << innerScope - << fixKwd(innerEnum->name()) << ">(" << stream << ", " << fixedParam << ", " - << innerScope << "__write);"; - return; - } - - ProxyPtr innerProxy = ProxyPtr::dynamicCast(seq->type()); - if(innerProxy) - { - string innerScope = fixKwd(innerProxy->_class()->scope()); - out << nl << "::IceInternal::writeSequence7<" << typeStr << ", " - << typeToString(innerProxy) << ">(" << stream << ", " << fixedParam << ", " - << innerScope << "__write);"; - return; - } - - ClassDeclPtr innerClass = ClassDeclPtr::dynamicCast(seq->type()); - if(innerClass) - { - string innerScope = fixKwd(innerClass->scope()); - out << nl << "::IceInternal::writeSequence7<" << typeStr << ", " - << typeToString(innerClass) << ">(" << stream << ", " << fixedParam << ", " - << innerScope << "__write);"; - return; - } - - - out << nl << "::IceInternal::writeSequence2<" << typeStr << ">(" << stream - << ", " << fixedParam << ");"; - } - else - { - out << nl << "::IceInternal::writeSequence1<" << typeStr << ">(" << stream << ", " - << fixedParam << ");"; - } + out << nl << stream << deref << "writeSize(static_cast< ::Ice::Int>(" << fixedParam << ".size()));"; + out << nl << seqType << "::const_iterator __p_" << fixedParam << ";"; + out << nl << "for(__p_" << fixedParam << " = " << fixedParam << ".begin(); __p_" << fixedParam + << " != " << fixedParam << ".end(); ++__p_" << fixedParam << ")"; + out << sb; + writeMarshalUnmarshalCode(out, seq->type(), "(*__p_" + fixedParam + ")", true); + out << eb; } else { @@ -864,98 +771,39 @@ Slice::writeMarshalUnmarshalCode(Output& out, const TypePtr& type, const string& else if(!seqType.empty()) { // - // Using alternate sequence type. In this case we use the templated readSequence functions, - // choosing the appropriate function depending on the type contained in the sequence, which - // have differing read semantics. + // Using alternate sequence type. // - string typeStr = typeToString(type, metaData); - if(typeStr[0] == ':') - { - typeStr = " " + typeStr; - } - if(typeStr[typeStr.size() - 1] == '>') - { - typeStr += " "; - } - if(!builtin || builtin->kind() == Builtin::KindObject || builtin->kind() == Builtin::KindObjectProxy) - { - SequencePtr innerSeq = SequencePtr::dynamicCast(seq->type()); - if(innerSeq) - { - string innerScope = fixKwd(innerSeq->scope()); - StringList l = innerSeq->getMetaData(); - seqType = findMetaData(l, false); - builtin = BuiltinPtr::dynamicCast(innerSeq->type()); - if(!seqType.empty() || !builtin || builtin->kind() == Builtin::KindObject || - builtin->kind() == Builtin::KindObjectProxy) - { - out << nl << "::IceInternal::readSequence4<" << typeStr << ", " << innerScope - << fixKwd(innerSeq->name()) << ", " << innerScope << "__U__" << fixKwd(innerSeq->name()) - << ">(" << stream << ", " << fixedParam << ", " << innerScope << "__read);"; - } - else if(builtin->kind() == Builtin::KindByte) - { - out << nl << "::IceInternal::readSequence3<" << typeStr << ">(" << stream << ", " - << fixedParam << ");"; - } - else - { - out << nl << "::IceInternal::readSequence1<" << typeStr << ">(" << stream << ", " - << fixedParam << ", true);"; - } - return; - } - - DictionaryPtr innerDict = DictionaryPtr::dynamicCast(seq->type()); - if(innerDict) - { - string innerScope = fixKwd(innerDict->scope()); - out << nl << "::IceInternal::readSequence4<" << typeStr << ", " << innerScope - << fixKwd(innerDict->name()) << ", " << innerScope << "__U__" << fixKwd(innerDict->name()) - << ">(" << stream << ", " << fixedParam << ", " << innerScope << "__read);"; - return; - } - - EnumPtr innerEnum = EnumPtr::dynamicCast(seq->type()); - if(innerEnum) - { - string innerScope = fixKwd(innerEnum->scope()); - out << nl << "::IceInternal::readSequence5<" << typeStr << ", " << innerScope - << fixKwd(innerEnum->name()) << ">(" << stream << ", " << fixedParam << ", " << innerScope - << "__read);"; - return; - } - - ProxyPtr innerProxy = ProxyPtr::dynamicCast(seq->type()); - if(innerProxy) - { - string innerScope = fixKwd(innerProxy->_class()->scope()); - out << nl << "::IceInternal::readSequence5<" << typeStr << ", " - << typeToString(innerProxy) << ">(" << stream << ", " << fixedParam << ", " << innerScope - << "__read);"; - return; - } - - ClassDeclPtr innerClass = ClassDeclPtr::dynamicCast(seq->type()); - if(innerClass) - { - string innerScope = fixKwd(innerClass->scope()); - out << nl << "::IceInternal::readSequence6<" << typeStr << ">(" << stream << ", " - << fixedParam << ", " << innerClass->minWireSize() << ", " - << innerScope << "__patch__" << innerClass->name() << "Ptr);"; - return; - } - - TypePtr elemType = seq->type(); - out << nl << "::IceInternal::readSequence2<" << typeStr << ">(" << stream << ", " - << fixedParam << ", " << elemType->minWireSize() << ", " - << (elemType->isVariableLength() ? "true" : "false") << ");"; - } - else - { - out << nl << "::IceInternal::readSequence1<" << typeStr << ">(" << stream << ", " - << fixedParam << ", " << (builtin->kind() == Builtin::KindString ? "true" : "false") << ");"; - } + out << nl << "::Ice::Int __sz_" << fixedParam << ";"; + out << nl << stream << deref << "readSize(__sz_" << fixedParam << ");"; + out << nl << seqType << "(__sz_" << fixedParam << ").swap(" << fixedParam << ");"; + if(seq->type()->isVariableLength()) + { + out << nl << stream << deref << "startSeq(__sz_" << fixedParam << ", " + << seq->type()->minWireSize() << ");"; + } + else + { + out << nl << stream << deref << "checkFixedSeq(__sz_" << fixedParam << ", " + << seq->type()->minWireSize() << ");"; + } + out << nl << seqType << "::iterator __p_" << fixedParam << ";"; + out << nl << "for(__p_" << fixedParam << " = " << fixedParam << ".begin(); __p_" << fixedParam + << " != " << fixedParam << ".end(); ++__p_" << fixedParam << ")"; + out << sb; + writeMarshalUnmarshalCode(out, seq->type(), "(*__p_" + fixedParam + ")", false); + if(seq->type()->isVariableLength()) + { + if(!SequencePtr::dynamicCast(seq->type())) + { + out << nl << stream << deref << "checkSeq();"; + } + out << nl << stream << deref << "endElement();"; + } + out << eb; + if(seq->type()->isVariableLength()) + { + out << nl << stream << deref << "endSeq(__sz_" << fixedParam << ");"; + } } else { diff --git a/cpp/src/slice2cpp/Gen.cpp b/cpp/src/slice2cpp/Gen.cpp index 79843be2ce1..97718dd9328 100644 --- a/cpp/src/slice2cpp/Gen.cpp +++ b/cpp/src/slice2cpp/Gen.cpp @@ -239,6 +239,8 @@ Slice::Gen::generate(const UnitPtr& p) C << "\n#include <Ice/SliceChecksums.h>"; } + C << "\n#include <IceUtil/Iterator.h>"; + StringList includes = p->includeFiles(); for(StringList::const_iterator q = includes.begin(); q != includes.end(); ++q) diff --git a/cpp/src/slice2cppe/Gen.cpp b/cpp/src/slice2cppe/Gen.cpp index e8f5780133e..52d18fddce3 100644 --- a/cpp/src/slice2cppe/Gen.cpp +++ b/cpp/src/slice2cppe/Gen.cpp @@ -238,6 +238,8 @@ Slice::Gen::generate(const UnitPtr& p) C << "\n#include <IceE/LocalException.h>"; } + C << "\n#include <IceE/Iterator.h>"; + StringList includes = p->includeFiles(); for(StringList::const_iterator q = includes.begin(); q != includes.end(); ++q) |