diff options
author | Michi Henning <michi@zeroc.com> | 2003-08-27 05:05:57 +0000 |
---|---|---|
committer | Michi Henning <michi@zeroc.com> | 2003-08-27 05:05:57 +0000 |
commit | 1000e26d3c7578d04b95ad8a42b61d009bb001cb (patch) | |
tree | 064f0d690eaff464b220625b373cba6af4213396 /cpp | |
parent | file XMLParser.h was initially added on branch binary_freeze. (diff) | |
download | ice-1000e26d3c7578d04b95ad8a42b61d009bb001cb.tar.bz2 ice-1000e26d3c7578d04b95ad8a42b61d009bb001cb.tar.xz ice-1000e26d3c7578d04b95ad8a42b61d009bb001cb.zip |
Added per-proxy contexts.
Diffstat (limited to 'cpp')
-rw-r--r-- | cpp/CHANGES | 25 | ||||
-rw-r--r-- | cpp/include/Ice/Proxy.h | 28 | ||||
-rw-r--r-- | cpp/src/Ice/ObjectAdapterI.cpp | 9 | ||||
-rw-r--r-- | cpp/src/Ice/Proxy.cpp | 75 | ||||
-rw-r--r-- | cpp/src/Ice/Reference.cpp | 41 | ||||
-rw-r--r-- | cpp/src/Ice/Reference.h | 4 | ||||
-rw-r--r-- | cpp/src/Ice/ReferenceFactory.cpp | 7 | ||||
-rw-r--r-- | cpp/src/Ice/ReferenceFactory.h | 4 | ||||
-rw-r--r-- | cpp/src/slice2cpp/Gen.cpp | 80 | ||||
-rw-r--r-- | cpp/test/Ice/operations/Test.ice | 2 | ||||
-rw-r--r-- | cpp/test/Ice/operations/TestAMD.ice | 2 | ||||
-rw-r--r-- | cpp/test/Ice/operations/TestAMDI.cpp | 7 | ||||
-rw-r--r-- | cpp/test/Ice/operations/TestAMDI.h | 2 | ||||
-rw-r--r-- | cpp/test/Ice/operations/TestI.cpp | 6 | ||||
-rw-r--r-- | cpp/test/Ice/operations/TestI.h | 2 | ||||
-rw-r--r-- | cpp/test/Ice/operations/Twoways.cpp | 22 | ||||
-rw-r--r-- | cpp/test/Ice/operations/TwowaysAMI.cpp | 83 |
17 files changed, 348 insertions, 51 deletions
diff --git a/cpp/CHANGES b/cpp/CHANGES index 599889cbb35..a4d946850e6 100644 --- a/cpp/CHANGES +++ b/cpp/CHANGES @@ -1,6 +1,31 @@ Changes since version 1.1.0 --------------------------- +- Added per-proxy contexts. The change is source-code compatible + with the previous approach, that is, it is still possible to + pass an explicit Ice::Context to an operation call as an additional, + trailing parameter. However, IceProxy::Ice::Object now contains two + new operations: + + - ice_getContext() + + This returns the context currently associated + with a particular proxy by value. (By default, + the context associated with proxies is empty.) + + - ice_newContext(const ::Ice::Context& context) + + This creates a new proxy that is associated with + the passed context. Thereafter, calls via the + new proxy always pass the context that was passed + to ice_newContext() when that proxy was created. + + The net effect of this is that it is now possible + to establish the context for a proxy once and, thereafter, + have that same context sent automatically whenever an + operation is invoked via the proxy (instead of having to + pass an explicit context parameter on every call). + - Fixed a bug in IceXML that prevented successful extraction of strings containing 8-bit characters. diff --git a/cpp/include/Ice/Proxy.h b/cpp/include/Ice/Proxy.h index 7021dd5bf13..a1eaab0706d 100644 --- a/cpp/include/Ice/Proxy.h +++ b/cpp/include/Ice/Proxy.h @@ -90,21 +90,33 @@ public: bool operator<(const Object&) const; ::Ice::Int ice_hash() const; - bool ice_isA(const ::std::string&, const ::Ice::Context& = ::Ice::Context()); - void ice_ping(const ::Ice::Context& = ::Ice::Context()); - ::std::vector< ::std::string> ice_ids(const ::Ice::Context& = ::Ice::Context()); - ::std::string ice_id(const ::Ice::Context& = ::Ice::Context()); - ::Ice::FacetPath ice_facets(const ::Ice::Context& = ::Ice::Context()); + bool ice_isA(const ::std::string&); + bool ice_isA(const ::std::string&, const ::Ice::Context&); + void ice_ping(); + void ice_ping(const ::Ice::Context&); + ::std::vector< ::std::string> ice_ids(); + ::std::vector< ::std::string> ice_ids(const ::Ice::Context&); + ::std::string ice_id(); + ::std::string ice_id(const ::Ice::Context&); + ::Ice::FacetPath ice_facets(); + ::Ice::FacetPath ice_facets(const ::Ice::Context&); + bool ice_invoke(const ::std::string&, ::Ice::OperationMode, const ::std::vector< ::Ice::Byte>&, + ::std::vector< ::Ice::Byte>&); // Returns true if ok, false if user exception. bool ice_invoke(const ::std::string&, ::Ice::OperationMode, const ::std::vector< ::Ice::Byte>&, ::std::vector< ::Ice::Byte>&, - const ::Ice::Context& = ::Ice::Context()); // Returns true if ok, false if user exception. + const ::Ice::Context&); // Returns true if ok, false if user exception. + void ice_invoke_async(const ::Ice::AMI_Object_ice_invokePtr&, + const ::std::string&, ::Ice::OperationMode, const ::std::vector< ::Ice::Byte>&); void ice_invoke_async(const ::Ice::AMI_Object_ice_invokePtr&, const ::std::string&, ::Ice::OperationMode, const ::std::vector< ::Ice::Byte>&, - const ::Ice::Context& = ::Ice::Context()); + const ::Ice::Context&); ::Ice::Identity ice_getIdentity() const; ::Ice::ObjectPrx ice_newIdentity(const ::Ice::Identity&) const; + ::Ice::Context ice_getContext() const; + ::Ice::ObjectPrx ice_newContext(const ::Ice::Context&) const; + ::Ice::FacetPath ice_getFacet() const; ::Ice::ObjectPrx ice_newFacet(const ::Ice::FacetPath&) const; ::Ice::ObjectPrx ice_appendFacet(const ::std::string&) const; @@ -142,6 +154,8 @@ protected: virtual ::IceInternal::Handle< ::IceDelegateM::Ice::Object> __createDelegateM(); virtual ::IceInternal::Handle< ::IceDelegateD::Ice::Object> __createDelegateD(); + const ::Ice::Context& __defaultContext() const; + private: void setup(const ::IceInternal::ReferencePtr&); diff --git a/cpp/src/Ice/ObjectAdapterI.cpp b/cpp/src/Ice/ObjectAdapterI.cpp index e5b3ea46093..72d58545ddf 100644 --- a/cpp/src/Ice/ObjectAdapterI.cpp +++ b/cpp/src/Ice/ObjectAdapterI.cpp @@ -345,7 +345,7 @@ Ice::ObjectAdapterI::createReverseProxy(const Identity& ident) // reference. // vector<EndpointPtr> endpoints; - ReferencePtr ref = _instance->referenceFactory()->create(ident, vector<string>(), Reference::ModeTwoway, + ReferencePtr ref = _instance->referenceFactory()->create(ident, Context(), vector<string>(), Reference::ModeTwoway, false, "", endpoints, 0, 0, this, true); return _instance->proxyFactory()->referenceToProxy(ref); } @@ -652,8 +652,9 @@ Ice::ObjectAdapterI::newProxy(const Identity& ident) const // Create a reference with the adapter id. // vector<EndpointPtr> endpoints; - ReferencePtr ref = _instance->referenceFactory()->create(ident, vector<string>(), Reference::ModeTwoway, - false, _id, endpoints, 0, _locatorInfo, 0, true); + ReferencePtr ref = _instance->referenceFactory()->create(ident, Context(), vector<string>(), + Reference::ModeTwoway, false, _id, + endpoints, 0, _locatorInfo, 0, true); // // Return a proxy for the reference. @@ -684,7 +685,7 @@ Ice::ObjectAdapterI::newDirectProxy(const Identity& ident) const // // Create a reference and return a proxy for this reference. // - ReferencePtr ref = _instance->referenceFactory()->create(ident, vector<string>(), Reference::ModeTwoway, + ReferencePtr ref = _instance->referenceFactory()->create(ident, Context(), vector<string>(), Reference::ModeTwoway, false, "", endpoints, 0, _locatorInfo, 0, true); return _instance->proxyFactory()->referenceToProxy(ref); diff --git a/cpp/src/Ice/Proxy.cpp b/cpp/src/Ice/Proxy.cpp index aadce898703..ba56ed55365 100644 --- a/cpp/src/Ice/Proxy.cpp +++ b/cpp/src/Ice/Proxy.cpp @@ -121,6 +121,12 @@ IceProxy::Ice::Object::ice_hash() const } bool +IceProxy::Ice::Object::ice_isA(const string& __id) +{ + return ice_isA(__id, _reference->context); +} + +bool IceProxy::Ice::Object::ice_isA(const string& __id, const Context& __context) { int __cnt = 0; @@ -143,6 +149,12 @@ IceProxy::Ice::Object::ice_isA(const string& __id, const Context& __context) } void +IceProxy::Ice::Object::ice_ping() +{ + return ice_ping(_reference->context); +} + +void IceProxy::Ice::Object::ice_ping(const Context& __context) { int __cnt = 0; @@ -166,6 +178,12 @@ IceProxy::Ice::Object::ice_ping(const Context& __context) } vector<string> +IceProxy::Ice::Object::ice_ids() +{ + return ice_ids(_reference->context); +} + +vector<string> IceProxy::Ice::Object::ice_ids(const Context& __context) { int __cnt = 0; @@ -188,6 +206,12 @@ IceProxy::Ice::Object::ice_ids(const Context& __context) } string +IceProxy::Ice::Object::ice_id() +{ + return ice_id(_reference->context); +} + +string IceProxy::Ice::Object::ice_id(const Context& __context) { int __cnt = 0; @@ -210,6 +234,12 @@ IceProxy::Ice::Object::ice_id(const Context& __context) } FacetPath +IceProxy::Ice::Object::ice_facets() +{ + return ice_facets(_reference->context); +} + +FacetPath IceProxy::Ice::Object::ice_facets(const Context& __context) { int __cnt = 0; @@ -235,6 +265,15 @@ bool IceProxy::Ice::Object::ice_invoke(const string& operation, OperationMode mode, const vector<Byte>& inParams, + vector<Byte>& outParams) +{ + return ice_invoke(operation, mode, inParams, outParams, _reference->context); +} + +bool +IceProxy::Ice::Object::ice_invoke(const string& operation, + OperationMode mode, + const vector<Byte>& inParams, vector<Byte>& outParams, const Context& context) { @@ -269,6 +308,15 @@ void IceProxy::Ice::Object::ice_invoke_async(const AMI_Object_ice_invokePtr& cb, const string& operation, OperationMode mode, + const vector<Byte>& inParams) +{ + return ice_invoke_async(cb, operation, mode, inParams, _reference->context); +} + +void +IceProxy::Ice::Object::ice_invoke_async(const AMI_Object_ice_invokePtr& cb, + const string& operation, + OperationMode mode, const vector<Byte>& inParams, const Context& context) { @@ -288,6 +336,27 @@ IceProxy::Ice::Object::ice_invoke_async(const AMI_Object_ice_invokePtr& cb, } } +Context +IceProxy::Ice::Object::ice_getContext() const +{ + return _reference->context; +} + +ObjectPrx +IceProxy::Ice::Object::ice_newContext(const Context& newContext) const +{ + if(newContext == _reference->context) + { + return ObjectPrx(const_cast< ::IceProxy::Ice::Object*>(this)); + } + else + { + ObjectPrx proxy(new ::IceProxy::Ice::Object()); + proxy->setup(_reference->changeContext(newContext)); + return proxy; + } +} + Identity IceProxy::Ice::Object::ice_getIdentity() const { @@ -767,6 +836,12 @@ IceProxy::Ice::Object::__createDelegateD() return Handle< ::IceDelegateD::Ice::Object>(new ::IceDelegateD::Ice::Object); } +const Context& +IceProxy::Ice::Object::__defaultContext() const +{ + return _reference->context; +} + void IceProxy::Ice::Object::setup(const ReferencePtr& ref) { diff --git a/cpp/src/Ice/Reference.cpp b/cpp/src/Ice/Reference.cpp index bffa4b46929..0f7da04d1c0 100644 --- a/cpp/src/Ice/Reference.cpp +++ b/cpp/src/Ice/Reference.cpp @@ -366,7 +366,22 @@ IceInternal::Reference::changeIdentity(const Identity& newIdentity) const } else { - return instance->referenceFactory()->create(newIdentity, facet, mode, secure, adapterId, + return instance->referenceFactory()->create(newIdentity, context, facet, mode, secure, adapterId, + endpoints, routerInfo, locatorInfo, reverseAdapter, + collocationOptimization); + } +} + +ReferencePtr +IceInternal::Reference::changeContext(const Context& newContext) const +{ + if(newContext == context) + { + return ReferencePtr(const_cast<Reference*>(this)); + } + else + { + return instance->referenceFactory()->create(identity, newContext, facet, mode, secure, adapterId, endpoints, routerInfo, locatorInfo, reverseAdapter, collocationOptimization); } @@ -381,7 +396,7 @@ IceInternal::Reference::changeFacet(const FacetPath& newFacet) const } else { - return instance->referenceFactory()->create(identity, newFacet, mode, secure, adapterId, + return instance->referenceFactory()->create(identity, context, newFacet, mode, secure, adapterId, endpoints, routerInfo, locatorInfo, reverseAdapter, collocationOptimization); } @@ -432,7 +447,7 @@ IceInternal::Reference::changeTimeout(int newTimeout) const newLocatorInfo = instance->locatorManager()->get(newLocator); } - return instance->referenceFactory()->create(identity, facet, mode, secure, adapterId, + return instance->referenceFactory()->create(identity, context, facet, mode, secure, adapterId, newEndpoints, newRouterInfo, newLocatorInfo, reverseAdapter, collocationOptimization); } @@ -446,7 +461,7 @@ IceInternal::Reference::changeMode(Mode newMode) const } else { - return instance->referenceFactory()->create(identity, facet, newMode, secure, adapterId, + return instance->referenceFactory()->create(identity, context, facet, newMode, secure, adapterId, endpoints, routerInfo, locatorInfo, reverseAdapter, collocationOptimization); } @@ -461,7 +476,7 @@ IceInternal::Reference::changeSecure(bool newSecure) const } else { - return instance->referenceFactory()->create(identity, facet, mode, newSecure, adapterId, + return instance->referenceFactory()->create(identity, context, facet, mode, newSecure, adapterId, endpoints, routerInfo, locatorInfo, reverseAdapter, collocationOptimization); } @@ -512,7 +527,7 @@ IceInternal::Reference::changeCompress(bool newCompress) const newLocatorInfo = instance->locatorManager()->get(newLocator); } - return instance->referenceFactory()->create(identity, facet, mode, secure, adapterId, + return instance->referenceFactory()->create(identity, context, facet, mode, secure, adapterId, newEndpoints, newRouterInfo, newLocatorInfo, reverseAdapter, collocationOptimization); } @@ -526,7 +541,7 @@ IceInternal::Reference::changeAdapterId(const string& newAdapterId) const } else { - return instance->referenceFactory()->create(identity, facet, mode, secure, newAdapterId, + return instance->referenceFactory()->create(identity, context, facet, mode, secure, newAdapterId, endpoints, routerInfo, locatorInfo, reverseAdapter, collocationOptimization); } @@ -541,7 +556,7 @@ IceInternal::Reference::changeEndpoints(const vector<EndpointPtr>& newEndpoints) } else { - return instance->referenceFactory()->create(identity, facet, mode, secure, adapterId, + return instance->referenceFactory()->create(identity, context, facet, mode, secure, adapterId, newEndpoints, routerInfo, locatorInfo, reverseAdapter, collocationOptimization); } @@ -558,7 +573,7 @@ IceInternal::Reference::changeRouter(const RouterPrx& newRouter) const } else { - return instance->referenceFactory()->create(identity, facet, mode, secure, adapterId, + return instance->referenceFactory()->create(identity, context, facet, mode, secure, adapterId, endpoints, newRouterInfo, locatorInfo, reverseAdapter, collocationOptimization); } @@ -575,7 +590,7 @@ IceInternal::Reference::changeLocator(const LocatorPrx& newLocator) const } else { - return instance->referenceFactory()->create(identity, facet, mode, secure, adapterId, + return instance->referenceFactory()->create(identity, context, facet, mode, secure, adapterId, endpoints, routerInfo, newLocatorInfo, reverseAdapter, collocationOptimization); } @@ -590,7 +605,7 @@ IceInternal::Reference::changeCollocationOptimization(bool newCollocationOptimiz } else { - return instance->referenceFactory()->create(identity, facet, mode, secure, adapterId, + return instance->referenceFactory()->create(identity, context, facet, mode, secure, adapterId, endpoints, routerInfo, locatorInfo, reverseAdapter, newCollocationOptimization); } @@ -602,12 +617,13 @@ IceInternal::Reference::changeDefault() const RouterInfoPtr defaultRouterInfo = instance->routerManager()->get(instance->referenceFactory()->getDefaultRouter()); LocatorInfoPtr defaultLocatorInfo = instance->locatorManager()->get(instance->referenceFactory()->getDefaultLocator()); - return instance->referenceFactory()->create(identity, FacetPath(), ModeTwoway, false, adapterId, + return instance->referenceFactory()->create(identity, context, FacetPath(), ModeTwoway, false, adapterId, endpoints, defaultRouterInfo, defaultLocatorInfo, 0, true); } IceInternal::Reference::Reference(const InstancePtr& inst, const Identity& ident, + const Context& ctx, const FacetPath& facPath, Mode md, bool sec, @@ -619,6 +635,7 @@ IceInternal::Reference::Reference(const InstancePtr& inst, bool collocationOptimization) : instance(inst), identity(ident), + context(ctx), facet(facPath), mode(md), secure(sec), diff --git a/cpp/src/Ice/Reference.h b/cpp/src/Ice/Reference.h index da7b83c6818..7f42a8e596d 100644 --- a/cpp/src/Ice/Reference.h +++ b/cpp/src/Ice/Reference.h @@ -65,6 +65,7 @@ public: // const InstancePtr instance; const Ice::Identity identity; + const Ice::Context context; const Ice::FacetPath facet; const Mode mode; const bool secure; @@ -81,6 +82,7 @@ public: // certain values. // ReferencePtr changeIdentity(const Ice::Identity&) const; + ReferencePtr changeContext(const Ice::Context&) const; ReferencePtr changeFacet(const Ice::FacetPath&) const; ReferencePtr changeTimeout(int) const; ReferencePtr changeMode(Mode) const; @@ -95,7 +97,7 @@ public: private: - Reference(const InstancePtr&, const Ice::Identity&, const Ice::FacetPath&, Mode, bool, + Reference(const InstancePtr&, const Ice::Identity&, const Ice::Context&, const Ice::FacetPath&, Mode, bool, const std::string&, const std::vector<EndpointPtr>&, const RouterInfoPtr&, const LocatorInfoPtr&, const Ice::ObjectAdapterPtr&, bool); friend class ReferenceFactory; diff --git a/cpp/src/Ice/ReferenceFactory.cpp b/cpp/src/Ice/ReferenceFactory.cpp index fb3264f98e8..b3782c18f4c 100644 --- a/cpp/src/Ice/ReferenceFactory.cpp +++ b/cpp/src/Ice/ReferenceFactory.cpp @@ -32,6 +32,7 @@ void IceInternal::decRef(::IceInternal::ReferenceFactory* p) { p->__decRef(); } ReferencePtr IceInternal::ReferenceFactory::create(const Identity& ident, + const Context& context, const vector<string>& facet, Reference::Mode mode, bool secure, @@ -57,7 +58,7 @@ IceInternal::ReferenceFactory::create(const Identity& ident, // // Create new reference // - ReferencePtr ref = new Reference(_instance, ident, facet, mode, secure, adapterId, + ReferencePtr ref = new Reference(_instance, ident, context, facet, mode, secure, adapterId, endpoints, routerInfo, locatorInfo, reverseAdapter, collocationOptimization); @@ -500,7 +501,7 @@ IceInternal::ReferenceFactory::create(const string& str) RouterInfoPtr routerInfo = _instance->routerManager()->get(getDefaultRouter()); LocatorInfoPtr locatorInfo = _instance->locatorManager()->get(getDefaultLocator()); - return create(ident, facet, mode, secure, adapter, endpoints, routerInfo, locatorInfo, 0, true); + return create(ident, Context(), facet, mode, secure, adapter, endpoints, routerInfo, locatorInfo, 0, true); } ReferencePtr @@ -552,7 +553,7 @@ IceInternal::ReferenceFactory::create(const Identity& ident, BasicStream* s) RouterInfoPtr routerInfo = _instance->routerManager()->get(getDefaultRouter()); LocatorInfoPtr locatorInfo = _instance->locatorManager()->get(getDefaultLocator()); - return create(ident, facet, mode, secure, adapterId, endpoints, routerInfo, locatorInfo, 0, true); + return create(ident, Context(), facet, mode, secure, adapterId, endpoints, routerInfo, locatorInfo, 0, true); } void diff --git a/cpp/src/Ice/ReferenceFactory.h b/cpp/src/Ice/ReferenceFactory.h index beedb4fa65f..c51b1f3c1d3 100644 --- a/cpp/src/Ice/ReferenceFactory.h +++ b/cpp/src/Ice/ReferenceFactory.h @@ -28,8 +28,8 @@ class ReferenceFactory : public ::IceUtil::Shared, public ::IceUtil::Mutex { public: - ReferencePtr create(const Ice::Identity&, const std::vector<std::string>&, Reference::Mode, bool, - const std::string&, const std::vector<EndpointPtr>&, + ReferencePtr create(const Ice::Identity&, const Ice::Context&, const std::vector<std::string>&, + Reference::Mode, bool, const std::string&, const std::vector<EndpointPtr>&, const RouterInfoPtr&, const LocatorInfoPtr&, const Ice::ObjectAdapterPtr&, bool); ReferencePtr create(const std::string&); ReferencePtr create(const Ice::Identity&, BasicStream*); diff --git a/cpp/src/slice2cpp/Gen.cpp b/cpp/src/slice2cpp/Gen.cpp index d7bf4a8adba..5fd71262f4e 100644 --- a/cpp/src/slice2cpp/Gen.cpp +++ b/cpp/src/slice2cpp/Gen.cpp @@ -1296,7 +1296,7 @@ Slice::Gen::ProxyVisitor::visitOperation(const OperationPtr& p) string params = "("; string paramsDecl = "("; // With declarators - string args = "("; + string args; ContainerPtr container = p->container(); ClassDefPtr cl = ClassDefPtr::dynamicCast(container); @@ -1304,8 +1304,8 @@ Slice::Gen::ProxyVisitor::visitOperation(const OperationPtr& p) string classScope = fixKwd(cl->scope()); string classScopedAMI = classScope + classNameAMI; - string paramsAMI = "(const " + classScopedAMI + '_' + name + "Ptr&, "; - string paramsDeclAMI = "(const " + classScopedAMI + '_' + name + "Ptr& __cb, "; // With declarators + string paramsAMI = "(const " + classScopedAMI + '_' + name + "Ptr&"; + string paramsDeclAMI = "(const " + classScopedAMI + '_' + name + "Ptr& __cb"; // With declarators string argsAMI = "(__cb, "; ParamDeclList paramList = p->parameters(); @@ -1330,42 +1330,65 @@ Slice::Gen::ProxyVisitor::visitOperation(const OperationPtr& p) string paramName = fixKwd((*q)->name()); + if(q != paramList.begin()) + { + params += ", "; + paramsDecl += ", "; + args += ", "; + } params += typeString; - params += ", "; paramsDecl += typeString; paramsDecl += ' '; paramsDecl += paramName; - paramsDecl += ", "; args += paramName; - args += ", "; if(!(*q)->isOutParam()) { - paramsAMI += typeString; paramsAMI += ", "; + paramsAMI += typeString; + paramsDeclAMI += ", "; paramsDeclAMI += typeString; paramsDeclAMI += ' '; paramsDeclAMI += paramName; - paramsDeclAMI += ", "; argsAMI += paramName; argsAMI += ", "; } } - params += "const ::Ice::Context& = ::Ice::Context())"; - paramsDecl += "const ::Ice::Context& __context)"; - args += "__context)"; - - paramsAMI += "const ::Ice::Context& = ::Ice::Context())"; - paramsDeclAMI += "const ::Ice::Context& __context)"; - argsAMI += "__context)"; - string thisPointer = fixKwd(scope.substr(0, scope.size() - 2)) + "*"; H << sp; - H << nl << retS << ' ' << name << params << ';'; + 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 << sb; + C << nl; + if(ret) + { + C << "return "; + } + C << name << '(' << args; + if(!paramList.empty()) + { + C << ", "; + } + C << "__defaultContext());"; + C << eb; + C << sp << nl << retS << nl << "IceProxy" << scoped << paramsDecl; + if(!paramList.empty()) + { + C << ", "; + } + C << "const ::Ice::Context& __ctx)"; C << sb; C << nl << "int __cnt = 0;"; C << nl << "while(true)"; @@ -1380,7 +1403,12 @@ Slice::Gen::ProxyVisitor::visitOperation(const OperationPtr& p) { C << "return "; } - C << "__del->" << name << args << ";"; + C << "__del->" << name << '(' << args; + if(!args.empty()) + { + C << ", "; + } + C << "__ctx);"; if(!ret) { C << nl << "return;"; @@ -1406,8 +1434,18 @@ Slice::Gen::ProxyVisitor::visitOperation(const OperationPtr& p) if(cl->hasMetaData("ami") || p->hasMetaData("ami")) { - H << nl << "void " << name << "_async" << paramsAMI << ';'; - C << sp << nl << "void" << nl << "IceProxy" << scoped << "_async" << paramsDeclAMI; + H << nl << "void " << name << "_async" << paramsAMI << ");"; + + H << nl << "void " << name << "_async" << paramsAMI << ", const ::Ice::Context&);"; + + C << sp << nl << "void" << nl << "IceProxy" << scoped << "_async" << paramsDeclAMI << ")"; + C << sb; + C << nl; + C << name << "_async" << argsAMI << "__defaultContext());"; + C << eb; + + C << sp << nl << "void" << nl << "IceProxy" << scoped << "_async" << paramsDeclAMI + << ", const ::Ice::Context& __ctx)"; C << sb; C << nl << "int __cnt = 0;"; C << nl << "while(true)"; @@ -1418,7 +1456,7 @@ Slice::Gen::ProxyVisitor::visitOperation(const OperationPtr& p) C << nl << "::IceDelegate" << thisPointer << " __del = dynamic_cast< ::IceDelegate" << thisPointer << ">(__delBase.get());"; C << nl; - C << "__del->" << name << "_async" << argsAMI << ";"; + C << "__del->" << name << "_async" << argsAMI << "__ctx);"; C << nl << "return;"; C << eb; C << nl << "catch(const ::Ice::LocalException& __ex)"; diff --git a/cpp/test/Ice/operations/Test.ice b/cpp/test/Ice/operations/Test.ice index 201f10fc8c5..3efa1db86e9 100644 --- a/cpp/test/Ice/operations/Test.ice +++ b/cpp/test/Ice/operations/Test.ice @@ -143,6 +143,8 @@ dictionary<string, MyEnum> StringMyEnumD; IntS opIntS(IntS s); + StringStringD opContext(); + }; ["ami"] class MyDerivedClass extends MyClass diff --git a/cpp/test/Ice/operations/TestAMD.ice b/cpp/test/Ice/operations/TestAMD.ice index b69fd08f7c1..349880ab7e9 100644 --- a/cpp/test/Ice/operations/TestAMD.ice +++ b/cpp/test/Ice/operations/TestAMD.ice @@ -143,6 +143,8 @@ dictionary<string, MyEnum> StringMyEnumD; IntS opIntS(IntS s); + StringStringD opContext(); + }; ["ami", "amd"] class MyDerivedClass extends MyClass diff --git a/cpp/test/Ice/operations/TestAMDI.cpp b/cpp/test/Ice/operations/TestAMDI.cpp index 20fd976b205..cc526f023b4 100644 --- a/cpp/test/Ice/operations/TestAMDI.cpp +++ b/cpp/test/Ice/operations/TestAMDI.cpp @@ -358,6 +358,13 @@ MyDerivedClassI::opIntS_async(const ::Test::AMD_MyClass_opIntSPtr& cb, const Tes } void +MyDerivedClassI::opContext_async(const ::Test::AMD_MyClass_opContextPtr& cb, const Ice::Current& c) +{ + Test::StringStringD r = c.ctx; + cb->ice_response(r); +} + +void MyDerivedClassI::opDerived_async(const Test::AMD_MyDerivedClass_opDerivedPtr& cb, const Ice::Current&) { diff --git a/cpp/test/Ice/operations/TestAMDI.h b/cpp/test/Ice/operations/TestAMDI.h index fe82a7007ca..404f96feb7a 100644 --- a/cpp/test/Ice/operations/TestAMDI.h +++ b/cpp/test/Ice/operations/TestAMDI.h @@ -124,6 +124,8 @@ public: virtual void opIntS_async(const ::Test::AMD_MyClass_opIntSPtr&, const Test::IntS&, const Ice::Current&); + virtual void opContext_async(const ::Test::AMD_MyClass_opContextPtr&, const Ice::Current&); + virtual void opDerived_async(const Test::AMD_MyDerivedClass_opDerivedPtr&, const Ice::Current&); diff --git a/cpp/test/Ice/operations/TestI.cpp b/cpp/test/Ice/operations/TestI.cpp index cdb67074963..a2e278052bf 100644 --- a/cpp/test/Ice/operations/TestI.cpp +++ b/cpp/test/Ice/operations/TestI.cpp @@ -335,6 +335,12 @@ MyDerivedClassI::opIntS(const Test::IntS& s, const Ice::Current&) return r; } +Test::StringStringD +MyDerivedClassI::opContext(const Ice::Current& c) +{ + return c.ctx; +} + void MyDerivedClassI::opDerived(const Ice::Current&) { diff --git a/cpp/test/Ice/operations/TestI.h b/cpp/test/Ice/operations/TestI.h index fe9f1c7aba3..9dfeaf18f0f 100644 --- a/cpp/test/Ice/operations/TestI.h +++ b/cpp/test/Ice/operations/TestI.h @@ -148,6 +148,8 @@ public: virtual Test::IntS opIntS(const Test::IntS&, const Ice::Current&); + virtual Test::StringStringD opContext(const Ice::Current&); + virtual void opDerived(const Ice::Current&); private: diff --git a/cpp/test/Ice/operations/Twoways.cpp b/cpp/test/Ice/operations/Twoways.cpp index 3fc8b6cc167..950bb3da412 100644 --- a/cpp/test/Ice/operations/Twoways.cpp +++ b/cpp/test/Ice/operations/Twoways.cpp @@ -591,4 +591,26 @@ twoways(const Test::MyClassPrx& p) } } } + + { + Ice::Context ctx; + ctx["one"] = "ONE"; + ctx["two"] = "TWO"; + ctx["three"] = "THREE"; + { + Test::StringStringD r = p->opContext(); + test(r != ctx); + } + { + Test::StringStringD r = p->opContext(ctx); + test(r == ctx); + } + { + Test::MyClassPrx p2 = Test::MyClassPrx::checkedCast(p->ice_newContext(ctx)); + Test::StringStringD r = p2->opContext(); + test(r == ctx); + r = p2->opContext(ctx); + test(r == ctx); + } + } } diff --git a/cpp/test/Ice/operations/TwowaysAMI.cpp b/cpp/test/Ice/operations/TwowaysAMI.cpp index cd3af19f958..deb351d5d6e 100644 --- a/cpp/test/Ice/operations/TwowaysAMI.cpp +++ b/cpp/test/Ice/operations/TwowaysAMI.cpp @@ -696,6 +696,8 @@ public: } }; +typedef IceUtil::Handle<AMI_MyClass_opStringMyEnumDI> AMI_MyClass_opStringMyEnumDIPtr; + class AMI_MyClass_opIntSI : public Test::AMI_MyClass_opIntS, public CallbackBase { public: @@ -724,7 +726,57 @@ private: typedef IceUtil::Handle<AMI_MyClass_opIntSI> AMI_MyClass_opIntSIPtr; -typedef IceUtil::Handle<AMI_MyClass_opStringMyEnumDI> AMI_MyClass_opStringMyEnumDIPtr; +class AMI_MyClass_opContextEqualI : public Test::AMI_MyClass_opContext, public CallbackBase +{ +public: + + AMI_MyClass_opContextEqualI(const Test::StringStringD &d) : _d(d) + { + } + + virtual void ice_response(const Test::StringStringD& r) + { + test(r == _d); + called(); + } + + virtual void ice_exception(const ::Ice::Exception&) + { + test(false); + } + +private: + + Test::StringStringD _d; +}; + +typedef IceUtil::Handle<AMI_MyClass_opContextEqualI> AMI_MyClass_opContextEqualIPtr; + +class AMI_MyClass_opContextNotEqualI : public Test::AMI_MyClass_opContext, public CallbackBase +{ +public: + + AMI_MyClass_opContextNotEqualI(const Test::StringStringD &d) : _d(d) + { + } + + virtual void ice_response(const Test::StringStringD& r) + { + test(r != _d); + called(); + } + + virtual void ice_exception(const ::Ice::Exception&) + { + test(false); + } + +private: + + Test::StringStringD _d; +}; + +typedef IceUtil::Handle<AMI_MyClass_opContextNotEqualI> AMI_MyClass_opContextNotEqualIPtr; class AMI_MyDerivedClass_opDerivedI : public Test::AMI_MyDerivedClass_opDerived, public CallbackBase { @@ -1039,6 +1091,35 @@ twowaysAMI(const Test::MyClassPrx& p) } { + Test::StringStringD ctx; + ctx["one"] = "ONE"; + ctx["two"] = "TWO"; + ctx["three"] = "THREE"; + { + AMI_MyClass_opContextNotEqualIPtr cb = new AMI_MyClass_opContextNotEqualI(ctx); + p->opContext_async(cb); + test(cb->check()); + } + { + AMI_MyClass_opContextEqualIPtr cb = new AMI_MyClass_opContextEqualI(ctx); + p->opContext_async(cb, ctx); + test(cb->check()); + } + Test::MyClassPrx p2 = Test::MyClassPrx::checkedCast(p->ice_newContext(ctx)); + { + AMI_MyClass_opContextEqualIPtr cb = new AMI_MyClass_opContextEqualI(ctx); + p2->opContext_async(cb); + test(cb->check()); + } + { + Test::MyClassPrx p2 = Test::MyClassPrx::checkedCast(p->ice_newContext(ctx)); + AMI_MyClass_opContextEqualIPtr cb = new AMI_MyClass_opContextEqualI(ctx); + p2->opContext_async(cb, ctx); + test(cb->check()); + } + } + + { Test::MyDerivedClassPrx derived = Test::MyDerivedClassPrx::checkedCast(p); test(derived); AMI_MyDerivedClass_opDerivedIPtr cb = new AMI_MyDerivedClass_opDerivedI; |