summaryrefslogtreecommitdiff
path: root/ruby
diff options
context:
space:
mode:
authorBenoit Foucher <benoit@zeroc.com>2018-01-31 17:21:12 +0100
committerBenoit Foucher <benoit@zeroc.com>2018-01-31 17:21:12 +0100
commitc3f44e70ea6a8c9bd16281f4b7e2bcd8f7bae47f (patch)
treea02e199af243136b4dc4a83929e8c9a185c9dcd8 /ruby
parentUpdated AutoStart description (diff)
downloadice-c3f44e70ea6a8c9bd16281f4b7e2bcd8f7bae47f.tar.bz2
ice-c3f44e70ea6a8c9bd16281f4b7e2bcd8f7bae47f.tar.xz
ice-c3f44e70ea6a8c9bd16281f4b7e2bcd8f7bae47f.zip
Added support for ice_fixed, ice_getTimeout, ice_getCompress methods (ICE-7996 & ICE-7976)
Diffstat (limited to 'ruby')
-rw-r--r--ruby/src/IceRuby/Connection.cpp13
-rw-r--r--ruby/src/IceRuby/Connection.h3
-rw-r--r--ruby/src/IceRuby/Proxy.cpp69
-rw-r--r--ruby/test/Ice/proxy/AllTests.rb41
4 files changed, 123 insertions, 3 deletions
diff --git a/ruby/src/IceRuby/Connection.cpp b/ruby/src/IceRuby/Connection.cpp
index a4f0f8bcbff..b2df21c6419 100644
--- a/ruby/src/IceRuby/Connection.cpp
+++ b/ruby/src/IceRuby/Connection.cpp
@@ -512,3 +512,16 @@ IceRuby::initConnection(VALUE iceModule)
rb_define_attr(_sslConnectionInfoClass, "certs", 1, 0);
rb_define_attr(_sslConnectionInfoClass, "verified", 1, 0);
}
+
+Ice::ConnectionPtr
+IceRuby::getConnection(VALUE v)
+{
+ Ice::ConnectionPtr* p = reinterpret_cast<Ice::ConnectionPtr*>(DATA_PTR(v));
+ return *p;
+}
+
+bool
+IceRuby::checkConnection(VALUE v)
+{
+ return callRuby(rb_obj_is_kind_of, v, _connectionClass) == Qtrue;
+}
diff --git a/ruby/src/IceRuby/Connection.h b/ruby/src/IceRuby/Connection.h
index 3c7a1a31038..9debcae3d27 100644
--- a/ruby/src/IceRuby/Connection.h
+++ b/ruby/src/IceRuby/Connection.h
@@ -21,6 +21,9 @@ void initConnection(VALUE);
VALUE createConnection(const Ice::ConnectionPtr&);
VALUE createConnectionInfo(const Ice::ConnectionInfoPtr&);
+Ice::ConnectionPtr getConnection(VALUE);
+bool checkConnection(VALUE);
+
}
#endif
diff --git a/ruby/src/IceRuby/Proxy.cpp b/ruby/src/IceRuby/Proxy.cpp
index 51a02f5e108..c93f27cea36 100644
--- a/ruby/src/IceRuby/Proxy.cpp
+++ b/ruby/src/IceRuby/Proxy.cpp
@@ -13,6 +13,7 @@
#include <Connection.h>
#include <Endpoint.h>
#include <Util.h>
+#include <Types.h>
#include <Ice/LocalException.h>
#include <Ice/Locator.h>
#include <Ice/Proxy.h>
@@ -827,6 +828,27 @@ IceRuby_ObjectPrx_ice_compress(VALUE self, VALUE b)
extern "C"
VALUE
+IceRuby_ObjectPrx_ice_getCompress(VALUE self)
+{
+ ICE_RUBY_TRY
+ {
+ Ice::ObjectPrx p = getProxy(self);
+ IceUtil::Optional<bool> c = p->ice_getCompress();
+ if(c)
+ {
+ return *c ? Qtrue : Qfalse;
+ }
+ else
+ {
+ return Unset;
+ }
+ }
+ ICE_RUBY_CATCH
+ return Qnil;
+}
+
+extern "C"
+VALUE
IceRuby_ObjectPrx_ice_timeout(VALUE self, VALUE t)
{
ICE_RUBY_TRY
@@ -848,6 +870,27 @@ IceRuby_ObjectPrx_ice_timeout(VALUE self, VALUE t)
extern "C"
VALUE
+IceRuby_ObjectPrx_ice_getTimeout(VALUE self)
+{
+ ICE_RUBY_TRY
+ {
+ Ice::ObjectPrx p = getProxy(self);
+ IceUtil::Optional<int> t = p->ice_getTimeout();
+ if(t)
+ {
+ return INT2FIX(*t);
+ }
+ else
+ {
+ return Unset;
+ }
+ }
+ ICE_RUBY_CATCH
+ return Qnil;
+}
+
+extern "C"
+VALUE
IceRuby_ObjectPrx_ice_connectionId(VALUE self, VALUE id)
{
ICE_RUBY_TRY
@@ -862,6 +905,29 @@ IceRuby_ObjectPrx_ice_connectionId(VALUE self, VALUE id)
extern "C"
VALUE
+IceRuby_ObjectPrx_ice_fixed(VALUE self, VALUE con)
+{
+ ICE_RUBY_TRY
+ {
+ Ice::ObjectPrx p = getProxy(self);
+
+ Ice::ConnectionPtr connection;
+ if(!NIL_P(con))
+ {
+ if(!checkConnection(con))
+ {
+ throw RubyException(rb_eTypeError, "argument must be an Ice.Connection");
+ }
+ connection = getConnection(con);
+ }
+ return createProxy(p->ice_fixed(connection), rb_class_of(self));
+ }
+ ICE_RUBY_CATCH
+ return Qnil;
+}
+
+extern "C"
+VALUE
IceRuby_ObjectPrx_ice_getConnection(VALUE self)
{
ICE_RUBY_TRY
@@ -1265,8 +1331,11 @@ IceRuby::initProxy(VALUE iceModule)
rb_define_method(_proxyClass, "ice_batchDatagram", CAST_METHOD(IceRuby_ObjectPrx_ice_batchDatagram), 0);
rb_define_method(_proxyClass, "ice_isBatchDatagram", CAST_METHOD(IceRuby_ObjectPrx_ice_isBatchDatagram), 0);
rb_define_method(_proxyClass, "ice_compress", CAST_METHOD(IceRuby_ObjectPrx_ice_compress), 1);
+ rb_define_method(_proxyClass, "ice_getCompress", CAST_METHOD(IceRuby_ObjectPrx_ice_getCompress), 0);
rb_define_method(_proxyClass, "ice_timeout", CAST_METHOD(IceRuby_ObjectPrx_ice_timeout), 1);
+ rb_define_method(_proxyClass, "ice_getTimeout", CAST_METHOD(IceRuby_ObjectPrx_ice_getTimeout), 0);
rb_define_method(_proxyClass, "ice_connectionId", CAST_METHOD(IceRuby_ObjectPrx_ice_connectionId), 1);
+ rb_define_method(_proxyClass, "ice_fixed", CAST_METHOD(IceRuby_ObjectPrx_ice_fixed), 1);
rb_define_method(_proxyClass, "ice_getConnection", CAST_METHOD(IceRuby_ObjectPrx_ice_getConnection), 0);
rb_define_method(_proxyClass, "ice_getCachedConnection", CAST_METHOD(IceRuby_ObjectPrx_ice_getCachedConnection), 0);
rb_define_method(_proxyClass, "ice_flushBatchRequests", CAST_METHOD(IceRuby_ObjectPrx_ice_flushBatchRequests), 0);
diff --git a/ruby/test/Ice/proxy/AllTests.rb b/ruby/test/Ice/proxy/AllTests.rb
index 42b4410ba97..a83885fe27f 100644
--- a/ruby/test/Ice/proxy/AllTests.rb
+++ b/ruby/test/Ice/proxy/AllTests.rb
@@ -508,11 +508,19 @@ def allTests(communicator)
#test(compObj.ice_compress(false) < compObj.ice_compress(true))
#test(!(compObj.ice_compress(true) < compObj.ice_compress(false)))
+ test(compObj.ice_getCompress() == Ice::Unset);
+ test(compObj.ice_compress(true).ice_getCompress() == true);
+ test(compObj.ice_compress(false).ice_getCompress() == false);
+
test(compObj.ice_timeout(20) == compObj.ice_timeout(20))
test(compObj.ice_timeout(10) != compObj.ice_timeout(20))
#test(compObj.ice_timeout(10) < compObj.ice_timeout(20))
#test(!(compObj.ice_timeout(20) < compObj.ice_timeout(10)))
+ test(compObj.ice_getTimeout() == Ice::Unset);
+ test(compObj.ice_timeout(10).ice_getTimeout() == 10);
+ test(compObj.ice_timeout(20).ice_getTimeout() == 20);
+
loc1 = Ice::LocatorPrx::uncheckedCast(communicator.stringToProxy("loc1:default -p 10000"))
loc2 = Ice::LocatorPrx::uncheckedCast(communicator.stringToProxy("loc2:default -p 10000"))
test(compObj.ice_locator(nil) == compObj.ice_locator(nil))
@@ -594,9 +602,13 @@ def allTests(communicator)
#test(compObj.ice_encodingVersion(Ice::Encoding_1_0) < compObj.ice_encodingVersion(Ice::Encoding_1_1))
#test(! (compObj.ice_encodingVersion(Ice::Encoding_1_1) < compObj.ice_encodingVersion(Ice::Encoding_1_0)))
- #
- # TODO: Ideally we should also test comparison of fixed proxies.
- #
+ baseConnection = base.ice_getConnection();
+ if(baseConnection != nil)
+ baseConnection2 = base.ice_connectionId("base2").ice_getConnection();
+ compObj1 = compObj1.ice_fixed(baseConnection);
+ compObj2 = compObj2.ice_fixed(baseConnection2);
+ test(compObj1 != compObj2);
+ end
puts "ok"
@@ -640,6 +652,29 @@ def allTests(communicator)
test(c == c2)
puts "ok"
+ print "testing ice_fixed... "
+ STDOUT.flush
+ connection = cl.ice_getConnection()
+ if connection != nil
+ cl.ice_fixed(connection).ice_ping()
+ test(cl.ice_secure(true).ice_fixed(connection).ice_isSecure())
+ test(cl.ice_facet("facet").ice_fixed(connection).ice_getFacet() == "facet")
+ test(cl.ice_oneway().ice_fixed(connection).ice_isOneway())
+ test(cl.ice_fixed(connection).ice_getConnection() == connection)
+ test(cl.ice_fixed(connection).ice_fixed(connection).ice_getConnection() == connection)
+ test(cl.ice_fixed(connection).ice_getTimeout() == Ice::Unset)
+ fixedConnection = cl.ice_connectionId("ice_fixed").ice_getConnection()
+ test(cl.ice_fixed(connection).ice_fixed(fixedConnection).ice_getConnection() == fixedConnection)
+ else
+ begin
+ cl.ice_fixed(connection)
+ test(false)
+ rescue
+ # Expected with null connection.
+ end
+ end
+ puts "ok"
+
print "testing encoding versioning... "
STDOUT.flush
ref20 = "test -e 2.0:default -p 12010";