Draft: Allow usage of (ffi:def-foreign-type ... ) in function declaration
I'm working on ECL binding for some C-library and found annoying issue.
There are several types declared in a library, which are convenient to use in a code. In fact these are synonyms for C types, but used in library a lot.
So, I modeled library type system on ECL side, something like that:
(ffi:def-foreign-type CSTR :cstring)
(ffi:def-foreign-type BYTE :unsigned-byte)
(ffi:def-foreign-type VOID :void)
and then created binding like that:
(defun test-function
(b str)
(ffi:c-inline (b str)
(byte cstr)
cstr
"@(return) = test_function(#0, #1);"
:side-effects nil))
ECL gives error Unknown representation type CSTR
during compilation of this function.
I made changes to compiler to expand FFI types to C types (here in MR).
It works, but if I change return type from cstr
to void
, it fails.
This MR is more about discussion. I understand I may be missing something and of course I can change cstr
and void
to :cstring
and :void
respectively, but it seems to be wrong to skip semantic information from original library.
Reproducer attached: cl-ffi-issue.tar.gz