<div dir="ltr"><br><div class="gmail_extra"><br><div class="gmail_quote">2018-04-12 3:10 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:1px solid rgb(204,204,204);padding-left:1ex"><div dir="ltr">Hi Nicolas,<div class="gmail_extra"><br><div class="gmail_quote"><span class="gmail-">On Wed, Apr 11, 2018 at 2:23 PM, Nicolas Cellier <span dir="ltr"><<a href="mailto:nicolas.cellier.aka.nice@gmail.com" target="_blank">nicolas.cellier.aka.nice@<wbr>gmail.com</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex"><div dir="ltr"><div><div>I'm trying to see how hard it is to port my HDF5 work from VW to Squeak.<br>It was not a pleasure in VW, because that already raised some questions despite that there is a somehow detailed DLLCC manual:<br><br><a href="https://stackoverflow.com/questions/49544642/why-cant-i-pass-an-uninterpretedbytes-to-a-void-thru-dll-c-connect" target="_blank">https://stackoverflow.com/ques<wbr>tions/49544642/why-cant-i-pass<wbr>-an-uninterpretedbytes-to-a-<wbr>void-thru-dll-c-connect</a><br><a href="https://stackoverflow.com/questions/49564024/isnt-pointer-type-checking-disabled-in-dll-c-connect-and-is-that-ok" target="_blank">https://stackoverflow.com/ques<wbr>tions/49564024/isnt-pointer-<wbr>type-checking-disabled-in-dll-<wbr>c-connect-and-is-that-ok</a></div></div></div></blockquote><div><br></div></span><div>What are you actually trying to do?  Can you post the C definitions?  I'm very familiar with both the SqueakFFI and DLLCC (as of 7.4.1) and the basic differences are to do with DLLCC's better cross-platform support, in that it auto-redefines typedefs on load.  But other than that I think the SqueakFFI is either just as good, or in some cases better (e.g. DLLCC has a bug in that it is the actual parameter that carries detailed type information for a struct, whereas in Andreas' SqueakFFI it is, correctly, the formal parameter).</div><span class="gmail-"><div><br></div></span></div></div></div></blockquote><div>Hi Eliot,<br></div><div>the library is huge (HDF5).
<div>All the interfacing code is available at cincom public store (HDF5 bundle)</div>

</div><div>To get an idea, you can inspect a clone of HDF5 library at <a href="https://github.com/live-clones/hdf5/tree/develop/src">https://github.com/live-clones/hdf5/tree/develop/src</a><br></div><div>The main structures/enum/typedefs/prototypes are in the H5*public.h files<br><br></div><div>The problems are all exposed in SO questions, but I can try and priotitize.<br><br></div><div>The essential barrier is that those headers use almost exclusively typedef'ed types.<br></div><div>Library is too huge for manual subsitution; this must be mechanized.<br></div><div>I would prefer some kind of support in FFI rather than having to hack own fragile ad-hoc pre-processor.<br></div><div><br></div><div>Then I have a problem because of alignment of struct fields which is compact in Squeak FFI rather than conforming to platform conventions.<br></div><div>Same here, manually hacking with field size is a no go, this must be mechanized.<br></div><div><br></div><div>Then some unions are used too and there is no support at all in FFI.<br><br></div><div>Then definitions like size_t are dependent on machine word size (32 or 64 bits), and there is no support for that in FFI.<br>I'll have to duplicate some work for supporting both 32 and 64 bits Squeak, or explore new hacks...<br></div><div>But there is no support and no documentation (how to).<br></div><div><br></div><div>Then while digging in source coden I did not see any double pointer support in struct fields.<br></div><div>The example I provide on SO shows what I would qualify as a bug.<br></div><div>I don't know yet whether I'll need those, but it's not good.<br></div><div><br></div><div>Maybe I can shoot each problem with more or less ugly 
workarounds.<br>At the end i can declare void * and deal with offset directly, but that's both:<br></div><div>- a lot of work<br></div><div>- a good recipe for generating very hard to find bugs - crashes if lucky, silent corruption if not<br></div><div> (dealing with offsets is like writing in assembler instead of C)<br><br></div><div>Given the size of the library, the probability of not creating such fault in manual translation is 0%<br></div><div>Plus, there are a few evolutions from one version of the library to the other...<br><br></div><div>That's my definition of hard++<br><br></div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex"><div dir="ltr"><div class="gmail_extra"><div class="gmail_quote"><span class="gmail-"><div></div><div> </div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex"><div dir="ltr"><div><div><br><br>But in Squeak, it sounds like hard++:<br></div><br><a href="https://stackoverflow.com/questions/49782651/how-one-aligns-structure-fields-in-squeak-ffi" target="_blank">https://stackoverflow.com/ques<wbr>tions/49782651/how-one-aligns-<wbr>structure-fields-in-squeak-ffi</a><br><a href="https://stackoverflow.com/questions/49783126/how-one-defines-a-union-type-in-squeak-ffi" target="_blank">https://stackoverflow.com/ques<wbr>tions/49783126/how-one-defines<wbr>-a-union-type-in-squeak-ffi</a><br><a href="https://stackoverflow.com/questions/49783443/how-one-defines-a-fixed-size-array-member-in-a-struct-in-squeak-ffi" target="_blank">https://stackoverflow.com/ques<wbr>tions/49783443/how-one-defines<wbr>-a-fixed-size-array-member-in-<wbr>a-struct-in-squeak-ffi</a><br><a href="https://stackoverflow.com/questions/49783882/how-one-deals-with-typedefs-in-squeak-ffi" target="_blank">https://stackoverflow.com/ques<wbr>tions/49783882/how-one-deals-<wbr>with-typedefs-in-squeak-ffi</a><br><a href="https://stackoverflow.com/questions/49784253/how-one-deals-with-multiple-pointer-level-like-char-in-squeak-ffi" target="_blank">https://stackoverflow.com/ques<wbr>tions/49784253/how-one-deals-<wbr>with-multiple-pointer-level-<wbr>like-char-in-squeak-ffi</a><br><a href="https://stackoverflow.com/questions/49784522/how-one-supports-both-32-and-64-bits-target-in-squeak-ffi" target="_blank">https://stackoverflow.com/ques<wbr>tions/49784522/how-one-support<wbr>s-both-32-and-64-bits-target-<wbr>in-squeak-ffi</a><br><br>Either I'm blind, or the very light documentation that I found lacks those details <br><a href="http://wiki.squeak.org/squeak/2426" target="_blank">http://wiki.squeak.org/squeak/<wbr>2426</a><br><br></div>I think that I could throw a few more questions (dealing with enums...) but I don't want to excede some unknown quota and start irritating a touchy SO moderator ;)<br><div><br><div><div>I'm afraid that there is no answer but "you're on your own"...<br></div><div>I'm open to studying Alien or UnifiedFFI of Pharo.<br></div><div>Or I can try and improve FFI.<br></div><div>At this stage, my trajectory has already been quite perturbed, and despite my knowledge of rocket science, I can see that I'm not going to put HDF5 on the intended orbit :(<br><br></div><div>Thoughts?<br></div><div><br><br></div></div></div></div>
<br><br>
<br></blockquote></span></div><span class="gmail-HOEnZb"><font color="#888888"><br><br clear="all"><div><br></div>-- <br><div class="gmail-m_5499903852224335258gmail_signature"><div dir="ltr"><div><span style="font-size:small;border-collapse:separate"><div>_,,,^..^,,,_<br></div><div>best, Eliot</div></span></div></div></div>
</font></span></div></div>
<br><br>
<br></blockquote></div><br></div></div>