X-Git-Url: https://git.distorted.org.uk/~mdw/clg/blobdiff_plain/46759268573d82db67eac23b54c8fb63d2187be7..4f805161e70cf5f9a07a8e20d819b4abe436022a:/glib/ffi.lisp diff --git a/glib/ffi.lisp b/glib/ffi.lisp index 759f43d..385a7c4 100644 --- a/glib/ffi.lisp +++ b/glib/ffi.lisp @@ -15,7 +15,7 @@ ;; License along with this library; if not, write to the Free Software ;; Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA -;; $Id: ffi.lisp,v 1.16 2005-02-22 17:27:25 espen Exp $ +;; $Id: ffi.lisp,v 1.18 2005-03-13 18:06:51 espen Exp $ (in-package "GLIB") @@ -207,10 +207,14 @@ `(,name ,(alien-type type)))) args)) ,(to-alien-form - `(let (,@(mapcar #'(lambda (arg) - (destructuring-bind (name type) arg - `(,name ,(from-alien-form name type)))) - args)) + `(let (,@(delete nil + (mapcar #'(lambda (arg) + (destructuring-bind (name type) arg + (let ((from-alien + (from-alien-form name type))) + (unless (eq name from-alien) + `(,name ,from-alien))))) + args))) ,@body) return-type)))) @@ -218,6 +222,8 @@ (defun callback (af) (sb-alien:alien-function-sap af)) +#+sbcl +(deftype callback () 'sb-alien:alien-function) ;;;; Definitons and translations of fundamental types @@ -461,6 +467,15 @@ (declare (ignore type args)) +size-of-float+) +(defmethod to-alien-form (form (type (eql 'single-float)) &rest args) + (declare (ignore type args)) + `(coerce ,form 'single-float)) + +(defmethod to-alien-function ((type (eql 'single-float)) &rest args) + (declare (ignore type args)) + #'(lambda (number) + (coerce number 'single-float))) + (defmethod writer-function ((type (eql 'single-float)) &rest args) (declare (ignore type args)) #'(lambda (value location &optional (offset 0)) @@ -480,6 +495,15 @@ (declare (ignore type args)) +size-of-double+) +(defmethod to-alien-form (form (type (eql 'double-float)) &rest args) + (declare (ignore type args)) + `(coerce ,form 'double-float)) + +(defmethod to-alien-function ((type (eql 'double-float)) &rest args) + (declare (ignore type args)) + #'(lambda (number) + (coerce number 'double-float))) + (defmethod writer-function ((type (eql 'double-float)) &rest args) (declare (ignore type args)) #'(lambda (value location &optional (offset 0))