Skip to content
Snippets Groups Projects
Commit 104e13ca authored by Liam Healy's avatar Liam Healy
Browse files

Generalize gref-mpointer-form to set values and fix documentation

parent 4d69bb66
No related branches found
No related tags found
No related merge requests found
;; Functions for both vectors and matrices. ;; Functions for both vectors and matrices.
;; Liam Healy 2008-04-26 20:48:44EDT both.lisp ;; Liam Healy 2008-04-26 20:48:44EDT both.lisp
;; Time-stamp: <2010-07-06 22:37:34EDT both.lisp> ;; Time-stamp: <2010-07-11 18:37:28EDT both.lisp>
;; ;;
;; Copyright 2008, 2009 Liam M. Healy ;; Copyright 2008, 2009 Liam M. Healy
;; Distributed under the terms of the GNU General Public License ;; Distributed under the terms of the GNU General Public License
...@@ -78,9 +78,6 @@ ...@@ -78,9 +78,6 @@
"Exchange the elements of a and b "Exchange the elements of a and b
by copying. The two must have the same dimensions.") by copying. The two must have the same dimensions.")
;;; These functions are here as debugging tools only; they do not insure
;;; coherency between the C and CL sides and therefore should not be
;;; used in production.
;;; For matrix functions, there should be another index argument ;;; For matrix functions, there should be another index argument
#| #|
(defmfun set-value ((object vector) index value) (defmfun set-value ((object vector) index value)
......
;; Foreign callback functions. ;; Foreign callback functions.
;; Liam Healy ;; Liam Healy
;; Time-stamp: <2010-06-29 22:51:19EDT callback.lisp> ;; Time-stamp: <2010-07-11 19:01:17EDT callback.lisp>
;; ;;
;; Copyright 2009 Liam M. Healy ;; Copyright 2009 Liam M. Healy
;; Distributed under the terms of the GNU General Public License ;; Distributed under the terms of the GNU General Public License
...@@ -37,14 +37,13 @@ ...@@ -37,14 +37,13 @@
;;; they are defined with those tasks. The macro #'defmcallback can ;;; they are defined with those tasks. The macro #'defmcallback can
;;; specify that the CL function is to expect in arglist and return as ;;; specify that the CL function is to expect in arglist and return as
;;; multiple values scalar quantities that come from and will be bound ;;; multiple values scalar quantities that come from and will be bound
;;; to either grid:foreign-arrays or C vectors. This is done with a list of the ;;; to either grid:foreign-arrays. This is done with a list of the
;;; type and size, e.g. (:double 3), and for setting :set, type size, ;;; type and size, e.g. (:double 3), and for setting :set, type size,
;;; e.g. (:set :double 3). If the 'grid:foreign-array argument is nil, it will ;;; e.g. (:set :double 3). These can read either :cvector or
;;; expand to read or set a C vector; if it is T, it will expand to ;;; :foreign-array. This allows the user to define ordinary CL
;;; read or set a grid:foreign-array. This allows the user to define ordinary CL
;;; functions with scalars as input and output. However, it may be ;;; functions with scalars as input and output. However, it may be
;;; desirable to read and set grid:foreign-arrays, in which case :pointer is the ;;; desirable to read and set grid:foreign-arrays, in which case
;;; right specification. ;;; :pointer is the right specification.
;;;;**************************************************************************** ;;;;****************************************************************************
;;;; Setting slots ;;;; Setting slots
......
;; Generate a lambda that calls the user function; will be called by callback. ;; Generate a lambda that calls the user function; will be called by callback.
;; Liam Healy ;; Liam Healy
;; Time-stamp: <2010-07-10 22:18:51EDT funcallable.lisp> ;; Time-stamp: <2010-07-11 18:12:29EDT funcallable.lisp>
;; ;;
;; Copyright 2009 Liam M. Healy ;; Copyright 2009, 2010 Liam M. Healy
;; Distributed under the terms of the GNU General Public License ;; Distributed under the terms of the GNU General Public License
;; ;;
;; This program is free software: you can redistribute it and/or modify ;; This program is free software: you can redistribute it and/or modify
...@@ -66,13 +66,17 @@ ...@@ -66,13 +66,17 @@
;;;;**************************************************************************** ;;;;****************************************************************************
(defun gref-mpointer-form (defun gref-mpointer-form
(mpointer index &optional (category 'vector) (element-type 'double-float)) (mpointer index &optional value (category 'vector) (element-type 'double-float))
"Create the call that will return an element from a GSL array mpointer." "Create the call that will return an element from a GSL array mpointer,
or set it to value if value is non-NIL."
(ffexpand (ffexpand
nil nil
(actual-gsl-function-name (actual-gsl-function-name
'("gsl_" :category :type "_get") category element-type) `("gsl_" :category :type ,(if value "_set" "_get"))
`(:pointer ,mpointer sizet ,index ,element-type))) category element-type)
(if value
`(:pointer ,mpointer sizet ,index ,element-type ,value :void)
`(:pointer ,mpointer sizet ,index ,element-type))))
(defun reference-foreign-element (defun reference-foreign-element
(foreign-variable-name linear-index argspec dimension-values) (foreign-variable-name linear-index argspec dimension-values)
...@@ -92,7 +96,7 @@ ...@@ -92,7 +96,7 @@
(parse-callback-argspec argspec 'element-type)) (parse-callback-argspec argspec 'element-type))
;; A vector ;; A vector
(gref-mpointer-form (gref-mpointer-form
foreign-variable-name linear-index 'vector foreign-variable-name linear-index nil 'vector
(parse-callback-argspec argspec 'element-type))) (parse-callback-argspec argspec 'element-type)))
`(cffi:mem-aref `(cffi:mem-aref
,foreign-variable-name ,foreign-variable-name
......
;; Definition of GSL objects and ways to use them. ;; Definition of GSL objects and ways to use them.
;; Liam Healy, Sun Dec 3 2006 - 10:21 ;; Liam Healy, Sun Dec 3 2006 - 10:21
;; Time-stamp: <2010-07-07 14:30:30EDT mobject.lisp> ;; Time-stamp: <2010-07-11 17:07:40EDT mobject.lisp>
;; ;;
;; Copyright 2006, 2007, 2008, 2009 Liam M. Healy ;; Copyright 2006, 2007, 2008, 2009 Liam M. Healy
;; Distributed under the terms of the GNU General Public License ;; Distributed under the terms of the GNU General Public License
...@@ -62,7 +62,7 @@ ...@@ -62,7 +62,7 @@
;;; allocate-inputs ;;; allocate-inputs
;;; freer ;;; freer
;;; callbacks ;;; callbacks
;;; See callbacks.lisp ;;; See callback.lisp
;;; superclasses ;;; superclasses
;;; List of superclasses other than 'mobject. ;;; List of superclasses other than 'mobject.
;;; singular ;;; singular
......
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