"vrtprj.com" <mail@vrtprj.com> writes:
> Hello,
>
> I've just discovered scsh and it seems to fulfill most of my needs. To cover
> the rest I'm trying to add RDF support to scsh by calling the Redland C
> library.
>
> Redland (0.9.16) provides a shared library, which I want to call from scsh
> (0.6.6). I looked into the Scheme 48 manual and tried the approaches
> mentioned there, but ran into problems. Perhaps somebody on this list has a
> hint for me?
>
> I loaded the lib via "dynamic-calls", and I tried the other approach and
> linked the library with scsh, fater having generated a SWIG wrapper. With both
> methods I get access to the defined funtions. Calling funtions without
> arguments works, but as soon as I try to use parameters the problems start -
> they don't seem to be passed properly. Example:
>
> (dynamic-load "/usr/local/lib/librdf.so")
> (define fw (get-external "librdf_free_world"))
> (define iw (get-external "librdf_new_world"))
> (call-external fw (call-external iw))
>
> Calling librdf-new-world returns a pointer, which then can be passed as an
> argument to librdf-free-world. The call to new-world returns something, but
> passing this value back to free-world results in a NULL pointer
> assignment/VM crash.
>
> Is it possible to use scsh in this way? Or do I have to write glue libraries
> for converting between scsh and Redland?
Yes, you have to write glue code. The called C functions get arguments
of type s48_value and you need to convert them to regular C values
using the s48_extract_X functions. Likewise, scsh expects the C
functions to return values of the s48_value and you need to convert
the C types to s48_value using the s48_enter_X functions.
In the source distribution, the directory scsh-0.6.6/scsh/ contains a
lot of sample C code.
--
Martin
|