From: ptkwt@...1.aracnet.com (Phil Tomson) Date: 2002-06-14T14:07:19+09:00 Subject: SWIG: returning a bool reference or pointer to Ruby I've got a class that defines the following method: class AEdge { .... virtual bool intersect( bool & overlap, xyT & ix, xyT & iy, xyT & iix, xyT & iiy, const AEdge & ae ); .... }; //AEdge.h Where overlap,ix,iy,iix and iiy are really values that should be returned by the function. So in Ruby I'd like to be able to do: intersection,overlap,ix,iy,iix,iiy = e.intersect(e1) (where intersection is the true/false value which is the bool returned from intersect). I tried to do the following in the .i file to no avail: %module Shapes %include "typemaps.i" bool AEdge::intersect(bool &OUTPUT,xyT &OUTPUT,xyT &OUTPUT, xyT &OUTPUT,xyT &OUTPUT,AEdge&); .... It kind of seems to me that I'm expecting a bit too much magic here but that's similar to what was shown in the latest SWIG/Ruby doc. I also tried: %module Shapes %include "typemaps.i" %apply bool *OUTPUT { bool* overlap }; %apply int *OUTPUT { xyT* ix, xyT* iy, xyT* iix, xyT* iiy }; but that didn't work either (NOTE: I tried both references and pointers thinking that SWIG converts references to pointers so maybe I need to do that too). Can someone clarify how this is supposed to work? BTW: I checked the typemaps.i file for Ruby and found no mappings from bool* to Ruby's TrueClass or FalseClass, so maybe that's the problem, but I'm not sure how to achieve this mapping. I suspect this would be a lot easier if Ruby had a Bool type that could be either true or false. I think it's been mentioned before, but it does seem a bit awkward that a variable set to true is of type TrueClass and a variable set to false is of FalseClass. So how would one go about mapping from a bool on the C side to either a true or false on the Ruby side and visa-versa? Phil