summaryrefslogtreecommitdiff
path: root/cpp/src/slice2swift
diff options
context:
space:
mode:
authorJose <jose@zeroc.com>2019-05-30 11:37:43 +0200
committerJose <jose@zeroc.com>2019-05-30 11:37:43 +0200
commit79a165ee6240c27ef75fdb72a94db9356728befa (patch)
tree4ea180bf5ba4d236afdefa72af76e48f0c287d7d /cpp/src/slice2swift
parentFix logger initialization (diff)
downloadice-79a165ee6240c27ef75fdb72a94db9356728befa.tar.bz2
ice-79a165ee6240c27ef75fdb72a94db9356728befa.tar.xz
ice-79a165ee6240c27ef75fdb72a94db9356728befa.zip
Swif doc comment fixes
Diffstat (limited to 'cpp/src/slice2swift')
-rw-r--r--cpp/src/slice2swift/Gen.cpp10
-rw-r--r--cpp/src/slice2swift/SwiftUtil.cpp55
-rw-r--r--cpp/src/slice2swift/SwiftUtil.h2
3 files changed, 34 insertions, 33 deletions
diff --git a/cpp/src/slice2swift/Gen.cpp b/cpp/src/slice2swift/Gen.cpp
index 77960e9dba2..b972a44e3e2 100644
--- a/cpp/src/slice2swift/Gen.cpp
+++ b/cpp/src/slice2swift/Gen.cpp
@@ -1116,10 +1116,6 @@ Gen::ProxyVisitor::visitClassDefStart(const ClassDefPtr& p)
out << eb;
out << sp;
- out << nl << "/// Returns the Slice type id of the interface or class associated with this proxy class.";
- out << nl << "///";
- out << nl << "/// - returns: `String` the Slice type id of the interface or class associated with";
- out << nl << "/// this proxy type";
out << nl;
if(swiftModule == "Ice")
{
@@ -1675,9 +1671,9 @@ Gen::ObjectExtVisitor::visitClassDefStart(const ClassDefPtr& p)
out << sp;
out << nl << "/// Returns the Slice type IDs of the interfaces supported by this object";
out << nl << "///";
- out << nl << "/// - parameter current: `Ice.Current` The Current object for the invocation.";
+ out << nl << "/// - parameter current: `Ice.Current` - The Current object for the invocation.";
out << nl << "///";
- out << nl << "/// - returns: `[Swift.String]` The Slice type IDs of the interfaces supported by this object,";
+ out << nl << "/// - returns: `[Swift.String]` - The Slice type IDs of the interfaces supported by this object,";
out << nl << "/// in base-to-derived order.";
out << nl << "func ice_ids(current _: Current) throws -> [Swift.String]";
out << sb;
@@ -1687,7 +1683,7 @@ Gen::ObjectExtVisitor::visitClassDefStart(const ClassDefPtr& p)
out << sp;
out << nl << "/// Tests whether this object supports a specific Slice interface.";
out << nl << "///";
- out << nl << "/// - parameter s: `Swift.String` - The name of the interface to be check.";
+ out << nl << "/// - parameter s: `String` - The name of the interface to be check.";
out << nl << "///";
out << nl << "/// - parameter current: `Ice.Current` - The Current object for the invocation.";
out << nl << "///";
diff --git a/cpp/src/slice2swift/SwiftUtil.cpp b/cpp/src/slice2swift/SwiftUtil.cpp
index 8b1c37bb901..d81801b5040 100644
--- a/cpp/src/slice2swift/SwiftUtil.cpp
+++ b/cpp/src/slice2swift/SwiftUtil.cpp
@@ -683,14 +683,16 @@ SwiftGenerator::writeOpDocSummary(IceUtilInternal::Output& out,
out << nl << "///";
if(dispatch)
{
- out << nl << "/// - parameter current: `Ice.Current` The Current object for the invocation.";
+ out << nl << "/// - parameter current: `Ice.Current` - The Current object for the invocation.";
}
else
{
- out << nl << "/// - parameter context: `Ice.Context` Optional request context.";
+ out << nl << "/// - parameter context: `Ice.Context` - Optional request context.";
}
}
+ typeCtx = local ? TypeContextLocal : 0;
+
if(async)
{
if(!dispatch)
@@ -706,23 +708,11 @@ SwiftGenerator::writeOpDocSummary(IceUtilInternal::Output& out,
}
out << nl << "///";
- out << nl << "/// - returns: `PromiseKit.Promise` - Promise object that ";
- if(local)
- {
- out << "will be resolved with the operation result.";
- }
- else if(dispatch)
- {
- out << "must be resolved with the return values of the dispatch.";
- }
- else
- {
- out << "will be resolved with the return values of the invocation.";
- }
+ out << nl << "/// - returns: `PromiseKit.Promise<" << operationReturnType(p, typeCtx)
+ << ">` - The result of the operation";
}
else
{
- typeCtx = local ? TypeContextLocal : 0;
const ParamInfoList allOutParams = getAllOutParams(p, typeCtx);
if(allOutParams.size() == 1)
{
@@ -750,16 +740,31 @@ SwiftGenerator::writeOpDocSummary(IceUtilInternal::Output& out,
else if(allOutParams.size() > 1)
{
out << nl << "///";
- out << nl << "/// - returns: a tuple with the following fields:";
- for(ParamInfoList::const_iterator q = allOutParams.begin(); q != allOutParams.end(); ++q)
+ out << nl << "/// - returns: `" << operationReturnType(p, typeCtx) << "`:";
+ if(p->returnType())
{
+ ParamInfo ret = allOutParams.back();
out << nl << "///";
- out << nl << "/// - " << q->name << ": `" << q->typeStr << "`";
- map<string, StringList>::const_iterator r = doc.params.find(q->name);
- if(r != doc.params.end() && !r->second.empty())
+ out << nl << "/// - " << ret.name << ": `" << ret.typeStr << "`";
+ if(!doc.returns.empty())
{
out << " - ";
- writeDocLines(out, r->second, false);
+ writeDocLines(out, doc.returns, false);
+ }
+ }
+
+ for(ParamInfoList::const_iterator q = allOutParams.begin(); q != allOutParams.end(); ++q)
+ {
+ if(q->param != 0)
+ {
+ out << nl << "///";
+ out << nl << "/// - " << q->name << ": `" << q->typeStr << "`";
+ map<string, StringList>::const_iterator r = doc.params.find(q->name);
+ if(r != doc.params.end() && !r->second.empty())
+ {
+ out << " - ";
+ writeDocLines(out, r->second, false);
+ }
}
}
}
@@ -1943,7 +1948,7 @@ SwiftGenerator::operationReturnIsTuple(const OperationPtr& op)
}
string
-SwiftGenerator::operationReturnType(const OperationPtr& op)
+SwiftGenerator::operationReturnType(const OperationPtr& op, int typeCtx)
{
ostringstream os;
bool returnIsTuple = operationReturnIsTuple(op);
@@ -1960,7 +1965,7 @@ SwiftGenerator::operationReturnType(const OperationPtr& op)
{
os << paramLabel("returnValue", outParams) << ": ";
}
- os << typeToString(returnType, op, op->getMetaData(), op->returnIsOptional());
+ os << typeToString(returnType, op, op->getMetaData(), op->returnIsOptional(), typeCtx);
}
for(ParamDeclList::const_iterator q = outParams.begin(); q != outParams.end(); ++q)
@@ -1975,7 +1980,7 @@ SwiftGenerator::operationReturnType(const OperationPtr& op)
os << (*q)->name() << ": ";
}
- os << typeToString((*q)->type(), *q, (*q)->getMetaData(), (*q)->optional());
+ os << typeToString((*q)->type(), *q, (*q)->getMetaData(), (*q)->optional(), typeCtx);
}
if(returnIsTuple)
diff --git a/cpp/src/slice2swift/SwiftUtil.h b/cpp/src/slice2swift/SwiftUtil.h
index 4f9330f13fe..3a4b338fba3 100644
--- a/cpp/src/slice2swift/SwiftUtil.h
+++ b/cpp/src/slice2swift/SwiftUtil.h
@@ -75,7 +75,7 @@ protected:
void writeMemberDoc(IceUtilInternal::Output&, const DataMemberPtr&);
std::string paramLabel(const std::string&, const ParamDeclList&);
- std::string operationReturnType(const OperationPtr&);
+ std::string operationReturnType(const OperationPtr&, int typeCtx = 0);
bool operationReturnIsTuple(const OperationPtr&);
std::string operationReturnDeclaration(const OperationPtr&);
std::string operationInParamsDeclaration(const OperationPtr&);