[CM] s7 wrap c func with scheme
bil at ccrma.Stanford.EDU
bil at ccrma.Stanford.EDU
Fri Feb 24 11:10:02 PST 2017
Probably the simplest way to make a C function callable from s7
is to wrap it in a function of the form
s7_pointer wrapper(s7_scheme *sc, s7_pointer args)
Then get the scheme-side arguments from "args", and
wrap the C function's output using the s7_make* functions.
It is then defined in s7 using s7_define_function.
s7.html has an example under "Define a function with arguments".
If you want this in a shared library, you also need to tell
s7's load function how to get the wrappers. This is normally
done via an environment with a field named 'init_func whose
value is the (name of the) C initialization function in the
library (i.e. the function that calls s7_define_function).
There's an example in the section about libsndlib.so,
but maybe I should add a simpler example.
cload.scm sets up all these wrappers and linkages for you,
but it is overkill for simple cases.
More information about the Cmdist
mailing list