From de6c38979da779441669d5ed8fc6cb569201f845 Mon Sep 17 00:00:00 2001 From: "Kevin M. Rosenberg" Date: Thu, 21 Mar 2002 16:47:59 +0000 Subject: [PATCH] r1613: Updated to use stack allocation --- ChangeLog | 1 + Makefile | 4 ++-- src/objects.cl | 19 ++++++++++++++----- 3 files changed, 17 insertions(+), 7 deletions(-) diff --git a/ChangeLog b/ChangeLog index fe54d30..300f25e 100644 --- a/ChangeLog +++ b/ChangeLog @@ -16,6 +16,7 @@ See TODO file -- actively maintained. Includes changes that you * Added gethostname2 to examples/gethostname.cl which uses with-foreign-object * Added char-array-to-pointer function to encapsulate converting a char array to a pointer to char + * Converted with-foreign-object to use stack allocation on CMUCL and LW 20 Mar 2002 * Updated strings.cl so that foreign-strings are always unsigned. diff --git a/Makefile b/Makefile index 6be1b72..52b3aab 100644 --- a/Makefile +++ b/Makefile @@ -5,7 +5,7 @@ # Programer: Kevin M. Rosenberg, M.D. # Date Started: Mar 2002 # -# CVS Id: $Id: Makefile,v 1.27 2002/03/21 14:49:14 kevin Exp $ +# CVS Id: $Id: Makefile,v 1.28 2002/03/21 16:47:59 kevin Exp $ # # This file, part of UFFI, is Copyright (c) 2002 by Kevin M. Rosenberg # @@ -31,7 +31,7 @@ realclean: clean docs: @(cd doc; make dist-doc) -VERSION=0.2.11 +VERSION=0.2.12 DISTDIR=uffi-${VERSION} DIST_TARBALL=${DISTDIR}.tar.gz DIST_ZIP=${DISTDIR}.zip diff --git a/src/objects.cl b/src/objects.cl index 7f10ab5..6a33f9b 100644 --- a/src/objects.cl +++ b/src/objects.cl @@ -1,4 +1,4 @@ -;;;; -*- Mode: ANSI-Lisp; Syntax: ANSI-Common-Lisp; Base: 10 -*- +;;;; -*- Mode: Lisp; Syntax: ANSI-Common-Lisp; Base: 10 -*- ;;;; ************************************************************************* ;;;; FILE IDENTIFICATION ;;;; @@ -7,7 +7,7 @@ ;;;; Programmer: Kevin M. Rosenberg ;;;; Date Started: Feb 2002 ;;;; -;;;; $Id: objects.cl,v 1.12 2002/03/21 15:57:01 kevin Exp $ +;;;; $Id: objects.cl,v 1.13 2002/03/21 16:47:46 kevin Exp $ ;;;; ;;;; This file, part of UFFI, is Copyright (c) 2002 by Kevin M. Rosenberg ;;;; @@ -109,11 +109,20 @@ an array of TYPE with size SIZE." ;; Simple first pass. Will later create optimized routines for ;; various platforms. -(defmacro with-foreign-object ((var type &rest etc) &rest body) - `(let ((,var (allocate-foreign-object ,type ,@etc))) +(defmacro with-foreign-object ((var type) &rest body) + #+allegro + `(let ((,var (allocate-foreign-object ,type))) (unwind-protect (progn ,@body) - (free-foreign-object ,var)))) + (free-foreign-object ,var))) + #+cmu + `(alien:with-alien ((,var ,(convert-from-uffi-type type :allocate))) + (setq ,var (alien:addr ,var)) + ,@body) + #+lispworks + `(fli:with-dynamic-foreign-objects ((,var ,(convert-from-uffi-type type :allocate))) + ,@body) + ) (defmacro with-foreign-objects (bindings &rest body) -- 2.34.1