Skip to content
Snippets Groups Projects
Commit 71e9d7cb authored by liam's avatar liam
Browse files

Sketch out how to use an imported array.

git-svn-id: svn+ssh://pop/opt/space/mathematics/gsl/trunk@3028 a3d8a0fb-c1db-0310-ace7-a616afeb9e30
parent 3976c84e
No related branches found
No related tags found
No related merge requests found
...@@ -3,7 +3,7 @@ ...@@ -3,7 +3,7 @@
; description: Using GSL storage. ; description: Using GSL storage.
; date: Sun Mar 26 2006 - 16:32 ; date: Sun Mar 26 2006 - 16:32
; author: Liam M. Healy ; author: Liam M. Healy
; modified: Fri Apr 7 2006 - 18:00 ; modified: Mon Apr 10 2006 - 23:10
;******************************************************** ;********************************************************
;;; $Id: $ ;;; $Id: $
...@@ -131,3 +131,45 @@ ...@@ -131,3 +131,45 @@
;;;(with-data (p permutation 5 #(2 3 4 0) t) foo) ;;;(with-data (p permutation 5 #(2 3 4 0) t) foo)
#|
;;; Another version, that takes a passed-in array
(defmacro with-data*
((symbol type size &optional init validate) &body body)
(let ((ptr (gensym "PTR")))
`(cffi::with-foreign-array (,ptr ,type ,size)
(let* ((,symbol
(make-instance ',(intern (format nil "GSL-~a" type))
:pointer ,ptr)))
(progn
,@(case init
(:identity `((set-identity ,symbol)))
((t) nil)
(t `((data-import ,symbol ,init))))
,@(when
validate
`((unless (data-valid ,symbol)
(error "Invalid ~a, ~a" type init))))
,@body)))))
;;; test
#+test
(with-data* (comb combination (4 i) t)
(loop collect (combination-list comb)
while (combination-next comb)))
#+expansion
(CFFI::WITH-FOREIGN-ARRAY
;;;(#:PTR3308 COMBINATION (4 I)) ; wrong
(#:PTR3308 :size ????) ; want
;;; need to C-structure here.
(LET* ((COMB
(MAKE-INSTANCE 'GSL-COMBINATION
:POINTER
#:PTR3308)))
(PROGN
(LOOP COLLECT
(COMBINATION-LIST COMB)
WHILE
(COMBINATION-NEXT COMB)))))
|#
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment