[cffi-devel] passing a list of numbers to double *
![](https://secure.gravatar.com/avatar/13663028cac36d0b9ff102354f298263.jpg?s=120&d=mm&r=g)
Hi, I have a function that looks like this: void myfunction(const double *values, int num_values); that expects a C array of doubles along with its length. SWIG generated the CFFI interface (cffi:defcfun ("myfunction" myfunction) :void (values :pointer) (num_values :int)) Imagine that I have a list '(1d0 2d0 3d0). What is the easiest way to call this function with these values? I am reading the CFFI documentation, but could not find this, sorry if this is an obvious question, just please point me in the right direction. Thanks, Tamas
![](https://secure.gravatar.com/avatar/51004fb1ed7a9faec361b6dd7787fc9f.jpg?s=120&d=mm&r=g)
On Wed, 2007-05-16 at 16:25 -0400, Tamas K Papp wrote:
I am reading the CFFI documentation, but could not find this, sorry if this is an obvious question, just please point me in the right direction.
Look at with-foreign-object. I have been doing other things so am not up to speed on newtypes, but there should be something there as powerful as specializing expand-to-foreign-dyn, if you need to pass double*s often. Don't trust the binding generator: see chapter 4, "Wrapper generators". -- ;;; Stephen Compall ** http://scompall.nocandysw.com/blog ** Failure to imagine vast possibilities usually stems from a lack of imagination, not a lack of possibility.
participants (2)
-
Stephen Compall
-
Tamas K Papp