On 4/ago/2005, at 05:09, Rayiner Hashem wrote:
- How does the translator interface express more complex C values?
Say, I want the "to-c" clause to send a struct to the C code? Can I just return an object allocated by foreign-object-alloc?
Yes, why not. That's pretty much what the string translator does.
- Is there any way to make translations optional, and only invoke
them on particular arguments in a given function declaration?
Sounds easy to implement (within defcfun at least) but I guess it's not that useful. If you don't want the string to be translated, just use :pointer (or eventually something like (* :char), for a typed pointer, or another some other appropriate type), same for boolean vs. :int.
I'm also thinking about one other thing. Say I'm wrapping this function:
void cairo_line_to(cairo_t* cr, double x, double y);
I'd like the Lisp declaration to be as if the function was:
(defun cairo-line-to (cr pt) ...) where 't' is a 'point' structure or maybe just a (x . y) cons cell. Would it be reasonable to include that kind of translation in the FFI, or would it be more prudent to put that in a higher layer?
Hmm, I'm trying to figure out if this is worth the trouble. Probably not this summer. This kind of stuff is interesting to me though, it'd be nice to avoid the need for the user to defun wrappers around the ffi whenever possible and this is a nice example. Need to figure out a good way of doing this kind of things.