Commit 3cd314c8 authored by Liam Healy's avatar Liam Healy
Browse files

Use fsbv:object for conversion if available; fix results of dot, cdot tests

In cl-convert-form, use fsbv:object on foreign structs if FSBV has
been loaded.  Previously, the conversion of (complex single-float) was
wrong because it assumed numbers were double-float; the test results
for dot and cdot have been fixed.
parent 158a845d
;; Expand the body of a defmfun
;; Liam Healy 2009-04-13 22:07:13EDT body-expand.lisp
;; Time-stamp: <2010-06-27 18:25:27EDT body-expand.lisp>
;; Time-stamp: <2010-11-27 13:54:41EST body-expand.lisp>
;;
;; Copyright 2009, 2010 Liam M. Healy
;; Distributed under the terms of the GNU General Public License
......@@ -84,19 +84,24 @@
(defun cl-convert-form (decl)
"Generate a form that calls the appropriate converter from C/GSL to CL."
(case (grid:st-actual-type decl)
(sf-result
`((val ,(grid:st-symbol decl))
(err ,(grid:st-symbol decl))))
(sf-result-e10
`((val ,(grid:st-symbol decl) 'sf-result-e10)
(e10 ,(grid:st-symbol decl))
(err ,(grid:st-symbol decl) 'sf-result-e10)))
(grid:complex-double-c
`((grid:complex-to-cl ,(grid:st-symbol decl) 0 'grid:complex-double-c)))
(grid:complex-float-c
`((grid:complex-to-cl ,(grid:st-symbol decl) 0 'grid:complex-float-c)))
(t `((cffi:mem-aref ,(grid:st-symbol decl) ',(grid:st-actual-type decl))))))
(or
#+fsbv
(if (member (grid:st-actual-type decl) fsbv::*libffi-struct-defs*)
`((fsbv:object ,(grid:st-symbol decl) ',(grid:st-actual-type decl))))
#-fsbv nil
(case (grid:st-actual-type decl)
(sf-result
`((val ,(grid:st-symbol decl))
(err ,(grid:st-symbol decl))))
(sf-result-e10
`((val ,(grid:st-symbol decl) 'sf-result-e10)
(e10 ,(grid:st-symbol decl))
(err ,(grid:st-symbol decl) 'sf-result-e10)))
(grid:complex-double-c
`((grid:complex-to-cl ,(grid:st-symbol decl) 'grid:complex-double-c)))
(grid:complex-float-c
`((grid:complex-to-cl ,(grid:st-symbol decl) 'grid:complex-float-c)))
(t `((cffi:mem-aref ,(grid:st-symbol decl) ',(grid:st-actual-type decl)))))))
(defun body-expand (name arglist gsl-name c-arguments key-args)
"Expand the body (computational part) of the defmfun."
......
......@@ -20,7 +20,7 @@
(LISP-UNIT:DEFINE-TEST CDOT
(LISP-UNIT::ASSERT-NUMERICAL-EQUAL
(LIST #C(-1.1684039224427728d28 0.0d0))
(LIST #C(-6252.624 -6236.0503))
(MULTIPLE-VALUE-LIST
(LET ((V1
(GRID:MAKE-FOREIGN-ARRAY
......
......@@ -50,7 +50,7 @@
-49.08d0))))
(DOT V1 V2))))
(LISP-UNIT::ASSERT-NUMERICAL-EQUAL
(LIST #C(-8.778225633844878d26 0.0d0))
(LIST #C(625.9737 -4310.1177))
(MULTIPLE-VALUE-LIST
(LET ((V1
(GRID:MAKE-FOREIGN-ARRAY
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment