[squeak-dev] FFI: FFI-CallbacksTests-mt.2.mcz

commits at source.squeak.org commits at source.squeak.org
Thu May 27 15:04:41 UTC 2021


Marcel Taeumel uploaded a new version of FFI-CallbacksTests to project FFI:
http://source.squeak.org/FFI/FFI-CallbacksTests-mt.2.mcz

==================== Summary ====================

Name: FFI-CallbacksTests-mt.2
Author: mt
Time: 27 May 2021, 5:04:41.572121 pm
UUID: 0dd9372f-59fc-bd4e-8fd7-9836d999426e
Ancestors: FFI-CallbacksTests-mt.1

Complements FFI-Callbacks-mt.21

=============== Diff against FFI-CallbacksTests-mt.1 ===============

Item was added:
+ ----- 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 := FFICallback newGC.
+ 	callback
+ 		setBlock: 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).
+ 
+ 	Smalltalk garbageCollect.
+ 	self deny: callback isNull.
+ 	compare := nil.
+ 	Smalltalk garbageCollect.
+ 	self assert: callback isNull.!



More information about the Squeak-dev mailing list