[squeak-dev] FFI: FFI-Tests-mt.56.mcz

commits at source.squeak.org commits at source.squeak.org
Wed Aug 11 11:36:32 UTC 2021


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

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

Name: FFI-Tests-mt.56
Author: mt
Time: 11 August 2021, 1:36:30.687352 pm
UUID: b0e133e9-08ce-cc49-a007-739c06891753
Ancestors: FFI-Tests-mt.55

Array types of unknown size do share alignment properties of their content type even if they cannot be used anywhere. Only their pointer types do. Yet, being consistent in calculating the #byteAlignment makes life easier in other parts of the system.

=============== Diff against FFI-Tests-mt.55 ===============

Item was changed:
  ----- Method: ExternalTypeTests>>testArrayOfAtomicsWithSpecialSize (in category 'tests - array types') -----
  testArrayOfAtomicsWithSpecialSize
  	"Test char[] and char[0]."
  
  	| contentType containerType |
  	contentType := ExternalType char.
  	
  	containerType := contentType asArrayType: 0.
  	self assert: containerType identical: (ExternalType typeNamed: 'char[0]').
  	self assert: 0 equals: containerType byteSize.
  	self assert: 0 equals: containerType size.
  	self assert: contentType identical: containerType contentType.
  	self assert: contentType byteAlignment equals: containerType byteAlignment.
  
  	containerType := contentType asArrayType: nil.
  	self assert: containerType identical: (ExternalType typeNamed: 'char[]').
  	self assert: nil equals: containerType byteSize.
  	self assert: nil equals: containerType size.
  	self assert: contentType identical: containerType contentType.
+ 	self assert: contentType byteAlignment equals: containerType byteAlignment.!
- 	self assert: 0 equals: containerType byteAlignment.!

Item was changed:
  ----- Method: ExternalTypeTests>>testArrayOfPointersToAtomicsWithSpecialSize (in category 'tests - array types') -----
  testArrayOfPointersToAtomicsWithSpecialSize
  	"Test char*[] and char*[0]."
  	
  	| contentType containerType |
  	contentType := ExternalType char asPointerType. "char*"
  
  	containerType := contentType asArrayType: 0.
  	self assert: containerType identical: (ExternalType typeNamed: 'char*[0]').
  	self assert: 0 equals: containerType byteSize.
  	self assert: 0 equals: containerType size.
  	self assert: contentType identical: containerType contentType.
  	self assert: contentType byteAlignment equals: containerType byteAlignment.
  
  	containerType := contentType asArrayType: nil.
  	self assert: containerType identical: (ExternalType typeNamed: 'char*[]').
  	self assert: nil equals: containerType byteSize.
  	self assert: nil equals: containerType size.
  	self assert: contentType identical: containerType contentType.
+ 	self assert: contentType byteAlignment equals: containerType byteAlignment.
- 	self assert: 0 equals: containerType byteAlignment.
  
  !

Item was changed:
  ----- Method: ExternalTypeTests>>testArrayOfPointersToStructsWithSpecialSize (in category 'tests - array types') -----
  testArrayOfPointersToStructsWithSpecialSize
  	
  	| contentType containerType |
  	contentType := FFITestPoint2 externalType asPointerType. "FFITestPoint2*"
  
  	containerType := contentType asArrayType: 0.
  	self assert: containerType identical: (ExternalType typeNamed: 'FFITestPoint2*[0]').
  	self assert: 0 equals: containerType byteSize.
  	self assert: 0 equals: containerType size.
  	self assert: contentType identical: containerType contentType.
  	self assert: contentType byteAlignment equals: containerType byteAlignment.
  
  	containerType := contentType asArrayType: nil.
  	self assert: containerType identical: (ExternalType typeNamed: 'FFITestPoint2*[]').
  	self assert: nil equals: containerType byteSize.
  	self assert: nil equals: containerType size.
  	self assert: contentType identical: containerType contentType.
+ 	self assert: contentType byteAlignment equals: containerType byteAlignment.
- 	self assert: 0 equals: containerType byteAlignment.
  !

Item was changed:
  ----- Method: ExternalTypeTests>>testArrayOfStructsWithSpecialSize (in category 'tests - array types') -----
  testArrayOfStructsWithSpecialSize
  
  	| contentType containerType |
  	contentType := FFITestPoint2 externalType.
  	
  	containerType := contentType asArrayType: 0.
  	self assert: containerType identical: (ExternalType typeNamed: 'FFITestPoint2[0]').
  	self assert: 0 equals: containerType byteSize.
  	self assert: 0 equals: containerType size.
  	self assert: contentType identical: containerType contentType.
  	self assert: contentType byteAlignment equals: containerType byteAlignment.
  
  	containerType := contentType asArrayType: nil.
  	self assert: containerType identical: (ExternalType typeNamed: 'FFITestPoint2[]').
  	self assert: nil equals: containerType byteSize.
  	self assert: nil equals: containerType size.
  	self assert: contentType identical: containerType contentType.
+ 	self assert: contentType byteAlignment equals: containerType byteAlignment.!
- 	self assert: 0 equals: containerType byteAlignment.!

Item was removed:
- (PackageInfo named: 'FFI-Tests') postscript: '"below, add code to be run after the loading of this package
- This package has struct depending on other struct.
- Due to load order, some struct may not get correctly initialized, and fall short in size.
- Calling a foreign function that write to such a struct may crash the image.
- We shall workaround those load order problems until a more robust fix is found."
- ExternalStructure compileAllFields.'!



More information about the Squeak-dev mailing list