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

FF-example.c



This question concerns the C code in MCL 2.0:examples:FF
examples:ff-example.c. I'd like to know what the following define
statements are trying to do:
define CDR(x) (* ((long *) (x)))

define CAR(x) (* (((Ptr *) (x)) -1))

define MACPTR_PTR(x) (* (Ptr *) (((long) (x)) +7)))

The definitions are the refered by
CDR(* x), CAR(* x) and (MACPTR_PTR(* x)  where x is
type defined as             long *x;

The exact code is as follows:
growptr(x)
long *x;
{
Ptr newp;
if (MACPTR_PTR(CAR(*x))) DisposPtr(MACPTR_PTR(CAR(*x)));
newp = NewPtr((CDR(*x))>>FIXNUM_SHIFT);
MACPTR_PTR(CAR(*x))=newp;
}

The lisp FFI defines the above function as

(deffcfun (grow-ptr "growptr") ((cons :lisp-ref) :novalue))

The lisp call is as follows:
(grow-ptr (cons (#_NewPtr 5) 10))
_NewPtr 5) 10))

I understand the overall function of the code; my proble lies in the
particular define stamements.

Thank you.

Chris Ryan (SIUC)