From: Kenny Tilton
Subject: Yikes! Vasilis's FFI is over my head....
Date: 
Message-ID: <Jpnnd.18253$Vk6.2736@twister.nyc.rr.com>
Paging any/all Clisp FFI and/or UFFI whizzes (I'll try their lists, too, 
but I am not sure which is better and youse guys respond fastest):

(defun gtk-object-set-property (obj property val-type val)
   (let ((varargs-def
	 `(c-struct list
	   (value ,val-type)
	   (end c-pointer))))
     (with-c-var (vec varargs-def (list val nil))
       (g-object-set-valist obj property
              (c-var-address (slot vec 'value))))))

Whoa. Advanced stuff. I see UFFI has with-foreign-object, but that does 
not take optional initialization. OK, I just do the initialization 
procedurally in the body? I'll live.

And that type-on-the-fly `(c-struct list ...) -- no can do in UFFI, I 
think. I need to break that out as a standalone:

    (uffi:defstruct valist..)?

kt

-- 
Cells? Cello? Celtik?: http://www.common-lisp.net/project/cells/
Why Lisp? http://alu.cliki.net/RtL%20Highlight%20Film

From: Kalle Olavi Niemitalo
Subject: Re: Yikes! Vasilis's FFI is over my head....
Date: 
Message-ID: <87sm75g5bn.fsf@Astalo.kon.iki.fi>
Kenny Tilton <·······@nyc.rr.com> quotes:

> (defun gtk-object-set-property (obj property val-type val)
>    (let ((varargs-def
> 	 `(c-struct list
> 	   (value ,val-type)
> 	   (end c-pointer))))
>      (with-c-var (vec varargs-def (list val nil))
>        (g-object-set-valist obj property
>               (c-var-address (slot vec 'value))))))

This seems to assume that va_list is simply a pointer, and that
variadic arguments are stored and padded in the same way as
members of structures.  These assumptions may hold on x86, but
at least the first one fails on Alpha.
From: Joerg Hoehle
Subject: Re: Yikes! Vasilis's FFI is over my head....
Date: 
Message-ID: <ufz2i3suh.fsf@users.sourceforge.net>
Kenny Tilton <·······@nyc.rr.com> writes:

> Paging any/all Clisp FFI and/or UFFI whizzes (I'll try their lists, too, 
> but I am not sure which is better and youse guys respond fastest):
[...]
> Whoa. Advanced stuff. [...] 
> And that type-on-the-fly `(c-struct list ...) -- no can do in UFFI, I 
> think. I need to break that out as a standalone:
>     (uffi:defstruct valist..)?

I believe you'll have to resort to one case per type with
UFFI. uffi:with-cast-pointer may help. I found a few places in cl-sql
where something similar is done, resulting in N distinct functions.
Maybe you can limit N to just handle int8/16/32 and opaque pointers,
maybe add single/double-float and that could be enough (UFFI tends to
manipulate mostly primitive types).

Esp. if this gtk stuff is in fact an arglist (or taglist), there are
even more restriction which may limit N. Typically a taglist may have
a fixed-size variable kind (i.e. always a union of int (or long) +
pointer, and small ints are just casted by the C compiler but still
need sizeof(int) bytes. This is just a wild guess on my part.

Regards,
	Jorg Hohle
Telekom/T-Systems Technology Center