[cffi-devel] problem with translation to foreign types

Tamas K Papp tpapp at Princeton.EDU
Mon Apr 21 13:55:26 UTC 2008


On Mon, Apr 21, 2008 at 01:54:05PM +0100, Luís Oliveira wrote:
> On Mon, Apr 21, 2008 at 12:42 AM, Tamas K Papp <tpapp at princeton.edu> wrote:
> >  (cffi:defctype my-double :double)
> >
> >  (defmethod cffi:translate-to-foreign (value (type (eql 'my-double)))
> >   (coerce value 'double-float))
> 
> That should be:
> 
> * (define-foreign-type my-double-type ()
>     ()
>     (:actual-type :double)
>     (:simple-parser my-double))
> 
> MY-DOUBLE-TYPE
> * (defmethod translate-to-foreign (value (type my-double-type))
>     (coerce value 'double-float))
> 
> #<STANDARD-METHOD TRANSLATE-TO-FOREIGN (T MY-DOUBLE-TYPE) {1003370511}>
> * (convert-to-foreign 10 'my-double)
> 
> 10.0d0

Hi Luis,

Thanks for the fast response, it fixed my problem.

Maybe mentioning define-foreign-type in section 5.4 (Foreign Type
Translators) of the manual would help.  Your example works perfectly,
but the define-foreign-type documentation mentions neither
:actual-type and :simple-parser.

Tamas



More information about the cffi-devel mailing list