X-Git-Url: http://git.kpe.io/?a=blobdiff_plain;f=src%2Fobjects.cl;h=b0b34f07ca98fb8191238cdf7f9fd8e5285c24eb;hb=4054fe997dbce15071a1d2b96a082b4a4a5a8363;hp=1ac0ad8b4080f6c1836a10b69eb447d2be3b9693;hpb=5709e7e3117996052ca59d6b997f8e73c74d8bb0;p=uffi.git diff --git a/src/objects.cl b/src/objects.cl index 1ac0ad8..b0b34f0 100644 --- a/src/objects.cl +++ b/src/objects.cl @@ -7,7 +7,7 @@ ;;;; Programmer: Kevin M. Rosenberg ;;;; Date Started: Feb 2002 ;;;; -;;;; $Id: objects.cl,v 1.10 2002/03/21 07:56:45 kevin Exp $ +;;;; $Id: objects.cl,v 1.11 2002/03/21 14:49:14 kevin Exp $ ;;;; ;;;; This file, part of UFFI, is Copyright (c) 2002 by Kevin M. Rosenberg ;;;; @@ -100,19 +100,21 @@ an array of TYPE with size SIZE." obj ) -#| -(defmacro allocate-byte-array (nsize) - #+cmu - `(alien:make-alien (alien:unsigned 8) ,nsize) - #+lispworks - `(fli:allocate-foreign-object :type :byte :nelems ,nsize) - #+allegro - `(ff:allocate-fobject (array :byte ,nsize)) -) +;; Simple first pass. Will later create optimized routines for +;; various platforms. +(defmacro with-foreign-object ((var type &rest etc) &rest body) + (let ((result (gensym))) + `(let* ((,var (allocate-foreign-object ,type ,@etc)) + (,result (progn ,@body))) + (free-foreign-object ,var) + ,result))) -(defmacro deref-byte-array (array position) - #+cmu `(alien:deref ,array ,position) - #+lispworks `(fli:dereference ,array :index ,position) - #+allegro `(ff:fslot-value-typed '(:array :byte) :c ,array ,position) -) -|# +(defmacro with-foreign-objects (bindings &rest body) + (if bindings + `(with-foreign-object ,(car bindings) + (with-foreign-objects ,(cdr bindings) + ,@body)) + `(progn ,@body))) + + +