[squeak-dev] FFI: FFI-Kernel-mt.157.mcz

commits at source.squeak.org commits at source.squeak.org
Mon May 17 08:03:49 UTC 2021

Marcel Taeumel uploaded a new version of FFI-Kernel to project FFI:

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

Name: FFI-Kernel-mt.157
Author: mt
Time: 17 May 2021, 10:03:47.21887 am
UUID: eee9f199-4910-6b4b-b9b5-1c793d7ce342
Ancestors: FFI-Kernel-mt.156

Fixes some bugs with empty array types during code loading.

=============== Diff against FFI-Kernel-mt.156 ===============

Item was changed:
  ----- Method: ExternalArrayType class>>newTypeForContentType:size: (in category 'instance creation') -----
  newTypeForContentType: contentType size: numElements
  	"!!!!!! Be aware that only the pointer type can be used in calls. As of SqueakFFIPrims VMMaker.oscog-eem.2950, there is no actual support for array types in the FFI plugin !!!!!!"
  	| type pointerType headerWord byteSize |	
  		flag: #contentVsContainer;
  		assert: [contentType isTypeAlias or: [contentType isArrayType not]]
  		description: 'No support for direct multi-dimensional containers yet. Use type aliases.'.
+ 		assert: [contentType isVoid not]
+ 		description: 'No array types for void type!!'.
+ 	self
  		assert: [
  			(ArrayTypes at: contentType typeName
  				ifPresent: [:sizes | sizes at: numElements ifAbsent: [nil]]
  				ifAbsent: [nil] ) isNil]
  		description: 'Array type already exists. Use #typeNamed: to access it.'.
  	type := ExternalArrayType basicNew.
  	pointerType := ExternalPointerType basicNew.
  	"1) Regular type"
  	byteSize := numElements
  		ifNil: [0] ifNotNil: [numElements * contentType byteSize].
  	self assert: [byteSize <= FFIStructSizeMask].
  	headerWord := contentType headerWord.
  	headerWord := headerWord bitClear: FFIStructSizeMask.
  	headerWord := headerWord bitOr: byteSize.
  		setReferencedType: pointerType;
  		compiledSpec: (WordArray with: headerWord);
  		byteAlignment: (numElements ifNil: [0] ifNotNil: [contentType byteAlignment]);
  		setReferentClass: contentType referentClass;
  		setContentType: contentType;
  		setSize: numElements.
  	"2) Pointer type. Reuse the compiledSpec of the content-type's pointer type."
  		setReferencedType: type;
  		compiledSpec: (WordArray with: (self pointerSpec bitOr: FFIFlagAtomic "HACK!! To deceive the FFI plugin :)"));
  		byteAlignment: self pointerAlignment;
  		setReferentClass: nil.
  	"3) Remember this new array type."
  	(ArrayTypes at: contentType typeName ifAbsentPut: [WeakValueDictionary new])
  		at: numElements put: type.
  	^ type!

Item was changed:
  ----- Method: ExternalArrayType>>isTypeAlias (in category 'testing') -----
+ 	self isUnknownType ifTrue: [^ false].
  	^ self isArrayOfArrays not
  		and: [referentClass notNil
  		and: [referentClass isTypeAlias
  		and: [referentClass originalType isArrayType]]]!

Item was changed:
  ----- Method: ExternalArrayType>>isUnknownType (in category 'testing') -----
+ 	"Array of unknown type is also an unknown type."
+ 	^ self contentType isUnknownType!
- 	^ false!

Item was changed:
  ----- Method: ExternalStructure class>>doneCompiling (in category 'class management') -----
  	"Base class changed to something that is an external structure now."
+ 	[self compileFields] ifError: [ "Ignore unfinished field specs" ].
+ 	self externalType isUnknownType ifTrue: [self externalType becomeKnownType].!
- 	[self compileFields] ifError: [ "Ignore unfinished field specs" ].!

Item was changed:
  ----- Method: ExternalUnknownType class>>newTypeForUnknownNamed: (in category 'instance creation') -----
+ newTypeForUnknownNamed: label
- newTypeForUnknownNamed: typeName
+ 	| typeName type pointerType |
+ 	typeName := label asSymbol.
- 	| type pointerType |
  		assert: [(StructTypes includesKey: typeName) not]
  		description: 'Type already exists. Use #typeNamed: to access it.'.
  	type := ExternalUnknownType basicNew
  		compiledSpec: (WordArray with: self structureSpec);
+ 		byteAlignment: 0; "dummy until #newReferentClass: is called"
+ 		setReferentClass: typeName;
  	self assert: [type isEmpty].
  	pointerType := ExternalPointerType basicNew
  		compiledSpec: (WordArray with: self pointerSpec);
  		byteAlignment: self pointerAlignment;
  	self assert: [pointerType isPointerType].
  	"Connect non-pointer type with pointer type."
  	type setReferencedType: pointerType.
  	pointerType setReferencedType: type.
  	"Remember this new struct type."
+ 	StructTypes at: typeName put: type.
- 	StructTypes at: typeName asSymbol put: type.
  	^ type!

Item was changed:
  ----- Method: ExternalUnknownType>>typeName (in category 'accessing') -----
+ 	self assert: [referentClass isSymbol].
+ 	^ referentClass "Usually just the name of the class."!
- 	self shouldNotImplement.!

More information about the Squeak-dev mailing list