interfacing u16vector from the inside of a c-lambda
Here is a simple piece of code to do it: ;; double each element of v (with length n) in place (define double! (c-lambda (scheme-object int) ; the vector and it's length void "//extract array from scheme object ___U16* v = ___CAST(___U16*, ___BODY_AS(___arg1, ___tSUBTYPED)); // perform the C operations int i; for (i=0; i<___arg2; i+=1) { v[i] += v[i]; }")) (define *v* (u16vector 0 1 2 3 4 5)) (display *v*) (newline) (double! *v* (u16vector-length *v*)) (display *v*) For more details, the Gambit site, specifically http://dynamo.iro.umontreal.ca/~gambit/wiki/index.php/Using_Gambit_with_Exte... has many details. Chris D.
Afficher les réponses par date
participants (1)
-
Christopher Dutchyn