summaryrefslogtreecommitdiff
path: root/cpp/src
diff options
context:
space:
mode:
authorJoe George <joe@zeroc.com>2019-03-07 16:13:25 -0500
committerJoe George <joe@zeroc.com>2019-03-07 16:13:25 -0500
commit4631d68474d071aa4abc2cb2d94bf2e9898a9dde (patch)
tree5e07352b1bcebb1991c760e8090173f5f8b33729 /cpp/src
parentMore stream fixes (diff)
downloadice-4631d68474d071aa4abc2cb2d94bf2e9898a9dde.tar.bz2
ice-4631d68474d071aa4abc2cb2d94bf2e9898a9dde.tar.xz
ice-4631d68474d071aa4abc2cb2d94bf2e9898a9dde.zip
Class unmarshaling fixes
Diffstat (limited to 'cpp/src')
-rw-r--r--cpp/src/slice2swift/Gen.cpp5
-rw-r--r--cpp/src/slice2swift/SwiftUtil.cpp39
2 files changed, 41 insertions, 3 deletions
diff --git a/cpp/src/slice2swift/Gen.cpp b/cpp/src/slice2swift/Gen.cpp
index 2d3c804e3dd..9b44c07f1fb 100644
--- a/cpp/src/slice2swift/Gen.cpp
+++ b/cpp/src/slice2swift/Gen.cpp
@@ -464,7 +464,8 @@ Gen::TypesVisitor::visitSequence(const SequencePtr& p)
out << nl << "v.reserveCapacity(sz)";
out << nl << "for i in 0 ..< sz";
out << sb;
- writeMarshalUnmarshalCode(out, type, typeToString(p->type(), p), "v[i]", false, false, false);
+ writeMarshalUnmarshalCode(out, type, typeToString(p->type(), p), "j", false, true, false);
+ out << nl << "v[i] = j";
out << eb;
out << nl << "return v";
out << eb;
@@ -497,7 +498,7 @@ Gen::TypesVisitor::visitSequence(const SequencePtr& p)
out << eb;
out << sp;
- out << nl << "public static func write(to ostr: " << ostr << ", tag: Int32, value v: "<< name << "?)";
+ out << nl << "public static func write(to ostr: " << ostr << ", tag: Int32, value v: "<< name << "?)";
out << sb;
out << nl << "guard let val = v else";
out << sb;
diff --git a/cpp/src/slice2swift/SwiftUtil.cpp b/cpp/src/slice2swift/SwiftUtil.cpp
index 8ce47228c71..1fe9ccf7fe0 100644
--- a/cpp/src/slice2swift/SwiftUtil.cpp
+++ b/cpp/src/slice2swift/SwiftUtil.cpp
@@ -820,8 +820,11 @@ SwiftGenerator::writeMarshalUnmarshalCode(Output &out,
}
else
{
+ if(declareParam)
+ {
+ out << nl << "var " << param << ": " << typeStr;
+ }
out << nl << "try " << stream << "read(" << unmarshalParam << ") { " << param << " = $0 }";
-
}
break;
}
@@ -837,6 +840,40 @@ SwiftGenerator::writeMarshalUnmarshalCode(Output &out,
}
}
+ if(ClassDeclPtr::dynamicCast(type))
+ {
+ if (marshal)
+ {
+ out << nl << stream << "write(" << marshalParam << ")";
+ }
+ else
+ {
+ if(declareParam)
+ {
+ out << nl << "var " << param << ": " << typeStr;
+ }
+ out << nl << "try " << stream << "read";
+ out << spar;
+ if(!unmarshalParam.empty())
+ {
+ out << unmarshalParam;
+ }
+ const string swiftModule = getSwiftModule(getTopLevelModule(ContainedPtr::dynamicCast(type)));
+ const string className = getUnqualified(getAbsolute(type), swiftModule);
+ out << ("value: " + className + ".self");
+ out << epar;
+ out << sb;
+ out << nl;
+ if(!declareParam)
+ {
+ out << "self.";
+ }
+ out << param << " = $0";
+ out << eb;
+ }
+ return;
+ }
+
EnumPtr en = EnumPtr::dynamicCast(type);
if(en)
{