From f2e583c0ecfea3b54aa77935c374fd6d4dd0cfcb Mon Sep 17 00:00:00 2001 From: William Robinson Date: Tue, 4 Mar 2008 10:49:21 +0000 Subject: [PATCH] Author: D Herring Date: Tue Mar 4 00:10:35 2008 -0500 Update lib/types.lisp for February 2007 CFFI (breaks 0.9.2) Luis changed the CFFI type system. In particular, DEFCTYPE now simply creates aliases which cannot support custom type translation (much like the C++ typedef). For details, see http://common-lisp.net/cgi-bin/darcsweb/darcsweb.cgi?r=cffi-cffi;a=commit;h=20070219011856-28748-e5c1f319e17f91d8e38f3cf906d14a5db40ba365.gz http://article.gmane.org/gmane.lisp.cffi.devel/1029 --- lib/types.lisp | 33 ++++++++++++++++++--------------- 1 file changed, 18 insertions(+), 15 deletions(-) diff --git a/lib/types.lisp b/lib/types.lisp index e5c87f4..c6f8c80 100644 --- a/lib/types.lisp +++ b/lib/types.lisp @@ -11,7 +11,10 @@ (in-package #:cl-glfw-types) (defctype enum :uint32) -(defctype boolean :uint8) +(define-foreign-type boolean-type () + () + (:actual-type :uint8) + (:simple-parser boolean)) (defctype bitfield :uint32) (defctype byte :int8) (defctype short :int16) @@ -20,10 +23,16 @@ (defctype ubyte :uint8) (defctype ushort :uint16) (defctype uint :uint32) -(defctype float :float) -(defctype clampf :float) -(defctype double :double) -(defctype clampd :double) +(define-foreign-type float-type () + () + (:actual-type :float) + (:simple-parser float)) +(defctype clampf float) +(define-foreign-type double-type () + () + (:actual-type :double) + (:simple-parser double)) +(defctype clampd double) (defctype void :void) #-cffi-features:no-long-long @@ -43,22 +52,16 @@ (defctype half :unsigned-short) ; this is how glext.h defines it anyway -(defmethod cffi:expand-to-foreign (value (type (eql 'boolean))) +(defmethod cffi:expand-to-foreign (value (type boolean-type)) `(if ,value 1 0)) -(defmethod cffi:expand-from-foreign (value (type (eql 'boolean))) +(defmethod cffi:expand-from-foreign (value (type boolean-type)) `(not (= ,value 0))) -(defmethod cffi:expand-to-foreign (value (type (eql 'clampf))) +(defmethod cffi:expand-to-foreign (value (type float-type)) `(coerce ,value 'single-float)) -(defmethod cffi:expand-to-foreign (value (type (eql 'clampd))) - `(coerce ,value 'double-float)) - -(defmethod cffi:expand-to-foreign (value (type (eql 'float))) - `(coerce ,value 'single-float)) - -(defmethod cffi:expand-to-foreign (value (type (eql 'double))) +(defmethod cffi:expand-to-foreign (value (type double-type)) `(coerce ,value 'double-float)) ;; TODO: Maybe we can find/write a converter to a half? Does anyone want it? -- 2.11.4.GIT