Commit 104e13ca authored by Liam Healy's avatar Liam Healy

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

parent 4d69bb66
;; Functions for both vectors and matrices.
;; 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
;; Distributed under the terms of the GNU General Public License
......@@ -78,9 +78,6 @@
"Exchange the elements of a and b
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
#|
(defmfun set-value ((object vector) index value)
......
;; Foreign callback functions.
;; 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
;; Distributed under the terms of the GNU General Public License
......@@ -37,14 +37,13 @@
;;; they are defined with those tasks. The macro #'defmcallback can
;;; specify that the CL function is to expect in arglist and return as
;;; 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,
;;; e.g. (:set :double 3). If the 'grid:foreign-array argument is nil, it will
;;; expand to read or set a C vector; if it is T, it will expand to
;;; read or set a grid:foreign-array. This allows the user to define ordinary CL
;;; e.g. (:set :double 3). These can read either :cvector or
;;; :foreign-array. This allows the user to define ordinary CL
;;; 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
;;; right specification.
;;; desirable to read and set grid:foreign-arrays, in which case
;;; :pointer is the right specification.
;;;;****************************************************************************
;;;; Setting slots
......
;; Generate a lambda that calls the user function; will be called by callback.
;; 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
;;
;; This program is free software: you can redistribute it and/or modify
......@@ -66,13 +66,17 @@
;;;;****************************************************************************
(defun gref-mpointer-form
(mpointer index &optional (category 'vector) (element-type 'double-float))
"Create the call that will return an element from a GSL array mpointer."
(mpointer index &optional value (category 'vector) (element-type 'double-float))
"Create the call that will return an element from a GSL array mpointer,
or set it to value if value is non-NIL."
(ffexpand
nil
(actual-gsl-function-name
'("gsl_" :category :type "_get") category element-type)
`(:pointer ,mpointer sizet ,index ,element-type)))
`("gsl_" :category :type ,(if value "_set" "_get"))
category element-type)
(if value
`(:pointer ,mpointer sizet ,index ,element-type ,value :void)
`(:pointer ,mpointer sizet ,index ,element-type))))
(defun reference-foreign-element
(foreign-variable-name linear-index argspec dimension-values)
......@@ -92,7 +96,7 @@
(parse-callback-argspec argspec 'element-type))
;; A vector
(gref-mpointer-form
foreign-variable-name linear-index 'vector
foreign-variable-name linear-index nil 'vector
(parse-callback-argspec argspec 'element-type)))
`(cffi:mem-aref
,foreign-variable-name
......
;; Definition of GSL objects and ways to use them.
;; 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
;; Distributed under the terms of the GNU General Public License
......@@ -62,7 +62,7 @@
;;; allocate-inputs
;;; freer
;;; callbacks
;;; See callbacks.lisp
;;; See callback.lisp
;;; superclasses
;;; List of superclasses other than 'mobject.
;;; singular
......
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