From: wolf@... Date: 2018-01-10T11:34:50+00:00 Subject: [ruby-core:84809] [Ruby trunk Feature#14348] win32ole: enable using a bit weirder classes than usual Issue #14348 has been reported by graywolf (Gray Wolf). ---------------------------------------- Feature #14348: win32ole: enable using a bit weirder classes than usual https://bugs.ruby-lang.org/issues/14348 * Author: graywolf (Gray Wolf) * Status: Open * Priority: Normal * Assignee: * Target version: ---------------------------------------- Currently win32ole requires coclass to directly implement (one) IDispatch. That works fine for ``` coclass Good { [default] interface GoodIface2; interface GoodIface1; }; interface GoodIface1 : IDispatch { // snip }; interface GoodIface2 : GoodIface1 { // snip }; ``` however, it fails to work for the following ``` coclass Bad { [default] interface BadIface1; interface BadIface2; }; interface BadIface1 : IDispatch { // snip }; interface BadIface2 : IDispatch { // snip }; ``` I suspect it's because when you ask for `IDispatch` of `Bad`, it doesn't know which one to give you (but I'm no COM expert so correct me if I'm wrong). Now, please let's not discuss if classes like that are good idea or not (I think they are not), fact is they do exists and simple patch allows using them with ruby's win32ole. Attached patch adds new `iface` keyword argument which let's you pick interface to acquire (it must still implement `IDispatch`). Documentation also says that you *very* likely do *NOT* need to use this argument. Usage in my particular case would look like this: ``` LIBNAME = 'xxx' TYPELIB = WIN32OLE_TYPELIB.new(LIBNAME) lic = 'xxxx' foo = WIN32OLE.new( TYPELIB.ole_type.find { |t| t.name == 'Foo' }, nil, license: lic, iface: '{00000000-0000-0000-0000-000000000000}' ) foo.Bar(1, 2, 'foobar') ``` as you can see, except for the need to specify the interface, it works exactly same as normal classes. Please consider for merge `^_^` ---Files-------------------------------- 0001-win32ole-Enable-COM-classes-with-multiple-IDispatch.patch (4.38 KB) -- https://bugs.ruby-lang.org/ Unsubscribe: