[cffi-devel] %expand-type-to-foreign-dyn vs *runtime-translator-form*

Stephen Compall s11 at member.fsf.org
Tue Mar 14 18:01:46 UTC 2006


On Mon, 2006-03-13 at 19:28 +0000, Luís Oliveira wrote:
> I guess that picking option 1 or 3 is a matter of picking the best  
> default behavior. Isn't option 3 the most common case?

Yes, but it would require some additional definition from those who
wanted to rely on translate-*.  It would also require at least one of
the tests misc-types.expand.{5,6} to match NIL instead of T.

Consider that I have defined a string type as in your previous message.
I have defined translate-to-foreign and free-translated-object on it so
I can pass strings as arguments.  If I do not define an
expand-to-foreign-dyn as well for it:

(eval-when (:compile-toplevel :load-toplevel :execute)
  (defmethod expand-to-foreign-dyn (value var body (type-name (eql ':string)))
    (freeing-foreign-dyn-expansion value var body type-name)))

I risk something in different cases:

* Where tests 5 and 6 are NIL: The string will not be freed.

* Where test 5 is T, but 6 is NIL: If I define an expand-to-foreign
method, even if it ever returns *runtime-translator-form*, the value
will not be freed.  This is the current behavior.

* Where test 5 is NIL, but 6 is T: This is just confusing, but: the
semantic requirement from option 2 is implicitly imposed, and the value
will not be freed *unless* I define an expand-to-foreign method.

* Where both tests are T: This is essentially option 1.

-- 
Stephen Compall
http://scompall.nocandysw.com/blog




More information about the cffi-devel mailing list