cmucl alien type question
Hi. This one is for all the CMUCL gurus.
I have some lisp code(a volume renderer) that accesses an alien data
structure. Currently, this is what I do:
(def-alien-variable "rawdata" (* unsigned-char))
and to access:
(defun get-vol-value (x y z)
(declare (fixnum x y z))
(deref rawdata (+ (the fixnum (* (the fixnum (* z vol-width-fixnum))
vol-height-fixnum))
(the fixnum (* y vol-width-fixnum))
x)))
As you can see, the alien type is simply a pointer to a chunk of unsigned
characters. The problem is that I want to access this data as if it were
a 3 dimensional array. My GET-VOL-VALUE function does this, albeit
slowly. What I want to do is cast this data structure into a new alien
type so that I can access it via:
(deref rawdata x y z)
This should be more efficient, correct?
I've tried doing:
(alien:cast rawdata (array (* unsigned-char) vol-width vol-height
vol-depth))
but I'm not sure what this does. Does this change the old rawdata
type or does it create a new one? I recieved lots of warnings when I
would try to access the alien.
I would like to avoid moving this data structure into the lisp heap as it
adds about 10 seconds to total gc time when I do this.
I'd appreciate any help anyone could give me.
--Jonathan