<div dir="ltr"><br><div class="gmail_extra"><br><div class="gmail_quote">2016-01-12 20:57 GMT+01:00 Esteban Lorenzano <span dir="ltr">&lt;<a href="mailto:estebanlm@gmail.com" target="_blank">estebanlm@gmail.com</a>&gt;</span>:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"> <br><div style="word-wrap:break-word">well… UnifiedFFI, UFFI or whatever it will be called already does that… as you know.<div>Currently we are using “older” NB way: as a method call, then solving it in first call. This is nice because is compatible and easies some stuff. </div><div>But final objective is to provide a pragma and solve it in compilation time. </div><div><br></div><div>Then we can 100% deprecate the invalid pragma old FFI uses today. </div></div></blockquote><div><br></div><div>But how do we solve the issue?<br></div><div> </div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div style="word-wrap:break-word"><div><br></div><div>At least, that’s what we have talk :)</div><div><br></div><div>Esteban</div><div><div><br><div><blockquote type="cite"><div>On 12 Jan 2016, at 20:06, Nicolai Hess &lt;<a href="mailto:nicolaihess@gmail.com" target="_blank">nicolaihess@gmail.com</a>&gt; wrote:</div><br><div><div dir="ltr"><br><div class="gmail_extra"><br><div class="gmail_quote">2016-01-10 16:57 GMT+01:00 Eliot Miranda <span dir="ltr">&lt;<a href="mailto:eliot.miranda@gmail.com" target="_blank">eliot.miranda@gmail.com</a>&gt;</span>:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"> <br><div dir="ltr">Hi Nicolai,<div class="gmail_extra"><br><div class="gmail_quote">On Sun, Jan 10, 2016 at 3:16 AM, Nicolai Hess <span dir="ltr">&lt;<a href="mailto:nicolaihess@gmail.com" target="_blank">nicolaihess@gmail.com</a>&gt;</span> wrote:<br><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left-width:1px;border-left-color:rgb(204,204,204);border-left-style:solid;padding-left:1ex"><div dir="ltr"><div><div><div><div><div><div><div>pharo fogbugz issue: 17359 MessageNotUnderstood: receiver of &quot;keywords&quot; is nil<br><br><br></div>is this valid pragma syntax:<br><br>    &lt;apicall: bool &#39;SetCursorPos&#39; (long long) module: &#39;user32.dll&#39;&gt;<br></div></div></div></div></div></div></div></blockquote><div><br></div><div>As others have said this is not a valid pragma.  A valid pragma is a message expression (a message with no receiver) that has only literal arguments.  There is one exception, to accept a variable name for the error code in a primitive invocation.</div><div><br></div><div>And as Levente has said it is a goal of the new FFI to get rid of the old syntax you show above.</div></div></div></div></blockquote><div><br><br></div><div>Thanks Eliot.<br><br></div><div>I think I will wait what Esteban will say to this, he put those classes in the image, maybe he had a plan for the new ffi/apicall syntax<br></div><div><br><br></div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div dir="ltr"><div class="gmail_extra"><div class="gmail_quote"><div><br></div><div>And as Igor Stasenko discovered /any/ C signature can be written as a literal Array, providing we allow underscores in Symbols (which is a preference).  So for example, the heapsort declaration from the standard C library:</div><div><br></div><div>int</div><div>     heapsort(void *base, size_t nel, size_t width,</div><div>         int (*compar)(const void *, const void *)) </div><div><br></div><div>could be written as a pragma via e.g.</div><div><br></div><div><div>    &lt;ffiCCall: #(int heapsort(void *base, size_t nel, size_t width, int (*compar)(const void *, const void *)))&gt;</div></div><div><br></div><div>in which case it is equal to</div><div><br></div><div><div>   &lt;ffiCCall: #(#int #heapsort #( #void #* #base #, #size_t #nel #, #size_t #width #, #int #( #* #compar ) #( #const #void #*, #const #void #*)))&gt;</div></div><div><br></div><div>which, while a massive hack, is pretty neat.  The only difficulty in parsing the above s that void *, is #void #*, not #void #* #,.</div><div><br></div><div>So for me, the natural pragma syntax for the new FFI should be a single keyword starting with ffi that includes the language with which to parse the pragma&#39;s argument, followed by a literal Array containing the signature (rather than e.g. a String).  I&#39;d also provide a special-purpose pretty-printer for literal arrays that would be used to pretty-print the above, e.g. when decompiling.</div><div><br></div><div>This would easily allow extensions such as</div><div><br></div><div>     &lt;ffiCcall: #(wchar_t * wcschr(const wchar_t *s, wchar_t c)) arg1is: #UnicodeString arg2is: Character&gt;</div><div><br></div><div>to guide a marshalling engine in providing automatic checks and conversions.</div><div><br></div><div>[Slightly OT]</div><div>Note that I&#39;m already using this syntax in Alien callbacks because one thing it does is to normalize the signature, eliminating the significance of most whitespace (the #*, above being one example where it fails).  So a Callback for heapsort above looks like</div><div><br></div><div><div>voidstarvoidstarRetint: callbackContext sp: spAlien</div><div><span style="white-space:pre-wrap">        </span>&lt;signature: #(int (*)(const void *, const void *)) abi: #IA32&gt;</div><div><span style="white-space:pre-wrap">        </span>^callbackContext wordResult:</div><div><span style="white-space:pre-wrap">                </span>(block</div><div><span style="white-space:pre-wrap">                        </span>value: (Alien forPointer: (spAlien unsignedLongAt: 1))</div><div><span style="white-space:pre-wrap">                        </span>value: (Alien forPointer: (spAlien unsignedLongAt: 5)))</div></div><div><br></div><div>or</div><div><div>voidstarvoidstarRetintARM32: callbackContext sp: spAlien</div><div><span style="white-space:pre-wrap">        </span>&lt;signature: #(int (*)(const void *, const void *)) abi: #ARM32&gt;</div><div><span style="white-space:pre-wrap">        </span>^callbackContext wordResult:</div><div><span style="white-space:pre-wrap">                </span>(block</div><div><span style="white-space:pre-wrap">                        </span>value: (Alien forPointer: (spAlien registerAt: 1))</div><div><span style="white-space:pre-wrap">                        </span>value: (Alien forPointer: (spAlien registerAt: 2)))</div></div><div><br></div><div><br></div><div>Hmmm, if Callback had subclasses for each ABI then the above would become</div><div><br></div><div>IA32Callback methods for signature</div><div><div><div>voidstarvoidstarRetint: callbackContext sp: spAlien</div><div><span style="white-space:pre-wrap">        </span>&lt;signature: #(int (*)(const void *, const void *))&gt;</div><div><span style="white-space:pre-wrap">        </span>^callbackContext wordResult:</div><div><span style="white-space:pre-wrap">                </span>(block</div><div><span style="white-space:pre-wrap">                        </span>value: (Alien forPointer: (spAlien unsignedLongAt: 1))</div><div><span style="white-space:pre-wrap">                        </span>value: (Alien forPointer: (spAlien unsignedLongAt: 5)))</div></div><div><br></div><div>ARM32Callback methods for signatures</div><div><div>voidstarvoidstarRetint: callbackContext sp: spAlien</div><div><span style="white-space:pre-wrap">        </span>&lt;signature: #(int (*)(const void *, const void *))&gt;</div><div><span style="white-space:pre-wrap">        </span>^callbackContext wordResult:</div><div><span style="white-space:pre-wrap">                </span>(block</div><div><span style="white-space:pre-wrap">                        </span>value: (Alien forPointer: (spAlien registerAt: 1))</div><div><span style="white-space:pre-wrap">                        </span>value: (Alien forPointer: (spAlien registerAt: 2)))</div></div></div><div><br></div><div>Much nicer.  I shall make it so.</div><div><br></div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left-width:1px;border-left-color:rgb(204,204,204);border-left-style:solid;padding-left:1ex"><div dir="ltr"><div><div><div><div><div><div>our (pharo) parser can not parse this (does not recognizes the<br></div></div>&quot;selector parts&quot; (apicall:module:) right)<br><br></div>Any recommendations how to fix this<br></div>- fix RBParser or<br></div>- change this pragma, for example, like this<br>   &lt;apicall: #(bool SetCursorPos (long long)) module: &#39;user32.dll&#39;&gt;<span><font color="#888888"><br><br><br></font></span></div><span><font color="#888888">nicolai</font></span></div></blockquote></div><div><br></div><div><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>
<br></blockquote></div><br></div></div>
</div></blockquote></div><br></div></div></div><br></blockquote></div><br></div></div>