[racket] Bootstrapping an FFI

From: Jay McCarthy (jay.mccarthy at gmail.com)
Date: Sat Aug 11 11:30:34 EDT 2012

Regarding a more recent version of OpenGL, there's RacketGL (on
planet) by Stephan that is automatically generated from Khronos' spec
files and is "perfect".

Jay

On Sat, Aug 11, 2012 at 8:01 AM, Ian Tegebo <ian.tegebo at gmail.com> wrote:
> Wow, looks great!
>
> I'm still looking at FFIs for both Graphviz and a more recent version
> of OpenGL, so I'd appreciate anyone's tips/code for translating C.
>
> On Sat, Aug 11, 2012 at 5:29 AM, Peter Braun <peter-braun at gmx.net> wrote:
>> Hi Ian,
>>
>> unfortunately I can't help you with automatic code generation but i've
>> written a binding for libSDL (and libSDL_image) manually. It's not complete
>> but covers quite a usable part of SDL (video, events, joystick and some
>> more). If it helps you in any way, feel free to use / fork the code. It's on
>> github:
>>
>> https://github.com/pb82/sdl4racket
>>
>> On 11.08.2012 04:43, Ian Tegebo wrote:
>>>
>>> I'm playing around with an FFI for SDL.  Rather than slog through all
>>> the headers by hand, I went looking for some code that may do a bit of
>>> the parsing and translation.  On PLaneT, I found dherman's c.plt:
>>>
>>> http://planet.racket-lang.org/display.ss?package=c.plt&owner=dherman
>>>
>>> I got stuck when it appeared that I'd need to provide it with a list
>>> of symbols that were typedef-ed:
>>>
>>>
>>> http://planet.racket-lang.org/package-source/dherman/c.plt/4/0/planet-docs/c/parsing.html#(part._include)
>>>
>>> I bit of preprocessing seems to make this still quite a bit of work:
>>>
>>> gcc  -D "__extension__=" -D "__attribute__(ARGS)=" -E
>>> /usr/include/SDL/SDL.h  | sed '/^\#/d' | indent -st -i2 |grep -vE
>>> '^[[:space:]]*$' > sdl.h
>>>
>>> Has anyone else gone down this road before?  Also, Besides Eli's
>>> paper, any general advice for Racket FFIs?
>>>
>>> Thanks,
>>
>>
>>
>> ____________________
>>  Racket Users list:
>>  http://lists.racket-lang.org/users
>
>
>
> --
> Ian Tegebo
> ____________________
>   Racket Users list:
>   http://lists.racket-lang.org/users



-- 
Jay McCarthy <jay at cs.byu.edu>
Assistant Professor / Brigham Young University
http://faculty.cs.byu.edu/~jay

"The glory of God is Intelligence" - D&C 93

Posted on the users mailing list.