[squeak-dev] FFI: FFI-Kernel.terf-eem.188.mcz

commits at source.squeak.org commits at source.squeak.org
Mon Aug 2 18:26:58 UTC 2021


Eliot Miranda uploaded a new version of FFI-Kernel to project FFI:
http://source.squeak.org/FFI/FFI-Kernel.terf-eem.188.mcz

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

Name: FFI-Kernel.terf-eem.188
Author: eem
Time: 2 August 2021, 11:26:54.33527 am
UUID: 59d1cf8c-e906-4d9b-9a75-995d353872f9
Ancestors: FFI-Kernel.terf-eem.187

fix another variable shadowing warning

=============== Diff against FFI-Kernel.terf-eem.187 ===============

Item was changed:
  ----- Method: ExternalStructure class>>compileStructureSpec:withAccessors: (in category 'field definition - support') -----
  compileStructureSpec: specArray withAccessors: aSymbol 
  	"Compile a type specification for the FFI calls.
  	Return the newly compiled spec.
  	
  	Eventually generate the field accessors according to following rules:
  	- aSymbol = #always always generate the accessors
  	- aSymbol = #never never generate the accessors
  	- aSymbol = #generated only generate the auto-generated accessors
  	- aSymbol = #absent only generate the absent accessors"
  	
  	| newByteAlignment byteOffset typeSpec newCompiledSpec |
  	byteOffset := 0.
  	newByteAlignment := self minStructureAlignment.
  	typeSpec := WriteStream on: (WordArray new: 10).
  	typeSpec nextPut: FFIFlagStructure.
  	specArray do:
  		[:spec | | fieldName fieldTypeName fieldType typeSize fieldAlignment |
  		fieldName := spec first.
  		fieldTypeName := spec second.
  		fieldType := (ExternalType typeNamed: fieldTypeName) ifNil: [self errorTypeNotFound: spec second].
  		typeSize := fieldType byteSize.
  		fieldAlignment := (fieldType byteAlignment max: self minFieldAlignment) min: self maxFieldAlignment.
  		byteOffset := byteOffset alignedTo: fieldAlignment.
  		newByteAlignment := newByteAlignment max: fieldAlignment.
  		spec size > 2 ifTrue: "extra size"
+ 			[spec third < typeSize ifTrue:
+ 				[^ self error: 'Explicit type size is less than expected'].
- 			[spec third < typeSize
- 				ifTrue: [^ self error: 'Explicit type size is less than expected'].
  			typeSize := spec third].
  		(fieldName notNil and: [self shouldGenerate: fieldName policy: aSymbol]) ifTrue:
  			[self generateStructureFieldAccessorsFor: fieldName startingAt: byteOffset + 1 type: fieldType].
  		typeSpec nextPutAll: (fieldType embeddedSpecWithSize: typeSize).
  		byteOffset := byteOffset + typeSize].
  	newByteAlignment := newByteAlignment min: self maxStructureAlignment.
  	byteOffset := byteOffset alignedTo: newByteAlignment.
  	newCompiledSpec := typeSpec contents.
  	newCompiledSpec at: 1 put: (byteOffset bitOr: FFIFlagStructure).
  	self
  		setCompiledSpec: newCompiledSpec
  		byteAlignment: newByteAlignment!

Item was changed:
  ----- Method: ExternalUnion class>>compileStructureSpec:withAccessors: (in category 'field definition - support') -----
  compileStructureSpec: specArray withAccessors: aSymbol 
  	"Compile a type specification for the FFI machinery.
  	Return the newly compiled spec.
  	Eventually generate the field accessors according to the policy defined in aSymbol."
  	| byteOffset maxByteSize typeSpec newCompiledSpec newByteAlignment |
  	byteOffset := 1.
  	newByteAlignment := 1.
  	maxByteSize := 0.
  	typeSpec := WriteStream on: (WordArray new: specArray size + 1).
  	typeSpec nextPut: FFIFlagStructure.
+ 	specArray do:
+ 		[:spec | | fieldName fieldTypeName fieldType typeSize typeAlignment |
- 	specArray do: [:spec |
- 		| fieldName fieldTypeName externalType typeSize typeAlignment |
  		fieldName := spec first.
  		fieldTypeName := spec second.
+ 		fieldType := (ExternalType typeNamed: fieldTypeName) ifNil: [self errorTypeNotFound: spec second].
+ 		typeSize := fieldType byteSize.
+ 		typeAlignment := fieldType byteAlignment.
+ 		spec size > 2 ifTrue: "extra size"
+ 			[spec third < typeSize ifTrue:
+ 				[^ self error: 'Explicit type size is less than expected'].
+ 			typeSize := spec third].
+ 		(fieldName notNil and: [self shouldGenerate: fieldName policy: aSymbol]) ifTrue:
+ 			[self generateStructureFieldAccessorsFor: fieldName startingAt: byteOffset type: fieldType].
+ 		typeSpec nextPutAll: (fieldType embeddedSpecWithSize: typeSize).
- 		externalType := (ExternalType typeNamed: fieldTypeName)
- 			ifNil: [self errorTypeNotFound: spec second].
- 		typeSize := externalType byteSize.
- 		typeAlignment := externalType byteAlignment.
- 		spec size > 2 ifTrue: ["extra size"
- 			spec third < typeSize
- 				ifTrue: [^ self error: 'Explicit type size is less than expected'].
- 			typeSize := spec third.
- 		].
- 		(fieldName notNil and: [self shouldGenerate: fieldName policy: aSymbol]) ifTrue: [
- 			self generateStructureFieldAccessorsFor: fieldName startingAt: byteOffset type: externalType.
- 		].
- 		typeSpec nextPutAll: (externalType embeddedSpecWithSize: typeSize).
  		maxByteSize := maxByteSize max: typeSize.
+ 		newByteAlignment := newByteAlignment max: typeAlignment].
- 		newByteAlignment := newByteAlignment max: typeAlignment
- 		].
  	maxByteSize := maxByteSize alignedTo: newByteAlignment.
  	newCompiledSpec := typeSpec contents.
  	newCompiledSpec at: 1 put: (maxByteSize bitOr: FFIFlagStructure).
  	self
  		setCompiledSpec: newCompiledSpec
+ 		byteAlignment: newByteAlignment!
- 		byteAlignment: newByteAlignment.!



More information about the Squeak-dev mailing list