[squeak-dev] The Inbox: System-mt.1161.mcz

Marcel Taeumel marcel.taeumel at hpi.de
Tue May 26 15:43:47 UTC 2020


1) Is "SystemPlatform" a fitting name? Alternatives: ExternalPlatform, HostPlatform, ...

2) Is it useful to document the known platform shorthands via #isWindows, #isARM, etc.?

3) Is it necessary to access the last platform and the current platform in that #systemPlatformChangedFrom:to: callback? Would #systemPlatformChanged be sufficient?

4) What are your thoughts on #isCompatibleWith: and #isMoreSpecificThan:?

5) Is it too specific to FFI to be in the "System" package? Can you think of VM plugins that would benefit from such a detection? Not sure about FileDirectory ... because those instances become invalid after startup anyway.

Best,
Marcel
Am 26.05.2020 17:28:59 schrieb commits at source.squeak.org <commits at source.squeak.org>:
A new version of System was added to project The Inbox:
http://source.squeak.org/inbox/System-mt.1161.mcz

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

Name: System-mt.1161
Author: mt
Time: 26 May 2020, 5:28:43.825729 pm
UUID: 5a830b9f-86d0-194c-b3a5-165e915ff666
Ancestors: System-mt.1160

Propose SystemPlatform and mechanism to detect platform changes at image startup.

Implementation is based on Monty's FFIExternalSharedPoolPlatform from the FFI-Pools package.

WHY? Can be used to manage platform-specific caches such as FFI's external structures or specifics in other VM plugins.

=============== Diff against System-mt.1160 ===============

Item was added:
+ ----- Method: ClassDescription>>systemPlatformChanged (in category '*System-Support') -----
+ systemPlatformChanged
+ "Access the current platform via SystemPlatform class >> #current."!

Item was added:
+ ----- Method: ClassDescription>>systemPlatformChangedFrom: (in category '*System-Support') -----
+ systemPlatformChangedFrom: lastPlatform
+ "Access the current platform via SystemPlatform class >> #current."
+
+ self systemPlatformChanged.!

Item was added:
+ ----- Method: ClassDescription>>systemPlatformChangedFrom:to: (in category '*System-Support') -----
+ systemPlatformChangedFrom: lastPlatform to: currentPlatform
+
+ self systemPlatformChangedFrom: currentPlatform.!

Item was added:
+ Object subclass: #SystemPlatform
+ instanceVariableNames: 'name osVersion subtype wordSize'
+ classVariableNames: 'LastPlatform'
+ poolDictionaries: ''
+ category: 'System-Support'!
+
+ !SystemPlatform commentStamp: 'mt 5/26/2020 16:30' prior: 0!
+ This class stores the host platform information to support testing instances for platform compatibility and specificity.
+
+ At image startup time, a change of platform will result in a call back so that interested classes can recalibrate external dependencies.!

Item was added:
+ ----- Method: SystemPlatform class>>current (in category 'accessing') -----
+ current
+ ^ LastPlatform ifNil: [LastPlatform := self newCurrent]!

Item was added:
+ ----- Method: SystemPlatform class>>initialize (in category 'class initialization') -----
+ initialize
+ "Make sure to detect a platform change as soon as possible on startup."
+
+ Smalltalk addToStartUpList: self after: DateAndTime.!

Item was added:
+ ----- Method: SystemPlatform class>>name: (in category 'instance creation') -----
+ name: aName
+ ^ self new name: aName!

Item was added:
+ ----- Method: SystemPlatform class>>name:osVersion: (in category 'instance creation') -----
+ name: aName osVersion: anOSVersionString
+ ^ self new
+ name: aName;
+ osVersion: anOSVersionString!

Item was added:
+ ----- Method: SystemPlatform class>>name:osVersion:subtype: (in category 'instance creation') -----
+ name: aName osVersion: anOSVersionString subtype: aSubtypeString
+ ^ self new
+ name: aName;
+ osVersion: anOSVersionString;
+ subtype: aSubtypeString!

Item was added:
+ ----- Method: SystemPlatform class>>name:osVersion:subtype:wordSize: (in category 'instance creation') -----
+ name: aName osVersion: anOSVersionString subtype: aSubtypeString wordSize: aWordSize
+ ^ self new
+ name: aName;
+ osVersion: anOSVersionString;
+ subtype: aSubtypeString;
+ wordSize: aWordSize!

Item was added:
+ ----- Method: SystemPlatform class>>name:wordSize: (in category 'instance creation') -----
+ name: aName wordSize: aWordSize
+ ^ self new
+ name: aName;
+ wordSize: aWordSize!

Item was added:
+ ----- Method: SystemPlatform class>>newCurrent (in category 'instance creation') -----
+ newCurrent
+
+ ^ self
+ name: Smalltalk os platformName
+ osVersion: Smalltalk osVersion
+ subtype: Smalltalk os platformSubtype
+ wordSize: Smalltalk wordSize!

Item was added:
+ ----- Method: SystemPlatform class>>startUp: (in category 'system startup') -----
+ startUp: resuming
+ "Notify all classes about platform changes."
+
+ resuming ifTrue: [
+ LastPlatform in: [:lastPlatform | self newCurrent in: [:currentPlatform |
+ lastPlatform = currentPlatform ifFalse: [
+ LastPlatform := currentPlatform.
+ Object withAllSubclassesDo: [:cls |
+ cls systemPlatformChangedFrom: lastPlatform to: currentPlatform]]]]].!

Item was added:
+ ----- Method: SystemPlatform>>= (in category 'comparing') -----
+ = anObject
+ self == anObject
+ ifTrue: [^ true].
+
+ self species == anObject species
+ ifFalse: [^ false].
+
+ ^ self name = anObject name
+ and: [self osVersion = anObject osVersion
+ and: [self subtype = anObject subtype
+ and: [self wordSize = anObject wordSize]]].!

Item was added:
+ ----- Method: SystemPlatform>>hasName (in category 'testing') -----
+ hasName
+ ^ self name notEmpty!

Item was added:
+ ----- Method: SystemPlatform>>hasOSVersion (in category 'testing') -----
+ hasOSVersion
+ ^ self osVersion notEmpty!

Item was added:
+ ----- Method: SystemPlatform>>hasSubtype (in category 'testing') -----
+ hasSubtype
+ ^ self subtype notEmpty!

Item was added:
+ ----- Method: SystemPlatform>>hasWordSize (in category 'testing') -----
+ hasWordSize
+ ^ self wordSize notNil!

Item was added:
+ ----- Method: SystemPlatform>>hash (in category 'comparing') -----
+ hash
+ ^ (((self species hash bitXor:
+ self name hash) bitXor:
+ self osVersion hash) bitXor:
+ self subtype hash) bitXor:
+ self wordSize hash!

Item was added:
+ ----- Method: SystemPlatform>>isARM (in category 'testing') -----
+ isARM
+ "E.g., Raspberry PI"
+
+ ^ self subtype asLowercase beginsWith: 'arm'!

Item was added:
+ ----- Method: SystemPlatform>>isCompatibleWith: (in category 'testing - compatibility') -----
+ isCompatibleWith: aPlatform
+ self == aPlatform
+ ifTrue: [^ true].
+
+ (self name = aPlatform name
+ or: [self hasName not
+ or: [aPlatform hasName not]])
+ ifFalse: [^ false].
+
+ (self osVersion = aPlatform osVersion
+ or: [self hasOSVersion not
+ or: [aPlatform hasOSVersion not]])
+ ifFalse: [^ false].
+
+ (self subtype = aPlatform subtype
+ or: [self hasSubtype not
+ or: [aPlatform hasSubtype not]])
+ ifFalse: [^ false].
+
+ (self wordSize = aPlatform wordSize
+ or: [self hasWordSize not
+ or: [aPlatform hasWordSize not]])
+ ifFalse: [^ false].
+
+ ^ true.!

Item was added:
+ ----- Method: SystemPlatform>>isMacOS (in category 'testing') -----
+ isMacOS
+
+ ^ self name asLowercase beginsWith: 'mac'!

Item was added:
+ ----- Method: SystemPlatform>>isMoreSpecificThan: (in category 'testing - compatibility') -----
+ isMoreSpecificThan: aPlatform
+ self == aPlatform
+ ifTrue: [^ false].
+
+ (self hasName
+ and: [aPlatform hasName not])
+ ifTrue: [^ true].
+
+ (self hasOSVersion
+ and: [aPlatform hasOSVersion not])
+ ifTrue: [^ true].
+
+ (self hasSubtype
+ and: [aPlatform hasSubtype not])
+ ifTrue: [^ true].
+
+ (self hasWordSize
+ and: [aPlatform hasWordSize not])
+ ifTrue: [^ true].
+
+ ^ false.!

Item was added:
+ ----- Method: SystemPlatform>>isRiscOS (in category 'testing') -----
+ isRiscOS
+
+ ^ self name asLowercase beginsWith: 'risc'!

Item was added:
+ ----- Method: SystemPlatform>>isUnix (in category 'testing') -----
+ isUnix
+
+ ^ self name asLowercase beginsWith: 'unix'!

Item was added:
+ ----- Method: SystemPlatform>>isWeb (in category 'testing') -----
+ isWeb
+ "SqueakJS"
+
+ ^ self name asLowercase beginsWith: 'web'!

Item was added:
+ ----- Method: SystemPlatform>>isWindows (in category 'testing') -----
+ isWindows
+
+ ^ self name asLowercase beginsWith: 'win'!

Item was added:
+ ----- Method: SystemPlatform>>name (in category 'accessing') -----
+ name
+ ^ name ifNil: [name := '']!

Item was added:
+ ----- Method: SystemPlatform>>name: (in category 'accessing') -----
+ name: aName
+ name := aName!

Item was added:
+ ----- Method: SystemPlatform>>osVersion (in category 'accessing') -----
+ osVersion
+ ^ osVersion ifNil: [osVersion := '']!

Item was added:
+ ----- Method: SystemPlatform>>osVersion: (in category 'accessing') -----
+ osVersion: anOSVersionString
+ osVersion := anOSVersionString!

Item was added:
+ ----- Method: SystemPlatform>>printOn: (in category 'printing') -----
+ printOn: aStream
+ self storeOn: aStream!

Item was added:
+ ----- Method: SystemPlatform>>storeOn: (in category 'printing') -----
+ storeOn: aStream
+ aStream
+ nextPut: $(;
+ nextPutAll: self class name asString;
+ nextPutAll: ' name: ';
+ print: self name;
+ nextPutAll: ' osVersion: ';
+ print: self osVersion;
+ nextPutAll: ' subtype: ';
+ print: self subtype;
+ nextPutAll: ' wordSize: ';
+ print: self wordSize;
+ nextPut: $).!

Item was added:
+ ----- Method: SystemPlatform>>subtype (in category 'accessing') -----
+ subtype
+ ^ subtype ifNil: [subtype := '']!

Item was added:
+ ----- Method: SystemPlatform>>subtype: (in category 'accessing') -----
+ subtype: aSubtypeString
+ subtype := aSubtypeString!

Item was added:
+ ----- Method: SystemPlatform>>wordSize (in category 'accessing') -----
+ wordSize
+ ^ wordSize!

Item was added:
+ ----- Method: SystemPlatform>>wordSize: (in category 'accessing') -----
+ wordSize: aWordSize
+ wordSize := aWordSize!


-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.squeakfoundation.org/pipermail/squeak-dev/attachments/20200526/eac413fd/attachment.html>


More information about the Squeak-dev mailing list