diff options
Diffstat (limited to 'cpp/src/slice2swift/Gen.cpp')
-rw-r--r-- | cpp/src/slice2swift/Gen.cpp | 46 |
1 files changed, 37 insertions, 9 deletions
diff --git a/cpp/src/slice2swift/Gen.cpp b/cpp/src/slice2swift/Gen.cpp index 31b05819d5f..20b3125ea13 100644 --- a/cpp/src/slice2swift/Gen.cpp +++ b/cpp/src/slice2swift/Gen.cpp @@ -123,6 +123,15 @@ Gen::ImportVisitor::visitModuleStart(const ModulePtr& p) _imports.push_back("Ice"); } } + + // + // Add PromiseKit import for interfaces and local interfaces which contain "async-oneway" metadata + // + if(p->hasNonLocalInterfaceDefs() || p->hasLocalClassDefsWithAsync()) + { + _imports.push_back("PromiseKit"); + } + return true; } @@ -166,15 +175,6 @@ Gen::ImportVisitor::visitClassDefStart(const ClassDefPtr& p) } } - if(!p->isLocal() && p->isInterface()) - { - const string promiseKit = "PromiseKit"; - if(find(_imports.begin(), _imports.end(), promiseKit) == _imports.end()) - { - _imports.push_back(promiseKit); - } - } - return false; } @@ -1323,4 +1323,32 @@ Gen::LocalObjectVisitor::visitOperation(const OperationPtr& p) out << epar; } } + + if(p->hasMetaData("async-oneway")) + { + out << sp; + out << nl << "func " << name << "Async"; + out << spar; + for(ParamDeclList::const_iterator i = inParams.begin(); i != inParams.end(); ++i) + { + ParamDeclPtr param = *i; + TypePtr type = param->type(); + ostringstream s; + if(inParams.size() == 1) + { + s << "_ "; + } + s << fixIdent(param->name()) << ": " + << typeToString(type, p, param->getMetaData(), param->optional(), typeCtx); + out << s.str(); + } + out << "sent: ((Bool) -> Void)?"; + out << "sentOn: Dispatch.DispatchQueue?"; + out << epar; + + out << " -> "; + + assert(!ret && outParams.empty()); + out << "PromiseKit.Promise<Void>"; + } } |