Commit 0912e504 authored by Liam M. Healy's avatar Liam M. Healy
Browse files

Function #'number-class finds the CL class from the number type

Function #'number-class finds the CL class from the number type,
replacing the previous function #'number-class-from-type in
init/defmfun-array.lisp.  It is a bit more general.
parent 7a78c863
;; Helpers for defining GSL functions on arrays
;; Liam Healy 2009-01-07 22:01:16EST defmfun-array.lisp
;; Time-stamp: <2009-10-18 19:35:15EDT defmfun-array.lisp>
;; Time-stamp: <2009-11-30 16:13:13EST defmfun-array.lisp>
;; $Id: $
(in-package :gsl)
......@@ -132,13 +132,6 @@
(string-downcase (symbol-name category)) :category
base-name))))))))))
(defun number-class-from-type (type)
"Find a class name that contains this type."
;; Not exhaustive; just trying to separate reals and complex.
(cond ((subtypep type 'complex) 'complex)
((subtypep type 'float) 'float)
(t (error "Can't pass type ~a." type))))
(defun actual-class-arglist
(arglist element-type c-arguments &optional replace-both)
"Replace the prototype arglist with an actual arglist."
......@@ -152,9 +145,9 @@
(if (and replacing (listp arg))
(list (first arg)
(case (second arg)
(:element-type (number-class-from-type element-type))
(:element-type (number-class element-type))
(:component-float-type
(number-class-from-type (component-float-type element-type)))
(number-class (component-float-type element-type)))
(otherwise
(data-class-name
(if (and (eq (second arg) 'both) replace-both)
......
;; Number types used by GSL functions, and specification conversion
;; Liam Healy 2008-12-31 21:06:34EST types.lisp
;; Time-stamp: <2009-11-14 10:54:53EST types.lisp>
;; Time-stamp: <2009-11-30 16:13:18EST types.lisp>
;; $Id: $
(in-package :gsl)
......@@ -207,3 +207,9 @@
"The CL type from the CFFI element type."
(unless (eq cffi-type :pointer)
(lookup-type cffi-type *cstd-cl-type-mapping*)))
;;; For future use
(defparameter *cl-numeric-classes* '(ratio integer rational float real complex number))
(defun number-class (type)
"Find the class corresponding to the numeric type."
(find-if (lambda (class) (subtypep type class)) *cl-numeric-classes*))
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