[MacRuby-devel] Exposing c structs and functions

John Shea johnmacshea at gmail.com
Thu Dec 18 13:55:40 PST 2008


Hi Jim,looks like no one who really knows this stuff is offering anything -
so I will suggest some of my naive solutions / possibilities:

- as far as I know C functions, structs etc are brought into macruby by the
bridgesupport project: http://bridgesupport.macosforge.org/trac/ - however I
cannot seem to find much information on it - however they do their stuff,
you could copy - if you could find some docs ;-)

- you could just use C in ruby the normal way via the inline gem
http://www.zenspider.com/ZSS/Products/RubyInline/ - works for me so far with
simple stuff. I thought I read somewhere you could also use Objective C with
this gem - but I cannot find anything on google at the moment.

- or you could proxy through a custom objective C class - eg I managed to
proxy some opengl function calls (not that there is a need to if you have a
NSOpenGLView class - it was more a proof of concept) - alas it failed when
calling GLUT functions (malloc errors).

Hope one of those helps you, I would be curious as to how you finally do it.
Cheers,
John

On Thu, Dec 18, 2008 at 4:29 PM, Jim Getzen <jim at getzen.name> wrote:

> Is there a way to expose some c structs and functions from a custom
> Objective-C framework to MacRuby?
>
> For instance, in my framework I have a 3-D point struct, such as:
> typedef struct {
>        CGFloat x, y, z;
> } JPoint3;
>
> In addition, I have creation functions such as 'JPoint3Make(x, y, z)' etc.
>
> How do I make these usable from MacRuby, like NSPoint and NSMakePoint are?
>
> Jim
> _______________________________________________
> 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/20081218/d454e219/attachment.html>


More information about the MacRuby-devel mailing list