summaryrefslogtreecommitdiff
path: root/cpp/src/slice2cpp
diff options
context:
space:
mode:
authorJoe George <joe@zeroc.com>2015-12-18 14:48:29 -0500
committerJoe George <joe@zeroc.com>2015-12-18 14:48:29 -0500
commit3c07e69ea17223c7d5a8449ec9bb75d9bba40e07 (patch)
tree6101376459c3f62f9fe4dcbb7819729667209191 /cpp/src/slice2cpp
parentC++11 Ice/ami test hangs on OS X (diff)
downloadice-3c07e69ea17223c7d5a8449ec9bb75d9bba40e07.tar.bz2
ice-3c07e69ea17223c7d5a8449ec9bb75d9bba40e07.tar.xz
ice-3c07e69ea17223c7d5a8449ec9bb75d9bba40e07.zip
ICE-6903 - "async" metadata changes
- Rename "async" metadata to "async-oneway" - Update C++11 mapping for "async-oneway".
Diffstat (limited to 'cpp/src/slice2cpp')
-rw-r--r--cpp/src/slice2cpp/Gen.cpp68
1 files changed, 39 insertions, 29 deletions
diff --git a/cpp/src/slice2cpp/Gen.cpp b/cpp/src/slice2cpp/Gen.cpp
index e34d25b5361..9b52d739bf2 100644
--- a/cpp/src/slice2cpp/Gen.cpp
+++ b/cpp/src/slice2cpp/Gen.cpp
@@ -662,7 +662,7 @@ Slice::Gen::generate(const UnitPtr& p)
ImplVisitor implVisitor(implH, implC, _dllExport);
p->visit(&implVisitor, false);
}
-
+
generateChecksumMap(p);
}
H << sp;
@@ -726,7 +726,7 @@ Slice::Gen::generate(const UnitPtr& p)
}*/
generateChecksumMap(p);
-
+
H << sp;
H.zeroIndent();
H << nl << "#endif";
@@ -3797,7 +3797,7 @@ Slice::Gen::ObjectVisitor::visitOperation(const OperationPtr& p)
C << eb;
}
- if(cl->isLocal() && (cl->hasMetaData("async") || p->hasMetaData("async")))
+ if(cl->isLocal() && (cl->hasMetaData("async-oneway") || p->hasMetaData("async-oneway")))
{
vector<string> paramsDeclAMI;
vector<string> outParamsDeclAMI;
@@ -4121,7 +4121,7 @@ Slice::Gen::AsyncCallbackVisitor::AsyncCallbackVisitor(Output& h, Output&, const
bool
Slice::Gen::AsyncCallbackVisitor::visitModuleStart(const ModulePtr& p)
{
- if(!p->hasNonLocalClassDefs() && !p->hasContentsWithMetaData("async"))
+ if(!p->hasNonLocalClassDefs() && !p->hasContentsWithMetaData("async-oneway"))
{
return false;
}
@@ -4159,7 +4159,7 @@ Slice::Gen::AsyncCallbackVisitor::visitOperation(const OperationPtr& p)
{
ClassDefPtr cl = ClassDefPtr::dynamicCast(p->container());
- if(cl->isLocal() && !(cl->hasMetaData("async") || p->hasMetaData("async")))
+ if(cl->isLocal() && !(cl->hasMetaData("async-oneway") || p->hasMetaData("async-oneway")))
{
return;
}
@@ -7677,7 +7677,7 @@ Slice::Gen::Cpp11LocalObjectVisitor::visitOperation(const OperationPtr& p)
H << nl << deprecateSymbol << "virtual " << retS << ' ' << fixKwd(name) << params
<< (isConst ? " const" : "") << " = 0;";
- if(cl->hasMetaData("async") || p->hasMetaData("async"))
+ if(cl->hasMetaData("async-oneway") || p->hasMetaData("async-oneway"))
{
vector<string> paramsDeclAMI;
vector<string> outParamsDeclAMI;
@@ -7689,24 +7689,11 @@ Slice::Gen::Cpp11LocalObjectVisitor::visitOperation(const OperationPtr& p)
StringList metaData = (*r)->getMetaData();
string typeString;
- if((*r)->isOutParam())
- {
- typeString = outputTypeToString((*r)->type(), (*r)->optional(), metaData,
- _useWstring | TypeContextAMIEnd | TypeContextLocalOperation, true);
- }
- else
- {
- typeString = inputTypeToString((*r)->type(), (*r)->optional(), metaData, _useWstring | TypeContextLocalOperation, true);
- }
-
if(!(*r)->isOutParam())
{
+ typeString = inputTypeToString((*r)->type(), (*r)->optional(), metaData, _useWstring | TypeContextLocalOperation, true);
paramsDeclAMI.push_back(typeString + ' ' + paramName);
}
- else
- {
- outParamsDeclAMI.push_back(typeString + ' ' + paramName);
- }
}
H << sp;
@@ -7721,19 +7708,42 @@ Slice::Gen::Cpp11LocalObjectVisitor::visitOperation(const OperationPtr& p)
{
H << nl;
}
- H << "::std::function<void (";
- for(vector<string>::const_iterator i = outParamsDeclAMI.begin(); i != outParamsDeclAMI.end();)
+ H << "::std::function<void (::std::exception_ptr)> exception,";
+ H << nl << "::std::function<void (bool)> sent) = 0;";
+ H.restoreIndent();
+
+ H << sp;
+ H << nl << "template<template<typename> class P = ::std::promise>";
+ H << nl << deprecateSymbol << "auto " << name << "_async" << spar << paramsDeclAMI << epar;
+ H.inc();
+ H << nl << "-> decltype(::std::declval<P<bool>>().get_future())";
+ H.dec();
+ H << sb;
+ H << nl << "using Promise = P<bool>;";
+ H << nl << "auto __promise = ::std::make_shared<Promise>();";
+
+ H << nl << name << "_async(";
+ H.useCurrentPosAsIndent();
+ for(vector<string>::const_iterator i = paramsDeclAMI.begin(); i != paramsDeclAMI.end(); ++i)
{
H << *i << ",";
- if(++i != outParamsDeclAMI.end())
- {
- H << " ";
- }
}
- H << ")>,";
- H << nl << "::std::function<void (::std::exception_ptr)> exception = nullptr,";
- H << nl << "::std::function<void (bool)> sent = nullptr) = 0;";
+ if(!paramsDeclAMI.empty())
+ {
+ H << nl;
+ }
+ H << "[__promise](::std::exception_ptr __ex)";
+ H << sb;
+ H << nl << "__promise->set_exception(::std::move(__ex));";
+ H << eb << ",";
+ H << nl << "[__promise](bool __b)";
+ H << sb;
+ H << nl << "__promise->set_value(__b);";
+ H << eb << ");";
H.restoreIndent();
+
+ H << nl << "return __promise->get_future();";
+ H << eb;
}
}