Question about Allegro FFI:
Suppose I have C-function that returns ENUM, something
like
typedef enum
{
CONNECTION_OK,
CONNECTION_BAD,
.............
};
Is it possible somehow arrange that in Allegro FFI, like
ENUM in CMUCL's ALIEN for example ?
Do you now ?
--
Vladimir Zolotykh
Vladimir Zolotykh <······@eurocom.od.ua> writes:
> Question about Allegro FFI:
>
> Suppose I have C-function that returns ENUM, something
> like
>
> typedef enum
> {
> CONNECTION_OK,
> CONNECTION_BAD,
> .............
> };
>
> Is it possible somehow arrange that in Allegro FFI, like
> ENUM in CMUCL's ALIEN for example ?
>
> Do you now ?
>
Not that I know.
In theory it is not too difficult to provide a macro that does
somenting like DEFINE-ENUM. But you are taking advntage of the fact
that your C compiler may accept things like
typedef enum {uno = 1, dos, tres} caballeros;
int x = 1;
void foo(caballeros z) { ... }
...
foo(x);
In any case, it would be a nice thing to have in the ACL FFI.
Cheers
--
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'.
In article <·················@eurocom.od.ua>, Vladimir Zolotykh wrote:
> Is it possible somehow arrange that in Allegro FFI, like
> ENUM in CMUCL's ALIEN for example ?
UFFI (http://uffi.med-info.com) has a DEF-ENUM macro that supports ACL.
--
Kevin Rosenberg
·····@rosenberg.net
I've took a glance to it. The DEF-ENUM interns some
symbols and defines constants also it issues:
(ff:def-foreign-type my-enum-type :int)
This my-enum-type should be passed to uffi:def-function as
RETURNING argument which in turn gives
(ff:def-foreign-call foo
......
:returning my-enum-type
.....
)
Here is the point I still don't understand. After calling FOO
I should COND result to see match with defined by DEF-ENUM
constants, while CMUCL ALIEN allows me just write
(case (foo ...)
(:one ..)
(:two ..)
)
Still additional (though very small) layer remains. There is a
chance that I just don't understand what UFFI can and can't do. If
so please correct me.
Kevin Rosenberg wrote:
>
> In article <·················@eurocom.od.ua>, Vladimir Zolotykh wrote:
> > Is it possible somehow arrange that in Allegro FFI, like
> > ENUM in CMUCL's ALIEN for example ?
>
> UFFI (http://uffi.med-info.com) has a DEF-ENUM macro that supports ACL.
>
--
Vladimir Zolotykh