From: Peter Stirling <peter@pj...> - 2010-07-19 13:42:10
I'm trying to use sb-alien to access some of libFLAC routines and I've
got one that I'm unsure how to describe to sbcl. I've copied out the
relevant structure definitions from the C headers to
http://www.pastecode.org/206608 and my attempt at lisp analogues are in
FLAC__metadata_get_tags() "returns" a pointer to a newly allocated
FLAC__StreamMetadata by writing to the pointer-pointer passed in the
FLAC_API FLAC__bool FLAC__metadata_get_tags(const char *filename,
I had tried using:
(define-alien-routine ("FLAC_metadata_get_tags" metadata-get-tags)
(comments (* (struct metadata)) :out))
but this gives an error:
(during macroexpansion of (DEFINE-ALIEN-ROUTINE
("FLAC__metadata_get_tags" METADATA-GET-TAGS) ...))
can't use :OUT or :IN-OUT on pointer-like type:
(* (STRUCT METADATA))
I think this is because aliens are boxed and I need to pass the address
of the pointer within the boxed lisp-reference. If I'm right in that
then I think I need to mess with system-area-pointer, though I'm not
sure how, and the manual says:
SBCL exports this type from sb-alien because CMUCL did, but tentatively
(as of the first draft of this section of the manual, SBCL 0.7.6) it is
deprecated, since it doesn't seem to be required by user code.
As an aside: What does sb-grovel gain you over direct use of sb-alien?
When I read the high-level description I was expecting something like
"lispify the C-structs etc you get from these header files, and insert
them in the current package" but reading the usage you are required to
declare which structures you are interested in and the names of the
fields etc, in the same way as sb-alien.
Get latest updates about Open Source Projects, Conferences and News.