-;;;; -*- Mode: ANSI-Lisp; Syntax: ANSI-Common-Lisp; Base: 10 -*-
+;;;; -*- Mode: Lisp; Syntax: ANSI-Common-Lisp; Base: 10 -*-
;;;; *************************************************************************
;;;; FILE IDENTIFICATION
;;;;
;;;; Programmer: Kevin M. Rosenberg
;;;; Date Started: Feb 2002
;;;;
-;;;; $Id: objects.cl,v 1.11 2002/03/21 14:49:14 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
;;;;
#+lispworks `(fli:make-pointer :address 0 :type ,type)
)
+(defmacro char-array-to-pointer (obj)
+ #+cmu `(alien:cast ,obj (* (alien:unsigned 8)))
+ #+lispworks `(fli:make-pointer :type '(:unsigned :char)
+ :address (fli:pointer-address ,obj))
+ #+allegro obj
+ )
+
(defmacro deref-pointer (ptr type)
"Returns a object pointed"
#+(or cmu lispworks) (declare (ignore type))
;; 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 with-foreign-object ((var type) &rest body)
+ #+allegro
+ `(let ((,var (allocate-foreign-object ,type)))
+ (unwind-protect
+ (progn ,@body)
+ (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)
(if bindings