[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: passing data types in Kyoto

In AKCL you may create lisp defstructs with raw entries.  The file
misc/rusage.lsp in the AKCL distribution shows an example of such a
structure and of invoking a c function getrusage to fill it.

The file misc/cstruct.lsp will create some lisp structures automatically to
match the corresponding C structure.  It was only a first attempt, and
undoubtedly needs further debugging, and extension.  It does attempt
to ascertain the position of each C structure slot by compiling a
small program, and then looking at the offsets.
Notes:  `defun doelimiter'should be `defun delimiter' in that file.
Also the slot positions are just printed out by parse-file.
If for a structure named foo
(si::sdata-slot-positions (get foo 'si::sdata)) does not have entries
to the slotpositions printed out by the C program, then they should
be adjusted.

Note that you must add the keywords :static t to make-array for an
array which you create in lisp and wish to pass to C, unless you are
sure that the garbage collector will not be called during the time the
C program will be looking at the object.  And of course you must keep
a lisp pointer to the structure or array, otherwise it will totally
disappear on the next gc.