All,

I'm using the Ruby module in SWIG1.3a5 to attempt to generate wrappers for a
C++ class library. It was going fairly well but I've run into the first
snag. Before I spend too much time on this problem I wanted to see if any
others have run into it and have come up with a solution.

In its current implementation, when SWIG/Ruby generates wrappers a the C++
class constructor it defines a singleton method for "new", e.g.

    rb_define_singleton_method(cMyBaseClass, "new",
wrap_new_MyBaseClass, -1);

The wrapper function (wrap_new_MyBaseClass) basically collects the input
arguments, calls the C++ constructor, and wraps up the result using Ruby's
Data_Wrap_Struct() function. This is a pretty reasonable approach but it
seems to prevent me from then overriding the initialize() function in my
Ruby code, when I derive new classes from MyBaseClass:

    require 'MyExtensionModule'

    class MyDerivedClass < MyExtensionModule::MyBaseClass
        def initialize(one, two)
            # Base class constructor requires four arguments
            super(one, two, "Foo", "Bar")
        end
    end

 If I try to create an instance of MyDerivedClass:

    thing = MyDerivedClass.new("first argument", "second argument")

I get an error indicating that "new" wants four input arguments instead of
the two I've provided. It looks like the wrapper code for "MyBaseClass"
intercepts the call to "new" and never even tries to invoke "initialize".

So before I try to do something clever hacking in SWIG, do any SWIG/Ruby
veterans have any thoughts on this problem?

TIA,

Lyle