X-Git-Url: https://www.chiark.greenend.org.uk/ucgi/~mdw/git/clg/blobdiff_plain/39ccb07932be1bab5d35fc4520f3dbec1511ac64..refs/heads/cvs:/gffi/interface.lisp diff --git a/gffi/interface.lisp b/gffi/interface.lisp index fd6be5e..f5b8b77 100644 --- a/gffi/interface.lisp +++ b/gffi/interface.lisp @@ -20,7 +20,7 @@ ;; TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE ;; SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. -;; $Id: interface.lisp,v 1.6 2007/09/07 07:28:42 espen Exp $ +;; $Id: interface.lisp,v 1.10 2008/12/10 02:40:18 espen Exp $ (in-package "GFFI") @@ -128,8 +128,15 @@ (defmacro defbinding (name lambda-list return-type &rest args) (list (cond ((and (namep expr) (not (in-arg-p style))) expr) - ((namep expr) (make-symbol (string expr))) - ((gensym))) + ((namep expr) + #-clisp(make-symbol (string expr)) + ;; The above used to work in CLISP, but I'm + ;; not sure exactly at which version it + ;; broke. The following could potentially + ;; cause variable capturing + #+clisp(intern (format nil "~A-~A" (string expr) (gensym)))) + (#-clisp(gensym) + #+clisp(intern (string (gensym))))) (or aux expr) type style out-type)))) args))) @@ -209,7 +216,8 @@ (defun %defbinding (cname lisp-name lambda-list declare-p arg-types aux-bindings when (out-arg-p style) collect (return-type out-type) when (return-arg-p style) - collect (return-type type))))))) + collect (return-type type)))) + ,lisp-name))) (defun ,lisp-name ,lambda-list ,doc (let ,aux-bindings @@ -306,7 +314,10 @@ (defmacro define-callback (name return-type args &body body) (let ((define-callback #+cmu'alien:def-callback #+(and sbcl alien-callbacks)'sb-alien::define-alien-callback - #+(and sbcl (not alien-callbacks))'sb-alien:define-alien-function)) + #+(and sbcl (not alien-callbacks))'sb-alien:define-alien-function) + (args (mapcar #'(lambda (arg) + (if (atom arg) (list arg arg) arg)) + args))) `(progn #+cmu(defparameter ,name nil) (,define-callback ,name @@ -383,8 +394,11 @@ (defun restore-callback-pointers () ;;; translated according to RETTYPE. Obtain a pointer that can be ;;; passed to C code for this callback by calling %CALLBACK. (defmacro define-callback (name return-type args &body body) - (let ((arg-names (mapcar #'first args)) - (arg-types (mapcar #'second args))) + (let* ((args (mapcar #'(lambda (arg) + (if (atom arg) (list arg arg) arg)) + args)) + (arg-names (mapcar #'first args)) + (arg-types (mapcar #'second args))) `(progn (defvar ,name ',name) (register-callback ',name @@ -431,6 +445,8 @@ (defun type-expand-to (type form) (error "~A can not be expanded to ~A" form type)))))) (expand form))) +(defun type-equal-p (type1 type2) + (and (subtypep type1 type2) (subtypep type2 type1))) ;;;; Type methods