* Kaz Kylheku <
201901221...@kylheku.com> :
Wrote on Wed, 23 Jan 2019 01:03:42 +0000 (UTC):
> I don't see how grovel can generate correct FFI in all cases, since
> it's just going after declarations. I wouldn't use anything of this
> sort.
there is magic in
github.com/rpav/c2ffi. It is dependent on the
vagaries of clang and it cannot handle bitfields in structs but afaik is
the best thing for generating ffi bindings from C.
Of course since you're working with the C-library you are expected to be
intimately familiar with the C API. There is a the wrapper that can put
a nice lisp-level interface over the C. To see that wrapper you have to
go look at yourself in a mirror.
> C functions have semantics that isn't revealed by the type signature,
> like which pointers are in, out or in-out parameters, who allocates
> what, and so on.
>
> Speaking of this topic and Gtk, the libraries in Gnome have a system
> ("GObject Introspection") whereby semantic information about library
> API's exported in libraries in XML form, stored in accompanying .gir
> files. (Look for these on your Ubuntu or what have you and take a look
> inside.)
cl-gobject-introspection in lisp is workable but very rough. (I
submitted some patches but the commits incorporated errors into the
patches and there are still some serious problems.)
The optimized syntax of cl-gobject-introspection is problematic, since
methods are called on objects there is no way to hack up eldoc editor
help for code one happens to be writing. The big advantage of using gir
here would be in assisting the programmer by doing introspection and
presenting completions structure which at code-writing time, that is
presently not workable with the present syntax.
> If you can grok this XML, you should be able to generate more-or-less
> correct FFI definitions from it.
The whole point of gir is that there are language bindings for lisp.
generating FFI definitions from gir xml is pointless, and they are
themselves generated from header and source file comments in a way
similar to a groveller.