From: elathan@... Date: 2004-01-08T22:12:01+09:00 Subject: Re: convert a C/C++ array to a Ruby array Quoting nobu.nokada@softhome.net: > > Actually it is part of the functionallity a C++ Class embeds: > > > > Foo::Foo(int n, double *f); > > double * Foo::Get(); > > > > Okay, I can grab 'n' from the constructor and use it as the length > > of the Ruby/C array, but I wanted to make sure that there is no > > general way to procceed without messing with the details of the > > C/C++ code. > > If you can get the length from Foo, you can use it. Yes I know. The problem is that I am creating Ruby bindings for a large framework (more than 50 C++ classes) and the bindings code is automagically generated by reading the C++ prototypes, using a handmade Ruby parser/compiler. The generated code is quite readable and can be altered by a human, but I want to eliminate as much as I can the human intervation, so as the majority of the C++ prototypes to be compiled in the Ruby API without human editing. > What do you really intend, pseudo array? If I was doing this by myself, I would create a Ruby array of length Foo::n and populate it with the double(s) Foo::Get() returns. But this requires some magick, i.e. to understand further the functionality of Class Foo; not just read the prototypes and translate them using an application. So, I asked here if someone knows a better way... I checked SWIG and it returns a special SWIG object in that case... Regards, Elias