[cffi-devel] translate-from-foreign
Luke Crook
luke at balooga.com
Tue May 22 16:35:08 UTC 2007
I'm trying to use translate-from-foreign on an enum. The enum returns :RM-TRUE
which I would like to convert to T, and :RM-FALSE and :RM-WHACKED which I would
like to convert to NIL. But CFFI does not seem to support translate-from-
foreign for types created with DEFCENUM. Is this observation correct?
(defmethod translate-from-foreign (value (type (eql 'rm-enum)))
(case value
(1 t)
((-1 0) nil)
(otherwise (cffi:foreign-enum-keyword 'rm-enum value))))
(cffi:defcenum #.(openrm-lispify "RMenum" 'enumname)
(#.(openrm-lispify "RM_WHACKED" 'enumvalue :keyword) -1)
(#.(openrm-lispify "RM_FALSE" 'enumvalue :keyword) 0)
(#.(openrm-lispify "RM_TRUE" 'enumvalue :keyword) 1)
(#.(openrm-lispify "RM_NATIVE_OPENGL" 'enumvalue :keyword) #x010)
(#.(openrm-lispify "RM_MESA_OPENGL" 'enumvalue :keyword) #x011)
(#.(openrm-lispify "RM_HARDWARE" 'enumvalue :keyword) #x020)
(#.(openrm-lispify "RM_SOFTWARE" 'enumvalue :keyword) #x021)
...
- Luke
More information about the cffi-devel
mailing list