From: Daniel Waite Date: 2009-01-03T09:04:49+09:00 Subject: Re: Ruby arguments into C function are warped Tim Hunter wrote: > A VALUE can reference any Ruby object, but the FIX2INT macro expects its > argument to be a Ruby Fixnum. If it's not, it will raise an exception. > You'll get an exception if you call mt.add("a", 0). Ah, that seems obvious now. Thanks for the help. > Also, the return value from t_add should be a VALUE, not an int. It's > your choice which VALUE to return. Here I chose self. Agreed, and I originally was returning self (it's still commented in the actual file) but I was trying to strip out all unnecessary code. > Also: not a Ruby issue, but a C issue: You've left yourself wide open > for a buffer overflow. Fully aware, but thanks for the concern. ;) Brian Candler wrote: > Have a look at the RubyInline gem, and FFI I've looked at RubyInline, and it was surprisingly easy to get it working. I'm uncertain if it will do what I need it do though -- namely, pass information back and forth between C and Ruby. The FFI project looks interesting though... :) Thanks for the excellent replies. -- Posted via http://www.ruby-forum.com/.