summaryrefslogtreecommitdiff
path: root/cpp
diff options
context:
space:
mode:
authorBernard Normier <bernard@zeroc.com>2007-10-02 11:48:54 -0400
committerBernard Normier <bernard@zeroc.com>2007-10-02 11:48:54 -0400
commit2cb718a85b417fb6a58be04fe1f102f733b8d39c (patch)
tree26549f37c7307037f0bf8bf0d42b6c1da7eaeb4b /cpp
parentFixed bug 2503 (diff)
downloadice-2cb718a85b417fb6a58be04fe1f102f733b8d39c.tar.bz2
ice-2cb718a85b417fb6a58be04fe1f102f733b8d39c.tar.xz
ice-2cb718a85b417fb6a58be04fe1f102f733b8d39c.zip
Squashed commit of the following:
commit 0ba15449d9dd44933d82cb643efded9dee12c5af Author: Bernard Normier <bernard@zeroc.com> Date: Tue Oct 2 11:48:07 2007 -0400 Documented updates commit cf49ee5a73bc62d1b6814dec5d9f288f0f45901d Author: Bernard Normier <bernard@zeroc.com> Date: Tue Oct 2 11:38:25 2007 -0400 Optimized implementation of various Prx ice_xxx functions/methods commit 706209d6d1a4e894fecf19dd1c0c3b6f12ef5842 Author: Bernard Normier <bernard@zeroc.com> Date: Fri Sep 28 14:34:02 2007 -0400 Updated code-generation to "overwrite" various Ice::ObjectPrx ice_ operations.
Diffstat (limited to 'cpp')
-rw-r--r--cpp/CHANGES8
-rw-r--r--cpp/demo/Ice/hello/Client.cpp24
-rw-r--r--cpp/include/Ice/Proxy.h2
-rw-r--r--cpp/src/Ice/Proxy.cpp52
-rw-r--r--cpp/src/IceGrid/Client.cpp8
-rw-r--r--cpp/src/slice2cpp/Gen.cpp120
6 files changed, 177 insertions, 37 deletions
diff --git a/cpp/CHANGES b/cpp/CHANGES
index c4496d8bdd2..fae73343ef3 100644
--- a/cpp/CHANGES
+++ b/cpp/CHANGES
@@ -1,6 +1,14 @@
Changes since version 3.2.X (binary incompatible)
-------------------------------------------------
+- A number of proxy functions (ice_timeout(), ice_oneway() etc.) now
+ return a proxy of the same type as the target. This way, you don't
+ need to uncheckedCast the returned proxy. For example, you can now
+ write:
+ hello = hello.ice_oneway();
+ instead of:
+ hello = HelloPrx::uncheckedCast(hello->ice_oneway());
+
- Added a fix to prevent the IceGrid node from printing an annoying
thread pool size warning on startup.
diff --git a/cpp/demo/Ice/hello/Client.cpp b/cpp/demo/Ice/hello/Client.cpp
index 1620c93f7c0..d45ff0ca8d6 100644
--- a/cpp/demo/Ice/hello/Client.cpp
+++ b/cpp/demo/Ice/hello/Client.cpp
@@ -54,10 +54,10 @@ HelloClient::run(int argc, char* argv[])
cerr << argv[0] << ": invalid proxy" << endl;
return EXIT_FAILURE;
}
- HelloPrx oneway = HelloPrx::uncheckedCast(twoway->ice_oneway());
- HelloPrx batchOneway = HelloPrx::uncheckedCast(twoway->ice_batchOneway());
- HelloPrx datagram = HelloPrx::uncheckedCast(twoway->ice_datagram());
- HelloPrx batchDatagram = HelloPrx::uncheckedCast(twoway->ice_batchDatagram());
+ HelloPrx oneway = twoway->ice_oneway();
+ HelloPrx batchOneway = twoway->ice_batchOneway();
+ HelloPrx datagram = twoway->ice_datagram();
+ HelloPrx batchDatagram = twoway->ice_batchDatagram();
bool secure = false;
int timeout = -1;
@@ -121,9 +121,9 @@ HelloClient::run(int argc, char* argv[])
timeout = -1;
}
- twoway = HelloPrx::uncheckedCast(twoway->ice_timeout(timeout));
- oneway = HelloPrx::uncheckedCast(oneway->ice_timeout(timeout));
- batchOneway = HelloPrx::uncheckedCast(batchOneway->ice_timeout(timeout));
+ twoway = twoway->ice_timeout(timeout);
+ oneway = oneway->ice_timeout(timeout);
+ batchOneway = batchOneway->ice_timeout(timeout);
if(timeout == -1)
{
@@ -158,11 +158,11 @@ HelloClient::run(int argc, char* argv[])
{
secure = !secure;
- twoway = HelloPrx::uncheckedCast(twoway->ice_secure(secure));
- oneway = HelloPrx::uncheckedCast(oneway->ice_secure(secure));
- batchOneway = HelloPrx::uncheckedCast(batchOneway->ice_secure(secure));
- datagram = HelloPrx::uncheckedCast(datagram->ice_secure(secure));
- batchDatagram = HelloPrx::uncheckedCast(batchDatagram->ice_secure(secure));
+ twoway = twoway->ice_secure(secure);
+ oneway = oneway->ice_secure(secure);
+ batchOneway = batchOneway->ice_secure(secure);
+ datagram = datagram->ice_secure(secure);
+ batchDatagram = batchDatagram->ice_secure(secure);
if(secure)
{
diff --git a/cpp/include/Ice/Proxy.h b/cpp/include/Ice/Proxy.h
index 35d5b904f0b..2e2696b0c86 100644
--- a/cpp/include/Ice/Proxy.h
+++ b/cpp/include/Ice/Proxy.h
@@ -253,6 +253,8 @@ protected:
virtual ::IceInternal::Handle< ::IceDelegateM::Ice::Object> __createDelegateM();
virtual ::IceInternal::Handle< ::IceDelegateD::Ice::Object> __createDelegateD();
+ virtual Object* __newInstance() const;
+
private:
bool ice_isA(const ::std::string&, const ::Ice::Context*);
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);
}