The CFFI bindings generated when using %rename are broken, because it changes both the name of the created function, *and* the name of the C function they call.
E.g., running "swig -noswig-lisp -cffi name.i" in Examples/test-suite should result in:
(cffi:defcfun ("foo_1" foo_2) :void)
(cffi:defcvar ("bar_1" bar_2)
:int)
(cl:defconstant Baz_2 47)
But currently results in:
(cffi:defcfun ("foo_2" foo_2) :void)
(cffi:defcvar ("bar_2" bar_2)
:int)
(cl:defconstant Baz_2 47)
Additionally, SWIG is checking the renamed-to variables against the identifier syntax for C, because the CFFI class didn't implement validIdentifier(). In particular, this forbids bindings like:
%rename foo_1 "%%foo_2";
void foo_1();
The % character a standard way of naming for "internal variant, don't use directly" in common lisp. CL is *much* more lax in which characters may be included, so I just told SWIG to not bother checking at all. The actual identifier rules for CL are way too complicated to implement, so I didn't think it was really worth reproducing them.
Finally, this fixes the -noswig-lisp command-line option. It is specified to omit the standard boilerplate code, but it *also* has the side-effect of removing all user-specified code output that is inserted like this:
%insert("swiglisp") %{
(defun hello () "hello"))
%}
Thus, this patch makes the internal use in Lib/cffi/cffi.swg instead use %insert("_swiglisp"), and the -noswig-lisp argument only disables "_swiglisp" sections, not "swiglisp" sections.
Thanks.
Closing all open CFFI issues as CFFI has been disabled, please see https://github.com/swig/swig/issues/1447