Loading c-array/foreign-array.lisp +7 −5 Original line number Diff line number Diff line ;; Foreign (C or C-compatible) arrays ;; Liam Healy 2008-12-28 10:44:22EST foreign-array.lisp ;; Time-stamp: <2010-04-25 21:27:18EDT foreign-array.lisp> ;; Time-stamp: <2010-04-26 09:51:57EDT foreign-array.lisp> ;; ;; Copyright 2008, 2009 Liam M. Healy ;; Distributed under the terms of the GNU General Public License Loading Loading @@ -191,9 +191,10 @@ (row-major-aref array array-index)))))) (defun copy-array-from-pointer (array pointer lisp-type index-offset length) "Copy length elements from array (starting at index-offset) of type lisp-type from the memory area that starts at pointer, coercing the elements if necessary." "Copy the foreign array at the pointer into a CL array. Copy 'length elements from the foreign array (starting at index-offset) of type 'lisp-type from the memory area, coercing the elements if necessary. Return the CL array." (let ((cffi-type (component-type lisp-type))) (loop :repeat length for pointer-index :from 0 :by (if (subtypep lisp-type 'complex) 2 1) Loading @@ -204,7 +205,8 @@ (complex (cffi:mem-aref pointer cffi-type pointer-index) (cffi:mem-aref pointer cffi-type (1+ pointer-index))) (cffi:mem-aref pointer cffi-type pointer-index)))))) (cffi:mem-aref pointer cffi-type pointer-index)))) array)) ;;;;**************************************************************************** ;;;; Make CL arrays from foreign arrays Loading Loading
c-array/foreign-array.lisp +7 −5 Original line number Diff line number Diff line ;; Foreign (C or C-compatible) arrays ;; Liam Healy 2008-12-28 10:44:22EST foreign-array.lisp ;; Time-stamp: <2010-04-25 21:27:18EDT foreign-array.lisp> ;; Time-stamp: <2010-04-26 09:51:57EDT foreign-array.lisp> ;; ;; Copyright 2008, 2009 Liam M. Healy ;; Distributed under the terms of the GNU General Public License Loading Loading @@ -191,9 +191,10 @@ (row-major-aref array array-index)))))) (defun copy-array-from-pointer (array pointer lisp-type index-offset length) "Copy length elements from array (starting at index-offset) of type lisp-type from the memory area that starts at pointer, coercing the elements if necessary." "Copy the foreign array at the pointer into a CL array. Copy 'length elements from the foreign array (starting at index-offset) of type 'lisp-type from the memory area, coercing the elements if necessary. Return the CL array." (let ((cffi-type (component-type lisp-type))) (loop :repeat length for pointer-index :from 0 :by (if (subtypep lisp-type 'complex) 2 1) Loading @@ -204,7 +205,8 @@ (complex (cffi:mem-aref pointer cffi-type pointer-index) (cffi:mem-aref pointer cffi-type (1+ pointer-index))) (cffi:mem-aref pointer cffi-type pointer-index)))))) (cffi:mem-aref pointer cffi-type pointer-index)))) array)) ;;;;**************************************************************************** ;;;; Make CL arrays from foreign arrays Loading