If I have ulong ulong long long ulong should I look in unsignedLongAt: 1 5 9 13 17 (with an increment of 4) ?? Le 9 sept. 2014 à 15:43, Esteban Lorenzano <estebanlm@gmail.com> a écrit :
it doesnât really matters. what you need to be sure for alien is that you have an âevaluatorâ for that callback.
for example, the
exampleCqsort
uses this callback:
int (*)(const void *, const void *)
so, in âCallbackâ instance side, you can find this definition:
voidstarvoidstarRetint: callbackContext sp: spAlien <signature: 'int (*)(const void *, const void *)' abi: 'IA32'> ^callbackContext wordResult: (block value: (Alien forPointer: (spAlien unsignedLongAt: 1)) value: (Alien forPointer: (spAlien unsignedLongAt: 5)))
So, you need to add a method extension, something like:
ulongulongRetulong: callbackContext sp: spAlien <signature: âulong (*)(ulong, ulong)' abi: 'IA32'> ^callbackContext wordResult: (block value: (spAlien unsignedLongAt: 1) value: (spAlien unsignedLongAt: 5))
then you can declare your callback something like:
cb := Callback signature: 'ulong (*)(ulong, ulong)' block: [ :arg1 :arg2 | ... ].
that has to work :)
yes, is pretty complicated, and yes, you need to do a method for each kind of different signature you want to use. but well, is the way it works now :)
Esteban
On 09 Sep 2014, at 12:00, Annick Fron <list@afceurope.com> wrote:
What signature should I use for a callback ? âulongâ does not seem to work
Annick