createCallback
^ FFICallback
signature: #(long (long))
block: [ :value | value ]
C functions:
long test(long(*function)(long), long value) {
return function(value);
}
#include <limits.h>
long long_min() {
return LONG_MIN;
}
FFI calls:
primCall: aCallback long: aNumber
^ self ffiCall: #(long test(FFICallback aCallback, long aNumber))
primLongMin
^ self ffiCall: #(long long_min())
Test case:
test
self
assert: (self primCall: self createCallback long: self primLongMin)
equals: self primLongMin
self primLongMin returns -2147483648 (= LONG_MIN).
Result of callback is 0 => test fails.
P.S. works in Pharo 5