<html><head><meta http-equiv="Content-Type" content="text/html charset=utf-8"></head><body style="word-wrap: break-word; -webkit-nbsp-mode: space; -webkit-line-break: after-white-space;" class=""><br class=""><div><blockquote type="cite" class=""><div class="">On 12 Jan 2016, at 21:12, Nicolai Hess &lt;<a href="mailto:nicolaihess@gmail.com" class="">nicolaihess@gmail.com</a>&gt; wrote:</div><br class="Apple-interchange-newline"><div class=""><div dir="ltr" class=""><br class=""><div class="gmail_extra"><br class=""><div class="gmail_quote">2016-01-12 20:57 GMT+01:00 Esteban Lorenzano <span dir="ltr" class="">&lt;<a href="mailto:estebanlm@gmail.com" target="_blank" class="">estebanlm@gmail.com</a>&gt;</span>:<br class=""><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">&nbsp;<br class=""><div style="word-wrap:break-word" class="">well… UnifiedFFI, UFFI or whatever it will be called already does that… as you know.<div class="">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.&nbsp;</div><div class="">But final objective is to provide a pragma and solve it in compilation time.&nbsp;</div><div class=""><br class=""></div><div class="">Then we can 100% deprecate the invalid pragma old FFI uses today.&nbsp;</div></div></blockquote><div class=""><br class=""></div><div class="">But how do we solve the issue?<br class=""></div></div></div></div></div></blockquote><div><br class=""></div><div>Well, we should add an #visitFFIPragmaNode: who can deal with it, in the mean time :)</div><div><br class=""></div><div>Esteban</div><br class=""><blockquote type="cite" class=""><div class=""><div dir="ltr" class=""><div class="gmail_extra"><div class="gmail_quote"><div class="">&nbsp;</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" class=""><div class=""><br class=""></div><div class="">At least, that’s what we have talk :)</div><div class=""><br class=""></div><div class="">Esteban</div><div class=""><div class=""><br class=""><div class=""><blockquote type="cite" class=""><div class="">On 12 Jan 2016, at 20:06, Nicolai Hess &lt;<a href="mailto:nicolaihess@gmail.com" target="_blank" class="">nicolaihess@gmail.com</a>&gt; wrote:</div><br class=""><div class=""><div dir="ltr" class=""><br class=""><div class="gmail_extra"><br class=""><div class="gmail_quote">2016-01-10 16:57 GMT+01:00 Eliot Miranda <span dir="ltr" class="">&lt;<a href="mailto:eliot.miranda@gmail.com" target="_blank" class="">eliot.miranda@gmail.com</a>&gt;</span>:<br class=""><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">&nbsp;<br class=""><div dir="ltr" class="">Hi Nicolai,<div class="gmail_extra"><br class=""><div class="gmail_quote">On Sun, Jan 10, 2016 at 3:16 AM, Nicolai Hess <span dir="ltr" class="">&lt;<a href="mailto:nicolaihess@gmail.com" target="_blank" class="">nicolaihess@gmail.com</a>&gt;</span> wrote:<br class=""><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" class=""><div class=""><div class=""><div class=""><div class=""><div class=""><div class=""><div class="">pharo fogbugz issue: 17359 MessageNotUnderstood: receiver of "keywords" is nil<br class=""><br class=""><br class=""></div>is this valid pragma syntax:<br class=""><br class="">&nbsp;&nbsp;&nbsp; &lt;apicall: bool 'SetCursorPos' (long long) module: 'user32.dll'&gt;<br class=""></div></div></div></div></div></div></div></blockquote><div class=""><br class=""></div><div class="">As others have said this is not a valid pragma.&nbsp; A valid pragma is a message expression (a message with no receiver) that has only literal arguments.&nbsp; There is one exception, to accept a variable name for the error code in a primitive invocation.</div><div class=""><br class=""></div><div class="">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 class=""><br class=""><br class=""></div><div class="">Thanks Eliot.<br class=""><br class=""></div><div class="">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 class=""></div><div class=""><br class=""><br class=""></div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div dir="ltr" class=""><div class="gmail_extra"><div class="gmail_quote"><div class=""><br class=""></div><div class="">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).&nbsp; So for example, the heapsort declaration from the standard C library:</div><div class=""><br class=""></div><div class="">int</div><div class="">&nbsp; &nbsp; &nbsp;heapsort(void *base, size_t nel, size_t width,</div><div class="">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp;int (*compar)(const void *, const void *))&nbsp;</div><div class=""><br class=""></div><div class="">could be written as a pragma via e.g.</div><div class=""><br class=""></div><div class=""><div class="">&nbsp; &nbsp; &lt;ffiCCall: #(int heapsort(void *base, size_t nel, size_t width, int (*compar)(const void *, const void *)))&gt;</div></div><div class=""><br class=""></div><div class="">in which case it is equal to</div><div class=""><br class=""></div><div class=""><div class="">&nbsp;&nbsp; &lt;ffiCCall: #(#int #heapsort #( #void #* #base #, #size_t #nel #, #size_t #width #, #int #( #* #compar ) #( #const #void #*, #const #void #*)))&gt;</div></div><div class=""><br class=""></div><div class="">which, while a massive hack, is pretty neat.&nbsp; The only difficulty in parsing the above s that void *, is #void #*, not #void #* #,.</div><div class=""><br class=""></div><div class="">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's argument, followed by a literal Array containing the signature (rather than e.g. a String).&nbsp; I'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 class=""><br class=""></div><div class="">This would easily allow extensions such as</div><div class=""><br class=""></div><div class="">&nbsp; &nbsp; &nbsp;&lt;ffiCcall: #(wchar_t * wcschr(const wchar_t *s, wchar_t c)) arg1is: #UnicodeString arg2is: Character&gt;</div><div class=""><br class=""></div><div class="">to guide a marshalling engine in providing automatic checks and conversions.</div><div class=""><br class=""></div><div class="">[Slightly OT]</div><div class="">Note that I'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).&nbsp; So a Callback for heapsort above looks like</div><div class=""><br class=""></div><div class=""><div class="">voidstarvoidstarRetint: callbackContext sp: spAlien</div><div class=""><span style="white-space:pre-wrap" class="">        </span>&lt;signature: #(int (*)(const void *, const void *)) abi: #IA32&gt;</div><div class=""><span style="white-space:pre-wrap" class="">        </span>^callbackContext wordResult:</div><div class=""><span style="white-space:pre-wrap" class="">                </span>(block</div><div class=""><span style="white-space:pre-wrap" class="">                        </span>value: (Alien forPointer: (spAlien unsignedLongAt: 1))</div><div class=""><span style="white-space:pre-wrap" class="">                        </span>value: (Alien forPointer: (spAlien unsignedLongAt: 5)))</div></div><div class=""><br class=""></div><div class="">or</div><div class=""><div class="">voidstarvoidstarRetintARM32: callbackContext sp: spAlien</div><div class=""><span style="white-space:pre-wrap" class="">        </span>&lt;signature: #(int (*)(const void *, const void *)) abi: #ARM32&gt;</div><div class=""><span style="white-space:pre-wrap" class="">        </span>^callbackContext wordResult:</div><div class=""><span style="white-space:pre-wrap" class="">                </span>(block</div><div class=""><span style="white-space:pre-wrap" class="">                        </span>value: (Alien forPointer: (spAlien registerAt: 1))</div><div class=""><span style="white-space:pre-wrap" class="">                        </span>value: (Alien forPointer: (spAlien registerAt: 2)))</div></div><div class=""><br class=""></div><div class=""><br class=""></div><div class="">Hmmm, if Callback had subclasses for each ABI then the above would become</div><div class=""><br class=""></div><div class="">IA32Callback methods for signature</div><div class=""><div class=""><div class="">voidstarvoidstarRetint: callbackContext sp: spAlien</div><div class=""><span style="white-space:pre-wrap" class="">        </span>&lt;signature: #(int (*)(const void *, const void *))&gt;</div><div class=""><span style="white-space:pre-wrap" class="">        </span>^callbackContext wordResult:</div><div class=""><span style="white-space:pre-wrap" class="">                </span>(block</div><div class=""><span style="white-space:pre-wrap" class="">                        </span>value: (Alien forPointer: (spAlien unsignedLongAt: 1))</div><div class=""><span style="white-space:pre-wrap" class="">                        </span>value: (Alien forPointer: (spAlien unsignedLongAt: 5)))</div></div><div class=""><br class=""></div><div class="">ARM32Callback methods for signatures</div><div class=""><div class="">voidstarvoidstarRetint: callbackContext sp: spAlien</div><div class=""><span style="white-space:pre-wrap" class="">        </span>&lt;signature: #(int (*)(const void *, const void *))&gt;</div><div class=""><span style="white-space:pre-wrap" class="">        </span>^callbackContext wordResult:</div><div class=""><span style="white-space:pre-wrap" class="">                </span>(block</div><div class=""><span style="white-space:pre-wrap" class="">                        </span>value: (Alien forPointer: (spAlien registerAt: 1))</div><div class=""><span style="white-space:pre-wrap" class="">                        </span>value: (Alien forPointer: (spAlien registerAt: 2)))</div></div></div><div class=""><br class=""></div><div class="">Much nicer.&nbsp; I shall make it so.</div><div class=""><br class=""></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" class=""><div class=""><div class=""><div class=""><div class=""><div class=""><div class="">our (pharo) parser can not parse this (does not recognizes the<br class=""></div></div>"selector parts" (apicall:module:) right)<br class=""><br class=""></div>Any recommendations how to fix this<br class=""></div>- fix RBParser or<br class=""></div>- change this pragma, for example, like this<br class="">&nbsp;  &lt;apicall: #(bool SetCursorPos (long long)) module: 'user32.dll'&gt;<span class=""><font color="#888888" class=""><br class=""><br class=""><br class=""></font></span></div><span class=""><font color="#888888" class="">nicolai</font></span></div></blockquote></div><div class=""><br class=""></div><div class=""><div dir="ltr" class=""><div class=""><span style="font-size:small;border-collapse:separate" class=""><div class="">_,,,^..^,,,_<br class=""></div><div class="">best,&nbsp;Eliot</div></span></div></div></div>
</div></div>
<br class=""></blockquote></div><br class=""></div></div>
</div></blockquote></div><br class=""></div></div></div><br class=""></blockquote></div><br class=""></div></div>
</div></blockquote></div><br class=""></body></html>