X-Git-Url: http://git.kpe.io/?a=blobdiff_plain;f=src%2Fobjects.lisp;h=6ec32234aaa87792332dc39ebc2bb0a4c65784ed;hb=868ae7fad94b80592524dea37eae1000075605c6;hp=940c941cc42f6d09338c22f90b8bc0d9e45949e0;hpb=1330decaa5c85fe9eda4f8933269e2dbaae2f7a7;p=uffi.git diff --git a/src/objects.lisp b/src/objects.lisp index 940c941..6ec3223 100644 --- a/src/objects.lisp +++ b/src/objects.lisp @@ -51,9 +51,21 @@ an array of TYPE with size SIZE. The TYPE parameter is evaluated." ) (progn #+(or cmu scl) - `(alien:make-alien ,(convert-from-uffi-type (eval type) :allocation) ,size) + (if (integerp size) + `(alien:cast + (alien:make-alien ,(convert-from-uffi-type (eval type) :allocation) ,size) + (array ,(convert-from-uffi-type (eval type) :allocation) ,size)) + `(alien:cast + (alien:make-alien ,(convert-from-uffi-type (eval type) :allocation) ,size) + (array ,(convert-from-uffi-type (eval type) :allocation) nil))) #+sbcl - `(sb-alien:make-alien ,(convert-from-uffi-type (eval type) :allocation) ,size) + (if (integerp size) + `(sb-alien:cast + (sb-alien:make-alien ,(convert-from-uffi-type (eval type) :allocation) ,size) + (array ,(convert-from-uffi-type (eval type) :allocation) ,size)) + `(sb-alien:cast + (sb-alien:make-alien ,(convert-from-uffi-type (eval type) :allocation) ,size) + (array ,(convert-from-uffi-type (eval type) :allocation) nil))) #+lispworks `(fli:allocate-foreign-object :type ',(convert-from-uffi-type type :allocate) :nelems ,size) #+allegro @@ -171,10 +183,15 @@ an array of TYPE with size SIZE. The TYPE parameter is evaluated." (let ((,var (alien:addr ,obj))) ,@body))) #+sbcl - (let ((obj (gensym))) - `(sb-alien:with-alien ((,obj ,(convert-from-uffi-type (eval type) :allocate))) - (let ((,var (sb-alien:addr ,obj))) - ,@body))) + (let ((obj (gensym)) + (ctype (convert-from-uffi-type (eval type) :allocate))) + (if (and (consp ctype) (eq 'array (car ctype))) + `(sb-alien:with-alien ((,obj ,ctype)) + (let* ((,var ,obj)) + ,@body)) + `(sb-alien:with-alien ((,obj ,ctype)) + (let* ((,var (sb-alien:addr ,obj))) + ,@body)))) #+lispworks `(fli:with-dynamic-foreign-objects ((,var ,(convert-from-uffi-type (eval type) :allocate)))