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

passing data types in Kyoto



	Arrays yes, structures are not as nice. I think even in the
latest version of AKCL C structures do not map directly to LISP
structures. For arrays, look in the file object.h . To reference
a LISP array in C your routine must get an argument off the 
value stack vs_base[???] where ??? is the argument number. There
are several array types so make sure you have the right one. But,
a vector for example, is referenced as x->v.v_self[index].

	If you wish to create a vector and return it to LISP it
must be created in the LISP space of your memory. This can be done
by first calling alloc_object and then for an array calling
array_allocself. Here is some psuedocode:

		x = alloc_object(t_vector);
		x->v.v_self = (object *)NULL;
		x->v.v_displaced = Cnil;
		x->v.v_dim = vector_length;
		x->v.v_adjustable = FALSE;
		x->v.v_hasfillp = FALSE;
		x->v.v_fillp = x->v.v_dim;
		x->v.v_elttype = (short)aet_fix;
		vs_push(x);       /* protect vector structure from GC */
		array_allocself(x,FALSE);

	/* before you return from routine to LISP remember to do a vs_pop for every
	   vs_push so the value stack gets cleaned up properly */

Suggested reading alloc.c, array.c, object.h, bds.h and others as appropriate.
Good Luck.

						Paul H