<div class="gmail_quote">On Sun, May 27, 2012 at 4:48 PM, Luís Oliveira <span dir="ltr"><<a href="mailto:luismbo@gmail.com" target="_blank">luismbo@gmail.com</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">




<div>On Sun, May 27, 2012 at 9:15 PM, Luís Oliveira <<a href="mailto:luismbo@gmail.com" target="_blank">luismbo@gmail.com</a>> wrote:<br>
> Did you notice the function lisp-string-to-foreign? Seems like a<br>
> cleaner way to implement translate-into-foreign-memory.<br>
<br>
</div>More importantly, how can you be translating a string without<br>
performing allocation in this case? Also, in general,<br>
translate-into-foreign-memory for strings should definitely refuse to<br>
accept string types without an explicit size. (Which is not<br>
implemented yet, IIRC.)<br>
<br>
In any case, why does Ryan's example need translate-into-foreign-memory?</blockquote><div><br>Yeah, the new method is the wrong thing, I need to revert this change.  When foreign-funcall-form is called and fsbvp=T, it calls translate-objects with indirect=T, which in turn calls #'expand-to-foreign-dyn-indirect on each of the arguments.  When an argument is a foreign-string-type, the trouble begins.   The foreign string is represented by a pointer, as indicated by the (:actual-type :pointer) in the define-foreign-type.  All libffi really needs is a pointer to the pointer, and there is a method for expand-to-foreign-dyn-indirect for foreign-pointer-type, but foreign-string-type is not a subclass of foreign-pointer-type. <br>


<br>It seems like the resolution is to define a method for expand-to-foreign-dyn-indirect for the foreign-type-alias class that does a recursive call using the actual-type.  Does that make sense?  As a side point, expand-to-foreign-dyn has a similar method but it is defined for enhanced-typedef (subclass chain: enhanced-typedef < foreign-typedef < foreign-type-alias); is there any reason why that method shouldn't be defined for foreign-type-alias instead?<br>


<br>Liam<br></div></div>