>>>>> On Thu, 8 Sep 2011 17:48:57 +0100, LuÍs Oliveira said: > > On Thu, Sep 8, 2011 at 5:30 PM, Liam Healy <l...@healy.washington.dc.us> > wrote: > > Why not defcstruct (suitably enhanced, of course) for everything? I > > don't want to preclude calling by reference those foreign structures I > > also need to call by value. So something that's called exclusively by > > reference should work too. If an application which only calls by > > reference doesn't want to use the translators, we can leave them > > undefined. > > Right now (defcfun foo :void (x some-struct-type)) is identical to > (defcfun foo :void (x (:pointer some-struct-type))). If you want to > change the former to be call-by-value we need a backwards-incompatible > change to DEFCSTRUCT such that a bare SOME-STRUCT-TYPE means > call-by-value.
C has a separate namespace for struct/union tags, so a more complete alternative is to use (:struct some-struct-type) everywhere (the LispWorks FLI does this). Passing the structure by value would be (defcfun foo :void (x (:struct some-struct-type))) and passing it by reference would be (defcfun foo :void (x (:pointer (:struct some-struct-type)))) CFFI could retain the semantics of plain some-struct-type to mean (:pointer some-struct-type) at the top level of defcfun and (:struct some-struct-type) everywhere else, though it would still be broken by cases like this: typedef double foo; struct foo { int x; }; void foofoo(foo x, struct foo y); __Martin _______________________________________________ cffi-devel mailing list cffi-devel@common-lisp.net http://lists.common-lisp.net/cgi-bin/mailman/listinfo/cffi-devel