FFI: FFI-Pools-mt.27.mcz

Previous Topic Next Topic
 
classic Classic list List threaded Threaded
1 message Options
Reply | Threaded
Open this post in threaded view
|

FFI: FFI-Pools-mt.27.mcz

commits-2
Marcel Taeumel uploaded a new version of FFI-Pools to project FFI:
http://source.squeak.org/FFI/FFI-Pools-mt.27.mcz

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

Name: FFI-Pools-mt.27
Author: mt
Time: 23 May 2021, 3:42:11.878158 pm
UUID: a2ba55a2-24e2-2940-a551-3daaa4540cfc
Ancestors: FFI-Pools-eem.26

Prepares extra pool for types to be used for fast field access in external structures.

=============== Diff against FFI-Pools-eem.26 ===============

Item was added:
+ SharedPool subclass: #ExternalTypePool
+ instanceVariableNames: ''
+ classVariableNames: ''
+ poolDictionaries: ''
+ category: 'FFI-Pools'!
+
+ !ExternalTypePool commentStamp: 'mt 5/23/2021 15:01' prior: 0!
+ I am a pool for known external types to be used in struct-field accessors. See #useTypePool preference. All subclasses of ExternalStructure should use this shared pool by default.!

Item was added:
+ ----- Method: ExternalTypePool class>>assuredPoolVarNameFor: (in category 'housekeeping') -----
+ assuredPoolVarNameFor: type
+
+ | name |
+ name := (self poolVarNameFor: type) asSymbol.
+ (self classPool includesKey: name)
+ ifFalse: [self addClassVarName: name].
+ self classPool at: name put: type.
+ ^ name!

Item was added:
+ ----- Method: ExternalTypePool class>>cleanUp (in category 'housekeeping') -----
+ cleanUp
+ "
+ self cleanUp.
+ "
+ self classPool keys do: [:classVarName |
+ (classVarName beginsWith: 'ExternalType_') ifTrue: [
+ (self classPool at: classVarName)
+ ifNil: [self classPool removeKey: classVarName]]].!

Item was added:
+ ----- Method: ExternalTypePool class>>poolVarNameFor: (in category 'housekeeping') -----
+ poolVarNameFor: type
+ "Answers the name to be used in the shared pool to speed up type look-up for field access in ExternalStructure."
+
+ ^ String streamContents: [:stream |
+ | nameStream |
+ stream nextPutAll: 'ExternalType_'.
+ nameStream := type typeName readStream.
+ [nameStream atEnd] whileFalse: [
+ | char |
+ (char := nameStream next) caseOf: {
+ [ $( ] -> [ "Ignore." ].
+ [ $) ] -> [ "Ignore." ].
+ [ $* ] -> [ stream nextPutAll: '_star' ].
+ [ $[ ] -> [ stream nextPut: $_ ].
+ [ $] ] -> [ stream nextPut: $_ ]
+ } otherwise: [ stream nextPut: char ]]]!

Item was added:
+ ----- Method: ExternalTypePool class>>reset (in category 'housekeeping') -----
+ reset
+ "
+ self reset
+ "
+ self classPool keys do: [:classVarName |
+ (classVarName beginsWith: 'ExternalType_') ifTrue: [
+ (self classPool at: classVarName put: nil)]].!