Luis Oliveira luismbo@gmail.com writes:
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)))
Honestly, I like the explicit lambdas here. It's not that much more verbose and it makes things pretty clear IMO.
(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?
James