Ruby, the new bindings and C++

So, I’m still working on getting RubyTag++ finished; today I also started again working in JulTagger, converted it to use RubyTag++ and started supporting more than one file selected at a time.

Unfortunately, when I was trying it, I ended up with a crash before and a runtime error (coming from RubyTag++), which meant that my current way to bind instances is not yet complete. Sigh.

Luckily, I had an answer from Richard Dale about the problem I blogged a while back with the evil evil hack needed to be able to get a correspondence between the ruby objects and the C++ instances. Less luckily, that way makes more difficult to create C++ objects, as the allocate function that replaces the initialize one does not pass the parameters that I need to pass to the new operator.

I’ve looked for documentation about it with Google, but I found nothing; Programming Ruby is completely useless about this as it still describe the old method. I found a few question asked in ruby’s mailing lists, but nothing actually useful for what I needed.

I finally found the solution in looking at wxruby code, that is C++ and uses the new interface. The trick seems to be to provide a fake pointer in the alloc function, and then just create the object in the initialize function.

I’ll be updating RubyTag++ later today, and then return working on JulTagger.