diff options
author | Bernard Normier <bernard@zeroc.com> | 2007-11-30 11:01:27 -0500 |
---|---|---|
committer | Bernard Normier <bernard@zeroc.com> | 2007-11-30 11:01:27 -0500 |
commit | 0b6a5d811e79550709b1e0589580976dba8c5aaa (patch) | |
tree | abf3606e45b80715a24b037c28866ba831f34560 /cpp/src/slice2sl/Gen.cpp | |
parent | Implemented service observers (diff) | |
parent | Fixed bug 2584 in Java/C# for consistency (diff) | |
download | ice-0b6a5d811e79550709b1e0589580976dba8c5aaa.tar.bz2 ice-0b6a5d811e79550709b1e0589580976dba8c5aaa.tar.xz ice-0b6a5d811e79550709b1e0589580976dba8c5aaa.zip |
Merge branch 'master' of ssh://cvs.zeroc.com/home/git/ice
Diffstat (limited to 'cpp/src/slice2sl/Gen.cpp')
-rwxr-xr-x | cpp/src/slice2sl/Gen.cpp | 58 |
1 files changed, 47 insertions, 11 deletions
diff --git a/cpp/src/slice2sl/Gen.cpp b/cpp/src/slice2sl/Gen.cpp index fef16d18686..0d89a1f5628 100755 --- a/cpp/src/slice2sl/Gen.cpp +++ b/cpp/src/slice2sl/Gen.cpp @@ -361,7 +361,7 @@ Slice::CsVisitor::getParams(const OperationPtr& op) } vector<string> -Slice::CsVisitor::getParamsAsync(const OperationPtr& op, bool amd) +Slice::CsVisitor::getParamsAsync(const OperationPtr& op, AsyncType type ) { vector<string> params; @@ -369,7 +369,15 @@ 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()); - params.push_back(scope + (amd ? "AMD_" : "AMI_") + cl->name() + '_' + op->name() + " cb__"); + if(type == AMIDelegate) + { + params.push_back(scope + "AMI_" + cl->name() + '_' + op->name() + "_response resp__"); + params.push_back(scope + "AMI_" + cl->name() + '_' + op->name() + "_exception ex__"); + } + else + { + params.push_back(scope + (type == AMD ? "AMD_" : "AMI_") + cl->name() + '_' + op->name() + " cb__"); + } ParamDeclList paramList = op->parameters(); for(ParamDeclList::const_iterator q = paramList.begin(); q != paramList.end(); ++q) @@ -2155,7 +2163,7 @@ Slice::Gen::ProxyVisitor::visitOperation(const OperationPtr& p) if(cl->hasMetaData("ami") || p->hasMetaData("ami")) { - vector<string> paramsAMI = getParamsAsync(p, false); + vector<string> paramsAMI = getParamsAsync(p, AMIDelegate); // // Write two versions of the operation - with and without a @@ -2272,7 +2280,7 @@ Slice::Gen::OpsVisitor::writeOperations(const ClassDefPtr& p, bool noCurrent) if(amd) { - params = getParamsAsync(op, true); + params = getParamsAsync(op, AMD); } else { @@ -2601,7 +2609,8 @@ Slice::Gen::HelperVisitor::visitClassDefStart(const ClassDefPtr& p) _out << sp << nl << "#region Asynchronous operations"; hasAsyncOps = true; } - vector<string> paramsAMI = getParamsAsync(op, false); + vector<string> paramsAMI = getParamsAsync(op, AMI); + vector<string> paramsAMIDel = getParamsAsync(op, AMIDelegate); vector<string> argsAMI = getArgsAsync(op); string opName = op->name(); @@ -2610,16 +2619,21 @@ Slice::Gen::HelperVisitor::visitClassDefStart(const ClassDefPtr& p) // Write two versions of the operation - with and without a // context parameter // + + string callbackName = fixId(p->scope()) + "AMI_" + containingClass->name() + "_" + opName; + _out << sp; - _out << nl << "public void " << opName << "_async" << spar << paramsAMI << epar; + _out << nl << "public void " << opName << "_async" << spar << paramsAMIDel << epar; _out << sb; + _out << nl << callbackName << " cb__ = new " << callbackName << "(resp__, ex__);"; _out << nl << opName << "_async" << spar << argsAMI << "null" << "false" << epar << ';'; _out << eb; _out << sp; - _out << nl << "public void " << opName << "_async" << spar << paramsAMI + _out << nl << "public void " << opName << "_async" << spar << paramsAMIDel << "_System.Collections.Generic.Dictionary<string, string> ctx__" << epar; _out << sb; + _out << nl << callbackName << " cb__ = new " << callbackName << "(resp__, ex__);"; _out << nl << opName << "_async" << spar << argsAMI << "ctx__" << "true" << epar << ';'; _out << eb; @@ -3151,14 +3165,27 @@ Slice::Gen::AsyncVisitor::visitOperation(const OperationPtr& p) vector<string> params = getParamsAsyncCB(p); vector<string> args = getArgsAsyncCB(p); - vector<string> paramsInvoke = getParamsAsync(p, false); + vector<string> paramsInvoke = getParamsAsync(p, AMI); - _out << sp << nl << "public abstract class AMI_" << cl->name() << '_' + _out << nl << "public delegate void AMI_" << cl->name() << "_" << name << "_response" << spar << params + << epar << ";"; + _out << nl << "public delegate void AMI_" << cl->name() << "_" << name << "_exception(Ice.Exception ex);"; + + _out << sp << nl << "public sealed class AMI_" << cl->name() << '_' << name << " : IceInternal.OutgoingAsync"; _out << sb; _out << sp; - _out << nl << "public abstract void ice_response" << spar << params << epar << ';'; + _out << nl << "public AMI_" << cl->name() << "_" << name << "(AMI_" << cl->name() << "_" << name + << "_response response, AMI_" << cl->name() << "_" << name << "_exception exception)"; + _out << sb; + _out << nl << "response_ = response;"; + _out << nl << "exception_ = exception;"; + _out << nl; + _out << nl << "System.Diagnostics.Debug.Assert(response_ != null);"; + _out << nl << "System.Diagnostics.Debug.Assert(exception_ != null);"; + _out << eb; + _out << sp << nl << "public void invoke__" << spar << "Ice.ObjectPrx prx__" << paramsInvoke << "_System.Collections.Generic.Dictionary<string, string> ctx__" << epar; _out << sb; @@ -3285,8 +3312,17 @@ Slice::Gen::AsyncVisitor::visitOperation(const OperationPtr& p) _out << nl << "return;"; _out << eb; } - _out << nl << "ice_response" << spar << args << epar << ';'; + _out << nl << "response_" << spar << args << epar << ';'; _out << eb; + + _out << sp << nl << "protected override void exception__(Ice.Exception ex)"; + _out << sb; + _out << nl << "exception_(ex);"; + _out << eb; + + _out << nl; + _out << nl << "private AMI_" << cl->name() << "_" << name << "_response response_ = null;"; + _out << nl << "private AMI_" << cl->name() << "_" << name << "_exception exception_ = null;"; _out << eb; } } |