From: Jonathan P. <jp...@dc...> - 2005-07-16 13:28:15
|
On 15 Jul 2005, at 21:24, Ralph Brorsen wrote: > If at all possible I would prefer not to link my C++ stuff against > Ruby in order to keep it clean. It is a library meant for stand- > alone distribution. I now handle the conversion in the SWIG layer: > > // Convert bool from Ruby --> C with type check > %typemap(in) BitmapPointer { > id ocobj = (id) NUM2UINT( rb_funcall($input, rb_intern > ("__ocid__"), 0) ); > $1 = [(NSBitmapImageRep*) ocobj bitmapData]; > } Did you try linking against RubyCocoa to make use of its dedicated function for getting at the __ocid__ of a Ruby object? That way will rely less on the internal workings of RubyCocoa. > Three more things were needed to make it work. > 1. Testinterface::Test(bitmapRep.bitmapData()) -> > Testinterface::Test(bitmapRep) (duh) > 2. #include <AppKit/NSBitmapImageRep.h> (in the SWIG .i file) > 3. You're now mixing Objective-C and C/C++ (aptly termed Objective-C > ++), and the compiler needs to be made aware of this. This is done > by changing the extension of the *_wrap.cxx file to .mm, ie. > *_wrap.mm. Update your makefile. Thanks for posting back with your results. Useful recipes. Jonathan |