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

commits at source.squeak.org commits at source.squeak.org
Thu Jun 4 14:01:14 UTC 2020


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

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

Name: FFI-Kernel-mt.90
Author: mt
Time: 4 June 2020, 4:01:13.887669 pm
UUID: 39f2d09d-7b47-1f44-ac03-6ef7515f1a3a
Ancestors: FFI-Kernel-mt.89

Makes print strings for type aliases more clear.

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

Item was added:
+ ----- Method: ExternalStructure class>>isTypeAlias (in category 'testing') -----
+ isTypeAlias
+ 	"Answer whether this structure is an alias for another C type, enum, etc."
+ 	"Example: #( nil 'long' )"
+ 	
+ 	| fields |
+ 	^ (fields := self fields) size = 2
+ 		and: [fields first isNil]!

Item was added:
+ ----- Method: ExternalType>>isTypeAlias (in category 'testing') -----
+ isTypeAlias
+ 
+ 	| typeAlias |
+ 	referentClass ifNil: [^ false].
+ 	typeAlias := self asNonPointerType.
+ 
+ 	AtomicTypes valuesDo: [:atomicType |
+ 		atomicType compiledSpec == typeAlias compiledSpec ifTrue: [^ true]].
+ 	(StructTypes keys
+ 		collect: [:typeName | self class structTypeNamed: typeName])
+ 		select: [:structType | structType notNil and: [structType ~~ typeAlias] and: [
+ 			structType referentClass notNil and: [structType referentClass isTypeAlias not]]]
+ 		thenDo: [:structType | structType compiledSpec == typeAlias compiledSpec ifTrue: [^ true]].
+ 	
+ 	^ false!

Item was added:
+ ----- Method: ExternalType>>originalType (in category 'accessing') -----
+ originalType
+ 	"Resolve type alias."
+ 
+ 	| typeAlias |
+ 	referentClass ifNil: [^ nil].
+ 	typeAlias := self asNonPointerType.
+ 
+ 	AtomicTypes valuesDo: [:atomicType |
+ 		(atomicType compiledSpec == typeAlias compiledSpec "and: [atomicType ~~ typeAlias]")
+ 			ifTrue: [^ self isPointerType ifTrue: [atomicType asPointerType] ifFalse: [atomicType]]].
+ 	(StructTypes keys
+ 		collect: [:typeName | self class structTypeNamed: typeName])
+ 		select: [:structType | structType notNil and: [structType ~~ typeAlias] and: [
+ 			structType referentClass notNil and: [structType referentClass isTypeAlias not]]]
+ 		thenDo: [:structType | structType compiledSpec == typeAlias compiledSpec
+ 			ifTrue: [	^ self isPointerType ifTrue: [structType asPointerType] ifFalse: [structType]]].
+ 	
+ 	^ nil!

Item was changed:
  ----- Method: ExternalType>>printOn: (in category 'printing') -----
  printOn: aStream
  
+ 	self isTypeAlias ifTrue: [
+ 		aStream
+ 			nextPutAll: referentClass name;
+ 			nextPut: $<;
+ 			print: self originalType;
+ 			nextPut: $>.
+ 		^ self].
+ 	
  	self isAtomic
  		ifTrue: [aStream nextPutAll: (AtomicTypeNames at: self atomicType)]
  		ifFalse: [
  			referentClass == nil
  				ifTrue:[aStream nextPutAll: '<unknown struct type>']
  				ifFalse:[aStream nextPutAll: referentClass name]].
  	self isPointerType ifTrue:[aStream nextPut: $*].!



More information about the Squeak-dev mailing list