r1613: Updated to use stack allocation
[uffi.git] / src / objects.cl
index 7f10ab5ba30124e4a08f5e43edf5b7b4c3abbff8..6a33f9b1cc04a9b145e6c27924ad13ddbef7d4e0 100644 (file)
@@ -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)