X-Git-Url: http://git.kpe.io/?a=blobdiff_plain;f=src%2Fobjects.lisp;h=33bd042e71048e36dec970f0c78e20a58f5f2386;hb=cdf0c1b6baea88081a47b5e07320ba1ddb466e26;hp=e9a2024112ec409b26c136a3deda65020ba8ca16;hpb=09464c82191ef241c749756bbad5ffaadd8f6e5f;p=uffi.git diff --git a/src/objects.lisp b/src/objects.lisp index e9a2024..33bd042 100644 --- a/src/objects.lisp +++ b/src/objects.lisp @@ -9,11 +9,8 @@ ;;;; ;;;; $Id$ ;;;; -;;;; This file, part of UFFI, is Copyright (c) 2002 by Kevin M. Rosenberg +;;;; This file, part of UFFI, is Copyright (c) 2002-2005 by Kevin M. Rosenberg ;;;; -;;;; UFFI users are granted the rights to distribute and use this software -;;;; as governed by the terms of the Lisp Lesser GNU Public License -;;;; (http://opensource.franz.com/preamble.html), also known as the LLGPL. ;;;; ************************************************************************* (in-package #:uffi) @@ -132,12 +129,14 @@ an array of TYPE with size SIZE. The TYPE parameter is evaluated." #+(or (and mcl (not openmcl))) obj #+(or allegro cmu sbcl scl openmcl) `(code-char ,obj) ;; lispworks varies whether deref'ing array vs. slot access of a char - #+lispworks - `(if (characterp ,obj) ,obj (code-char ,obj))) + #+lispworks `(if (characterp ,obj) ,obj (code-char ,obj))) (defmacro ensure-char-integer (obj) #+(or (and mcl (not openmcl))) `(char-code ,obj) - #+(or allegro cmu sbcl scl openmcl) obj) + #+(or allegro cmu sbcl scl openmcl) obj + ;; lispworks varies whether deref'ing array vs. slot access of a char + #+lispworks + `(if (integerp ,obj) ,obj (char-code ,obj))) (defmacro ensure-char-storable (obj) #+(or lispworks (and mcl (not openmcl))) obj @@ -243,6 +242,12 @@ an array of TYPE with size SIZE. The TYPE parameter is evaluated." '(error "WITH-CAST-POINTER not (yet) implemented for ~A" (lisp-implementation-type))) +#+(or allegro openmcl) +(defun convert-external-name (name) + "Add an underscore to NAME if necessary for the ABI." + #+(or macosx darwinppc-target) (concatenate 'string "_" name) + #-(or macosx darwinppc-target) name) + (defmacro def-foreign-var (names type module) #-lispworks (declare (ignore module)) (let ((foreign-name (if (atom names) names (first names))) @@ -256,7 +261,7 @@ an array of TYPE with size SIZE. The TYPE parameter is evaluated." #+allegro `(define-symbol-macro ,lisp-name (ff:fslot-value-typed (quote ,(convert-from-uffi-type type :deref)) - :c (ff:get-entry-point ,foreign-name))) + :c (ff:get-entry-point ,(convert-external-name foreign-name)))) #+lispworks `(progn (fli:define-foreign-variable (,lisp-name ,foreign-name) @@ -265,11 +270,10 @@ an array of TYPE with size SIZE. The TYPE parameter is evaluated." :module ,module) (define-symbol-macro ,lisp-name (fli:dereference (,lisp-name) :copy-foreign-object nil))) - #+(and openmcl darwinppc-target) - (setf foreign-name (concatenate 'string "_" foreign-name)) #+openmcl `(define-symbol-macro ,lisp-name - (deref-pointer (ccl:foreign-symbol-address ,foreign-name) ,var-type)) + (deref-pointer (ccl:foreign-symbol-address + ,(convert-external-name foreign-name)) ,var-type)) #-(or allegro cmu scl sbcl lispworks openmcl) `(define-symbol-macro ,lisp-name '(error "DEF-FOREIGN-VAR not (yet) defined for ~A"