diff options
author | Bernard Normier <bernard@zeroc.com> | 2016-06-09 22:32:22 -0400 |
---|---|---|
committer | Bernard Normier <bernard@zeroc.com> | 2016-06-09 22:33:32 -0400 |
commit | 69e99559db0bd9cfa076b65360af21c0ab417a12 (patch) | |
tree | 8961f24ff3e5dbaefcbe65c9905f460ce8eb0f3c /cpp/src/slice2cpp | |
parent | ICE-7166 - Change php library name to IcePHP.so on OS X (diff) | |
download | ice-69e99559db0bd9cfa076b65360af21c0ab417a12.tar.bz2 ice-69e99559db0bd9cfa076b65360af21c0ab417a12.tar.xz ice-69e99559db0bd9cfa076b65360af21c0ab417a12.zip |
Renamed C++11 AMI/AMD suffix: _async to Async
Diffstat (limited to 'cpp/src/slice2cpp')
-rw-r--r-- | cpp/src/slice2cpp/Gen.cpp | 106 | ||||
-rw-r--r-- | cpp/src/slice2cpp/Gen.h | 2 |
2 files changed, 73 insertions, 35 deletions
diff --git a/cpp/src/slice2cpp/Gen.cpp b/cpp/src/slice2cpp/Gen.cpp index 852b2fa81fc..28899335797 100644 --- a/cpp/src/slice2cpp/Gen.cpp +++ b/cpp/src/slice2cpp/Gen.cpp @@ -15,6 +15,7 @@ #include <IceUtil/Iterator.h> #include <IceUtil/InputUtil.h> #include <IceUtil/StringConverter.h> +#include <IceUtil/StringUtil.h> #include <Slice/Checksum.h> #include <Slice/FileTracker.h> @@ -452,6 +453,17 @@ writeDataMemberInitializers(IceUtilInternal::Output& C, const DataMemberList& me } } +string +resultStructName(const string& name, const string& scope = "") +{ + string stName = IceUtilInternal::toUpper(name.substr(0, 1)) + name.substr(1) + "Result"; + if(!scope.empty()) + { + stName = scope + "::" + stName; + } + return stName; +} + } Slice::Gen::Gen(const string& base, const string& headerExtension, const string& sourceExtension, @@ -788,9 +800,6 @@ Slice::Gen::generate(const UnitPtr& p) Cpp11TypesVisitor typesVisitor(H, C, _dllExport); p->visit(&typesVisitor, false); - Cpp11ProxyVisitor proxyVisitor(H, C, _dllExport); - p->visit(&proxyVisitor, false); - Cpp11LocalObjectVisitor localObjectVisitor(H, C, _dllExport); p->visit(&localObjectVisitor, false); @@ -800,6 +809,9 @@ Slice::Gen::generate(const UnitPtr& p) Cpp11ValueVisitor valueVisitor(H, C, _dllExport); p->visit(&valueVisitor, false); + Cpp11ProxyVisitor proxyVisitor(H, C, _dllExport); + p->visit(&proxyVisitor, false); + Cpp11StreamVisitor streamVisitor(H, C, _dllExport); p->visit(&streamVisitor, false); @@ -5586,8 +5598,8 @@ Slice::Gen::Cpp11DeclVisitor::visitOperation(const OperationPtr& p) } } -Slice::Gen::Cpp11TypesVisitor::Cpp11TypesVisitor(Output& h, Output& c, const string& dllExport) : - H(h), C(c), _dllExport(dllExport), _doneStaticSymbol(false), _useWstring(false) +Slice::Gen::Cpp11TypesVisitor::Cpp11TypesVisitor(Output& h, Output& c, const string& dllExport, int useWstring) : + H(h), C(c), _dllExport(dllExport), _doneStaticSymbol(false), _useWstring(useWstring) { } @@ -6264,25 +6276,12 @@ Slice::Gen::Cpp11ProxyVisitor::visitOperation(const OperationPtr& p) } else { - futureT = "Result_" + name; - } - - if(lambdaOutParams.size() > 1) - { - // We need to generate a Result_ struct. - H << sp; - H << nl << "struct Result_" << name; - H << sb; - for(ParamDeclList::const_iterator q = outParams.begin(); q != outParams.end(); ++q) - { - string typeString = typeToString((*q)->type(), (*q)->optional(), (*q)->getMetaData(), _useWstring, true); - H << nl << typeString << " " << fixKwd((*q)->name()) << ";"; - } - if(ret) + string resultScope = cl->scope() + cl->name(); + if(!cl->isInterface()) { - H << nl << retS << " " << returnValueS << ";"; + resultScope += "Disp"; } - H << eb << ";"; + futureT = resultStructName(name, resultScope); } string deprecateSymbol = getDeprecateSymbol(p, cl); @@ -6311,11 +6310,11 @@ Slice::Gen::Cpp11ProxyVisitor::visitOperation(const OperationPtr& p) } if(futureT == "void") { - H << nl << "makePromiseOutgoing"; + H << "makePromiseOutgoing"; } else { - H << nl << "makePromiseOutgoing<" << futureT << ">"; + H << "makePromiseOutgoing<" << futureT << ">"; } H << spar << "true, this" << string("&" + scoped + "__" + name); for(ParamDeclList::const_iterator q = inParams.begin(); q != inParams.end(); ++q) @@ -6356,7 +6355,7 @@ Slice::Gen::Cpp11ProxyVisitor::visitOperation(const OperationPtr& p) // H << sp; H << nl << "::std::function<void ()>"; - H << nl << name << "_async("; + H << nl << name << "Async("; H.useCurrentPosAsIndent(); if(!lambdaParamsDecl.empty()) { @@ -6423,7 +6422,7 @@ Slice::Gen::Cpp11ProxyVisitor::visitOperation(const OperationPtr& p) // H << sp; H << nl << "template<template<typename> class P = ::std::promise>"; - H << nl << deprecateSymbol << "auto " << name << "_async" << spar << futureParamsDecl; + H << nl << deprecateSymbol << "auto " << name << "Async" << spar << futureParamsDecl; H << "const ::Ice::Context& __ctx = Ice::noExplicitContext" << epar; H.inc(); H << nl << "-> decltype(::std::declval<P<" << futureT << ">>().get_future())"; @@ -7035,7 +7034,7 @@ Slice::Gen::Cpp11LocalObjectVisitor::visitOperation(const OperationPtr& p) H << sp; H << nl << "virtual ::std::function<void ()>"; - H << nl << name << "_async("; + H << nl << name << "Async("; H.useCurrentPosAsIndent(); for(vector<string>::const_iterator i = paramsDeclAMI.begin(); i != paramsDeclAMI.end(); ++i) { @@ -7051,7 +7050,7 @@ Slice::Gen::Cpp11LocalObjectVisitor::visitOperation(const OperationPtr& p) H << sp; H << nl << "template<template<typename> class P = ::std::promise>"; - H << nl << deprecateSymbol << "auto " << name << "_async" << spar << paramsDeclAMI << epar; + H << nl << deprecateSymbol << "auto " << name << "Async" << spar << paramsDeclAMI << epar; H.inc(); H << nl << "-> decltype(::std::declval<P<bool>>().get_future())"; H.dec(); @@ -7059,7 +7058,7 @@ Slice::Gen::Cpp11LocalObjectVisitor::visitOperation(const OperationPtr& p) H << nl << "using Promise = P<bool>;"; H << nl << "auto __promise = ::std::make_shared<Promise>();"; - H << nl << name << "_async("; + H << nl << name << "Async("; H.useCurrentPosAsIndent(); for(vector<string>::const_iterator i = paramsDeclAMI.begin(); i != paramsDeclAMI.end(); ++i) { @@ -7333,7 +7332,7 @@ Slice::Gen::Cpp11InterfaceVisitor::visitOperation(const OperationPtr& p) ParamDeclList inParams; ParamDeclList outParams; ParamDeclList paramList = p->parameters(); - vector< string> outDecls; + vector<string> outDecls; for(ParamDeclList::iterator q = paramList.begin(); q != paramList.end(); ++q) { string paramName = fixKwd(string(paramPrefix) + (*q)->name()); @@ -7367,6 +7366,45 @@ Slice::Gen::Cpp11InterfaceVisitor::visitOperation(const OperationPtr& p) args += (isMovable(type) && !isOutParam) ? ("::std::move(" + paramName + ")") : paramName; } + if((outParams.size() > 1) || (ret && outParams.size() > 0)) + { + // + // Generate OpNameResult struct + // + StructPtr st = cl->createStruct(resultStructName(name), false, Slice::Dummy); + st->setMetaData(cl->getMetaData()); + + if(ret) + { + string returnValue = "returnValue"; + for(ParamDeclList::iterator q = outParams.begin(); q != outParams.end(); ++q) + { + if((*q)->name() == returnValue) + { + returnValue = string("_") + returnValue; + break; + } + } + DataMemberPtr dm = + st->createDataMember(returnValue, ret, p->returnIsOptional(), p->returnTag(), 0, "", "", false); + dm->setMetaData(p->getMetaData()); + } + + for(ParamDeclList::iterator q = outParams.begin(); q != outParams.end(); ++q) + { + DataMemberPtr dm = + st->createDataMember((*q)->name(), (*q)->type(), (*q)->optional(), (*q)->tag(), 0, "", ""); + dm->setMetaData((*q)->getMetaData()); + } + + // + // Generate C++ struct + // + Cpp11TypesVisitor typesVisitor(H, C, _dllExport, _useWstring); + st->visit(&typesVisitor, false); + } + + if(!paramList.empty()) { params += ", "; @@ -7448,7 +7486,7 @@ Slice::Gen::Cpp11InterfaceVisitor::visitOperation(const OperationPtr& p) } else { - H << nl << deprecateSymbol << "virtual void " << name << "_async("; + H << nl << deprecateSymbol << "virtual void " << name << "Async("; H.useCurrentPosAsIndent(); H << paramsAMD; if(!paramsAMD.empty()) @@ -7563,7 +7601,7 @@ Slice::Gen::Cpp11InterfaceVisitor::visitOperation(const OperationPtr& p) C << nl << "try"; C << sb; - C << nl << name << "_async("; + C << nl << name << "Async("; C.useCurrentPosAsIndent(); if(!argsAMD.empty()) { @@ -8284,7 +8322,7 @@ Slice::Gen::Cpp11ImplVisitor::visitClassDefStart(const ClassDefPtr& p) string responseParams; string responseParamsDecl; - H << sp << nl << "virtual void " << opName << "_async("; + H << sp << nl << "virtual void " << opName << "Async("; H.useCurrentPosAsIndent(); for(ParamDeclList::const_iterator q = inParams.begin(); q != inParams.end(); ++q) { @@ -8323,7 +8361,7 @@ Slice::Gen::Cpp11ImplVisitor::visitClassDefStart(const ClassDefPtr& p) H << nl << "const Ice::Current&)" << isConst << ';'; H.restoreIndent(); - C << sp << nl << "void" << nl << scope << name << "I::" << opName << "_async("; + C << sp << nl << "void" << nl << scope << name << "I::" << opName << "Async("; C.useCurrentPosAsIndent(); for(ParamDeclList::const_iterator q = inParams.begin(); q != inParams.end(); ++q) { diff --git a/cpp/src/slice2cpp/Gen.h b/cpp/src/slice2cpp/Gen.h index 114f13781c0..e1d00e60976 100644 --- a/cpp/src/slice2cpp/Gen.h +++ b/cpp/src/slice2cpp/Gen.h @@ -369,7 +369,7 @@ private: { public: - Cpp11TypesVisitor(::IceUtilInternal::Output&, ::IceUtilInternal::Output&, const std::string&); + Cpp11TypesVisitor(::IceUtilInternal::Output&, ::IceUtilInternal::Output&, const std::string&, int = 0); virtual bool visitModuleStart(const ModulePtr&); virtual void visitModuleEnd(const ModulePtr&); |