summaryrefslogtreecommitdiff
path: root/cpp/src/slice2swift/Gen.cpp
diff options
context:
space:
mode:
authorJoe George <joe@zeroc.com>2019-03-14 10:01:44 -0400
committerJoe George <joe@zeroc.com>2019-03-14 10:01:44 -0400
commit1ae202d309b6aea7ab8662eb917f71868f0dc20d (patch)
tree513819cc600bde3f76f729f046b545fbd6ebcae1 /cpp/src/slice2swift/Gen.cpp
parentSwift proxy testing & fixes (diff)
downloadice-1ae202d309b6aea7ab8662eb917f71868f0dc20d.tar.bz2
ice-1ae202d309b6aea7ab8662eb917f71868f0dc20d.tar.xz
ice-1ae202d309b6aea7ab8662eb917f71868f0dc20d.zip
Proxy fixes
- omit label for single param operations - add missing context - fix optional return unmarshaling
Diffstat (limited to 'cpp/src/slice2swift/Gen.cpp')
-rw-r--r--cpp/src/slice2swift/Gen.cpp13
1 files changed, 10 insertions, 3 deletions
diff --git a/cpp/src/slice2swift/Gen.cpp b/cpp/src/slice2swift/Gen.cpp
index 4122956577b..746a6a285d8 100644
--- a/cpp/src/slice2swift/Gen.cpp
+++ b/cpp/src/slice2swift/Gen.cpp
@@ -894,11 +894,14 @@ Gen::ProxyVisitor::visitOperation(const OperationPtr& op)
out << sp;
out << nl << "func " << opName;
out << spar;
+ const string omitLabel = inParams.size() == 1 ? "_ " : "";
for(ParamDeclList::const_iterator q = inParams.begin(); q != inParams.end(); ++q)
{
ParamDeclPtr param = *q;
- out << (param->name() + ": " + typeToString(param->type(), param));
+ out << (omitLabel + param->name() + ": " + typeToString(param->type(), param));
}
+ // context
+ out << "context: Context? = nil";
out << epar;
out << " throws";
@@ -985,7 +988,8 @@ Gen::ProxyVisitor::visitOperation(const OperationPtr& op)
out << ',';
}
}
- out << "]";
+ out << "],";
+ out << nl << "context: context";
out << ")";
out.restoreIndent();
out << nl;
@@ -1007,21 +1011,24 @@ Gen::ProxyVisitor::visitOperation(const OperationPtr& op)
returnVals.push_back((*q)->name());
}
+ // If the return type is optional we unmarshal it with the rest of the optional params (in order)
if(returnType && !op->returnIsOptional())
{
writeMarshalUnmarshalCode(out, returnType, typeToString(returnType, op), "ret", false, true, false);
returnVals.push_front("ret");
}
+ bool optReturnUnmarshaled = false;
for(ParamDeclList::const_iterator q = optionalOutParams.begin(); q != optionalOutParams.end(); ++q)
{
ParamDeclPtr param = *q;
assert(param->optional());
- if(returnType && op->returnIsOptional() && op->returnTag() < param->tag())
+ if(returnType && op->returnIsOptional() && !optReturnUnmarshaled && (op->returnTag() < param->tag()))
{
writeMarshalUnmarshalCode(out, returnType, typeToString(returnType, op), "ret", false, true, false, op->returnTag());
returnVals.push_front("ret");
+ optReturnUnmarshaled = true;
}
ContainedPtr topLevel = getTopLevelModule(ContainedPtr::dynamicCast(param));