diff options
Diffstat (limited to 'cpp/src')
-rw-r--r-- | cpp/src/Ice/Proxy.cpp | 52 | ||||
-rw-r--r-- | cpp/src/IceGrid/Client.cpp | 8 | ||||
-rw-r--r-- | cpp/src/slice2cpp/Gen.cpp | 120 |
3 files changed, 155 insertions, 25 deletions
diff --git a/cpp/src/Ice/Proxy.cpp b/cpp/src/Ice/Proxy.cpp index fde808f5acd..b902dedaad1 100644 --- a/cpp/src/Ice/Proxy.cpp +++ b/cpp/src/Ice/Proxy.cpp @@ -323,7 +323,7 @@ IceProxy::Ice::Object::ice_identity(const Identity& newIdentity) const } else { - ObjectPrx proxy(new ::IceProxy::Ice::Object()); + ObjectPrx proxy = new Object; proxy->setup(_reference->changeIdentity(newIdentity)); return proxy; } @@ -344,7 +344,7 @@ IceProxy::Ice::Object::ice_getContext() const ObjectPrx IceProxy::Ice::Object::ice_context(const Context& newContext) const { - ObjectPrx proxy(new ::IceProxy::Ice::Object()); + ObjectPrx proxy = __newInstance(); proxy->setup(_reference->changeContext(newContext)); return proxy; } @@ -358,7 +358,7 @@ IceProxy::Ice::Object::ice_newContext(const Context& newContext) const ObjectPrx IceProxy::Ice::Object::ice_defaultContext() const { - ObjectPrx proxy(new ::IceProxy::Ice::Object()); + ObjectPrx proxy = __newInstance(); proxy->setup(_reference->defaultContext()); return proxy; } @@ -378,7 +378,7 @@ IceProxy::Ice::Object::ice_facet(const string& newFacet) const } else { - ObjectPrx proxy(new ::IceProxy::Ice::Object()); + ObjectPrx proxy = new Object; proxy->setup(_reference->changeFacet(newFacet)); return proxy; } @@ -405,7 +405,7 @@ IceProxy::Ice::Object::ice_adapterId(const string& newAdapterId) const } else { - ObjectPrx proxy(new ::IceProxy::Ice::Object()); + ObjectPrx proxy = __newInstance(); proxy->setup(_reference->changeAdapterId(newAdapterId)); return proxy; } @@ -444,7 +444,7 @@ IceProxy::Ice::Object::ice_endpoints(const EndpointSeq& newEndpoints) const } else { - ObjectPrx proxy(new ::IceProxy::Ice::Object()); + ObjectPrx proxy = __newInstance(); proxy->setup(_reference->changeEndpoints(endpoints)); return proxy; } @@ -471,7 +471,7 @@ IceProxy::Ice::Object::ice_locatorCacheTimeout(Int newTimeout) const } else { - ObjectPrx proxy(new ::IceProxy::Ice::Object()); + ObjectPrx proxy = __newInstance(); proxy->setup(_reference->changeLocatorCacheTimeout(newTimeout)); return proxy; } @@ -492,7 +492,7 @@ IceProxy::Ice::Object::ice_connectionCached(bool newCache) const } else { - ObjectPrx proxy(new ::IceProxy::Ice::Object()); + ObjectPrx proxy = __newInstance(); proxy->setup(_reference->changeCacheConnection(newCache)); return proxy; } @@ -513,7 +513,7 @@ IceProxy::Ice::Object::ice_endpointSelection(EndpointSelectionType newType) cons } else { - ObjectPrx proxy(new ::IceProxy::Ice::Object()); + ObjectPrx proxy = __newInstance(); proxy->setup(_reference->changeEndpointSelection(newType)); return proxy; } @@ -534,7 +534,7 @@ IceProxy::Ice::Object::ice_secure(bool b) const } else { - ObjectPrx proxy(new ::IceProxy::Ice::Object()); + ObjectPrx proxy = __newInstance(); proxy->setup(_reference->changeSecure(b)); return proxy; } @@ -555,7 +555,7 @@ IceProxy::Ice::Object::ice_preferSecure(bool b) const } else { - ObjectPrx proxy(new ::IceProxy::Ice::Object()); + ObjectPrx proxy = __newInstance(); proxy->setup(_reference->changePreferSecure(b)); return proxy; } @@ -578,7 +578,7 @@ IceProxy::Ice::Object::ice_router(const RouterPrx& router) const } else { - ObjectPrx proxy(new ::IceProxy::Ice::Object()); + ObjectPrx proxy = __newInstance(); proxy->setup(ref); return proxy; } @@ -601,7 +601,7 @@ IceProxy::Ice::Object::ice_locator(const LocatorPrx& locator) const } else { - ObjectPrx proxy(new ::IceProxy::Ice::Object()); + ObjectPrx proxy = __newInstance(); proxy->setup(ref); return proxy; } @@ -628,7 +628,7 @@ IceProxy::Ice::Object::ice_collocationOptimized(bool b) const } else { - ObjectPrx proxy(new ::IceProxy::Ice::Object()); + ObjectPrx proxy = __newInstance(); proxy->setup(_reference->changeCollocationOptimization(b)); return proxy; } @@ -643,7 +643,7 @@ IceProxy::Ice::Object::ice_twoway() const } else { - ObjectPrx proxy(new ::IceProxy::Ice::Object()); + ObjectPrx proxy = __newInstance(); proxy->setup(_reference->changeMode(Reference::ModeTwoway)); return proxy; } @@ -664,7 +664,7 @@ IceProxy::Ice::Object::ice_oneway() const } else { - ObjectPrx proxy(new ::IceProxy::Ice::Object()); + ObjectPrx proxy = __newInstance(); proxy->setup(_reference->changeMode(Reference::ModeOneway)); return proxy; } @@ -685,7 +685,7 @@ IceProxy::Ice::Object::ice_batchOneway() const } else { - ObjectPrx proxy(new ::IceProxy::Ice::Object()); + ObjectPrx proxy = __newInstance(); proxy->setup(_reference->changeMode(Reference::ModeBatchOneway)); return proxy; } @@ -706,7 +706,7 @@ IceProxy::Ice::Object::ice_datagram() const } else { - ObjectPrx proxy(new ::IceProxy::Ice::Object()); + ObjectPrx proxy = __newInstance(); proxy->setup(_reference->changeMode(Reference::ModeDatagram)); return proxy; } @@ -727,7 +727,7 @@ IceProxy::Ice::Object::ice_batchDatagram() const } else { - ObjectPrx proxy(new ::IceProxy::Ice::Object()); + ObjectPrx proxy = __newInstance(); proxy->setup(_reference->changeMode(Reference::ModeBatchDatagram)); return proxy; } @@ -749,7 +749,7 @@ IceProxy::Ice::Object::ice_compress(bool b) const } else { - ObjectPrx proxy(new ::IceProxy::Ice::Object()); + ObjectPrx proxy = __newInstance(); proxy->setup(ref); return proxy; } @@ -765,7 +765,7 @@ IceProxy::Ice::Object::ice_timeout(int t) const } else { - ObjectPrx proxy(new ::IceProxy::Ice::Object()); + ObjectPrx proxy = __newInstance(); proxy->setup(ref); return proxy; } @@ -781,7 +781,7 @@ IceProxy::Ice::Object::ice_connectionId(const string& id) const } else { - ObjectPrx proxy(new ::IceProxy::Ice::Object()); + ObjectPrx proxy = __newInstance(); proxy->setup(ref); return proxy; } @@ -803,7 +803,7 @@ IceProxy::Ice::Object::ice_threadPerConnection(bool b) const } else { - ObjectPrx proxy(new ::IceProxy::Ice::Object()); + ObjectPrx proxy = __newInstance(); proxy->setup(ref); return proxy; } @@ -1088,6 +1088,12 @@ IceProxy::Ice::Object::__createDelegateD() return Handle< ::IceDelegateD::Ice::Object>(new ::IceDelegateD::Ice::Object); } +IceProxy::Ice::Object* +IceProxy::Ice::Object::__newInstance() const +{ + return new Object; +} + void IceProxy::Ice::Object::setup(const ReferencePtr& ref) { diff --git a/cpp/src/IceGrid/Client.cpp b/cpp/src/IceGrid/Client.cpp index 3e67844adc0..c814f9cb0cb 100644 --- a/cpp/src/IceGrid/Client.cpp +++ b/cpp/src/IceGrid/Client.cpp @@ -364,7 +364,9 @@ Client::run(int argc, char* argv[]) // Use SSL if available. try { - router = Glacier2::RouterPrx::checkedCast(router->ice_secure(true)); + Glacier2::RouterPrx secureRouter = router->ice_secure(true); + secureRouter->ice_ping(); + router = secureRouter; } catch(const Ice::NoEndpointException&) { @@ -484,7 +486,9 @@ Client::run(int argc, char* argv[]) // Use SSL if available. try { - registry = RegistryPrx::checkedCast(registry->ice_secure(true)); + RegistryPrx secureRegistry = registry->ice_secure(true); + secureRegistry->ice_ping(); + registry = secureRegistry; } catch(const Ice::NoEndpointException&) { diff --git a/cpp/src/slice2cpp/Gen.cpp b/cpp/src/slice2cpp/Gen.cpp index 0d70727d44f..ebafdf80e5b 100644 --- a/cpp/src/slice2cpp/Gen.cpp +++ b/cpp/src/slice2cpp/Gen.cpp @@ -1778,9 +1778,123 @@ Slice::Gen::ProxyVisitor::visitClassDefStart(const ClassDefPtr& p) void Slice::Gen::ProxyVisitor::visitClassDefEnd(const ClassDefPtr& p) { + string name = fixKwd(p->name()); string scoped = fixKwd(p->scoped()); string scope = fixKwd(p->scope()); + + // + // "Overwrite" various non-virtual functions in ::IceProxy::Ice::Object that return an ObjectPrx and + // are more usable when they return a <name>Prx + // + + // + // No identity! + // + + H << nl << nl << "::IceInternal::ProxyHandle<" << name << "> ice_context(const ::Ice::Context& __context) const"; + H << sb; + H << nl << "return dynamic_cast<" << name << "*>(::IceProxy::Ice::Object::ice_context(__context).get());"; + H << eb; + + // + // No facet! + // + + H << nl << nl << "::IceInternal::ProxyHandle<" << name << "> ice_adapterId(const std::string& __id) const"; + H << sb; + H << nl << "return dynamic_cast<" << name << "*>(::IceProxy::Ice::Object::ice_adapterId(__id).get());"; + H << eb; + + H << nl << nl << "::IceInternal::ProxyHandle<" << name << "> ice_endpoints(const ::Ice::EndpointSeq& __endpoints) const"; + H << sb; + H << nl << "return dynamic_cast<" << name << "*>(::IceProxy::Ice::Object::ice_endpoints(__endpoints).get());"; + H << eb; + + H << nl << nl << "::IceInternal::ProxyHandle<" << name << "> ice_locatorCacheTimeout(int __timeout) const"; + H << sb; + H << nl << "return dynamic_cast<" << name << "*>(::IceProxy::Ice::Object::ice_locatorCacheTimeout(__timeout).get());"; + H << eb; + + H << nl << nl << "::IceInternal::ProxyHandle<" << name << "> ice_connectionCached(bool __cached) const"; + H << sb; + H << nl << "return dynamic_cast<" << name << "*>(::IceProxy::Ice::Object::ice_connectionCached(__cached).get());"; + H << eb; + + H << nl << nl << "::IceInternal::ProxyHandle<" << name << "> ice_endpointSelection(::Ice::EndpointSelectionType __est) const"; + H << sb; + H << nl << "return dynamic_cast<" << name << "*>(::IceProxy::Ice::Object::ice_endpointSelection(__est).get());"; + H << eb; + + H << nl << nl << "::IceInternal::ProxyHandle<" << name << "> ice_secure(bool __secure) const"; + H << sb; + H << nl << "return dynamic_cast<" << name << "*>(::IceProxy::Ice::Object::ice_secure(__secure).get());"; + H << eb; + + H << nl << nl << "::IceInternal::ProxyHandle<" << name << "> ice_preferSecure(bool __preferSecure) const"; + H << sb; + H << nl << "return dynamic_cast<" << name << "*>(::IceProxy::Ice::Object::ice_preferSecure(__preferSecure).get());"; + H << eb; + + H << nl << nl << "::IceInternal::ProxyHandle<" << name << "> ice_router(const ::Ice::RouterPrx& __router) const"; + H << sb; + H << nl << "return dynamic_cast<" << name << "*>(::IceProxy::Ice::Object::ice_router(__router).get());"; + H << eb; + + H << nl << nl << "::IceInternal::ProxyHandle<" << name << "> ice_locator(const ::Ice::LocatorPrx& __locator) const"; + H << sb; + H << nl << "return dynamic_cast<" << name << "*>(::IceProxy::Ice::Object::ice_locator(__locator).get());"; + H << eb; + + H << nl << nl << "::IceInternal::ProxyHandle<" << name << "> ice_collocationOptimized(bool __co) const"; + H << sb; + H << nl << "return dynamic_cast<" << name << "*>(::IceProxy::Ice::Object::ice_collocationOptimized(__co).get());"; + H << eb; + + H << nl << nl << "::IceInternal::ProxyHandle<" << name << "> ice_twoway() const"; + H << sb; + H << nl << "return dynamic_cast<" << name << "*>(::IceProxy::Ice::Object::ice_twoway().get());"; + H << eb; + + H << nl << nl << "::IceInternal::ProxyHandle<" << name << "> ice_oneway() const"; + H << sb; + H << nl << "return dynamic_cast<" << name << "*>(::IceProxy::Ice::Object::ice_oneway().get());"; + H << eb; + + H << nl << nl << "::IceInternal::ProxyHandle<" << name << "> ice_batchOneway() const"; + H << sb; + H << nl << "return dynamic_cast<" << name << "*>(::IceProxy::Ice::Object::ice_batchOneway().get());"; + H << eb; + + H << nl << nl << "::IceInternal::ProxyHandle<" << name << "> ice_datagram() const"; + H << sb; + H << nl << "return dynamic_cast<" << name << "*>(::IceProxy::Ice::Object::ice_datagram().get());"; + H << eb; + + H << nl << nl << "::IceInternal::ProxyHandle<" << name << "> ice_batchDatagram() const"; + H << sb; + H << nl << "return dynamic_cast<" << name << "*>(::IceProxy::Ice::Object::ice_batchDatagram().get());"; + H << eb; + + H << nl << nl << "::IceInternal::ProxyHandle<" << name << "> ice_compress(bool __compress) const"; + H << sb; + H << nl << "return dynamic_cast<" << name << "*>(::IceProxy::Ice::Object::ice_compress(__compress).get());"; + H << eb; + + H << nl << nl << "::IceInternal::ProxyHandle<" << name << "> ice_timeout(int __timeout) const"; + H << sb; + H << nl << "return dynamic_cast<" << name << "*>(::IceProxy::Ice::Object::ice_timeout(__timeout).get());"; + H << eb; + + H << nl << nl << "::IceInternal::ProxyHandle<" << name << "> ice_connectionId(const std::string& __id) const"; + H << sb; + H << nl << "return dynamic_cast<" << name << "*>(::IceProxy::Ice::Object::ice_connectionId(__id).get());"; + H << eb; + H << nl << nl << "::IceInternal::ProxyHandle<" << name << "> ice_threadPerConnection(bool __tpc) const"; + H << sb; + H << nl << "return dynamic_cast<" << name << "*>(::IceProxy::Ice::Object::ice_threadPerConnection(__tpc).get());"; + H << eb; + H << nl << nl << _dllExport << "static const ::std::string& ice_staticId();"; H.dec(); @@ -1788,6 +1902,7 @@ Slice::Gen::ProxyVisitor::visitClassDefEnd(const ClassDefPtr& p) H.inc(); H << sp << nl << _dllExport << "virtual ::IceInternal::Handle< ::IceDelegateM::Ice::Object> __createDelegateM();"; H << nl << _dllExport << "virtual ::IceInternal::Handle< ::IceDelegateD::Ice::Object> __createDelegateD();"; + H << nl << _dllExport << "virtual ::IceProxy::Ice::Object* __newInstance() const;"; H << eb << ';'; C << sp; @@ -1806,6 +1921,11 @@ Slice::Gen::ProxyVisitor::visitClassDefEnd(const ClassDefPtr& p) C << sb; C << nl << "return ::IceInternal::Handle< ::IceDelegateD::Ice::Object>(new ::IceDelegateD" << scoped << ");"; C << eb; + C << sp << nl << "::IceProxy::Ice::Object*"; + C << nl << "IceProxy" << scoped << "::__newInstance() const"; + C << sb; + C << nl << "return new " << name << ";"; + C << eb; _useWstring = resetUseWstring(_useWstringHist); } |