summaryrefslogtreecommitdiff
path: root/cpp/src/Ice/Object.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'cpp/src/Ice/Object.cpp')
-rw-r--r--cpp/src/Ice/Object.cpp234
1 files changed, 164 insertions, 70 deletions
diff --git a/cpp/src/Ice/Object.cpp b/cpp/src/Ice/Object.cpp
index fa39befdd9d..4df368298e6 100644
--- a/cpp/src/Ice/Object.cpp
+++ b/cpp/src/Ice/Object.cpp
@@ -12,20 +12,26 @@
#include <Ice/IncomingAsync.h>
#include <Ice/IncomingRequest.h>
#include <Ice/LocalException.h>
-#include <Ice/Stream.h>
#include <Ice/SlicedData.h>
using namespace std;
using namespace Ice;
using namespace IceInternal;
+namespace Ice
+{
+const Current noExplicitCurrent = Current();
+}
+
+#ifndef ICE_CPP11_MAPPING
Object* Ice::upCast(Object* p) { return p; }
-void
+void
Ice::__patch(ObjectPtr& obj, const ObjectPtr& v)
{
obj = v;
}
+#endif
bool
Ice::Object::operator==(const Object& r) const
@@ -51,7 +57,11 @@ const string __Ice__Object_ids[] =
}
bool
+#ifdef ICE_CPP11_MAPPING
+Ice::Object::ice_isA(string s, const Current&) const
+#else
Ice::Object::ice_isA(const string& s, const Current&) const
+#endif
{
return s == __Ice__Object_ids[0];
}
@@ -80,32 +90,28 @@ Ice::Object::ice_staticId()
return __Ice__Object_ids[0];
}
+#ifndef ICE_CPP11_MAPPING
Ice::ObjectPtr
Ice::Object::ice_clone() const
{
throw CloneNotImplementedException(__FILE__, __LINE__);
return 0; // avoid warning with some compilers
}
-
-void
-Ice::Object::ice_preMarshal()
-{
-}
-
-void
-Ice::Object::ice_postUnmarshal()
-{
-}
+#endif
DispatchStatus
Ice::Object::___ice_isA(Incoming& __inS, const Current& __current)
{
- BasicStream* __is = __inS.startReadParams();
+ InputStream* __is = __inS.startReadParams();
string __id;
__is->read(__id, false);
__inS.endReadParams();
+#ifdef ICE_CPP11_MAPPING
+ bool __ret = ice_isA(move(__id), __current);
+#else
bool __ret = ice_isA(__id, __current);
- BasicStream* __os = __inS.__startWriteParams(DefaultFormat);
+#endif
+ OutputStream* __os = __inS.__startWriteParams(DefaultFormat);
__os->write(__ret);
__inS.__endWriteParams(true);
return DispatchOK;
@@ -125,7 +131,7 @@ Ice::Object::___ice_ids(Incoming& __inS, const Current& __current)
{
__inS.readEmptyParams();
vector<string> __ret = ice_ids(__current);
- BasicStream* __os = __inS.__startWriteParams(DefaultFormat);
+ OutputStream* __os = __inS.__startWriteParams(DefaultFormat);
__os->write(&__ret[0], &__ret[0] + __ret.size(), false);
__inS.__endWriteParams(true);
return DispatchOK;
@@ -136,18 +142,12 @@ Ice::Object::___ice_id(Incoming& __inS, const Current& __current)
{
__inS.readEmptyParams();
string __ret = ice_id(__current);
- BasicStream* __os = __inS.__startWriteParams(DefaultFormat);
+ OutputStream* __os = __inS.__startWriteParams(DefaultFormat);
__os->write(__ret, false);
__inS.__endWriteParams(true);
return DispatchOK;
}
-Ice::Int
-Ice::Object::ice_operationAttributes(const string&) const
-{
- return 0;
-}
-
string Ice::Object::__all[] =
{
@@ -188,7 +188,6 @@ Ice::Object::ice_dispatch(Request& request, const DispatchInterceptorAsyncCallba
IceInternal::Incoming& in = dynamic_cast<IceInternal::IncomingRequest&>(request)._in;
-
PushCb pusbCb(in, cb);
in.startOver(); // may raise ResponseSentException
return __dispatch(in, in.getCurrent());
@@ -203,7 +202,7 @@ Ice::Object::__dispatch(Incoming& in, const Current& current)
if(r.first == r.second)
{
throw OperationNotExistException(__FILE__, __LINE__, current.id, current.facet, current.operation);
- }
+ }
switch(r.first - __all)
{
@@ -229,49 +228,39 @@ Ice::Object::__dispatch(Incoming& in, const Current& current)
throw OperationNotExistException(__FILE__, __LINE__, current.id, current.facet, current.operation);
}
+#ifndef ICE_CPP11_MAPPING
void
-Ice::Object::__write(IceInternal::BasicStream* os) const
+Ice::Object::ice_preMarshal()
{
- os->startWriteObject(0);
- __writeImpl(os);
- os->endWriteObject();
}
-
-void
-Ice::Object::__read(IceInternal::BasicStream* is)
+
+void
+Ice::Object::ice_postUnmarshal()
{
- is->startReadObject();
- __readImpl(is);
- is->endReadObject(false);
}
-
-void
-Ice::Object::__write(const OutputStreamPtr& os) const
+
+void
+Ice::Object::__write(Ice::OutputStream* os) const
{
os->startObject(0);
__writeImpl(os);
os->endObject();
}
-
-void
-Ice::Object::__read(const InputStreamPtr& is)
+
+void
+Ice::Object::__read(Ice::InputStream* is)
{
- is->startObject();
+ is->startObject();
__readImpl(is);
is->endObject(false);
}
-
-void
-Ice::Object::__writeImpl(const OutputStreamPtr&) const
-{
- throw MarshalException(__FILE__, __LINE__, "class was not generated with stream support");
-}
-
-void
-Ice::Object::__readImpl(const InputStreamPtr&)
+
+Ice::Int
+Ice::Object::ice_operationAttributes(const string&) const
{
- throw MarshalException(__FILE__, __LINE__, "class was not generated with stream support");
+ return 0;
}
+#endif
namespace
{
@@ -281,19 +270,26 @@ operationModeToString(OperationMode mode)
{
switch(mode)
{
- case Normal:
+ case ICE_ENUM(OperationMode, Normal):
return "::Ice::Normal";
- case Nonmutating:
+ case ICE_ENUM(OperationMode, Nonmutating):
return "::Ice::Nonmutating";
- case Idempotent:
+ case ICE_ENUM(OperationMode, Idempotent):
return "::Ice::Idempotent";
}
-
+ //
+ // This could not happen with C++11 strong type enums
+ //
+#ifdef ICE_CPP11_MAPPING
+ assert(false);
+ return "";
+#else
ostringstream os;
os << "unknown value (" << mode << ")";
return os.str();
+#endif
}
}
@@ -303,12 +299,12 @@ Ice::Object::__checkMode(OperationMode expected, OperationMode received)
{
if(expected != received)
{
- if(expected == Idempotent && received == Nonmutating)
+ if(expected == ICE_ENUM(OperationMode, Idempotent) && received == ICE_ENUM(OperationMode, Nonmutating))
{
- //
+ //
// Fine: typically an old client still using the deprecated nonmutating keyword
//
-
+
//
// Note that expected == Nonmutating and received == Idempotent is not ok:
// the server may still use the deprecated nonmutating keyword to detect updates
@@ -388,6 +384,64 @@ Ice::BlobjectAsync::__dispatch(Incoming& in, const Current& current)
const Byte* inEncaps;
Int sz;
in.readParamEncaps(inEncaps, sz);
+#ifdef ICE_CPP11_MAPPING
+ auto async = IncomingAsync::create(in);
+ try
+ {
+ ice_invoke_async(vector<Byte>(inEncaps, inEncaps + sz),
+ [async](bool ok, const vector<Byte>& outEncaps)
+ {
+ if(async->__validateResponse(ok))
+ {
+ try
+ {
+ if(outEncaps.empty())
+ {
+ async->__writeParamEncaps(0, 0, ok);
+ }
+ else
+ {
+ async->__writeParamEncaps(&outEncaps[0], static_cast< ::Ice::Int>(outEncaps.size()), ok);
+ }
+ }
+ catch(const LocalException& ex)
+ {
+ async->__exception(ex);
+ return;
+ }
+ async->__response();
+ }
+ },
+ [async](exception_ptr e)
+ {
+ if(e)
+ {
+ try
+ {
+ rethrow_exception(e);
+ }
+ catch(const exception& ex)
+ {
+ async->ice_exception(ex);
+ }
+ }
+ else
+ {
+ async->ice_exception();
+ }
+ },
+ current);
+ }
+ catch(const ::std::exception& ex)
+ {
+ async->ice_exception(ex);
+ }
+ catch(...)
+ {
+ async->ice_exception();
+ }
+#else
+
AMD_Object_ice_invokePtr cb = new ::IceAsync::Ice::AMD_Object_ice_invoke(in);
try
{
@@ -401,6 +455,7 @@ Ice::BlobjectAsync::__dispatch(Incoming& in, const Current& current)
{
cb->ice_exception();
}
+#endif
return DispatchAsync;
}
@@ -411,6 +466,56 @@ Ice::BlobjectArrayAsync::__dispatch(Incoming& in, const Current& current)
Int sz;
in.readParamEncaps(inEncaps.first, sz);
inEncaps.second = inEncaps.first + sz;
+#ifdef ICE_CPP11_MAPPING
+ auto async = IncomingAsync::create(in);
+ try
+ {
+ ice_invoke_async(inEncaps,
+ [async](bool ok, const pair<const Byte*, const Byte*>& outEncaps)
+ {
+ if(async->__validateResponse(ok))
+ {
+ try
+ {
+ async->__writeParamEncaps(outEncaps.first, static_cast<Int>(outEncaps.second - outEncaps.first), ok);
+ }
+ catch(const LocalException& ex)
+ {
+ async->__exception(ex);
+ return;
+ }
+ async->__response();
+ }
+ },
+ [async](exception_ptr e)
+ {
+ if(e)
+ {
+ try
+ {
+ rethrow_exception(e);
+ }
+ catch(const exception& ex)
+ {
+ async->ice_exception(ex);
+ }
+ }
+ else
+ {
+ async->ice_exception();
+ }
+ },
+ current);
+ }
+ catch(const ::std::exception& ex)
+ {
+ async->ice_exception(ex);
+ }
+ catch(...)
+ {
+ async->ice_exception();
+ }
+#else
AMD_Object_ice_invokePtr cb = new ::IceAsync::Ice::AMD_Object_ice_invoke(in);
try
{
@@ -424,17 +529,6 @@ Ice::BlobjectArrayAsync::__dispatch(Incoming& in, const Current& current)
{
cb->ice_exception();
}
+#endif
return DispatchAsync;
}
-
-void
-Ice::ice_writeObject(const OutputStreamPtr& out, const ObjectPtr& p)
-{
- out->write(p);
-}
-
-void
-Ice::ice_readObject(const InputStreamPtr& in, ObjectPtr& p)
-{
- in->read(p);
-}