Marcel Taeumel uploaded a new version of FFI-CallbacksTests to project FFI: http://source.squeak.org/FFI/FFI-CallbacksTests-mt.4.mcz
==================== Summary ====================
Name: FFI-CallbacksTests-mt.4 Author: mt Time: 28 May 2021, 4:52:03.114735 pm UUID: ae1966df-d4d7-4464-947d-d1e4618d5e7d Ancestors: FFI-CallbacksTests-mt.3
Complements FFI-Callbacks-mt.24
=============== Diff against FFI-CallbacksTests-mt.3 ===============
Item was changed: ----- Method: FFICallbackTests>>test08ManagedCallback (in category 'tests') ----- test08ManagedCallback
| array unsorted sorted compare callback | unsorted := #(71 66 33 77 16 63 91 54 48 52). sorted := #(16 33 48 52 54 63 66 71 77 91).
array := ExternalType int32_t allocate: 10. 1 to: array size do: [:index | array at: index put: (unsorted at: index)].
compare := [:a :b | (a - b) sign]. callback := compare gcSignature: #(int32_t 'int32_t*' 'int32_t*'). lib qsort: array with: array size with: array contentType byteSize with: callback. self assert: (sorted hasEqualElements: array).
"Callback no longer needed but still there." Smalltalk garbageCollect. self deny: callback isNull.
"Callback depends on the existence of the compare block." self assert: callback + identical: (FFICallback fromEvaluable: compare). - identical: (FFICallback lookupCallbackForEvaluable: compare). compare := nil. Smalltalk garbageCollect. self assert: callback isNull.!
Item was changed: ----- Method: FFICallbackTests>>test09UnmanagedCallback (in category 'tests') ----- test09UnmanagedCallback
| array unsorted sorted compare callback | unsorted := #(71 66 33 77 16 63 91 54 48 52). sorted := #(16 33 48 52 54 63 66 71 77 91).
array := ExternalType int32_t allocate: 10. 1 to: array size do: [:index | array at: index put: (unsorted at: index)].
compare := [:a :b | (a - b) sign]. callback := compare signature: #(int32_t 'int32_t*' 'int32_t*'). lib qsort: array with: array size with: array contentType byteSize with: callback. self assert: (sorted hasEqualElements: array).
"Callback no longer needed but still there." Smalltalk garbageCollect. self deny: callback isNull.
"Callback independent from the compare block." + self assert: (FFICallback fromEvaluable: compare) isNil. - self assert: (FFICallback lookupCallbackForEvaluable: compare) isNil. compare := nil. Smalltalk garbageCollect. self deny: callback isNull.
"Callback needs to be free'd manually." callback free. self assert: callback isNull.!
packages@lists.squeakfoundation.org