diff options
author | Mark Spruiell <mes@zeroc.com> | 2017-01-30 13:45:21 -0800 |
---|---|---|
committer | Mark Spruiell <mes@zeroc.com> | 2017-01-30 13:45:21 -0800 |
commit | 61270a10f980933cf582edb766f10c8ac6d86e8a (patch) | |
tree | 45ab4a7c2986954054fce613bc3c8f7967e7951e /ruby/src/IceRuby | |
parent | Fix slice2cpp build failure (diff) | |
download | ice-61270a10f980933cf582edb766f10c8ac6d86e8a.tar.bz2 ice-61270a10f980933cf582edb766f10c8ac6d86e8a.tar.xz ice-61270a10f980933cf582edb766f10c8ac6d86e8a.zip |
merging IceBridge into master
Diffstat (limited to 'ruby/src/IceRuby')
-rw-r--r-- | ruby/src/IceRuby/Connection.cpp | 46 | ||||
-rw-r--r-- | ruby/src/IceRuby/Util.cpp | 4 |
2 files changed, 48 insertions, 2 deletions
diff --git a/ruby/src/IceRuby/Connection.cpp b/ruby/src/IceRuby/Connection.cpp index 6b4b57efdc7..2c5f65a8434 100644 --- a/ruby/src/IceRuby/Connection.cpp +++ b/ruby/src/IceRuby/Connection.cpp @@ -46,14 +46,23 @@ IceRuby::createConnection(const Ice::ConnectionPtr& p) extern "C" VALUE -IceRuby_Connection_close(VALUE self, VALUE b) +IceRuby_Connection_close(VALUE self, VALUE mode) { ICE_RUBY_TRY { Ice::ConnectionPtr* p = reinterpret_cast<Ice::ConnectionPtr*>(DATA_PTR(self)); assert(p); - (*p)->close(RTEST(b)); + volatile VALUE type = callRuby(rb_path2class, "Ice::ConnectionClose"); + if(callRuby(rb_obj_is_instance_of, mode, type) != Qtrue) + { + throw RubyException(rb_eTypeError, + "value for 'mode' argument must be an enumerator of Ice.ConnectionClose"); + } + volatile VALUE modeValue = callRuby(rb_funcall, mode, rb_intern("to_i"), 0); + assert(TYPE(modeValue) == T_FIXNUM); + Ice::ConnectionClose cc = static_cast<Ice::ConnectionClose>(FIX2LONG(modeValue)); + (*p)->close(cc); } ICE_RUBY_CATCH return Qnil; @@ -76,6 +85,21 @@ IceRuby_Connection_flushBatchRequests(VALUE self) extern "C" VALUE +IceRuby_Connection_heartbeat(VALUE self) +{ + ICE_RUBY_TRY + { + Ice::ConnectionPtr* p = reinterpret_cast<Ice::ConnectionPtr*>(DATA_PTR(self)); + assert(p); + + (*p)->heartbeat(); + } + ICE_RUBY_CATCH + return Qnil; +} + +extern "C" +VALUE IceRuby_Connection_setACM(VALUE self, VALUE t, VALUE c, VALUE h) { ICE_RUBY_TRY @@ -221,6 +245,7 @@ IceRuby_Connection_getEndpoint(VALUE self) ICE_RUBY_CATCH return Qnil; } + extern "C" VALUE IceRuby_Connection_setBufferSize(VALUE self, VALUE r, VALUE s) @@ -241,6 +266,21 @@ IceRuby_Connection_setBufferSize(VALUE self, VALUE r, VALUE s) extern "C" VALUE +IceRuby_Connection_throwException(VALUE self) +{ + ICE_RUBY_TRY + { + Ice::ConnectionPtr* p = reinterpret_cast<Ice::ConnectionPtr*>(DATA_PTR(self)); + assert(p); + + (*p)->throwException(); + } + ICE_RUBY_CATCH + return Qnil; +} + +extern "C" +VALUE IceRuby_Connection_toString(VALUE self) { ICE_RUBY_TRY @@ -377,6 +417,7 @@ IceRuby::initConnection(VALUE iceModule) // rb_define_method(_connectionClass, "close", CAST_METHOD(IceRuby_Connection_close), 1); rb_define_method(_connectionClass, "flushBatchRequests", CAST_METHOD(IceRuby_Connection_flushBatchRequests), 0); + rb_define_method(_connectionClass, "heartbeat", CAST_METHOD(IceRuby_Connection_heartbeat), 0); rb_define_method(_connectionClass, "setACM", CAST_METHOD(IceRuby_Connection_setACM), 3); rb_define_method(_connectionClass, "getACM", CAST_METHOD(IceRuby_Connection_getACM), 0); rb_define_method(_connectionClass, "type", CAST_METHOD(IceRuby_Connection_type), 0); @@ -384,6 +425,7 @@ IceRuby::initConnection(VALUE iceModule) rb_define_method(_connectionClass, "getInfo", CAST_METHOD(IceRuby_Connection_getInfo), 0); rb_define_method(_connectionClass, "getEndpoint", CAST_METHOD(IceRuby_Connection_getEndpoint), 0); rb_define_method(_connectionClass, "setBufferSize", CAST_METHOD(IceRuby_Connection_setBufferSize), 2); + rb_define_method(_connectionClass, "throwException", CAST_METHOD(IceRuby_Connection_throwException), 0); rb_define_method(_connectionClass, "toString", CAST_METHOD(IceRuby_Connection_toString), 0); rb_define_method(_connectionClass, "to_s", CAST_METHOD(IceRuby_Connection_toString), 0); rb_define_method(_connectionClass, "inspect", CAST_METHOD(IceRuby_Connection_toString), 0); diff --git a/ruby/src/IceRuby/Util.cpp b/ruby/src/IceRuby/Util.cpp index 7fa1222fb06..84708f2dfb8 100644 --- a/ruby/src/IceRuby/Util.cpp +++ b/ruby/src/IceRuby/Util.cpp @@ -732,6 +732,10 @@ setExceptionMembers(const Ice::LocalException& ex, VALUE p) volatile VALUE v = createString(e.reason); callRuby(rb_iv_set, p, "@reason", v); } + catch(const Ice::ConnectionManuallyClosedException& e) + { + callRuby(rb_iv_set, p, "@graceful", e.graceful ? Qtrue : Qfalse); + } catch(const Ice::LocalException&) { // |