summaryrefslogtreecommitdiff
path: root/cpp/src/slice2cpp
diff options
context:
space:
mode:
authorBernard Normier <bernard@zeroc.com>2016-08-30 11:46:50 -0400
committerBernard Normier <bernard@zeroc.com>2016-08-30 11:46:50 -0400
commit91669a597c47aa8dbd0d8ec2f144de430cce2e53 (patch)
treef35fb6ad0b69deb2c016c8ce284bf13a4650e41f /cpp/src/slice2cpp
parentFix ICE-7302 - Java Ice/exceptions amd server does not use AMDThrowerI (diff)
downloadice-91669a597c47aa8dbd0d8ec2f144de430cce2e53.tar.bz2
ice-91669a597c47aa8dbd0d8ec2f144de430cce2e53.tar.xz
ice-91669a597c47aa8dbd0d8ec2f144de430cce2e53.zip
C++11 mapping: moved OpNameResult from Disp to Value class
Diffstat (limited to 'cpp/src/slice2cpp')
-rw-r--r--cpp/src/slice2cpp/Gen.cpp101
1 files changed, 61 insertions, 40 deletions
diff --git a/cpp/src/slice2cpp/Gen.cpp b/cpp/src/slice2cpp/Gen.cpp
index 8ffd072bddc..1ad5a34660c 100644
--- a/cpp/src/slice2cpp/Gen.cpp
+++ b/cpp/src/slice2cpp/Gen.cpp
@@ -554,6 +554,62 @@ resultStructName(const string& name, const string& scope = "")
return stName;
}
+void
+emitOpNameResult(IceUtilInternal::Output& H, const OperationPtr& p, int useWstring)
+{
+ string name = p->name();
+
+ TypePtr ret = p->returnType();
+ string retS = returnTypeToString(ret, p->returnIsOptional(), p->getMetaData(), useWstring | TypeContextCpp11);
+
+ ParamDeclList outParams;
+ ParamDeclList paramList = p->parameters();
+
+ for(ParamDeclList::iterator q = paramList.begin(); q != paramList.end(); ++q)
+ {
+ if((*q)->isOutParam())
+ {
+ outParams.push_back(*q);
+ }
+ }
+
+ if((outParams.size() > 1) || (ret && outParams.size() > 0))
+ {
+ //
+ // Generate OpNameResult struct
+ //
+ list<string> dataMembers;
+ string returnValueS = "returnValue";
+
+ for(ParamDeclList::iterator q = outParams.begin(); q != outParams.end(); ++q)
+ {
+ string typeString = typeToString((*q)->type(), (*q)->optional(), (*q)->getMetaData(),
+ useWstring | TypeContextCpp11);
+
+ dataMembers.push_back(typeString + " " + fixKwd((*q)->name()));
+
+ if((*q)->name() == "returnValue")
+ {
+ returnValueS = "_returnValue";
+ }
+ }
+
+ if(ret)
+ {
+ dataMembers.push_front(retS + " " + returnValueS);
+ }
+
+ H << sp;
+ H << nl << "struct " << resultStructName(name);
+ H << sb;
+ for(list<string>::const_iterator q = dataMembers.begin(); q != dataMembers.end(); ++q)
+ {
+ H << nl << *q << ";";
+ }
+ H << eb << ";";
+ }
+}
+
string
condMove(bool moveIt, const string& str)
{
@@ -5991,8 +6047,7 @@ Slice::Gen::Cpp11ProxyVisitor::visitOperation(const OperationPtr& p)
}
else
{
- string suffix = cl->isInterface() ? "" : "Disp";
- string resultScope = fixKwd(cl->scope() + cl->name() + suffix);
+ string resultScope = fixKwd(cl->scope() + cl->name());
futureT = resultStructName(name, resultScope);
}
@@ -6810,8 +6865,6 @@ Slice::Gen::Cpp11InterfaceVisitor::visitClassDefStart(const ClassDefPtr& p)
{
base = bases.front();
}
- DataMemberList dataMembers = p->dataMembers();
- DataMemberList allDataMembers = p->allDataMembers();
H << sp << nl << "class " << _dllExport << name << " : ";
H.useCurrentPosAsIndent();
@@ -7049,43 +7102,11 @@ Slice::Gen::Cpp11InterfaceVisitor::visitOperation(const OperationPtr& p)
args += condMove(isMovable(type) && !isOutParam, paramName);
}
- if((outParams.size() > 1) || (ret && outParams.size() > 0))
+ if(cl->isInterface())
{
- //
- // Generate OpNameResult struct
- //
- list<string> dataMembers;
- string returnValueS = "returnValue";
-
- for(ParamDeclList::iterator q = outParams.begin(); q != outParams.end(); ++q)
- {
- string typeString = typeToString((*q)->type(), (*q)->optional(), (*q)->getMetaData(),
- _useWstring | TypeContextCpp11);
-
- dataMembers.push_back(typeString + " " + fixKwd((*q)->name()));
-
- if((*q)->name() == "returnValue")
- {
- returnValueS = "_returnValue";
- }
- }
-
- if(ret)
- {
- dataMembers.push_front(retS + " " + returnValueS);
- }
-
- H << sp;
- H << nl << "struct " << resultStructName(name);
- H << sb;
- for(list<string>::const_iterator q = dataMembers.begin(); q != dataMembers.end(); ++q)
- {
- H << nl << *q << ";";
- }
- H << eb << ";";
+ emitOpNameResult(H, p, _useWstring);
}
-
if(!paramList.empty())
{
params += ", ";
@@ -7497,11 +7518,11 @@ Slice::Gen::Cpp11ValueVisitor::visitStructStart(const StructPtr&)
}
void
-Slice::Gen::Cpp11ValueVisitor::visitOperation(const OperationPtr&)
+Slice::Gen::Cpp11ValueVisitor::visitOperation(const OperationPtr& p)
{
+ emitOpNameResult(H, p, _useWstring);
}
-
bool
Slice::Gen::Cpp11ObjectVisitor::emitVirtualBaseInitializers(const ClassDefPtr& derived, const ClassDefPtr& base)
{