# Swig & passing array of arrays

**URL:** <https://www.ruby-forum.com/t/swig-passing-array-of-arrays/76900>\
**Category:** Ruby\
**Created:** [March 5, 2006, 2:49pm UTC](https://www.ruby-forum.com/t/swig-passing-array-of-arrays/76900 "2006-03-05T14:49:02Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![alby](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/a/85f322/32.png) [@alby](https://www.ruby-forum.com/u/alby)\
**Post date:** [March 5, 2006, 2:49pm UTC](https://www.ruby-forum.com/t/swig-passing-array-of-arrays/76900/1 "2006-03-05T14:49:02Z")

</div>

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

---

<div class="post-metadata">

**Author:** ![alby](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/a/85f322/32.png) [@alby](https://www.ruby-forum.com/u/alby)\
**Post date:** [March 5, 2006, 10:14pm UTC](https://www.ruby-forum.com/t/swig-passing-array-of-arrays/76900/2 "2006-03-05T22:14:04Z")

</div>

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](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!
