On 4/ago/2005, at 04:57, James Bielman wrote:
;; IMO the cleanest, but also verbose, using a function ;; that returns the form using backquote: :in (lambda (var value body) `(let ((,var (foreign-string-alloc ,value))) (unwind-protect (progn ,@body) (foreign-string-free ,var))))
After trying to implement this and realizing some of my assumptions were incorrect (eg. (symbol-)macrolet for &$var won't work, I'd need to search for it in the form) I got to these two syntaxes:
(define-type-translation string :pointer "Translation between C and Lisp strings." :to-c-arg (lambda (var value body) `(with-foreign-string (,var ,value) ,@body)) :to-c (lambda (value) `(foreign-string-alloc ,value)) :from-c (lambda (value) `(foreign-string-to-lisp ,value)))
(define-type-translation string :pointer "Translation between C and Lisp strings." (:to-c-arg (var value body) `(with-foreign-string (,var ,value) ,@body)) (:to-c (value) `(foreign-string-alloc ,value)) (:from-c (value) `(foreign-string-to-lisp ,value)))
Preferences and/or comments anyone?