X-Git-Url: http://git.kpe.io/?a=blobdiff_plain;f=src%2Fprimitives.lisp;h=0133de3e2fae2f960bfb68f1bb98c4b1d404efdb;hb=c6c305a69913c148753813cc057be7127017ae6a;hp=6147753d8847a874b1afe7238d6b2666d199ad37;hpb=054eef05bc69478566de63cc3bfb19ce411179c4;p=uffi.git diff --git a/src/primitives.lisp b/src/primitives.lisp index 6147753..0133de3 100644 --- a/src/primitives.lisp +++ b/src/primitives.lisp @@ -7,7 +7,7 @@ ;;;; Programmer: Kevin M. Rosenberg ;;;; Date Started: Feb 2002 ;;;; -;;;; $Id: primitives.lisp,v 1.2 2002/10/01 17:05:29 kevin Exp $ +;;;; $Id: primitives.lisp,v 1.3 2002/10/14 01:51:15 kevin Exp $ ;;;; ;;;; This file, part of UFFI, is Copyright (c) 2002 by Kevin M. Rosenberg ;;;; @@ -84,11 +84,14 @@ supports takes advantage of this optimization." (eval-when (:compile-toplevel :load-toplevel :execute) (defvar +type-conversion-hash+ (make-hash-table :size 20)) - #+(or cmu sbcl) (defvar +cmu-def-type-hash+ (make-hash-table :size 20)) + #+(or cmu sbcl) (defvar *cmu-def-type-hash* (make-hash-table :size 20)) ) +#+(or cmu sbcl) +(defparameter *cmu-sbcl-def-type-list* nil) + #+cmu -(defconstant +cmu-def-type-list+ +(defparameter *cmu-sbcl-def-type-list* '((:char . (alien:signed 8)) (:unsigned-char . (alien:unsigned 8)) (:byte . (alien:signed 8)) @@ -104,7 +107,7 @@ supports takes advantage of this optimization." ) "Conversions in CMUCL for def-foreign-type are different than in def-function") #+sbcl -(defconstant +cmu-def-type-list+ +(defparameter *cmu-sbcl-def-type-list* '((:char . (sb-alien:signed 8)) (:unsigned-char . (sb-alien:unsigned 8)) (:byte . (sb-alien:signed 8)) @@ -120,10 +123,10 @@ supports takes advantage of this optimization." ) "Conversions in SBCL for def-foreign-type are different than in def-function") -(defparameter +type-conversion-list+ nil) +(defparameter *type-conversion-list* nil) #+cmu -(setq +type-conversion-list+ +(setq *type-conversion-list* '((* . *) (:void . c-call:void) (:short . c-call:short) (:pointer-void . (* t)) @@ -140,24 +143,24 @@ supports takes advantage of this optimization." (:array . alien:array))) #+sbcl -(setq +type-conversion-list+ - '((* . *) (:void . void) - (:short . short) +(setq *type-conversion-list* + '((* . *) (:void . sb-alien:void) + (:short . sb-alien:short) (:pointer-void . (* t)) - (:cstring . c-string) - (:char . char) + (:cstring . sb-alien:c-string) + (:char . sb-alien:char) (:unsigned-char . (sb-alien:unsigned 8)) (:byte . (sb-alien:signed 8)) (:unsigned-byte . (sb-alien:unsigned 8)) - (:short . unsigned-short) - (:unsigned-short . unsigned-short) - (:int . integer) (:unsigned-int . unsigned-int) - (:long . long) (:unsigned-long . unsigned-long) - (:float . float) (:double . double) - (:array . array))) + (:short . sb-alien:unsigned-short) + (:unsigned-short . sb-alien:unsigned-short) + (:int . sb-alien:integer) (:unsigned-int . sb-alien:unsigned-int) + (:long . sb-alien:long) (:unsigned-long . sb-alien:unsigned-long) + (:float . sb-alien:float) (:double . sb-alien:double) + (:array . sb-alien:array))) #+(or allegro cormanlisp) -(setq +type-conversion-list+ +(setq *type-conversion-list* '((* . *) (:void . :void) (:short . :short) (:pointer-void . (* :void)) @@ -172,7 +175,7 @@ supports takes advantage of this optimization." (:array . :array))) #+lispworks -(setq +type-conversion-list+ +(setq *type-conversion-list* '((* . :pointer) (:void . :void) (:short . :short) (:pointer-void . (:pointer :void)) @@ -189,7 +192,7 @@ supports takes advantage of this optimization." (:array . :c-array))) #+(and mcl (not openmcl)) -(setq +type-conversion-list+ +(setq *type-conversion-list* '((* . :pointer) (:void . :void) (:short . :short) (:unsigned-short . :unsigned-short) (:pointer-void . :pointer) @@ -203,7 +206,7 @@ supports takes advantage of this optimization." (:array . :array))) #+openmcl -(setq +type-conversion-list+ +(setq *type-conversion-list* '((* . :address) (:void . :void) (:short . :short) (:unsigned-short . :unsigned-short) (:pointer-void . :address) @@ -217,12 +220,12 @@ supports takes advantage of this optimization." (:float . :single-float) (:double . :double-float) (:array . :array))) -(dolist (type +type-conversion-list+) +(dolist (type *type-conversion-list*) (setf (gethash (car type) +type-conversion-hash+) (cdr type))) #+(or cmu sbcl) -(dolist (type +cmu-def-type-list+) - (setf (gethash (car type) +cmu-def-type-hash+) (cdr type))) +(dolist (type *cmu-sbcl-def-type-list*) + (setf (gethash (car type) *cmu-def-type-hash*) (cdr type))) (defun basic-convert-from-uffi-type (type) (let ((found-type (gethash type +type-conversion-hash+))) @@ -241,7 +244,7 @@ supports takes advantage of this optimization." (setq type '((* :char) integer))) #+(or cmu sbcl) ((eq context :type) - (let ((cmu-type (gethash type +cmu-def-type-hash+))) + (let ((cmu-type (gethash type *cmu-def-type-hash*))) (if cmu-type cmu-type (basic-convert-from-uffi-type type))))