summaryrefslogtreecommitdiff
path: root/cpp/src/Slice/CsUtil.cpp
diff options
context:
space:
mode:
authorMichi Henning <michi@zeroc.com>2007-09-19 15:42:58 +1000
committerMichi Henning <michi@zeroc.com>2007-09-19 15:42:58 +1000
commit32c7c9e1cfe2e87c69c9710e1c4969a7db09f8a4 (patch)
tree0410941fad3f5e1f6ddda57afc1b5787269ee09e /cpp/src/Slice/CsUtil.cpp
parentMerge branch 'master' of ssh://cvs.zeroc.com/home/git/ice (diff)
downloadice-32c7c9e1cfe2e87c69c9710e1c4969a7db09f8a4.tar.bz2
ice-32c7c9e1cfe2e87c69c9710e1c4969a7db09f8a4.tar.xz
ice-32c7c9e1cfe2e87c69c9710e1c4969a7db09f8a4.zip
Added support for custom sequences. Unfortunately, it doesn't work.
Looks like a C# compiler bug.
Diffstat (limited to 'cpp/src/Slice/CsUtil.cpp')
-rwxr-xr-xcpp/src/Slice/CsUtil.cpp85
1 files changed, 80 insertions, 5 deletions
diff --git a/cpp/src/Slice/CsUtil.cpp b/cpp/src/Slice/CsUtil.cpp
index 34860477f28..9b3d4f7575e 100755
--- a/cpp/src/Slice/CsUtil.cpp
+++ b/cpp/src/Slice/CsUtil.cpp
@@ -176,8 +176,15 @@ Slice::CsGenerator::typeToString(const TypePtr& type)
string meta;
if(seq->findMetaData(prefix, meta))
{
- return "_System.Collections.Generic." + meta.substr(prefix.size())
- + "<" + typeToString(seq->type()) + ">";
+ string type = meta.substr(prefix.size());
+ if(type == "List" || type == "LinkedList" || type == "Queue" || type == "Stack")
+ {
+ return "_System.Collections.Generic." + type + "<" + typeToString(seq->type()) + ">";
+ }
+ else
+ {
+ return "global::" + type + "<" + typeToString(seq->type()) + ">";
+ }
}
return typeToString(seq->type()) + "[]";
@@ -711,6 +718,10 @@ Slice::CsGenerator::writeSequenceMarshalUnmarshalCode(Output& out,
{
out << "Ice.Object[" << param << "_lenx];";
}
+ else if(isCustom)
+ {
+ out << "global::" << genericType << "<Ice.Object>();";
+ }
else if(isGeneric)
{
out << "_System.Collections.Generic." << genericType << "<Ice.Object>(";
@@ -731,7 +742,25 @@ Slice::CsGenerator::writeSequenceMarshalUnmarshalCode(Output& out,
{
out << "(ReadObjectCallback)";
}
- out << "new IceInternal.SequencePatcher<" << typeS << ">(" << param << ", typeof(Ice.Object), ix__));";
+ string patcherName;
+ if(isCustom)
+ {
+ patcherName = "CustomSeq";
+ }
+ else if(isList)
+ {
+ patcherName = "List";
+ }
+ else if(isArray)
+ {
+ patcherName = "Array";
+ }
+ else
+ {
+ patcherName = "Sequence";
+ }
+ out << "new IceInternal." << patcherName << "Patcher<" << typeS << ">("
+ << param << ", typeof(Ice.Object), ix__));";
}
else
{
@@ -803,6 +832,18 @@ Slice::CsGenerator::writeSequenceMarshalUnmarshalCode(Output& out,
{
out << nl << param << " = " << stream << ".read" << typeS << "Seq();";
}
+ else if(isCustom)
+ {
+ out << sb;
+ out << nl << param << " = new " << "global::" << genericType << "<"
+ << typeToString(type) << ">();";
+ out << nl << "int szx__ = " << stream << ".readSize();";
+ out << nl << "for(int ix__ = 0; ix__ < szx__; ++ix__)";
+ out << sb;
+ out << nl << param << ".Add(" << stream << ".read" << typeS << "());";
+ out << eb;
+ out << eb;
+ }
else if(isGeneric)
{
out << nl << stream << ".read" << typeS << "Seq(out " << param << ");";
@@ -873,6 +914,10 @@ Slice::CsGenerator::writeSequenceMarshalUnmarshalCode(Output& out,
{
out << toArrayAlloc(typeS + "[]", "szx__");
}
+ else if(isCustom)
+ {
+ out << "global::" << genericType << "<" << typeS << ">()";
+ }
else if(isGeneric)
{
out << "_System.Collections.Generic." << genericType << "<" << typeS << ">(";
@@ -889,8 +934,26 @@ Slice::CsGenerator::writeSequenceMarshalUnmarshalCode(Output& out,
out << ';';
out << nl << "for(int ix__ = 0; ix__ < szx__; ++ix__)";
out << sb;
- out << nl << "IceInternal.SequencePatcher<" << typeS << "> spx = new IceInternal.SequencePatcher<" << typeS << ">("
- << param << ", " << "typeof(" << typeS << "), ix__);";
+
+ string patcherName;
+ if(isCustom)
+ {
+ patcherName = "CustomSeq";
+ }
+ else if(isList)
+ {
+ patcherName = "List";
+ }
+ else if(isArray)
+ {
+ patcherName = "Array";
+ }
+ else
+ {
+ patcherName = "Sequence";
+ }
+ out << nl << "IceInternal." << patcherName << "Patcher<" << typeS << "> spx = new IceInternal."
+ << patcherName << "Patcher<" << typeS << ">(" << param << ", " << "typeof(" << typeS << "), ix__);";
out << nl << stream << ".readObject(";
if(streamingAPI)
{
@@ -988,6 +1051,10 @@ Slice::CsGenerator::writeSequenceMarshalUnmarshalCode(Output& out,
{
out << toArrayAlloc(typeS + "[]", "szx__") << ";";
}
+ else if(isCustom)
+ {
+ out << "global::" << genericType << "<" << typeS << ">();";
+ }
else if(isGeneric)
{
out << "_System.Collections.Generic." << genericType << "<" << typeS << ">(";
@@ -1121,6 +1188,10 @@ Slice::CsGenerator::writeSequenceMarshalUnmarshalCode(Output& out,
{
out << toArrayAlloc(typeS + "[]", "szx__") << ";";
}
+ else if(isCustom)
+ {
+ out << "global::" << genericType << "<" << typeS << ">();";
+ }
else if(isGeneric)
{
out << "_System.Collections.Generic." << genericType << "<" << typeS << ">(";
@@ -1232,6 +1303,10 @@ Slice::CsGenerator::writeSequenceMarshalUnmarshalCode(Output& out,
{
out << toArrayAlloc(typeS + "[]", "szx__") << ";";
}
+ else if(isCustom)
+ {
+ out << "global::" << genericType << "<" << typeS << ">();";
+ }
else if(isGeneric)
{
out << "_System.Collections.Generic." << genericType << "<" << typeS << ">();";