diff options
author | Jose <jose@zeroc.com> | 2016-07-22 20:52:15 +0200 |
---|---|---|
committer | Jose <jose@zeroc.com> | 2016-07-22 20:52:15 +0200 |
commit | 506915e2bc9ef6c15e6fd66ac0bd9c693180c914 (patch) | |
tree | 12c66ab3413b4de96483c280c0e995bfd2d68658 /cpp/src/slice2cs/CsUtil.cpp | |
parent | CSharp AMD mapping update (diff) | |
download | ice-506915e2bc9ef6c15e6fd66ac0bd9c693180c914.tar.bz2 ice-506915e2bc9ef6c15e6fd66ac0bd9c693180c914.tar.xz ice-506915e2bc9ef6c15e6fd66ac0bd9c693180c914.zip |
slice2cs updates for new AMD mapping
Diffstat (limited to 'cpp/src/slice2cs/CsUtil.cpp')
-rw-r--r-- | cpp/src/slice2cs/CsUtil.cpp | 68 |
1 files changed, 68 insertions, 0 deletions
diff --git a/cpp/src/slice2cs/CsUtil.cpp b/cpp/src/slice2cs/CsUtil.cpp index b3b1cf9718a..590ceab2345 100644 --- a/cpp/src/slice2cs/CsUtil.cpp +++ b/cpp/src/slice2cs/CsUtil.cpp @@ -11,6 +11,7 @@ #include <DotNetNames.h> #include <Slice/Util.h> #include <IceUtil/Functional.h> +#include <IceUtil/StringUtil.h> #include <sys/types.h> #include <sys/stat.h> @@ -352,6 +353,73 @@ Slice::CsGenerator::typeToString(const TypePtr& type, bool optional) return "???"; } +ParamDeclList +Slice::CsGenerator::getInParams(const ParamDeclList& params) +{ + ParamDeclList inParams; + for (ParamDeclList::const_iterator i = params.begin(); i != params.end(); ++i) + { + if (!(*i)->isOutParam()) + { + inParams.push_back(*i); + } + } + return inParams; +} + +ParamDeclList +Slice::CsGenerator::getOutParams(const ParamDeclList& params) +{ + ParamDeclList outParams; + for (ParamDeclList::const_iterator i = params.begin(); i != params.end(); ++i) + { + if ((*i)->isOutParam()) + { + outParams.push_back(*i); + } + } + return outParams; +} + +string +Slice::CsGenerator::resultStructName(const string& className, const string& opName, const string& scope) +{ + ostringstream s; + s << scope + << className + << "_" + << IceUtilInternal::toUpper(opName.substr(0, 1)) + << opName.substr(1) + << "Result"; + return s.str(); +} + +string +Slice::CsGenerator::asyncResultType(const OperationPtr& op, const string& type) +{ + string t = type; + ParamDeclList outParams = getOutParams(op->parameters()); + if (op->returnType() || !outParams.empty()) + { + t += "<"; + if (outParams.empty()) + { + t += typeToString(op->returnType(), op->returnIsOptional()); + } + else if (op->returnType() || outParams.size() > 1) + { + ClassDefPtr cl = ClassDefPtr::dynamicCast(op->container()); + t += resultStructName(cl->name(), op->name(), fixId(cl->scope())); + } + else + { + t += typeToString(outParams.front()->type(), outParams.front()->optional()); + } + t += ">"; + } + return t; +} + bool Slice::CsGenerator::isValueType(const TypePtr& type) { |