Advertisement
Guest User

Untitled

a guest
May 12th, 2020
123
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.01 KB | None | 0 0
  1. (cffi:defcstruct (complex-single-float :class foreign-complex-single-float)
  2. (real :float)
  3. (imag :float))
  4.  
  5. (cffi:defctype complex-single-float (:struct complex-single-float))
  6.  
  7. (defmethod cffi:translate-from-foreign (ptr (type foreign-complex-single-float))
  8. (cffi:with-foreign-slots ((real imag) ptr (:struct complex-single-float))
  9. (complex real imag)))
  10.  
  11. (defmethod cffi:expand-from-foreign (ptr (type foreign-complex-single-float))
  12. `(cffi:with-foreign-slots ((real imag) ,ptr (:struct complex-single-float))
  13. (complex real imag)))
  14.  
  15. (defmethod cffi:translate-into-foreign-memory (value (type foreign-complex-single-float) ptr)
  16. (cffi:with-foreign-slots ((real imag) ptr (:struct complex-single-float))
  17. (setf real (realpart value)
  18. imag (imagpart value))))
  19.  
  20. ;;; A test function to see if the above stuff works.
  21.  
  22. (cffi:defcfun ("conjf" %conjf) complex-single-float
  23. (z :pointer))
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement