[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: Guile-Git 0.6.0 released; looking for maintainers!
From: |
Attila Lendvai |
Subject: |
Re: Guile-Git 0.6.0 released; looking for maintainers! |
Date: |
Tue, 27 Feb 2024 19:25:58 +0000 |
> An idea might be to look into using nyacc’s ffi-helper to generate
> struct definitions.
over there in CL land i wrote an automatic FFI generator. it's now part of the
main CL FFI lib:
https://github.com/cffi/cffi/tree/master/src/c2ffi
it is based on c2ffi:
https://github.com/rpav/c2ffi
which is a piece of C++ code that uses CLANG as a library to parse any C header
file, and emit its content into a json file.
a thin layer of lisp code can generate the actual sexp FFI definitions from the
json files, that then can be hooked into the usual guile way of doing FFI.
the json files can be checked into the repo, which then eliminates the
dependency on c2ffi on the user side (i.e. the project is only as heavy as any
other hand-written FFI wrapper). that way only the maintainer needs to
regenerate the json files every once in a while.
or short of a smarter build tool like ASDF, we can also check in the generated
lisp files.
if there's interest, then i can help porting this over to guile.
below are some example projects that are using it. they are rather thin and
simple, yet provide a full FFI:
https://github.com/hu-dwim/hu.dwim.zlib
https://github.com/hu-dwim/hu.dwim.sdl
PS: clang now supports `-ast-dump=json`, which may or may not eliminate the
need for c2ffi entirely: https://github.com/rpav/c2ffi/issues/112
--
• attila lendvai
• PGP: 963F 5D5F 45C7 DFCD 0A39
--
“Sometimes I wonder whether the world is being run by smart people who are
putting us on or by imbeciles who really mean it.”
— Mark Twain (1835-1910)