;;;; Programmer: Kevin M. Rosenberg
;;;; Date Started: Feb 2002
;;;;
-;;;; $Id: libraries.cl,v 1.4 2002/03/16 22:54:06 kevin Exp $
+;;;; $Id: libraries.cl,v 1.5 2002/03/21 04:05:15 kevin Exp $
;;;;
;;;; This file, part of UFFI, is Copyright (c) 2002 by Kevin M. Rosenberg
;;;;
(defvar *loaded-libraries* nil
"List of foreign libraries loaded. Used to prevent reloading a library")
-(defun load-foreign-library (filename &key module supporting-libraries)
+(defun load-foreign-library (filename &key module supporting-libraries
+ force-load)
#+allegro (declare (ignore module supporting-libraries))
#+lispworks (declare (ignore supporting-libraries))
#+cmu (declare (ignore module))
(if (pathnamep filename) ;; ensure filename is a string to check if
(setq filename (namestring filename))) ; already loaded
- (if (find filename *loaded-libraries* :test #'string-equal)
+ (if (and (not force-load)
+ (find filename *loaded-libraries* :test #'string-equal))
t ;; return T, but don't reload library
(progn
#+cmu (alien:load-foreign filename
;;;; Programmer: Kevin M. Rosenberg
;;;; Date Started: Feb 2002
;;;;
-;;;; $Id: strings.cl,v 1.8 2002/03/19 16:42:59 kevin Exp $
+;;;; $Id: strings.cl,v 1.9 2002/03/21 04:05:15 kevin Exp $
;;;;
;;;; This file, part of UFFI, is Copyright (c) 2002 by Kevin M. Rosenberg
;;;;
`(ff:allocate-fobject :char :c ,size)
)
-(defmacro with-cstring ((foreign-string lisp-string) &body body)
+(defmacro with-foreign-string ((foreign-string lisp-string) &body body)
+ (let ((result (gensym)))
+ `(let* ((,foreign-string (convert-to-foreign-string ,lisp-string))
+ (,result (progn ,@body)))
+ (declare (dynamic-extent ,foreign-string))
+ (free-foreign-object ,foreign-string)
+ ,result)))
+
+(defmacro with-cstring ((cstring lisp-string) &body body)
#+cmu
- `(let ((,foreign-string ,lisp-string)) ,@body)
+ `(let ((,cstring ,lisp-string)) ,@body)
#+allegro
(let ((acl-native (gensym)))
`(excl:with-native-string (,acl-native ,lisp-string)
- (let ((,foreign-string (if ,lisp-string ,acl-native 0)))
+ (let ((,cstring (if ,lisp-string ,acl-native 0)))
,@body)))
#+lispworks
(let ((result (gensym)))
- `(let* ((,foreign-string (convert-to-cstring ,lisp-string))
- (,result ,@body))
- (fli:free-foreign-object ,foreign-string)
+ `(let* ((,cstring (convert-to-cstring ,lisp-string))
+ (,result (progn ,@body)))
+ (fli:free-foreign-object ,cstring)
,result))
)
+
+
;; Modified from CMUCL's source to handle non-null terminated strings
#+cmu
(defun cmucl-naturalize-cstring (sap &key
;;;; Programmer: Kevin M. Rosenberg
;;;; Date Started: Feb 2002
;;;;
-;;;; $Id: test-examples.cl,v 1.5 2002/03/18 02:27:32 kevin Exp $
+;;;; $Id: test-examples.cl,v 1.6 2002/03/21 04:05:15 kevin Exp $
;;;;
;;;; This file, part of UFFI, is Copyright (c) 2002 by Kevin M. Rosenberg
;;;;
:directory '(:relative "examples"))
*load-truename*))))
+ (load-test "c-test-fns")
(load-test "array-2d")
(load-test "strtol")
(load-test "gettime")