From: Jim Freeze Date: 2003-05-03T09:16:00+09:00 Subject: Re: SWIG on Solaris problem On Saturday, 3 May 2003 at 6:49:12 +0900, Lyle Johnson wrote: > > extern int fact2(int *INPUT); > > %include typemaps.i > > that it will define a number of useful typemaps for dealing with this > situation. You've already seen how to handle the case of a pointer > that's really an input. But what if your function was instead using that > argument as an output, e.g. > > void deepthought(int *answer) { > *answer = 42; > } > > Here, 'answer' is obviously an output-only argument. So you'd use the > OUTPUT typemap from typemaps.i: > > %include typemaps.i > > void deepthought(int *OUTPUT); > > When you call this function from Ruby, you don't pass it any arguments; > its outputs come to you as regular outputs should: > > the_answer = deepthought() # should return 42 What would happen if I defined several OUTPUT params. Would I get an array back? > Finally, for input-output arguments, use the INOUT typemap: > > /* example.c */ > void triple(int *n) { > *n = (*n) * 3; > } > > /* example.i */ > > %include typemaps.i > > void triple(int *INOUT); > > And to call this function from Ruby: > > tripled_value = triple(5) # should return 15 What if the function already has a return value. Can one use an OUTPUT or INOUT argument? -- Jim Freeze ---------- They're only trying to make me LOOK paranoid!