[comp.lang.lisp] Passing arrays between C and AKCL

dmc@pur-ee.UUCP (David M Chelberg) (02/08/90)

I am interested in passing data between C and AKCL.  The manual for
KCL only specifies how to pass simple args (ints, floats).  I have a
need to pass large arrays, and strings between C and AKCL.  Does
anyone know how to accomplish this?  The manual mentions a type of
argument called object, but doesn't tell how to get at the underlying
data in the object.  An important consideration is that the garbage
collector not muck up the array when the C program is looking at it.

Thanks in advance for any help,

 -- Prof. David Chelberg (dmc@piccolo.ecn.purdue.edu)

jeff@aiai.ed.ac.uk (Jeff Dalton) (02/09/90)

In article <14438@pur-ee.UUCP> dmc@pur-ee.UUCP (David M Chelberg) writes:
>I am interested in passing data between C and AKCL.  The manual for
>KCL only specifies how to pass simple args (ints, floats).  I have a
>need to pass large arrays, and strings between C and AKCL.  Does
>anyone know how to accomplish this?  The manual mentions a type of
>argument called object, but doesn't tell how to get at the underlying
>data in the object.  An important consideration is that the garbage
>collector not muck up the array when the C program is looking at it.

Ok, first look at the section of the manual that deals with the C
interface.  It tells you how to protect objects from garbage
collection.  It also tells you how to call Lisp from C, which lets you
do various things, such as allocate objects, without figuring out the
internals of KCL.  [What it really tells you is how to mix Lisp and C
together in one file, but you can use those techniques to write
interface routines, etc.]

Note that it's only new objects that have to be protected from GC.
Objects passed to C from Lisp are ok, because the Lisp code still
has ahold of them.

To see how to get to the data in an "object", look at the declarations
in "h/object.h".  The ones that will actually be available in compiled
code are in "cmpinclude.h", but "object.h" is easier to read.

-- Jeff