Hi,
I need to express several enumerated types in ACL foreign function
facility. The ACL FFI does not have macros to define enumerations (at
least last time I checked).
Does anybody have some working code that I could use to this end?
Thanks
--
Marco Antoniotti ========================================================
NYU Courant Bioinformatics Group tel. +1 - 212 - 998 3488
719 Broadway 12th Floor fax +1 - 212 - 995 4122
New York, NY 10003, USA http://bioinformatics.cat.nyu.edu
"Hello New York! We'll do what we can!"
Bill Murray in `Ghostbusters'.
"Marco Antoniotti" <·······@cs.nyu.edu> wrote in message
····················@octagon.mrl.nyu.edu...
>
> Hi,
>
> I need to express several enumerated types in ACL foreign function
> facility. The ACL FFI does not have macros to define enumerations (at
> least last time I checked).
>
> Does anybody have some working code that I could use to this end?
>
I seem to remember something like this in the uncommon-xml code at
http://alpha.onshore.com
Hope this helps...
Eric
"Marco Antoniotti" <·······@cs.nyu.edu> wrote in message
····················@octagon.mrl.nyu.edu...
>
> Hi,
>
> I need to express several enumerated types in ACL foreign function
> facility. The ACL FFI does not have macros to define enumerations (at
> least last time I checked).
>
> Does anybody have some working code that I could use to this end?
>
There is almost certainly a better way to do this,
the whole thing feels awkward and it's missing a way
to type the constants. This has only been tested in
the listener using LW. It's late, I'll look at it in
the morning. Newbie code, Caveat emptor, YMMV, etc.
(defmacro enum (&rest args)
(let ((count 0))
`(progn ,@(mapcar
#'(lambda (x)
(if (listp x)
(prog1
`(defconstant ,(car x) ,(cadr x))
(setf count (+ 1 (cadr x))))
(prog1
`(defconstant ,x ,count)
(incf count))))
args))))
CL-USER 1 > (enum a b c (d 10) (e 1) f )
F
CL-USER 2 > (format t "~&~{~A ~}~%" (list a b c d e f))
0 1 2 10 1 2
NIL
*Yawn*,
Geoff
I need to express several enumerated types in ACL foreign function
facility. The ACL FFI does not have macros to define enumerations
(at least last time I checked).
Does anybody have some working code that I could use to this end?
I'm not sure exactly what problem you want to solve here. My
simpleminded approach was just to define a constant that matched the
order of the enum and then used position/aref to do the mapping, e.g.
For
enum { C_SVC, NU_SVC, ONE_CLASS, EPSILON_SVR, NU_SVR }; /* svm_type */
I did
(defconstant libsvm-problem-types
#(:classification-c :classification-nu :density
:regression-epsilon :regression-nu))
and
(set-slot 'svm-type (position svm-type libsvm-problem-types))
or
(aref libsvm-problem-types svm-type)
etc.
--
Lawrence Hunter, Ph.D.
Director, Center for Computational Pharmacology
Associate Professor of Pharmacology, PMB & Computer Science
URL: http://compbio.uchsc.edu/Hunter
phone (303) 315-1094 UCHSC, Campus Box C236
fax (303) 315-1098 School of Medicine rm 2817b
cell (303) 324-0355 4200 E. 9th Ave.
email: ············@uchsc.edu Denver, CO 80262