From: Vladimir Zolotykh
Subject: ACL FFI question
Date: 
Message-ID: <3CDE79B6.2F3174B3@eurocom.od.ua>
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

From: Marco Antoniotti
Subject: Re: ACL FFI question
Date: 
Message-ID: <y6cn0v5nfhn.fsf@octagon.mrl.nyu.edu>
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'.
From: Kevin Rosenberg
Subject: Re: ACL FFI question
Date: 
Message-ID: <slrnadtv18.ojt.kevin@tiger.med-info.com>
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
From: Vladimir Zolotykh
Subject: Re: ACL FFI question
Date: 
Message-ID: <3CDFBE31.A3030115@eurocom.od.ua>
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