From: Lyle Johnson Date: 2003-05-06T00:18:24+09:00 Subject: Re: SWIG on Solaris problem Jim Freeze wrote: > Ok, so, let me change things a bit here. The fact2 code was just > to do a test to see why int* did not work. I am really trying > to wrap the itkDB library. The function is defined as: > > dbInit(int *pnArgs, char **pString); > > (or dbInit(int *pnArgs, String *pString); > where typdef char * String;) > > I expect to call it from ruby as: > > require 'itkdb' > Itkdb.dbInit(1, "some_path") OK, this is getting a little trickier. Try this typemap: %module example %typemap(in) (int *pnArgs, String *pString) (int temp, int i) { Check_Type($input, T_ARRAY); temp = RARRAY($input)->len; $1 = &temp; $2 = (String *) malloc(sizeof(String)); for (i = 0; i < $1; i++) { $2[i] = StringValuePtr(rb_ary_entry($input, i)); } } %typemap(freearg) String *pString { free((void *) pString); } void dbInit(int *pnArgs, String *pString); Hope this helps, Lyle