summaryrefslogtreecommitdiff
path: root/cpp/src
diff options
context:
space:
mode:
authorJoe George <joe@zeroc.com>2019-03-18 13:22:11 -0400
committerJoe George <joe@zeroc.com>2019-03-18 13:22:11 -0400
commite05a325acf76f9f5afee8c0f6d29779f2f382c7c (patch)
tree636d085f03a937e73fcf815ff41f84f4d234200c /cpp/src
parentAsync fixes (diff)
downloadice-e05a325acf76f9f5afee8c0f6d29779f2f382c7c.tar.bz2
ice-e05a325acf76f9f5afee8c0f6d29779f2f382c7c.tar.xz
ice-e05a325acf76f9f5afee8c0f6d29779f2f382c7c.zip
Proxy unmarshaling cleanup for streaming
Diffstat (limited to 'cpp/src')
-rw-r--r--cpp/src/slice2swift/Gen.cpp20
-rw-r--r--cpp/src/slice2swift/SwiftUtil.cpp40
2 files changed, 50 insertions, 10 deletions
diff --git a/cpp/src/slice2swift/Gen.cpp b/cpp/src/slice2swift/Gen.cpp
index 86d25b75bad..1041d9c0b2c 100644
--- a/cpp/src/slice2swift/Gen.cpp
+++ b/cpp/src/slice2swift/Gen.cpp
@@ -866,6 +866,26 @@ Gen::ProxyVisitor::visitClassDefStart(const ClassDefPtr& p)
out << nl << "return " << prxI << ".uncheckedCast(prx: prx, facet: facet, context: context) as " << prxI << "?";
out << eb;
+ //
+ // InputStream extension
+ //
+ out << sp;
+ out << nl << "public extension " << getUnqualified("Ice.InputStream", swiftModule);
+ out << sb;
+
+ out << nl << "func read(_ prx: " << prx << ".Protocol) throws -> " << prx << "?";
+ out << sb;
+ out << nl << "return try read() as " << prxI << "?";
+ out << eb;
+
+ out << sp;
+ out << nl << "func read(tag: Int32, prx: " << prx << ".Protocol) throws -> " << prx << "?";
+ out << sb;
+ out << nl << "return try read(tag: tag) as " << prxI << "?";
+ out << eb;
+
+ out << eb;
+
out << sp;
out << nl << "public extension " << prx;
out << sb;
diff --git a/cpp/src/slice2swift/SwiftUtil.cpp b/cpp/src/slice2swift/SwiftUtil.cpp
index ef5453aca20..71e8c21bbf8 100644
--- a/cpp/src/slice2swift/SwiftUtil.cpp
+++ b/cpp/src/slice2swift/SwiftUtil.cpp
@@ -843,7 +843,17 @@ SwiftGenerator::writeMarshalUnmarshalCode(Output &out,
}
else
{
- out << nl << assign << " = try " << stream << "read(" << unmarshalParam << ") as _ObjectPrxI?";
+ // proxy reads requires an additional parameter
+ const string prxType = getUnqualified(getAbsolute(type), swiftModule) + ".self";
+ if(unmarshalParam.empty())
+ {
+ unmarshalParam = prxType;
+ }
+ else
+ {
+ unmarshalParam += ", prx: " + prxType;
+ }
+ out << nl << assign << " = try " << stream << "read(" << unmarshalParam << ")";
}
break;
}
@@ -905,15 +915,16 @@ SwiftGenerator::writeMarshalUnmarshalCode(Output &out,
}
else
{
- out << nl << "try " << stream << "read";
- out << spar;
- if(!unmarshalParam.empty())
+ const string className = getUnqualified(getAbsolute(type), swiftModule);
+ if(unmarshalParam.empty())
{
- out << unmarshalParam;
+ unmarshalParam = className + ".self";
}
- const string className = getUnqualified(getAbsolute(type), swiftModule);
- out << ("value: " + className + ".self");
- out << epar;
+ else
+ {
+ unmarshalParam += ", value: " + className + ".self";
+ }
+ out << nl << "try " << stream << "read(" << unmarshalParam << ")";
out << sb;
out << nl;
if(!declareParam)
@@ -949,8 +960,17 @@ SwiftGenerator::writeMarshalUnmarshalCode(Output &out,
}
else
{
- const string prxI = "_" + getUnqualified(getAbsolute(type), swiftModule) + "I?";
- out << nl << assign << " = try " << stream << "read(" << unmarshalParam << ") as " << prxI ;
+ // proxy reads requires an additional parameter
+ const string prxType = getUnqualified(getAbsolute(type), swiftModule) + ".self";
+ if(unmarshalParam.empty())
+ {
+ unmarshalParam = prxType;
+ }
+ else
+ {
+ unmarshalParam += ", prx: " + prxType;
+ }
+ out << nl << assign << " = try " << stream << "read(" << unmarshalParam << ")";
}
return;
}