diff options
Diffstat (limited to 'ruby/src/IceRuby/Communicator.cpp')
-rw-r--r-- | ruby/src/IceRuby/Communicator.cpp | 54 |
1 files changed, 38 insertions, 16 deletions
diff --git a/ruby/src/IceRuby/Communicator.cpp b/ruby/src/IceRuby/Communicator.cpp index 7a7635c1dbf..3d90f420464 100644 --- a/ruby/src/IceRuby/Communicator.cpp +++ b/ruby/src/IceRuby/Communicator.cpp @@ -10,11 +10,12 @@ #include <Communicator.h> #include <ImplicitContext.h> #include <Logger.h> -#include <ObjectFactory.h> #include <Properties.h> #include <Proxy.h> #include <Types.h> #include <Util.h> +#include <ValueFactoryManager.h> +#include <IceUtil/DisableWarnings.h> #include <Ice/Communicator.h> #include <Ice/Initialize.h> #include <Ice/Locator.h> @@ -37,9 +38,9 @@ IceRuby_Communicator_mark(Ice::CommunicatorPtr* p) assert(p); try { - ObjectFactoryPtr pof = ObjectFactoryPtr::dynamicCast((*p)->findObjectFactory("")); - assert(pof); - pof->mark(); + ValueFactoryManagerPtr vfm = ValueFactoryManagerPtr::dynamicCast((*p)->getValueFactoryManager()); + assert(vfm); + vfm->markSelf(); } catch(const Ice::CommunicatorDestroyedException&) { @@ -128,6 +129,7 @@ IceRuby_initialize(int argc, VALUE* argv, VALUE self) seq.insert(seq.begin(), getString(progName)); data.compactIdResolver = new IdResolver; + data.valueFactoryManager = new ValueFactoryManager; if(hasArgs) { @@ -181,7 +183,7 @@ IceRuby_initialize(int argc, VALUE* argv, VALUE self) throw; } - + // // Replace the contents of the given argument list with the filtered arguments. // @@ -205,9 +207,6 @@ IceRuby_initialize(int argc, VALUE* argv, VALUE self) } 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)); @@ -256,12 +255,19 @@ extern "C" VALUE IceRuby_Communicator_destroy(VALUE self) { + Ice::CommunicatorPtr p = getCommunicator(self); + + ValueFactoryManagerPtr vfm = ValueFactoryManagerPtr::dynamicCast(p->getValueFactoryManager()); + assert(vfm); + ICE_RUBY_TRY { - Ice::CommunicatorPtr p = getCommunicator(self); p->destroy(); } ICE_RUBY_CATCH + + vfm->destroy(); + return Qnil; } @@ -371,7 +377,7 @@ IceRuby_Communicator_proxyToProperty(VALUE self, VALUE obj, VALUE str) volatile VALUE value = createString(q->second); callRuby(rb_hash_aset, result, key, value); } - return result; + return result; } ICE_RUBY_CATCH return Qnil; @@ -414,10 +420,10 @@ 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); + ValueFactoryManagerPtr vfm = ValueFactoryManagerPtr::dynamicCast(p->getValueFactoryManager()); + assert(vfm); string idstr = getString(id); - pof->add(factory, idstr); + vfm->addObjectFactory(factory, idstr); } ICE_RUBY_CATCH return Qnil; @@ -430,10 +436,25 @@ IceRuby_Communicator_findObjectFactory(VALUE self, VALUE id) ICE_RUBY_TRY { Ice::CommunicatorPtr p = getCommunicator(self); - ObjectFactoryPtr pof = ObjectFactoryPtr::dynamicCast(p->findObjectFactory("")); - assert(pof); + ValueFactoryManagerPtr vfm = ValueFactoryManagerPtr::dynamicCast(p->getValueFactoryManager()); + assert(vfm); string idstr = getString(id); - return pof->find(idstr); + return vfm->findObjectFactory(idstr); + } + ICE_RUBY_CATCH + return Qnil; +} + +extern "C" +VALUE +IceRuby_Communicator_getValueFactoryManager(VALUE self) +{ + ICE_RUBY_TRY + { + Ice::CommunicatorPtr p = getCommunicator(self); + ValueFactoryManagerPtr vfm = ValueFactoryManagerPtr::dynamicCast(p->getValueFactoryManager()); + assert(vfm); + return vfm->getObject(); } ICE_RUBY_CATCH return Qnil; @@ -596,6 +617,7 @@ IceRuby::initCommunicator(VALUE iceModule) rb_define_method(_communicatorClass, "identityToString", CAST_METHOD(IceRuby_Communicator_identityToString), 1); rb_define_method(_communicatorClass, "addObjectFactory", CAST_METHOD(IceRuby_Communicator_addObjectFactory), 2); rb_define_method(_communicatorClass, "findObjectFactory", CAST_METHOD(IceRuby_Communicator_findObjectFactory), 1); + rb_define_method(_communicatorClass, "getValueFactoryManager", CAST_METHOD(IceRuby_Communicator_getValueFactoryManager), 0); rb_define_method(_communicatorClass, "getImplicitContext", CAST_METHOD(IceRuby_Communicator_getImplicitContext), 0); rb_define_method(_communicatorClass, "getProperties", CAST_METHOD(IceRuby_Communicator_getProperties), 0); rb_define_method(_communicatorClass, "getLogger", CAST_METHOD(IceRuby_Communicator_getLogger), 0); |