---259930559-66454694-11075916221442 Content-Type: MULTIPART/MIXED; BOUNDARY="-259930559-66454694-1107591622=:11442" This message is in MIME format. The first part should be readable text, while the remaining parts are likely unreadable without MIME-aware tools. ---259930559-66454694-11075916221442 Content-Type: TEXT/PLAIN; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: QUOTED-PRINTABLE Thank you once again Lyle :-) . On Fri, 4 Feb 2005, Lyle Johnson wrote: > On Fri, 4 Feb 2005 16:30:32 +0900, Asbjøòn Reglund Thorsen > <asbjoert / ifi.uio.no> wrote: > >> This is what I tried, but did not work: >> >> %typemap(out) int &{ //C->Ruby, Back to Ruby int object >> long *n = (long *) $1; >> $result = INT2NUM(*n); >> } > > This one won't generate a compiler error (well, it didn't for me) but > it's dangerous to cast the return value, which is a pointer-to-int, to > a pointer-to-long. Here's a better version of this typemap: > > %typemap(out) int & { > $result = INT2NUM(*$1); > } > >> %typemap(in) int &{ //Ruby->C, From Ruby integer to C long >> $1 = NUM2INT($input); >> } > > OK, this is the one that generated the compiler error you saw. Here's > a corrected version: > > %typemap(in) int & (int tmp) { > tmp = NUM2INT($input); > $1 = &tmp; > } > > Hope this helps, > > Lyle > > ---259930559-66454694-11075916221442-- ---259930559-66454694-11075916221442--