[cffi-devel] DEFINE-TYPE-TRANSLATOR and EVAL-WHEN

James Bielman jamesjb at jamesjb.com
Fri Dec 23 14:10:02 UTC 2005


Luis,

Can you think of any reasons why this would be a bad idea? (modulo the
annoying STYLE-WARNINGs from SBCL about method redefinition I guess...)

I added some type translators to the new examples I'm working on and got
bitten by the fact that DEFINE-TYPE-TRANSLATOR doesn't make the
translator available until load time.  I think it's best for it to
expand into an EVAL-WHEN like DEFCFUN, DEFCTYPE, etc, unless there's
some problem I'm not thinking of:

--- old-cffi/src/types.lisp     2005-12-23 03:04:40.000000000 -0800
+++ new-cffi/src/types.lisp     2005-12-23 05:47:58.000000000 -0800
@@ -685,7 +685,7 @@
         (:to-c-dynamic (values 'to-c-dynamic-form nil)))
     (let ((type-spec `(,(gensym "TYPE") (eql ',type)))
           (args (delete nil (list value-arg var-arg body-arg))))
-      `(progn
+      `(eval-when (:compile-toplevel :load-toplevel :execute)
          (defmethod ,form-method (,type-spec , at args)
            , at body)
          ,(when translate-method      ; no method for to-c-dynamic

James





More information about the cffi-devel mailing list