Hi,
I've been trying to see whether I can get the actual vector data as a pointer in C. I found some code which used macros like ___CAST and __BODY_AS in the BLAS interface, but I could not find any further documentation on these macros. Alternatively, is it possible to wrap an existing C array ('malloc'ed on the heap) as a vector (and hence use the vector primitives on it).
-aditya
Afficher les réponses par date
I don't think these macros are documented.
You can just use the ___BODY macro. It will give you a ___WORD* pointer to the body of any subtyped scheme object.
As for having a scheme object body allocated with malloc, I think it would probably behave badly with the garbage collector.
If you want to allocate a scheme object in c, check the ___alloc_scmobj in lib/mem.c As an example let's check what the ##make-vector function does in lib/_kernel.scm
___SCMOBJ result = ___alloc_scmobj (___sVECTOR, n<<___LWS, ___STILL);
I'm showing you how it allocates the still object as it is the simplest case.