<div dir="ltr">Hi Nicolas,<div class="gmail_extra"><br><div class="gmail_quote">On Fri, Apr 13, 2018 at 12:40 PM, Nicolas Cellier <span dir="ltr"><<a href="mailto:nicolas.cellier.aka.nice@gmail.com" target="_blank">nicolas.cellier.aka.nice@gmail.com</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left-width:1px;border-left-style:solid;border-left-color:rgb(204,204,204);padding-left:1ex"><br><div dir="ltr"><div class="gmail_extra"><div class="gmail_quote">2018-04-13 21:28 GMT+02:00 Eliot Miranda <span dir="ltr"><<a href="mailto:eliot.miranda@gmail.com" target="_blank">eliot.miranda@gmail.com</a>></span>:<br><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left-width:1px;border-left-style:solid;border-left-color:rgb(204,204,204);padding-left:1ex"> <div dir="ltr"><div class="gmail_extra"><div class="gmail_quote">On Fri, Apr 13, 2018 at 10:59 AM, Nicolas Cellier <span dir="ltr"><<a href="mailto:nicolas.cellier.aka.nice@gmail.com" target="_blank">nicolas.cellier.aka.nice@gmai<wbr>l.com</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left-width:1px;border-left-style:solid;border-left-color:rgb(204,204,204);padding-left:1ex"><div dir="ltr"><br><div class="gmail_extra"><div class="gmail_quote"><span>2018-04-13 17:08 GMT+02:00 Eliot Miranda <span dir="ltr"><<a href="mailto:eliot.miranda@gmail.com" target="_blank">eliot.miranda@gmail.com</a>></span>:<br><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left-width:1px;border-left-style:solid;border-left-color:rgb(204,204,204);padding-left:1ex"><div dir="auto"><div>Hi Nicolas,<br><br></div><span><div>On Apr 13, 2018, at 7:01 AM, Nicolas Cellier <<a href="mailto:nicolas.cellier.aka.nice@gmail.com" target="_blank">nicolas.cellier.aka.nice@gmai<wbr>l.com</a>> wrote:<br></div><blockquote type="cite"><div><div dir="ltr"><div><div><div><div><div>So I started to improve the Squeak FFI:<br></div>-1) I corrected pointer arithmetic on 64 bits <a href="http://source.squeak.org/FFI/FFI-Kernel-nice.48.diff" target="_blank">http://source.squeak.org/FFI/F<wbr>FI-Kernel-nice.48.diff</a><br></div>-2) I prepared the possibility of having automated layout spec updates <a href="http://source.squeak.org/FFI/FFI-Kernel-nice.49.diff" target="_blank">http://source.squeak.org/FFI/F<wbr>FI-Kernel-nice.49.diff</a><br><br></div>Note that the FFI plugin by itself did not change.<br></div>The next steps should be to provide support for native platform alignment of fields and unions.<br></div>I'll focus on these when i can.</div></div></blockquote></span>I shall join you as soon as I am able.  Right now I have a pressing task, but within a few weeks I should be able to help.</div></blockquote><div><br></div></span><div>Hi Eliot,<br></div><div>thanks.<br></div><div>I think that I can manage the easiest image side issues, but as soon as a feature will require an evolution of the plugin, your review is mandatory, as well as coordination with Pharo team, Backward compatibility counts and Esteban spent enough time on UFFI, so this will mean either unifying our forces or forking a plugin!<br></div></div></div></div></blockquote><div><br></div><div>Sounds good.  A fork is to be avoided at all costs.  I don't see any pressure for a fork though because the plugin is essentially defined by the platform's ABI and Andreas' design for the type specification language is sufficiently general.  Am I missing something?  (Esteban are you reading?)</div></div></div></div></blockquote><div><br></div><div>With my current understanding, two essential features are missing in the type compiledSpec:<br>- multiple indirection pointers (I've got an example of these in HDF5)<br></div></div></div></div></blockquote><div><br></div><div>What do you mean, 64 vs 32 bit pointers or?</div><div> </div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left-width:1px;border-left-style:solid;border-left-color:rgb(204,204,204);padding-left:1ex"><div dir="ltr"><div class="gmail_extra"><div class="gmail_quote"><div></div><div>- fixed size arrays in struct members (I've got an example in HDF5 too!)<br><br></div><div>For now, we can workaround with<br>- void * declaration and human crafted pointer handling<br>- unrolled array members (1 member per array slot!)<br></div></div></div></div></blockquote><div><br></div><div>I think unrolling might be a good solution.  There are relatively few types in a typical FFI interface and even fewer that have fixed size arrays in structs, so adding this would indeed create a few large specs, but in practice not many, whereas introducing support for arrays of types in the specs would add recursion into the marshaling in the plugin, and that could be error prone and slow.  Unrolling in the type to spec compiler (and re-rolling in printTypedefOn:) is probably simpler and I suspect would be far more robust.</div><div><br></div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left-width:1px;border-left-style:solid;border-left-color:rgb(204,204,204);padding-left:1ex"><div dir="ltr"><div class="gmail_extra"><div class="gmail_quote"><div>A modification of FFI would be necessary only for enforcing type checking.<br></div></div></div></div></blockquote><div><br></div><div>I'm not sure where this comes in if we unroll.  At least on callout the plugin merely checks that a structure is of the right size, and if specified the right subclass of ExternalStructure.  That's still sufficient if we realign instances of ExternalStructure on startup right?</div><div> </div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left-width:1px;border-left-style:solid;border-left-color:rgb(204,204,204);padding-left:1ex"><div dir="ltr"><div class="gmail_extra"><div class="gmail_quote"><div></div><div>I don't plan anything right now, and I agree that doing so with backward compatibility is by far preferred.<br></div></div></div></div></blockquote><div><br></div><div>+1000.</div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left-width:1px;border-left-style:solid;border-left-color:rgb(204,204,204);padding-left:1ex"><div dir="ltr"><div class="gmail_extra"><div class="gmail_quote"><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left-width:1px;border-left-style:solid;border-left-color:rgb(204,204,204);padding-left:1ex"><div dir="ltr"><div class="gmail_extra"><div class="gmail_quote"><div></div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left-width:1px;border-left-style:solid;border-left-color:rgb(204,204,204);padding-left:1ex"><div dir="ltr"><div class="gmail_extra"><div class="gmail_quote"><span><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left-width:1px;border-left-style:solid;border-left-color:rgb(204,204,204);padding-left:1ex"><div dir="auto"><span><div><blockquote type="cite"><div><div class="gmail_extra"><div class="gmail_quote">2018-04-12 23:27 GMT+02:00 Denis Kudriashov <span dir="ltr"><<a href="mailto:dionisiydk@gmail.com" target="_blank">dionisiydk@gmail.com</a>></span>:<br><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left-width:1px;border-left-style:solid;border-left-color:rgb(204,204,204);padding-left:1ex"><div dir="ltr">Hi<div><br></div><div>There is project <a href="https://github.com/estebanlm/TalkFFI" target="_blank">TalkFFI</a> from Ciprian Teodorov.</div></div><div class="gmail-m_-8608280351672206870m_4600202436944168543m_-4665315498895994616m_6538023448696195102HOEnZb"><div class="gmail-m_-8608280351672206870m_4600202436944168543m_-4665315498895994616m_6538023448696195102h5"><div class="gmail_extra"><br><div class="gmail_quote">2018-04-12 22:50 GMT+02:00 Bert Freudenberg <span dir="ltr"><<a href="mailto:bert@freudenbergs.de" target="_blank">bert@freudenbergs.de</a>></span>:<br><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left-width:1px;border-left-style:solid;border-left-color:rgb(204,204,204);padding-left:1ex"><div dir="ltr"><span><div style="font-family:arial,helvetica,sans-serif;font-size:small;color:rgb(0,0,0)"><span style="font-family:arial,sans-serif;color:rgb(34,34,34)">On 12 April 2018 at 22:34, Nicolas Cellier </span><span dir="ltr" style="font-family:arial,sans-serif;color:rgb(34,34,34)"><<a href="mailto:nicolas.cellier.aka.nice@gmail.com" target="_blank">nicolas.cellier.aka.nice@gmai<wbr>l.com</a>></span><span style="font-family:arial,sans-serif;color:rgb(34,34,34)"> wrote:</span><br></div></span><div class="gmail_extra"><div class="gmail_quote"><span><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left-width:1px;border-left-style:solid;border-left-color:rgb(204,204,204);padding-left:1ex"><div dir="ltr"><div class="gmail_extra"><div class="gmail_quote"><span class="gmail-m_-8608280351672206870m_4600202436944168543m_-4665315498895994616m_6538023448696195102m_-1260474800631308584m_2694655752977270737gmail-"><div><br></div></span><div>There are at least two problems:<br></div><div>- documentation (lack of)<br></div><div>- limitations (unions, pointer on pointer on ...)<br></div><div>- automation (I said at least two, not at most)<br></div><div><br></div><div>For the first problem, I opened the SO issues. Not ideal, but it's a start.<br></div><div>For the second, I'll see if I can do something...<br></div><div>For the third, I did import some .h header with VW DLLCC, and I'm in the process of translating to other dialects.<br>It's easier because Smalltalk syntax is order of magnitudes smaller than C syntax.</div></div></div></div></blockquote><div><br></div></span><div><div style="font-family:arial,helvetica,sans-serif;font-size:small;color:rgb(0,0,0)">​I always thought it should be fairly straightforward to make a FFI bindings generator using SWIG (<span style="font-family:arial,sans-serif;color:rgb(34,34,34)"><a href="http://www.swig.org/" target="_blank">http://www.swig.org/</a>).</span></div><div style="font-family:arial,helvetica,sans-serif;font-size:small;color:rgb(0,0,0)"><span style="font-family:arial,sans-serif;color:rgb(34,34,34)"><br></span></div><div style="font-family:arial,helvetica,sans-serif;font-size:small;color:rgb(0,0,0)"><span style="font-family:arial,sans-serif;color:rgb(34,34,34)">SWIG parses C headers and outputs XML. Starting from that XML should be way easier than trying to parse C ourselves.</span></div></div><span class="gmail-m_-8608280351672206870m_4600202436944168543m_-4665315498895994616m_6538023448696195102m_-1260474800631308584HOEnZb"><font color="#888888"><div><br></div><div style="font-family:arial,helvetica,sans-serif;font-size:small;color:rgb(0,0,0)">​- Bert -​</div></font></span></div></div></div></blockquote></div></div></div></div></blockquote></div></div></div></blockquote></div></span></div></blockquote></span></div></div></div></blockquote></div>-- <br><div class="gmail-m_-8608280351672206870m_4600202436944168543gmail_signature"><div dir="ltr"><div><span style="font-size:small;border-collapse:separate"><div>_,,,^..^,,,_<br></div><div>best, Eliot</div></span></div></div></div>
</div></div>
</blockquote></div></div></div></blockquote></div><br><div class="gmail_signature"><div dir="ltr"><div><span style="font-size:small;border-collapse:separate"><div>_,,,^..^,,,_<br></div><div>best, Eliot</div></span></div></div></div>
</div></div>