Skip to content
Snippets Groups Projects
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
No related branches found
No related tags found
No related merge requests found
;; Helpers for defining GSL functions on arrays ;; Helpers for defining GSL functions on arrays
;; Liam Healy 2009-01-07 22:01:16EST defmfun-array.lisp ;; 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: $ ;; $Id: $
(in-package :gsl) (in-package :gsl)
...@@ -132,13 +132,6 @@ ...@@ -132,13 +132,6 @@
(string-downcase (symbol-name category)) :category (string-downcase (symbol-name category)) :category
base-name)))))))))) 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 (defun actual-class-arglist
(arglist element-type c-arguments &optional replace-both) (arglist element-type c-arguments &optional replace-both)
"Replace the prototype arglist with an actual arglist." "Replace the prototype arglist with an actual arglist."
...@@ -152,9 +145,9 @@ ...@@ -152,9 +145,9 @@
(if (and replacing (listp arg)) (if (and replacing (listp arg))
(list (first arg) (list (first arg)
(case (second arg) (case (second arg)
(:element-type (number-class-from-type element-type)) (:element-type (number-class element-type))
(:component-float-type (:component-float-type
(number-class-from-type (component-float-type element-type))) (number-class (component-float-type element-type)))
(otherwise (otherwise
(data-class-name (data-class-name
(if (and (eq (second arg) 'both) replace-both) (if (and (eq (second arg) 'both) replace-both)
......
;; Number types used by GSL functions, and specification conversion ;; Number types used by GSL functions, and specification conversion
;; Liam Healy 2008-12-31 21:06:34EST types.lisp ;; 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: $ ;; $Id: $
(in-package :gsl) (in-package :gsl)
...@@ -207,3 +207,9 @@ ...@@ -207,3 +207,9 @@
"The CL type from the CFFI element type." "The CL type from the CFFI element type."
(unless (eq cffi-type :pointer) (unless (eq cffi-type :pointer)
(lookup-type cffi-type *cstd-cl-type-mapping*))) (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*))
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment