summaryrefslogtreecommitdiff
path: root/cpp/src/slice2cs
diff options
context:
space:
mode:
authorJose <jose@zeroc.com>2016-07-22 20:52:15 +0200
committerJose <jose@zeroc.com>2016-07-22 20:52:15 +0200
commit506915e2bc9ef6c15e6fd66ac0bd9c693180c914 (patch)
tree12c66ab3413b4de96483c280c0e995bfd2d68658 /cpp/src/slice2cs
parentCSharp AMD mapping update (diff)
downloadice-506915e2bc9ef6c15e6fd66ac0bd9c693180c914.tar.bz2
ice-506915e2bc9ef6c15e6fd66ac0bd9c693180c914.tar.xz
ice-506915e2bc9ef6c15e6fd66ac0bd9c693180c914.zip
slice2cs updates for new AMD mapping
Diffstat (limited to 'cpp/src/slice2cs')
-rw-r--r--cpp/src/slice2cs/CsUtil.cpp68
-rw-r--r--cpp/src/slice2cs/CsUtil.h5
-rw-r--r--cpp/src/slice2cs/Gen.cpp1590
-rw-r--r--cpp/src/slice2cs/Gen.h49
-rw-r--r--cpp/src/slice2cs/Main.cpp6
5 files changed, 703 insertions, 1015 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)
{
diff --git a/cpp/src/slice2cs/CsUtil.h b/cpp/src/slice2cs/CsUtil.h
index 2401ae1db84..b782e5ef4fc 100644
--- a/cpp/src/slice2cs/CsUtil.h
+++ b/cpp/src/slice2cs/CsUtil.h
@@ -33,6 +33,11 @@ public:
static void validateMetaData(const UnitPtr&);
protected:
+
+ static ParamDeclList getInParams(const ParamDeclList&);
+ static ParamDeclList getOutParams(const ParamDeclList&);
+ static std::string resultStructName(const std::string& className, const std::string& opName, const std::string& scope = "");
+ static std::string asyncResultType(const OperationPtr&, const std::string& t = "_System.Threading.Tasks.Task");
static std::string fixId(const std::string&, int = 0, bool = false);
static std::string fixId(const ContainedPtr&, int = 0, bool = false);
static std::string getOptionalFormat(const TypePtr&);
diff --git a/cpp/src/slice2cs/Gen.cpp b/cpp/src/slice2cs/Gen.cpp
index 2fca1a449b1..63c361c3063 100644
--- a/cpp/src/slice2cs/Gen.cpp
+++ b/cpp/src/slice2cs/Gen.cpp
@@ -145,33 +145,6 @@ emitDeprecate(const ContainedPtr& p1, const ContainedPtr& p2, Output& out, const
}
}
-ParamDeclList
-getInParams(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
-getOutParams(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
getAsyncTaskParamName(ParamDeclList params, const string& name)
@@ -187,19 +160,6 @@ getAsyncTaskParamName(ParamDeclList params, const string& name)
}
string
-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
resultStructReturnValueName(ParamDeclList outParams)
{
for(ParamDeclList::const_iterator i = outParams.begin(); i != outParams.end(); ++i)
@@ -214,9 +174,8 @@ resultStructReturnValueName(ParamDeclList outParams)
}
-Slice::CsVisitor::CsVisitor(Output& out, bool compat) :
- _out(out),
- _compat(compat)
+Slice::CsVisitor::CsVisitor(Output& out) :
+ _out(out)
{
}
@@ -232,12 +191,16 @@ Slice::CsVisitor::writeMarshalUnmarshalParams(const ParamDeclList& params, const
string paramPrefix = "";
string returnValueS = "ret__";
- if(!marshal && op)
+ if(op)
{
- if((op->returnType() && !params.empty()) || params.size() > 1)
+ const bool amd = ClassDefPtr::dynamicCast(op->container())->hasMetaData("amd") || op->hasMetaData("amd");
+ if((amd && marshal) || !marshal)
{
- paramPrefix = "ret__.";
- returnValueS = resultStructReturnValueName(getOutParams(op->parameters()));
+ if((op->returnType() && !params.empty()) || params.size() > 1)
+ {
+ paramPrefix = "ret__.";
+ returnValueS = resultStructReturnValueName(getOutParams(op->parameters()));
+ }
}
}
@@ -445,46 +408,21 @@ Slice::CsVisitor::writeInheritedOperations(const ClassDefPtr& p)
}
allOps.sort();
allOps.unique();
- for(OperationList::const_iterator op = allOps.begin(); op != allOps.end(); ++op)
+ for(OperationList::const_iterator i = allOps.begin(); i != allOps.end(); ++i)
{
- ClassDefPtr containingClass = ClassDefPtr::dynamicCast((*op)->container());
- bool amd = containingClass->hasMetaData("amd") || (*op)->hasMetaData("amd");
- string name = fixId((*op)->name(), DotNet::ICloneable, true);
- if(!amd)
+ ClassDefPtr containingClass = ClassDefPtr::dynamicCast((*i)->container());
+ if(containingClass->hasMetaData("amd") || (*i)->hasMetaData("amd"))
{
- vector<string> params = getParams(*op);
- vector<string> args = getArgs(*op);
- string retS = typeToString((*op)->returnType(), (*op)->returnIsOptional());
-
- _out << sp << nl << "public " << retS << ' ' << name << spar << params << epar;
- _out << sb;
- _out << nl;
- if((*op)->returnType())
- {
- _out << "return ";
- }
- _out << name << spar << args << "Ice.ObjectImpl.defaultCurrent" << epar << ';';
- _out << eb;
-
- _out << sp << nl << "public abstract " << retS << ' ' << name << spar << params;
- if(!containingClass->isLocal())
- {
- _out << "Ice.Current current__";
- }
- _out << epar << ';';
+ _out << sp << nl << "public abstract void " << " " << (*i)->name() << "Async" << spar
+ << getParamsAsync(*i) << (asyncResultType(*i, "_System.Action") + " response_")
+ << "_System.Action<_System.Exception> exception_" << "Ice.Current current__ = null"
+ << epar << ';';
}
else
{
- vector<string> params = getParamsAsync(*op, true);
- vector<string> args = getArgsAsync(*op, true);
-
- _out << sp << nl << "public void " << name << "_async" << spar << params << epar;
- _out << sb;
- _out << nl << name << "_async" << spar << args << epar << ';';
- _out << eb;
-
- _out << sp << nl << "public abstract void " << name << "_async"
- << spar << params << "Ice.Current current__" << epar << ';';
+ _out << sp << nl << "public abstract " << typeToString((*i)->returnType(), (*i)->returnIsOptional()) << ' '
+ << fixId((*i)->name(), DotNet::ICloneable, true) << spar << getParams(*i)
+ << (containingClass->isLocal() ? "" : "Ice.Current current__ = null") << epar << ";";
}
}
@@ -544,7 +482,8 @@ Slice::CsVisitor::writeDispatchAndMarshalling(const ClassDefPtr& p)
_out << eb << ";";
string qualifier = "override ";
- if(!p->isInterface() && !hasBaseClass) {
+ if(!p->isInterface() && !hasBaseClass)
+ {
qualifier = "virtual ";
}
@@ -553,31 +492,16 @@ Slice::CsVisitor::writeDispatchAndMarshalling(const ClassDefPtr& p)
{
emitGeneratedCodeAttribute();
}
- _out << nl << "public " << qualifier << "bool ice_isA(string s)";
+ _out << nl << "public " << qualifier << "bool ice_isA(string s, Ice.Current current__ = null)";
_out << sb;
_out << nl << "return _System.Array.BinarySearch(ids__, s, IceUtilInternal.StringUtil.OrdinalStringComparer) >= 0;";
_out << eb;
- _out << sp;
- if(!p->isInterface())
- {
- emitGeneratedCodeAttribute();
- }
- _out << nl << "public " << qualifier << "bool ice_isA(string s, Ice.Current current__)";
- _out << sb;
- _out << nl << "return _System.Array.BinarySearch(ids__, s, IceUtilInternal.StringUtil.OrdinalStringComparer) >= 0;";
- _out << eb;
-
- if(!p->isInterface() && !hasBaseClass) {
- _out << sp;
- emitGeneratedCodeAttribute();
- _out << nl << "public virtual void ice_ping()";
- _out << sb;
- _out << eb;
-
+ if(!p->isInterface() && !hasBaseClass)
+ {
_out << sp;
emitGeneratedCodeAttribute();
- _out << nl << "public virtual void ice_ping(Ice.Current current__)";
+ _out << nl << "public virtual void ice_ping(Ice.Current current__ = null)";
_out << sb;
_out << eb;
}
@@ -587,7 +511,7 @@ Slice::CsVisitor::writeDispatchAndMarshalling(const ClassDefPtr& p)
{
emitGeneratedCodeAttribute();
}
- _out << nl << "public " << qualifier << "string[] ice_ids()";
+ _out << nl << "public " << qualifier << "string[] ice_ids(Ice.Current current__ = null)";
_out << sb;
_out << nl << "return ids__;";
_out << eb;
@@ -597,27 +521,7 @@ Slice::CsVisitor::writeDispatchAndMarshalling(const ClassDefPtr& p)
{
emitGeneratedCodeAttribute();
}
- _out << nl << "public " << qualifier << "string[] ice_ids(Ice.Current current__)";
- _out << sb;
- _out << nl << "return ids__;";
- _out << eb;
-
- _out << sp;
- if(!p->isInterface())
- {
- emitGeneratedCodeAttribute();
- }
- _out << nl << "public " << qualifier << "string ice_id()";
- _out << sb;
- _out << nl << "return ids__[" << scopedPos << "];";
- _out << eb;
-
- _out << sp;
- if(!p->isInterface())
- {
- emitGeneratedCodeAttribute();
- }
- _out << nl << "public " << qualifier << "string ice_id(Ice.Current current__)";
+ _out << nl << "public " << qualifier << "string ice_id(Ice.Current current__ = null)";
_out << sb;
_out << nl << "return ids__[" << scopedPos << "];";
_out << eb;
@@ -627,7 +531,8 @@ Slice::CsVisitor::writeDispatchAndMarshalling(const ClassDefPtr& p)
{
emitGeneratedCodeAttribute();
}
- if(p->isInterface() || hasBaseClass) {
+ if(p->isInterface() || hasBaseClass)
+ {
_out << nl << "public static new string ice_staticId()";
}
else
@@ -646,12 +551,14 @@ Slice::CsVisitor::writeDispatchAndMarshalling(const ClassDefPtr& p)
_out << sp << nl << "#region Operation dispatch";
}
- if(!p->isInterface() && !hasBaseClass) {
+ if(!p->isInterface() && !hasBaseClass)
+ {
_out << sp;
emitGeneratedCodeAttribute();
- _out << nl << "public virtual Ice.DispatchStatus ice_dispatch(Ice.Request request, Ice.DispatchInterceptorAsyncCallback cb)";
+ _out << nl << "public virtual Ice.DispatchStatus ice_dispatch(Ice.Request request, "
+ << "Ice.DispatchInterceptorAsyncCallback cb)";
_out << sb;
- _out << nl << "IceInternal.Incoming inc = (IceInternal.Incoming)request;";
+ _out << nl << "var inc = (IceInternal.Incoming)request;";
_out << nl << "if(cb != null)";
_out << sb;
_out << nl << "inc.push(cb);";
@@ -697,22 +604,8 @@ Slice::CsVisitor::writeDispatchAndMarshalling(const ClassDefPtr& p)
_out << sb;
TypePtr ret = op->returnType();
-
- ParamDeclList paramList = op->parameters();
- ParamDeclList inParams;
- ParamDeclList outParams;
-
- for(ParamDeclList::const_iterator pli = paramList.begin(); pli != paramList.end(); ++pli)
- {
- if((*pli)->isOutParam())
- {
- outParams.push_back(*pli);
- }
- else
- {
- inParams.push_back(*pli);
- }
- }
+ ParamDeclList inParams = getInParams(op->parameters());
+ ParamDeclList outParams = getOutParams(op->parameters());
_out << nl << "Ice.ObjectImpl.checkMode__(" << sliceModeToIceMode(op->mode()) << ", current__.mode);";
if(!inParams.empty())
@@ -720,7 +613,7 @@ Slice::CsVisitor::writeDispatchAndMarshalling(const ClassDefPtr& p)
//
// Unmarshal 'in' parameters.
//
- _out << nl << "Ice.InputStream is__ = inS__.startReadParams();";
+ _out << nl << "var is__ = inS__.startReadParams();";
for(ParamDeclList::const_iterator pli = inParams.begin(); pli != inParams.end(); ++pli)
{
string param = fixId((*pli)->name());
@@ -763,25 +656,25 @@ Slice::CsVisitor::writeDispatchAndMarshalling(const ClassDefPtr& p)
_out << nl << "inS__.readEmptyParams();";
}
- const bool amd = p->hasMetaData("amd") || op->hasMetaData("amd");
- if(!amd)
- {
- ExceptionList throws = op->throws();
- throws.sort();
- throws.unique();
+ ExceptionList throws = op->throws();
+ throws.sort();
+ throws.unique();
- //
- // Arrange exceptions into most-derived to least-derived order. If we don't
- // do this, a base exception handler can appear before a derived exception
- // handler, causing compiler warnings and resulting in the base exception
- // being marshaled instead of the derived exception.
- //
+ //
+ // Arrange exceptions into most-derived to least-derived order. If we don't
+ // do this, a base exception handler can appear before a derived exception
+ // handler, causing compiler warnings and resulting in the base exception
+ // being marshaled instead of the derived exception.
+ //
#if defined(__SUNPRO_CC)
- throws.sort(Slice::derivedToBaseCompare);
+ throws.sort(Slice::derivedToBaseCompare);
#else
- throws.sort(Slice::DerivedToBaseCompare());
+ throws.sort(Slice::DerivedToBaseCompare());
#endif
+ const bool amd = p->hasMetaData("amd") || op->hasMetaData("amd");
+ if(!amd)
+ {
for(ParamDeclList::const_iterator pli = outParams.begin(); pli != outParams.end(); ++pli)
{
string typeS = typeToString((*pli)->type(), (*pli)->optional());
@@ -799,8 +692,7 @@ Slice::CsVisitor::writeDispatchAndMarshalling(const ClassDefPtr& p)
_out << nl;
if(ret)
{
- string retS = typeToString(ret, op->returnIsOptional());
- _out << retS << " ret__ = ";
+ _out << "var ret__ = ";
}
_out << "obj__." << fixId(opName, DotNet::ICloneable, true) << spar;
for(ParamDeclList::const_iterator pli = inParams.begin(); pli != inParams.end(); ++pli)
@@ -823,7 +715,7 @@ Slice::CsVisitor::writeDispatchAndMarshalling(const ClassDefPtr& p)
//
if(!outParams.empty() || ret)
{
- _out << nl << "Ice.OutputStream os__ = inS__.startWriteParams__("
+ _out << nl << "var os__ = inS__.startWriteParams__("
<< opFormatTypeToString(op) << ");";
writeMarshalUnmarshalParams(outParams, op, true);
if(op->returnsClasses(false))
@@ -862,25 +754,64 @@ Slice::CsVisitor::writeDispatchAndMarshalling(const ClassDefPtr& p)
//
// Call on the servant.
//
- string classNameAMD = "AMD_" + p->name();
- _out << nl << classNameAMD << '_' << opName << " cb__ = new _" << classNameAMD << '_' << opName
- << "(inS__);";
- _out << nl << "try";
- _out << sb;
- _out << nl << "obj__.";
- if(amd)
- {
- _out << opName << "_async";
- }
- else
+ string retS;
+ string retP;
+ if(ret || !outParams.empty())
{
- _out << fixId(opName, DotNet::ICloneable, true);
+ if(outParams.empty())
+ {
+ retS = typeToString(ret, op->returnIsOptional());
+ retP = "ret__";
+ }
+ else if(ret || outParams.size() > 1)
+ {
+ retS = resultStructName(cl->name(), op->name(), fixId(cl->scope()));
+ retP = "ret__";
+ }
+ else
+ {
+ retS = typeToString(outParams.front()->type(), outParams.front()->optional());
+ retP = fixId(outParams.front()->name());
+ }
}
- _out << spar;
- if(amd)
+
+ _out << nl << "var in__ = new IceInternal.IncomingAsync(inS__);";
+ if(!throws.empty())
{
- _out << "cb__";
+ _out << nl << "_System.Action<_System.Exception> exHandler__ = (ex) =>";
+ _out << sb;
+
+ _out << nl << "try";
+ _out << sb;
+ _out << nl << "throw ex;";
+ _out << eb;
+
+ for(ExceptionList::const_iterator r = throws.begin(); r != throws.end(); ++r)
+ {
+ string exS = fixId((*r)->scoped());
+ _out << nl << "catch(" << exS << " ex__)";
+ _out << sb;
+ _out << nl << "if(in__.validateResponse__(false))";
+ _out << sb;
+ _out << nl << "in__.writeUserException__(ex__, " << opFormatTypeToString(op) << ");";
+ _out << nl << "in__.response__();";
+ _out << eb;
+ _out << eb;
+ }
+
+ _out << nl << "catch(_System.Exception ex__)";
+ _out << sb;
+ _out << nl << "in__.ice_exception(ex__);";
+ _out << eb;
+ _out << eb << ";";
}
+
+ _out << nl << "try";
+ _out << sb;
+ _out << nl << "obj__.";
+ _out << opName << "Async";
+ _out << "(";
+
for(ParamDeclList::const_iterator pli = inParams.begin(); pli != inParams.end(); ++pli)
{
string arg = fixId((*pli)->name());
@@ -888,13 +819,89 @@ Slice::CsVisitor::writeDispatchAndMarshalling(const ClassDefPtr& p)
{
arg = (*pli)->name() + "__PP.value";
}
- _out << arg;
+ _out << arg << ", ";
}
- _out << "current__" << epar << ';';
+ _out.inc();
+
+ if(retS.empty())
+ {
+ _out << "() =>";
+ _out << sb;
+ _out << nl << "try";
+ _out << sb;
+ _out << nl << "if(in__.validateResponse__(true))";
+ _out << sb;
+ _out << nl << "in__.writeEmptyParams__();";
+ _out << nl << "in__.response__();";
+ _out << eb;
+ _out << eb;
+ _out << nl << "catch(_System.Exception ex__)";
+ _out << sb;
+ if(throws.empty())
+ {
+ _out << nl << "in__.ice_exception(ex__);";
+ }
+ else
+ {
+ _out << nl << "exHandler__(ex__);";
+ }
+ _out << eb;
+ _out << eb << ",";
+ }
+ else
+ {
+ if(!ret && outParams.size() == 1)
+ {
+ _out << nl << "(" << fixId(outParams.front()->name()) << ") =>";
+ }
+ else
+ {
+ _out << nl << "(ret__) =>";
+ }
+ _out << sb;
+ _out << nl << "if(in__.validateResponse__(true))";
+ _out << sb;
+ _out << nl << "try";
+ _out << sb;
+ _out << nl << "var os__ = in__.startWriteParams__(" << opFormatTypeToString(op) << ");";
+ writeMarshalUnmarshalParams(outParams, op, true);
+ if(op->returnsClasses(false))
+ {
+ _out << nl << "os__.writePendingValues();";
+ }
+ _out << nl << "in__.endWriteParams__(true);";
+ _out << eb;
+ _out << nl << "catch(Ice.LocalException ex__)";
+ _out << sb;
+ _out << nl << "in__.exception__(ex__);";
+ _out << nl << "return;";
+ _out << eb;
+ _out << nl << "in__.response__();";
+ _out << eb;
+ _out << eb << ",";
+ }
+
+ if(throws.empty())
+ {
+ _out << nl << "in__.ice_exception,";
+ }
+ else
+ {
+ _out << nl << "exHandler__,";
+ }
+ _out << nl << "current__);";
+ _out.dec();
_out << eb;
_out << nl << "catch(_System.Exception ex__)";
_out << sb;
- _out << nl << "cb__.ice_exception(ex__);";
+ if(throws.empty())
+ {
+ _out << nl << "in__.ice_exception(ex__);";
+ }
+ else
+ {
+ _out << nl << "exHandler__(ex__);";
+ }
_out << eb;
_out << nl << "return Ice.DispatchStatus.DispatchAsync;";
@@ -1001,93 +1008,6 @@ Slice::CsVisitor::writeDispatchAndMarshalling(const ClassDefPtr& p)
_out << nl << "throw new Ice.OperationNotExistException(current__.id, current__.facet, current__.operation);";
_out << eb;
}
- /*else if(!p->isInterface() && !hasBaseClass)
- {
- _out << sp << nl << "private static string[] all__ =";
- _out << sb;
- _out << nl << "\"ice_id\","
- _out << nl << "\"ice_ids\","
- _out << nl << "\"ice_isA\","
- _out << nl << "\"ice_ping\","
- _out << eb << ';';
-
- _out << sp;
- emitGeneratedCodeAttribute();
- _out << nl << "public virtual Ice.DispatchStatus "
- << "dispatch__(IceInternal.Incoming inS__, Ice.Current current__)";
- _out << sb;
- _out << nl << "int pos = System.Array.BinarySearch(all__, current__.operation);";
- _out << nl << "if(pos < 0)";
- _out << sb;
- _out << nl << "throw new Ice.OperationNotExistException(current__.id, current__.facet, current__.operation);";
- _out << eb;
- _out << sp << nl << "switch(pos)";
- _out << sb;
- _out << nl << "case 0:";
- _out << sb;
- _out << nl << "return ice_id___(this, inS__, current__);";
- _out << eb;
-
-
- int i = 0;
- for(StringList::const_iterator q = allOpNames.begin(); q != allOpNames.end(); ++q)
- {
- string opName = *q;
-
- _out << nl << "case " << i++ << ':';
- _out << sb;
- if(opName == "ice_id")
- {
- _out << nl << "return ice_id___(this, inS__, current__);";
- }
- else if(opName == "ice_ids")
- {
- _out << nl << "return ice_ids___(this, inS__, current__);";
- }
- else if(opName == "ice_isA")
- {
- _out << nl << "return ice_isA___(this, inS__, current__);";
- }
- else if(opName == "ice_ping")
- {
- _out << nl << "return ice_ping___(this, inS__, current__);";
- }
- else
- {
- //
- // There's probably a better way to do this
- //
- for(OperationList::const_iterator t = allOps.begin(); t != allOps.end(); ++t)
- {
- if((*t)->name() == (*q))
- {
- ContainerPtr container = (*t)->container();
- ClassDefPtr cl = ClassDefPtr::dynamicCast(container);
- assert(cl);
- if(cl->scoped() == p->scoped())
- {
- _out << nl << "return " << opName << "___(this, inS__, current__);";
- }
- else
- {
- string base = cl->scoped();
- if(cl->isInterface())
- {
- base += "Disp_";
- }
- _out << nl << "return " << fixId(base) << "." << opName << "___(this, inS__, current__);";
- }
- break;
- }
- }
- }
- _out << eb;
- }
- _out << eb;
- _out << sp << nl << "_System.Diagnostics.Debug.Assert(false);";
- _out << nl << "throw new Ice.OperationNotExistException(current__.id, current__.facet, current__.operation);";
- _out << eb;
- }*/
if(!p->isInterface() || ops.size() != 0)
{
@@ -1430,7 +1350,7 @@ Slice::CsVisitor::getParams(const OperationPtr& op)
}
vector<string>
-Slice::CsVisitor::getParamsAsync(const OperationPtr& op, bool amd)
+Slice::CsVisitor::getParamsAsync(const OperationPtr& op)
{
vector<string> params;
@@ -1438,10 +1358,6 @@ Slice::CsVisitor::getParamsAsync(const OperationPtr& op, bool amd)
ContainerPtr container = op->container();
ClassDefPtr cl = ClassDefPtr::dynamicCast(container); // Get the class containing the op.
string scope = fixId(cl->scope());
- if(amd)
- {
- params.push_back(scope + "AMD_" + cl->name() + '_' + op->name() + " cb__");
- }
ParamDeclList paramList = op->parameters();
for(ParamDeclList::const_iterator q = paramList.begin(); q != paramList.end(); ++q)
@@ -1513,15 +1429,9 @@ Slice::CsVisitor::getArgs(const OperationPtr& op)
}
vector<string>
-Slice::CsVisitor::getArgsAsync(const OperationPtr& op, bool amd)
+Slice::CsVisitor::getArgsAsync(const OperationPtr& op)
{
vector<string> args;
-
- if(amd)
- {
- args.push_back("cb__");
- }
-
ParamDeclList paramList = op->parameters();
for(ParamDeclList::const_iterator q = paramList.begin(); q != paramList.end(); ++q)
{
@@ -1724,8 +1634,8 @@ Slice::CsVisitor::writeConstantValue(const TypePtr& type, const SyntaxTreeBasePt
//
- // Unicode character in the range U+10000 to U+10FFFF is not permitted in a character literal
- // and is represented using a Unicode surrogate pair.
+ // Unicode character in the range U+10000 to U+10FFFF is not permitted in a character
+ // literal and is represented using a Unicode surrogate pair.
//
if(v > 0xFFFF)
{
@@ -2336,8 +2246,9 @@ Slice::CsVisitor::writeDocCommentAMI(const OperationPtr& p, ParamDir paramType,
}
void
-Slice::CsVisitor::writeDocCommentTaskAsyncAMI(const OperationPtr& p, const string& deprecateReason, const string& extraParam1,
- const string& extraParam2, const string& extraParam3)
+Slice::CsVisitor::writeDocCommentTaskAsyncAMI(const OperationPtr& p, const string& deprecateReason,
+ const string& extraParam1, const string& extraParam2,
+ const string& extraParam3)
{
StringList summaryLines;
StringList remarksLines;
@@ -2406,7 +2317,7 @@ Slice::CsVisitor::writeDocCommentTaskAsyncAMI(const OperationPtr& p, const strin
}
void
-Slice::CsVisitor::writeDocCommentAMD(const OperationPtr& p, ParamDir paramType, const string& extraParam)
+Slice::CsVisitor::writeDocCommentAMD(const OperationPtr& p)
{
ContainerPtr container = p->container();
ClassDefPtr contained = ClassDefPtr::dynamicCast(container);
@@ -2421,106 +2332,18 @@ Slice::CsVisitor::writeDocCommentAMD(const OperationPtr& p, ParamDir paramType,
return;
}
- if(paramType == OutParam)
- {
- _out << nl << "/// <summary>";
- _out << nl << "/// ice_response indicates that";
- _out << nl << "/// the operation completed successfully.";
- _out << nl << "/// </summary>";
-
- //
- // Find the comment for the return value (if any) and rewrite that as a <param> comment.
- //
- static const string returnsTag = "<returns>";
- bool doneReturn = false;
- bool foundReturn = false;
- for(StringList::const_iterator i = remarksLines.begin(); i != remarksLines.end() && !doneReturn; ++i)
- {
- if(!foundReturn)
- {
- string::size_type pos = i->find(returnsTag);
- if(pos != string::npos)
- {
- pos += returnsTag.size();
- foundReturn = true;
- string::size_type endpos = i->find('<', pos);
- if(endpos != string::npos)
- {
- _out << nl << "/// <param name=\"ret__\">(return value) " << i->substr(pos, endpos - pos);
- }
- else
- {
- _out << nl << "/// <param name=\"ret__\">(return value) " << i->substr(pos);
- }
- }
- }
- else
- {
- string::size_type pos = i->find('<');
- if(pos != string::npos)
- {
- _out << nl << "/// " << i->substr(0, pos) << "</param>";
- doneReturn = true;
- }
- else
- {
- _out << nl << "/// " << *i;
- }
- }
- }
- if(foundReturn && !doneReturn)
- {
- _out << "</param>";
- }
- }
- else
- {
- //
- // Output the leading comment block up until the first tag.
- //
- _out << nl << "/// <summary>";
- for(StringList::const_iterator i = summaryLines.begin(); i != summaryLines.end(); ++i)
- {
- _out << nl << "/// " << *i;
- }
-
- bool done = false;
- for(StringList::const_iterator i = remarksLines.begin(); i != remarksLines.end() && !done; ++i)
- {
- string::size_type pos = i->find('<');
- done = true;
- if(pos != string::npos)
- {
- if(pos != 0)
- {
- _out << nl << "/// " << i->substr(0, pos);
- }
- }
- else
- {
- _out << nl << "/// " << *i;
- }
- }
- _out << nl << "/// </summary>";
- }
-
-
//
// Write the comments for the parameters.
//
- writeDocCommentParam(p, paramType, true);
+ writeDocCommentParam(p, InParam, true);
- if(!extraParam.empty())
- {
- _out << nl << "/// " << extraParam;
- }
+ _out << nl << "/// " << "<param name=\"response__\">The response callback for the operation.</param>";
+ _out << nl << "/// " << "<param name=\"exception__\">The exception callback for the operation.</param>";
+ _out << nl << "/// " << "<param name=\"current__\">The Current object for the invocation.</param>";
- if(paramType == InParam)
+ if(!deprecateReason.empty())
{
- if(!deprecateReason.empty())
- {
- _out << nl << "/// <para>" << deprecateReason << "</para>";
- }
+ _out << nl << "/// <para>" << deprecateReason << "</para>";
}
}
@@ -2545,14 +2368,6 @@ Slice::CsVisitor::writeDocCommentParam(const OperationPtr& p, ParamDir paramType
}
//
- // Print a comment for the callback parameter.
- //
- if(paramType == InParam && amd)
- {
- _out << nl << "/// <param name=\"cb__\">The callback object for the operation.</param>";
- }
-
- //
// Print the comments for all the parameters that appear in the parameter list.
//
StringList summaryLines;
@@ -2601,9 +2416,7 @@ Slice::CsVisitor::writeDocCommentParam(const OperationPtr& p, ParamDir paramType
}
Slice::Gen::Gen(const string& base, const vector<string>& includePaths, const string& dir,
- bool impl, bool implTie, bool compat) :
- _includePaths(includePaths),
- _compat(compat)
+ bool impl, bool implTie) : _includePaths(includePaths)
{
string fileBase = base;
string::size_type pos = base.find_last_of("/\\");
@@ -2675,62 +2488,56 @@ Slice::Gen::generate(const UnitPtr& p)
{
CsGenerator::validateMetaData(p);
- UnitVisitor unitVisitor(_out, _compat);
+ UnitVisitor unitVisitor(_out);
p->visit(&unitVisitor, false);
- CompactIdVisitor compactIdVisitor(_out, _compat);
+ CompactIdVisitor compactIdVisitor(_out);
p->visit(&compactIdVisitor, false);
- TypesVisitor typesVisitor(_out, _compat);
+ TypesVisitor typesVisitor(_out);
p->visit(&typesVisitor, false);
- if(_compat)
- {
- //
- // The async delegates are emitted before the proxy definition
- // because the proxy methods need to know the type.
- //
- AsyncDelegateVisitor asyncDelegateVisitor(_out, _compat);
- p->visit(&asyncDelegateVisitor, false);
- }
+ //
+ // The async delegates are emitted before the proxy definition
+ // because the proxy methods need to know the type.
+ //
+ AsyncDelegateVisitor asyncDelegateVisitor(_out);
+ p->visit(&asyncDelegateVisitor, false);
- ResultVisitor resultVisitor(_out, _compat);
+ ResultVisitor resultVisitor(_out);
p->visit(&resultVisitor, false);
- ProxyVisitor proxyVisitor(_out, _compat);
+ ProxyVisitor proxyVisitor(_out);
p->visit(&proxyVisitor, false);
- OpsVisitor opsVisitor(_out, _compat);
+ OpsVisitor opsVisitor(_out);
p->visit(&opsVisitor, false);
- HelperVisitor helperVisitor(_out, _compat);
+ HelperVisitor helperVisitor(_out);
p->visit(&helperVisitor, false);
- DispatcherVisitor dispatcherVisitor(_out, _compat);
+ DispatcherVisitor dispatcherVisitor(_out);
p->visit(&dispatcherVisitor, false);
-
- AsyncVisitor asyncVisitor(_out, _compat);
- p->visit(&asyncVisitor, false);
}
void
Slice::Gen::generateTie(const UnitPtr& p)
{
- TieVisitor tieVisitor(_out, _compat);
+ TieVisitor tieVisitor(_out);
p->visit(&tieVisitor, false);
}
void
Slice::Gen::generateImpl(const UnitPtr& p)
{
- ImplVisitor implVisitor(_impl, _compat);
+ ImplVisitor implVisitor(_impl);
p->visit(&implVisitor, false);
}
void
Slice::Gen::generateImplTie(const UnitPtr& p)
{
- ImplTieVisitor implTieVisitor(_impl, _compat);
+ ImplTieVisitor implTieVisitor(_impl);
p->visit(&implTieVisitor, false);
}
@@ -2806,8 +2613,8 @@ Slice::Gen::printHeader()
_out << "//\n";
}
-Slice::Gen::UnitVisitor::UnitVisitor(IceUtilInternal::Output& out, bool compat) :
- CsVisitor(out, compat)
+Slice::Gen::UnitVisitor::UnitVisitor(IceUtilInternal::Output& out) :
+ CsVisitor(out)
{
}
@@ -2838,8 +2645,8 @@ Slice::Gen::UnitVisitor::visitUnitStart(const UnitPtr& p)
return false;
}
-Slice::Gen::CompactIdVisitor::CompactIdVisitor(IceUtilInternal::Output& out, bool compat) :
- CsVisitor(out, compat)
+Slice::Gen::CompactIdVisitor::CompactIdVisitor(IceUtilInternal::Output& out) :
+ CsVisitor(out)
{
}
@@ -2872,8 +2679,8 @@ Slice::Gen::CompactIdVisitor::visitClassDefStart(const ClassDefPtr& p)
return false;
}
-Slice::Gen::TypesVisitor::TypesVisitor(IceUtilInternal::Output& out, bool compat) :
- CsVisitor(out, compat)
+Slice::Gen::TypesVisitor::TypesVisitor(IceUtilInternal::Output& out) :
+ CsVisitor(out)
{
}
@@ -2939,7 +2746,6 @@ Slice::Gen::TypesVisitor::visitClassDefStart(const ClassDefPtr& p)
{
baseNames.push_back("Ice.Object");
baseNames.push_back(name + "Operations_");
- baseNames.push_back(name + "OperationsNC_");
}
for(ClassList::const_iterator q = bases.begin(); q != bases.end(); ++q)
{
@@ -2974,10 +2780,10 @@ Slice::Gen::TypesVisitor::visitClassDefStart(const ClassDefPtr& p)
baseNames.push_back(fixId(bases.front()->scoped()));
bases.pop_front();
}
+
if(p->isAbstract() && !p->isLocal())
{
baseNames.push_back(name + "Operations_");
- baseNames.push_back(name + "OperationsNC_");
}
for(ClassList::const_iterator q = bases.begin(); q != bases.end(); ++q)
@@ -3150,9 +2956,11 @@ Slice::Gen::TypesVisitor::visitClassDefEnd(const ClassDefPtr& p)
void
Slice::Gen::TypesVisitor::visitOperation(const OperationPtr& p)
{
- ClassDefPtr classDef = ClassDefPtr::dynamicCast(p->container());
- bool isLocal = classDef->isLocal();
- bool isInterface = classDef->isInterface();
+ ClassDefPtr cl = ClassDefPtr::dynamicCast(p->container());
+ bool isLocal = cl->isLocal();
+ bool isInterface = cl->isInterface();
+
+ bool amd = !isLocal && (cl->hasMetaData("amd") || p->hasMetaData("amd"));
//
// Non-local classes and interfaces get the operations from their
@@ -3163,27 +2971,31 @@ Slice::Gen::TypesVisitor::visitOperation(const OperationPtr& p)
return;
}
- bool amd = !isLocal && (classDef->hasMetaData("amd") || p->hasMetaData("amd"));
-
string name = p->name();
- ParamDeclList paramList = p->parameters();
+ ParamDeclList outParams = getOutParams(p->parameters());
vector<string> params;
vector<string> args;
+ TypePtr ret = p->returnType();
string retS;
if(!amd)
{
params = getParams(p);
- args = getArgs(p);
name = fixId(name, DotNet::ICloneable, true);
- retS = typeToString(p->returnType(), p->returnIsOptional());
+ retS = typeToString(ret, p->returnIsOptional());
}
else
{
- params = getParamsAsync(p, true);
- args = getArgsAsync(p, true);
+ params = getParamsAsync(p);
+ params.push_back(asyncResultType(p, "_System.Action") + " response__");
+ params.push_back("_System.Action<_System.Exception> exception__");
+ name = name + "Async";
retS = "void";
- name = name + "_async";
+ }
+
+ if(!isLocal)
+ {
+ params.push_back("Ice.Current current__ = null");
}
_out << sp;
@@ -3192,46 +3004,28 @@ Slice::Gen::TypesVisitor::visitOperation(const OperationPtr& p)
_out << nl;
}
- writeDocComment(p, getDeprecateReason(p, classDef, "operation"));
- emitAttributes(p);
- emitDeprecate(p, classDef, _out, "operation");
- emitGeneratedCodeAttribute();
- _out << nl;
- if(!isInterface)
- {
- _out << "public ";
- if(isLocal)
- {
- _out << "abstract ";
- }
- }
- _out << retS << " " << name << spar << params << epar;
- if(isLocal)
+ if(amd)
{
- _out << ";";
+ writeDocCommentAMD(p);
}
else
{
- _out << sb;
- _out << nl;
- if(!amd && p->returnType())
- {
- _out << "return ";
- }
- _out << "this." << name << spar << args << "Ice.ObjectImpl.defaultCurrent" << epar << ';';
- _out << eb;
+ writeDocComment(p, getDeprecateReason(p, cl, "operation"),
+ isLocal ? "" : "<param name=\"current__\">The Current object for the invocation.</param>");
}
-
- if(!isLocal)
+ emitAttributes(p);
+ emitDeprecate(p, cl, _out, "operation");
+ emitGeneratedCodeAttribute();
+ _out << nl;
+ if(!isInterface)
{
- emitGeneratedCodeAttribute();
- _out << nl << "public abstract " << retS << " " << name
- << spar << params << "Ice.Current current__" << epar << ';';
+ _out << "public abstract ";
}
+ _out << retS << " " << name << spar << params << epar << ";";
- if(isLocal && (classDef->hasMetaData("async-oneway") || p->hasMetaData("async-oneway")))
+ if(isLocal && (cl->hasMetaData("async-oneway") || p->hasMetaData("async-oneway")))
{
- vector<string> paramsNewAsync = getParamsAsync(p, false);
+ vector<string> paramsNewAsync = getParamsAsync(p);
TypePtr ret = p->returnType();
ParamDeclList outParams = getOutParams(p->parameters());
@@ -3248,25 +3042,7 @@ Slice::Gen::TypesVisitor::visitOperation(const OperationPtr& p)
{
_out << "public abstract ";
}
- _out << "_System.Threading.Tasks.Task";
- if(ret || outParams.size() > 0)
- {
- _out << "<";
- string returnTypeS;
- if(outParams.empty())
- {
- returnTypeS = typeToString(p->returnType(), p->returnIsOptional());
- }
- else if(p->returnType() || outParams.size() > 1)
- {
- returnTypeS = resultStructName(classDef->name(), p->name(), fixId(classDef->scope()));
- }
- else
- {
- returnTypeS = typeToString(outParams.front()->type(), outParams.front()->optional());
- }
- _out << returnTypeS << ">";
- }
+ _out << asyncResultType(p);
string progress = getAsyncTaskParamName(inParams, "progress");
string cancel = getAsyncTaskParamName(inParams, "cancel");
@@ -3276,34 +3052,32 @@ Slice::Gen::TypesVisitor::visitOperation(const OperationPtr& p)
<< ("_System.Threading.CancellationToken " + cancel + " = new _System.Threading.CancellationToken()")
<< epar << ";";
- if(_compat)
+
+ //
+ // IAsyncResult based asynchronous mehtods
+ //
+ _out << sp;
+ emitAttributes(p);
+ emitGeneratedCodeAttribute();
+ _out << nl;
+ if(!isInterface)
{
- //
- // IAsyncResult based asynchronous mehtods
- //
- _out << sp;
- emitAttributes(p);
- emitGeneratedCodeAttribute();
- _out << nl;
- if(!isInterface)
- {
- _out << "public abstract ";
- }
- _out << "Ice.AsyncResult begin_" << name << spar << paramsNewAsync
- << "Ice.AsyncCallback cb__ = null"
- << "object cookie__ = null" << epar << ';';
+ _out << "public abstract ";
+ }
+ _out << "Ice.AsyncResult begin_" << name << spar << paramsNewAsync
+ << "Ice.AsyncCallback cb__ = null"
+ << "object cookie__ = null" << epar << ';';
- _out << sp;
- emitAttributes(p);
- emitGeneratedCodeAttribute();
- _out << nl;
- if(!isInterface)
- {
- _out << "public abstract ";
- }
- _out << typeToString(p->returnType(), p->returnIsOptional()) << " end_" << name << spar
- << getParamsAsyncCB(p, false, true) << "Ice.AsyncResult r__" << epar << ';';
+ _out << sp;
+ emitAttributes(p);
+ emitGeneratedCodeAttribute();
+ _out << nl;
+ if(!isInterface)
+ {
+ _out << "public abstract ";
}
+ _out << typeToString(p->returnType(), p->returnIsOptional()) << " end_" << name << spar
+ << getParamsAsyncCB(p, false, true) << "Ice.AsyncResult r__" << epar << ';';
}
}
@@ -4422,8 +4196,8 @@ Slice::Gen::TypesVisitor::writeMemberEquals(const DataMemberList& dataMembers, i
}
}
-Slice::Gen::ResultVisitor::ResultVisitor(::IceUtilInternal::Output& out, bool compat)
- : CsVisitor(out, compat)
+Slice::Gen::ResultVisitor::ResultVisitor(::IceUtilInternal::Output& out)
+ : CsVisitor(out)
{
}
@@ -4476,13 +4250,54 @@ Slice::Gen::ResultVisitor::visitOperation(const OperationPtr& p)
TypePtr ret = p->returnType();
if(outParams.size() > 1 || (ret && outParams.size() > 0))
{
+ string name = resultStructName(cl->name(), p->name());
+
+ string retS;
+ string retSName;
+
+ if(ret)
+ {
+ retS = typeToString(ret, p->returnIsOptional());
+ retSName = resultStructReturnValueName(outParams);
+ }
+
_out << sp;
- _out << nl << "public struct " << resultStructName(cl->name(), p->name());
+ _out << nl << "public struct " << name;
+ _out << sb;
+ //
+ // one shot constructor
+ //
+ _out << nl << "public " << name << spar;
+
+ if(ret)
+ {
+ _out << (retS + " " + retSName);
+ }
+
+ for(ParamDeclList::const_iterator i = outParams.begin(); i != outParams.end(); ++i)
+ {
+ _out << (typeToString((*i)->type(), (*i)->optional()) + " " + fixId((*i)->name()));
+ }
+ _out << epar;
+
_out << sb;
+
+ if(ret)
+ {
+ _out << nl << "this." << retSName << " = " << retSName << ";";
+ }
+
+ for(ParamDeclList::const_iterator i = outParams.begin(); i != outParams.end(); ++i)
+ {
+ _out << nl << "this." << fixId((*i)->name()) << " = " << fixId((*i)->name()) << ";";
+ }
+
+ _out << eb;
+
+ _out << sp;
if(ret)
{
- _out << nl << "public " << typeToString(ret, p->returnIsOptional()) << " "
- << resultStructReturnValueName(outParams) << ";";
+ _out << nl << "public " << retS << " " << retSName << ";";
}
for(ParamDeclList::const_iterator i = outParams.begin(); i != outParams.end(); ++i)
@@ -4494,8 +4309,8 @@ Slice::Gen::ResultVisitor::visitOperation(const OperationPtr& p)
}
}
-Slice::Gen::ProxyVisitor::ProxyVisitor(IceUtilInternal::Output& out, bool compat) :
- CsVisitor(out, compat)
+Slice::Gen::ProxyVisitor::ProxyVisitor(IceUtilInternal::Output& out) :
+ CsVisitor(out)
{
}
@@ -4549,7 +4364,6 @@ Slice::Gen::ProxyVisitor::visitClassDefStart(const ClassDefPtr& p)
}
}
}
-
_out << sb;
return true;
@@ -4567,7 +4381,7 @@ Slice::Gen::ProxyVisitor::visitOperation(const OperationPtr& p)
ClassDefPtr cl = ClassDefPtr::dynamicCast(p->container());
string name = fixId(p->name(), DotNet::ICloneable, true);
vector<string> params = getParams(p);
- vector<string> paramsNewAsync = getParamsAsync(p, false);
+ vector<string> paramsNewAsync = getParamsAsync(p);
ParamDeclList paramList = p->parameters();
ParamDeclList outParams = getOutParams(p->parameters());
@@ -4610,25 +4424,7 @@ Slice::Gen::ProxyVisitor::visitOperation(const OperationPtr& p)
{
_out << nl << "[_System.Obsolete(\"" << deprecateReason << "\")]";
}
- _out << nl << "_System.Threading.Tasks.Task";
- if(p->returnType() || !outParams.empty())
- {
- string returnTypeS;
- if(outParams.empty())
- {
- returnTypeS = typeToString(p->returnType(), p->returnIsOptional());
- }
- else if(p->returnType() || outParams.size() > 1)
- {
- returnTypeS = resultStructName(cl->name(), p->name(), fixId(cl->scope()));
- }
- else
- {
- returnTypeS = typeToString(outParams.front()->type(), outParams.front()->optional());
- }
-
- _out << "<" << returnTypeS << ">";
- }
+ _out << nl << asyncResultType(p);
_out << " " << p->name() << "Async" << spar
<< paramsNewAsync
<< ("Ice.OptionalContext " + context + " = new Ice.OptionalContext()")
@@ -4640,65 +4436,62 @@ Slice::Gen::ProxyVisitor::visitOperation(const OperationPtr& p)
//
// Write the async versions of the operation (using IAsyncResult API)
//
- if(_compat)
- {
- string clScope = fixId(cl->scope());
- string delType = clScope + "Callback_" + cl->name() + "_" + p->name();
+ string clScope = fixId(cl->scope());
+ string delType = clScope + "Callback_" + cl->name() + "_" + p->name();
- _out << sp;
- writeDocCommentAMI(p, InParam, deprecateReason,
- "<param name=\"ctx__\">The Context map to send with the invocation.</param>");
- if(!deprecateReason.empty())
- {
- _out << nl << "[_System.Obsolete(\"" << deprecateReason << "\")]";
- }
- _out << nl << "Ice.AsyncResult<" << delType << "> begin_" << p->name() << spar << paramsNewAsync
- << ("Ice.OptionalContext ctx__ = new Ice.OptionalContext()") << epar << ';';
+ _out << sp;
+ writeDocCommentAMI(p, InParam, deprecateReason,
+ "<param name=\"ctx__\">The Context map to send with the invocation.</param>");
+ if(!deprecateReason.empty())
+ {
+ _out << nl << "[_System.Obsolete(\"" << deprecateReason << "\")]";
+ }
+ _out << nl << "Ice.AsyncResult<" << delType << "> begin_" << p->name() << spar << paramsNewAsync
+ << ("Ice.OptionalContext ctx__ = new Ice.OptionalContext()") << epar << ';';
- //
- // Type-unsafe begin_ methods.
- //
- _out << sp;
- writeDocCommentAMI(p, InParam, deprecateReason,
- "<param name=\"cb__\">Asynchronous callback invoked when the operation completes.</param>",
- "<param name=\"cookie__\">Application data to store in the asynchronous result object.</param>");
- if(!deprecateReason.empty())
- {
- _out << nl << "[_System.Obsolete(\"" << deprecateReason << "\")]";
- }
- _out << nl << "Ice.AsyncResult begin_" << p->name() << spar << paramsNewAsync << "Ice.AsyncCallback cb__"
- << "object cookie__" << epar << ';';
+ //
+ // Type-unsafe begin_ methods.
+ //
+ _out << sp;
+ writeDocCommentAMI(p, InParam, deprecateReason,
+ "<param name=\"cb__\">Asynchronous callback invoked when the operation completes.</param>",
+ "<param name=\"cookie__\">Application data to store in the asynchronous result object.</param>");
+ if(!deprecateReason.empty())
+ {
+ _out << nl << "[_System.Obsolete(\"" << deprecateReason << "\")]";
+ }
+ _out << nl << "Ice.AsyncResult begin_" << p->name() << spar << paramsNewAsync << "Ice.AsyncCallback cb__"
+ << "object cookie__" << epar << ';';
- _out << sp;
- writeDocCommentAMI(p, InParam, deprecateReason,
- "<param name=\"ctx__\">The Context map to send with the invocation.</param>",
- "<param name=\"cb__\">Asynchronous callback invoked when the operation completes.</param>",
- "<param name=\"cookie__\">Application data to store in the asynchronous result object.</param>");
- if(!deprecateReason.empty())
- {
- _out << nl << "[_System.Obsolete(\"" << deprecateReason << "\")]";
- }
- _out << nl << "Ice.AsyncResult begin_" << p->name() << spar << paramsNewAsync
- << "Ice.OptionalContext ctx__" << "Ice.AsyncCallback cb__"
- << "object cookie__" << epar << ';';
+ _out << sp;
+ writeDocCommentAMI(p, InParam, deprecateReason,
+ "<param name=\"ctx__\">The Context map to send with the invocation.</param>",
+ "<param name=\"cb__\">Asynchronous callback invoked when the operation completes.</param>",
+ "<param name=\"cookie__\">Application data to store in the asynchronous result object.</param>");
+ if(!deprecateReason.empty())
+ {
+ _out << nl << "[_System.Obsolete(\"" << deprecateReason << "\")]";
+ }
+ _out << nl << "Ice.AsyncResult begin_" << p->name() << spar << paramsNewAsync
+ << "Ice.OptionalContext ctx__" << "Ice.AsyncCallback cb__"
+ << "object cookie__" << epar << ';';
- //
- // end_ method.
- //
- _out << sp;
- writeDocCommentAMI(p, OutParam, deprecateReason,
- "<param name=\"r__\">The asynchronous result object for the invocation.</param>");
- if(!deprecateReason.empty())
- {
- _out << nl << "[_System.Obsolete(\"" << deprecateReason << "\")]";
- }
- _out << nl << retS << " end_" << p->name() << spar << getParamsAsyncCB(p, false, true) << "Ice.AsyncResult r__"
- << epar << ';';
+ //
+ // end_ method.
+ //
+ _out << sp;
+ writeDocCommentAMI(p, OutParam, deprecateReason,
+ "<param name=\"r__\">The asynchronous result object for the invocation.</param>");
+ if(!deprecateReason.empty())
+ {
+ _out << nl << "[_System.Obsolete(\"" << deprecateReason << "\")]";
}
+ _out << nl << retS << " end_" << p->name() << spar << getParamsAsyncCB(p, false, true) << "Ice.AsyncResult r__"
+ << epar << ';';
}
-Slice::Gen::AsyncDelegateVisitor::AsyncDelegateVisitor(IceUtilInternal::Output& out, bool compat)
- : CsVisitor(out, compat)
+Slice::Gen::AsyncDelegateVisitor::AsyncDelegateVisitor(IceUtilInternal::Output& out)
+ : CsVisitor(out)
{
}
@@ -4754,8 +4547,8 @@ Slice::Gen::AsyncDelegateVisitor::visitOperation(const OperationPtr& p)
_out << paramDeclAMI << epar << ';';
}
-Slice::Gen::OpsVisitor::OpsVisitor(IceUtilInternal::Output& out, bool compat)
- : CsVisitor(out, compat)
+Slice::Gen::OpsVisitor::OpsVisitor(IceUtilInternal::Output& out)
+ : CsVisitor(out)
{
}
@@ -4788,13 +4581,7 @@ Slice::Gen::OpsVisitor::visitClassDefStart(const ClassDefPtr& p)
{
return false;
}
-
- if(!p->isLocal())
- {
- writeOperations(p, false);
- }
- writeOperations(p, true);
-
+ writeOperations(p, p->isLocal());
return false;
}
@@ -4854,55 +4641,54 @@ Slice::Gen::OpsVisitor::writeOperations(const ClassDefPtr& p, bool noCurrent)
{
OperationPtr op = *r;
bool amd = !p->isLocal() && (p->hasMetaData("amd") || op->hasMetaData("amd"));
- string opname = amd ? (op->name() + "_async") : fixId(op->name(), DotNet::ICloneable, true);
-
- TypePtr ret;
vector<string> params;
+ TypePtr ret = op->returnType();
+ string retS;
+ string opName;
- if(amd)
+ if(!amd)
{
- params = getParamsAsync(op, true);
+ params = getParams(op);
+ opName = fixId(op->name(), DotNet::ICloneable, true);
+ retS = typeToString(ret, op->returnIsOptional());
}
else
{
- params = getParams(op);
- ret = op->returnType();
+ params = getParamsAsync(op);
+ params.push_back(asyncResultType(op, "_System.Action") + " response__");
+ params.push_back("_System.Action<_System.Exception> exception__");
+ opName = op->name() + "Async";
+ retS = "void";
}
- _out << sp;
-
- string deprecateReason = getDeprecateReason(*r, p, "operation");
- string extraCurrent;
- if(!noCurrent && !p->isLocal())
+ if(!noCurrent)
{
- extraCurrent = "<param name=\"current__\">The Current object for the invocation.</param>";
+ params.push_back("Ice.Current current__ = null");
}
+
+ _out << sp;
+
if(amd)
{
- writeDocCommentAMD(*r, InParam, extraCurrent);
+ writeDocCommentAMD(op);
}
else
{
- writeDocComment(*r, deprecateReason, extraCurrent);
+ writeDocComment(op, getDeprecateReason(op, p, "operation"),
+ noCurrent ? "" : "<param name=\"current__\">The Current object for the invocation.</param>");
}
-
- emitDeprecate(op, p, _out, "operation");
-
emitAttributes(op);
- string retS = typeToString(ret, op->returnIsOptional());
- _out << nl << retS << ' ' << opname << spar << params;
- if(!noCurrent && !p->isLocal())
- {
- _out << "Ice.Current current__";
- }
- _out << epar << ';';
+ emitDeprecate(op, op, _out, "operation");
+ emitGeneratedCodeAttribute();
+ _out << nl << retS << " " << opName << spar << params << epar << ";";
}
_out << eb;
}
-Slice::Gen::HelperVisitor::HelperVisitor(IceUtilInternal::Output& out, bool compat) :
- CsVisitor(out, compat)
+
+Slice::Gen::HelperVisitor::HelperVisitor(IceUtilInternal::Output& out) :
+ CsVisitor(out)
{
}
@@ -4959,7 +4745,7 @@ Slice::Gen::HelperVisitor::visitClassDefStart(const ClassDefPtr& p)
vector<string> params = getParams(op);
vector<string> args = getArgs(op);
- vector<string> argsAMI = getArgsAsync(op, false);
+ vector<string> argsAMI = getArgsAsync(op);
string deprecateReason = getDeprecateReason(op, p, "operation");
@@ -5056,8 +4842,8 @@ Slice::Gen::HelperVisitor::visitClassDefStart(const ClassDefPtr& p)
ClassDefPtr cl = ClassDefPtr::dynamicCast(op->container());
string clScope = fixId(cl->scope());
- vector<string> paramsAMI = getParamsAsync(op, false);
- vector<string> argsAMI = getArgsAsync(op, false);
+ vector<string> paramsAMI = getParamsAsync(op);
+ vector<string> argsAMI = getArgsAsync(op);
string opName = op->name();
@@ -5289,180 +5075,177 @@ Slice::Gen::HelperVisitor::visitClassDefStart(const ClassDefPtr& p)
//
// IAsyncResult AMI mapping.
//
- if(_compat)
+ _out << sp << nl << "#region Asynchronous operations";
+ for(OperationList::const_iterator r = ops.begin(); r != ops.end(); ++r)
{
- _out << sp << nl << "#region Asynchronous operations";
- for(OperationList::const_iterator r = ops.begin(); r != ops.end(); ++r)
- {
- OperationPtr op = *r;
+ OperationPtr op = *r;
- ClassDefPtr cl = ClassDefPtr::dynamicCast(op->container());
- string clScope = fixId(cl->scope());
- vector<string> paramsAMI = getParamsAsync(op, false);
- vector<string> argsAMI = getArgsAsync(op, false);
- string opName = op->name();
- ParamDeclList inParams = getInParams(op->parameters());
- ParamDeclList outParams = getOutParams(op->parameters());
+ ClassDefPtr cl = ClassDefPtr::dynamicCast(op->container());
+ string clScope = fixId(cl->scope());
+ vector<string> paramsAMI = getParamsAsync(op);
+ vector<string> argsAMI = getArgsAsync(op);
+ string opName = op->name();
+ ParamDeclList inParams = getInParams(op->parameters());
+ ParamDeclList outParams = getOutParams(op->parameters());
- TypePtr ret = op->returnType();
- string retS = typeToString(ret, op->returnIsOptional());
+ TypePtr ret = op->returnType();
+ string retS = typeToString(ret, op->returnIsOptional());
- string returnTypeS;
- if(ret || !outParams.empty())
+ string returnTypeS;
+ if(ret || !outParams.empty())
+ {
+ if(outParams.empty())
{
- if(outParams.empty())
- {
- returnTypeS = typeToString(ret, op->returnIsOptional());
- }
- else if(ret || outParams.size() > 1)
- {
- returnTypeS = resultStructName(cl->name(), op->name(), fixId(cl->scope()));
- }
- else
- {
- returnTypeS = typeToString(outParams.front()->type(), outParams.front()->optional());
- }
+ returnTypeS = typeToString(ret, op->returnIsOptional());
+ }
+ else if(ret || outParams.size() > 1)
+ {
+ returnTypeS = resultStructName(cl->name(), op->name(), fixId(cl->scope()));
+ }
+ else
+ {
+ returnTypeS = typeToString(outParams.front()->type(), outParams.front()->optional());
}
- ExceptionList throws = op->throws();
- throws.sort();
- throws.unique();
+ }
+ ExceptionList throws = op->throws();
+ throws.sort();
+ throws.unique();
- //
- // Arrange exceptions into most-derived to least-derived order. If we don't
- // do this, a base exception handler can appear before a derived exception
- // handler, causing compiler warnings and resulting in the base exception
- // being marshaled instead of the derived exception.
- //
+ //
+ // Arrange exceptions into most-derived to least-derived order. If we don't
+ // do this, a base exception handler can appear before a derived exception
+ // handler, causing compiler warnings and resulting in the base exception
+ // being marshaled instead of the derived exception.
+ //
#if defined(__SUNPRO_CC)
- throws.sort(Slice::derivedToBaseCompare);
+ throws.sort(Slice::derivedToBaseCompare);
#else
- throws.sort(Slice::DerivedToBaseCompare());
+ throws.sort(Slice::DerivedToBaseCompare());
#endif
- //
- // Write the begin_ methods.
- //
- string delType = clScope + "Callback_" + cl->name() + "_" + op->name();
+ //
+ // Write the begin_ methods.
+ //
+ string delType = clScope + "Callback_" + cl->name() + "_" + op->name();
- _out << sp;
- _out << nl << "public Ice.AsyncResult<" << delType << "> begin_" << opName << spar << paramsAMI
- << ("Ice.OptionalContext ctx__ = new Ice.OptionalContext()") << epar;
- _out << sb;
- _out << nl << "return begin_" << opName << spar << argsAMI << "ctx__" << "null" << "null" << "false"
- << epar << ';';
- _out << eb;
+ _out << sp;
+ _out << nl << "public Ice.AsyncResult<" << delType << "> begin_" << opName << spar << paramsAMI
+ << ("Ice.OptionalContext ctx__ = new Ice.OptionalContext()") << epar;
+ _out << sb;
+ _out << nl << "return begin_" << opName << spar << argsAMI << "ctx__" << "null" << "null" << "false"
+ << epar << ';';
+ _out << eb;
- _out << sp;
- _out << nl << "public Ice.AsyncResult begin_" << opName << spar << paramsAMI
- << "Ice.AsyncCallback cb__" << "object cookie__" << epar;
- _out << sb;
- _out << nl << "return begin_" << opName << spar << argsAMI << "new Ice.OptionalContext()" << "cb__"
- << "cookie__" << "false" << epar << ';';
- _out << eb;
+ _out << sp;
+ _out << nl << "public Ice.AsyncResult begin_" << opName << spar << paramsAMI
+ << "Ice.AsyncCallback cb__" << "object cookie__" << epar;
+ _out << sb;
+ _out << nl << "return begin_" << opName << spar << argsAMI << "new Ice.OptionalContext()" << "cb__"
+ << "cookie__" << "false" << epar << ';';
+ _out << eb;
- _out << sp;
- _out << nl << "public Ice.AsyncResult begin_" << opName << spar << paramsAMI
- << "Ice.OptionalContext ctx__" << "Ice.AsyncCallback cb__"
- << "object cookie__" << epar;
- _out << sb;
- _out << nl << "return begin_" << opName << spar << argsAMI << "ctx__" << "cb__"
- << "cookie__" << "false" << epar << ';';
- _out << eb;
+ _out << sp;
+ _out << nl << "public Ice.AsyncResult begin_" << opName << spar << paramsAMI
+ << "Ice.OptionalContext ctx__" << "Ice.AsyncCallback cb__"
+ << "object cookie__" << epar;
+ _out << sb;
+ _out << nl << "return begin_" << opName << spar << argsAMI << "ctx__" << "cb__"
+ << "cookie__" << "false" << epar << ';';
+ _out << eb;
- //
- // Write the end_ method.
- //
- string flatName = "__" + opName + "_name";
- _out << sp << nl << "public " << retS << " end_" << opName << spar << getParamsAsyncCB(op, false, true)
- << "Ice.AsyncResult r__" << epar;
- _out << sb;
+ //
+ // Write the end_ method.
+ //
+ string flatName = "__" + opName + "_name";
+ _out << sp << nl << "public " << retS << " end_" << opName << spar << getParamsAsyncCB(op, false, true)
+ << "Ice.AsyncResult r__" << epar;
+ _out << sb;
- _out << nl << "var resultI__ = IceInternal.AsyncResultI.check(r__, this, " << flatName << ");";
+ _out << nl << "var resultI__ = IceInternal.AsyncResultI.check(r__, this, " << flatName << ");";
- if(returnTypeS.empty())
+ if(returnTypeS.empty())
+ {
+ _out << nl << "((IceInternal.OutgoingAsyncT<object>)resultI__.OutgoingAsync).result__(resultI__.wait());";
+ }
+ else
+ {
+ _out << nl << "var outgoing__ = (IceInternal.OutgoingAsyncT<" << returnTypeS << ">)resultI__.OutgoingAsync;";
+ if(outParams.empty())
+ {
+ _out << nl << "return outgoing__.result__(resultI__.wait());";
+ }
+ else if(!ret && outParams.size() == 1)
{
- _out << nl << "((IceInternal.OutgoingAsyncT<object>)resultI__.OutgoingAsync).result__(resultI__.wait());";
+ _out << nl << fixId(outParams.front()->name()) << " = outgoing__.result__(resultI__.wait());";
}
else
{
- _out << nl << "var outgoing__ = (IceInternal.OutgoingAsyncT<" << returnTypeS << ">)resultI__.OutgoingAsync;";
- if(outParams.empty())
+ _out << nl << "var result__ = outgoing__.result__(resultI__.wait());";
+ for(ParamDeclList::const_iterator i = outParams.begin(); i != outParams.end(); ++i)
{
- _out << nl << "return outgoing__.result__(resultI__.wait());";
+ _out << nl << fixId((*i)->name()) << " = result__." << fixId((*i)->name()) << ";";
}
- else if(!ret && outParams.size() == 1)
- {
- _out << nl << fixId(outParams.front()->name()) << " = outgoing__.result__(resultI__.wait());";
- }
- else
- {
- _out << nl << "var result__ = outgoing__.result__(resultI__.wait());";
- for(ParamDeclList::const_iterator i = outParams.begin(); i != outParams.end(); ++i)
- {
- _out << nl << fixId((*i)->name()) << " = result__." << fixId((*i)->name()) << ";";
- }
- if(ret)
- {
- _out << nl << "return result__." << resultStructReturnValueName(outParams) << ";";
- }
+ if(ret)
+ {
+ _out << nl << "return result__." << resultStructReturnValueName(outParams) << ";";
}
}
- _out << eb;
+ }
+ _out << eb;
- //
- // Write the common begin_ implementation.
- //
- _out << sp;
- _out << nl << "private Ice.AsyncResult<" << delType << "> begin_" << opName << spar << paramsAMI
- << "_System.Collections.Generic.Dictionary<string, string> ctx__"
- << "Ice.AsyncCallback completedCallback__" << "object cookie__" << "bool synchronous__"
- << epar;
- _out << sb;
+ //
+ // Write the common begin_ implementation.
+ //
+ _out << sp;
+ _out << nl << "private Ice.AsyncResult<" << delType << "> begin_" << opName << spar << paramsAMI
+ << "_System.Collections.Generic.Dictionary<string, string> ctx__"
+ << "Ice.AsyncCallback completedCallback__" << "object cookie__" << "bool synchronous__"
+ << epar;
+ _out << sb;
- _out << nl << "var completed__ = new IceInternal.OperationAsyncResultCompletionCallback<" << delType;
- _out << ", " << (returnTypeS.empty() ? "object" : returnTypeS);
- _out << ">(";
+ _out << nl << "var completed__ = new IceInternal.OperationAsyncResultCompletionCallback<" << delType;
+ _out << ", " << (returnTypeS.empty() ? "object" : returnTypeS);
+ _out << ">(";
- //
- // Write the completed callback
- //
- _out.inc();
- _out << nl << "(" << delType << " cb__, " << (returnTypeS.empty() ? "object" : returnTypeS) << " ret__) =>";
- _out << sb;
- _out << nl << "if(cb__ != null)";
- _out << sb;
- _out << nl << "cb__.Invoke" << spar;
- if(ret && outParams.empty())
- {
- _out << "ret__";
- }
- else if(ret || outParams.size() > 1)
+ //
+ // Write the completed callback
+ //
+ _out.inc();
+ _out << nl << "(" << delType << " cb__, " << (returnTypeS.empty() ? "object" : returnTypeS) << " ret__) =>";
+ _out << sb;
+ _out << nl << "if(cb__ != null)";
+ _out << sb;
+ _out << nl << "cb__.Invoke" << spar;
+ if(ret && outParams.empty())
+ {
+ _out << "ret__";
+ }
+ else if(ret || outParams.size() > 1)
+ {
+ if(ret)
{
- if(ret)
- {
- _out << "ret__." + resultStructReturnValueName(outParams);
- }
- for(ParamDeclList::const_iterator pli = outParams.begin(); pli != outParams.end(); ++pli)
- {
- _out << "ret__." + fixId((*pli)->name());
- }
+ _out << "ret__." + resultStructReturnValueName(outParams);
}
- else if(!outParams.empty())
+ for(ParamDeclList::const_iterator pli = outParams.begin(); pli != outParams.end(); ++pli)
{
- _out << "ret__";
+ _out << "ret__." + fixId((*pli)->name());
}
- _out << epar << ';';
- _out << eb;
- _out << eb << ",";
- _out << nl << "this, " << flatName << ", cookie__, completedCallback__);";
-
- _out.dec();
- _out << nl << op->name() << "_invoke__" << spar << argsAMI << "ctx__" << "synchronous__" << "completed__" << epar << ";";
- _out << nl << "return completed__;";
- _out << eb;
}
- _out << sp << nl << "#endregion"; // Asynchronous operations
+ else if(!outParams.empty())
+ {
+ _out << "ret__";
+ }
+ _out << epar << ';';
+ _out << eb;
+ _out << eb << ",";
+ _out << nl << "this, " << flatName << ", cookie__, completedCallback__);";
+
+ _out.dec();
+ _out << nl << op->name() << "_invoke__" << spar << argsAMI << "ctx__" << "synchronous__" << "completed__" << epar << ";";
+ _out << nl << "return completed__;";
+ _out << eb;
}
+ _out << sp << nl << "#endregion"; // Asynchronous operations
_out << sp << nl << "#region Checked and unchecked cast operations";
_out << sp << nl << "public static " << name << "Prx checkedCast(Ice.ObjectPrx b)";
@@ -5670,7 +5453,6 @@ Slice::Gen::HelperVisitor::visitSequence(const SequencePtr& p)
writeSequenceMarshalUnmarshalCode(_out, p, "v__", false, false);
_out << nl << "return v__;";
_out << eb;
-
_out << eb;
string prefix = "clr:generic:";
@@ -5861,8 +5643,8 @@ Slice::Gen::HelperVisitor::visitDictionary(const DictionaryPtr& p)
_out << eb;
}
-Slice::Gen::DispatcherVisitor::DispatcherVisitor(::IceUtilInternal::Output &out, bool compat)
- : CsVisitor(out, compat)
+Slice::Gen::DispatcherVisitor::DispatcherVisitor(::IceUtilInternal::Output &out)
+ : CsVisitor(out)
{
}
@@ -5907,44 +5689,40 @@ Slice::Gen::DispatcherVisitor::visitClassDefStart(const ClassDefPtr& p)
_out << sp << nl << "#region Slice operations";
}
- for(OperationList::const_iterator op = ops.begin(); op != ops.end(); ++op)
+ for(OperationList::const_iterator i = ops.begin(); i != ops.end(); ++i)
{
- bool amd = p->hasMetaData("amd") || (*op)->hasMetaData("amd");
+ OperationPtr op = *i;
+ bool amd = p->hasMetaData("amd") || op->hasMetaData("amd");
- string opname = (*op)->name();
+ string retS;
+ string opname = op->name();
vector<string> params;
vector<string> args;
- TypePtr ret;
+ TypePtr ret = op->returnType();
if(amd)
{
- opname = opname + "_async";
- params = getParamsAsync(*op, true);
- args = getArgsAsync(*op, true);
+ opname = opname + "Async";
+ params = getParamsAsync(op);
+ params.push_back(asyncResultType(op, "_System.Action") + " result__");
+ params.push_back("_System.Action<_System.Exception> exception__");
+ retS = "void";
}
else
{
+ retS = typeToString(ret, op->returnIsOptional());
opname = fixId(opname, DotNet::ICloneable, true);
- params = getParams(*op);
- ret = (*op)->returnType();
- args = getArgs(*op);
+ params = getParams(op);
}
- string retS = typeToString(ret, (*op)->returnIsOptional());
- _out << sp << nl << "public " << retS << " " << opname << spar << params << epar;
- _out << sb << nl;
- if(ret)
+ if(!p->isLocal())
{
- _out << "return ";
+ params.push_back("Ice.Current current__ = null");
}
- _out << opname << spar << args << "Ice.ObjectImpl.defaultCurrent" << epar << ';';
- _out << eb;
+
_out << sp << nl << "public abstract " << retS << " " << opname << spar << params;
- if(!p->isLocal())
- {
- _out << "Ice.Current current__";
- }
+
_out << epar << ';';
}
@@ -5962,173 +5740,8 @@ Slice::Gen::DispatcherVisitor::visitClassDefStart(const ClassDefPtr& p)
return true;
}
-Slice::Gen::AsyncVisitor::AsyncVisitor(::IceUtilInternal::Output &out, bool compat)
- : CsVisitor(out, compat)
-{
-}
-
-bool
-Slice::Gen::AsyncVisitor::visitModuleStart(const ModulePtr& p)
-{
- if(!p->hasAsyncOps())
- {
- return false;
- }
-
- _out << sp << nl << "namespace " << fixId(p->name());
- _out << sb;
- return true;
-}
-
-void
-Slice::Gen::AsyncVisitor::visitModuleEnd(const ModulePtr&)
-{
- _out << eb;
-}
-
-bool
-Slice::Gen::AsyncVisitor::visitClassDefStart(const ClassDefPtr&)
-{
- return true;
-}
-
-void
-Slice::Gen::AsyncVisitor::visitClassDefEnd(const ClassDefPtr&)
-{
-}
-
-void
-Slice::Gen::AsyncVisitor::visitOperation(const OperationPtr& p)
-{
- ContainerPtr container = p->container();
- ClassDefPtr cl = ClassDefPtr::dynamicCast(container);
-
- if(cl->isLocal())
- {
- return;
- }
-
- string name = p->name();
-
- if(cl->hasMetaData("amd") || p->hasMetaData("amd"))
- {
- string classNameAMD = "AMD_" + cl->name();
- string classNameAMDI = "_AMD_" + cl->name();
-
- vector<string> paramsAMD = getParamsAsyncCB(p, true, true);
-
- _out << sp;
- writeDocCommentOp(p);
- emitComVisibleAttribute();
- emitGeneratedCodeAttribute();
- _out << nl << "public interface " << classNameAMD << '_' << name << " : Ice.AMDCallback";
- _out << sb;
- _out << sp;
- writeDocCommentAMD(p, OutParam, "");
- _out << nl << "void ice_response" << spar << paramsAMD << epar << ';';
- _out << eb;
-
- TypePtr ret = p->returnType();
-
- ParamDeclList paramList = p->parameters();
- ParamDeclList outParams;
-
- for(ParamDeclList::const_iterator pli = paramList.begin(); pli != paramList.end(); ++pli)
- {
- if((*pli)->isOutParam())
- {
- outParams.push_back(*pli);
- }
- }
-
- ExceptionList throws = p->throws();
- throws.sort();
- throws.unique();
-
- //
- // Arrange exceptions into most-derived to least-derived order. If we don't
- // do this, a base exception handler can appear before a derived exception
- // handler, causing compiler warnings and resulting in the base exception
- // being marshaled instead of the derived exception.
- //
-#if defined(__SUNPRO_CC)
- throws.sort(Slice::derivedToBaseCompare);
-#else
- throws.sort(Slice::DerivedToBaseCompare());
-#endif
-
- _out << sp;
- emitGeneratedCodeAttribute();
- _out << nl << "class " << classNameAMDI << '_' << name
- << " : IceInternal.IncomingAsync, " << classNameAMD << '_' << name;
- _out << sb;
-
- _out << sp << nl << "public " << classNameAMDI << '_' << name << "(IceInternal.Incoming inc) : base(inc)";
- _out << sb;
- _out << eb;
-
- _out << sp << nl << "public void ice_response" << spar << paramsAMD << epar;
- _out << sb;
- _out << nl << "if(validateResponse__(true))";
- _out << sb;
- if(ret || !outParams.empty())
- {
- _out << nl << "try";
- _out << sb;
- _out << nl << "Ice.OutputStream os__ = startWriteParams__(" << opFormatTypeToString(p) << ");";
- writeMarshalUnmarshalParams(outParams, p, true);
- if(p->returnsClasses(false))
- {
- _out << nl << "os__.writePendingValues();";
- }
- _out << nl << "endWriteParams__(true);";
- _out << eb;
- _out << nl << "catch(Ice.LocalException ex__)";
- _out << sb;
- _out << nl << "exception__(ex__);";
- _out << nl << "return;";
- _out << eb;
- }
- else
- {
- _out << nl << "writeEmptyParams__();";
- }
- _out << nl << "response__();";
- _out << eb;
- _out << eb;
-
- if(!throws.empty())
- {
- _out << sp << nl << "override public void ice_exception(_System.Exception ex)";
- _out << sb;
- _out << nl << "try";
- _out << sb;
- _out << nl << "throw ex;";
- _out << eb;
- for(ExceptionList::const_iterator r = throws.begin(); r != throws.end(); ++r)
- {
- string exS = fixId((*r)->scoped());
- _out << nl << "catch(" << exS << " ex__)";
- _out << sb;
- _out << nl << "if(validateResponse__(false))";
- _out << sb;
- _out << nl << "writeUserException__(ex__, " << opFormatTypeToString(p) << ");";
- _out << nl << "response__();";
- _out << eb;
- _out << eb;
- }
- _out << nl << "catch(_System.Exception ex__)";
- _out << sb;
- _out << nl << "base.ice_exception(ex__);";
- _out << eb;
- _out << eb;
- }
- _out << eb;
- }
-}
-
-Slice::Gen::TieVisitor::TieVisitor(IceUtilInternal::Output& out, bool compat)
- : CsVisitor(out, compat)
+Slice::Gen::TieVisitor::TieVisitor(IceUtilInternal::Output& out)
+ : CsVisitor(out)
{
}
@@ -6222,26 +5835,38 @@ Slice::Gen::TieVisitor::visitClassDefStart(const ClassDefPtr& p)
for(OperationList::const_iterator r = ops.begin(); r != ops.end(); ++r)
{
bool hasAMD = p->hasMetaData("amd") || (*r)->hasMetaData("amd");
- string opName = hasAMD ? (*r)->name() + "_async" : fixId((*r)->name(), DotNet::ICloneable, true);
+ string opName = hasAMD ? (*r)->name() + "Async" : fixId((*r)->name(), DotNet::ICloneable, true);
TypePtr ret = (*r)->returnType();
- string retS = typeToString(ret);
+ string retS;
+ ParamDeclList outParams = getOutParams((*r)->parameters());
vector<string> params;
vector<string> args;
if(hasAMD)
{
- params = getParamsAsync((*r), true);
- args = getArgsAsync(*r, true);
+ params = getParamsAsync(*r);
+ params.push_back(asyncResultType(*r, "_System.Action") + " response__");
+ params.push_back("_System.Action<_System.Exception> exception__");
+ params.push_back("Ice.Current current__ = null");
+
+ args = getArgsAsync(*r);
+ args.push_back("response__");
+ args.push_back("exception__");
+ args.push_back("current__");
+ retS = "void";
}
else
{
params = getParams(*r);
+ params.push_back("Ice.Current current__ = null");
args = getArgs(*r);
+ args.push_back("current__");
+ retS = typeToString(ret, (*r)->returnIsOptional());
}
_out << sp << nl << "public override ";
- _out << (hasAMD ? string("void") : retS) << ' ' << opName << spar << params << "Ice.Current current__";
+ _out << retS << ' ' << opName << spar << params;
_out << epar;
_out << sb;
_out << nl;
@@ -6249,7 +5874,7 @@ Slice::Gen::TieVisitor::visitClassDefStart(const ClassDefPtr& p)
{
_out << "return ";
}
- _out << "_ice_delegate." << opName << spar << args << "current__";
+ _out << "_ice_delegate." << opName << spar << args;
_out << epar << ';';
_out << eb;
}
@@ -6279,31 +5904,41 @@ Slice::Gen::TieVisitor::writeInheritedOperationsWithOpNames(const ClassDefPtr& p
for(OperationList::const_iterator r = ops.begin(); r != ops.end(); ++r)
{
bool hasAMD = p->hasMetaData("amd") || (*r)->hasMetaData("amd");
- string opName = hasAMD ? (*r)->name() + "_async" : fixId((*r)->name(), DotNet::ICloneable, true);
+ string opName = hasAMD ? (*r)->name() + "Async" : fixId((*r)->name(), DotNet::ICloneable, true);
if(opNames.find(opName) != opNames.end())
{
continue;
}
opNames.insert(opName);
+ ParamDeclList outParams = getOutParams((*r)->parameters());
TypePtr ret = (*r)->returnType();
- string retS = typeToString(ret);
+ string retS;
vector<string> params;
vector<string> args;
if(hasAMD)
{
- params = getParamsAsync((*r), true);
- args = getArgsAsync(*r, true);
+ params = getParamsAsync(*r);
+ params.push_back(asyncResultType(*r, "_System.Action") + " response__");
+ params.push_back("_System.Action<_System.Exception> exception__");
+ args = getArgsAsync(*r);
+ args.push_back("response__");
+ args.push_back("exception__");
+ retS = "void";
}
else
{
params = getParams(*r);
args = getArgs(*r);
+ retS = typeToString(ret, (*r)->returnIsOptional());
}
+ params.push_back("Ice.Current current__ = null");
+ args.push_back("current__");
+
_out << sp << nl << "public override ";
- _out << (hasAMD ? string("void") : retS) << ' ' << opName << spar << params << "Ice.Current current__";
+ _out << retS << ' ' << opName << spar << params;
_out << epar;
_out << sb;
_out << nl;
@@ -6311,8 +5946,7 @@ Slice::Gen::TieVisitor::writeInheritedOperationsWithOpNames(const ClassDefPtr& p
{
_out << "return ";
}
- _out << "_ice_delegate." << opName << spar << args << "current__";
- _out << epar << ';';
+ _out << "_ice_delegate." << opName << spar << args << epar << ';';
_out << eb;
}
@@ -6323,8 +5957,8 @@ Slice::Gen::TieVisitor::writeInheritedOperationsWithOpNames(const ClassDefPtr& p
}
}
-Slice::Gen::BaseImplVisitor::BaseImplVisitor(IceUtilInternal::Output& out, bool compat)
- : CsVisitor(out, compat)
+Slice::Gen::BaseImplVisitor::BaseImplVisitor(IceUtilInternal::Output& out)
+ : CsVisitor(out)
{
}
@@ -6349,14 +5983,14 @@ Slice::Gen::BaseImplVisitor::writeOperation(const OperationPtr& op, bool comment
if(!cl->isLocal() && (cl->hasMetaData("amd") || op->hasMetaData("amd")))
{
ParamDeclList::const_iterator i;
- vector<string> pDecl = getParamsAsync(op, true);
+ vector<string> pDecl = getParamsAsync(op);
_out << "public ";
if(!forTie)
{
_out << "override ";
}
- _out << "void " << opName << "_async" << spar << pDecl << "Ice.Current current__" << epar;
+ _out << "void " << opName << "_async" << spar << pDecl << "Ice.Current current__ = null" << epar;
if(comment)
{
@@ -6405,7 +6039,7 @@ Slice::Gen::BaseImplVisitor::writeOperation(const OperationPtr& op, bool comment
_out << retS << ' ' << fixId(opName, DotNet::ICloneable, true) << spar << pDecls;
if(!cl->isLocal())
{
- _out << "Ice.Current current__";
+ _out << "Ice.Current current__ = null";
}
_out << epar;
if(comment)
@@ -6431,8 +6065,8 @@ Slice::Gen::BaseImplVisitor::writeOperation(const OperationPtr& op, bool comment
}
}
-Slice::Gen::ImplVisitor::ImplVisitor(IceUtilInternal::Output& out, bool compat) :
- BaseImplVisitor(out, compat)
+Slice::Gen::ImplVisitor::ImplVisitor(IceUtilInternal::Output& out) :
+ BaseImplVisitor(out)
{
}
@@ -6499,8 +6133,8 @@ Slice::Gen::ImplVisitor::visitClassDefEnd(const ClassDefPtr&)
_out << eb;
}
-Slice::Gen::ImplTieVisitor::ImplTieVisitor(IceUtilInternal::Output& out, bool compat)
- : BaseImplVisitor(out, compat)
+Slice::Gen::ImplTieVisitor::ImplTieVisitor(IceUtilInternal::Output& out)
+ : BaseImplVisitor(out)
{
}
diff --git a/cpp/src/slice2cs/Gen.h b/cpp/src/slice2cs/Gen.h
index 1ea677284c9..1a5623f467a 100644
--- a/cpp/src/slice2cs/Gen.h
+++ b/cpp/src/slice2cs/Gen.h
@@ -20,7 +20,7 @@ class CsVisitor : public CsGenerator, public ParserVisitor
{
public:
- CsVisitor(::IceUtilInternal::Output&, bool);
+ CsVisitor(::IceUtilInternal::Output&);
virtual ~CsVisitor();
protected:
@@ -33,10 +33,10 @@ protected:
virtual void writeInheritedOperations(const ClassDefPtr&);
virtual void writeDispatchAndMarshalling(const ClassDefPtr&);
virtual std::vector<std::string> getParams(const OperationPtr&);
- virtual std::vector<std::string> getParamsAsync(const OperationPtr&, bool);
+ virtual std::vector<std::string> getParamsAsync(const OperationPtr&);
virtual std::vector<std::string> getParamsAsyncCB(const OperationPtr&, bool, bool);
virtual std::vector<std::string> getArgs(const OperationPtr&);
- virtual std::vector<std::string> getArgsAsync(const OperationPtr&, bool);
+ virtual std::vector<std::string> getArgsAsync(const OperationPtr&);
void emitAttributes(const ContainedPtr&);
void emitComVisibleAttribute();
@@ -68,11 +68,10 @@ protected:
const std::string& = "", const std::string& = "");
void writeDocCommentTaskAsyncAMI(const OperationPtr&, const std::string&, const std::string& = "",
const std::string& = "", const std::string& = "");
- void writeDocCommentAMD(const OperationPtr&, ParamDir, const std::string&);
+ void writeDocCommentAMD(const OperationPtr&);
void writeDocCommentParam(const OperationPtr&, ParamDir, bool);
::IceUtilInternal::Output& _out;
- bool _compat;
};
class Gen : private ::IceUtil::noncopyable
@@ -83,7 +82,6 @@ public:
const std::vector<std::string>&,
const std::string&,
bool,
- bool,
bool);
~Gen();
@@ -108,7 +106,7 @@ private:
{
public:
- UnitVisitor(::IceUtilInternal::Output&, bool);
+ UnitVisitor(::IceUtilInternal::Output&);
virtual bool visitUnitStart(const UnitPtr&);
};
@@ -117,7 +115,7 @@ private:
{
public:
- CompactIdVisitor(IceUtilInternal::Output&, bool);
+ CompactIdVisitor(IceUtilInternal::Output&);
virtual bool visitUnitStart(const UnitPtr&);
virtual void visitUnitEnd(const UnitPtr&);
@@ -128,7 +126,7 @@ private:
{
public:
- TypesVisitor(::IceUtilInternal::Output&, bool);
+ TypesVisitor(::IceUtilInternal::Output&);
virtual bool visitModuleStart(const ModulePtr&);
virtual void visitModuleEnd(const ModulePtr&);
@@ -155,7 +153,7 @@ private:
{
public:
- AsyncDelegateVisitor(::IceUtilInternal::Output&, bool);
+ AsyncDelegateVisitor(::IceUtilInternal::Output&);
virtual bool visitModuleStart(const ModulePtr&);
virtual void visitModuleEnd(const ModulePtr&);
@@ -168,7 +166,7 @@ private:
{
public:
- ResultVisitor(::IceUtilInternal::Output&, bool);
+ ResultVisitor(::IceUtilInternal::Output&);
virtual bool visitModuleStart(const ModulePtr&);
virtual void visitModuleEnd(const ModulePtr&);
@@ -181,7 +179,7 @@ private:
{
public:
- ProxyVisitor(::IceUtilInternal::Output&, bool);
+ ProxyVisitor(::IceUtilInternal::Output&);
virtual bool visitModuleStart(const ModulePtr&);
virtual void visitModuleEnd(const ModulePtr&);
@@ -194,7 +192,7 @@ private:
{
public:
- OpsVisitor(::IceUtilInternal::Output&, bool);
+ OpsVisitor(::IceUtilInternal::Output&);
virtual bool visitModuleStart(const ModulePtr&);
virtual void visitModuleEnd(const ModulePtr&);
@@ -208,7 +206,7 @@ private:
{
public:
- HelperVisitor(::IceUtilInternal::Output&, bool);
+ HelperVisitor(::IceUtilInternal::Output&);
virtual bool visitModuleStart(const ModulePtr&);
virtual void visitModuleEnd(const ModulePtr&);
@@ -222,31 +220,18 @@ private:
{
public:
- DispatcherVisitor(::IceUtilInternal::Output&, bool);
+ DispatcherVisitor(::IceUtilInternal::Output&);
virtual bool visitModuleStart(const ModulePtr&);
virtual void visitModuleEnd(const ModulePtr&);
virtual bool visitClassDefStart(const ClassDefPtr&);
};
- class AsyncVisitor : public CsVisitor
- {
- public:
-
- AsyncVisitor(::IceUtilInternal::Output&, bool);
-
- virtual bool visitModuleStart(const ModulePtr&);
- virtual void visitModuleEnd(const ModulePtr&);
- virtual bool visitClassDefStart(const ClassDefPtr&);
- virtual void visitClassDefEnd(const ClassDefPtr&);
- virtual void visitOperation(const OperationPtr&);
- };
-
class TieVisitor : public CsVisitor
{
public:
- TieVisitor(::IceUtilInternal::Output&, bool);
+ TieVisitor(::IceUtilInternal::Output&);
virtual bool visitModuleStart(const ModulePtr&);
virtual void visitModuleEnd(const ModulePtr&);
@@ -263,7 +248,7 @@ private:
{
public:
- BaseImplVisitor(::IceUtilInternal::Output&, bool);
+ BaseImplVisitor(::IceUtilInternal::Output&);
protected:
@@ -274,7 +259,7 @@ private:
{
public:
- ImplVisitor(::IceUtilInternal::Output&, bool);
+ ImplVisitor(::IceUtilInternal::Output&);
virtual bool visitModuleStart(const ModulePtr&);
virtual void visitModuleEnd(const ModulePtr&);
@@ -286,7 +271,7 @@ private:
{
public:
- ImplTieVisitor(::IceUtilInternal::Output&, bool);
+ ImplTieVisitor(::IceUtilInternal::Output&);
virtual bool visitModuleStart(const ModulePtr&);
virtual void visitModuleEnd(const ModulePtr&);
diff --git a/cpp/src/slice2cs/Main.cpp b/cpp/src/slice2cs/Main.cpp
index c09fc9d0d54..5850c2cb640 100644
--- a/cpp/src/slice2cs/Main.cpp
+++ b/cpp/src/slice2cs/Main.cpp
@@ -78,7 +78,6 @@ usage(const char* n)
"--ice Allow reserved Ice prefix in Slice identifiers.\n"
"--underscore Allow underscores in Slice identifiers.\n"
"--checksum Generate checksums for Slice definitions.\n"
- "--compat Generate compatibility code to support depreacted features.\n"
;
}
@@ -104,7 +103,6 @@ compile(int argc, char* argv[])
opts.addOpt("", "ice");
opts.addOpt("", "underscore");
opts.addOpt("", "checksum");
- opts.addOpt("", "compat");
bool validate = false;
for(int i = 0; i < argc; ++i)
@@ -186,8 +184,6 @@ compile(int argc, char* argv[])
bool checksum = opts.isSet("checksum");
- bool compat = opts.isSet("compat");
-
if(args.empty())
{
getErrorStream() << argv[0] << ": error: no input file" << endl;
@@ -322,7 +318,7 @@ compile(int argc, char* argv[])
{
try
{
- Gen gen(icecpp->getBaseName(), includePaths, output, impl, implTie, compat);
+ Gen gen(icecpp->getBaseName(), includePaths, output, impl, implTie);
gen.generate(p);
if(tie)
{