[MacRuby-devel] How to use custom C struct's?

Jeremy Voorhis jvoorhis at gmail.com
Wed Aug 5 09:40:54 PDT 2009


When MacRuby's FFI support is more mature, declaring an FFI::Struct subclass
like this will be another option.
  class MapPoint < FFI::Struct
    layout :row, :int, :col, :Int
  end

You instantiate an FFI::Struct with a pointer. I'm hacking away on a Ruby
interface to a C library, and I'm slinging around pointers, structs and
unions with ease on MRI 1.8.6, 1.9.1 and JRuby.

Best,

Jeremy

On Wed, Aug 5, 2009 at 8:41 AM, Eloy Duran <eloy.de.enige at gmail.com> wrote:

> Hi,
>
> On Aug 5, 2009, at 5:31 PM, Clay Bridges wrote:
>
>> The google didn't yield much guidance on this. Before I started a
>> deep-dive on the MacRuby source, and/or the standard ruby way to
>> handle this sort of thing, I thought I would ask a couple of
>> questions:
>>
>> 1) Any easy advice?
>>
>
> Yes, use RubyCocoa
>
>  2) Is this different in MacRuby than in ruby proper?
>>
>
> RubyCocoa at least allows you to use BridgeSupport which would allow you to
> map these. Afaik MacRuby doesn't fully support it yet.
>
>  3) Any pointers into the MacRuby source that might help me?
>>
>
> BridgeSupport needs to fully implemented.
>
> Keep in mind, MacRuby is not stable yet.
>
> HTH,
> Eloy
>
> _______________________________________________
> MacRuby-devel mailing list
> MacRuby-devel at lists.macosforge.org
> http://lists.macosforge.org/mailman/listinfo.cgi/macruby-devel
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.macosforge.org/pipermail/macruby-devel/attachments/20090805/a569acbb/attachment.html>


More information about the MacRuby-devel mailing list