summaryrefslogtreecommitdiff
path: root/cpp/src/Slice/CPlusPlusUtil.cpp
diff options
context:
space:
mode:
authorJose <jose@zeroc.com>2009-11-06 02:36:38 +0100
committerJose <jose@zeroc.com>2009-11-06 02:36:38 +0100
commit488d2234965a5495306a5a4f9f40a37f6df02aae (patch)
tree20990d18f6c2641f4336da3be34ddc62185b7801 /cpp/src/Slice/CPlusPlusUtil.cpp
parentanother fix to watch dog thread in TestUtil (diff)
downloadice-488d2234965a5495306a5a4f9f40a37f6df02aae.tar.bz2
ice-488d2234965a5495306a5a4f9f40a37f6df02aae.tar.xz
ice-488d2234965a5495306a5a4f9f40a37f6df02aae.zip
855 - Stream template functions and template programming.
Diffstat (limited to 'cpp/src/Slice/CPlusPlusUtil.cpp')
-rw-r--r--cpp/src/Slice/CPlusPlusUtil.cpp412
1 files changed, 4 insertions, 408 deletions
diff --git a/cpp/src/Slice/CPlusPlusUtil.cpp b/cpp/src/Slice/CPlusPlusUtil.cpp
index 93c5f25a1d3..a19636f2ef8 100644
--- a/cpp/src/Slice/CPlusPlusUtil.cpp
+++ b/cpp/src/Slice/CPlusPlusUtil.cpp
@@ -1124,418 +1124,14 @@ Slice::writeStreamMarshalUnmarshalCode(Output& out, const TypePtr& type, const s
stream = str;
}
- BuiltinPtr builtin = BuiltinPtr::dynamicCast(type);
- if(builtin)
- {
- switch(builtin->kind())
- {
- case Builtin::KindByte:
- {
- if(marshal)
- {
- out << nl << stream << "->writeByte(" << fixedParam << ");";
- }
- else
- {
- out << nl << fixedParam << " = " << stream << "->readByte();";
- }
- break;
- }
- case Builtin::KindBool:
- {
- if(marshal)
- {
- out << nl << stream << "->writeBool(" << fixedParam << ");";
- }
- else
- {
- out << nl << fixedParam << " = " << stream << "->readBool();";
- }
- break;
- }
- case Builtin::KindShort:
- {
- if(marshal)
- {
- out << nl << stream << "->writeShort(" << fixedParam << ");";
- }
- else
- {
- out << nl << fixedParam << " = " << stream << "->readShort();";
- }
- break;
- }
- case Builtin::KindInt:
- {
- if(marshal)
- {
- out << nl << stream << "->writeInt(" << fixedParam << ");";
- }
- else
- {
- out << nl << fixedParam << " = " << stream << "->readInt();";
- }
- break;
- }
- case Builtin::KindLong:
- {
- if(marshal)
- {
- out << nl << stream << "->writeLong(" << fixedParam << ");";
- }
- else
- {
- out << nl << fixedParam << " = " << stream << "->readLong();";
- }
- break;
- }
- case Builtin::KindFloat:
- {
- if(marshal)
- {
- out << nl << stream << "->writeFloat(" << fixedParam << ");";
- }
- else
- {
- out << nl << fixedParam << " = " << stream << "->readFloat();";
- }
- break;
- }
- case Builtin::KindDouble:
- {
- if(marshal)
- {
- out << nl << stream << "->writeDouble(" << fixedParam << ");";
- }
- else
- {
- out << nl << fixedParam << " = " << stream << "->readDouble();";
- }
- break;
- }
- case Builtin::KindString:
- {
- string strType = findMetaData(metaData, true);
- if(strType != "string" && (useWstring || strType == "wstring"))
- {
- if(marshal)
- {
- out << nl << stream << "->writeWstring(" << fixedParam << ");";
- }
- else
- {
- out << nl << fixedParam << " = " << stream << "->readWstring();";
- }
- }
- else
- {
- if(marshal)
- {
- out << nl << stream << "->writeString(" << fixedParam << ");";
- }
- else
- {
- out << nl << fixedParam << " = " << stream << "->readString();";
- }
- }
- break;
- }
- case Builtin::KindObject:
- {
- if(marshal)
- {
- out << nl << "::Ice::ice_writeObject(" << stream << ", " << fixedParam << ");";
- }
- else
- {
- out << nl << "::Ice::ice_readObject(" << stream << ", " << fixedParam << ");";
- }
- break;
- }
- case Builtin::KindObjectProxy:
- {
- // TODO
- if(marshal)
- {
- out << nl << stream << "->writeProxy(" << fixedParam << ");";
- }
- else
- {
- out << nl << fixedParam << " = " << stream << "->readProxy();";
- }
- break;
- }
- case Builtin::KindLocalObject:
- {
- assert(false);
- break;
- }
- }
-
- return;
- }
-
- ClassDeclPtr cl = ClassDeclPtr::dynamicCast(type);
- if(cl)
+ if(marshal)
{
- string scope = fixKwd(cl->scope());
- if(marshal)
- {
- out << nl << scope << "ice_write" << cl->name() << "(" << stream << ", " << fixedParam << ");";
- }
- else
- {
- out << nl << scope << "ice_read" << cl->name() << "(" << stream << ", " << fixedParam << ");";
- }
-
- return;
+ out << nl << stream << "->write(" << fixedParam << ");";
}
-
- StructPtr st = StructPtr::dynamicCast(type);
- if(st)
- {
- string scope = fixKwd(st->scope());
- if(marshal)
- {
- out << nl << scope << "ice_write" << st->name() << "(" << stream << ", " << fixedParam << ");";
- }
- else
- {
- if(findMetaData(st->getMetaData(), false) == "class")
- {
- out << nl << fixedParam << " = new " << fixKwd(st->scoped()) << ";";
- }
- out << nl << scope << "ice_read" << st->name() << "(" << stream << ", " << fixedParam << ");";
- }
-
- return;
- }
-
- SequencePtr seq = SequencePtr::dynamicCast(type);
- if(seq)
- {
- string seqType = findMetaData(metaData, false);
- if(!seqType.empty())
- {
- if(marshal)
- {
- out << nl << stream << "->writeSize(static_cast< ::Ice::Int>(" << fixedParam << ".size()));";
- out << nl << seqType << "::const_iterator ___" << fixedParam << ";";
- out << nl << "for(___" << fixedParam << " = " << fixedParam << ".begin(); ___" << fixedParam << " != "
- << fixedParam << ".end(); ++___" << fixedParam << ")";
- out << sb;
- writeStreamMarshalUnmarshalCode(out, seq->type(), "(*___" + fixedParam + ")", true);
- out << eb;
- }
- else
- {
- out << nl << seqType << "(static_cast< ::Ice::Int>(" << stream << "->readSize())).swap("
- << fixedParam << ");";
- out << nl << seqType << "::iterator ___" << fixedParam << ";";
- out << nl << "for(___" << fixedParam << " = " << fixedParam << ".begin(); ___" << fixedParam << " != "
- << fixedParam << ".end(); ++___" << fixedParam << ")";
- out << sb;
- writeStreamMarshalUnmarshalCode(out, seq->type(), "(*___" + fixedParam + ")", false);
- out << eb;
- }
- }
- else
- {
- bool protobuf;
- seqType = findMetaData(seq, seq->getMetaData(), false, protobuf);
- builtin = BuiltinPtr::dynamicCast(seq->type());
- if(protobuf || !seqType.empty() || !builtin || (builtin->kind() == Builtin::KindObject ||
- builtin->kind() == Builtin::KindObjectProxy))
- {
- string scope = fixKwd(seq->scope());
- if(marshal)
- {
- out << nl << scope << "ice_write" << seq->name() << '(' << stream << ", " << fixedParam << ");";
- }
- else
- {
- out << nl << scope << "ice_read" << seq->name() << '(' << stream << ", " << fixedParam << ");";
- }
- }
- else
- {
- switch(builtin->kind())
- {
- case Builtin::KindByte:
- {
- if(marshal)
- {
- out << nl << stream << "->writeByteSeq(" << fixedParam << ");";
- }
- else
- {
- out << nl << fixedParam << " = " << stream << "->readByteSeq();";
- }
- break;
- }
- case Builtin::KindBool:
- {
- if(marshal)
- {
- out << nl << stream << "->writeBoolSeq(" << fixedParam << ");";
- }
- else
- {
- out << nl << fixedParam << " = " << stream << "->readBoolSeq();";
- }
- break;
- }
- case Builtin::KindShort:
- {
- if(marshal)
- {
- out << nl << stream << "->writeShortSeq(" << fixedParam << ");";
- }
- else
- {
- out << nl << fixedParam << " = " << stream << "->readShortSeq();";
- }
- break;
- }
- case Builtin::KindInt:
- {
- if(marshal)
- {
- out << nl << stream << "->writeIntSeq(" << fixedParam << ");";
- }
- else
- {
- out << nl << fixedParam << " = " << stream << "->readIntSeq();";
- }
- break;
- }
- case Builtin::KindLong:
- {
- if(marshal)
- {
- out << nl << stream << "->writeLongSeq(" << fixedParam << ");";
- }
- else
- {
- out << nl << fixedParam << " = " << stream << "->readLongSeq();";
- }
- break;
- }
- case Builtin::KindFloat:
- {
- if(marshal)
- {
- out << nl << stream << "->writeFloatSeq(" << fixedParam << ");";
- }
- else
- {
- out << nl << fixedParam << " = " << stream << "->readFloatSeq();";
- }
- break;
- }
- case Builtin::KindDouble:
- {
- if(marshal)
- {
- out << nl << stream << "->writeDoubleSeq(" << fixedParam << ");";
- }
- else
- {
- out << nl << fixedParam << " = " << stream << "->readDoubleSeq();";
- }
- break;
- }
- case Builtin::KindString:
- {
- string strType = findMetaData(seq->typeMetaData(), true);
- if(strType != "string" && (useWstring || strType == "wstring"))
- {
- if(marshal)
- {
- out << nl << stream << "->writeWstringSeq(" << fixedParam << ");";
- }
- else
- {
- out << nl << fixedParam << " = " << stream << "->readWstringSeq();";
- }
- }
- else
- {
- if(marshal)
- {
- out << nl << stream << "->writeStringSeq(" << fixedParam << ");";
- }
- else
- {
- out << nl << fixedParam << " = " << stream << "->readStringSeq();";
- }
- }
- break;
- }
- case Builtin::KindObject:
- case Builtin::KindObjectProxy:
- case Builtin::KindLocalObject:
- {
- assert(false);
- break;
- }
- }
- }
- }
-
- return;
- }
-
- DictionaryPtr dict = DictionaryPtr::dynamicCast(type);
- if(dict)
- {
- string scope = fixKwd(dict->scope());
- if(marshal)
- {
- out << nl << scope << "ice_write" << dict->name() << "(" << stream << ", " << fixedParam << ");";
- }
- else
- {
- out << nl << scope << "ice_read" << dict->name() << "(" << stream << ", " << fixedParam << ");";
- }
-
- return;
- }
-
- EnumPtr en = EnumPtr::dynamicCast(type);
- if(en)
- {
- string scope = fixKwd(en->scope());
- if(marshal)
- {
- out << nl << scope << "ice_write" << en->name() << "(" << stream << ", " << fixedParam << ");";
- }
- else
- {
- out << nl << scope << "ice_read" << en->name() << "(" << stream << ", " << fixedParam << ");";
- }
-
- return;
- }
-
- ProxyPtr prx = ProxyPtr::dynamicCast(type);
- if(prx)
+ else
{
- ClassDeclPtr cls = prx->_class();
- string scope = fixKwd(cls->scope());
- if(marshal)
- {
- out << nl << scope << "ice_write" << cls->name() << "Prx(" << stream << ", " << fixedParam << ");";
- }
- else
- {
- out << nl << scope << "ice_read" << cls->name() << "Prx(" << stream << ", " << fixedParam << ");";
- }
-
- return;
+ out << nl << stream << "->read(" << fixedParam << ");";
}
-
- assert(false);
}
// Accepted metadata.