Forum: Ruby swig & passing array of arrays

Announcement (2017-05-07): www.ruby-forum.com is now read-only since I unfortunately do not have the time to support and maintain the forum any more. Please see rubyonrails.org/community and ruby-lang.org/en/community for other Rails- und Ruby-related community platforms.
0aca516785b12ea4ffd4fec43d69f586?d=identicon&s=25 Albert Vernon Smith (Guest)
on 2006-03-05 14:49
(Received via mailing list)
Hi,

I'm trying to get SWIG to create a wrapper for some C code.  I have
some functions which take an int** (which points to an array of
arrays, and they also take the dimensions as arguments).  I don't
know how to do the typemap for this - I want to be able to write

  My_module.my_c_function([[1,2],[3,4]])

for the corresponding C function

  void my_c_function(int xsize, int ysize, int** aryary)

Anyone have any idea how to help me?  From various googling, I
understand how to pass an array of ints, but passing arrays of arrays
has me stumped.

Thanks,
-albert
97d424fe924f2139812a4a6de1ef6b79?d=identicon&s=25 rickhg12hs (Guest)
on 2006-03-05 22:14
(Received via mailing list)
Sorry I don't have a complete answer for you ... looks like this may
take a bit of work.

http://www.swig.org/Doc1.3/Typemaps.html#Typemaps_nn40

.... shows an example using Python.

To call your function the way you want, looks like you'll need to write
a typemap and/or helper functions to extract the Ruby array values and
populate a C array with the correct type values.  ruby.h has a bunch of
conversion macros and prototypes that will help.

Good luck!
This topic is locked and can not be replied to.