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

commits at source.squeak.org commits at source.squeak.org
Thu May 6 17:15:39 UTC 2021


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

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

Name: FFI-Kernel-mt.137
Author: mt
Time: 6 May 2021, 7:15:39.236981 pm
UUID: 2cd24707-c5c7-d24e-aa5f-70eae222e880
Ancestors: FFI-Kernel-mt.136

Prevent users from accessing type information for a generic ExternalData class. It makes no sense if you don't have a concrete type at hand.

Adds the missing extra-type-check pref check for dynamic data access in external types.

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

Item was changed:
  ----- Method: ExternalData class>>byteAlignment (in category 'external type') -----
  byteAlignment
  
+ 	self shouldNotImplement.!
- 	^ self externalType byteAlignment!

Item was changed:
  ----- Method: ExternalData class>>byteSize (in category 'external type') -----
  byteSize
+ 
+ 	self shouldNotImplement.!
- 	
- 	^ self externalType byteSize!

Item was changed:
  ----- Method: ExternalData class>>compiledSpec (in category 'external type') -----
  compiledSpec
  
+ 	self shouldNotImplement.!
- 	^ self externalType compiledSpec!

Item was changed:
  ----- Method: ExternalData class>>externalType (in category 'external type') -----
  externalType
- 	"Without having concrete external data, we can only tell that some void* will be in charge."
  	
+ 	self shouldNotImplement.!
- 	^ ExternalType void asPointerType!

Item was changed:
  ----- Method: ExternalStructureType>>handle:at:put: (in category 'external data') -----
  handle: handle at: byteOffset put: value
  	"Write a value using the receiver's external type at the given handle and byteOffset. This is the dynamic version of #writeFieldAt:with:."
  
  	self checkType.
  	
  	self isAtomic
  		ifTrue: [ "alias to atomic"
+ 			self class extraTypeChecks ifTrue: [
+ 				self flag: #addTypeCheck. "mt: Note that there is currently no mapping from objects that represent valid atomics to atomic types."].
- 			self flag: #addTypeCheck. "mt: Note that there is currently no mapping from objects that represent valid atomics to atomic types."
  			^ handle
  				perform: ((AtomicSelectors at: self atomicType), 'put:') asSymbol
  				with: byteOffset
  				with: value getHandle]
  		ifFalse: [ "regular struct or alias to struct or alias to pointer"
+ 			self class extraTypeChecks ifTrue: [
+ 				self assert: [value externalType == self]].
- 			self assert: [value externalType == self].
  			^ handle
  				structAt: byteOffset
  				put: value getHandle
  				length: self byteSize].!

Item was changed:
  ----- Method: ExternalType>>handle:at:put: (in category 'external data') -----
  handle: handle at: byteOffset put: value
  	"Write a value using the receiver's external type at the given handle and byteOffset. This is the dynamic version of #writeFieldAt:with:."
  
  	self checkType.
  	
  	self isPointerType
  		ifFalse: [ "set atomic value"
+ 			self class extraTypeChecks ifTrue: [
+ 				self flag: #addTypeCheck. "mt: Note that there is currently no mapping from objects that represent valid atomics to atomic types."].
- 			self flag: #addTypeCheck. "mt: Note that there is currently no mapping from objects that represent valid atomics to atomic types."
  			handle
  				perform: ((AtomicSelectors at: self atomicType), 'put:') asSymbol
  				with: byteOffset
  				with: value]
  		ifTrue: [ "set pointer to struct/union/alias"
+ 			self class extraTypeChecks ifTrue: [
+ 				self assert: [value externalType == self]].
- 			self assert: [value externalType == self].
  			handle
  				pointerAt: byteOffset
  				put: value getHandle
  				length: self byteSize].!



More information about the Squeak-dev mailing list