[SWIG] Dynamic method dispatching with "send"

(Esteban Manchado Velázquez) #1

Hi all,

   Perhaps this is a stupid question, but I don't know enough SWIG yet:

   Can't I use the "send" method for dynamic method dispatching? I'm currently
writing my first attempt at a Ruby interface, with SWIG, and I can't get
"send" to work.

   The scenario is:

-------------------------------- 8< --------------------------------
   class OutChannel
      def create_ice(options={})
         ice = get_ice(orig_create_ice)
         puts ice.class
         [:host, :port].each do |opt|
            ice.send(opt, options[opt]) if options.has_key? opt
         end
         ice.apply_profile
         ice
      end
   end
-------------------------------- >8 --------------------------------

When "send" is called, it raises this exception:

   TypeError: wrong argument type Symbol (expected Data)

I even redefined "send", to check parameters and make sure it was calling the
method I thought, but everything seems OK:

-------------------------------- 8< --------------------------------
   class Shouter
      alias_method :old_send, :send
      def send(meth, *args)
         puts "parameters: #{meth}, #{args.join(', ')}"
         old_send(meth, *args)
      end
   end
-------------------------------- >8 --------------------------------

The result, then, is:

-------------------------------- 8< --------------------------------
parameters: host, corintio
TypeError: wrong argument type Symbol (expected Data)
-------------------------------- >8 --------------------------------

I can send complete sources, although I guess it's nothing specific of my
code.

   Any ideas why it doesn't work? It works with "method", though :-? I'm
clueless...

   Regards,

···

--
Esteban Manchado Velázquez <zoso@foton.es> - http://www.foton.es
EuropeSwPatentFree - http://EuropeSwPatentFree.hispalinux.es