<div id="__MailbirdStyleContent" style="font-size: 10pt;font-family: Arial;color: #000000">
                                        
                                        
                                            
                                        
                                        
                                        1) Is "SystemPlatform" a fitting name? Alternatives: ExternalPlatform, HostPlatform, ...<div><br></div><div>2) Is it useful to document the known platform shorthands via #isWindows, #isARM, etc.?</div><div><br></div><div>3) Is it necessary to access the last platform and the current platform in that #systemPlatformChangedFrom:to: callback? Would #systemPlatformChanged be sufficient?</div><div><br></div><div>4) What are your thoughts on #isCompatibleWith: and #isMoreSpecificThan:?</div><div><br></div><div>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.</div><div><br></div><div>Best,</div><div>Marcel</div><div class="mb_sig"></div>
                                        
                                        <blockquote class="history_container" type="cite" style="border-left-style: solid;border-width: 1px;margin-top: 20px;margin-left: 0px;padding-left: 10px;min-width: 500px">
                        <p style="color: #AAAAAA; margin-top: 10px;">Am 26.05.2020 17:28:59 schrieb commits@source.squeak.org <commits@source.squeak.org>:</p><div style="font-family:Arial,Helvetica,sans-serif">A new version of System was added to project The Inbox:<br>http://source.squeak.org/inbox/System-mt.1161.mcz<br><br>==================== Summary ====================<br><br>Name: System-mt.1161<br>Author: mt<br>Time: 26 May 2020, 5:28:43.825729 pm<br>UUID: 5a830b9f-86d0-194c-b3a5-165e915ff666<br>Ancestors: System-mt.1160<br><br>Propose SystemPlatform and mechanism to detect platform changes at image startup.<br><br>Implementation is based on Monty's FFIExternalSharedPoolPlatform from the FFI-Pools package.<br><br>WHY? Can be used to manage platform-specific caches such as FFI's external structures or specifics in other VM plugins.<br><br>=============== Diff against System-mt.1160 ===============<br><br>Item was added:<br>+ ----- Method: ClassDescription>>systemPlatformChanged (in category '*System-Support') -----<br>+ systemPlatformChanged<br>+       "Access the current platform via SystemPlatform class >> #current."!<br><br>Item was added:<br>+ ----- Method: ClassDescription>>systemPlatformChangedFrom: (in category '*System-Support') -----<br>+ systemPlatformChangedFrom: lastPlatform<br>+         "Access the current platform via SystemPlatform class >> #current."<br>+  <br>+     self systemPlatformChanged.!<br><br>Item was added:<br>+ ----- Method: ClassDescription>>systemPlatformChangedFrom:to: (in category '*System-Support') -----<br>+ systemPlatformChangedFrom: lastPlatform to: currentPlatform<br>+ <br>+      self systemPlatformChangedFrom: currentPlatform.!<br><br>Item was added:<br>+ Object subclass: #SystemPlatform<br>+     instanceVariableNames: 'name osVersion subtype wordSize'<br>+     classVariableNames: 'LastPlatform'<br>+   poolDictionaries: ''<br>+         category: 'System-Support'!<br>+ <br>+ !SystemPlatform commentStamp: 'mt 5/26/2020 16:30' prior: 0!<br>+ This class stores the host platform information to support testing instances for platform compatibility and specificity.<br>+ <br>+ At image startup time, a change of platform will result in a call back so that interested classes can recalibrate external dependencies.!<br><br>Item was added:<br>+ ----- Method: SystemPlatform class>>current (in category 'accessing') -----<br>+ current<br>+      ^ LastPlatform ifNil: [LastPlatform := self newCurrent]!<br><br>Item was added:<br>+ ----- Method: SystemPlatform class>>initialize (in category 'class initialization') -----<br>+ initialize<br>+         "Make sure to detect a platform change as soon as possible on startup."<br>+ <br>+        Smalltalk addToStartUpList: self after: DateAndTime.!<br><br>Item was added:<br>+ ----- Method: SystemPlatform class>>name: (in category 'instance creation') -----<br>+ name: aName<br>+   ^ self new name: aName!<br><br>Item was added:<br>+ ----- Method: SystemPlatform class>>name:osVersion: (in category 'instance creation') -----<br>+ name: aName osVersion: anOSVersionString<br>+  ^ self new<br>+           name: aName;<br>+                 osVersion: anOSVersionString!<br><br>Item was added:<br>+ ----- Method: SystemPlatform class>>name:osVersion:subtype: (in category 'instance creation') -----<br>+ name: aName osVersion: anOSVersionString subtype: aSubtypeString<br>+    ^ self new<br>+           name: aName;<br>+                 osVersion: anOSVersionString;<br>+                subtype: aSubtypeString!<br><br>Item was added:<br>+ ----- Method: SystemPlatform class>>name:osVersion:subtype:wordSize: (in category 'instance creation') -----<br>+ name: aName osVersion: anOSVersionString subtype: aSubtypeString wordSize: aWordSize<br>+    ^ self new<br>+           name: aName;<br>+                 osVersion: anOSVersionString;<br>+                subtype: aSubtypeString;<br>+             wordSize: aWordSize!<br><br>Item was added:<br>+ ----- Method: SystemPlatform class>>name:wordSize: (in category 'instance creation') -----<br>+ name: aName wordSize: aWordSize<br>+       ^ self new<br>+           name: aName;<br>+                 wordSize: aWordSize!<br><br>Item was added:<br>+ ----- Method: SystemPlatform class>>newCurrent (in category 'instance creation') -----<br>+ newCurrent<br>+ <br>+    ^ self<br>+               name: Smalltalk os platformName<br>+              osVersion: Smalltalk osVersion<br>+               subtype: Smalltalk os platformSubtype<br>+                wordSize: Smalltalk wordSize!<br><br>Item was added:<br>+ ----- Method: SystemPlatform class>>startUp: (in category 'system startup') -----<br>+ startUp: resuming<br>+     "Notify all classes about platform changes."<br>+ <br>+   resuming ifTrue: [<br>+           LastPlatform in: [:lastPlatform | self newCurrent in: [:currentPlatform |<br>+                    lastPlatform = currentPlatform ifFalse: [<br>+                            LastPlatform := currentPlatform.<br>+                             Object withAllSubclassesDo: [:cls |<br>+                                  cls systemPlatformChangedFrom: lastPlatform to: currentPlatform]]]]].!<br><br>Item was added:<br>+ ----- Method: SystemPlatform>>= (in category 'comparing') -----<br>+ = anObject<br>+     self == anObject<br>+             ifTrue: [^ true].<br>+ <br>+        self species == anObject species<br>+             ifFalse: [^ false].<br>+ <br>+      ^ self name = anObject name<br>+          and: [self osVersion = anObject osVersion<br>+                    and: [self subtype = anObject subtype<br>+                                and: [self wordSize = anObject wordSize]]].!<br><br>Item was added:<br>+ ----- Method: SystemPlatform>>hasName (in category 'testing') -----<br>+ hasName<br>+      ^ self name notEmpty!<br><br>Item was added:<br>+ ----- Method: SystemPlatform>>hasOSVersion (in category 'testing') -----<br>+ hasOSVersion<br>+   ^ self osVersion notEmpty!<br><br>Item was added:<br>+ ----- Method: SystemPlatform>>hasSubtype (in category 'testing') -----<br>+ hasSubtype<br>+  ^ self subtype notEmpty!<br><br>Item was added:<br>+ ----- Method: SystemPlatform>>hasWordSize (in category 'testing') -----<br>+ hasWordSize<br>+  ^ self wordSize notNil!<br><br>Item was added:<br>+ ----- Method: SystemPlatform>>hash (in category 'comparing') -----<br>+ hash<br>+       ^ (((self species hash bitXor:<br>+               self name hash) bitXor:<br>+                      self osVersion hash) bitXor:<br>+                                 self subtype hash) bitXor:<br>+                                   self wordSize hash!<br><br>Item was added:<br>+ ----- Method: SystemPlatform>>isARM (in category 'testing') -----<br>+ isARM<br>+   "E.g., Raspberry PI"<br>+       <br>+     ^ self subtype asLowercase beginsWith: 'arm'!<br><br>Item was added:<br>+ ----- Method: SystemPlatform>>isCompatibleWith: (in category 'testing - compatibility') -----<br>+ isCompatibleWith: aPlatform<br>+       self == aPlatform<br>+            ifTrue: [^ true].<br>+ <br>+        (self name = aPlatform name<br>+          or: [self hasName not<br>+                        or: [aPlatform hasName not]])<br>+                ifFalse: [^ false].<br>+ <br>+      (self osVersion = aPlatform osVersion<br>+                or: [self hasOSVersion not<br>+                   or: [aPlatform hasOSVersion not]])<br>+           ifFalse: [^ false].<br>+ <br>+      (self subtype = aPlatform subtype<br>+            or: [self hasSubtype not<br>+                     or: [aPlatform hasSubtype not]])<br>+             ifFalse: [^ false].<br>+ <br>+      (self wordSize = aPlatform wordSize<br>+          or: [self hasWordSize not<br>+                    or: [aPlatform hasWordSize not]])<br>+            ifFalse: [^ false].<br>+ <br>+      ^ true.!<br><br>Item was added:<br>+ ----- Method: SystemPlatform>>isMacOS (in category 'testing') -----<br>+ isMacOS<br>+ <br>+      ^ self name asLowercase beginsWith: 'mac'!<br><br>Item was added:<br>+ ----- Method: SystemPlatform>>isMoreSpecificThan: (in category 'testing - compatibility') -----<br>+ isMoreSpecificThan: aPlatform<br>+      self == aPlatform<br>+            ifTrue: [^ false].<br>+ <br>+       (self hasName<br>+                and: [aPlatform hasName not])<br>+                ifTrue: [^ true].<br>+ <br>+        (self hasOSVersion<br>+           and: [aPlatform hasOSVersion not])<br>+           ifTrue: [^ true].<br>+ <br>+        (self hasSubtype<br>+             and: [aPlatform hasSubtype not])<br>+             ifTrue: [^ true].<br>+ <br>+        (self hasWordSize<br>+            and: [aPlatform hasWordSize not])<br>+            ifTrue: [^ true].<br>+ <br>+        ^ false.!<br><br>Item was added:<br>+ ----- Method: SystemPlatform>>isRiscOS (in category 'testing') -----<br>+ isRiscOS<br>+ <br>+   ^ self name asLowercase beginsWith: 'risc'!<br><br>Item was added:<br>+ ----- Method: SystemPlatform>>isUnix (in category 'testing') -----<br>+ isUnix<br>+ <br>+     ^ self name asLowercase beginsWith: 'unix'!<br><br>Item was added:<br>+ ----- Method: SystemPlatform>>isWeb (in category 'testing') -----<br>+ isWeb<br>+   "SqueakJS"<br>+         <br>+     ^ self name asLowercase beginsWith: 'web'!<br><br>Item was added:<br>+ ----- Method: SystemPlatform>>isWindows (in category 'testing') -----<br>+ isWindows<br>+ <br>+        ^ self name asLowercase beginsWith: 'win'!<br><br>Item was added:<br>+ ----- Method: SystemPlatform>>name (in category 'accessing') -----<br>+ name<br>+    ^ name ifNil: [name := '']!<br><br>Item was added:<br>+ ----- Method: SystemPlatform>>name: (in category 'accessing') -----<br>+ name: aName<br>+   name := aName!<br><br>Item was added:<br>+ ----- Method: SystemPlatform>>osVersion (in category 'accessing') -----<br>+ osVersion<br>+      ^ osVersion ifNil: [osVersion := '']!<br><br>Item was added:<br>+ ----- Method: SystemPlatform>>osVersion: (in category 'accessing') -----<br>+ osVersion: anOSVersionString<br>+   osVersion := anOSVersionString!<br><br>Item was added:<br>+ ----- Method: SystemPlatform>>printOn: (in category 'printing') -----<br>+ printOn: aStream<br>+        self storeOn: aStream!<br><br>Item was added:<br>+ ----- Method: SystemPlatform>>storeOn: (in category 'printing') -----<br>+ storeOn: aStream<br>+         aStream<br>+              nextPut: $(;<br>+                 nextPutAll: self class name asString;<br>+                nextPutAll: ' name: ';<br>+               print: self name;<br>+            nextPutAll: ' osVersion: ';<br>+          print: self osVersion;<br>+               nextPutAll: ' subtype: ';<br>+            print: self subtype;<br>+                 nextPutAll: ' wordSize: ';<br>+           print: self wordSize;<br>+                nextPut: $).!<br><br>Item was added:<br>+ ----- Method: SystemPlatform>>subtype (in category 'accessing') -----<br>+ subtype<br>+   ^ subtype ifNil: [subtype := '']!<br><br>Item was added:<br>+ ----- Method: SystemPlatform>>subtype: (in category 'accessing') -----<br>+ subtype: aSubtypeString<br>+      subtype := aSubtypeString!<br><br>Item was added:<br>+ ----- Method: SystemPlatform>>wordSize (in category 'accessing') -----<br>+ wordSize<br>+    ^ wordSize!<br><br>Item was added:<br>+ ----- Method: SystemPlatform>>wordSize: (in category 'accessing') -----<br>+ wordSize: aWordSize<br>+       wordSize := aWordSize!<br><br><br></div></blockquote></div>