summaryrefslogtreecommitdiff
path: root/cpp
diff options
context:
space:
mode:
authorMarc Laukien <marc@zeroc.com>2004-02-15 21:19:54 +0000
committerMarc Laukien <marc@zeroc.com>2004-02-15 21:19:54 +0000
commit3ede1ddccf6c3f4c2f8a19fc8d16e9827c607cc2 (patch)
treef04bbbc008badb7eb13e499ff92fa7cfa100b888 /cpp
parentminor (diff)
downloadice-3ede1ddccf6c3f4c2f8a19fc8d16e9827c607cc2.tar.bz2
ice-3ede1ddccf6c3f4c2f8a19fc8d16e9827c607cc2.tar.xz
ice-3ede1ddccf6c3f4c2f8a19fc8d16e9827c607cc2.zip
more AMI stuff
Diffstat (limited to 'cpp')
-rw-r--r--cpp/include/Ice/OutgoingAsync.h49
-rw-r--r--cpp/include/Ice/Proxy.h9
-rw-r--r--cpp/include/IceUtil/OutputUtil.h44
-rw-r--r--cpp/src/Ice/BasicStream.cpp11
-rw-r--r--cpp/src/Ice/Connection.cpp2
-rw-r--r--cpp/src/Ice/OutgoingAsync.cpp234
-rw-r--r--cpp/src/Ice/Proxy.cpp87
-rw-r--r--cpp/src/Ice/ProxyFactory.cpp56
-rw-r--r--cpp/src/Ice/ProxyFactory.h17
-rw-r--r--cpp/src/IceUtil/OutputUtil.cpp38
-rw-r--r--cpp/src/slice2cpp/Gen.cpp595
11 files changed, 532 insertions, 610 deletions
diff --git a/cpp/include/Ice/OutgoingAsync.h b/cpp/include/Ice/OutgoingAsync.h
index 0c809e14f13..a7ba8f9cecb 100644
--- a/cpp/include/Ice/OutgoingAsync.h
+++ b/cpp/include/Ice/OutgoingAsync.h
@@ -18,9 +18,8 @@
#include <IceUtil/Time.h>
#include <Ice/OutgoingAsyncF.h>
-#include <Ice/ConnectionF.h>
#include <Ice/ReferenceF.h>
-#include <Ice/InstanceF.h>
+#include <Ice/ConnectionF.h>
#include <Ice/Current.h>
namespace IceInternal
@@ -32,49 +31,47 @@ class BasicStream;
// We need virtual inheritance from shared, because the user might use
// multiple inheritance from IceUtil::Shared.
//
-class ICE_API OutgoingAsync : virtual public ::IceUtil::Shared
+class ICE_API OutgoingAsync : virtual public IceUtil::Shared
{
public:
OutgoingAsync();
virtual ~OutgoingAsync();
- virtual void ice_exception(const ::IceUtil::Exception&) = 0;
+ virtual void ice_exception(const Ice::Exception&) = 0;
- void __setup(const ConnectionPtr&, const ReferencePtr&, const std::string&, ::Ice::OperationMode,
- const ::Ice::Context&);
+ void __setup(const IceInternal::ReferencePtr&);
- void __invoke();
void __finished(BasicStream&);
- void __finished(const ::Ice::LocalException&);
+ void __finished(const Ice::Exception&);
bool __timedOut() const;
- BasicStream* __is();
- BasicStream* __os();
+ // Inlined for speed optimization.
+ BasicStream* __istream() { return __is; }
+ BasicStream* __ostream() { return __os; }
protected:
+ void __prepare(const std::string&, Ice::OperationMode, const Ice::Context&);
+ void __send();
+
virtual void __response(bool) = 0;
+ BasicStream* __is;
+ BasicStream* __os;
+
+ int __cnt;
+
private:
- void warning(const ::Ice::Exception&) const;
- void warning(const ::std::exception&) const;
+ void warning(const Ice::Exception&) const;
+ void warning(const std::exception&) const;
void warning() const;
+ const ReferencePtr _reference;
ConnectionPtr _connection;
-
- //
- // We need a separate InstancePtr, because _is and _os only hold a
- // Instance* for optimization.
- //
- InstancePtr _instance;
-
IceUtil::Time _absoluteTimeout;
-
- BasicStream* _is;
- BasicStream* _os;
};
}
@@ -82,12 +79,14 @@ private:
namespace Ice
{
-class ICE_API AMI_Object_ice_invoke : public ::IceInternal::OutgoingAsync
+class ICE_API AMI_Object_ice_invoke : public IceInternal::OutgoingAsync
{
public:
- virtual void ice_response(bool, const ::std::vector< ::Ice::Byte>&) = 0;
- virtual void ice_exception(const ::IceUtil::Exception&) = 0;
+ virtual void ice_response(bool, const std::vector<Ice::Byte>&) = 0;
+ virtual void ice_exception(const Ice::Exception&) = 0;
+
+ void __invoke(const std::string& operation, OperationMode, const std::vector<Byte>&, const Context&);
private:
diff --git a/cpp/include/Ice/Proxy.h b/cpp/include/Ice/Proxy.h
index 9485348f18c..957df9f0c7d 100644
--- a/cpp/include/Ice/Proxy.h
+++ b/cpp/include/Ice/Proxy.h
@@ -180,9 +180,6 @@ public:
virtual ::Ice::FacetPath ice_facets(const ::Ice::Context&) = 0;
virtual bool ice_invoke(const ::std::string&, ::Ice::OperationMode, const ::std::vector< ::Ice::Byte>&,
::std::vector< ::Ice::Byte>&, const ::Ice::Context&) = 0;
- virtual void ice_invoke_async(const ::Ice::AMI_Object_ice_invokePtr&,
- const ::std::string&, ::Ice::OperationMode, const ::std::vector< ::Ice::Byte>&,
- const ::Ice::Context&) = 0;
};
} }
@@ -203,9 +200,6 @@ public:
virtual ::Ice::FacetPath ice_facets(const ::Ice::Context&);
virtual bool ice_invoke(const ::std::string&, ::Ice::OperationMode, const ::std::vector< ::Ice::Byte>&,
::std::vector< ::Ice::Byte>&, const ::Ice::Context&);
- virtual void ice_invoke_async(const ::Ice::AMI_Object_ice_invokePtr&,
- const ::std::string&, ::Ice::OperationMode, const ::std::vector< ::Ice::Byte>&,
- const ::Ice::Context&);
void __copyFrom(const ::IceInternal::Handle< ::IceDelegateM::Ice::Object>&);
@@ -236,9 +230,6 @@ public:
virtual ::Ice::FacetPath ice_facets(const ::Ice::Context&);
virtual bool ice_invoke(const ::std::string&, ::Ice::OperationMode, const ::std::vector< ::Ice::Byte>&,
::std::vector< ::Ice::Byte>&, const ::Ice::Context&);
- virtual void ice_invoke_async(const ::Ice::AMI_Object_ice_invokePtr&,
- const ::std::string&, ::Ice::OperationMode, const ::std::vector< ::Ice::Byte>&,
- const ::Ice::Context&);
void __copyFrom(const ::IceInternal::Handle< ::IceDelegateD::Ice::Object>&);
protected:
diff --git a/cpp/include/IceUtil/OutputUtil.h b/cpp/include/IceUtil/OutputUtil.h
index 58849604e3c..d44851ca844 100644
--- a/cpp/include/IceUtil/OutputUtil.h
+++ b/cpp/include/IceUtil/OutputUtil.h
@@ -18,6 +18,7 @@
#include <IceUtil/Config.h>
#include <fstream>
#include <stack>
+#include <vector>
namespace IceUtil
{
@@ -104,16 +105,22 @@ public:
Output(std::ostream&);
Output(const char*);
+ virtual void print(const char*); // Print a string.
+
void setBeginBlock(const char *); // what do we use at block starts?
void setEndBlock(const char *); // what do we use the block end?
void sb(); // Start a block.
void eb(); // End a block.
+ void spar(); // Start a paramater list.
+ void epar(); // End a paramater list.
+
private:
std::string _blockStart;
std::string _blockEnd;
+ int _par; // If >= 0, we are writing a parameter list.
};
template<typename T>
@@ -126,6 +133,17 @@ operator<<(Output& out, const T& val)
return out;
}
+template<typename T>
+Output&
+operator<<(Output& out, const std::vector<T>& val)
+{
+ for(typename std::vector<T>::const_iterator p = val.begin(); p != val.end(); ++p)
+ {
+ out << *p;
+ }
+ return out;
+}
+
template<>
inline Output&
operator<<(Output& o, const NextLine&)
@@ -168,6 +186,32 @@ operator<<(Output& o, const EndBlock&)
return o;
}
+class ICE_UTIL_API StartPar
+{
+};
+extern ICE_UTIL_API StartPar spar;
+
+template<>
+inline Output&
+operator<<(Output& o, const StartPar&)
+{
+ o.spar();
+ return o;
+}
+
+class ICE_UTIL_API EndPar
+{
+};
+extern ICE_UTIL_API EndPar epar;
+
+template<>
+inline Output&
+operator<<(Output& o, const EndPar&)
+{
+ o.epar();
+ return o;
+}
+
ICE_UTIL_API Output& operator<<(Output&, std::ios_base& (*)(std::ios_base&));
// ----------------------------------------------------------------------
diff --git a/cpp/src/Ice/BasicStream.cpp b/cpp/src/Ice/BasicStream.cpp
index 8989b206176..24d9ea4bbda 100644
--- a/cpp/src/Ice/BasicStream.cpp
+++ b/cpp/src/Ice/BasicStream.cpp
@@ -1385,14 +1385,15 @@ IceInternal::BasicStream::throwException()
traceSlicing("exception", id, _slicingCat, _instance->logger());
}
skipSlice(); // Slice off what we don't understand.
- read(id); // Read type id for next slice.
+ read(id); // Read type id for next slice.
}
}
+
//
- // Getting here should be impossible: we can get here only if the
- // sender has marshaled a sequence of type IDs, none of which we
- // have factory for. This means that sender and receiver disagree
- // about the Slice definitions they use.
+ // We can get here only if the sender has marshaled a sequence of
+ // type IDs, none of which we have factory for. This means that
+ // sender and receiver disagree about the Slice definitions they
+ // use.
//
throw UnknownUserException(__FILE__, __LINE__);
}
diff --git a/cpp/src/Ice/Connection.cpp b/cpp/src/Ice/Connection.cpp
index 1d00d73b1ea..9d8e10ac782 100644
--- a/cpp/src/Ice/Connection.cpp
+++ b/cpp/src/Ice/Connection.cpp
@@ -612,7 +612,7 @@ IceInternal::Connection::sendAsyncRequest(const OutgoingAsyncPtr& out)
_exception->ice_throw();
}
- BasicStream* os = out->__os();
+ BasicStream* os = out->__ostream();
//
// Fill in the request ID.
diff --git a/cpp/src/Ice/OutgoingAsync.cpp b/cpp/src/Ice/OutgoingAsync.cpp
index 244f8914456..7f6ac044561 100644
--- a/cpp/src/Ice/OutgoingAsync.cpp
+++ b/cpp/src/Ice/OutgoingAsync.cpp
@@ -16,8 +16,8 @@
#include <Ice/Object.h>
#include <Ice/Connection.h>
#include <Ice/Reference.h>
-#include <Ice/LocalException.h>
#include <Ice/Instance.h>
+#include <Ice/LocalException.h>
#include <Ice/Properties.h>
#include <Ice/LoggerUtil.h>
@@ -32,159 +32,117 @@ void IceInternal::incRef(AMI_Object_ice_invoke* p) { p->__incRef(); }
void IceInternal::decRef(AMI_Object_ice_invoke* p) { p->__decRef(); }
IceInternal::OutgoingAsync::OutgoingAsync() :
- _is(0),
- _os(0)
+ __is(0),
+ __os(0),
+ __cnt(0)
{
}
IceInternal::OutgoingAsync::~OutgoingAsync()
{
- delete _is;
- delete _os;
-}
-
-void
-IceInternal::OutgoingAsync::__setup(const ConnectionPtr& connection, const ReferencePtr& ref,
- const string& operation, OperationMode mode, const Context& context)
-{
- _connection = connection;
- _instance = ref->instance;
- delete _is;
- delete _os;
- _is = new BasicStream(_instance.get());
- _os = new BasicStream(_instance.get());
+ delete __is;
+ delete __os;
- _connection->prepareRequest(_os);
-
- ref->identity.__write(_os);
- _os->write(ref->facet);
- _os->write(operation);
- _os->write(static_cast<Byte>(mode));
- _os->writeSize(Int(context.size()));
- Context::const_iterator p;
- for(p = context.begin(); p != context.end(); ++p)
+ if(_connection)
{
- _os->write(p->first);
- _os->write(p->second);
+ _connection->decProxyCount();
}
-
- //
- // Input and output parameters are always sent in an
- // encapsulation, which makes it possible to forward requests as
- // blobs.
- //
- _os->startWriteEncaps();
}
void
-IceInternal::OutgoingAsync::__invoke()
+IceInternal::OutgoingAsync::__setup(const ReferencePtr& ref)
{
- _os->endWriteEncaps();
-
- try
- {
- _connection->sendAsyncRequest(this);
- }
- catch(const LocalException&)
- {
- //
- // Twoway requests report exceptions using finished().
- //
- assert(false);
- }
-
- if(_connection->timeout() >= 0)
- {
- _absoluteTimeout = IceUtil::Time::now() + IceUtil::Time::milliSeconds(_connection->timeout());
- }
+ const_cast<ReferencePtr&>(_reference) = ref;
}
void
IceInternal::OutgoingAsync::__finished(BasicStream& is)
{
+ DispatchStatus status;
+
try
{
- _is->swap(is);
- Byte status;
- _is->read(status);
+ __is->swap(is);
+ Byte b;
+ __is->read(b);
+ status = static_cast<DispatchStatus>(b);
- switch(static_cast<DispatchStatus>(status))
+ switch(status)
{
case DispatchOK:
- {
- _is->startReadEncaps();
- __response(true);
- break;
- }
-
case DispatchUserException:
{
- _is->startReadEncaps();
- __response(false);
+ __is->startReadEncaps();
break;
}
case DispatchObjectNotExist:
{
ObjectNotExistException ex(__FILE__, __LINE__);
- ex.id.__read(_is);
- _is->read(ex.facet);
- _is->read(ex.operation);
- ice_exception(ex);
- break;
+ ex.id.__read(__is);
+ __is->read(ex.facet);
+ __is->read(ex.operation);
+ throw ex;
}
case DispatchFacetNotExist:
{
FacetNotExistException ex(__FILE__, __LINE__);
- ex.id.__read(_is);
- _is->read(ex.facet);
- _is->read(ex.operation);
- ice_exception(ex);
- break;
+ ex.id.__read(__is);
+ __is->read(ex.facet);
+ __is->read(ex.operation);
+ throw ex;
}
case DispatchOperationNotExist:
{
OperationNotExistException ex(__FILE__, __LINE__);
- ex.id.__read(_is);
- _is->read(ex.facet);
- _is->read(ex.operation);
- ice_exception(ex);
- break;
+ ex.id.__read(__is);
+ __is->read(ex.facet);
+ __is->read(ex.operation);
+ throw ex;
}
case DispatchUnknownException:
{
UnknownException ex(__FILE__, __LINE__);
- _is->read(ex.unknown);
- ice_exception(ex);
- break;
+ __is->read(ex.unknown);
+ throw ex;
}
case DispatchUnknownLocalException:
{
UnknownLocalException ex(__FILE__, __LINE__);
- _is->read(ex.unknown);
- ice_exception(ex);
- break;
+ __is->read(ex.unknown);
+ throw ex;
}
case DispatchUnknownUserException:
{
UnknownUserException ex(__FILE__, __LINE__);
- _is->read(ex.unknown);
- ice_exception(ex);
- break;
+ __is->read(ex.unknown);
+ throw ex;
}
default:
{
- ice_exception(UnknownReplyStatusException(__FILE__, __LINE__));
- break;
+ UnknownReplyStatusException ex(__FILE__, __LINE__);
+ throw ex;
}
}
}
+ catch(const LocalException& ex)
+ {
+ __finished(ex);
+ return;
+ }
+
+ assert(status == DispatchOK || status == DispatchUserException);
+
+ try
+ {
+ __response(status == DispatchOK);
+ }
catch(const Exception& ex)
{
warning(ex);
@@ -200,7 +158,7 @@ IceInternal::OutgoingAsync::__finished(BasicStream& is)
}
void
-IceInternal::OutgoingAsync::__finished(const LocalException& exc)
+IceInternal::OutgoingAsync::__finished(const Exception& exc)
{
try
{
@@ -233,24 +191,66 @@ IceInternal::OutgoingAsync::__timedOut() const
}
}
-BasicStream*
-IceInternal::OutgoingAsync::__is()
+void
+IceInternal::OutgoingAsync::__prepare(const string& operation, OperationMode mode, const Context& context)
{
- return _is;
+ delete __is;
+ delete __os;
+ __is = new BasicStream(_reference->instance.get());
+ __os = new BasicStream(_reference->instance.get());
+
+ if(_connection)
+ {
+ _connection->decProxyCount();
+ _connection = 0;
+ }
+
+ _connection = _reference->getConnection();
+ _connection->incProxyCount();
+
+ _connection->prepareRequest(__os);
+ _reference->identity.__write(__os);
+ __os->write(_reference->facet);
+ __os->write(operation);
+ __os->write(static_cast<Byte>(mode));
+ __os->writeSize(Int(context.size()));
+ Context::const_iterator p;
+ for(p = context.begin(); p != context.end(); ++p)
+ {
+ __os->write(p->first);
+ __os->write(p->second);
+ }
+
+ __os->startWriteEncaps();
}
-BasicStream*
-IceInternal::OutgoingAsync::__os()
+void
+IceInternal::OutgoingAsync::__send()
{
- return _os;
+ try
+ {
+ _connection->sendAsyncRequest(this);
+ }
+ catch(const LocalException&)
+ {
+ //
+ // Twoway requests report exceptions using finished().
+ //
+ assert(false);
+ }
+
+ if(_connection->timeout() >= 0)
+ {
+ _absoluteTimeout = IceUtil::Time::now() + IceUtil::Time::milliSeconds(_connection->timeout());
+ }
}
void
IceInternal::OutgoingAsync::warning(const Exception& ex) const
{
- if(_instance->properties()->getPropertyAsIntWithDefault("Ice.Warn.AMICallback", 1) > 0)
+ if(_reference->instance->properties()->getPropertyAsIntWithDefault("Ice.Warn.AMICallback", 1) > 0)
{
- Warning out(_instance->logger());
+ Warning out(_reference->instance->logger());
out << "Ice::Exception raised by AMI callback:\n" << ex;
}
}
@@ -258,9 +258,9 @@ IceInternal::OutgoingAsync::warning(const Exception& ex) const
void
IceInternal::OutgoingAsync::warning(const std::exception& ex) const
{
- if(_instance->properties()->getPropertyAsIntWithDefault("Ice.Warn.AMICallback", 1) > 0)
+ if(_reference->instance->properties()->getPropertyAsIntWithDefault("Ice.Warn.AMICallback", 1) > 0)
{
- Warning out(_instance->logger());
+ Warning out(_reference->instance->logger());
out << "std::exception raised by AMI callback:\n" << ex.what();
}
}
@@ -268,28 +268,44 @@ IceInternal::OutgoingAsync::warning(const std::exception& ex) const
void
IceInternal::OutgoingAsync::warning() const
{
- if(_instance->properties()->getPropertyAsIntWithDefault("Ice.Warn.AMICallback", 1) > 0)
+ if(_reference->instance->properties()->getPropertyAsIntWithDefault("Ice.Warn.AMICallback", 1) > 0)
{
- Warning out(_instance->logger());
+ Warning out(_reference->instance->logger());
out << "unknown exception raised by AMI callback";
}
}
void
+Ice::AMI_Object_ice_invoke::__invoke(const string& operation, OperationMode mode, const vector<Byte>& inParams,
+ const Context& context)
+{
+ try
+ {
+ __prepare(operation, mode, context);
+ __os->writeBlob(inParams);
+ __os->endWriteEncaps();
+ }
+ catch(const LocalException& ex)
+ {
+ __finished(ex);
+ return;
+ }
+ __send();
+}
+
+void
Ice::AMI_Object_ice_invoke::__response(bool ok) // ok == true means no user exception.
{
vector<Byte> outParams;
try
{
- BasicStream* __is = this->__is();
Int sz = __is->getReadEncapsSize();
__is->readBlob(outParams, sz);
}
- catch(const Exception& ex)
+ catch(const LocalException& ex)
{
- ice_exception(ex);
+ __finished(ex);
return;
}
ice_response(ok, outParams);
}
-
diff --git a/cpp/src/Ice/Proxy.cpp b/cpp/src/Ice/Proxy.cpp
index c37bc69ae0e..5dce0dcd61b 100644
--- a/cpp/src/Ice/Proxy.cpp
+++ b/cpp/src/Ice/Proxy.cpp
@@ -12,8 +12,6 @@
//
// **********************************************************************
-#include <IceUtil/Thread.h>
-
#include <Ice/Proxy.h>
#include <Ice/ProxyFactory.h>
#include <Ice/Object.h>
@@ -24,8 +22,6 @@
#include <Ice/Reference.h>
#include <Ice/Endpoint.h>
#include <Ice/Instance.h>
-#include <Ice/LoggerUtil.h>
-#include <Ice/TraceLevels.h>
#include <Ice/Connection.h>
#include <Ice/RouterInfo.h>
#include <Ice/LocatorInfo.h>
@@ -325,16 +321,10 @@ IceProxy::Ice::Object::ice_invoke_async(const AMI_Object_ice_invokePtr& cb,
const vector<Byte>& inParams,
const Context& context)
{
- try
- {
- __checkTwowayOnly("ice_invoke_async");
- Handle< ::IceDelegate::Ice::Object> __del = __getDelegate();
- __del->ice_invoke_async(cb, operation, mode, inParams, context);
- }
- catch(const LocalException& __ex)
- {
- cb->__finished(__ex);
- }
+ __checkTwowayOnly("ice_invoke_async");
+ cb->__setup(__reference());
+ cb->__invoke(operation, mode, inParams, context);
+
}
Context
@@ -693,54 +683,14 @@ IceProxy::Ice::Object::__handleException(const LocalException& ex, int& cnt)
_reference->locatorInfo->clearObjectCache(_reference);
}
- ++cnt;
-
- TraceLevelsPtr traceLevels = _reference->instance->traceLevels();
- LoggerPtr logger = _reference->instance->logger();
ProxyFactoryPtr proxyFactory = _reference->instance->proxyFactory();
-
- //
- // Instance components may be null if Communicator has been destroyed.
- //
- if(traceLevels && logger && proxyFactory)
+ if(proxyFactory)
{
- const std::vector<int>& retryIntervals = proxyFactory->getRetryIntervals();
-
- if(cnt > static_cast<int>(retryIntervals.size()))
- {
- if(traceLevels->retry >= 1)
- {
- Trace out(logger, traceLevels->retryCat);
- out << "cannot retry operation call because retry limit has been exceeded\n" << ex;
- }
- ex.ice_throw();
- }
-
- if(traceLevels->retry >= 1)
- {
- Trace out(logger, traceLevels->retryCat);
- out << "re-trying operation call";
- if(cnt > 0 && retryIntervals[cnt - 1] > 0)
- {
- out << " in " << retryIntervals[cnt - 1] << "ms";
- }
- out << " because of exception\n" << ex;
- }
-
- if(cnt > 0)
- {
- //
- // Sleep before retrying.
- //
- IceUtil::ThreadControl::sleep(IceUtil::Time::milliSeconds(retryIntervals[cnt - 1]));
- }
+ proxyFactory->checkRetryAfterException(ex, cnt);
}
else
{
- //
- // Impossible to retry after Communicator has been destroyed.
- //
- ex.ice_throw();
+ ex.ice_throw(); // The communicator is already destroyed, so we cannot retry.
}
}
@@ -983,19 +933,6 @@ IceDelegateM::Ice::Object::ice_invoke(const string& operation,
}
void
-IceDelegateM::Ice::Object::ice_invoke_async(const AMI_Object_ice_invokePtr& cb,
- const string& operation,
- OperationMode mode,
- const vector<Byte>& inParams,
- const Context& context)
-{
- cb->__setup(__connection, __reference, operation, mode, context);
- BasicStream* __os = cb->__os();
- __os->writeBlob(inParams);
- cb->__invoke();
-}
-
-void
IceDelegateM::Ice::Object::__copyFrom(const ::IceInternal::Handle< ::IceDelegateM::Ice::Object>& from)
{
//
@@ -1120,16 +1057,6 @@ IceDelegateD::Ice::Object::ice_invoke(const string&,
}
void
-IceDelegateD::Ice::Object::ice_invoke_async(const AMI_Object_ice_invokePtr&,
- const string&,
- OperationMode,
- const vector<Byte>&,
- const Context&)
-{
- throw CollocationOptimizationException(__FILE__, __LINE__);
-}
-
-void
IceDelegateD::Ice::Object::__copyFrom(const ::IceInternal::Handle< ::IceDelegateD::Ice::Object>& from)
{
//
diff --git a/cpp/src/Ice/ProxyFactory.cpp b/cpp/src/Ice/ProxyFactory.cpp
index 96ce9c97d32..d3bc5f844c9 100644
--- a/cpp/src/Ice/ProxyFactory.cpp
+++ b/cpp/src/Ice/ProxyFactory.cpp
@@ -12,12 +12,15 @@
//
// **********************************************************************
+#include <IceUtil/Thread.h>
#include <Ice/ProxyFactory.h>
#include <Ice/Instance.h>
#include <Ice/Proxy.h>
#include <Ice/ReferenceFactory.h>
#include <Ice/BasicStream.h>
#include <Ice/Properties.h>
+#include <Ice/LoggerUtil.h>
+#include <Ice/TraceLevels.h>
using namespace std;
using namespace Ice;
@@ -86,10 +89,57 @@ IceInternal::ProxyFactory::referenceToProxy(const ReferencePtr& ref) const
}
}
-const std::vector<int>&
-IceInternal::ProxyFactory::getRetryIntervals() const
+void
+IceInternal::ProxyFactory::checkRetryAfterException(const LocalException& ex, int& cnt) const
{
- return _retryIntervals;
+ ++cnt;
+
+ TraceLevelsPtr traceLevels = _instance->traceLevels();
+ LoggerPtr logger = _instance->logger();
+
+ //
+ // Instance components may be null if the communicator has been
+ // destroyed.
+ //
+ if(traceLevels && logger)
+ {
+ if(cnt > static_cast<int>(_retryIntervals.size()))
+ {
+ if(traceLevels->retry >= 1)
+ {
+ Trace out(logger, traceLevels->retryCat);
+ out << "cannot retry operation call because retry limit has been exceeded\n" << ex;
+ }
+ ex.ice_throw();
+ }
+
+ if(traceLevels->retry >= 1)
+ {
+ Trace out(logger, traceLevels->retryCat);
+ out << "re-trying operation call";
+ if(cnt > 0 && _retryIntervals[cnt - 1] > 0)
+ {
+ out << " in " << _retryIntervals[cnt - 1] << "ms";
+ }
+ out << " because of exception\n" << ex;
+ }
+
+ if(cnt > 0)
+ {
+ //
+ // Sleep before retrying.
+ //
+ IceUtil::ThreadControl::sleep(IceUtil::Time::milliSeconds(_retryIntervals[cnt - 1]));
+ }
+ }
+ else
+ {
+ //
+ // Impossible to retry after the communicator has been
+ // destroyed.
+ //
+ ex.ice_throw();
+ }
}
IceInternal::ProxyFactory::ProxyFactory(const InstancePtr& instance) :
diff --git a/cpp/src/Ice/ProxyFactory.h b/cpp/src/Ice/ProxyFactory.h
index e148fc0e7cb..59d6dc9e45b 100644
--- a/cpp/src/Ice/ProxyFactory.h
+++ b/cpp/src/Ice/ProxyFactory.h
@@ -21,25 +21,26 @@
#include <Ice/InstanceF.h>
#include <Ice/ReferenceF.h>
#include <Ice/ProxyF.h>
+#include <Ice/Exception.h>
namespace IceInternal
{
class BasicStream;
-class ProxyFactory : public ::IceUtil::Shared
+class ProxyFactory : public IceUtil::Shared
{
public:
- ::Ice::ObjectPrx stringToProxy(const std::string&) const;
- std::string proxyToString(const ::Ice::ObjectPrx&) const;
+ Ice::ObjectPrx stringToProxy(const std::string&) const;
+ std::string proxyToString(const Ice::ObjectPrx&) const;
- ::Ice::ObjectPrx streamToProxy(BasicStream*) const;
- void proxyToStream(const ::Ice::ObjectPrx&, BasicStream*) const;
+ Ice::ObjectPrx streamToProxy(BasicStream*) const;
+ void proxyToStream(const Ice::ObjectPrx&, BasicStream*) const;
- ::Ice::ObjectPrx referenceToProxy(const ReferencePtr&) const;
+ Ice::ObjectPrx referenceToProxy(const ReferencePtr&) const;
- const ::std::vector<int>& getRetryIntervals() const;
+ void checkRetryAfterException(const Ice::LocalException&, int&) const;
private:
@@ -48,7 +49,7 @@ private:
friend class Instance;
InstancePtr _instance;
- ::std::vector<int> _retryIntervals;
+ std::vector<int> _retryIntervals;
};
}
diff --git a/cpp/src/IceUtil/OutputUtil.cpp b/cpp/src/IceUtil/OutputUtil.cpp
index d38292ffd26..00fc1897f33 100644
--- a/cpp/src/IceUtil/OutputUtil.cpp
+++ b/cpp/src/IceUtil/OutputUtil.cpp
@@ -23,6 +23,8 @@ namespace IceUtil
NextLine nl;
StartBlock sb;
EndBlock eb;
+StartPar spar;
+EndPar epar;
Separator sp;
EndElement ee;
StartEscapes startEscapes;
@@ -237,24 +239,40 @@ IceUtil::OutputBase::fill(ostream::char_type newFill)
IceUtil::Output::Output() :
OutputBase(),
_blockStart("{"),
- _blockEnd("}")
+ _blockEnd("}"),
+ _par(-1)
{
}
IceUtil::Output::Output(ostream& os) :
OutputBase(os),
_blockStart("{"),
- _blockEnd("}")
+ _blockEnd("}"),
+ _par(-1)
{
}
IceUtil::Output::Output(const char* s) :
OutputBase(s),
_blockStart("{"),
- _blockEnd("}")
+ _blockEnd("}"),
+ _par(-1)
{
}
+void
+IceUtil::Output::print(const char* s)
+{
+ if(_par >= 0)
+ {
+ if(++_par > 1) // No comma for the first parameter.
+ {
+ _out << ", ";
+ }
+ }
+ OutputBase::print(s);
+}
+
void
IceUtil::Output::setBeginBlock(const char *bb)
{
@@ -292,6 +310,20 @@ IceUtil::Output::eb()
--_pos;
}
+void
+IceUtil::Output::spar()
+{
+ _out << '(';
+ _par = 0;
+}
+
+void
+IceUtil::Output::epar()
+{
+ _par = -1;
+ _out << ')';
+}
+
Output&
IceUtil::operator<<(Output& out, ios_base& (*val)(ios_base&))
{
diff --git a/cpp/src/slice2cpp/Gen.cpp b/cpp/src/slice2cpp/Gen.cpp
index c21bdfc428e..4a841a96562 100644
--- a/cpp/src/slice2cpp/Gen.cpp
+++ b/cpp/src/slice2cpp/Gen.cpp
@@ -376,7 +376,7 @@ Slice::Gen::TypesVisitor::visitExceptionStart(const ExceptionPtr& p)
}
H << nl << "virtual const ::std::string& ice_name() const;";
- C << sp << nl << "::std::string " << scoped.substr(2) << "::_name = \"" << p->scoped().substr(2) << "\";";
+ C << sp << nl << "const ::std::string " << scoped.substr(2) << "::_name = \"" << p->scoped().substr(2) << "\";";
C << sp << nl << "const ::std::string&" << nl << scoped.substr(2) << "::ice_name() const";
C << sb;
C << nl << "return " << scoped.substr(2) << "::_name;";
@@ -523,7 +523,7 @@ Slice::Gen::TypesVisitor::visitExceptionEnd(const ExceptionPtr& p)
H.dec();
H << sp << nl << "private:";
H.inc();
- H << sp << nl << "static ::std::string _name;";
+ H << sp << nl << "static const ::std::string _name;";
H << eb << ';';
}
@@ -1117,23 +1117,19 @@ Slice::Gen::ProxyVisitor::visitOperation(const OperationPtr& p)
TypePtr ret = p->returnType();
string retS = returnTypeToString(ret);
- string params = "(";
- string paramsDecl = "("; // With declarators
- string args;
-
- ContainerPtr container = p->container();
- ClassDefPtr cl = ClassDefPtr::dynamicCast(container);
- string classNameAMI = "AMI_" + fixKwd(cl->name());
- string classScope = fixKwd(cl->scope());
- string classScopedAMI = classScope + classNameAMI;
+ vector<string> params;
+ vector<string> paramsDecl;
+ vector<string> args;
- string paramsAMI = "(const " + classScopedAMI + '_' + name + "Ptr&";
- string paramsDeclAMI = "(const " + classScopedAMI + '_' + name + "Ptr& __cb"; // With declarators
- string argsAMI = "(__cb, ";
+ vector<string> paramsAMI;
+ vector<string> paramsDeclAMI;
+ vector<string> argsAMI;
ParamDeclList paramList = p->parameters();
for(ParamDeclList::const_iterator q = paramList.begin(); q != paramList.end(); ++q)
{
+ string paramName = fixKwd((*q)->name());
+
#if defined(__SUNPRO_CC) && (__SUNPRO_CC==0x550)
//
// Work around for Sun CC 5.5 bug #4853566
@@ -1151,67 +1147,37 @@ Slice::Gen::ProxyVisitor::visitOperation(const OperationPtr& p)
string typeString = (*q)->isOutParam() ? outputTypeToString((*q)->type()) : inputTypeToString((*q)->type());
#endif
- string paramName = fixKwd((*q)->name());
-
- if(q != paramList.begin())
- {
- params += ", ";
- paramsDecl += ", ";
- args += ", ";
- }
- params += typeString;
- paramsDecl += typeString;
- paramsDecl += ' ';
- paramsDecl += paramName;
- args += paramName;
+ params.push_back(typeString);
+ paramsDecl.push_back(typeString + ' ' + paramName);
+ args.push_back(paramName);
if(!(*q)->isOutParam())
{
- paramsAMI += ", ";
- paramsAMI += typeString;
- paramsDeclAMI += ", ";
- paramsDeclAMI += typeString;
- paramsDeclAMI += ' ';
- paramsDeclAMI += paramName;
- argsAMI += paramName;
- argsAMI += ", ";
+ string inputTypeString = inputTypeToString((*q)->type());
+
+ paramsAMI.push_back(inputTypeString);
+ paramsDeclAMI.push_back(inputTypeString + ' ' + paramName);
+ argsAMI.push_back(paramName);
}
}
string thisPointer = fixKwd(scope.substr(0, scope.size() - 2)) + "*";
H << sp;
+ H << nl << retS << ' ' << name << spar << params << epar << ';';
+ H << nl << retS << ' ' << name << spar << params << "const ::Ice::Context&" << epar << ';';
- H << nl << retS << ' ' << name << params << ");";
-
- H << nl << retS << ' ' << name << params;
- if(!paramList.empty())
- {
- H << ", ";
- }
- H << "const ::Ice::Context&);";
-
- C << sp << nl << retS << nl << "IceProxy" << scoped << paramsDecl << ")";
+ C << sp << nl << retS << nl << "IceProxy" << scoped << spar << paramsDecl << epar;
C << sb;
C << nl;
if(ret)
{
C << "return ";
}
- C << name << '(' << args;
- if(!paramList.empty())
- {
- C << ", ";
- }
- C << "__defaultContext());";
+ C << name << spar << args << "__defaultContext()" << epar << ';';
C << eb;
- C << sp << nl << retS << nl << "IceProxy" << scoped << paramsDecl;
- if(!paramList.empty())
- {
- C << ", ";
- }
- C << "const ::Ice::Context& __ctx)";
+ C << sp << nl << retS << nl << "IceProxy" << scoped << spar << paramsDecl << "const ::Ice::Context& __ctx" << epar;
C << sb;
C << nl << "int __cnt = 0;";
C << nl << "while(true)";
@@ -1230,12 +1196,7 @@ Slice::Gen::ProxyVisitor::visitOperation(const OperationPtr& p)
{
C << "return ";
}
- C << "__del->" << name << '(' << args;
- if(!args.empty())
- {
- C << ", ";
- }
- C << "__ctx);";
+ C << "__del->" << name << spar << args << "__ctx" << epar << ';';
if(!ret)
{
C << nl << "return;";
@@ -1259,35 +1220,33 @@ Slice::Gen::ProxyVisitor::visitOperation(const OperationPtr& p)
C << eb;
C << eb;
+ ContainerPtr container = p->container();
+ ClassDefPtr cl = ClassDefPtr::dynamicCast(container);
if(cl->hasMetaData("ami") || p->hasMetaData("ami"))
{
- H << nl << "void " << name << "_async" << paramsAMI << ");";
+ string classNameAMI = "AMI_" + fixKwd(cl->name());
+ string classScope = fixKwd(cl->scope());
+ string classScopedAMI = classScope + classNameAMI;
- H << nl << "void " << name << "_async" << paramsAMI << ", const ::Ice::Context&);";
+ H << nl << "void " << name << "_async" << spar << ("const" + classScopedAMI + '_' + name + "Ptr&")
+ << paramsAMI << epar << ';';
+ H << nl << "void " << name << "_async" << spar << ("const" + classScopedAMI + '_' + name + "Ptr&")
+ << paramsAMI << "const ::Ice::Context&" << epar << ';';
- C << sp << nl << "void" << nl << "IceProxy" << scoped << "_async" << paramsDeclAMI << ")";
+ C << sp << nl << "void" << nl << "IceProxy" << scoped << "_async" << spar
+ << ("const " + classScopedAMI + '_' + name + "Ptr& __cb") << paramsDeclAMI << epar;
C << sb;
- C << nl;
- C << name << "_async" << argsAMI << "__defaultContext());";
+ C << nl << name << "_async" << spar << "__cb" << argsAMI << "__defaultContext()" << epar << ';';
C << eb;
- C << sp << nl << "void" << nl << "IceProxy" << scoped << "_async" << paramsDeclAMI
- << ", const ::Ice::Context& __ctx)";
- C << sb;
- C << nl << "try";
+ C << sp << nl << "void" << nl << "IceProxy" << scoped << "_async" << spar
+ << ("const " + classScopedAMI + '_' + name + "Ptr& __cb") << paramsDeclAMI << "const ::Ice::Context& __ctx"
+ << epar;
C << sb;
// Async requests may only be sent twoway.
C << nl << "__checkTwowayOnly(\"" << p->name() << "\");";
- C << nl << "::IceInternal::Handle< ::IceDelegate::Ice::Object> __delBase = __getDelegate();";
- C << nl << "::IceDelegate" << thisPointer << " __del = dynamic_cast< ::IceDelegate"
- << thisPointer << ">(__delBase.get());";
- C << nl;
- C << "__del->" << name << "_async" << argsAMI << "__ctx);";
- C << eb;
- C << nl << "catch(const ::Ice::LocalException& __ex)";
- C << sb;
- C << nl << "__cb->__finished(__ex);";
- C << eb;
+ C << nl << "__cb->__setup(__reference());";
+ C << nl << "__cb->__invoke" << spar << argsAMI << "__ctx" << epar << ';';
C << eb;
}
}
@@ -1389,15 +1348,7 @@ Slice::Gen::DelegateVisitor::visitOperation(const OperationPtr& p)
TypePtr ret = p->returnType();
string retS = returnTypeToString(ret);
- string params = "(";
-
- ContainerPtr container = p->container();
- ClassDefPtr cl = ClassDefPtr::dynamicCast(container);
- string classNameAMI = "AMI_" + fixKwd(cl->name());
- string classScope = fixKwd(cl->scope());
- string classScopedAMI = classScope + classNameAMI;
-
- string paramsAMI = "(const " + classScopedAMI + '_' + name + "Ptr&, ";
+ vector<string> params;
ParamDeclList paramList = p->parameters();
for(ParamDeclList::const_iterator q = paramList.begin(); q != paramList.end(); ++q)
@@ -1418,27 +1369,13 @@ Slice::Gen::DelegateVisitor::visitOperation(const OperationPtr& p)
#else
string typeString = (*q)->isOutParam() ? outputTypeToString((*q)->type()) : inputTypeToString((*q)->type());
#endif
- params += typeString;
- params += ", ";
- if(!(*q)->isOutParam())
- {
- paramsAMI += typeString;
- paramsAMI += ", ";
- }
+ params.push_back(typeString);
}
- params += "const ::Ice::Context&)";
- paramsAMI += "const ::Ice::Context&)";
-
- H << sp;
-
- H << nl << "virtual " << retS << ' ' << name << params << " = 0;";
+ params.push_back("const ::Ice::Context&");
- if(cl->hasMetaData("ami") || p->hasMetaData("ami"))
- {
- H << nl << "virtual void " << name << "_async" << paramsAMI << " = 0;";
- }
+ H << sp << nl << "virtual " << retS << ' ' << name << spar << params << epar << " = 0;";
}
Slice::Gen::DelegateMVisitor::DelegateMVisitor(Output& h, Output& c, const string& dllExport) :
@@ -1541,17 +1478,8 @@ Slice::Gen::DelegateMVisitor::visitOperation(const OperationPtr& p)
TypePtr ret = p->returnType();
string retS = returnTypeToString(ret);
- string params = "(";
- string paramsDecl = "("; // With declarators
-
- ContainerPtr container = p->container();
- ClassDefPtr cl = ClassDefPtr::dynamicCast(container);
- string classNameAMI = "AMI_" + fixKwd(cl->name());
- string classScope = fixKwd(cl->scope());
- string classScopedAMI = classScope + classNameAMI;
-
- string paramsAMI = "(const " + classScopedAMI + '_' + name + "Ptr&, ";
- string paramsDeclAMI = "(const " + classScopedAMI + '_' + name + "Ptr& __cb, "; // With declarators
+ vector<string> params;
+ vector<string> paramsDecl;
TypeStringList inParams;
TypeStringList outParams;
@@ -1573,42 +1501,20 @@ Slice::Gen::DelegateMVisitor::visitOperation(const OperationPtr& p)
typeString = inputTypeToString(type);
}
- params += typeString;
- params += ", ";
- paramsDecl += typeString;
- paramsDecl += ' ';
- paramsDecl += paramName;
- paramsDecl += ", ";
-
- if(!isOutParam)
- {
- paramsAMI += typeString;
- paramsAMI += ", ";
- paramsDeclAMI += typeString;
- paramsDeclAMI += ' ';
- paramsDeclAMI += paramName;
- paramsDeclAMI += ", ";
- }
+ params.push_back(typeString);
+ paramsDecl.push_back(typeString + ' ' + paramName);
}
- params += "const ::Ice::Context&)";
- paramsDecl += "const ::Ice::Context& __context)";
-
- paramsAMI += "const ::Ice::Context&)";
- paramsDeclAMI += "const ::Ice::Context& __context)";
-
- ExceptionList throws = p->throws();
+ params.push_back("const ::Ice::Context&");
+ paramsDecl.push_back("const ::Ice::Context& __context");
- H << sp << nl << "virtual " << retS << ' ' << name << params << ';';
- C << sp << nl << retS << nl << "IceDelegateM" << scoped << paramsDecl;
+ H << sp << nl << "virtual " << retS << ' ' << name << spar << params << epar << ';';
+ C << sp << nl << retS << nl << "IceDelegateM" << scoped << spar << paramsDecl << epar;
C << sb;
C << nl << "static const ::std::string __operation(\"" << p->name() << "\");";
C << nl << "::IceInternal::Outgoing __out(__connection.get(), __reference.get(), __operation, "
<< "static_cast< ::Ice::OperationMode>(" << p->mode() << "), __context);";
- if(ret || !outParams.empty() || !throws.empty())
- {
- C << nl << "::IceInternal::BasicStream* __is = __out.is();";
- }
+ C << nl << "::IceInternal::BasicStream* __is = __out.is();";
if(!inParams.empty())
{
C << nl << "::IceInternal::BasicStream* __os = __out.os();";
@@ -1620,14 +1526,7 @@ Slice::Gen::DelegateMVisitor::visitOperation(const OperationPtr& p)
}
C << nl << "if(!__out.invoke())";
C << sb;
- if(!throws.empty())
- {
- C << nl << "__is->throwException();";
- }
- else
- {
- C << nl << "throw ::Ice::UnknownUserException(__FILE__, __LINE__);";
- }
+ C << nl << "__is->throwException();";
C << eb;
writeAllocateCode(C, TypeStringList(), ret);
if(!outParams.empty() || ret)
@@ -1650,27 +1549,6 @@ Slice::Gen::DelegateMVisitor::visitOperation(const OperationPtr& p)
C << nl << "return __ret;";
}
C << eb;
-
- if(cl->hasMetaData("ami") || p->hasMetaData("ami"))
- {
- H << nl << "virtual void " << name << "_async" << paramsAMI << ';';
- C << sp << nl << "void" << nl << "IceDelegateM" << scoped << "_async" << paramsDeclAMI;
- C << sb;
- C << nl << "static const ::std::string __operation(\"" << p->name() << "\");";
- C << nl << "__cb->__setup(__connection, __reference, __operation, "
- << "static_cast< ::Ice::OperationMode>(" << p->mode() << "), __context);";
- if(!inParams.empty())
- {
- C << nl << "::IceInternal::BasicStream* __os = __cb->__os();";
- }
- writeMarshalCode(C, inParams, 0);
- if(p->sendsClasses())
- {
- C << nl << "__os->writePendingObjects();";
- }
- C << nl << "__cb->__invoke();";
- C << eb;
- }
}
Slice::Gen::DelegateDVisitor::DelegateDVisitor(Output& h, Output& c, const string& dllExport) :
@@ -1773,21 +1651,15 @@ Slice::Gen::DelegateDVisitor::visitOperation(const OperationPtr& p)
TypePtr ret = p->returnType();
string retS = returnTypeToString(ret);
- string params = "(";
- string paramsDecl = "("; // With declarators
- string args = "(";
-
- ContainerPtr container = p->container();
- ClassDefPtr cl = ClassDefPtr::dynamicCast(container);
- string classNameAMI = "AMI_" + fixKwd(cl->name());
- string classScope = fixKwd(cl->scope());
- string classScopedAMI = classScope + classNameAMI;
-
- string paramsAMI = "(const " + classScopedAMI + '_' + name + "Ptr&, ";
+ vector<string> params;
+ vector<string> paramsDecl;
+ vector<string> args;
ParamDeclList paramList = p->parameters();
for(ParamDeclList::const_iterator q = paramList.begin(); q != paramList.end(); ++q)
{
+ string paramName = fixKwd((*q)->name());
+
#if defined(__SUNPRO_CC) && (__SUNPRO_CC==0x550)
//
// Work around for Sun CC 5.5 bug #4853566
@@ -1804,46 +1676,34 @@ Slice::Gen::DelegateDVisitor::visitOperation(const OperationPtr& p)
#else
string typeString = (*q)->isOutParam() ? outputTypeToString((*q)->type()) : inputTypeToString((*q)->type());
#endif
- string paramName = fixKwd((*q)->name());
-
- params += typeString;
- params += ", ";
- paramsDecl += typeString;
- paramsDecl += ' ';
- paramsDecl += paramName;
- paramsDecl += ", ";
- args += paramName;
- args += ", ";
- if(!(*q)->isOutParam())
- {
- paramsAMI += typeString;
- paramsAMI += ", ";
- }
+ params.push_back(typeString);
+ paramsDecl.push_back(typeString + ' ' + paramName);
+ args.push_back(paramName);
}
-
- params += "const ::Ice::Context&)";
- paramsDecl += "const ::Ice::Context& __context)";
- args += "__current)";
- paramsAMI += "const ::Ice::Context&)";
-
+ params.push_back("const ::Ice::Context&");
+ paramsDecl.push_back("const ::Ice::Context& __context");
+ args.push_back("__current");
+
+ ContainerPtr container = p->container();
+ ClassDefPtr cl = ClassDefPtr::dynamicCast(container);
string thisPointer = fixKwd(cl->scoped()) + "*";
H << sp;
- H << nl << "virtual " << retS << ' ' << name << params << ';';
+ H << nl << "virtual " << retS << ' ' << name << spar << params << epar << ';';
bool amd = !cl->isLocal() && (cl->hasMetaData("amd") || p->hasMetaData("amd"));
if(amd)
{
- C << sp << nl << retS << nl << "IceDelegateD" << scoped << params;
+ C << sp << nl << retS << nl << "IceDelegateD" << scoped << spar << params << epar;
C << sb;
C << nl << "throw ::Ice::CollocationOptimizationException(__FILE__, __LINE__);";
C << eb;
}
else
{
- C << sp << nl << retS << nl << "IceDelegateD" << scoped << paramsDecl;
+ C << sp << nl << retS << nl << "IceDelegateD" << scoped << spar << paramsDecl << epar;
C << sb;
C << nl << "::Ice::Current __current;";
C << nl << "__initCurrent(__current, \"" << p->name()
@@ -1867,7 +1727,7 @@ Slice::Gen::DelegateDVisitor::visitOperation(const OperationPtr& p)
{
C << "return ";
}
- C << "__servant->" << name << args << ';';
+ C << "__servant->" << name << spar << args << epar << ';';
if(!ret)
{
C << nl << "return;";
@@ -1880,15 +1740,6 @@ Slice::Gen::DelegateDVisitor::visitOperation(const OperationPtr& p)
C << eb;
C << eb;
}
-
- if(cl->hasMetaData("ami") || p->hasMetaData("ami"))
- {
- H << nl << "virtual void " << name << "_async" << paramsAMI << ';';
- C << sp << nl << "void" << nl << "IceDelegateD" << scoped << "_async" << paramsAMI;
- C << sb;
- C << nl << "throw ::Ice::CollocationOptimizationException(__FILE__, __LINE__);";
- C << eb;
- }
}
Slice::Gen::ObjectDeclVisitor::ObjectDeclVisitor(Output& h, Output& c, const string& dllExport) :
@@ -2398,7 +2249,7 @@ Slice::Gen::ObjectVisitor::visitOperation(const OperationPtr& p)
string retS = returnTypeToString(ret);
string params = "(";
- string paramsDecl = "("; // With declarators
+ string paramsDecl = "(";
string args = "(";
ContainerPtr container = p->container();
@@ -2408,7 +2259,7 @@ Slice::Gen::ObjectVisitor::visitOperation(const OperationPtr& p)
string classScopedAMD = classScope + classNameAMD;
string paramsAMD = "(const " + classScopedAMD + '_' + name + "Ptr&, ";
- string paramsDeclAMD = "(const " + classScopedAMD + '_' + name + "Ptr& __cb, "; // With declarators
+ string paramsDeclAMD = "(const " + classScopedAMD + '_' + name + "Ptr& __cb, ";
string argsAMD = "(__cb, ";
TypeStringList inParams;
@@ -3491,53 +3342,55 @@ Slice::Gen::AsyncVisitor::visitOperation(const OperationPtr& p)
string classScopedAMI = classScope + classNameAMI;
string classScopedAMD = classScope + classNameAMD;
- string params;
- string paramsDecl; // With declarators
- string args;
-
- ExceptionList throws = p->throws();
- throws.sort();
- throws.unique();
+ vector<string> params;
+ vector<string> paramsDecl;
+ vector<string> args;
+ vector<string> paramsInvoke;
+ vector<string> paramsDeclInvoke;
+ vector<string> argsInvoke;
+
TypePtr ret = p->returnType();
string retS = inputTypeToString(ret);
if(ret)
{
- params += retS;
- paramsDecl += retS;
- paramsDecl += ' ';
- paramsDecl += "__ret";
- args += "__ret";
+ params.push_back(retS);
+ paramsDecl.push_back(retS + " __ret");
+ args.push_back("__ret");
}
+ TypeStringList inParams;
TypeStringList outParams;
ParamDeclList paramList = p->parameters();
for(ParamDeclList::const_iterator q = paramList.begin(); q != paramList.end(); ++q)
{
+ string paramName = fixKwd((*q)->name());
+ TypePtr type = (*q)->type();
+ string typeString = inputTypeToString(type);
+
if((*q)->isOutParam())
{
- string paramName = fixKwd((*q)->name());
- TypePtr type = (*q)->type();
- string typeString = inputTypeToString(type);
-
- if(ret || !outParams.empty())
- {
- params += ", ";
- paramsDecl += ", ";
- args += ", ";
- }
-
- params += typeString;
- paramsDecl += typeString;
- paramsDecl += ' ';
- paramsDecl += paramName;
- args += paramName;
-
+ params.push_back(typeString);
+ paramsDecl.push_back(typeString + ' ' + paramName);
+ args.push_back(paramName);
+
outParams.push_back(make_pair(type, paramName));
}
+ else
+ {
+ paramsInvoke.push_back(typeString);
+ paramsDeclInvoke.push_back(typeString + ' ' + paramName);
+ argsInvoke.push_back(paramName);
+
+ inParams.push_back(make_pair(type, paramName));
+ }
}
+ paramsInvoke.push_back("const ::Ice::Context&");
+ paramsDeclInvoke.push_back("const ::Ice::Context& __ctx");
+ argsInvoke.push_back("__ctx");
+
if(cl->hasMetaData("ami") || p->hasMetaData("ami"))
{
H << sp << nl << "class " << _dllExport << classNameAMI << '_' << name
@@ -3547,9 +3400,11 @@ Slice::Gen::AsyncVisitor::visitOperation(const OperationPtr& p)
H << nl << "public:";
H.inc();
H << sp;
- H << nl << "virtual void ice_response(" << params << ") = 0;";
+ H << nl << "virtual void ice_response" << spar << params << epar << " = 0;";
H << nl << "virtual void ice_exception(const ::Ice::Exception&) = 0;";
H << sp;
+ H << nl << "void __invoke" << spar << paramsInvoke << epar << ';';
+ H << sp;
H.dec();
H << nl << "private:";
H.inc();
@@ -3559,25 +3414,37 @@ Slice::Gen::AsyncVisitor::visitOperation(const OperationPtr& p)
H << sp << nl << "typedef ::IceUtil::Handle< " << classScopedAMI << '_' << name << "> "
<< classNameAMI << '_' << name << "Ptr;";
- C << sp << nl << "void" << nl << classScopedAMI.substr(2) << '_' << name << "::__response(bool __ok)";
+ C << sp << nl << "void" << nl << classScopedAMI.substr(2) << '_' << name << "::__invoke" << spar
+ << paramsDeclInvoke << epar;
C << sb;
- writeAllocateCode(C, outParams, ret);
C << nl << "try";
C << sb;
- if(ret || !outParams.empty() || !throws.empty())
+ C << nl << "static const ::std::string __operation(\"" << p->name() << "\");";
+ C << nl << "__prepare(__operation, " << "static_cast< ::Ice::OperationMode>(" << p->mode()
+ << "), __ctx);";
+ writeMarshalCode(C, inParams, 0);
+ if(p->sendsClasses())
{
- C << nl << "::IceInternal::BasicStream* __is = this->__is();";
+ C << nl << "__os->writePendingObjects();";
}
+ C << nl << "__os->endWriteEncaps();";
+ C << eb;
+ C << nl << "catch(const ::Ice::LocalException& __ex)";
+ C << sb;
+ C << nl << "__finished(__ex);";
+ C << nl << "return;";
+ C << eb;
+ C << nl << "__send();";
+ C << eb;
+
+ C << sp << nl << "void" << nl << classScopedAMI.substr(2) << '_' << name << "::__response(bool __ok)";
+ C << sb;
+ writeAllocateCode(C, outParams, ret);
+ C << nl << "try";
+ C << sb;
C << nl << "if(!__ok)";
C << sb;
- if(!throws.empty())
- {
- C << nl << "__is->throwException();";
- }
- else
- {
- C << nl << "throw ::Ice::UnknownUserException(__FILE__, __LINE__);";
- }
+ C << nl << "__is->throwException();";
C << eb;
writeUnmarshalCode(C, outParams, ret);
if(p->returnsClasses())
@@ -3587,10 +3454,10 @@ Slice::Gen::AsyncVisitor::visitOperation(const OperationPtr& p)
C << eb;
C << nl << "catch(const ::Ice::Exception& __ex)";
C << sb;
- C << nl << "ice_exception(__ex);";
+ C << nl << "__finished(__ex);";
C << nl << "return;";
C << eb;
- C << nl << "ice_response(" << args << ");";
+ C << nl << "ice_response" << spar << args << epar << ';';
C << eb;
}
@@ -3603,7 +3470,7 @@ Slice::Gen::AsyncVisitor::visitOperation(const OperationPtr& p)
H << nl << "public:";
H.inc();
H << sp;
- H << nl << "virtual void ice_response(" << params << ") = 0;";
+ H << nl << "virtual void ice_response" << spar << params << epar << " = 0;";
H << nl << "virtual void ice_exception(const ::Ice::Exception&) = 0;";
H << nl << "virtual void ice_exception(const ::std::exception&) = 0;";
H << nl << "virtual void ice_exception() = 0;";
@@ -3621,7 +3488,7 @@ Slice::Gen::AsyncImplVisitor::AsyncImplVisitor(Output& h, Output& c, const strin
bool
Slice::Gen::AsyncImplVisitor::visitUnitStart(const UnitPtr& p)
{
- if(!p->hasNonLocalClassDecls() || (/*!p->hasContentsWithMetaData("ami") &&*/ !p->hasContentsWithMetaData("amd")))
+ if(!p->hasNonLocalClassDecls() || !p->hasContentsWithMetaData("amd"))
{
return false;
}
@@ -3640,7 +3507,7 @@ Slice::Gen::AsyncImplVisitor::visitUnitEnd(const UnitPtr& p)
bool
Slice::Gen::AsyncImplVisitor::visitModuleStart(const ModulePtr& p)
{
- if(!p->hasNonLocalClassDecls() || (/*!p->hasContentsWithMetaData("ami") &&*/ !p->hasContentsWithMetaData("amd")))
+ if(!p->hasNonLocalClassDecls() || !p->hasContentsWithMetaData("amd"))
{
return false;
}
@@ -3664,22 +3531,19 @@ Slice::Gen::AsyncImplVisitor::visitOperation(const OperationPtr& p)
ContainerPtr container = p->container();
ClassDefPtr cl = ClassDefPtr::dynamicCast(container);
- if(cl->isLocal() ||
- (/*!cl->hasMetaData("ami") && !p->hasMetaData("ami") &&*/ !cl->hasMetaData("amd") && !p->hasMetaData("amd")))
+ if(cl->isLocal() || (!cl->hasMetaData("amd") && !p->hasMetaData("amd")))
{
return;
}
string name = fixKwd(p->name());
-// string classNameAMI = "AMI_" + fixKwd(cl->name());
string classNameAMD = "AMD_" + fixKwd(cl->name());
string classScope = fixKwd(cl->scope());
-// string classScopedAMI = classScope + classNameAMI;
string classScopedAMD = classScope + classNameAMD;
string params;
- string paramsDecl; // With declarators
+ string paramsDecl;
string args;
ExceptionList throws = p->throws();
@@ -3725,111 +3589,108 @@ Slice::Gen::AsyncImplVisitor::visitOperation(const OperationPtr& p)
}
}
- if(cl->hasMetaData("amd") || p->hasMetaData("amd"))
+ H << sp << nl << "class " << _dllExport << classNameAMD << '_' << name
+ << " : public " << classScopedAMD << '_' << name << ", public ::IceInternal::IncomingAsync";
+ H << sb;
+ H.dec();
+ H << nl << "public:";
+ H.inc();
+
+ H << sp;
+ H << nl << classNameAMD << '_' << name << "(::IceInternal::Incoming&);";
+
+ H << sp;
+ H << nl << "virtual void ice_response(" << params << ");";
+ H << nl << "virtual void ice_exception(const ::Ice::Exception&);";
+ H << nl << "virtual void ice_exception(const ::std::exception&);";
+ H << nl << "virtual void ice_exception();";
+ H << eb << ';';
+
+ C << sp << nl << "IceAsync" << classScopedAMD << '_' << name << "::" << classNameAMD << '_' << name
+ << "(::IceInternal::Incoming& in) :";
+ C.inc();
+ C << nl << "IncomingAsync(in)";
+ C.dec();
+ C << sb;
+ C << eb;
+
+ C << sp << nl << "void" << nl << "IceAsync" << classScopedAMD << '_' << name << "::ice_response("
+ << paramsDecl << ')';
+ C << sb;
+ C << nl << "if(!_finished)";
+ C << sb;
+ if(ret || !outParams.empty())
{
- H << sp << nl << "class " << _dllExport << classNameAMD << '_' << name
- << " : public " << classScopedAMD << '_' << name << ", public ::IceInternal::IncomingAsync";
- H << sb;
- H.dec();
- H << nl << "public:";
- H.inc();
-
- H << sp;
- H << nl << classNameAMD << '_' << name << "(::IceInternal::Incoming&);";
-
- H << sp;
- H << nl << "virtual void ice_response(" << params << ");";
- H << nl << "virtual void ice_exception(const ::Ice::Exception&);";
- H << nl << "virtual void ice_exception(const ::std::exception&);";
- H << nl << "virtual void ice_exception();";
- H << eb << ';';
-
- C << sp << nl << "IceAsync" << classScopedAMD << '_' << name << "::" << classNameAMD << '_' << name
- << "(::IceInternal::Incoming& in) :";
- C.inc();
- C << nl << "IncomingAsync(in)";
- C.dec();
- C << sb;
- C << eb;
-
- C << sp << nl << "void" << nl << "IceAsync" << classScopedAMD << '_' << name << "::ice_response("
- << paramsDecl << ')';
- C << sb;
- C << nl << "if(!_finished)";
+ C << nl << "try";
C << sb;
- if(ret || !outParams.empty())
+ C << nl << "::IceInternal::BasicStream* __os = this->__os();";
+ writeMarshalCode(C, outParams, ret);
+ if(p->returnsClasses())
{
- C << nl << "try";
- C << sb;
- C << nl << "::IceInternal::BasicStream* __os = this->__os();";
- writeMarshalCode(C, outParams, ret);
- if(p->returnsClasses())
- {
- C << nl << "__os->writePendingObjects();";
- }
- C << eb;
- C << nl << "catch(const ::Ice::Exception& __ex)";
- C << sb;
- C << nl << "__exception(__ex);";
- C << nl << "return;";
- C << eb;
+ C << nl << "__os->writePendingObjects();";
}
- C << nl << "__response(true);";
C << eb;
- C << eb;
-
- C << sp << nl << "void" << nl << "IceAsync" << classScopedAMD << '_' << name
- << "::ice_exception(const ::Ice::Exception& ex)";
+ C << nl << "catch(const ::Ice::Exception& __ex)";
C << sb;
- C << nl << "if(!_finished)";
+ C << nl << "__exception(__ex);";
+ C << nl << "return;";
+ C << eb;
+ }
+ C << nl << "__response(true);";
+ C << eb;
+ C << eb;
+
+ C << sp << nl << "void" << nl << "IceAsync" << classScopedAMD << '_' << name
+ << "::ice_exception(const ::Ice::Exception& ex)";
+ C << sb;
+ C << nl << "if(!_finished)";
+ C << sb;
+ if(throws.empty())
+ {
+ C << nl << "__exception(ex);";
+ }
+ else
+ {
+ C << nl << "try";
C << sb;
- if(throws.empty())
- {
- C << nl << "__exception(ex);";
- }
- else
+ C << nl << "ex.ice_throw();";
+ C << eb;
+ ExceptionList::const_iterator r;
+ for(r = throws.begin(); r != throws.end(); ++r)
{
- C << nl << "try";
+ C << nl << "catch(const " << fixKwd((*r)->scoped()) << "& __ex)";
C << sb;
- C << nl << "ex.ice_throw();";
- C << eb;
- ExceptionList::const_iterator r;
- for(r = throws.begin(); r != throws.end(); ++r)
+ C << nl << "__os()->write(__ex);";
+ if((*r)->usesClasses())
{
- C << nl << "catch(const " << fixKwd((*r)->scoped()) << "& __ex)";
- C << sb;
- C << nl << "__os()->write(__ex);";
- if((*r)->usesClasses())
- {
- C << nl << "__os()->writePendingObjects();";
- }
- C << nl << "__response(false);";
- C << eb;
+ C << nl << "__os()->writePendingObjects();";
}
- C << nl << "catch(const ::Ice::Exception& __ex)";
- C << sb;
- C << nl << "__exception(__ex);";
+ C << nl << "__response(false);";
C << eb;
}
- C << eb;
- C << eb;
-
- C << sp << nl << "void" << nl << "IceAsync" << classScopedAMD << '_' << name
- << "::ice_exception(const ::std::exception& ex)";
- C << sb;
- C << nl << "if(!_finished)";
- C << sb;
- C << nl << "__exception(ex);";
- C << eb;
- C << eb;
-
- C << sp << nl << "void" << nl << "IceAsync" << classScopedAMD << '_' << name
- << "::ice_exception()";
- C << sb;
- C << nl << "if(!_finished)";
+ C << nl << "catch(const ::Ice::Exception& __ex)";
C << sb;
- C << nl << "__exception();";
- C << eb;
+ C << nl << "__exception(__ex);";
C << eb;
}
+ C << eb;
+ C << eb;
+
+ C << sp << nl << "void" << nl << "IceAsync" << classScopedAMD << '_' << name
+ << "::ice_exception(const ::std::exception& ex)";
+ C << sb;
+ C << nl << "if(!_finished)";
+ C << sb;
+ C << nl << "__exception(ex);";
+ C << eb;
+ C << eb;
+
+ C << sp << nl << "void" << nl << "IceAsync" << classScopedAMD << '_' << name
+ << "::ice_exception()";
+ C << sb;
+ C << nl << "if(!_finished)";
+ C << sb;
+ C << nl << "__exception();";
+ C << eb;
+ C << eb;
}