diff options
author | Bernard Normier <bernard@zeroc.com> | 2007-02-01 17:09:49 +0000 |
---|---|---|
committer | Bernard Normier <bernard@zeroc.com> | 2007-02-01 17:09:49 +0000 |
commit | abada90e3f84dc703b8ddc9efcbed8a946fadead (patch) | |
tree | 2c6f9dccd510ea97cb927a7bd635422efaae547a /rb/src | |
parent | removing trace message (diff) | |
download | ice-abada90e3f84dc703b8ddc9efcbed8a946fadead.tar.bz2 ice-abada90e3f84dc703b8ddc9efcbed8a946fadead.tar.xz ice-abada90e3f84dc703b8ddc9efcbed8a946fadead.zip |
Expanded tabs into spaces
Diffstat (limited to 'rb/src')
-rw-r--r-- | rb/src/IceRuby/Communicator.cpp | 518 | ||||
-rw-r--r-- | rb/src/IceRuby/ImplicitContext.cpp | 50 | ||||
-rw-r--r-- | rb/src/IceRuby/Logger.cpp | 38 | ||||
-rw-r--r-- | rb/src/IceRuby/ObjectFactory.cpp | 58 | ||||
-rw-r--r-- | rb/src/IceRuby/Operation.cpp | 290 | ||||
-rw-r--r-- | rb/src/IceRuby/Properties.cpp | 228 | ||||
-rw-r--r-- | rb/src/IceRuby/Proxy.cpp | 920 | ||||
-rw-r--r-- | rb/src/IceRuby/Slice.cpp | 254 | ||||
-rw-r--r-- | rb/src/IceRuby/Types.cpp | 1536 | ||||
-rw-r--r-- | rb/src/IceRuby/Types.h | 2 | ||||
-rw-r--r-- | rb/src/IceRuby/Util.cpp | 300 | ||||
-rw-r--r-- | rb/src/IceRuby/Util.h | 16 |
12 files changed, 2105 insertions, 2105 deletions
diff --git a/rb/src/IceRuby/Communicator.cpp b/rb/src/IceRuby/Communicator.cpp index 8932525fe6b..7b0c56d04fb 100644 --- a/rb/src/IceRuby/Communicator.cpp +++ b/rb/src/IceRuby/Communicator.cpp @@ -36,13 +36,13 @@ IceRuby_Communicator_mark(Ice::CommunicatorPtr* p) assert(p); try { - ObjectFactoryPtr pof = ObjectFactoryPtr::dynamicCast((*p)->findObjectFactory("")); - assert(pof); - pof->mark(); + ObjectFactoryPtr pof = ObjectFactoryPtr::dynamicCast((*p)->findObjectFactory("")); + assert(pof); + pof->mark(); } catch(const Ice::CommunicatorDestroyedException&) { - // Ignore. This is expected. + // Ignore. This is expected. } } @@ -60,156 +60,156 @@ IceRuby_initialize(int argc, VALUE* argv, VALUE self) { ICE_RUBY_TRY { - volatile VALUE initDataCls = callRuby(rb_path2class, "Ice::InitializationData"); - volatile VALUE args = Qnil, initData = Qnil; - if(argc == 1) - { - if(isArray(argv[0])) - { - args = argv[0]; - } - else if(callRuby(rb_obj_is_instance_of, argv[0], initDataCls) == Qtrue) - { - initData = argv[0]; - } - else - { - throw RubyException(rb_eTypeError, "invalid argument to Ice::initialize"); - } - } - else if(argc == 2) - { - if(!isArray(argv[0]) || callRuby(rb_obj_is_instance_of, argv[1], initDataCls) == Qfalse) - { - throw RubyException(rb_eTypeError, "invalid argument to Ice::initialize"); - } - args = argv[0]; - initData = argv[1]; - } - else if(argc > 0) - { - throw RubyException(rb_eArgError, "invalid number of arguments to Ice::initialize"); - } - - Ice::StringSeq seq; - if(!NIL_P(args) && !arrayToStringSeq(args, seq)) - { - throw RubyException(rb_eTypeError, "invalid array argument to Ice::initialize"); - } - - // - // Use the with-args or the without-args version of initialize()? - // - bool hasArgs = !seq.empty(); - - Ice::InitializationData data; - if(!NIL_P(initData)) - { - volatile VALUE properties = callRuby(rb_iv_get, initData, "@properties"); - volatile VALUE logger = callRuby(rb_iv_get, initData, "@logger"); - - if(!NIL_P(properties)) - { - data.properties = getProperties(properties); - } - - if(!NIL_P(logger)) - { - throw RubyException(rb_eArgError, "custom logger is not supported"); - } - } - - // - // Insert the program name (stored in the Ruby global variable $0) as the first - // element of the sequence. - // - volatile VALUE progName = callRuby(rb_gv_get, "$0"); - seq.insert(seq.begin(), getString(progName)); - - data.properties = Ice::createProperties(seq, data.properties); - - // - // Disable collocation optimization, otherwise an invocation on a - // collocated servant results in a CollocationOptimizationException - // (because Ruby uses the blobject API). - // - // TODO: Enable if a server mapping is added. - // - //data.properties->setProperty("Ice.Default.CollocationOptimization", "0"); - - // - // Remaining command line options are passed to the communicator - // as an argument vector in case they contain plugin properties. - // - int ac = static_cast<int>(seq.size()); - char** av = new char*[ac + 1]; - int i = 0; - for(Ice::StringSeq::const_iterator s = seq.begin(); s != seq.end(); ++s, ++i) - { - av[i] = strdup(s->c_str()); - } - av[ac] = 0; - - Ice::CommunicatorPtr communicator; - try - { - if(hasArgs) - { - communicator = Ice::initialize(ac, av, data); - } - else - { - communicator = Ice::initialize(data); - } - } - catch(...) - { - for(i = 0; i < ac + 1; ++i) - { - free(av[i]); - } - delete[] av; - - throw; - } - - // - // Replace the contents of the given argument list with the filtered arguments. - // - if(!NIL_P(args)) - { - callRuby(rb_ary_clear, args); - - // - // We start at index 1 in order to skip the element that we inserted earlier. - // - for(i = 1; i < ac; ++i) - { - volatile VALUE str = createString(av[i]); - callRuby(rb_ary_push, args, str); - } - } - - for(i = 0; i < ac + 1; ++i) - { - free(av[i]); - } - delete[] av; - - ObjectFactoryPtr factory = new ObjectFactory; - communicator->addObjectFactory(factory, ""); - - VALUE result = Data_Wrap_Struct(_communicatorClass, IceRuby_Communicator_mark, - IceRuby_Communicator_free, new Ice::CommunicatorPtr(communicator)); - - CommunicatorMap::iterator p = _communicatorMap.find(communicator); - if(p != _communicatorMap.end()) - { - _communicatorMap.erase(p); - } - _communicatorMap.insert(CommunicatorMap::value_type(communicator, reinterpret_cast<const VALUE&>(result))); - - return result; + volatile VALUE initDataCls = callRuby(rb_path2class, "Ice::InitializationData"); + volatile VALUE args = Qnil, initData = Qnil; + if(argc == 1) + { + if(isArray(argv[0])) + { + args = argv[0]; + } + else if(callRuby(rb_obj_is_instance_of, argv[0], initDataCls) == Qtrue) + { + initData = argv[0]; + } + else + { + throw RubyException(rb_eTypeError, "invalid argument to Ice::initialize"); + } + } + else if(argc == 2) + { + if(!isArray(argv[0]) || callRuby(rb_obj_is_instance_of, argv[1], initDataCls) == Qfalse) + { + throw RubyException(rb_eTypeError, "invalid argument to Ice::initialize"); + } + args = argv[0]; + initData = argv[1]; + } + else if(argc > 0) + { + throw RubyException(rb_eArgError, "invalid number of arguments to Ice::initialize"); + } + + Ice::StringSeq seq; + if(!NIL_P(args) && !arrayToStringSeq(args, seq)) + { + throw RubyException(rb_eTypeError, "invalid array argument to Ice::initialize"); + } + + // + // Use the with-args or the without-args version of initialize()? + // + bool hasArgs = !seq.empty(); + + Ice::InitializationData data; + if(!NIL_P(initData)) + { + volatile VALUE properties = callRuby(rb_iv_get, initData, "@properties"); + volatile VALUE logger = callRuby(rb_iv_get, initData, "@logger"); + + if(!NIL_P(properties)) + { + data.properties = getProperties(properties); + } + + if(!NIL_P(logger)) + { + throw RubyException(rb_eArgError, "custom logger is not supported"); + } + } + + // + // Insert the program name (stored in the Ruby global variable $0) as the first + // element of the sequence. + // + volatile VALUE progName = callRuby(rb_gv_get, "$0"); + seq.insert(seq.begin(), getString(progName)); + + data.properties = Ice::createProperties(seq, data.properties); + + // + // Disable collocation optimization, otherwise an invocation on a + // collocated servant results in a CollocationOptimizationException + // (because Ruby uses the blobject API). + // + // TODO: Enable if a server mapping is added. + // + //data.properties->setProperty("Ice.Default.CollocationOptimization", "0"); + + // + // Remaining command line options are passed to the communicator + // as an argument vector in case they contain plugin properties. + // + int ac = static_cast<int>(seq.size()); + char** av = new char*[ac + 1]; + int i = 0; + for(Ice::StringSeq::const_iterator s = seq.begin(); s != seq.end(); ++s, ++i) + { + av[i] = strdup(s->c_str()); + } + av[ac] = 0; + + Ice::CommunicatorPtr communicator; + try + { + if(hasArgs) + { + communicator = Ice::initialize(ac, av, data); + } + else + { + communicator = Ice::initialize(data); + } + } + catch(...) + { + for(i = 0; i < ac + 1; ++i) + { + free(av[i]); + } + delete[] av; + + throw; + } + + // + // Replace the contents of the given argument list with the filtered arguments. + // + if(!NIL_P(args)) + { + callRuby(rb_ary_clear, args); + + // + // We start at index 1 in order to skip the element that we inserted earlier. + // + for(i = 1; i < ac; ++i) + { + volatile VALUE str = createString(av[i]); + callRuby(rb_ary_push, args, str); + } + } + + for(i = 0; i < ac + 1; ++i) + { + free(av[i]); + } + delete[] av; + + ObjectFactoryPtr factory = new ObjectFactory; + communicator->addObjectFactory(factory, ""); + + VALUE result = Data_Wrap_Struct(_communicatorClass, IceRuby_Communicator_mark, + IceRuby_Communicator_free, new Ice::CommunicatorPtr(communicator)); + + CommunicatorMap::iterator p = _communicatorMap.find(communicator); + if(p != _communicatorMap.end()) + { + _communicatorMap.erase(p); + } + _communicatorMap.insert(CommunicatorMap::value_type(communicator, reinterpret_cast<const VALUE&>(result))); + + return result; } ICE_RUBY_CATCH return Qnil; @@ -221,8 +221,8 @@ IceRuby_Communicator_destroy(VALUE self) { ICE_RUBY_TRY { - Ice::CommunicatorPtr p = getCommunicator(self); - p->destroy(); + Ice::CommunicatorPtr p = getCommunicator(self); + p->destroy(); } ICE_RUBY_CATCH return Qnil; @@ -234,8 +234,8 @@ IceRuby_Communicator_shutdown(VALUE self) { ICE_RUBY_TRY { - Ice::CommunicatorPtr p = getCommunicator(self); - p->shutdown(); + Ice::CommunicatorPtr p = getCommunicator(self); + p->shutdown(); } ICE_RUBY_CATCH return Qnil; @@ -247,8 +247,8 @@ IceRuby_Communicator_isShutdown(VALUE self) { ICE_RUBY_TRY { - Ice::CommunicatorPtr p = getCommunicator(self); - return p->isShutdown() ? Qtrue : Qfalse; + Ice::CommunicatorPtr p = getCommunicator(self); + return p->isShutdown() ? Qtrue : Qfalse; } ICE_RUBY_CATCH return Qnil; @@ -260,10 +260,10 @@ IceRuby_Communicator_stringToProxy(VALUE self, VALUE str) { ICE_RUBY_TRY { - Ice::CommunicatorPtr p = getCommunicator(self); - string s = getString(str); - Ice::ObjectPrx proxy = p->stringToProxy(s); - return createProxy(proxy); + Ice::CommunicatorPtr p = getCommunicator(self); + string s = getString(str); + Ice::ObjectPrx proxy = p->stringToProxy(s); + return createProxy(proxy); } ICE_RUBY_CATCH return Qnil; @@ -275,18 +275,18 @@ IceRuby_Communicator_proxyToString(VALUE self, VALUE proxy) { ICE_RUBY_TRY { - Ice::CommunicatorPtr p = getCommunicator(self); - Ice::ObjectPrx prx; - if(!NIL_P(proxy)) - { - if(!checkProxy(proxy)) - { - throw RubyException(rb_eTypeError, "argument must be a proxy"); - } - prx = getProxy(proxy); - } - string str = p->proxyToString(prx); - return createString(str); + Ice::CommunicatorPtr p = getCommunicator(self); + Ice::ObjectPrx prx; + if(!NIL_P(proxy)) + { + if(!checkProxy(proxy)) + { + throw RubyException(rb_eTypeError, "argument must be a proxy"); + } + prx = getProxy(proxy); + } + string str = p->proxyToString(prx); + return createString(str); } ICE_RUBY_CATCH return Qnil; @@ -298,10 +298,10 @@ IceRuby_Communicator_propertyToProxy(VALUE self, VALUE str) { ICE_RUBY_TRY { - Ice::CommunicatorPtr p = getCommunicator(self); - string s = getString(str); - Ice::ObjectPrx proxy = p->propertyToProxy(s); - return createProxy(proxy); + Ice::CommunicatorPtr p = getCommunicator(self); + string s = getString(str); + Ice::ObjectPrx proxy = p->propertyToProxy(s); + return createProxy(proxy); } ICE_RUBY_CATCH return Qnil; @@ -313,10 +313,10 @@ IceRuby_Communicator_stringToIdentity(VALUE self, VALUE str) { ICE_RUBY_TRY { - Ice::CommunicatorPtr p = getCommunicator(self); - string s = getString(str); - Ice::Identity ident = p->stringToIdentity(s); - return createIdentity(ident); + Ice::CommunicatorPtr p = getCommunicator(self); + string s = getString(str); + Ice::Identity ident = p->stringToIdentity(s); + return createIdentity(ident); } ICE_RUBY_CATCH return Qnil; @@ -328,10 +328,10 @@ IceRuby_Communicator_identityToString(VALUE self, VALUE id) { ICE_RUBY_TRY { - Ice::CommunicatorPtr p = getCommunicator(self); - Ice::Identity ident = getIdentity(id); - string str = p->identityToString(ident); - return createString(str); + Ice::CommunicatorPtr p = getCommunicator(self); + Ice::Identity ident = getIdentity(id); + string str = p->identityToString(ident); + return createString(str); } ICE_RUBY_CATCH return Qnil; @@ -343,11 +343,11 @@ IceRuby_Communicator_addObjectFactory(VALUE self, VALUE factory, VALUE id) { ICE_RUBY_TRY { - Ice::CommunicatorPtr p = getCommunicator(self); - ObjectFactoryPtr pof = ObjectFactoryPtr::dynamicCast(p->findObjectFactory("")); - assert(pof); - string idstr = getString(id); - pof->add(factory, idstr); + Ice::CommunicatorPtr p = getCommunicator(self); + ObjectFactoryPtr pof = ObjectFactoryPtr::dynamicCast(p->findObjectFactory("")); + assert(pof); + string idstr = getString(id); + pof->add(factory, idstr); } ICE_RUBY_CATCH return Qnil; @@ -359,11 +359,11 @@ IceRuby_Communicator_findObjectFactory(VALUE self, VALUE id) { ICE_RUBY_TRY { - Ice::CommunicatorPtr p = getCommunicator(self); - ObjectFactoryPtr pof = ObjectFactoryPtr::dynamicCast(p->findObjectFactory("")); - assert(pof); - string idstr = getString(id); - return pof->find(idstr); + Ice::CommunicatorPtr p = getCommunicator(self); + ObjectFactoryPtr pof = ObjectFactoryPtr::dynamicCast(p->findObjectFactory("")); + assert(pof); + string idstr = getString(id); + return pof->find(idstr); } ICE_RUBY_CATCH return Qnil; @@ -377,9 +377,9 @@ IceRuby_Communicator_getDefaultContext(VALUE self) ICE_RUBY_TRY { - Ice::CommunicatorPtr p = getCommunicator(self); - Ice::Context ctx = p->getDefaultContext(); - return contextToHash(ctx); + Ice::CommunicatorPtr p = getCommunicator(self); + Ice::Context ctx = p->getDefaultContext(); + return contextToHash(ctx); } ICE_RUBY_CATCH return Qnil; @@ -393,14 +393,14 @@ IceRuby_Communicator_setDefaultContext(VALUE self, VALUE context) ICE_RUBY_TRY { - Ice::Context ctx; - if(!hashToContext(context, ctx)) - { - throw RubyException(rb_eTypeError, "argument must be a hash"); - } - - Ice::CommunicatorPtr p = getCommunicator(self); - p->setDefaultContext(ctx); + Ice::Context ctx; + if(!hashToContext(context, ctx)) + { + throw RubyException(rb_eTypeError, "argument must be a hash"); + } + + Ice::CommunicatorPtr p = getCommunicator(self); + p->setDefaultContext(ctx); } ICE_RUBY_CATCH return Qnil; @@ -412,9 +412,9 @@ IceRuby_Communicator_getImplicitContext(VALUE self) { ICE_RUBY_TRY { - Ice::CommunicatorPtr p = getCommunicator(self); - Ice::ImplicitContextPtr implicitContext = p->getImplicitContext(); - return createImplicitContext(implicitContext); + Ice::CommunicatorPtr p = getCommunicator(self); + Ice::ImplicitContextPtr implicitContext = p->getImplicitContext(); + return createImplicitContext(implicitContext); } ICE_RUBY_CATCH return Qnil; @@ -427,9 +427,9 @@ IceRuby_Communicator_getProperties(VALUE self) { ICE_RUBY_TRY { - Ice::CommunicatorPtr p = getCommunicator(self); - Ice::PropertiesPtr props = p->getProperties(); - return createProperties(props); + Ice::CommunicatorPtr p = getCommunicator(self); + Ice::PropertiesPtr props = p->getProperties(); + return createProperties(props); } ICE_RUBY_CATCH return Qnil; @@ -441,9 +441,9 @@ IceRuby_Communicator_getLogger(VALUE self) { ICE_RUBY_TRY { - Ice::CommunicatorPtr p = getCommunicator(self); - Ice::LoggerPtr logger = p->getLogger(); - return createLogger(logger); + Ice::CommunicatorPtr p = getCommunicator(self); + Ice::LoggerPtr logger = p->getLogger(); + return createLogger(logger); } ICE_RUBY_CATCH return Qnil; @@ -455,14 +455,14 @@ IceRuby_Communicator_getDefaultRouter(VALUE self) { ICE_RUBY_TRY { - Ice::CommunicatorPtr p = getCommunicator(self); - Ice::RouterPrx router = p->getDefaultRouter(); - if(router) - { - volatile VALUE cls = callRuby(rb_path2class, "Ice::RouterPrx"); - assert(!NIL_P(cls)); - return createProxy(router, cls); - } + Ice::CommunicatorPtr p = getCommunicator(self); + Ice::RouterPrx router = p->getDefaultRouter(); + if(router) + { + volatile VALUE cls = callRuby(rb_path2class, "Ice::RouterPrx"); + assert(!NIL_P(cls)); + return createProxy(router, cls); + } } ICE_RUBY_CATCH return Qnil; @@ -474,17 +474,17 @@ IceRuby_Communicator_setDefaultRouter(VALUE self, VALUE router) { ICE_RUBY_TRY { - Ice::CommunicatorPtr p = getCommunicator(self); - Ice::RouterPrx proxy; - if(!NIL_P(router)) - { - if(!checkProxy(router)) - { - throw RubyException(rb_eTypeError, "argument must be a proxy"); - } - proxy = Ice::RouterPrx::uncheckedCast(getProxy(router)); - } - p->setDefaultRouter(proxy); + Ice::CommunicatorPtr p = getCommunicator(self); + Ice::RouterPrx proxy; + if(!NIL_P(router)) + { + if(!checkProxy(router)) + { + throw RubyException(rb_eTypeError, "argument must be a proxy"); + } + proxy = Ice::RouterPrx::uncheckedCast(getProxy(router)); + } + p->setDefaultRouter(proxy); } ICE_RUBY_CATCH return Qnil; @@ -496,14 +496,14 @@ IceRuby_Communicator_getDefaultLocator(VALUE self) { ICE_RUBY_TRY { - Ice::CommunicatorPtr p = getCommunicator(self); - Ice::LocatorPrx locator = p->getDefaultLocator(); - if(locator) - { - volatile VALUE cls = callRuby(rb_path2class, "Ice::LocatorPrx"); - assert(!NIL_P(cls)); - return createProxy(locator, cls); - } + Ice::CommunicatorPtr p = getCommunicator(self); + Ice::LocatorPrx locator = p->getDefaultLocator(); + if(locator) + { + volatile VALUE cls = callRuby(rb_path2class, "Ice::LocatorPrx"); + assert(!NIL_P(cls)); + return createProxy(locator, cls); + } } ICE_RUBY_CATCH return Qnil; @@ -515,17 +515,17 @@ IceRuby_Communicator_setDefaultLocator(VALUE self, VALUE locator) { ICE_RUBY_TRY { - Ice::CommunicatorPtr p = getCommunicator(self); - Ice::LocatorPrx proxy; - if(!NIL_P(locator)) - { - if(!checkProxy(locator)) - { - throw RubyException(rb_eTypeError, "argument must be a proxy"); - } - proxy = Ice::LocatorPrx::uncheckedCast(getProxy(locator)); - } - p->setDefaultLocator(proxy); + Ice::CommunicatorPtr p = getCommunicator(self); + Ice::LocatorPrx proxy; + if(!NIL_P(locator)) + { + if(!checkProxy(locator)) + { + throw RubyException(rb_eTypeError, "argument must be a proxy"); + } + proxy = Ice::LocatorPrx::uncheckedCast(getProxy(locator)); + } + p->setDefaultLocator(proxy); } ICE_RUBY_CATCH return Qnil; @@ -537,8 +537,8 @@ IceRuby_Communicator_flushBatchRequests(VALUE self) { ICE_RUBY_TRY { - Ice::CommunicatorPtr p = getCommunicator(self); - p->flushBatchRequests(); + Ice::CommunicatorPtr p = getCommunicator(self); + p->flushBatchRequests(); } ICE_RUBY_CATCH return Qnil; @@ -586,7 +586,7 @@ IceRuby::lookupCommunicator(const Ice::CommunicatorPtr& p) CommunicatorMap::iterator q = _communicatorMap.find(p.get()); if(q != _communicatorMap.end()) { - return q->second; + return q->second; } return Qnil; } diff --git a/rb/src/IceRuby/ImplicitContext.cpp b/rb/src/IceRuby/ImplicitContext.cpp index f4dde065247..af31074245f 100644 --- a/rb/src/IceRuby/ImplicitContext.cpp +++ b/rb/src/IceRuby/ImplicitContext.cpp @@ -32,8 +32,8 @@ IceRuby_ImplicitContext_getContext(VALUE self) { ICE_RUBY_TRY { - Ice::ImplicitContextPtr p = getImplicitContext(self); - return contextToHash(p->getContext()); + Ice::ImplicitContextPtr p = getImplicitContext(self); + return contextToHash(p->getContext()); } ICE_RUBY_CATCH return Qnil; @@ -45,13 +45,13 @@ IceRuby_ImplicitContext_setContext(VALUE self, VALUE context) { ICE_RUBY_TRY { - Ice::Context ctx; - if(!hashToContext(context, ctx)) - { - throw RubyException(rb_eTypeError, "argument must be a hash"); - } - Ice::ImplicitContextPtr p = getImplicitContext(self); - p->setContext(ctx); + Ice::Context ctx; + if(!hashToContext(context, ctx)) + { + throw RubyException(rb_eTypeError, "argument must be a hash"); + } + Ice::ImplicitContextPtr p = getImplicitContext(self); + p->setContext(ctx); } ICE_RUBY_CATCH return Qnil; @@ -63,10 +63,10 @@ IceRuby_ImplicitContext_get(VALUE self, VALUE key) { ICE_RUBY_TRY { - Ice::ImplicitContextPtr p = getImplicitContext(self); - string k = getString(key); - string v = p->get(k); - return createString(v); + Ice::ImplicitContextPtr p = getImplicitContext(self); + string k = getString(key); + string v = p->get(k); + return createString(v); } ICE_RUBY_CATCH return Qnil; @@ -79,11 +79,11 @@ IceRuby_ImplicitContext_getWithDefault(VALUE self, VALUE key, VALUE dflt) { ICE_RUBY_TRY { - Ice::ImplicitContextPtr p = getImplicitContext(self); - string k = getString(key); - string d = getString(dflt); - string v = p->getWithDefault(k, d); - return createString(v); + Ice::ImplicitContextPtr p = getImplicitContext(self); + string k = getString(key); + string d = getString(dflt); + string v = p->getWithDefault(k, d); + return createString(v); } ICE_RUBY_CATCH return Qnil; @@ -96,10 +96,10 @@ IceRuby_ImplicitContext_set(VALUE self, VALUE key, VALUE value) { ICE_RUBY_TRY { - Ice::ImplicitContextPtr p = getImplicitContext(self); - string k = getString(key); - string v = getString(value); - p->set(k, v); + Ice::ImplicitContextPtr p = getImplicitContext(self); + string k = getString(key); + string v = getString(value); + p->set(k, v); } ICE_RUBY_CATCH return Qnil; @@ -111,9 +111,9 @@ IceRuby_ImplicitContext_remove(VALUE self, VALUE key) { ICE_RUBY_TRY { - Ice::ImplicitContextPtr p = getImplicitContext(self); - string k = getString(key); - p->remove(k); + Ice::ImplicitContextPtr p = getImplicitContext(self); + string k = getString(key); + p->remove(k); } ICE_RUBY_CATCH return Qnil; diff --git a/rb/src/IceRuby/Logger.cpp b/rb/src/IceRuby/Logger.cpp index 516bc0988b9..67ae57e52b3 100644 --- a/rb/src/IceRuby/Logger.cpp +++ b/rb/src/IceRuby/Logger.cpp @@ -36,11 +36,11 @@ IceRuby_Logger_print(VALUE self, VALUE message) { ICE_RUBY_TRY { - Ice::LoggerPtr* p = reinterpret_cast<Ice::LoggerPtr*>(DATA_PTR(self)); - assert(p); + Ice::LoggerPtr* p = reinterpret_cast<Ice::LoggerPtr*>(DATA_PTR(self)); + assert(p); - string msg = getString(message); - (*p)->print(msg); + string msg = getString(message); + (*p)->print(msg); } ICE_RUBY_CATCH return Qnil; @@ -52,12 +52,12 @@ IceRuby_Logger_trace(VALUE self, VALUE category, VALUE message) { ICE_RUBY_TRY { - Ice::LoggerPtr* p = reinterpret_cast<Ice::LoggerPtr*>(DATA_PTR(self)); - assert(p); + Ice::LoggerPtr* p = reinterpret_cast<Ice::LoggerPtr*>(DATA_PTR(self)); + assert(p); - string cat = getString(category); - string msg = getString(message); - (*p)->trace(cat, msg); + string cat = getString(category); + string msg = getString(message); + (*p)->trace(cat, msg); } ICE_RUBY_CATCH return Qnil; @@ -69,11 +69,11 @@ IceRuby_Logger_warning(VALUE self, VALUE message) { ICE_RUBY_TRY { - Ice::LoggerPtr* p = reinterpret_cast<Ice::LoggerPtr*>(DATA_PTR(self)); - assert(p); + Ice::LoggerPtr* p = reinterpret_cast<Ice::LoggerPtr*>(DATA_PTR(self)); + assert(p); - string msg = getString(message); - (*p)->warning(msg); + string msg = getString(message); + (*p)->warning(msg); } ICE_RUBY_CATCH return Qnil; @@ -85,11 +85,11 @@ IceRuby_Logger_error(VALUE self, VALUE message) { ICE_RUBY_TRY { - Ice::LoggerPtr* p = reinterpret_cast<Ice::LoggerPtr*>(DATA_PTR(self)); - assert(p); + Ice::LoggerPtr* p = reinterpret_cast<Ice::LoggerPtr*>(DATA_PTR(self)); + assert(p); - string msg = getString(message); - (*p)->error(msg); + string msg = getString(message); + (*p)->error(msg); } ICE_RUBY_CATCH return Qnil; @@ -101,8 +101,8 @@ IceRuby_getProcessLogger() { ICE_RUBY_TRY { - Ice::LoggerPtr logger = Ice::getProcessLogger(); - return createLogger(logger); + Ice::LoggerPtr logger = Ice::getProcessLogger(); + return createLogger(logger); } ICE_RUBY_CATCH return Qnil; diff --git a/rb/src/IceRuby/ObjectFactory.cpp b/rb/src/IceRuby/ObjectFactory.cpp index a5ed94901ab..19d6b9eab28 100644 --- a/rb/src/IceRuby/ObjectFactory.cpp +++ b/rb/src/IceRuby/ObjectFactory.cpp @@ -35,7 +35,7 @@ IceRuby::ObjectFactory::create(const string& id) ClassInfoPtr info = lookupClassInfo(id); if(!info) { - return 0; + return 0; } // @@ -44,16 +44,16 @@ IceRuby::ObjectFactory::create(const string& id) FactoryMap::iterator p = _factoryMap.find(id); if(p != _factoryMap.end()) { - // - // Invoke the create method on the Ruby factory object. - // - volatile VALUE str = createString(id); - volatile VALUE obj = callRuby(rb_funcall, p->second, rb_intern("create"), 1, str); - if(NIL_P(obj)) - { - return 0; - } - return new ObjectReader(obj, info); + // + // Invoke the create method on the Ruby factory object. + // + volatile VALUE str = createString(id); + volatile VALUE obj = callRuby(rb_funcall, p->second, rb_intern("create"), 1, str); + if(NIL_P(obj)) + { + return 0; + } + return new ObjectReader(obj, info); } // @@ -61,7 +61,7 @@ IceRuby::ObjectFactory::create(const string& id) // if(info->isAbstract) { - return 0; + return 0; } // @@ -79,17 +79,17 @@ IceRuby::ObjectFactory::destroy() for(FactoryMap::iterator p = _factoryMap.begin(); p != _factoryMap.end(); ++p) { - // - // Invoke the destroy method on each registered Ruby factory. - // - try - { - callRuby(rb_funcall, p->second, rb_intern("destroy"), 0); - } - catch(const RubyException&) - { - // Ignore. - } + // + // Invoke the destroy method on each registered Ruby factory. + // + try + { + callRuby(rb_funcall, p->second, rb_intern("destroy"), 0); + } + catch(const RubyException&) + { + // Ignore. + } } _factoryMap.clear(); } @@ -102,10 +102,10 @@ IceRuby::ObjectFactory::add(VALUE factory, const string& id) FactoryMap::iterator p = _factoryMap.find(id); if(p != _factoryMap.end()) { - Ice::AlreadyRegisteredException ex(__FILE__, __LINE__); - ex.kindOfObject = "object factory"; - ex.id = id; - throw ex; + Ice::AlreadyRegisteredException ex(__FILE__, __LINE__); + ex.kindOfObject = "object factory"; + ex.id = id; + throw ex; } _factoryMap.insert(FactoryMap::value_type(id, factory)); @@ -119,7 +119,7 @@ IceRuby::ObjectFactory::find(const string& id) FactoryMap::iterator p = _factoryMap.find(id); if(p == _factoryMap.end()) { - return Qnil; + return Qnil; } return p->second; @@ -130,6 +130,6 @@ IceRuby::ObjectFactory::mark() { for(FactoryMap::iterator p = _factoryMap.begin(); p != _factoryMap.end(); ++p) { - rb_gc_mark(p->second); + rb_gc_mark(p->second); } } diff --git a/rb/src/IceRuby/Operation.cpp b/rb/src/IceRuby/Operation.cpp index 3494c0d6376..2c8c161625b 100644 --- a/rb/src/IceRuby/Operation.cpp +++ b/rb/src/IceRuby/Operation.cpp @@ -80,12 +80,12 @@ IceRuby_Operation_free(OperationPtr* p) extern "C" VALUE IceRuby_defineOperation(VALUE /*self*/, VALUE name, VALUE mode, VALUE sendMode, VALUE amd, VALUE inParams, - VALUE outParams, VALUE returnType, VALUE exceptions) + VALUE outParams, VALUE returnType, VALUE exceptions) { ICE_RUBY_TRY { - OperationIPtr op = new OperationI(name, mode, sendMode, amd, inParams, outParams, returnType, exceptions); - return Data_Wrap_Struct(_operationClass, 0, IceRuby_Operation_free, new OperationPtr(op)); + OperationIPtr op = new OperationI(name, mode, sendMode, amd, inParams, outParams, returnType, exceptions); + return Data_Wrap_Struct(_operationClass, 0, IceRuby_Operation_free, new OperationPtr(op)); } ICE_RUBY_CATCH return Qnil; @@ -97,11 +97,11 @@ IceRuby_Operation_invoke(VALUE self, VALUE proxy, VALUE opArgs, VALUE ctx) { ICE_RUBY_TRY { - assert(TYPE(opArgs) == T_ARRAY); + assert(TYPE(opArgs) == T_ARRAY); - OperationPtr op = getOperation(self); - assert(op); - return op->invoke(getProxy(proxy), opArgs, ctx); + OperationPtr op = getOperation(self); + assert(op); + return op->invoke(getProxy(proxy), opArgs, ctx); } ICE_RUBY_CATCH return Qnil; @@ -113,9 +113,9 @@ IceRuby_Operation_deprecate(VALUE self, VALUE msg) { ICE_RUBY_TRY { - OperationPtr op = getOperation(self); - assert(op); - op->deprecate(getString(msg)); + OperationPtr op = getOperation(self); + assert(op); + op->deprecate(getString(msg)); } ICE_RUBY_CATCH return Qnil; @@ -143,17 +143,17 @@ IceRuby::ParamInfo::unmarshaled(VALUE val, VALUE target, void* closure) // OperationI implementation. // IceRuby::OperationI::OperationI(VALUE name, VALUE mode, VALUE sendMode, VALUE amd, VALUE inParams, VALUE outParams, - VALUE returnType, VALUE exceptions) + VALUE returnType, VALUE exceptions) { _name = getString(name); _amd = amd == Qtrue; if(_amd) { - _dispatchName = fixIdent(_name, IdentNormal) + "_async"; + _dispatchName = fixIdent(_name, IdentNormal) + "_async"; } else { - _dispatchName = fixIdent(_name, IdentNormal); + _dispatchName = fixIdent(_name, IdentNormal); } // @@ -178,13 +178,13 @@ IceRuby::OperationI::OperationI(VALUE name, VALUE mode, VALUE sendMode, VALUE am _sendsClasses = false; for(i = 0; i < RARRAY(inParams)->len; ++i) { - ParamInfoPtr param = new ParamInfo; - param->type = getType(RARRAY(inParams)->ptr[i]); - _inParams.push_back(param); - if(!_sendsClasses) - { - _sendsClasses = param->type->usesClasses(); - } + ParamInfoPtr param = new ParamInfo; + param->type = getType(RARRAY(inParams)->ptr[i]); + _inParams.push_back(param); + if(!_sendsClasses) + { + _sendsClasses = param->type->usesClasses(); + } } // @@ -193,13 +193,13 @@ IceRuby::OperationI::OperationI(VALUE name, VALUE mode, VALUE sendMode, VALUE am _returnsClasses = false; for(i = 0; i < RARRAY(outParams)->len; ++i) { - ParamInfoPtr param = new ParamInfo; - param->type = getType(RARRAY(outParams)->ptr[i]); - _outParams.push_back(param); - if(!_returnsClasses) - { - _returnsClasses = param->type->usesClasses(); - } + ParamInfoPtr param = new ParamInfo; + param->type = getType(RARRAY(outParams)->ptr[i]); + _outParams.push_back(param); + if(!_returnsClasses) + { + _returnsClasses = param->type->usesClasses(); + } } // @@ -207,12 +207,12 @@ IceRuby::OperationI::OperationI(VALUE name, VALUE mode, VALUE sendMode, VALUE am // if(!NIL_P(returnType)) { - _returnType = new ParamInfo; - _returnType->type = getType(returnType); - if(!_returnsClasses) - { - _returnsClasses = _returnType->type->usesClasses(); - } + _returnType = new ParamInfo; + _returnType->type = getType(returnType); + if(!_returnsClasses) + { + _returnsClasses = _returnType->type->usesClasses(); + } } // @@ -220,7 +220,7 @@ IceRuby::OperationI::OperationI(VALUE name, VALUE mode, VALUE sendMode, VALUE am // for(i = 0; i < RARRAY(exceptions)->len; ++i) { - _exceptions.push_back(getException(RARRAY(exceptions)->ptr[i])); + _exceptions.push_back(getException(RARRAY(exceptions)->ptr[i])); } } @@ -237,8 +237,8 @@ IceRuby::OperationI::invoke(const Ice::ObjectPrx& proxy, VALUE args, VALUE hctx) if(!_deprecateMessage.empty()) { - rb_warning(_deprecateMessage.c_str()); - _deprecateMessage.clear(); // Only show the warning once. + rb_warning(_deprecateMessage.c_str()); + _deprecateMessage.clear(); // Only show the warning once. } checkTwowayOnly(proxy); @@ -251,17 +251,17 @@ IceRuby::OperationI::invoke(const Ice::ObjectPrx& proxy, VALUE args, VALUE hctx) if(!NIL_P(hctx)) { - Ice::Context ctx; - if(!hashToContext(hctx, ctx)) - { - throw RubyException(rb_eArgError, "context argument must be nil or a hash"); - } + Ice::Context ctx; + if(!hashToContext(hctx, ctx)) + { + throw RubyException(rb_eArgError, "context argument must be nil or a hash"); + } - status = proxy->ice_invoke(_name, _sendMode, params, result, ctx); + status = proxy->ice_invoke(_name, _sendMode, params, result, ctx); } else { - status = proxy->ice_invoke(_name, _sendMode, params, result); + status = proxy->ice_invoke(_name, _sendMode, params, result); } // @@ -269,31 +269,31 @@ IceRuby::OperationI::invoke(const Ice::ObjectPrx& proxy, VALUE args, VALUE hctx) // if(proxy->ice_isTwoway()) { - if(!status) - { - // - // Unmarshal a user exception. - // - volatile VALUE ex = unmarshalException(result, communicator); - throw RubyException(ex); - } - else if(_outParams.size() > 0 || _returnType) - { - // - // Unmarshal the results. If there is more than one value to be returned, then return them - // in an array of the form [result, outParam1, ...]. Otherwise just return the value. - // - volatile VALUE results = unmarshalResults(result, communicator); - - if(RARRAY(results)->len > 1) - { - return results; - } - else - { - return RARRAY(results)->ptr[0]; - } - } + if(!status) + { + // + // Unmarshal a user exception. + // + volatile VALUE ex = unmarshalException(result, communicator); + throw RubyException(ex); + } + else if(_outParams.size() > 0 || _returnType) + { + // + // Unmarshal the results. If there is more than one value to be returned, then return them + // in an array of the form [result, outParam1, ...]. Otherwise just return the value. + // + volatile VALUE results = unmarshalResults(result, communicator); + + if(RARRAY(results)->len > 1) + { + return results; + } + else + { + return RARRAY(results)->ptr[0]; + } + } } return Qnil; @@ -304,17 +304,17 @@ IceRuby::OperationI::deprecate(const string& msg) { if(!msg.empty()) { - _deprecateMessage = msg; + _deprecateMessage = msg; } else { - _deprecateMessage = "operation " + _name + " is deprecated"; + _deprecateMessage = "operation " + _name + " is deprecated"; } } void IceRuby::OperationI::prepareRequest(const Ice::CommunicatorPtr& communicator, VALUE args, bool async, - vector<Ice::Byte>& bytes) + vector<Ice::Byte>& bytes) { // // Validate the number of arguments. @@ -323,45 +323,45 @@ IceRuby::OperationI::prepareRequest(const Ice::CommunicatorPtr& communicator, VA long paramCount = static_cast<long>(_inParams.size()); if(argc != paramCount) { - string fixedName = fixIdent(_name, IdentNormal); - throw RubyException(rb_eArgError, "%s expects %ld in parameters", fixedName.c_str(), paramCount); + string fixedName = fixIdent(_name, IdentNormal); + throw RubyException(rb_eArgError, "%s expects %ld in parameters", fixedName.c_str(), paramCount); } if(!_inParams.empty()) { - // - // Marshal the in parameters. - // - Ice::OutputStreamPtr os = Ice::createOutputStream(communicator); - - ObjectMap objectMap; - long i = 0; - for(ParamInfoList::iterator p = _inParams.begin(); p != _inParams.end(); ++p, ++i) - { - volatile VALUE arg = RARRAY(args)->ptr[i]; - if(!(*p)->type->validate(arg)) - { - string opName; - if(async) - { - opName = fixIdent(_name, IdentNormal) + "_async"; - } - else - { - opName = fixIdent(_name, IdentNormal); - } - throw RubyException(rb_eTypeError, "invalid value for argument %ld in operation `%s'", - async ? i + 2 : i + 1, opName.c_str()); - } - (*p)->type->marshal(arg, os, &objectMap); - } - - if(_sendsClasses) - { - os->writePendingObjects(); - } - - os->finished(bytes); + // + // Marshal the in parameters. + // + Ice::OutputStreamPtr os = Ice::createOutputStream(communicator); + + ObjectMap objectMap; + long i = 0; + for(ParamInfoList::iterator p = _inParams.begin(); p != _inParams.end(); ++p, ++i) + { + volatile VALUE arg = RARRAY(args)->ptr[i]; + if(!(*p)->type->validate(arg)) + { + string opName; + if(async) + { + opName = fixIdent(_name, IdentNormal) + "_async"; + } + else + { + opName = fixIdent(_name, IdentNormal); + } + throw RubyException(rb_eTypeError, "invalid value for argument %ld in operation `%s'", + async ? i + 2 : i + 1, opName.c_str()); + } + (*p)->type->marshal(arg, os, &objectMap); + } + + if(_sendsClasses) + { + os->writePendingObjects(); + } + + os->finished(bytes); } } @@ -381,18 +381,18 @@ IceRuby::OperationI::unmarshalResults(const vector<Ice::Byte>& bytes, const Ice: Ice::InputStreamPtr is = Ice::createInputStream(communicator, bytes); for(ParamInfoList::iterator p = _outParams.begin(); p != _outParams.end(); ++p, ++i) { - void* closure = reinterpret_cast<void*>(i); - (*p)->type->unmarshal(is, *p, results, closure); + void* closure = reinterpret_cast<void*>(i); + (*p)->type->unmarshal(is, *p, results, closure); } if(_returnType) { - _returnType->type->unmarshal(is, _returnType, results, 0); + _returnType->type->unmarshal(is, _returnType, results, 0); } if(_returnsClasses) { - is->readPendingObjects(); + is->readPendingObjects(); } RARRAY(results)->len = numResults; @@ -409,34 +409,34 @@ IceRuby::OperationI::unmarshalException(const vector<Ice::Byte>& bytes, const Ic string id = is->readString(); while(!id.empty()) { - ExceptionInfoPtr info = lookupExceptionInfo(id); - if(info) - { - volatile VALUE ex = info->unmarshal(is); - if(info->usesClasses) - { - is->readPendingObjects(); - } - - if(validateException(ex)) - { - return ex; - } - else - { - volatile VALUE cls = CLASS_OF(ex); - volatile VALUE path = callRuby(rb_class_path, cls); - assert(TYPE(path) == T_STRING); - Ice::UnknownUserException e(__FILE__, __LINE__); - e.unknown = RSTRING(path)->ptr; - throw e; - } - } - else - { - is->skipSlice(); - id = is->readString(); - } + ExceptionInfoPtr info = lookupExceptionInfo(id); + if(info) + { + volatile VALUE ex = info->unmarshal(is); + if(info->usesClasses) + { + is->readPendingObjects(); + } + + if(validateException(ex)) + { + return ex; + } + else + { + volatile VALUE cls = CLASS_OF(ex); + volatile VALUE path = callRuby(rb_class_path, cls); + assert(TYPE(path) == T_STRING); + Ice::UnknownUserException e(__FILE__, __LINE__); + e.unknown = RSTRING(path)->ptr; + throw e; + } + } + else + { + is->skipSlice(); + id = is->readString(); + } } // @@ -453,10 +453,10 @@ IceRuby::OperationI::validateException(VALUE ex) const { for(ExceptionInfoList::const_iterator p = _exceptions.begin(); p != _exceptions.end(); ++p) { - if(callRuby(rb_obj_is_kind_of, ex, (*p)->rubyClass)) - { - return true; - } + if(callRuby(rb_obj_is_kind_of, ex, (*p)->rubyClass)) + { + return true; + } } return false; @@ -467,9 +467,9 @@ IceRuby::OperationI::checkTwowayOnly(const Ice::ObjectPrx& proxy) const { if((_returnType != 0 || !_outParams.empty()) && !proxy->ice_isTwoway()) { - Ice::TwowayOnlyException ex(__FILE__, __LINE__); - ex.operation = _name; - throw ex; + Ice::TwowayOnlyException ex(__FILE__, __LINE__); + ex.operation = _name; + throw ex; } } diff --git a/rb/src/IceRuby/Properties.cpp b/rb/src/IceRuby/Properties.cpp index c597a09d79f..2a8be6e708c 100644 --- a/rb/src/IceRuby/Properties.cpp +++ b/rb/src/IceRuby/Properties.cpp @@ -31,49 +31,49 @@ IceRuby_createProperties(int argc, VALUE* argv, VALUE self) { ICE_RUBY_TRY { - Ice::StringSeq seq; - if(argc >= 1 && !NIL_P(argv[0]) && !arrayToStringSeq(argv[0], seq)) - { - throw RubyException(rb_eTypeError, "invalid array argument to Ice::createProperties"); - } + Ice::StringSeq seq; + if(argc >= 1 && !NIL_P(argv[0]) && !arrayToStringSeq(argv[0], seq)) + { + throw RubyException(rb_eTypeError, "invalid array argument to Ice::createProperties"); + } - Ice::PropertiesPtr defaults; - if(argc == 2) - { - if(!NIL_P(argv[1]) && callRuby(rb_obj_is_instance_of, argv[1], _propertiesClass) == Qfalse) - { - throw RubyException(rb_eTypeError, "invalid properties argument to Ice::createProperties"); - } - defaults = getProperties(argv[1]); - } + Ice::PropertiesPtr defaults; + if(argc == 2) + { + if(!NIL_P(argv[1]) && callRuby(rb_obj_is_instance_of, argv[1], _propertiesClass) == Qfalse) + { + throw RubyException(rb_eTypeError, "invalid properties argument to Ice::createProperties"); + } + defaults = getProperties(argv[1]); + } - // - // Insert the program name (stored in the Ruby global variable $0) as the first - // element of the sequence. - // - volatile VALUE progName = callRuby(rb_gv_get, "$0"); - seq.insert(seq.begin(), getString(progName)); + // + // Insert the program name (stored in the Ruby global variable $0) as the first + // element of the sequence. + // + volatile VALUE progName = callRuby(rb_gv_get, "$0"); + seq.insert(seq.begin(), getString(progName)); - Ice::PropertiesPtr obj = Ice::createProperties(seq, defaults); + Ice::PropertiesPtr obj = Ice::createProperties(seq, defaults); - // - // Replace the contents of the given argument list with the filtered arguments. - // - if(argc > 0 && !NIL_P(argv[0])) - { - callRuby(rb_ary_clear, argv[0]); + // + // Replace the contents of the given argument list with the filtered arguments. + // + if(argc > 0 && !NIL_P(argv[0])) + { + callRuby(rb_ary_clear, argv[0]); - // - // We start at index 1 in order to skip the element that we inserted earlier. - // - for(Ice::StringSeq::size_type i = 1; i < seq.size(); ++i) - { - volatile VALUE str = createString(seq[i]); - callRuby(rb_ary_push, argv[0], str); - } - } + // + // We start at index 1 in order to skip the element that we inserted earlier. + // + for(Ice::StringSeq::size_type i = 1; i < seq.size(); ++i) + { + volatile VALUE str = createString(seq[i]); + callRuby(rb_ary_push, argv[0], str); + } + } - return createProperties(obj); + return createProperties(obj); } ICE_RUBY_CATCH return Qnil; @@ -85,10 +85,10 @@ IceRuby_Properties_getProperty(VALUE self, VALUE key) { ICE_RUBY_TRY { - Ice::PropertiesPtr p = getProperties(self); - string k = getString(key); - string v = p->getProperty(k); - return createString(v); + Ice::PropertiesPtr p = getProperties(self); + string k = getString(key); + string v = p->getProperty(k); + return createString(v); } ICE_RUBY_CATCH return Qnil; @@ -100,11 +100,11 @@ IceRuby_Properties_getPropertyWithDefault(VALUE self, VALUE key, VALUE def) { ICE_RUBY_TRY { - Ice::PropertiesPtr p = getProperties(self); - string k = getString(key); - string d = getString(def); - string v = p->getPropertyWithDefault(k, d); - return createString(v); + Ice::PropertiesPtr p = getProperties(self); + string k = getString(key); + string d = getString(def); + string v = p->getPropertyWithDefault(k, d); + return createString(v); } ICE_RUBY_CATCH return Qnil; @@ -116,10 +116,10 @@ IceRuby_Properties_getPropertyAsInt(VALUE self, VALUE key) { ICE_RUBY_TRY { - Ice::PropertiesPtr p = getProperties(self); - string k = getString(key); - Ice::Int v = p->getPropertyAsInt(k); - return INT2FIX(v); + Ice::PropertiesPtr p = getProperties(self); + string k = getString(key); + Ice::Int v = p->getPropertyAsInt(k); + return INT2FIX(v); } ICE_RUBY_CATCH return Qnil; @@ -131,11 +131,11 @@ IceRuby_Properties_getPropertyAsIntWithDefault(VALUE self, VALUE key, VALUE def) { ICE_RUBY_TRY { - Ice::PropertiesPtr p = getProperties(self); - string k = getString(key); - Ice::Int d = getInteger(def); - Ice::Int v = p->getPropertyAsIntWithDefault(k, d); - return INT2FIX(v); + Ice::PropertiesPtr p = getProperties(self); + string k = getString(key); + Ice::Int d = getInteger(def); + Ice::Int v = p->getPropertyAsIntWithDefault(k, d); + return INT2FIX(v); } ICE_RUBY_CATCH return Qnil; @@ -147,17 +147,17 @@ IceRuby_Properties_getPropertiesForPrefix(VALUE self, VALUE prefix) { ICE_RUBY_TRY { - Ice::PropertiesPtr p = getProperties(self); - string pfx = getString(prefix); - Ice::PropertyDict dict = p->getPropertiesForPrefix(pfx); - volatile VALUE result = callRuby(rb_hash_new); - for(Ice::PropertyDict::const_iterator q = dict.begin(); q != dict.end(); ++q) - { - volatile VALUE key = createString(q->first); - volatile VALUE value = createString(q->second); - callRuby(rb_hash_aset, result, key, value); - } - return result; + Ice::PropertiesPtr p = getProperties(self); + string pfx = getString(prefix); + Ice::PropertyDict dict = p->getPropertiesForPrefix(pfx); + volatile VALUE result = callRuby(rb_hash_new); + for(Ice::PropertyDict::const_iterator q = dict.begin(); q != dict.end(); ++q) + { + volatile VALUE key = createString(q->first); + volatile VALUE value = createString(q->second); + callRuby(rb_hash_aset, result, key, value); + } + return result; } ICE_RUBY_CATCH return Qnil; @@ -169,10 +169,10 @@ IceRuby_Properties_setProperty(VALUE self, VALUE key, VALUE value) { ICE_RUBY_TRY { - Ice::PropertiesPtr p = getProperties(self); - string k = getString(key); - string v = getString(value); - p->setProperty(k, v); + Ice::PropertiesPtr p = getProperties(self); + string k = getString(key); + string v = getString(value); + p->setProperty(k, v); } ICE_RUBY_CATCH return Qnil; @@ -184,9 +184,9 @@ IceRuby_Properties_getCommandLineOptions(VALUE self) { ICE_RUBY_TRY { - Ice::PropertiesPtr p = getProperties(self); - Ice::StringSeq options = p->getCommandLineOptions(); - return stringSeqToArray(options); + Ice::PropertiesPtr p = getProperties(self); + Ice::StringSeq options = p->getCommandLineOptions(); + return stringSeqToArray(options); } ICE_RUBY_CATCH return Qnil; @@ -198,15 +198,15 @@ IceRuby_Properties_parseCommandLineOptions(VALUE self, VALUE prefix, VALUE optio { ICE_RUBY_TRY { - Ice::PropertiesPtr p = getProperties(self); - string pfx = getString(prefix); - Ice::StringSeq seq; - if(!arrayToStringSeq(options, seq)) - { - throw RubyException(rb_eTypeError, "invalid array argument to Ice::parseCommandLineOptions"); - } - Ice::StringSeq filtered = p->parseCommandLineOptions(pfx, seq); - return stringSeqToArray(filtered); + Ice::PropertiesPtr p = getProperties(self); + string pfx = getString(prefix); + Ice::StringSeq seq; + if(!arrayToStringSeq(options, seq)) + { + throw RubyException(rb_eTypeError, "invalid array argument to Ice::parseCommandLineOptions"); + } + Ice::StringSeq filtered = p->parseCommandLineOptions(pfx, seq); + return stringSeqToArray(filtered); } ICE_RUBY_CATCH return Qnil; @@ -218,14 +218,14 @@ IceRuby_Properties_parseIceCommandLineOptions(VALUE self, VALUE options) { ICE_RUBY_TRY { - Ice::PropertiesPtr p = getProperties(self); - Ice::StringSeq seq; - if(!arrayToStringSeq(options, seq)) - { - throw RubyException(rb_eTypeError, "invalid array argument to Ice::parseIceCommandLineOptions"); - } - Ice::StringSeq filtered = p->parseIceCommandLineOptions(seq); - return stringSeqToArray(filtered); + Ice::PropertiesPtr p = getProperties(self); + Ice::StringSeq seq; + if(!arrayToStringSeq(options, seq)) + { + throw RubyException(rb_eTypeError, "invalid array argument to Ice::parseIceCommandLineOptions"); + } + Ice::StringSeq filtered = p->parseIceCommandLineOptions(seq); + return stringSeqToArray(filtered); } ICE_RUBY_CATCH return Qnil; @@ -237,9 +237,9 @@ IceRuby_Properties_load(VALUE self, VALUE file) { ICE_RUBY_TRY { - Ice::PropertiesPtr p = getProperties(self); - string f = getString(file); - p->load(f); + Ice::PropertiesPtr p = getProperties(self); + string f = getString(file); + p->load(f); } ICE_RUBY_CATCH return Qnil; @@ -251,9 +251,9 @@ IceRuby_Properties_clone(VALUE self) { ICE_RUBY_TRY { - Ice::PropertiesPtr p = getProperties(self); - Ice::PropertiesPtr props = p->clone(); - return createProperties(props); + Ice::PropertiesPtr p = getProperties(self); + Ice::PropertiesPtr props = p->clone(); + return createProperties(props); } ICE_RUBY_CATCH return Qnil; @@ -265,18 +265,18 @@ IceRuby_Properties_to_s(VALUE self) { ICE_RUBY_TRY { - Ice::PropertiesPtr p = getProperties(self); - Ice::PropertyDict dict = p->getPropertiesForPrefix(""); - string str; - for(Ice::PropertyDict::const_iterator q = dict.begin(); q != dict.end(); ++q) - { - if(q != dict.begin()) - { - str.append("\n"); - } - str.append(q->first + "=" + q->second); - } - return createString(str); + Ice::PropertiesPtr p = getProperties(self); + Ice::PropertyDict dict = p->getPropertiesForPrefix(""); + string str; + for(Ice::PropertyDict::const_iterator q = dict.begin(); q != dict.end(); ++q) + { + if(q != dict.begin()) + { + str.append("\n"); + } + str.append(q->first + "=" + q->second); + } + return createString(str); } ICE_RUBY_CATCH return Qnil; @@ -290,19 +290,19 @@ IceRuby::initProperties(VALUE iceModule) _propertiesClass = rb_define_class_under(iceModule, "PropertiesI", rb_cObject); rb_define_method(_propertiesClass, "getProperty", CAST_METHOD(IceRuby_Properties_getProperty), 1); rb_define_method(_propertiesClass, "getPropertyWithDefault", - CAST_METHOD(IceRuby_Properties_getPropertyWithDefault), 2); + CAST_METHOD(IceRuby_Properties_getPropertyWithDefault), 2); rb_define_method(_propertiesClass, "getPropertyAsInt", CAST_METHOD(IceRuby_Properties_getPropertyAsInt), 1); rb_define_method(_propertiesClass, "getPropertyAsIntWithDefault", - CAST_METHOD(IceRuby_Properties_getPropertyAsIntWithDefault), 2); + CAST_METHOD(IceRuby_Properties_getPropertyAsIntWithDefault), 2); rb_define_method(_propertiesClass, "getPropertiesForPrefix", - CAST_METHOD(IceRuby_Properties_getPropertiesForPrefix), 1); + CAST_METHOD(IceRuby_Properties_getPropertiesForPrefix), 1); rb_define_method(_propertiesClass, "setProperty", CAST_METHOD(IceRuby_Properties_setProperty), 2); rb_define_method(_propertiesClass, "getCommandLineOptions", CAST_METHOD(IceRuby_Properties_getCommandLineOptions), - 0); + 0); rb_define_method(_propertiesClass, "parseCommandLineOptions", - CAST_METHOD(IceRuby_Properties_parseCommandLineOptions), 2); + CAST_METHOD(IceRuby_Properties_parseCommandLineOptions), 2); rb_define_method(_propertiesClass, "parseIceCommandLineOptions", - CAST_METHOD(IceRuby_Properties_parseIceCommandLineOptions), 1); + CAST_METHOD(IceRuby_Properties_parseIceCommandLineOptions), 1); rb_define_method(_propertiesClass, "load", CAST_METHOD(IceRuby_Properties_load), 1); rb_define_method(_propertiesClass, "clone", CAST_METHOD(IceRuby_Properties_clone), 0); rb_define_method(_propertiesClass, "to_s", CAST_METHOD(IceRuby_Properties_to_s), 0); diff --git a/rb/src/IceRuby/Proxy.cpp b/rb/src/IceRuby/Proxy.cpp index 51bc3dc9491..e96683559dc 100644 --- a/rb/src/IceRuby/Proxy.cpp +++ b/rb/src/IceRuby/Proxy.cpp @@ -46,10 +46,10 @@ IceRuby_Connection_close(VALUE self, VALUE b) { ICE_RUBY_TRY { - Ice::ConnectionPtr* p = reinterpret_cast<Ice::ConnectionPtr*>(DATA_PTR(self)); - assert(p); + Ice::ConnectionPtr* p = reinterpret_cast<Ice::ConnectionPtr*>(DATA_PTR(self)); + assert(p); - (*p)->close(RTEST(b)); + (*p)->close(RTEST(b)); } ICE_RUBY_CATCH return Qnil; @@ -61,10 +61,10 @@ IceRuby_Connection_flushBatchRequests(VALUE self) { ICE_RUBY_TRY { - Ice::ConnectionPtr* p = reinterpret_cast<Ice::ConnectionPtr*>(DATA_PTR(self)); - assert(p); + Ice::ConnectionPtr* p = reinterpret_cast<Ice::ConnectionPtr*>(DATA_PTR(self)); + assert(p); - (*p)->flushBatchRequests(); + (*p)->flushBatchRequests(); } ICE_RUBY_CATCH return Qnil; @@ -76,11 +76,11 @@ IceRuby_Connection_type(VALUE self) { ICE_RUBY_TRY { - Ice::ConnectionPtr* p = reinterpret_cast<Ice::ConnectionPtr*>(DATA_PTR(self)); - assert(p); + Ice::ConnectionPtr* p = reinterpret_cast<Ice::ConnectionPtr*>(DATA_PTR(self)); + assert(p); - string s = (*p)->type(); - return createString(s); + string s = (*p)->type(); + return createString(s); } ICE_RUBY_CATCH return Qnil; @@ -92,11 +92,11 @@ IceRuby_Connection_timeout(VALUE self) { ICE_RUBY_TRY { - Ice::ConnectionPtr* p = reinterpret_cast<Ice::ConnectionPtr*>(DATA_PTR(self)); - assert(p); + Ice::ConnectionPtr* p = reinterpret_cast<Ice::ConnectionPtr*>(DATA_PTR(self)); + assert(p); - Ice::Int timeout = (*p)->timeout(); - return INT2FIX(timeout); + Ice::Int timeout = (*p)->timeout(); + return INT2FIX(timeout); } ICE_RUBY_CATCH return Qnil; @@ -108,11 +108,11 @@ IceRuby_Connection_toString(VALUE self) { ICE_RUBY_TRY { - Ice::ConnectionPtr* p = reinterpret_cast<Ice::ConnectionPtr*>(DATA_PTR(self)); - assert(p); + Ice::ConnectionPtr* p = reinterpret_cast<Ice::ConnectionPtr*>(DATA_PTR(self)); + assert(p); - string s = (*p)->toString(); - return createString(s); + string s = (*p)->toString(); + return createString(s); } ICE_RUBY_CATCH return Qnil; @@ -142,11 +142,11 @@ IceRuby_Endpoint_toString(VALUE self) { ICE_RUBY_TRY { - Ice::EndpointPtr* p = reinterpret_cast<Ice::EndpointPtr*>(DATA_PTR(self)); - assert(p); + Ice::EndpointPtr* p = reinterpret_cast<Ice::EndpointPtr*>(DATA_PTR(self)); + assert(p); - string s = (*p)->toString(); - return createString(s); + string s = (*p)->toString(); + return createString(s); } ICE_RUBY_CATCH return Qnil; @@ -185,16 +185,16 @@ checkArgs(const char* name, int numArgs, int argc, VALUE* argv, Ice::Context& ct { if(argc < numArgs || argc > numArgs + 1) { - throw RubyException(rb_eArgError, "%s expects %d argument%s including an optional context hash", name, - numArgs + 1, numArgs + 1 == 1 ? "" : "s"); + throw RubyException(rb_eArgError, "%s expects %d argument%s including an optional context hash", name, + numArgs + 1, numArgs + 1 == 1 ? "" : "s"); } if(argc == numArgs + 1) { - if(!hashToContext(argv[numArgs], ctx)) - { - throw RubyException(rb_eArgError, "%s: invalid context hash", name); - } - return true; + if(!hashToContext(argv[numArgs], ctx)) + { + throw RubyException(rb_eArgError, "%s: invalid context hash", name); + } + return true; } return false; } @@ -205,8 +205,8 @@ IceRuby_ObjectPrx_ice_getHash(VALUE self) { ICE_RUBY_TRY { - Ice::ObjectPrx p = getProxy(self); - return INT2FIX(p->ice_getHash()); + Ice::ObjectPrx p = getProxy(self); + return INT2FIX(p->ice_getHash()); } ICE_RUBY_CATCH return Qnil; @@ -218,9 +218,9 @@ IceRuby_ObjectPrx_ice_getCommunicator(VALUE self) { ICE_RUBY_TRY { - Ice::ObjectPrx p = getProxy(self); - Ice::CommunicatorPtr communicator = p->ice_getCommunicator(); - return lookupCommunicator(communicator); + Ice::ObjectPrx p = getProxy(self); + Ice::CommunicatorPtr communicator = p->ice_getCommunicator(); + return lookupCommunicator(communicator); } ICE_RUBY_CATCH return Qnil; @@ -232,9 +232,9 @@ IceRuby_ObjectPrx_ice_toString(VALUE self) { ICE_RUBY_TRY { - Ice::ObjectPrx p = getProxy(self); - string s = p->ice_toString(); - return createString(s); + Ice::ObjectPrx p = getProxy(self); + string s = p->ice_toString(); + return createString(s); } ICE_RUBY_CATCH return Qnil; @@ -246,23 +246,23 @@ IceRuby_ObjectPrx_ice_isA(int argc, VALUE* argv, VALUE self) { ICE_RUBY_TRY { - Ice::ObjectPrx p = getProxy(self); + Ice::ObjectPrx p = getProxy(self); - Ice::Context ctx; - bool haveContext = checkArgs("ice_isA", 1, argc, argv, ctx); + Ice::Context ctx; + bool haveContext = checkArgs("ice_isA", 1, argc, argv, ctx); - string id = getString(argv[0]); + string id = getString(argv[0]); - bool result; - if(haveContext) - { - result = p->ice_isA(id, ctx); - } - else - { - result = p->ice_isA(id); - } - return result ? Qtrue : Qfalse; + bool result; + if(haveContext) + { + result = p->ice_isA(id, ctx); + } + else + { + result = p->ice_isA(id); + } + return result ? Qtrue : Qfalse; } ICE_RUBY_CATCH return Qnil; @@ -274,19 +274,19 @@ IceRuby_ObjectPrx_ice_ping(int argc, VALUE* argv, VALUE self) { ICE_RUBY_TRY { - Ice::ObjectPrx p = getProxy(self); + Ice::ObjectPrx p = getProxy(self); - Ice::Context ctx; - bool haveContext = checkArgs("ice_ping", 0, argc, argv, ctx); + Ice::Context ctx; + bool haveContext = checkArgs("ice_ping", 0, argc, argv, ctx); - if(haveContext) - { - p->ice_ping(ctx); - } - else - { - p->ice_ping(); - } + if(haveContext) + { + p->ice_ping(ctx); + } + else + { + p->ice_ping(); + } } ICE_RUBY_CATCH return Qnil; @@ -298,30 +298,30 @@ IceRuby_ObjectPrx_ice_ids(int argc, VALUE* argv, VALUE self) { ICE_RUBY_TRY { - Ice::ObjectPrx p = getProxy(self); - - Ice::Context ctx; - bool haveContext = checkArgs("ice_ids", 0, argc, argv, ctx); - - vector<string> ids; - if(haveContext) - { - ids = p->ice_ids(ctx); - } - else - { - ids = p->ice_ids(); - } - - volatile VALUE result = createArray(ids.size()); - long i = 0; - for(vector<string>::iterator q = ids.begin(); q != ids.end(); ++q, ++i) - { - RARRAY(result)->ptr[i] = createString(*q); - } - RARRAY(result)->len = static_cast<long>(ids.size()); + Ice::ObjectPrx p = getProxy(self); - return result; + Ice::Context ctx; + bool haveContext = checkArgs("ice_ids", 0, argc, argv, ctx); + + vector<string> ids; + if(haveContext) + { + ids = p->ice_ids(ctx); + } + else + { + ids = p->ice_ids(); + } + + volatile VALUE result = createArray(ids.size()); + long i = 0; + for(vector<string>::iterator q = ids.begin(); q != ids.end(); ++q, ++i) + { + RARRAY(result)->ptr[i] = createString(*q); + } + RARRAY(result)->len = static_cast<long>(ids.size()); + + return result; } ICE_RUBY_CATCH return Qnil; @@ -333,22 +333,22 @@ IceRuby_ObjectPrx_ice_id(int argc, VALUE* argv, VALUE self) { ICE_RUBY_TRY { - Ice::ObjectPrx p = getProxy(self); + Ice::ObjectPrx p = getProxy(self); - Ice::Context ctx; - bool haveContext = checkArgs("ice_id", 0, argc, argv, ctx); + Ice::Context ctx; + bool haveContext = checkArgs("ice_id", 0, argc, argv, ctx); - string id; - if(haveContext) - { - id = p->ice_id(ctx); - } - else - { - id = p->ice_id(); - } + string id; + if(haveContext) + { + id = p->ice_id(ctx); + } + else + { + id = p->ice_id(); + } - return createString(id); + return createString(id); } ICE_RUBY_CATCH return Qnil; @@ -360,8 +360,8 @@ IceRuby_ObjectPrx_ice_getIdentity(VALUE self) { ICE_RUBY_TRY { - Ice::ObjectPrx p = getProxy(self); - return createIdentity(p->ice_getIdentity()); + Ice::ObjectPrx p = getProxy(self); + return createIdentity(p->ice_getIdentity()); } ICE_RUBY_CATCH return Qnil; @@ -373,9 +373,9 @@ IceRuby_ObjectPrx_ice_identity(VALUE self, VALUE id) { ICE_RUBY_TRY { - Ice::ObjectPrx p = getProxy(self); - Ice::Identity ident = getIdentity(id); - return createProxy(p->ice_identity(ident)); + Ice::ObjectPrx p = getProxy(self); + Ice::Identity ident = getIdentity(id); + return createProxy(p->ice_identity(ident)); } ICE_RUBY_CATCH return Qnil; @@ -387,8 +387,8 @@ IceRuby_ObjectPrx_ice_getContext(VALUE self) { ICE_RUBY_TRY { - Ice::ObjectPrx p = getProxy(self); - return contextToHash(p->ice_getContext()); + Ice::ObjectPrx p = getProxy(self); + return contextToHash(p->ice_getContext()); } ICE_RUBY_CATCH return Qnil; @@ -400,14 +400,14 @@ IceRuby_ObjectPrx_ice_context(VALUE self, VALUE ctx) { ICE_RUBY_TRY { - Ice::ObjectPrx p = getProxy(self); + Ice::ObjectPrx p = getProxy(self); - Ice::Context context; - if(!NIL_P(ctx) && !hashToContext(ctx, context)) - { - throw RubyException(rb_eTypeError, "argument is not a context hash"); - } - return createProxy(p->ice_context(context)); + Ice::Context context; + if(!NIL_P(ctx) && !hashToContext(ctx, context)) + { + throw RubyException(rb_eTypeError, "argument is not a context hash"); + } + return createProxy(p->ice_context(context)); } ICE_RUBY_CATCH return Qnil; @@ -419,8 +419,8 @@ IceRuby_ObjectPrx_ice_defaultContext(VALUE self) { ICE_RUBY_TRY { - Ice::ObjectPrx p = getProxy(self); - return createProxy(p->ice_defaultContext()); + Ice::ObjectPrx p = getProxy(self); + return createProxy(p->ice_defaultContext()); } ICE_RUBY_CATCH return Qnil; @@ -432,9 +432,9 @@ IceRuby_ObjectPrx_ice_getFacet(VALUE self) { ICE_RUBY_TRY { - Ice::ObjectPrx p = getProxy(self); - string facet = p->ice_getFacet(); - return createString(facet); + Ice::ObjectPrx p = getProxy(self); + string facet = p->ice_getFacet(); + return createString(facet); } ICE_RUBY_CATCH return Qnil; @@ -446,9 +446,9 @@ IceRuby_ObjectPrx_ice_facet(VALUE self, VALUE facet) { ICE_RUBY_TRY { - Ice::ObjectPrx p = getProxy(self); - string f = getString(facet); - return createProxy(p->ice_facet(f)); + Ice::ObjectPrx p = getProxy(self); + string f = getString(facet); + return createProxy(p->ice_facet(f)); } ICE_RUBY_CATCH return Qnil; @@ -460,9 +460,9 @@ IceRuby_ObjectPrx_ice_getAdapterId(VALUE self) { ICE_RUBY_TRY { - Ice::ObjectPrx p = getProxy(self); - string id = p->ice_getAdapterId(); - return createString(id); + Ice::ObjectPrx p = getProxy(self); + string id = p->ice_getAdapterId(); + return createString(id); } ICE_RUBY_CATCH return Qnil; @@ -474,9 +474,9 @@ IceRuby_ObjectPrx_ice_adapterId(VALUE self, VALUE id) { ICE_RUBY_TRY { - Ice::ObjectPrx p = getProxy(self); - string idstr = getString(id); - return createProxy(p->ice_adapterId(idstr)); + Ice::ObjectPrx p = getProxy(self); + string idstr = getString(id); + return createProxy(p->ice_adapterId(idstr)); } ICE_RUBY_CATCH return Qnil; @@ -488,17 +488,17 @@ IceRuby_ObjectPrx_ice_getEndpoints(VALUE self) { ICE_RUBY_TRY { - Ice::ObjectPrx p = getProxy(self); + Ice::ObjectPrx p = getProxy(self); - Ice::EndpointSeq seq = p->ice_getEndpoints(); - volatile VALUE result = createArray(seq.size()); - Ice::EndpointSeq::size_type i = 0; - for(Ice::EndpointSeq::iterator q = seq.begin(); q != seq.end(); ++q, ++i) - { - RARRAY(result)->ptr[i] = createEndpoint(seq[i]); - } - RARRAY(result)->len = static_cast<long>(seq.size()); - return result; + Ice::EndpointSeq seq = p->ice_getEndpoints(); + volatile VALUE result = createArray(seq.size()); + Ice::EndpointSeq::size_type i = 0; + for(Ice::EndpointSeq::iterator q = seq.begin(); q != seq.end(); ++q, ++i) + { + RARRAY(result)->ptr[i] = createEndpoint(seq[i]); + } + RARRAY(result)->len = static_cast<long>(seq.size()); + return result; } ICE_RUBY_CATCH return Qnil; @@ -510,33 +510,33 @@ IceRuby_ObjectPrx_ice_endpoints(VALUE self, VALUE seq) { ICE_RUBY_TRY { - Ice::ObjectPrx p = getProxy(self); - - if(!NIL_P(seq) && !isArray(seq)) - { - throw RubyException(rb_eTypeError, "ice_endpoints requires an array of endpoints"); - } - - Ice::EndpointSeq endpoints; - if(!NIL_P(seq)) - { - volatile VALUE arr = callRuby(rb_check_array_type, seq); - if(NIL_P(seq)) - { - throw RubyException(rb_eTypeError, "unable to convert value to an array of endpoints"); - } - for(long i = 0; i < RARRAY(arr)->len; ++i) - { - if(callRuby(rb_obj_is_instance_of, RARRAY(arr)->ptr[i], _endpointClass) == Qfalse) - { - throw RubyException(rb_eTypeError, "array element is not an Ice::Endpoint"); - } - Ice::EndpointPtr* e = reinterpret_cast<Ice::EndpointPtr*>(DATA_PTR(RARRAY(arr)->ptr[i])); - assert(e); - endpoints.push_back(*e); - } - } - return createProxy(p->ice_endpoints(endpoints)); + Ice::ObjectPrx p = getProxy(self); + + if(!NIL_P(seq) && !isArray(seq)) + { + throw RubyException(rb_eTypeError, "ice_endpoints requires an array of endpoints"); + } + + Ice::EndpointSeq endpoints; + if(!NIL_P(seq)) + { + volatile VALUE arr = callRuby(rb_check_array_type, seq); + if(NIL_P(seq)) + { + throw RubyException(rb_eTypeError, "unable to convert value to an array of endpoints"); + } + for(long i = 0; i < RARRAY(arr)->len; ++i) + { + if(callRuby(rb_obj_is_instance_of, RARRAY(arr)->ptr[i], _endpointClass) == Qfalse) + { + throw RubyException(rb_eTypeError, "array element is not an Ice::Endpoint"); + } + Ice::EndpointPtr* e = reinterpret_cast<Ice::EndpointPtr*>(DATA_PTR(RARRAY(arr)->ptr[i])); + assert(e); + endpoints.push_back(*e); + } + } + return createProxy(p->ice_endpoints(endpoints)); } ICE_RUBY_CATCH return Qnil; @@ -548,9 +548,9 @@ IceRuby_ObjectPrx_ice_getLocatorCacheTimeout(VALUE self) { ICE_RUBY_TRY { - Ice::ObjectPrx p = getProxy(self); - Ice::Int t = p->ice_getLocatorCacheTimeout(); - return INT2FIX(t); + Ice::ObjectPrx p = getProxy(self); + Ice::Int t = p->ice_getLocatorCacheTimeout(); + return INT2FIX(t); } ICE_RUBY_CATCH return Qnil; @@ -562,9 +562,9 @@ IceRuby_ObjectPrx_ice_locatorCacheTimeout(VALUE self, VALUE timeout) { ICE_RUBY_TRY { - Ice::ObjectPrx p = getProxy(self); - long t = getInteger(timeout); - return createProxy(p->ice_locatorCacheTimeout(static_cast<Ice::Int>(t))); + Ice::ObjectPrx p = getProxy(self); + long t = getInteger(timeout); + return createProxy(p->ice_locatorCacheTimeout(static_cast<Ice::Int>(t))); } ICE_RUBY_CATCH return Qnil; @@ -576,8 +576,8 @@ IceRuby_ObjectPrx_ice_isConnectionCached(VALUE self) { ICE_RUBY_TRY { - Ice::ObjectPrx p = getProxy(self); - return p->ice_isConnectionCached() ? Qtrue : Qfalse; + Ice::ObjectPrx p = getProxy(self); + return p->ice_isConnectionCached() ? Qtrue : Qfalse; } ICE_RUBY_CATCH return Qnil; @@ -589,8 +589,8 @@ IceRuby_ObjectPrx_ice_connectionCached(VALUE self, VALUE b) { ICE_RUBY_TRY { - Ice::ObjectPrx p = getProxy(self); - return createProxy(p->ice_connectionCached(RTEST(b))); + Ice::ObjectPrx p = getProxy(self); + return createProxy(p->ice_connectionCached(RTEST(b))); } ICE_RUBY_CATCH return Qnil; @@ -602,22 +602,22 @@ IceRuby_ObjectPrx_ice_getEndpointSelection(VALUE self) { ICE_RUBY_TRY { - Ice::ObjectPrx p = getProxy(self); - - Ice::EndpointSelectionType type = p->ice_getEndpointSelection(); - volatile VALUE cls = callRuby(rb_path2class, "Ice::EndpointSelectionType"); - assert(!NIL_P(cls)); - ID name = 0; - switch(type) - { - case Ice::Random: - name = rb_intern("Random"); - break; - case Ice::Ordered: - name = rb_intern("Ordered"); - break; - } - return callRuby(rb_funcall, cls, name, 0); + Ice::ObjectPrx p = getProxy(self); + + Ice::EndpointSelectionType type = p->ice_getEndpointSelection(); + volatile VALUE cls = callRuby(rb_path2class, "Ice::EndpointSelectionType"); + assert(!NIL_P(cls)); + ID name = 0; + switch(type) + { + case Ice::Random: + name = rb_intern("Random"); + break; + case Ice::Ordered: + name = rb_intern("Ordered"); + break; + } + return callRuby(rb_funcall, cls, name, 0); } ICE_RUBY_CATCH return Qnil; @@ -629,18 +629,18 @@ IceRuby_ObjectPrx_ice_endpointSelection(VALUE self, VALUE type) { ICE_RUBY_TRY { - Ice::ObjectPrx p = getProxy(self); + Ice::ObjectPrx p = getProxy(self); - volatile VALUE cls = callRuby(rb_path2class, "Ice::EndpointSelectionType"); - assert(!NIL_P(cls)); - if(callRuby(rb_obj_is_instance_of, type, cls) == Qfalse) - { - throw RubyException(rb_eTypeError, "argument must be an Ice::EndpointSelectionType enumerator"); - } + volatile VALUE cls = callRuby(rb_path2class, "Ice::EndpointSelectionType"); + assert(!NIL_P(cls)); + if(callRuby(rb_obj_is_instance_of, type, cls) == Qfalse) + { + throw RubyException(rb_eTypeError, "argument must be an Ice::EndpointSelectionType enumerator"); + } - volatile VALUE val = callRuby(rb_funcall, type, rb_intern("to_i"), 0); - Ice::EndpointSelectionType t = static_cast<Ice::EndpointSelectionType>(getInteger(val)); - return createProxy(p->ice_endpointSelection(t)); + volatile VALUE val = callRuby(rb_funcall, type, rb_intern("to_i"), 0); + Ice::EndpointSelectionType t = static_cast<Ice::EndpointSelectionType>(getInteger(val)); + return createProxy(p->ice_endpointSelection(t)); } ICE_RUBY_CATCH return Qnil; @@ -652,8 +652,8 @@ IceRuby_ObjectPrx_ice_isSecure(VALUE self) { ICE_RUBY_TRY { - Ice::ObjectPrx p = getProxy(self); - return p->ice_isSecure() ? Qtrue : Qfalse; + Ice::ObjectPrx p = getProxy(self); + return p->ice_isSecure() ? Qtrue : Qfalse; } ICE_RUBY_CATCH return Qnil; @@ -665,8 +665,8 @@ IceRuby_ObjectPrx_ice_secure(VALUE self, VALUE b) { ICE_RUBY_TRY { - Ice::ObjectPrx p = getProxy(self); - return createProxy(p->ice_secure(RTEST(b))); + Ice::ObjectPrx p = getProxy(self); + return createProxy(p->ice_secure(RTEST(b))); } ICE_RUBY_CATCH return Qnil; @@ -704,15 +704,15 @@ IceRuby_ObjectPrx_ice_getRouter(VALUE self) { ICE_RUBY_TRY { - Ice::ObjectPrx p = getProxy(self); + Ice::ObjectPrx p = getProxy(self); - Ice::RouterPrx router = p->ice_getRouter(); - if(router) - { - volatile VALUE cls = callRuby(rb_path2class, "Ice::RouterPrx"); - assert(!NIL_P(cls)); - return createProxy(router, cls); - } + Ice::RouterPrx router = p->ice_getRouter(); + if(router) + { + volatile VALUE cls = callRuby(rb_path2class, "Ice::RouterPrx"); + assert(!NIL_P(cls)); + return createProxy(router, cls); + } } ICE_RUBY_CATCH return Qnil; @@ -724,18 +724,18 @@ IceRuby_ObjectPrx_ice_router(VALUE self, VALUE router) { ICE_RUBY_TRY { - Ice::ObjectPrx p = getProxy(self); + Ice::ObjectPrx p = getProxy(self); - Ice::RouterPrx proxy; - if(!NIL_P(router)) - { - if(!checkProxy(router)) - { - throw RubyException(rb_eTypeError, "argument must be a proxy"); - } - proxy = Ice::RouterPrx::uncheckedCast(getProxy(router)); - } - return createProxy(p->ice_router(proxy)); + Ice::RouterPrx proxy; + if(!NIL_P(router)) + { + if(!checkProxy(router)) + { + throw RubyException(rb_eTypeError, "argument must be a proxy"); + } + proxy = Ice::RouterPrx::uncheckedCast(getProxy(router)); + } + return createProxy(p->ice_router(proxy)); } ICE_RUBY_CATCH return Qnil; @@ -747,15 +747,15 @@ IceRuby_ObjectPrx_ice_getLocator(VALUE self) { ICE_RUBY_TRY { - Ice::ObjectPrx p = getProxy(self); + Ice::ObjectPrx p = getProxy(self); - Ice::LocatorPrx locator = p->ice_getLocator(); - if(locator) - { - volatile VALUE cls = callRuby(rb_path2class, "Ice::LocatorPrx"); - assert(!NIL_P(cls)); - return createProxy(locator, cls); - } + Ice::LocatorPrx locator = p->ice_getLocator(); + if(locator) + { + volatile VALUE cls = callRuby(rb_path2class, "Ice::LocatorPrx"); + assert(!NIL_P(cls)); + return createProxy(locator, cls); + } } ICE_RUBY_CATCH return Qnil; @@ -767,18 +767,18 @@ IceRuby_ObjectPrx_ice_locator(VALUE self, VALUE locator) { ICE_RUBY_TRY { - Ice::ObjectPrx p = getProxy(self); + Ice::ObjectPrx p = getProxy(self); - Ice::LocatorPrx proxy; - if(!NIL_P(locator)) - { - if(!checkProxy(locator)) - { - throw RubyException(rb_eTypeError, "argument must be a proxy"); - } - proxy = Ice::LocatorPrx::uncheckedCast(getProxy(locator)); - } - return createProxy(p->ice_locator(proxy)); + Ice::LocatorPrx proxy; + if(!NIL_P(locator)) + { + if(!checkProxy(locator)) + { + throw RubyException(rb_eTypeError, "argument must be a proxy"); + } + proxy = Ice::LocatorPrx::uncheckedCast(getProxy(locator)); + } + return createProxy(p->ice_locator(proxy)); } ICE_RUBY_CATCH return Qnil; @@ -790,8 +790,8 @@ IceRuby_ObjectPrx_ice_twoway(VALUE self) { ICE_RUBY_TRY { - Ice::ObjectPrx p = getProxy(self); - return createProxy(p->ice_twoway()); + Ice::ObjectPrx p = getProxy(self); + return createProxy(p->ice_twoway()); } ICE_RUBY_CATCH return Qnil; @@ -803,8 +803,8 @@ IceRuby_ObjectPrx_ice_isTwoway(VALUE self) { ICE_RUBY_TRY { - Ice::ObjectPrx p = getProxy(self); - return p->ice_isTwoway() ? Qtrue : Qfalse; + Ice::ObjectPrx p = getProxy(self); + return p->ice_isTwoway() ? Qtrue : Qfalse; } ICE_RUBY_CATCH return Qnil; @@ -816,8 +816,8 @@ IceRuby_ObjectPrx_ice_oneway(VALUE self) { ICE_RUBY_TRY { - Ice::ObjectPrx p = getProxy(self); - return createProxy(p->ice_oneway()); + Ice::ObjectPrx p = getProxy(self); + return createProxy(p->ice_oneway()); } ICE_RUBY_CATCH return Qnil; @@ -829,8 +829,8 @@ IceRuby_ObjectPrx_ice_isOneway(VALUE self) { ICE_RUBY_TRY { - Ice::ObjectPrx p = getProxy(self); - return p->ice_isOneway() ? Qtrue : Qfalse; + Ice::ObjectPrx p = getProxy(self); + return p->ice_isOneway() ? Qtrue : Qfalse; } ICE_RUBY_CATCH return Qnil; @@ -842,8 +842,8 @@ IceRuby_ObjectPrx_ice_batchOneway(VALUE self) { ICE_RUBY_TRY { - Ice::ObjectPrx p = getProxy(self); - return createProxy(p->ice_batchOneway()); + Ice::ObjectPrx p = getProxy(self); + return createProxy(p->ice_batchOneway()); } ICE_RUBY_CATCH return Qnil; @@ -855,8 +855,8 @@ IceRuby_ObjectPrx_ice_isBatchOneway(VALUE self) { ICE_RUBY_TRY { - Ice::ObjectPrx p = getProxy(self); - return p->ice_isBatchOneway() ? Qtrue : Qfalse; + Ice::ObjectPrx p = getProxy(self); + return p->ice_isBatchOneway() ? Qtrue : Qfalse; } ICE_RUBY_CATCH return Qnil; @@ -868,8 +868,8 @@ IceRuby_ObjectPrx_ice_datagram(VALUE self) { ICE_RUBY_TRY { - Ice::ObjectPrx p = getProxy(self); - return createProxy(p->ice_datagram()); + Ice::ObjectPrx p = getProxy(self); + return createProxy(p->ice_datagram()); } ICE_RUBY_CATCH return Qnil; @@ -881,8 +881,8 @@ IceRuby_ObjectPrx_ice_isDatagram(VALUE self) { ICE_RUBY_TRY { - Ice::ObjectPrx p = getProxy(self); - return p->ice_isDatagram() ? Qtrue : Qfalse; + Ice::ObjectPrx p = getProxy(self); + return p->ice_isDatagram() ? Qtrue : Qfalse; } ICE_RUBY_CATCH return Qnil; @@ -894,8 +894,8 @@ IceRuby_ObjectPrx_ice_batchDatagram(VALUE self) { ICE_RUBY_TRY { - Ice::ObjectPrx p = getProxy(self); - return createProxy(p->ice_batchDatagram()); + Ice::ObjectPrx p = getProxy(self); + return createProxy(p->ice_batchDatagram()); } ICE_RUBY_CATCH return Qnil; @@ -907,8 +907,8 @@ IceRuby_ObjectPrx_ice_isBatchDatagram(VALUE self) { ICE_RUBY_TRY { - Ice::ObjectPrx p = getProxy(self); - return p->ice_isBatchDatagram() ? Qtrue : Qfalse; + Ice::ObjectPrx p = getProxy(self); + return p->ice_isBatchDatagram() ? Qtrue : Qfalse; } ICE_RUBY_CATCH return Qnil; @@ -920,8 +920,8 @@ IceRuby_ObjectPrx_ice_compress(VALUE self, VALUE b) { ICE_RUBY_TRY { - Ice::ObjectPrx p = getProxy(self); - return createProxy(p->ice_compress(RTEST(b))); + Ice::ObjectPrx p = getProxy(self); + return createProxy(p->ice_compress(RTEST(b))); } ICE_RUBY_CATCH return Qnil; @@ -933,9 +933,9 @@ IceRuby_ObjectPrx_ice_timeout(VALUE self, VALUE t) { ICE_RUBY_TRY { - Ice::ObjectPrx p = getProxy(self); - Ice::Int timeout = static_cast<Ice::Int>(getInteger(t)); - return createProxy(p->ice_timeout(timeout)); + Ice::ObjectPrx p = getProxy(self); + Ice::Int timeout = static_cast<Ice::Int>(getInteger(t)); + return createProxy(p->ice_timeout(timeout)); } ICE_RUBY_CATCH return Qnil; @@ -947,9 +947,9 @@ IceRuby_ObjectPrx_ice_connectionId(VALUE self, VALUE id) { ICE_RUBY_TRY { - Ice::ObjectPrx p = getProxy(self); - string idstr = getString(id); - return createProxy(p->ice_connectionId(idstr)); + Ice::ObjectPrx p = getProxy(self); + string idstr = getString(id); + return createProxy(p->ice_connectionId(idstr)); } ICE_RUBY_CATCH return Qnil; @@ -987,9 +987,9 @@ IceRuby_ObjectPrx_ice_getConnection(VALUE self) { ICE_RUBY_TRY { - Ice::ObjectPrx p = getProxy(self); - Ice::ConnectionPtr conn = p->ice_getConnection(); - return createConnection(conn); + Ice::ObjectPrx p = getProxy(self); + Ice::ConnectionPtr conn = p->ice_getConnection(); + return createConnection(conn); } ICE_RUBY_CATCH return Qnil; @@ -1001,12 +1001,12 @@ IceRuby_ObjectPrx_ice_getCachedConnection(VALUE self) { ICE_RUBY_TRY { - Ice::ObjectPrx p = getProxy(self); - Ice::ConnectionPtr conn = p->ice_getCachedConnection(); - if(!conn) - { - return createConnection(conn); - } + Ice::ObjectPrx p = getProxy(self); + Ice::ConnectionPtr conn = p->ice_getCachedConnection(); + if(!conn) + { + return createConnection(conn); + } } ICE_RUBY_CATCH return Qnil; @@ -1018,17 +1018,17 @@ IceRuby_ObjectPrx_equals(VALUE self, VALUE other) { ICE_RUBY_TRY { - if(NIL_P(other)) - { - return Qfalse; - } - if(!checkProxy(other)) - { - throw RubyException(rb_eTypeError, "argument must be a proxy"); - } - Ice::ObjectPrx p1 = getProxy(self); - Ice::ObjectPrx p2 = getProxy(other); - return p1 == p2 ? Qtrue : Qfalse; + if(NIL_P(other)) + { + return Qfalse; + } + if(!checkProxy(other)) + { + throw RubyException(rb_eTypeError, "argument must be a proxy"); + } + Ice::ObjectPrx p1 = getProxy(self); + Ice::ObjectPrx p2 = getProxy(other); + return p1 == p2 ? Qtrue : Qfalse; } ICE_RUBY_CATCH return Qnil; @@ -1056,9 +1056,9 @@ checkedCastImpl(const Ice::ObjectPrx& p, const string& id, const string& facet, { if(target->ice_isA(id)) - { - return createProxy(target, type); - } + { + return createProxy(target, type); + } } return Qnil; @@ -1079,9 +1079,9 @@ checkedCastImpl(const Ice::ObjectPrx& p, const string& id, const string& facet, { if(target->ice_isA(id, ctx)) - { - return createProxy(target, type); - } + { + return createProxy(target, type); + } } return Qnil; @@ -1097,71 +1097,71 @@ IceRuby_ObjectPrx_checkedCast(int argc, VALUE* args, VALUE self) // ICE_RUBY_TRY { - if(argc < 1 || argc > 3) - { - throw RubyException(rb_eArgError, "checkedCast requires a proxy argument and optional facet and context"); - } - - if(NIL_P(args[0])) - { - return Qnil; - } - - if(!checkProxy(args[0])) - { - throw RubyException(rb_eArgError, "checkedCast requires a proxy argument"); - } - - Ice::ObjectPrx p = getProxy(args[0]); - - string facet; - volatile VALUE ctx = Qnil; - - if(argc == 3) - { - if(!NIL_P(args[1]) && !isString(args[1])) - { - throw RubyException(rb_eArgError, "facet argument to checkedCast must be a string"); - } - facet = getString(args[1]); - - if(!NIL_P(args[2]) && !isHash(args[2])) - { - throw RubyException(rb_eArgError, "context argument to checkedCast must be a hash"); - } - ctx = args[2]; - } - else if(argc == 2) - { - if(isString(args[1])) - { - facet = getString(args[1]); - } - else if(isHash(args[1])) - { - ctx = args[1]; - } - else - { - throw RubyException(rb_eArgError, "second argument to checkedCast must be a facet or context"); - } - } - - if(NIL_P(ctx)) - { - return checkedCastImpl(p, "::Ice::Object", facet, Qnil); - } - else - { - Ice::Context c; + if(argc < 1 || argc > 3) + { + throw RubyException(rb_eArgError, "checkedCast requires a proxy argument and optional facet and context"); + } + + if(NIL_P(args[0])) + { + return Qnil; + } + + if(!checkProxy(args[0])) + { + throw RubyException(rb_eArgError, "checkedCast requires a proxy argument"); + } + + Ice::ObjectPrx p = getProxy(args[0]); + + string facet; + volatile VALUE ctx = Qnil; + + if(argc == 3) + { + if(!NIL_P(args[1]) && !isString(args[1])) + { + throw RubyException(rb_eArgError, "facet argument to checkedCast must be a string"); + } + facet = getString(args[1]); + + if(!NIL_P(args[2]) && !isHash(args[2])) + { + throw RubyException(rb_eArgError, "context argument to checkedCast must be a hash"); + } + ctx = args[2]; + } + else if(argc == 2) + { + if(isString(args[1])) + { + facet = getString(args[1]); + } + else if(isHash(args[1])) + { + ctx = args[1]; + } + else + { + throw RubyException(rb_eArgError, "second argument to checkedCast must be a facet or context"); + } + } + + if(NIL_P(ctx)) + { + return checkedCastImpl(p, "::Ice::Object", facet, Qnil); + } + else + { + Ice::Context c; #ifndef NDEBUG - bool b = + bool b = #endif - hashToContext(ctx, c); - assert(b); + hashToContext(ctx, c); + assert(b); - return checkedCastImpl(p, "::Ice::Object", facet, c, Qnil); - } + return checkedCastImpl(p, "::Ice::Object", facet, c, Qnil); + } } ICE_RUBY_CATCH return Qnil; @@ -1173,37 +1173,37 @@ IceRuby_ObjectPrx_uncheckedCast(int argc, VALUE* args, VALUE self) { ICE_RUBY_TRY { - if(argc < 1 || argc > 2) - { - throw RubyException(rb_eArgError, "uncheckedCast requires a proxy argument and an optional facet"); - } - - if(NIL_P(args[0])) - { - return Qnil; - } - - if(!checkProxy(args[0])) - { - throw RubyException(rb_eArgError, "uncheckedCast requires a proxy argument"); - } - - string facet; - if(argc == 2) - { - facet = getString(args[1]); - } - - Ice::ObjectPrx p = getProxy(args[0]); - - if(!facet.empty()) - { - return createProxy(p->ice_facet(facet)); - } - else - { - return createProxy(p); - } + if(argc < 1 || argc > 2) + { + throw RubyException(rb_eArgError, "uncheckedCast requires a proxy argument and an optional facet"); + } + + if(NIL_P(args[0])) + { + return Qnil; + } + + if(!checkProxy(args[0])) + { + throw RubyException(rb_eArgError, "uncheckedCast requires a proxy argument"); + } + + string facet; + if(argc == 2) + { + facet = getString(args[1]); + } + + Ice::ObjectPrx p = getProxy(args[0]); + + if(!facet.empty()) + { + return createProxy(p->ice_facet(facet)); + } + else + { + return createProxy(p); + } } ICE_RUBY_CATCH return Qnil; @@ -1219,58 +1219,58 @@ IceRuby_ObjectPrx_ice_checkedCast(VALUE self, VALUE obj, VALUE id, VALUE facetOr // ICE_RUBY_TRY { - if(NIL_P(obj)) - { - return Qnil; - } - - if(!checkProxy(obj)) - { - throw RubyException(rb_eArgError, "checkedCast requires a proxy argument"); - } - - Ice::ObjectPrx p = getProxy(obj); - - string idstr = getString(id); - - string facet; - if(isString(facetOrCtx)) - { - facet = getString(facetOrCtx); - } - else if(isHash(facetOrCtx)) - { - if(!NIL_P(ctx)) - { - throw RubyException(rb_eArgError, "facet argument to checkedCast must be a string"); - } - ctx = facetOrCtx; - } - else if(!NIL_P(facetOrCtx)) - { - throw RubyException(rb_eArgError, "second argument to checkedCast must be a facet or context"); - } - - if(!NIL_P(ctx) && !isHash(ctx)) - { - throw RubyException(rb_eArgError, "context argument to checkedCast must be a hash"); - } - - if(NIL_P(ctx)) - { - return checkedCastImpl(p, idstr, facet, self); - } - else - { - Ice::Context c; + if(NIL_P(obj)) + { + return Qnil; + } + + if(!checkProxy(obj)) + { + throw RubyException(rb_eArgError, "checkedCast requires a proxy argument"); + } + + Ice::ObjectPrx p = getProxy(obj); + + string idstr = getString(id); + + string facet; + if(isString(facetOrCtx)) + { + facet = getString(facetOrCtx); + } + else if(isHash(facetOrCtx)) + { + if(!NIL_P(ctx)) + { + throw RubyException(rb_eArgError, "facet argument to checkedCast must be a string"); + } + ctx = facetOrCtx; + } + else if(!NIL_P(facetOrCtx)) + { + throw RubyException(rb_eArgError, "second argument to checkedCast must be a facet or context"); + } + + if(!NIL_P(ctx) && !isHash(ctx)) + { + throw RubyException(rb_eArgError, "context argument to checkedCast must be a hash"); + } + + if(NIL_P(ctx)) + { + return checkedCastImpl(p, idstr, facet, self); + } + else + { + Ice::Context c; #ifndef NDEBUG - bool b = + bool b = #endif - hashToContext(ctx, c); - assert(b); + hashToContext(ctx, c); + assert(b); - return checkedCastImpl(p, idstr, facet, c, self); - } + return checkedCastImpl(p, idstr, facet, c, self); + } } ICE_RUBY_CATCH return Qnil; @@ -1282,28 +1282,28 @@ IceRuby_ObjectPrx_ice_uncheckedCast(VALUE self, VALUE obj, VALUE facet) { ICE_RUBY_TRY { - if(NIL_P(obj)) - { - return Qnil; - } + if(NIL_P(obj)) + { + return Qnil; + } - if(!checkProxy(obj)) - { - throw RubyException(rb_eArgError, "uncheckedCast requires a proxy argument"); - } + if(!checkProxy(obj)) + { + throw RubyException(rb_eArgError, "uncheckedCast requires a proxy argument"); + } - Ice::ObjectPrx p = getProxy(obj); + Ice::ObjectPrx p = getProxy(obj); - string f = getString(facet); + string f = getString(facet); - if(!f.empty()) - { - return createProxy(p->ice_facet(f), self); - } - else - { - return createProxy(p, self); - } + if(!f.empty()) + { + return createProxy(p->ice_facet(f), self); + } + else + { + return createProxy(p, self); + } } ICE_RUBY_CATCH return Qnil; @@ -1315,7 +1315,7 @@ IceRuby_ObjectPrx_new(int /*argc*/, VALUE* /*args*/, VALUE self) { ICE_RUBY_TRY { - throw RubyException(rb_eRuntimeError, "a proxy cannot be created via new"); + throw RubyException(rb_eRuntimeError, "a proxy cannot be created via new"); } ICE_RUBY_CATCH return Qnil; @@ -1379,12 +1379,12 @@ IceRuby::initProxy(VALUE iceModule) rb_define_method(_proxyClass, "ice_getEndpoints", CAST_METHOD(IceRuby_ObjectPrx_ice_getEndpoints), 0); rb_define_method(_proxyClass, "ice_endpoints", CAST_METHOD(IceRuby_ObjectPrx_ice_endpoints), 1); rb_define_method(_proxyClass, "ice_getLocatorCacheTimeout", - CAST_METHOD(IceRuby_ObjectPrx_ice_getLocatorCacheTimeout), 0); + CAST_METHOD(IceRuby_ObjectPrx_ice_getLocatorCacheTimeout), 0); rb_define_method(_proxyClass, "ice_locatorCacheTimeout", CAST_METHOD(IceRuby_ObjectPrx_ice_locatorCacheTimeout), 1); rb_define_method(_proxyClass, "ice_isConnectionCached", CAST_METHOD(IceRuby_ObjectPrx_ice_isConnectionCached), 0); rb_define_method(_proxyClass, "ice_connectionCached", CAST_METHOD(IceRuby_ObjectPrx_ice_connectionCached), 1); rb_define_method(_proxyClass, "ice_getEndpointSelection", - CAST_METHOD(IceRuby_ObjectPrx_ice_getEndpointSelection), 0); + CAST_METHOD(IceRuby_ObjectPrx_ice_getEndpointSelection), 0); rb_define_method(_proxyClass, "ice_endpointSelection", CAST_METHOD(IceRuby_ObjectPrx_ice_endpointSelection), 1); rb_define_method(_proxyClass, "ice_isSecure", CAST_METHOD(IceRuby_ObjectPrx_ice_isSecure), 0); rb_define_method(_proxyClass, "ice_secure", CAST_METHOD(IceRuby_ObjectPrx_ice_secure), 1); @@ -1438,11 +1438,11 @@ IceRuby::createProxy(const Ice::ObjectPrx& p, VALUE cls) // if(NIL_P(cls)) { - return Data_Wrap_Struct(_proxyClass, IceRuby_ObjectPrx_mark, IceRuby_ObjectPrx_free, new Ice::ObjectPrx(p)); + return Data_Wrap_Struct(_proxyClass, IceRuby_ObjectPrx_mark, IceRuby_ObjectPrx_free, new Ice::ObjectPrx(p)); } else { - return Data_Wrap_Struct(cls, IceRuby_ObjectPrx_mark, IceRuby_ObjectPrx_free, new Ice::ObjectPrx(p)); + return Data_Wrap_Struct(cls, IceRuby_ObjectPrx_mark, IceRuby_ObjectPrx_free, new Ice::ObjectPrx(p)); } } diff --git a/rb/src/IceRuby/Slice.cpp b/rb/src/IceRuby/Slice.cpp index 0e1bf9bf1e9..c1a49029454 100644 --- a/rb/src/IceRuby/Slice.cpp +++ b/rb/src/IceRuby/Slice.cpp @@ -24,133 +24,133 @@ IceRuby_loadSlice(int argc, VALUE* argv, VALUE self) { ICE_RUBY_TRY { - if(argc < 1 || argc > 2) - { - throw RubyException(rb_eArgError, "wrong number of arguments"); - } - - string cmd = getString(argv[0]); - vector<string> argSeq; - try - { - argSeq = IceUtil::Options::split(cmd); - } - catch(const IceUtil::BadOptException& ex) - { - throw RubyException(rb_eArgError, "error in Slice options: %s", ex.reason.c_str()); - } - catch(const IceUtil::APIException& ex) - { - throw RubyException(rb_eArgError, "error in Slice options: %s", ex.reason.c_str()); - } - - if(argc > 1) - { - if(!arrayToStringSeq(argv[1], argSeq)) - { - throw RubyException(rb_eTypeError, "argument 2 is not an array"); - } - } - - IceUtil::Options opts; - opts.addOpt("D", "", IceUtil::Options::NeedArg, "", IceUtil::Options::Repeat); - opts.addOpt("U", "", IceUtil::Options::NeedArg, "", IceUtil::Options::Repeat); - opts.addOpt("I", "", IceUtil::Options::NeedArg, "", IceUtil::Options::Repeat); - opts.addOpt("d", "debug"); - opts.addOpt("", "ice"); - opts.addOpt("", "checksum"); - opts.addOpt("", "all"); - opts.addOpt("", "case-sensitive"); - - vector<string> files; - try - { - argSeq.insert(argSeq.begin(), ""); // dummy argv[0] - files = opts.parse(argSeq); - if(files.empty()) - { - throw RubyException(rb_eArgError, "no Slice files specified in `%s'", cmd.c_str()); - } - } - catch(const IceUtil::BadOptException& ex) - { - throw RubyException(rb_eArgError, "error in Slice options: %s", ex.reason.c_str()); - } - catch(const IceUtil::APIException& ex) - { - throw RubyException(rb_eArgError, "error in Slice options: %s", ex.reason.c_str()); - } - - string cppArgs; - vector<string> includePaths; - bool debug = false; - bool ice = true; // This must be true so that we can create Ice::Identity when necessary. - bool caseSensitive = false; - bool all = false; - bool checksum = false; - if(opts.isSet("D")) - { - vector<string> optargs = opts.argVec("D"); - for(vector<string>::const_iterator i = optargs.begin(); i != optargs.end(); ++i) - { - cppArgs += " -D" + *i; - } - } - if(opts.isSet("U")) - { - vector<string> optargs = opts.argVec("U"); - for(vector<string>::const_iterator i = optargs.begin(); i != optargs.end(); ++i) - { - cppArgs += " -U" + *i; - } - } - if(opts.isSet("I")) - { - includePaths = opts.argVec("I"); - for(vector<string>::const_iterator i = includePaths.begin(); i != includePaths.end(); ++i) - { - cppArgs += " -I" + *i; - } - } - debug = opts.isSet("d") || opts.isSet("debug"); - caseSensitive = opts.isSet("case-sensitive"); - all = opts.isSet("all"); - checksum = opts.isSet("checksum"); - - bool ignoreRedefs = false; - - for(vector<string>::const_iterator p = files.begin(); p != files.end(); ++p) - { - string file = *p; - Slice::Preprocessor icecpp("icecpp", file, cppArgs); - FILE* cppHandle = icecpp.preprocess(false); - - if(cppHandle == 0) - { - throw RubyException(rb_eArgError, "Slice preprocessing failed for `%s'", cmd.c_str()); - } - - UnitPtr u = Slice::Unit::createUnit(ignoreRedefs, all, ice, caseSensitive); - int parseStatus = u->parse(cppHandle, debug); - - if(!icecpp.close() || parseStatus == EXIT_FAILURE) - { - u->destroy(); - throw RubyException(rb_eArgError, "Slice parsing failed for `%s'", cmd.c_str()); - } - - // - // Generate the Ruby code into a string stream. - // - ostringstream codeStream; - IceUtil::Output out(codeStream); - out.setUseTab(false); - generate(u, all, checksum, includePaths, out); - u->destroy(); - - string code = codeStream.str(); - callRuby(rb_eval_string, code.c_str()); - } + if(argc < 1 || argc > 2) + { + throw RubyException(rb_eArgError, "wrong number of arguments"); + } + + string cmd = getString(argv[0]); + vector<string> argSeq; + try + { + argSeq = IceUtil::Options::split(cmd); + } + catch(const IceUtil::BadOptException& ex) + { + throw RubyException(rb_eArgError, "error in Slice options: %s", ex.reason.c_str()); + } + catch(const IceUtil::APIException& ex) + { + throw RubyException(rb_eArgError, "error in Slice options: %s", ex.reason.c_str()); + } + + if(argc > 1) + { + if(!arrayToStringSeq(argv[1], argSeq)) + { + throw RubyException(rb_eTypeError, "argument 2 is not an array"); + } + } + + IceUtil::Options opts; + opts.addOpt("D", "", IceUtil::Options::NeedArg, "", IceUtil::Options::Repeat); + opts.addOpt("U", "", IceUtil::Options::NeedArg, "", IceUtil::Options::Repeat); + opts.addOpt("I", "", IceUtil::Options::NeedArg, "", IceUtil::Options::Repeat); + opts.addOpt("d", "debug"); + opts.addOpt("", "ice"); + opts.addOpt("", "checksum"); + opts.addOpt("", "all"); + opts.addOpt("", "case-sensitive"); + + vector<string> files; + try + { + argSeq.insert(argSeq.begin(), ""); // dummy argv[0] + files = opts.parse(argSeq); + if(files.empty()) + { + throw RubyException(rb_eArgError, "no Slice files specified in `%s'", cmd.c_str()); + } + } + catch(const IceUtil::BadOptException& ex) + { + throw RubyException(rb_eArgError, "error in Slice options: %s", ex.reason.c_str()); + } + catch(const IceUtil::APIException& ex) + { + throw RubyException(rb_eArgError, "error in Slice options: %s", ex.reason.c_str()); + } + + string cppArgs; + vector<string> includePaths; + bool debug = false; + bool ice = true; // This must be true so that we can create Ice::Identity when necessary. + bool caseSensitive = false; + bool all = false; + bool checksum = false; + if(opts.isSet("D")) + { + vector<string> optargs = opts.argVec("D"); + for(vector<string>::const_iterator i = optargs.begin(); i != optargs.end(); ++i) + { + cppArgs += " -D" + *i; + } + } + if(opts.isSet("U")) + { + vector<string> optargs = opts.argVec("U"); + for(vector<string>::const_iterator i = optargs.begin(); i != optargs.end(); ++i) + { + cppArgs += " -U" + *i; + } + } + if(opts.isSet("I")) + { + includePaths = opts.argVec("I"); + for(vector<string>::const_iterator i = includePaths.begin(); i != includePaths.end(); ++i) + { + cppArgs += " -I" + *i; + } + } + debug = opts.isSet("d") || opts.isSet("debug"); + caseSensitive = opts.isSet("case-sensitive"); + all = opts.isSet("all"); + checksum = opts.isSet("checksum"); + + bool ignoreRedefs = false; + + for(vector<string>::const_iterator p = files.begin(); p != files.end(); ++p) + { + string file = *p; + Slice::Preprocessor icecpp("icecpp", file, cppArgs); + FILE* cppHandle = icecpp.preprocess(false); + + if(cppHandle == 0) + { + throw RubyException(rb_eArgError, "Slice preprocessing failed for `%s'", cmd.c_str()); + } + + UnitPtr u = Slice::Unit::createUnit(ignoreRedefs, all, ice, caseSensitive); + int parseStatus = u->parse(cppHandle, debug); + + if(!icecpp.close() || parseStatus == EXIT_FAILURE) + { + u->destroy(); + throw RubyException(rb_eArgError, "Slice parsing failed for `%s'", cmd.c_str()); + } + + // + // Generate the Ruby code into a string stream. + // + ostringstream codeStream; + IceUtil::Output out(codeStream); + out.setUseTab(false); + generate(u, all, checksum, includePaths, out); + u->destroy(); + + string code = codeStream.str(); + callRuby(rb_eval_string, code.c_str()); + } } ICE_RUBY_CATCH diff --git a/rb/src/IceRuby/Types.cpp b/rb/src/IceRuby/Types.cpp index 024ac8af236..d01b9d46c77 100644 --- a/rb/src/IceRuby/Types.cpp +++ b/rb/src/IceRuby/Types.cpp @@ -75,7 +75,7 @@ addClassInfo(const string& id, const ClassInfoPtr& info) ClassInfoMap::iterator p = _classInfoMap.find(id); if(p != _classInfoMap.end()) { - _classInfoMap.erase(p); + _classInfoMap.erase(p); } _classInfoMap.insert(ClassInfoMap::value_type(id, info)); } @@ -95,7 +95,7 @@ addProxyInfo(const string& id, const ProxyInfoPtr& info) ProxyInfoMap::iterator p = _proxyInfoMap.find(id); if(p != _proxyInfoMap.end()) { - _proxyInfoMap.erase(p); + _proxyInfoMap.erase(p); } _proxyInfoMap.insert(ProxyInfoMap::value_type(id, info)); } @@ -109,7 +109,7 @@ lookupProxyInfo(const string& id) ProxyInfoMap::iterator p = _proxyInfoMap.find(id); if(p != _proxyInfoMap.end()) { - return p->second; + return p->second; } return 0; } @@ -177,21 +177,21 @@ IceRuby::PrimitiveInfo::getId() const switch(kind) { case KindBool: - return "bool"; + return "bool"; case KindByte: - return "byte"; + return "byte"; case KindShort: - return "short"; + return "short"; case KindInt: - return "int"; + return "int"; case KindLong: - return "long"; + return "long"; case KindFloat: - return "float"; + return "float"; case KindDouble: - return "double"; + return "double"; case KindString: - return "string"; + return "string"; } assert(false); return string(); @@ -216,128 +216,128 @@ IceRuby::PrimitiveInfo::marshal(VALUE p, const Ice::OutputStreamPtr& os, ObjectM { case PrimitiveInfo::KindBool: { - os->writeBool(RTEST(p)); - break; + os->writeBool(RTEST(p)); + break; } case PrimitiveInfo::KindByte: { - long i = getInteger(p); - if(i >= 0 && i <= 255) - { - os->writeByte(static_cast<Ice::Byte>(i)); - break; - } - throw RubyException(rb_eTypeError, "value is out of range for a byte"); + long i = getInteger(p); + if(i >= 0 && i <= 255) + { + os->writeByte(static_cast<Ice::Byte>(i)); + break; + } + throw RubyException(rb_eTypeError, "value is out of range for a byte"); } case PrimitiveInfo::KindShort: { - long i = getInteger(p); - if(i >= SHRT_MIN && i <= SHRT_MAX) - { - os->writeShort(static_cast<Ice::Short>(i)); - break; - } - throw RubyException(rb_eTypeError, "value is out of range for a short"); + long i = getInteger(p); + if(i >= SHRT_MIN && i <= SHRT_MAX) + { + os->writeShort(static_cast<Ice::Short>(i)); + break; + } + throw RubyException(rb_eTypeError, "value is out of range for a short"); } case PrimitiveInfo::KindInt: { - long i = getInteger(p); - if(i >= INT_MIN && i <= INT_MAX) - { - os->writeInt(static_cast<Ice::Int>(i)); - break; - } - throw RubyException(rb_eTypeError, "value is out of range for an int"); + long i = getInteger(p); + if(i >= INT_MIN && i <= INT_MAX) + { + os->writeInt(static_cast<Ice::Int>(i)); + break; + } + throw RubyException(rb_eTypeError, "value is out of range for an int"); } case PrimitiveInfo::KindLong: { - os->writeLong(getLong(p)); - break; + os->writeLong(getLong(p)); + break; } case PrimitiveInfo::KindFloat: { - volatile VALUE val = callRuby(rb_Float, p); - if(NIL_P(val)) - { - throw RubyException(rb_eTypeError, "unable to convert value to a float"); - } - assert(TYPE(val) == T_FLOAT); - os->writeFloat(static_cast<float>(RFLOAT(val)->value)); - break; + volatile VALUE val = callRuby(rb_Float, p); + if(NIL_P(val)) + { + throw RubyException(rb_eTypeError, "unable to convert value to a float"); + } + assert(TYPE(val) == T_FLOAT); + os->writeFloat(static_cast<float>(RFLOAT(val)->value)); + break; } case PrimitiveInfo::KindDouble: { - volatile VALUE val = callRuby(rb_Float, p); - if(NIL_P(val)) - { - throw RubyException(rb_eTypeError, "unable to convert value to a double"); - } - assert(TYPE(val) == T_FLOAT); - os->writeDouble(RFLOAT(val)->value); - break; + volatile VALUE val = callRuby(rb_Float, p); + if(NIL_P(val)) + { + throw RubyException(rb_eTypeError, "unable to convert value to a double"); + } + assert(TYPE(val) == T_FLOAT); + os->writeDouble(RFLOAT(val)->value); + break; } case PrimitiveInfo::KindString: { - string val = getString(p); - os->writeString(val); - break; + string val = getString(p); + os->writeString(val); + break; } } } void IceRuby::PrimitiveInfo::unmarshal(const Ice::InputStreamPtr& is, const UnmarshalCallbackPtr& cb, VALUE target, - void* closure) + void* closure) { volatile VALUE val = Qnil; switch(kind) { case PrimitiveInfo::KindBool: { - val = is->readBool() ? Qtrue : Qfalse; - break; + val = is->readBool() ? Qtrue : Qfalse; + break; } case PrimitiveInfo::KindByte: { - long l = is->readByte(); - val = callRuby(rb_int2inum, l); - break; + long l = is->readByte(); + val = callRuby(rb_int2inum, l); + break; } case PrimitiveInfo::KindShort: { - long l = is->readShort(); - val = callRuby(rb_int2inum, l); - break; + long l = is->readShort(); + val = callRuby(rb_int2inum, l); + break; } case PrimitiveInfo::KindInt: { - long l = is->readInt(); - val = callRuby(rb_int2inum, l); - break; + long l = is->readInt(); + val = callRuby(rb_int2inum, l); + break; } case PrimitiveInfo::KindLong: { - Ice::Long l = is->readLong(); - val = callRuby(rb_ll2inum, l); - break; + Ice::Long l = is->readLong(); + val = callRuby(rb_ll2inum, l); + break; } case PrimitiveInfo::KindFloat: { - Ice::Float f = is->readFloat(); - val = callRuby(rb_float_new, f); - break; + Ice::Float f = is->readFloat(); + val = callRuby(rb_float_new, f); + break; } case PrimitiveInfo::KindDouble: { - Ice::Double d = is->readDouble(); - val = callRuby(rb_float_new, d); - break; + Ice::Double d = is->readDouble(); + val = callRuby(rb_float_new, d); + break; } case PrimitiveInfo::KindString: { - string str = is->readString(); - val = createString(str); - break; + string str = is->readString(); + val = createString(str); + break; } } cb->unmarshaled(val, target, closure); @@ -350,41 +350,41 @@ IceRuby::PrimitiveInfo::print(VALUE value, IceUtil::Output& out, PrintObjectHist { case PrimitiveInfo::KindBool: { - out << (RTEST(value) ? "true" : "false"); - break; + out << (RTEST(value) ? "true" : "false"); + break; } case PrimitiveInfo::KindByte: case PrimitiveInfo::KindShort: case PrimitiveInfo::KindInt: { - out << getInteger(value); - break; + out << getInteger(value); + break; } case PrimitiveInfo::KindLong: { - Ice::Long l = getLong(value); - char buf[64]; + Ice::Long l = getLong(value); + char buf[64]; #ifdef _WIN32 - sprintf(buf, "%I64d", l); + sprintf(buf, "%I64d", l); #elif defined(ICE_64) - sprintf(buf, "%ld", l); + sprintf(buf, "%ld", l); #else - sprintf(buf, "%lld", l); + sprintf(buf, "%lld", l); #endif - out << buf; - break; + out << buf; + break; } case PrimitiveInfo::KindFloat: case PrimitiveInfo::KindDouble: { - double d = toDouble(value); - out << d; - break; + double d = toDouble(value); + out << d; + break; } case PrimitiveInfo::KindString: { - out << "'" << getString(value) << "'"; - break; + out << "'" << getString(value) << "'"; + break; } } } @@ -395,7 +395,7 @@ IceRuby::PrimitiveInfo::toDouble(VALUE v) volatile VALUE val = callRuby(rb_Float, v); if(NIL_P(val)) { - throw RubyException(rb_eTypeError, "unable to convert value to a double"); + throw RubyException(rb_eTypeError, "unable to convert value to a double"); } assert(TYPE(val) == T_FLOAT); return RFLOAT(val)->value; @@ -430,20 +430,20 @@ IceRuby::EnumInfo::marshal(VALUE p, const Ice::OutputStreamPtr& os, ObjectMap*) long count = static_cast<long>(enumerators.size()); if(ival < 0 || ival >= count) { - throw RubyException(rb_eRangeError, "value %ld is out of range for enum %s", ival, id.c_str()); + throw RubyException(rb_eRangeError, "value %ld is out of range for enum %s", ival, id.c_str()); } if(count <= 127) { - os->writeByte(static_cast<Ice::Byte>(ival)); + os->writeByte(static_cast<Ice::Byte>(ival)); } else if(count <= 32767) { - os->writeShort(static_cast<Ice::Short>(ival)); + os->writeShort(static_cast<Ice::Short>(ival)); } else { - os->writeInt(ival); + os->writeInt(ival); } } @@ -454,20 +454,20 @@ IceRuby::EnumInfo::unmarshal(const Ice::InputStreamPtr& is, const UnmarshalCallb int count = static_cast<int>(enumerators.size()); if(count <= 127) { - val = is->readByte(); + val = is->readByte(); } else if(count <= 32767) { - val = is->readShort(); + val = is->readShort(); } else { - val = is->readInt(); + val = is->readInt(); } if(val < 0 || val >= count) { - throw RubyException(rb_eRangeError, "enumerator %ld is out of range for enum %s", val, id.c_str()); + throw RubyException(rb_eRangeError, "enumerator %ld is out of range for enum %s", val, id.c_str()); } cb->unmarshaled(enumerators[val], target, closure); @@ -478,8 +478,8 @@ IceRuby::EnumInfo::print(VALUE value, IceUtil::Output& out, PrintObjectHistory*) { if(!validate(value)) { - out << "<invalid value - expected " << id << ">"; - return; + out << "<invalid value - expected " << id << ">"; + return; } volatile VALUE str = callRuby(rb_funcall, value, rb_intern("inspect"), 0); out << getString(str); @@ -514,10 +514,10 @@ IceRuby::StructInfo::usesClasses() { for(DataMemberList::iterator q = members.begin(); q != members.end(); ++q) { - if((*q)->type->usesClasses()) - { - return true; - } + if((*q)->type->usesClasses()) + { + return true; + } } return false; @@ -530,27 +530,27 @@ IceRuby::StructInfo::marshal(VALUE p, const Ice::OutputStreamPtr& os, ObjectMap* for(DataMemberList::iterator q = members.begin(); q != members.end(); ++q) { - DataMemberPtr member = *q; - volatile VALUE val = callRuby(rb_ivar_get, p, member->rubyID); - if(!member->type->validate(val)) - { - throw RubyException(rb_eTypeError, "invalid value for %s member `%s'", const_cast<char*>(id.c_str()), - member->name.c_str()); - } - member->type->marshal(val, os, objectMap); + DataMemberPtr member = *q; + volatile VALUE val = callRuby(rb_ivar_get, p, member->rubyID); + if(!member->type->validate(val)) + { + throw RubyException(rb_eTypeError, "invalid value for %s member `%s'", const_cast<char*>(id.c_str()), + member->name.c_str()); + } + member->type->marshal(val, os, objectMap); } } void IceRuby::StructInfo::unmarshal(const Ice::InputStreamPtr& is, const UnmarshalCallbackPtr& cb, VALUE target, - void* closure) + void* closure) { volatile VALUE obj = callRuby(rb_class_new_instance, 0, static_cast<VALUE*>(0), rubyClass); for(DataMemberList::iterator q = members.begin(); q != members.end(); ++q) { - DataMemberPtr member = *q; - member->type->unmarshal(is, member, obj, 0); + DataMemberPtr member = *q; + member->type->unmarshal(is, member, obj, 0); } cb->unmarshaled(obj, target, closure); @@ -561,23 +561,23 @@ IceRuby::StructInfo::print(VALUE value, IceUtil::Output& out, PrintObjectHistory { if(!validate(value)) { - out << "<invalid value - expected " << id << ">"; - return; + out << "<invalid value - expected " << id << ">"; + return; } out.sb(); for(DataMemberList::iterator q = members.begin(); q != members.end(); ++q) { - DataMemberPtr member = *q; - out << nl << member->name << " = "; - if(callRuby(rb_ivar_defined, value, member->rubyID) == Qfalse) - { - out << "<not defined>"; - } - else - { - volatile VALUE val = callRuby(rb_ivar_get, value, member->rubyID); - member->type->print(val, out, history); - } + DataMemberPtr member = *q; + out << nl << member->name << " = "; + if(callRuby(rb_ivar_defined, value, member->rubyID) == Qfalse) + { + out << "<not defined>"; + } + else + { + volatile VALUE val = callRuby(rb_ivar_get, value, member->rubyID); + member->type->print(val, out, history); + } } out.eb(); } @@ -587,7 +587,7 @@ IceRuby::StructInfo::destroy() { for(DataMemberList::iterator p = members.begin(); p != members.end(); ++p) { - (*p)->type->destroy(); + (*p)->type->destroy(); } members.clear(); } @@ -609,15 +609,15 @@ IceRuby::SequenceInfo::validate(VALUE val) // if(NIL_P(val) || TYPE(val) == T_ARRAY) { - return true; + return true; } if(TYPE(val) == T_STRING) { - PrimitiveInfoPtr pi = PrimitiveInfoPtr::dynamicCast(elementType); - if(pi && pi->kind == PrimitiveInfo::KindByte) - { - return true; - } + PrimitiveInfoPtr pi = PrimitiveInfoPtr::dynamicCast(elementType); + if(pi && pi->kind == PrimitiveInfo::KindByte) + { + return true; + } } ID id = rb_intern("to_ary"); return callRuby(rb_respond_to, val, id) != 0; @@ -634,45 +634,45 @@ IceRuby::SequenceInfo::marshal(VALUE p, const Ice::OutputStreamPtr& os, ObjectMa { if(NIL_P(p)) { - os->writeSize(0); - return; + os->writeSize(0); + return; } PrimitiveInfoPtr pi = PrimitiveInfoPtr::dynamicCast(elementType); if(pi) { - marshalPrimitiveSequence(pi, p, os); - return; + marshalPrimitiveSequence(pi, p, os); + return; } volatile VALUE arr = callRuby(rb_Array, p); if(NIL_P(arr)) { - throw RubyException(rb_eTypeError, "unable to convert value to an array"); + throw RubyException(rb_eTypeError, "unable to convert value to an array"); } long sz = RARRAY(arr)->len; os->writeSize(static_cast<Ice::Int>(sz)); for(long i = 0; i < sz; ++i) { - if(!elementType->validate(RARRAY(arr)->ptr[i])) - { - throw RubyException(rb_eTypeError, "invalid value for element %ld of `%s'", i, - const_cast<char*>(id.c_str())); - } - elementType->marshal(RARRAY(arr)->ptr[i], os, objectMap); + if(!elementType->validate(RARRAY(arr)->ptr[i])) + { + throw RubyException(rb_eTypeError, "invalid value for element %ld of `%s'", i, + const_cast<char*>(id.c_str())); + } + elementType->marshal(RARRAY(arr)->ptr[i], os, objectMap); } } void IceRuby::SequenceInfo::unmarshal(const Ice::InputStreamPtr& is, const UnmarshalCallbackPtr& cb, VALUE target, - void* closure) + void* closure) { PrimitiveInfoPtr pi = PrimitiveInfoPtr::dynamicCast(elementType); if(pi) { - unmarshalPrimitiveSequence(pi, is, cb, target, closure); - return; + unmarshalPrimitiveSequence(pi, is, cb, target, closure); + return; } Ice::Int sz = is->readSize(); @@ -680,8 +680,8 @@ IceRuby::SequenceInfo::unmarshal(const Ice::InputStreamPtr& is, const UnmarshalC for(Ice::Int i = 0; i < sz; ++i) { - void* cl = reinterpret_cast<void*>(i); - elementType->unmarshal(is, this, arr, cl); + void* cl = reinterpret_cast<void*>(i); + elementType->unmarshal(is, this, arr, cl); } RARRAY(arr)->len = sz; @@ -700,31 +700,31 @@ IceRuby::SequenceInfo::print(VALUE value, IceUtil::Output& out, PrintObjectHisto { if(!validate(value)) { - out << "<invalid value - expected " << id << ">"; - return; + out << "<invalid value - expected " << id << ">"; + return; } if(NIL_P(value)) { - out << "{}"; + out << "{}"; } else { - volatile VALUE arr = callRuby(rb_Array, value); - if(NIL_P(arr)) - { - throw RubyException(rb_eTypeError, "unable to convert value to an array"); - } + volatile VALUE arr = callRuby(rb_Array, value); + if(NIL_P(arr)) + { + throw RubyException(rb_eTypeError, "unable to convert value to an array"); + } - long sz = RARRAY(arr)->len; + long sz = RARRAY(arr)->len; - out.sb(); - for(long i = 0; i < sz; ++i) - { - out << nl << '[' << i << "] = "; - elementType->print(RARRAY(arr)->ptr[i], out, history); - } - out.eb(); + out.sb(); + for(long i = 0; i < sz; ++i) + { + out << nl << '[' << i << "] = "; + elementType->print(RARRAY(arr)->ptr[i], out, history); + } + out.eb(); } } @@ -733,8 +733,8 @@ IceRuby::SequenceInfo::destroy() { if(elementType) { - elementType->destroy(); - elementType = 0; + elementType->destroy(); + elementType = 0; } } @@ -749,167 +749,167 @@ IceRuby::SequenceInfo::marshalPrimitiveSequence(const PrimitiveInfoPtr& pi, VALU // if(pi->kind == PrimitiveInfo::KindByte) { - if(TYPE(p) == T_STRING) - { - str = p; - } - else - { - arr = callRuby(rb_Array, p); - if(NIL_P(arr)) - { - throw RubyException(rb_eTypeError, "argument is not a string or an array"); - } - } + if(TYPE(p) == T_STRING) + { + str = p; + } + else + { + arr = callRuby(rb_Array, p); + if(NIL_P(arr)) + { + throw RubyException(rb_eTypeError, "argument is not a string or an array"); + } + } } else { - arr = callRuby(rb_Array, p); - if(NIL_P(arr)) - { - throw RubyException(rb_eTypeError, "unable to convert value to an array"); - } + arr = callRuby(rb_Array, p); + if(NIL_P(arr)) + { + throw RubyException(rb_eTypeError, "unable to convert value to an array"); + } } switch(pi->kind) { case PrimitiveInfo::KindBool: { - long sz = RARRAY(arr)->len; - Ice::BoolSeq seq(sz); - for(long i = 0; i < sz; ++i) - { - seq[i] = RTEST(RARRAY(arr)->ptr[i]); - } - os->writeBoolSeq(seq); - break; + long sz = RARRAY(arr)->len; + Ice::BoolSeq seq(sz); + for(long i = 0; i < sz; ++i) + { + seq[i] = RTEST(RARRAY(arr)->ptr[i]); + } + os->writeBoolSeq(seq); + break; } case PrimitiveInfo::KindByte: { - if(!NIL_P(str)) - { - const char* s = RSTRING(str)->ptr; - const long len = RSTRING(str)->len; - if(s == 0 || len == 0) - { - os->writeSize(0); - } - else - { - os->writeByteSeq(reinterpret_cast<const Ice::Byte*>(s), reinterpret_cast<const Ice::Byte*>(s + len)); - } - } - else - { - long sz = RARRAY(arr)->len; - Ice::ByteSeq seq(sz); - for(long i = 0; i < sz; ++i) - { - long val = getInteger(RARRAY(arr)->ptr[i]); - if(val < 0 || val > 255) - { - throw RubyException(rb_eTypeError, "invalid value for element %ld of sequence<byte>", i); - } - seq[i] = static_cast<Ice::Byte>(val); - } - os->writeByteSeq(seq); - } - break; + if(!NIL_P(str)) + { + const char* s = RSTRING(str)->ptr; + const long len = RSTRING(str)->len; + if(s == 0 || len == 0) + { + os->writeSize(0); + } + else + { + os->writeByteSeq(reinterpret_cast<const Ice::Byte*>(s), reinterpret_cast<const Ice::Byte*>(s + len)); + } + } + else + { + long sz = RARRAY(arr)->len; + Ice::ByteSeq seq(sz); + for(long i = 0; i < sz; ++i) + { + long val = getInteger(RARRAY(arr)->ptr[i]); + if(val < 0 || val > 255) + { + throw RubyException(rb_eTypeError, "invalid value for element %ld of sequence<byte>", i); + } + seq[i] = static_cast<Ice::Byte>(val); + } + os->writeByteSeq(seq); + } + break; } case PrimitiveInfo::KindShort: { - long sz = RARRAY(arr)->len; - Ice::ShortSeq seq(sz); - for(long i = 0; i < sz; ++i) - { - long val = getInteger(RARRAY(arr)->ptr[i]); - if(val < SHRT_MIN || val > SHRT_MAX) - { - throw RubyException(rb_eTypeError, "invalid value for element %ld of sequence<short>", i); - } - seq[i] = static_cast<Ice::Short>(val); - } - os->writeShortSeq(seq); - break; + long sz = RARRAY(arr)->len; + Ice::ShortSeq seq(sz); + for(long i = 0; i < sz; ++i) + { + long val = getInteger(RARRAY(arr)->ptr[i]); + if(val < SHRT_MIN || val > SHRT_MAX) + { + throw RubyException(rb_eTypeError, "invalid value for element %ld of sequence<short>", i); + } + seq[i] = static_cast<Ice::Short>(val); + } + os->writeShortSeq(seq); + break; } case PrimitiveInfo::KindInt: { - long sz = RARRAY(arr)->len; - Ice::IntSeq seq(sz); - for(long i = 0; i < sz; ++i) - { - long val = getInteger(RARRAY(arr)->ptr[i]); - if(val < INT_MIN || val > INT_MAX) - { - throw RubyException(rb_eTypeError, "invalid value for element %ld of sequence<int>", i); - } - seq[i] = static_cast<Ice::Int>(val); - } - os->writeIntSeq(seq); - break; + long sz = RARRAY(arr)->len; + Ice::IntSeq seq(sz); + for(long i = 0; i < sz; ++i) + { + long val = getInteger(RARRAY(arr)->ptr[i]); + if(val < INT_MIN || val > INT_MAX) + { + throw RubyException(rb_eTypeError, "invalid value for element %ld of sequence<int>", i); + } + seq[i] = static_cast<Ice::Int>(val); + } + os->writeIntSeq(seq); + break; } case PrimitiveInfo::KindLong: { - long sz = RARRAY(arr)->len; - Ice::LongSeq seq(sz); - for(long i = 0; i < sz; ++i) - { - seq[i] = getLong(RARRAY(arr)->ptr[i]); - } - os->writeLongSeq(seq); - break; + long sz = RARRAY(arr)->len; + Ice::LongSeq seq(sz); + for(long i = 0; i < sz; ++i) + { + seq[i] = getLong(RARRAY(arr)->ptr[i]); + } + os->writeLongSeq(seq); + break; } case PrimitiveInfo::KindFloat: { - long sz = RARRAY(arr)->len; - Ice::FloatSeq seq(sz); - for(long i = 0; i < sz; ++i) - { - volatile VALUE v = callRuby(rb_Float, RARRAY(arr)->ptr[i]); - if(NIL_P(v)) - { - throw RubyException(rb_eTypeError, "unable to convert array element %ld to a float", i); - } - assert(TYPE(v) == T_FLOAT); - seq[i] = static_cast<Ice::Float>(RFLOAT(v)->value); - } - os->writeFloatSeq(seq); - break; + long sz = RARRAY(arr)->len; + Ice::FloatSeq seq(sz); + for(long i = 0; i < sz; ++i) + { + volatile VALUE v = callRuby(rb_Float, RARRAY(arr)->ptr[i]); + if(NIL_P(v)) + { + throw RubyException(rb_eTypeError, "unable to convert array element %ld to a float", i); + } + assert(TYPE(v) == T_FLOAT); + seq[i] = static_cast<Ice::Float>(RFLOAT(v)->value); + } + os->writeFloatSeq(seq); + break; } case PrimitiveInfo::KindDouble: { - long sz = RARRAY(arr)->len; - Ice::DoubleSeq seq(sz); - for(long i = 0; i < sz; ++i) - { - volatile VALUE v = callRuby(rb_Float, RARRAY(arr)->ptr[i]); - if(NIL_P(v)) - { - throw RubyException(rb_eTypeError, "unable to convert array element %ld to a double", i); - } - assert(TYPE(v) == T_FLOAT); - seq[i] = RFLOAT(v)->value; - } - os->writeDoubleSeq(seq); - break; + long sz = RARRAY(arr)->len; + Ice::DoubleSeq seq(sz); + for(long i = 0; i < sz; ++i) + { + volatile VALUE v = callRuby(rb_Float, RARRAY(arr)->ptr[i]); + if(NIL_P(v)) + { + throw RubyException(rb_eTypeError, "unable to convert array element %ld to a double", i); + } + assert(TYPE(v) == T_FLOAT); + seq[i] = RFLOAT(v)->value; + } + os->writeDoubleSeq(seq); + break; } case PrimitiveInfo::KindString: { - long sz = RARRAY(arr)->len; - Ice::StringSeq seq(sz); - for(long i = 0; i < sz; ++i) - { - seq[i] = getString(RARRAY(arr)->ptr[i]); - } - os->writeStringSeq(seq); - break; + long sz = RARRAY(arr)->len; + Ice::StringSeq seq(sz); + for(long i = 0; i < sz; ++i) + { + seq[i] = getString(RARRAY(arr)->ptr[i]); + } + os->writeStringSeq(seq); + break; } } } void IceRuby::SequenceInfo::unmarshalPrimitiveSequence(const PrimitiveInfoPtr& pi, const Ice::InputStreamPtr& is, - const UnmarshalCallbackPtr& cb, VALUE target, void* closure) + const UnmarshalCallbackPtr& cb, VALUE target, void* closure) { volatile VALUE result = Qnil; @@ -917,107 +917,107 @@ IceRuby::SequenceInfo::unmarshalPrimitiveSequence(const PrimitiveInfoPtr& pi, co { case PrimitiveInfo::KindBool: { - pair<const bool*, const bool*> p; - IceUtil::ScopedArray<bool> sa(is->readBoolSeq(p)); - long sz = static_cast<long>(p.second - p.first); - result = createArray(sz); + pair<const bool*, const bool*> p; + IceUtil::ScopedArray<bool> sa(is->readBoolSeq(p)); + long sz = static_cast<long>(p.second - p.first); + result = createArray(sz); - for(long i = 0; i < sz; ++i) - { - RARRAY(result)->ptr[i] = p.first[i] ? Qtrue : Qfalse; - } - RARRAY(result)->len = sz; - break; + for(long i = 0; i < sz; ++i) + { + RARRAY(result)->ptr[i] = p.first[i] ? Qtrue : Qfalse; + } + RARRAY(result)->len = sz; + break; } case PrimitiveInfo::KindByte: { - pair<const Ice::Byte*, const Ice::Byte*> p; - is->readByteSeq(p); - result = callRuby(rb_str_new, reinterpret_cast<const char*>(p.first), static_cast<long>(p.second - p.first)); - break; + pair<const Ice::Byte*, const Ice::Byte*> p; + is->readByteSeq(p); + result = callRuby(rb_str_new, reinterpret_cast<const char*>(p.first), static_cast<long>(p.second - p.first)); + break; } case PrimitiveInfo::KindShort: { - pair<const Ice::Short*, const Ice::Short*> p; - IceUtil::ScopedArray<Ice::Short> sa(is->readShortSeq(p)); - long sz = static_cast<long>(p.second - p.first); - result = createArray(sz); + pair<const Ice::Short*, const Ice::Short*> p; + IceUtil::ScopedArray<Ice::Short> sa(is->readShortSeq(p)); + long sz = static_cast<long>(p.second - p.first); + result = createArray(sz); - for(long i = 0; i < sz; ++i) - { - RARRAY(result)->ptr[i] = INT2FIX(p.first[i]); - } - RARRAY(result)->len = sz; - break; + for(long i = 0; i < sz; ++i) + { + RARRAY(result)->ptr[i] = INT2FIX(p.first[i]); + } + RARRAY(result)->len = sz; + break; } case PrimitiveInfo::KindInt: { - pair<const Ice::Int*, const Ice::Int*> p; - IceUtil::ScopedArray<Ice::Int> sa(is->readIntSeq(p)); - long sz = static_cast<long>(p.second - p.first); - result = createArray(sz); + pair<const Ice::Int*, const Ice::Int*> p; + IceUtil::ScopedArray<Ice::Int> sa(is->readIntSeq(p)); + long sz = static_cast<long>(p.second - p.first); + result = createArray(sz); - for(long i = 0; i < sz; ++i) - { - RARRAY(result)->ptr[i] = INT2FIX(p.first[i]); - } - RARRAY(result)->len = sz; - break; + for(long i = 0; i < sz; ++i) + { + RARRAY(result)->ptr[i] = INT2FIX(p.first[i]); + } + RARRAY(result)->len = sz; + break; } case PrimitiveInfo::KindLong: { - pair<const Ice::Long*, const Ice::Long*> p; - IceUtil::ScopedArray<Ice::Long> sa(is->readLongSeq(p)); - long sz = static_cast<long>(p.second - p.first); - result = createArray(sz); + pair<const Ice::Long*, const Ice::Long*> p; + IceUtil::ScopedArray<Ice::Long> sa(is->readLongSeq(p)); + long sz = static_cast<long>(p.second - p.first); + result = createArray(sz); - for(long i = 0; i < sz; ++i) - { - RARRAY(result)->ptr[i] = callRuby(rb_ll2inum, p.first[i]); - } - RARRAY(result)->len = sz; - break; + for(long i = 0; i < sz; ++i) + { + RARRAY(result)->ptr[i] = callRuby(rb_ll2inum, p.first[i]); + } + RARRAY(result)->len = sz; + break; } case PrimitiveInfo::KindFloat: { - pair<const Ice::Float*, const Ice::Float*> p; - IceUtil::ScopedArray<Ice::Float> sa(is->readFloatSeq(p)); - long sz = static_cast<long>(p.second - p.first); - result = createArray(sz); + pair<const Ice::Float*, const Ice::Float*> p; + IceUtil::ScopedArray<Ice::Float> sa(is->readFloatSeq(p)); + long sz = static_cast<long>(p.second - p.first); + result = createArray(sz); - for(long i = 0; i < sz; ++i) - { - RARRAY(result)->ptr[i] = callRuby(rb_float_new, p.first[i]); - } - RARRAY(result)->len = sz; - break; + for(long i = 0; i < sz; ++i) + { + RARRAY(result)->ptr[i] = callRuby(rb_float_new, p.first[i]); + } + RARRAY(result)->len = sz; + break; } case PrimitiveInfo::KindDouble: { - pair<const Ice::Double*, const Ice::Double*> p; - IceUtil::ScopedArray<Ice::Double> sa(is->readDoubleSeq(p)); - long sz = static_cast<long>(p.second - p.first); - result = createArray(sz); + pair<const Ice::Double*, const Ice::Double*> p; + IceUtil::ScopedArray<Ice::Double> sa(is->readDoubleSeq(p)); + long sz = static_cast<long>(p.second - p.first); + result = createArray(sz); - for(long i = 0; i < sz; ++i) - { - RARRAY(result)->ptr[i] = callRuby(rb_float_new, p.first[i]); - } - RARRAY(result)->len = sz; - break; + for(long i = 0; i < sz; ++i) + { + RARRAY(result)->ptr[i] = callRuby(rb_float_new, p.first[i]); + } + RARRAY(result)->len = sz; + break; } case PrimitiveInfo::KindString: { - Ice::StringSeq seq = is->readStringSeq(); - long sz = static_cast<long>(seq.size()); - result = createArray(sz); + Ice::StringSeq seq = is->readStringSeq(); + long sz = static_cast<long>(seq.size()); + result = createArray(sz); - for(long i = 0; i < sz; ++i) - { - RARRAY(result)->ptr[i] = createString(seq[i]); - } - RARRAY(result)->len = sz; - break; + for(long i = 0; i < sz; ++i) + { + RARRAY(result)->ptr[i] = createString(seq[i]); + } + RARRAY(result)->len = sz; + break; } } cb->unmarshaled(result, target, closure); @@ -1040,7 +1040,7 @@ IceRuby::DictionaryInfo::validate(VALUE val) // if(NIL_P(val) || TYPE(val) == T_HASH) { - return true; + return true; } ID id = rb_intern("to_hash"); return callRuby(rb_respond_to, val, id) != 0; @@ -1057,13 +1057,13 @@ namespace struct DictionaryMarshalIterator : public IceRuby::HashIterator { DictionaryMarshalIterator(const IceRuby::DictionaryInfoPtr& d, const Ice::OutputStreamPtr o, IceRuby::ObjectMap* m) - : dict(d), os(o), objectMap(m) + : dict(d), os(o), objectMap(m) { } virtual void element(VALUE key, VALUE value) { - dict->marshalElement(key, value, os, objectMap); + dict->marshalElement(key, value, os, objectMap); } IceRuby::DictionaryInfoPtr dict; @@ -1077,14 +1077,14 @@ IceRuby::DictionaryInfo::marshal(VALUE p, const Ice::OutputStreamPtr& os, Object { if(NIL_P(p)) { - os->writeSize(0); - return; + os->writeSize(0); + return; } volatile VALUE hash = callRuby(rb_convert_type, p, T_HASH, "Hash", "to_hash"); if(NIL_P(hash)) { - throw RubyException(rb_eTypeError, "unable to convert value to a hash"); + throw RubyException(rb_eTypeError, "unable to convert value to a hash"); } int sz = RHASH(hash)->tbl->num_entries; @@ -1099,12 +1099,12 @@ IceRuby::DictionaryInfo::marshalElement(VALUE key, VALUE value, const Ice::Outpu { if(!keyType->validate(key)) { - throw RubyException(rb_eTypeError, "invalid key in `%s' element", const_cast<char*>(id.c_str())); + throw RubyException(rb_eTypeError, "invalid key in `%s' element", const_cast<char*>(id.c_str())); } if(!valueType->validate(value)) { - throw RubyException(rb_eTypeError, "invalid value in `%s' element", const_cast<char*>(id.c_str())); + throw RubyException(rb_eTypeError, "invalid value in `%s' element", const_cast<char*>(id.c_str())); } keyType->marshal(key, os, objectMap); @@ -1113,7 +1113,7 @@ IceRuby::DictionaryInfo::marshalElement(VALUE key, VALUE value, const Ice::Outpu void IceRuby::DictionaryInfo::unmarshal(const Ice::InputStreamPtr& is, const UnmarshalCallbackPtr& cb, VALUE target, - void* closure) + void* closure) { volatile VALUE hash = callRuby(rb_hash_new); @@ -1123,19 +1123,19 @@ IceRuby::DictionaryInfo::unmarshal(const Ice::InputStreamPtr& is, const Unmarsha Ice::Int sz = is->readSize(); for(Ice::Int i = 0; i < sz; ++i) { - // - // A dictionary key cannot be a class (or contain one), so the key must be - // available immediately. - // - keyType->unmarshal(is, keyCB, Qnil, 0); - assert(!NIL_P(keyCB->key)); + // + // A dictionary key cannot be a class (or contain one), so the key must be + // available immediately. + // + keyType->unmarshal(is, keyCB, Qnil, 0); + assert(!NIL_P(keyCB->key)); - // - // The callback will set the dictionary entry with the unmarshaled value, - // so we pass it the key. - // - void* cl = reinterpret_cast<void*>(keyCB->key); - valueType->unmarshal(is, this, hash, cl); + // + // The callback will set the dictionary entry with the unmarshaled value, + // so we pass it the key. + // + void* cl = reinterpret_cast<void*>(keyCB->key); + valueType->unmarshal(is, this, hash, cl); } cb->unmarshaled(hash, target, closure); @@ -1153,13 +1153,13 @@ namespace struct DictionaryPrintIterator : public IceRuby::HashIterator { DictionaryPrintIterator(const DictionaryInfoPtr& d, IceUtil::Output& o, PrintObjectHistory* h) : - dict(d), out(o), history(h) + dict(d), out(o), history(h) { } virtual void element(VALUE key, VALUE value) { - dict->printElement(key, value, out, history); + dict->printElement(key, value, out, history); } IceRuby::DictionaryInfoPtr dict; @@ -1173,32 +1173,32 @@ IceRuby::DictionaryInfo::print(VALUE value, IceUtil::Output& out, PrintObjectHis { if(!validate(value)) { - out << "<invalid value - expected " << id << ">"; - return; + out << "<invalid value - expected " << id << ">"; + return; } if(NIL_P(value)) { - out << "{}"; + out << "{}"; } else { - volatile VALUE hash = callRuby(rb_convert_type, value, T_HASH, "Hash", "to_hash"); - if(NIL_P(hash)) - { - throw RubyException(rb_eTypeError, "unable to convert value to a hash"); - } + volatile VALUE hash = callRuby(rb_convert_type, value, T_HASH, "Hash", "to_hash"); + if(NIL_P(hash)) + { + throw RubyException(rb_eTypeError, "unable to convert value to a hash"); + } - if(RHASH(hash)->tbl->num_entries == 0) - { - out << "{}"; - return; - } + if(RHASH(hash)->tbl->num_entries == 0) + { + out << "{}"; + return; + } - out.sb(); - DictionaryPrintIterator iter(this, out, history); - hashIterate(hash, iter); - out.eb(); + out.sb(); + DictionaryPrintIterator iter(this, out, history); + hashIterate(hash, iter); + out.eb(); } } @@ -1222,13 +1222,13 @@ IceRuby::DictionaryInfo::destroy() { if(keyType) { - keyType->destroy(); - keyType = 0; + keyType->destroy(); + keyType = 0; } if(valueType) { - valueType->destroy(); - valueType = 0; + valueType->destroy(); + valueType = 0; } } @@ -1246,7 +1246,7 @@ IceRuby::ClassInfo::validate(VALUE val) { if(NIL_P(val)) { - return true; + return true; } // @@ -1257,7 +1257,7 @@ IceRuby::ClassInfo::validate(VALUE val) volatile VALUE type = callRuby(rb_const_get, cls, rb_intern("ICE_TYPE")); if(NIL_P(type)) { - return false; + return false; } ClassInfoPtr info = ClassInfoPtr::dynamicCast(getType(type)); assert(info); @@ -1275,13 +1275,13 @@ IceRuby::ClassInfo::marshal(VALUE p, const Ice::OutputStreamPtr& os, ObjectMap* { if(!defined) { - throw RubyException(rb_eRuntimeError, "class %s is declared but not defined", id.c_str()); + throw RubyException(rb_eRuntimeError, "class %s is declared but not defined", id.c_str()); } if(NIL_P(p)) { - os->writeObject(0); - return; + os->writeObject(0); + return; } // @@ -1295,17 +1295,17 @@ IceRuby::ClassInfo::marshal(VALUE p, const Ice::OutputStreamPtr& os, ObjectMap* ObjectMap::iterator q = objectMap->find(p); if(q == objectMap->end()) { - volatile VALUE cls = CLASS_OF(p); - volatile VALUE type = callRuby(rb_const_get, cls, rb_intern("ICE_TYPE")); - assert(!NIL_P(type)); // Should have been caught by validate(). - ClassInfoPtr info = ClassInfoPtr::dynamicCast(getType(type)); - assert(info); - writer = new ObjectWriter(info, p, objectMap); - objectMap->insert(ObjectMap::value_type(p, writer)); + volatile VALUE cls = CLASS_OF(p); + volatile VALUE type = callRuby(rb_const_get, cls, rb_intern("ICE_TYPE")); + assert(!NIL_P(type)); // Should have been caught by validate(). + ClassInfoPtr info = ClassInfoPtr::dynamicCast(getType(type)); + assert(info); + writer = new ObjectWriter(info, p, objectMap); + objectMap->insert(ObjectMap::value_type(p, writer)); } else { - writer = q->second; + writer = q->second; } // @@ -1316,11 +1316,11 @@ IceRuby::ClassInfo::marshal(VALUE p, const Ice::OutputStreamPtr& os, ObjectMap* void IceRuby::ClassInfo::unmarshal(const Ice::InputStreamPtr& is, const UnmarshalCallbackPtr& cb, VALUE target, - void* closure) + void* closure) { if(!defined) { - throw RubyException(rb_eRuntimeError, "class %s is declared but not defined", id.c_str()); + throw RubyException(rb_eRuntimeError, "class %s is declared but not defined", id.c_str()); } is->readObject(new ReadObjectCallback(this, cb, target, closure)); @@ -1331,34 +1331,34 @@ IceRuby::ClassInfo::print(VALUE value, IceUtil::Output& out, PrintObjectHistory* { if(!validate(value)) { - out << "<invalid value - expected " << id << ">"; - return; + out << "<invalid value - expected " << id << ">"; + return; } if(NIL_P(value)) { - out << "<nil>"; + out << "<nil>"; } else { - map<VALUE, int>::iterator q = history->objects.find(value); - if(q != history->objects.end()) - { - out << "<object #" << q->second << ">"; - } - else - { - volatile VALUE cls = CLASS_OF(value); - volatile VALUE type = callRuby(rb_const_get, cls, rb_intern("ICE_TYPE")); - ClassInfoPtr info = ClassInfoPtr::dynamicCast(getType(type)); - assert(info); - out << "object #" << history->index << " (" << info->id << ')'; - history->objects.insert(map<VALUE, int>::value_type(value, history->index)); - ++history->index; - out.sb(); - info->printMembers(value, out, history); - out.eb(); - } + map<VALUE, int>::iterator q = history->objects.find(value); + if(q != history->objects.end()) + { + out << "<object #" << q->second << ">"; + } + else + { + volatile VALUE cls = CLASS_OF(value); + volatile VALUE type = callRuby(rb_const_get, cls, rb_intern("ICE_TYPE")); + ClassInfoPtr info = ClassInfoPtr::dynamicCast(getType(type)); + assert(info); + out << "object #" << history->index << " (" << info->id << ')'; + history->objects.insert(map<VALUE, int>::value_type(value, history->index)); + ++history->index; + out.sb(); + info->printMembers(value, out, history); + out.eb(); + } } } @@ -1369,12 +1369,12 @@ IceRuby::ClassInfo::destroy() interfaces.clear(); if(!members.empty()) { - DataMemberList ml = members; - members.clear(); - for(DataMemberList::iterator p = ml.begin(); p != ml.end(); ++p) - { - (*p)->type->destroy(); - } + DataMemberList ml = members; + members.clear(); + for(DataMemberList::iterator p = ml.begin(); p != ml.end(); ++p) + { + (*p)->type->destroy(); + } } } @@ -1383,22 +1383,22 @@ IceRuby::ClassInfo::printMembers(VALUE value, IceUtil::Output& out, PrintObjectH { if(base) { - base->printMembers(value, out, history); + base->printMembers(value, out, history); } for(DataMemberList::iterator q = members.begin(); q != members.end(); ++q) { - DataMemberPtr member = *q; - out << nl << member->name << " = "; - if(callRuby(rb_ivar_defined, value, member->rubyID) == Qfalse) - { - out << "<not defined>"; - } - else - { - volatile VALUE val = callRuby(rb_ivar_get, value, member->rubyID); - member->type->print(val, out, history); - } + DataMemberPtr member = *q; + out << nl << member->name << " = "; + if(callRuby(rb_ivar_defined, value, member->rubyID) == Qfalse) + { + out << "<not defined>"; + } + else + { + volatile VALUE val = callRuby(rb_ivar_get, value, member->rubyID); + member->type->print(val, out, history); + } } } @@ -1410,25 +1410,25 @@ IceRuby::ClassInfo::isA(const ClassInfoPtr& info) // if(info->isIceObject) { - return true; + return true; } else if(this == info.get()) { - return true; + return true; } else if(base && base->isA(info)) { - return true; + return true; } else if(!interfaces.empty()) { - for(ClassInfoList::iterator p = interfaces.begin(); p != interfaces.end(); ++p) - { - if((*p)->isA(info)) - { - return true; - } - } + for(ClassInfoList::iterator p = interfaces.begin(); p != interfaces.end(); ++p) + { + if((*p)->isA(info)) + { + return true; + } + } } return false; @@ -1448,16 +1448,16 @@ IceRuby::ProxyInfo::validate(VALUE val) { if(!NIL_P(val)) { - if(!checkProxy(val)) - { - return false; - } - volatile VALUE cls = CLASS_OF(val); - volatile VALUE type = callRuby(rb_const_get, cls, rb_intern("ICE_TYPE")); - assert(!NIL_P(type)); - ProxyInfoPtr info = ProxyInfoPtr::dynamicCast(getType(type)); - assert(info); - return info->classInfo->isA(classInfo); + if(!checkProxy(val)) + { + return false; + } + volatile VALUE cls = CLASS_OF(val); + volatile VALUE type = callRuby(rb_const_get, cls, rb_intern("ICE_TYPE")); + assert(!NIL_P(type)); + ProxyInfoPtr info = ProxyInfoPtr::dynamicCast(getType(type)); + assert(info); + return info->classInfo->isA(classInfo); } return true; } @@ -1467,30 +1467,30 @@ IceRuby::ProxyInfo::marshal(VALUE p, const Ice::OutputStreamPtr& os, ObjectMap*) { if(NIL_P(p)) { - os->writeProxy(0); + os->writeProxy(0); } else { - assert(checkProxy(p)); // validate() should have caught this. - os->writeProxy(getProxy(p)); + assert(checkProxy(p)); // validate() should have caught this. + os->writeProxy(getProxy(p)); } } void IceRuby::ProxyInfo::unmarshal(const Ice::InputStreamPtr& is, const UnmarshalCallbackPtr& cb, VALUE target, - void* closure) + void* closure) { Ice::ObjectPrx proxy = is->readProxy(); if(!proxy) { - cb->unmarshaled(Qnil, target, closure); - return; + cb->unmarshaled(Qnil, target, closure); + return; } if(NIL_P(rubyClass)) { - throw RubyException(rb_eRuntimeError, "class %s is declared but not defined", id.c_str()); + throw RubyException(rb_eRuntimeError, "class %s is declared but not defined", id.c_str()); } volatile VALUE p = createProxy(proxy, rubyClass); @@ -1502,17 +1502,17 @@ IceRuby::ProxyInfo::print(VALUE value, IceUtil::Output& out, PrintObjectHistory* { if(!validate(value)) { - out << "<invalid value - expected " << getId() << ">"; - return; + out << "<invalid value - expected " << getId() << ">"; + return; } if(NIL_P(value)) { - out << "<nil>"; + out << "<nil>"; } else { - out << getString(value); + out << getString(value); } } @@ -1536,7 +1536,7 @@ IceRuby::ObjectWriter::ice_preMarshal() ID id = rb_intern("ice_preMarshal"); if(callRuby(rb_respond_to, _object, id)) { - callRuby(rb_funcall, _object, id, 0); + callRuby(rb_funcall, _object, id, 0); } } @@ -1546,24 +1546,24 @@ IceRuby::ObjectWriter::write(const Ice::OutputStreamPtr& os) const ClassInfoPtr info = _info; while(info) { - os->writeTypeId(info->id); + os->writeTypeId(info->id); - os->startSlice(); - for(DataMemberList::iterator q = info->members.begin(); q != info->members.end(); ++q) - { - DataMemberPtr member = *q; - volatile VALUE val = callRuby(rb_ivar_get, _object, member->rubyID); - if(!member->type->validate(val)) - { - throw RubyException(rb_eTypeError, "invalid value for %s member `%s'", _info->id.c_str(), - member->name.c_str()); - } + os->startSlice(); + for(DataMemberList::iterator q = info->members.begin(); q != info->members.end(); ++q) + { + DataMemberPtr member = *q; + volatile VALUE val = callRuby(rb_ivar_get, _object, member->rubyID); + if(!member->type->validate(val)) + { + throw RubyException(rb_eTypeError, "invalid value for %s member `%s'", _info->id.c_str(), + member->name.c_str()); + } - member->type->marshal(val, os, _map); - } - os->endSlice(); + member->type->marshal(val, os, _map); + } + os->endSlice(); - info = info->base; + info = info->base; } // @@ -1589,7 +1589,7 @@ IceRuby::ObjectReader::ice_postUnmarshal() ID id = rb_intern("ice_postUnmarshal"); if(callRuby(rb_respond_to, _object, id)) { - callRuby(rb_funcall, _object, id, 0); + callRuby(rb_funcall, _object, id, 0); } } @@ -1601,26 +1601,26 @@ IceRuby::ObjectReader::read(const Ice::InputStreamPtr& is, bool rid) // if(_info->id != Ice::Object::ice_staticId()) { - ClassInfoPtr info = _info; - while(info) - { - if(rid) - { - is->readTypeId(); - } + ClassInfoPtr info = _info; + while(info) + { + if(rid) + { + is->readTypeId(); + } - is->startSlice(); - for(DataMemberList::iterator p = info->members.begin(); p != info->members.end(); ++p) - { - DataMemberPtr member = *p; - member->type->unmarshal(is, member, _object, 0); - } - is->endSlice(); + is->startSlice(); + for(DataMemberList::iterator p = info->members.begin(); p != info->members.end(); ++p) + { + DataMemberPtr member = *p; + member->type->unmarshal(is, member, _object, 0); + } + is->endSlice(); - rid = true; + rid = true; - info = info->base; - } + info = info->base; + } } // @@ -1628,7 +1628,7 @@ IceRuby::ObjectReader::read(const Ice::InputStreamPtr& is, bool rid) // if(rid) { - is->readTypeId(); + is->readTypeId(); } is->startSlice(); @@ -1636,7 +1636,7 @@ IceRuby::ObjectReader::read(const Ice::InputStreamPtr& is, bool rid) Ice::Int sz = is->readSize(); if(sz != 0) { - throw Ice::MarshalException(__FILE__, __LINE__); + throw Ice::MarshalException(__FILE__, __LINE__); } is->endSlice(); } @@ -1659,16 +1659,16 @@ IceRuby::ObjectReader::getObject() const IceRuby::InfoMapDestroyer::~InfoMapDestroyer() { { - for(ProxyInfoMap::iterator p = _proxyInfoMap.begin(); p != _proxyInfoMap.end(); ++p) - { - p->second->destroy(); - } + for(ProxyInfoMap::iterator p = _proxyInfoMap.begin(); p != _proxyInfoMap.end(); ++p) + { + p->second->destroy(); + } } { - for(ClassInfoMap::iterator p = _classInfoMap.begin(); p != _classInfoMap.end(); ++p) - { - p->second->destroy(); - } + for(ClassInfoMap::iterator p = _classInfoMap.begin(); p != _classInfoMap.end(); ++p) + { + p->second->destroy(); + } } _exceptionInfoMap.clear(); } @@ -1677,7 +1677,7 @@ IceRuby::InfoMapDestroyer::~InfoMapDestroyer() // ReadObjectCallback implementation. // IceRuby::ReadObjectCallback::ReadObjectCallback(const ClassInfoPtr& info, const UnmarshalCallbackPtr& cb, - VALUE target, void* closure) : + VALUE target, void* closure) : _info(info), _cb(cb), _target(target), _closure(closure) { } @@ -1687,27 +1687,27 @@ IceRuby::ReadObjectCallback::invoke(const Ice::ObjectPtr& p) { if(p) { - ObjectReaderPtr reader = ObjectReaderPtr::dynamicCast(p); - assert(reader); + ObjectReaderPtr reader = ObjectReaderPtr::dynamicCast(p); + assert(reader); - // - // Verify that the unmarshaled object is compatible with the formal type. - // - volatile VALUE obj = reader->getObject(); - if(!_info->validate(obj)) - { - Ice::UnexpectedObjectException ex(__FILE__, __LINE__); - ex.reason = "unmarshaled object is not an instance of " + _info->id; - ex.type = reader->getInfo()->getId(); - ex.expectedType = _info->id; - throw ex; - } + // + // Verify that the unmarshaled object is compatible with the formal type. + // + volatile VALUE obj = reader->getObject(); + if(!_info->validate(obj)) + { + Ice::UnexpectedObjectException ex(__FILE__, __LINE__); + ex.reason = "unmarshaled object is not an instance of " + _info->id; + ex.type = reader->getInfo()->getId(); + ex.expectedType = _info->id; + throw ex; + } - _cb->unmarshaled(obj, _target, _closure); + _cb->unmarshaled(obj, _target, _closure); } else { - _cb->unmarshaled(Qnil, _target, _closure); + _cb->unmarshaled(Qnil, _target, _closure); } } @@ -1719,7 +1719,7 @@ IceRuby::ExceptionInfo::marshal(VALUE p, const Ice::OutputStreamPtr& os, ObjectM { if(callRuby(rb_obj_is_kind_of, p, rubyClass) == Qfalse) { - throw RubyException(rb_eTypeError, "expected exception %s", id.c_str()); + throw RubyException(rb_eTypeError, "expected exception %s", id.c_str()); } os->writeBool(usesClasses); @@ -1727,24 +1727,24 @@ IceRuby::ExceptionInfo::marshal(VALUE p, const Ice::OutputStreamPtr& os, ObjectM ExceptionInfoPtr info = this; while(info) { - os->writeString(info->id); + os->writeString(info->id); - os->startSlice(); - for(DataMemberList::iterator q = info->members.begin(); q != info->members.end(); ++q) - { - DataMemberPtr member = *q; - volatile VALUE val = callRuby(rb_ivar_get, p, member->rubyID); - if(!member->type->validate(val)) - { - throw RubyException(rb_eTypeError, "invalid value for %s member `%s'", id.c_str(), - member->name.c_str()); - } + os->startSlice(); + for(DataMemberList::iterator q = info->members.begin(); q != info->members.end(); ++q) + { + DataMemberPtr member = *q; + volatile VALUE val = callRuby(rb_ivar_get, p, member->rubyID); + if(!member->type->validate(val)) + { + throw RubyException(rb_eTypeError, "invalid value for %s member `%s'", id.c_str(), + member->name.c_str()); + } - member->type->marshal(val, os, objectMap); - } - os->endSlice(); + member->type->marshal(val, os, objectMap); + } + os->endSlice(); - info = info->base; + info = info->base; } } @@ -1759,19 +1759,19 @@ IceRuby::ExceptionInfo::unmarshal(const Ice::InputStreamPtr& is) ExceptionInfoPtr info = this; while(info) { - is->startSlice(); - for(DataMemberList::iterator q = info->members.begin(); q != info->members.end(); ++q) - { - DataMemberPtr member = *q; - member->type->unmarshal(is, member, obj, 0); - } - is->endSlice(); + is->startSlice(); + for(DataMemberList::iterator q = info->members.begin(); q != info->members.end(); ++q) + { + DataMemberPtr member = *q; + member->type->unmarshal(is, member, obj, 0); + } + is->endSlice(); - info = info->base; - if(info) - { - is->readString(); // Read the ID of the next slice. - } + info = info->base; + if(info) + { + is->readString(); // Read the ID of the next slice. + } } return obj; @@ -1782,8 +1782,8 @@ IceRuby::ExceptionInfo::print(VALUE value, IceUtil::Output& out) { if(callRuby(rb_obj_is_kind_of, value, rubyClass) == Qfalse) { - out << "<invalid value - expected " << id << ">"; - return; + out << "<invalid value - expected " << id << ">"; + return; } PrintObjectHistory history; @@ -1800,22 +1800,22 @@ IceRuby::ExceptionInfo::printMembers(VALUE value, IceUtil::Output& out, PrintObj { if(base) { - base->printMembers(value, out, history); + base->printMembers(value, out, history); } for(DataMemberList::iterator q = members.begin(); q != members.end(); ++q) { - DataMemberPtr member = *q; - out << nl << member->name << " = "; - if(callRuby(rb_ivar_defined, value, member->rubyID) == Qfalse) - { - out << "<not defined>"; - } - else - { - volatile VALUE val = callRuby(rb_ivar_get, value, member->rubyID); - member->type->print(val, out, history); - } + DataMemberPtr member = *q; + out << nl << member->name << " = "; + if(callRuby(rb_ivar_defined, value, member->rubyID) == Qfalse) + { + out << "<not defined>"; + } + else + { + volatile VALUE val = callRuby(rb_ivar_get, value, member->rubyID); + member->type->print(val, out, history); + } } } @@ -1825,18 +1825,18 @@ IceRuby_defineEnum(VALUE /*self*/, VALUE id, VALUE type, VALUE enumerators) { ICE_RUBY_TRY { - EnumInfoPtr info = new EnumInfo; - info->id = getString(id); - info->rubyClass = type; + EnumInfoPtr info = new EnumInfo; + info->id = getString(id); + info->rubyClass = type; - volatile VALUE arr = callRuby(rb_check_array_type, enumerators); - assert(!NIL_P(arr)); - for(long i = 0; i < RARRAY(arr)->len; ++i) - { - info->enumerators.push_back(RARRAY(arr)->ptr[i]); - } + volatile VALUE arr = callRuby(rb_check_array_type, enumerators); + assert(!NIL_P(arr)); + for(long i = 0; i < RARRAY(arr)->len; ++i) + { + info->enumerators.push_back(RARRAY(arr)->ptr[i]); + } - return createType(info); + return createType(info); } ICE_RUBY_CATCH return Qnil; @@ -1848,26 +1848,26 @@ IceRuby_defineStruct(VALUE /*self*/, VALUE id, VALUE type, VALUE members) { ICE_RUBY_TRY { - StructInfoPtr info = new StructInfo; - info->id = getString(id); - info->rubyClass = type; - - volatile VALUE arr = callRuby(rb_check_array_type, members); - assert(!NIL_P(arr)); - for(long i = 0; i < RARRAY(arr)->len; ++i) - { - volatile VALUE m = callRuby(rb_check_array_type, RARRAY(arr)->ptr[i]); - assert(!NIL_P(m)); - assert(RARRAY(m)->len == 2); - DataMemberPtr member = new DataMember; - member->name = getString(RARRAY(m)->ptr[0]); - member->type = getType(RARRAY(m)->ptr[1]); - string s = "@" + member->name; - member->rubyID = rb_intern(s.c_str()); - info->members.push_back(member); - } - - return createType(info); + StructInfoPtr info = new StructInfo; + info->id = getString(id); + info->rubyClass = type; + + volatile VALUE arr = callRuby(rb_check_array_type, members); + assert(!NIL_P(arr)); + for(long i = 0; i < RARRAY(arr)->len; ++i) + { + volatile VALUE m = callRuby(rb_check_array_type, RARRAY(arr)->ptr[i]); + assert(!NIL_P(m)); + assert(RARRAY(m)->len == 2); + DataMemberPtr member = new DataMember; + member->name = getString(RARRAY(m)->ptr[0]); + member->type = getType(RARRAY(m)->ptr[1]); + string s = "@" + member->name; + member->rubyID = rb_intern(s.c_str()); + info->members.push_back(member); + } + + return createType(info); } ICE_RUBY_CATCH return Qnil; @@ -1879,11 +1879,11 @@ IceRuby_defineSequence(VALUE /*self*/, VALUE id, VALUE elementType) { ICE_RUBY_TRY { - SequenceInfoPtr info = new SequenceInfo; - info->id = getString(id); - info->elementType = getType(elementType); + SequenceInfoPtr info = new SequenceInfo; + info->id = getString(id); + info->elementType = getType(elementType); - return createType(info); + return createType(info); } ICE_RUBY_CATCH return Qnil; @@ -1895,12 +1895,12 @@ IceRuby_defineDictionary(VALUE /*self*/, VALUE id, VALUE keyType, VALUE valueTyp { ICE_RUBY_TRY { - DictionaryInfoPtr info = new DictionaryInfo; - info->id = getString(id); - info->keyType = getType(keyType); - info->valueType = getType(valueType); + DictionaryInfoPtr info = new DictionaryInfo; + info->id = getString(id); + info->keyType = getType(keyType); + info->valueType = getType(valueType); - return createType(info); + return createType(info); } ICE_RUBY_CATCH return Qnil; @@ -1912,20 +1912,20 @@ IceRuby_declareProxy(VALUE /*self*/, VALUE id) { ICE_RUBY_TRY { - string proxyId = getString(id); - proxyId += "Prx"; + string proxyId = getString(id); + proxyId += "Prx"; - ProxyInfoPtr info = lookupProxyInfo(proxyId); - if(!info) - { - info = new ProxyInfo; - info->id = proxyId; - info->rubyClass = Qnil; - info->typeObj = createType(info); - addProxyInfo(proxyId, info); - } + ProxyInfoPtr info = lookupProxyInfo(proxyId); + if(!info) + { + info = new ProxyInfo; + info->id = proxyId; + info->rubyClass = Qnil; + info->typeObj = createType(info); + addProxyInfo(proxyId, info); + } - return info->typeObj; + return info->typeObj; } ICE_RUBY_CATCH return Qnil; @@ -1937,20 +1937,20 @@ IceRuby_declareClass(VALUE /*self*/, VALUE id) { ICE_RUBY_TRY { - string idstr = getString(id); - ClassInfoPtr info = lookupClassInfo(idstr); - if(!info) - { - info = new ClassInfo; - info->id = idstr; - info->isIceObject = idstr == "::Ice::Object"; - info->rubyClass = Qnil; - info->typeObj = createType(info); - info->defined = false; - addClassInfo(idstr, info); - } - - return info->typeObj; + string idstr = getString(id); + ClassInfoPtr info = lookupClassInfo(idstr); + if(!info) + { + info = new ClassInfo; + info->id = idstr; + info->isIceObject = idstr == "::Ice::Object"; + info->rubyClass = Qnil; + info->typeObj = createType(info); + info->defined = false; + addClassInfo(idstr, info); + } + + return info->typeObj; } ICE_RUBY_CATCH return Qnil; @@ -1962,41 +1962,41 @@ IceRuby_defineException(VALUE /*self*/, VALUE id, VALUE type, VALUE base, VALUE { ICE_RUBY_TRY { - ExceptionInfoPtr info = new ExceptionInfo; - info->id = getString(id); - - if(!NIL_P(base)) - { - info->base = ExceptionInfoPtr::dynamicCast(getException(base)); - assert(info->base); - } - - info->usesClasses = false; - - volatile VALUE arr = callRuby(rb_check_array_type, members); - assert(!NIL_P(arr)); - for(long i = 0; i < RARRAY(arr)->len; ++i) - { - volatile VALUE m = callRuby(rb_check_array_type, RARRAY(arr)->ptr[i]); - assert(!NIL_P(m)); - assert(RARRAY(m)->len == 2); - DataMemberPtr member = new DataMember; - member->name = getString(RARRAY(m)->ptr[0]); - member->type = getType(RARRAY(m)->ptr[1]); - string s = "@" + member->name; - member->rubyID = rb_intern(s.c_str()); - info->members.push_back(member); - if(!info->usesClasses) - { - info->usesClasses = member->type->usesClasses(); - } - } - - info->rubyClass = type; - - addExceptionInfo(info->id, info); - - return createException(info); + ExceptionInfoPtr info = new ExceptionInfo; + info->id = getString(id); + + if(!NIL_P(base)) + { + info->base = ExceptionInfoPtr::dynamicCast(getException(base)); + assert(info->base); + } + + info->usesClasses = false; + + volatile VALUE arr = callRuby(rb_check_array_type, members); + assert(!NIL_P(arr)); + for(long i = 0; i < RARRAY(arr)->len; ++i) + { + volatile VALUE m = callRuby(rb_check_array_type, RARRAY(arr)->ptr[i]); + assert(!NIL_P(m)); + assert(RARRAY(m)->len == 2); + DataMemberPtr member = new DataMember; + member->name = getString(RARRAY(m)->ptr[0]); + member->type = getType(RARRAY(m)->ptr[1]); + string s = "@" + member->name; + member->rubyID = rb_intern(s.c_str()); + info->members.push_back(member); + if(!info->usesClasses) + { + info->usesClasses = member->type->usesClasses(); + } + } + + info->rubyClass = type; + + addExceptionInfo(info->id, info); + + return createException(info); } ICE_RUBY_CATCH return Qnil; @@ -2008,12 +2008,12 @@ IceRuby_TypeInfo_defineProxy(VALUE self, VALUE type, VALUE classInfo) { ICE_RUBY_TRY { - ProxyInfoPtr info = ProxyInfoPtr::dynamicCast(getType(self)); - assert(info); + ProxyInfoPtr info = ProxyInfoPtr::dynamicCast(getType(self)); + assert(info); - info->rubyClass = type; - info->classInfo = ClassInfoPtr::dynamicCast(getType(classInfo)); - assert(info->classInfo); + info->rubyClass = type; + info->classInfo = ClassInfoPtr::dynamicCast(getType(classInfo)); + assert(info->classInfo); } ICE_RUBY_CATCH return Qnil; @@ -2025,46 +2025,46 @@ IceRuby_TypeInfo_defineClass(VALUE self, VALUE type, VALUE isAbstract, VALUE bas { ICE_RUBY_TRY { - ClassInfoPtr info = ClassInfoPtr::dynamicCast(getType(self)); - assert(info); - - info->isAbstract = isAbstract == Qtrue; - - if(!NIL_P(base)) - { - info->base = ClassInfoPtr::dynamicCast(getType(base)); - assert(info->base); - } - - long i; - volatile VALUE arr; - - arr = callRuby(rb_check_array_type, interfaces); - assert(!NIL_P(arr)); - for(i = 0; i < RARRAY(arr)->len; ++i) - { - ClassInfoPtr iface = ClassInfoPtr::dynamicCast(getType(RARRAY(arr)->ptr[i])); - assert(iface); - info->interfaces.push_back(iface); - } - - arr = callRuby(rb_check_array_type, members); - assert(!NIL_P(arr)); - for(i = 0; i < RARRAY(arr)->len; ++i) - { - volatile VALUE m = callRuby(rb_check_array_type, RARRAY(arr)->ptr[i]); - assert(!NIL_P(m)); - assert(RARRAY(m)->len == 2); - DataMemberPtr member = new DataMember; - member->name = getString(RARRAY(m)->ptr[0]); - member->type = getType(RARRAY(m)->ptr[1]); - string s = "@" + member->name; - member->rubyID = rb_intern(s.c_str()); - info->members.push_back(member); - } - - info->rubyClass = type; - info->defined = true; + ClassInfoPtr info = ClassInfoPtr::dynamicCast(getType(self)); + assert(info); + + info->isAbstract = isAbstract == Qtrue; + + if(!NIL_P(base)) + { + info->base = ClassInfoPtr::dynamicCast(getType(base)); + assert(info->base); + } + + long i; + volatile VALUE arr; + + arr = callRuby(rb_check_array_type, interfaces); + assert(!NIL_P(arr)); + for(i = 0; i < RARRAY(arr)->len; ++i) + { + ClassInfoPtr iface = ClassInfoPtr::dynamicCast(getType(RARRAY(arr)->ptr[i])); + assert(iface); + info->interfaces.push_back(iface); + } + + arr = callRuby(rb_check_array_type, members); + assert(!NIL_P(arr)); + for(i = 0; i < RARRAY(arr)->len; ++i) + { + volatile VALUE m = callRuby(rb_check_array_type, RARRAY(arr)->ptr[i]); + assert(!NIL_P(m)); + assert(RARRAY(m)->len == 2); + DataMemberPtr member = new DataMember; + member->name = getString(RARRAY(m)->ptr[0]); + member->type = getType(RARRAY(m)->ptr[1]); + string s = "@" + member->name; + member->rubyID = rb_intern(s.c_str()); + info->members.push_back(member); + } + + info->rubyClass = type; + info->defined = true; } ICE_RUBY_CATCH return Qnil; @@ -2076,16 +2076,16 @@ IceRuby_stringify(VALUE /*self*/, VALUE obj, VALUE type) { ICE_RUBY_TRY { - TypeInfoPtr info = getType(type); + TypeInfoPtr info = getType(type); - ostringstream ostr; - IceUtil::Output out(ostr); - PrintObjectHistory history; - history.index = 0; - info->print(obj, out, &history); + ostringstream ostr; + IceUtil::Output out(ostr); + PrintObjectHistory history; + history.index = 0; + info->print(obj, out, &history); - string str = ostr.str(); - return createString(str); + string str = ostr.str(); + return createString(str); } ICE_RUBY_CATCH return Qnil; @@ -2097,16 +2097,16 @@ IceRuby_stringifyException(VALUE /*self*/, VALUE ex) { ICE_RUBY_TRY { - volatile VALUE cls = CLASS_OF(ex); - volatile VALUE type = callRuby(rb_const_get, cls, rb_intern("ICE_TYPE")); - ExceptionInfoPtr info = getException(type); + volatile VALUE cls = CLASS_OF(ex); + volatile VALUE type = callRuby(rb_const_get, cls, rb_intern("ICE_TYPE")); + ExceptionInfoPtr info = getException(type); - ostringstream ostr; - IceUtil::Output out(ostr); - info->print(ex, out); + ostringstream ostr; + IceUtil::Output out(ostr); + info->print(ex, out); - string str = ostr.str(); - return createString(str); + string str = ostr.str(); + return createString(str); } ICE_RUBY_CATCH return Qnil; @@ -2121,7 +2121,7 @@ IceRuby::lookupClassInfo(const string& id) ClassInfoMap::iterator p = _classInfoMap.find(id); if(p != _classInfoMap.end()) { - return p->second; + return p->second; } return 0; } @@ -2135,7 +2135,7 @@ IceRuby::lookupExceptionInfo(const string& id) ExceptionInfoMap::iterator p = _exceptionInfoMap.find(id); if(p != _exceptionInfoMap.end()) { - return p->second; + return p->second; } return 0; } diff --git a/rb/src/IceRuby/Types.h b/rb/src/IceRuby/Types.h index d69fb064810..91e8e2d87a0 100644 --- a/rb/src/IceRuby/Types.h +++ b/rb/src/IceRuby/Types.h @@ -228,7 +228,7 @@ private: void marshalPrimitiveSequence(const PrimitiveInfoPtr&, VALUE, const Ice::OutputStreamPtr&); void unmarshalPrimitiveSequence(const PrimitiveInfoPtr&, const Ice::InputStreamPtr&, const UnmarshalCallbackPtr&, - VALUE, void*); + VALUE, void*); }; typedef IceUtil::Handle<SequenceInfo> SequenceInfoPtr; diff --git a/rb/src/IceRuby/Util.cpp b/rb/src/IceRuby/Util.cpp index 272bb95516b..b02d2efcaba 100644 --- a/rb/src/IceRuby/Util.cpp +++ b/rb/src/IceRuby/Util.cpp @@ -83,19 +83,19 @@ IceRuby::getInteger(VALUE val) { if(!FIXNUM_P(val) && TYPE(val) != T_BIGNUM) { - val = callRuby(rb_Integer, val); + val = callRuby(rb_Integer, val); } if(FIXNUM_P(val)) { - return FIX2LONG(val); + return FIX2LONG(val); } else if(TYPE(val) == T_BIGNUM) { - Ice::Long l = getLong(val); - if(l >= static_cast<Ice::Long>(INT_MIN) && l <= static_cast<Ice::Long>(INT_MAX)) - { - return static_cast<long>(l); - } + Ice::Long l = getLong(val); + if(l >= static_cast<Ice::Long>(INT_MIN) && l <= static_cast<Ice::Long>(INT_MAX)) + { + return static_cast<long>(l); + } } throw RubyException(rb_eTypeError, "unable to convert value to an integer"); } @@ -114,37 +114,37 @@ IceRuby::getLong(VALUE val) volatile VALUE v = callRuby(rb_Integer, val); if(NIL_P(v)) { - throw RubyException(rb_eTypeError, "unable to convert value to a long"); + throw RubyException(rb_eTypeError, "unable to convert value to a long"); } if(FIXNUM_P(v)) { - return FIX2LONG(v); + return FIX2LONG(v); } else { - assert(TYPE(v) == T_BIGNUM); - long len = RBIGNUM(v)->len; - if(len > SIZEOF_LONG_LONG/SIZEOF_BDIGITS) - { - throw RubyException(rb_eRangeError, "bignum too big to convert into long"); - } - BDIGIT *ds = BDIGITS(v); - BDIGIT_DBL num = 0; - while(len--) - { - num = BIGUP(num); - num += ds[len]; - } - Ice::Long l = static_cast<Ice::Long>(num); - if(l < 0 && (RBIGNUM(v)->sign || l != LLONG_MIN)) - { - throw RubyException(rb_eRangeError, "bignum too big to convert into long"); - } - if (!RBIGNUM(v)->sign) - { - return -l; - } - return l; + assert(TYPE(v) == T_BIGNUM); + long len = RBIGNUM(v)->len; + if(len > SIZEOF_LONG_LONG/SIZEOF_BDIGITS) + { + throw RubyException(rb_eRangeError, "bignum too big to convert into long"); + } + BDIGIT *ds = BDIGITS(v); + BDIGIT_DBL num = 0; + while(len--) + { + num = BIGUP(num); + num += ds[len]; + } + Ice::Long l = static_cast<Ice::Long>(num); + if(l < 0 && (RBIGNUM(v)->sign || l != LLONG_MIN)) + { + throw RubyException(rb_eRangeError, "bignum too big to convert into long"); + } + if (!RBIGNUM(v)->sign) + { + return -l; + } + return l; } } @@ -154,12 +154,12 @@ IceRuby::arrayToStringSeq(VALUE val, vector<string>& seq) volatile VALUE arr = callRuby(rb_check_array_type, val); if(NIL_P(arr)) { - return false; + return false; } for(long i = 0; i < RARRAY(arr)->len; ++i) { - string s = getString(RARRAY(arr)->ptr[i]); - seq.push_back(getString(RARRAY(arr)->ptr[i])); + string s = getString(RARRAY(arr)->ptr[i]); + seq.push_back(getString(RARRAY(arr)->ptr[i])); } return true; } @@ -171,7 +171,7 @@ IceRuby::stringSeqToArray(const vector<string>& seq) long i = 0; for(vector<string>::const_iterator p = seq.begin(); p != seq.end(); ++p, ++i) { - RARRAY(result)->ptr[i] = createString(*p); + RARRAY(result)->ptr[i] = createString(*p); } RARRAY(result)->len = static_cast<long>(seq.size()); return result; @@ -188,9 +188,9 @@ struct HashToContextIterator : public IceRuby::HashIterator virtual void element(VALUE key, VALUE value) { - string kstr = IceRuby::getString(key); - string vstr = IceRuby::getString(value); - ctx[kstr] = vstr; + string kstr = IceRuby::getString(key); + string vstr = IceRuby::getString(value); + ctx[kstr] = vstr; } Ice::Context& ctx; @@ -203,11 +203,11 @@ IceRuby::hashToContext(VALUE val, Ice::Context& ctx) { if(TYPE(val) != T_HASH) { - val = callRuby(rb_convert_type, val, T_HASH, "Hash", "to_hash"); - if(NIL_P(val)) - { - return false; - } + val = callRuby(rb_convert_type, val, T_HASH, "Hash", "to_hash"); + if(NIL_P(val)) + { + return false; + } } HashToContextIterator iter(ctx); hashIterate(val, iter); @@ -220,9 +220,9 @@ IceRuby::contextToHash(const Ice::Context& ctx) volatile VALUE result = callRuby(rb_hash_new); for(Ice::Context::const_iterator p = ctx.begin(); p != ctx.end(); ++p) { - volatile VALUE key = callRuby(rb_str_new, p->first.c_str(), static_cast<long>(p->first.size())); - volatile VALUE value = callRuby(rb_str_new, p->second.c_str(), static_cast<long>(p->second.size())); - callRuby(rb_hash_aset, result, key, value); + volatile VALUE key = callRuby(rb_str_new, p->first.c_str(), static_cast<long>(p->first.size())); + volatile VALUE value = callRuby(rb_str_new, p->second.c_str(), static_cast<long>(p->second.size())); + callRuby(rb_hash_aset, result, key, value); } return result; } @@ -239,8 +239,8 @@ IceRuby_Util_hash_foreach_callback(VALUE val, VALUE arg) // ICE_RUBY_TRY { - IceRuby::HashIterator* iter = reinterpret_cast<IceRuby::HashIterator*>(arg); - iter->element(key, value); + IceRuby::HashIterator* iter = reinterpret_cast<IceRuby::HashIterator*>(arg); + iter->element(key, value); } ICE_RUBY_CATCH return val; @@ -256,8 +256,8 @@ IceRuby::hashIterate(VALUE h, HashIterator& iter) { assert(TYPE(h) == T_HASH); callRuby(rb_iterate, rb_each, h, - reinterpret_cast<ICE_RUBY_HASH_FOREACH_CALLBACK>(IceRuby_Util_hash_foreach_callback), - reinterpret_cast<VALUE>(&iter)); + reinterpret_cast<ICE_RUBY_HASH_FOREACH_CALLBACK>(IceRuby_Util_hash_foreach_callback), + reinterpret_cast<VALUE>(&iter)); } Ice::Identity @@ -268,7 +268,7 @@ IceRuby::getIdentity(VALUE v) if(callRuby(rb_obj_is_kind_of, v, cls) == Qfalse) { - throw RubyException(rb_eTypeError, "value is not an Ice::Identity"); + throw RubyException(rb_eTypeError, "value is not an Ice::Identity"); } volatile VALUE name = callRuby(rb_iv_get, v, "@name"); @@ -276,19 +276,19 @@ IceRuby::getIdentity(VALUE v) if(!NIL_P(category) && !isString(category)) { - throw RubyException(rb_eTypeError, "identity category must be a string"); + throw RubyException(rb_eTypeError, "identity category must be a string"); } if(NIL_P(name) || !isString(name)) { - throw RubyException(rb_eTypeError, "identity name must be a string"); + throw RubyException(rb_eTypeError, "identity name must be a string"); } Ice::Identity result; result.name = getString(name); if(!NIL_P(category)) { - result.category = getString(category); + result.category = getString(category); } return result; } @@ -314,7 +314,7 @@ IceRuby::callProtected(RubyFunction func, VALUE arg) volatile VALUE result = rb_protect(func, arg, &error); if(error) { - throw RubyException(); + throw RubyException(); } return result; } @@ -327,166 +327,166 @@ setExceptionMembers(const Ice::LocalException& ex, VALUE p) // try { - ex.ice_throw(); + ex.ice_throw(); } catch(const Ice::InitializationException& e) { - volatile VALUE v = createString(e.reason); - callRuby(rb_iv_set, p, "@reason", v); + volatile VALUE v = createString(e.reason); + callRuby(rb_iv_set, p, "@reason", v); } catch(const Ice::PluginInitializationException& e) { - volatile VALUE v = createString(e.reason); - callRuby(rb_iv_set, p, "@reason", v); + volatile VALUE v = createString(e.reason); + callRuby(rb_iv_set, p, "@reason", v); } catch(const Ice::AlreadyRegisteredException& e) { - volatile VALUE v; - v = createString(e.kindOfObject); - callRuby(rb_iv_set, p, "@kindOfObject", v); - v = createString(e.id); - callRuby(rb_iv_set, p, "@id", v); + volatile VALUE v; + v = createString(e.kindOfObject); + callRuby(rb_iv_set, p, "@kindOfObject", v); + v = createString(e.id); + callRuby(rb_iv_set, p, "@id", v); } catch(const Ice::NotRegisteredException& e) { - volatile VALUE v; - v = createString(e.kindOfObject); - callRuby(rb_iv_set, p, "@kindOfObject", v); - v = createString(e.id); - callRuby(rb_iv_set, p, "@id", v); + volatile VALUE v; + v = createString(e.kindOfObject); + callRuby(rb_iv_set, p, "@kindOfObject", v); + v = createString(e.id); + callRuby(rb_iv_set, p, "@id", v); } catch(const Ice::TwowayOnlyException& e) { - volatile VALUE v = createString(e.operation); - callRuby(rb_iv_set, p, "@operation", v); + volatile VALUE v = createString(e.operation); + callRuby(rb_iv_set, p, "@operation", v); } catch(const Ice::UnknownException& e) { - volatile VALUE v = createString(e.unknown); - callRuby(rb_iv_set, p, "@unknown", v); + volatile VALUE v = createString(e.unknown); + callRuby(rb_iv_set, p, "@unknown", v); } catch(const Ice::ObjectAdapterDeactivatedException& e) { - volatile VALUE v = createString(e.name); - callRuby(rb_iv_set, p, "@name", v); + volatile VALUE v = createString(e.name); + callRuby(rb_iv_set, p, "@name", v); } catch(const Ice::ObjectAdapterIdInUseException& e) { - volatile VALUE v = createString(e.id); - callRuby(rb_iv_set, p, "@id", v); + volatile VALUE v = createString(e.id); + callRuby(rb_iv_set, p, "@id", v); } catch(const Ice::NoEndpointException& e) { - volatile VALUE v = createString(e.proxy); - callRuby(rb_iv_set, p, "@proxy", v); + volatile VALUE v = createString(e.proxy); + callRuby(rb_iv_set, p, "@proxy", v); } catch(const Ice::EndpointParseException& e) { - volatile VALUE v = createString(e.str); - callRuby(rb_iv_set, p, "@str", v); + volatile VALUE v = createString(e.str); + callRuby(rb_iv_set, p, "@str", v); } catch(const Ice::IdentityParseException& e) { - volatile VALUE v = createString(e.str); - callRuby(rb_iv_set, p, "@str", v); + volatile VALUE v = createString(e.str); + callRuby(rb_iv_set, p, "@str", v); } catch(const Ice::ProxyParseException& e) { - volatile VALUE v = createString(e.str); - callRuby(rb_iv_set, p, "@str", v); + volatile VALUE v = createString(e.str); + callRuby(rb_iv_set, p, "@str", v); } catch(const Ice::IllegalIdentityException& e) { - volatile VALUE v = IceRuby::createIdentity(e.id); - callRuby(rb_iv_set, p, "@id", v); + volatile VALUE v = IceRuby::createIdentity(e.id); + callRuby(rb_iv_set, p, "@id", v); } catch(const Ice::RequestFailedException& e) { - volatile VALUE v; - v = IceRuby::createIdentity(e.id); - callRuby(rb_iv_set, p, "@id", v); - v = createString(e.facet); - callRuby(rb_iv_set, p, "@facet", v); - v = createString(e.operation); - callRuby(rb_iv_set, p, "@operation", v); + volatile VALUE v; + v = IceRuby::createIdentity(e.id); + callRuby(rb_iv_set, p, "@id", v); + v = createString(e.facet); + callRuby(rb_iv_set, p, "@facet", v); + v = createString(e.operation); + callRuby(rb_iv_set, p, "@operation", v); } catch(const Ice::FileException& e) { - volatile VALUE v = INT2FIX(e.error); - callRuby(rb_iv_set, p, "@error", v); - v = createString(e.path); - callRuby(rb_iv_set, p, "@path", v); + volatile VALUE v = INT2FIX(e.error); + callRuby(rb_iv_set, p, "@error", v); + v = createString(e.path); + callRuby(rb_iv_set, p, "@path", v); } catch(const Ice::SyscallException& e) // This must appear after all subclasses of SyscallException. { - volatile VALUE v = INT2FIX(e.error); - callRuby(rb_iv_set, p, "@error", v); + volatile VALUE v = INT2FIX(e.error); + callRuby(rb_iv_set, p, "@error", v); } catch(const Ice::DNSException& e) { - volatile VALUE v; - v = INT2FIX(e.error); - callRuby(rb_iv_set, p, "@error", v); - v = createString(e.host); - callRuby(rb_iv_set, p, "@host", v); + volatile VALUE v; + v = INT2FIX(e.error); + callRuby(rb_iv_set, p, "@error", v); + v = createString(e.host); + callRuby(rb_iv_set, p, "@host", v); } catch(const Ice::UnsupportedProtocolException& e) { - callRuby(rb_iv_set, p, "@badMajor", INT2FIX(e.badMajor)); - callRuby(rb_iv_set, p, "@badMinor", INT2FIX(e.badMinor)); - callRuby(rb_iv_set, p, "@major", INT2FIX(e.major)); - callRuby(rb_iv_set, p, "@minor", INT2FIX(e.minor)); + callRuby(rb_iv_set, p, "@badMajor", INT2FIX(e.badMajor)); + callRuby(rb_iv_set, p, "@badMinor", INT2FIX(e.badMinor)); + callRuby(rb_iv_set, p, "@major", INT2FIX(e.major)); + callRuby(rb_iv_set, p, "@minor", INT2FIX(e.minor)); } catch(const Ice::UnsupportedEncodingException& e) { - callRuby(rb_iv_set, p, "@badMajor", INT2FIX(e.badMajor)); - callRuby(rb_iv_set, p, "@badMinor", INT2FIX(e.badMinor)); - callRuby(rb_iv_set, p, "@major", INT2FIX(e.major)); - callRuby(rb_iv_set, p, "@minor", INT2FIX(e.minor)); + callRuby(rb_iv_set, p, "@badMajor", INT2FIX(e.badMajor)); + callRuby(rb_iv_set, p, "@badMinor", INT2FIX(e.badMinor)); + callRuby(rb_iv_set, p, "@major", INT2FIX(e.major)); + callRuby(rb_iv_set, p, "@minor", INT2FIX(e.minor)); } catch(const Ice::NoObjectFactoryException& e) { - volatile VALUE v; - v = createString(e.reason); - callRuby(rb_iv_set, p, "@reason", v); - v = createString(e.type); - callRuby(rb_iv_set, p, "@type", v); + volatile VALUE v; + v = createString(e.reason); + callRuby(rb_iv_set, p, "@reason", v); + v = createString(e.type); + callRuby(rb_iv_set, p, "@type", v); } catch(const Ice::UnexpectedObjectException& e) { - volatile VALUE v; - v = createString(e.reason); - callRuby(rb_iv_set, p, "@reason", v); - v = createString(e.type); - callRuby(rb_iv_set, p, "@type", v); - v = createString(e.expectedType); - callRuby(rb_iv_set, p, "@expectedType", v); + volatile VALUE v; + v = createString(e.reason); + callRuby(rb_iv_set, p, "@reason", v); + v = createString(e.type); + callRuby(rb_iv_set, p, "@type", v); + v = createString(e.expectedType); + callRuby(rb_iv_set, p, "@expectedType", v); } catch(const Ice::ProtocolException& e) // This must appear after all subclasses of ProtocolException. { - volatile VALUE v = createString(e.reason); - callRuby(rb_iv_set, p, "@reason", v); + volatile VALUE v = createString(e.reason); + callRuby(rb_iv_set, p, "@reason", v); } catch(const Ice::FeatureNotSupportedException& e) { - volatile VALUE v = createString(e.unsupportedFeature); - callRuby(rb_iv_set, p, "@unsupportedFeature", v); + volatile VALUE v = createString(e.unsupportedFeature); + callRuby(rb_iv_set, p, "@unsupportedFeature", v); } catch(const Ice::NotSetException& e) { - volatile VALUE v = createString(e.key); - callRuby(rb_iv_set, p, "@key", v); + volatile VALUE v = createString(e.key); + callRuby(rb_iv_set, p, "@key", v); } catch(const Ice::SecurityException& e) { - volatile VALUE v = createString(e.reason); - callRuby(rb_iv_set, p, "@reason", v); + volatile VALUE v = createString(e.reason); + callRuby(rb_iv_set, p, "@reason", v); } catch(const Ice::LocalException&) { - // - // Nothing to do. - // + // + // Nothing to do. + // } } @@ -500,23 +500,23 @@ IceRuby::convertLocalException(const Ice::LocalException& ex) // try { - string name = ex.ice_name(); - volatile VALUE cls = callRuby(rb_path2class, name.c_str()); - if(NIL_P(cls)) - { - throw RubyException(rb_eRuntimeError, "exception class `%s' not found", name.c_str()); - } - volatile VALUE result = callRuby(rb_class_new_instance, 0, reinterpret_cast<VALUE*>(0), cls); - setExceptionMembers(ex, result); - return result; + string name = ex.ice_name(); + volatile VALUE cls = callRuby(rb_path2class, name.c_str()); + if(NIL_P(cls)) + { + throw RubyException(rb_eRuntimeError, "exception class `%s' not found", name.c_str()); + } + volatile VALUE result = callRuby(rb_class_new_instance, 0, reinterpret_cast<VALUE*>(0), cls); + setExceptionMembers(ex, result); + return result; } catch(const RubyException& e) { - return e.ex; + return e.ex; } catch(...) { - string msg = "failure occurred while converting exception " + ex.ice_name(); - return rb_exc_new2(rb_eRuntimeError, msg.c_str()); + string msg = "failure occurred while converting exception " + ex.ice_name(); + return rb_exc_new2(rb_eRuntimeError, msg.c_str()); } } diff --git a/rb/src/IceRuby/Util.h b/rb/src/IceRuby/Util.h index f4f16b68282..2e3e385f163 100644 --- a/rb/src/IceRuby/Util.h +++ b/rb/src/IceRuby/Util.h @@ -300,7 +300,7 @@ VALUE convertLocalException(const Ice::LocalException&); goto __ice_start; \ \ __ice_handle_exception: \ - rb_exc_raise(__ice_ex); \ + rb_exc_raise(__ice_ex); \ \ __ice_start: \ try @@ -312,28 +312,28 @@ VALUE convertLocalException(const Ice::LocalException&); #define ICE_RUBY_CATCH \ catch(const ::IceRuby::RubyException& ex) \ { \ - ICE_RUBY_RETHROW(ex.ex); \ + ICE_RUBY_RETHROW(ex.ex); \ } \ catch(const ::Ice::LocalException& ex) \ { \ - ICE_RUBY_RETHROW(convertLocalException(ex)); \ + ICE_RUBY_RETHROW(convertLocalException(ex)); \ } \ catch(const ::Ice::Exception& ex) \ { \ - string __ice_msg = "unknown Ice exception: " + ex.ice_name(); \ - ICE_RUBY_RETHROW(rb_exc_new2(rb_eRuntimeError, __ice_msg.c_str())); \ + string __ice_msg = "unknown Ice exception: " + ex.ice_name(); \ + ICE_RUBY_RETHROW(rb_exc_new2(rb_eRuntimeError, __ice_msg.c_str())); \ } \ catch(const std::bad_alloc& ex) \ { \ - ICE_RUBY_RETHROW(rb_exc_new2(rb_eNoMemError, ex.what())); \ + ICE_RUBY_RETHROW(rb_exc_new2(rb_eNoMemError, ex.what())); \ } \ catch(const std::exception& ex) \ { \ - ICE_RUBY_RETHROW(rb_exc_new2(rb_eRuntimeError, ex.what())); \ + ICE_RUBY_RETHROW(rb_exc_new2(rb_eRuntimeError, ex.what())); \ } \ catch(...) \ { \ - ICE_RUBY_RETHROW(rb_exc_new2(rb_eRuntimeError, "caught unknown C++ exception")); \ + ICE_RUBY_RETHROW(rb_exc_new2(rb_eRuntimeError, "caught unknown C++ exception")); \ } #endif |