diff options
author | Joe George <joe@zeroc.com> | 2019-03-19 17:14:21 -0400 |
---|---|---|
committer | Joe George <joe@zeroc.com> | 2019-03-19 17:14:21 -0400 |
commit | 36f218d195429160d334c01ad3e2e9d0fd9a357c (patch) | |
tree | 220ce8745c2fefb710cb85d6ae9ed87aa8bac06b /cpp/src/slice2swift/Gen.cpp | |
parent | Logger simplifications (diff) | |
download | ice-36f218d195429160d334c01ad3e2e9d0fd9a357c.tar.bz2 ice-36f218d195429160d334c01ad3e2e9d0fd9a357c.tar.xz ice-36f218d195429160d334c01ad3e2e9d0fd9a357c.zip |
Add async-oneway
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>"; + } } |