This is the mail archive of the guile@cygnus.com mailing list for the guile project.
Index Nav: | [Date Index] [Subject Index] [Author Index] [Thread Index] | |
---|---|---|
Message Nav: | [Date Prev] [Date Next] | [Thread Prev] [Thread Next] |
Jim Blandy <jimb@red-bean.com> writes: > Yeah, there will always be a way for C code to get at the real bytes > of a uniform array. The SCM_CHARS macro works on uniform vectors, > and SCM_VELTS works for uniform arrays. I think. :) Hmm, let's see how much I remember of the internals (after writing lots of uniform arrays code - and I still have to look at Guile sources to do so). SCM_LENGTH and SCM_VELTS return length and the first element of the uniform vector. You probably want to cast the result of SCM_VELTS (like (double*)SCM_VELTS(blah) ) SCM_ARRAY_V returns the uniform vector containing the elements of the uniform array. SCM_ARRAY_NDIM is rank, SCM_ARRAY_BASE is the offset, and SCM_ARRAY_DIMS is the vector with dimensions for the array. So to index 2-dimensional array, you'd do ((double*)SCM_VELTS(SCM_ARRAY_V(arr))) + SCM_ARRAY_BASE(arr) + (i - SCM_ARRAY_DIMS(a)[0].lbnd) * SCM_ARRAY_DIMS(a)[0].inc + (j - SCM_ARRAY_DIMS(a)[1].lbnd) * SCM_ARRAY_DIMS(a)[1].inc (result is a pointer to double). This will work for both normal and shared arrays. -- I refuse to use .sig