#REFACTORING by cg
authorClaus Gittinger <cg@exept.de>
Wed, 09 May 2018 12:05:08 +0200
changeset 22818 2d1519c3ed91
parent 22817 65a92285bb30
child 22819 0f32cbafef8c
#REFACTORING by cg class: ClassDescription added: #sharedPoolNamed: changed: #sharedPools
ClassDescription.st
--- a/ClassDescription.st	Wed May 09 11:54:13 2018 +0200
+++ b/ClassDescription.st	Wed May 09 12:05:08 2018 +0200
@@ -1148,6 +1148,52 @@
     "Created: 3.6.1997 / 11:55:05 / cg"
 !
 
+sharedPoolNamed:aPoolName
+    "this returns a resolved real pool (i.e. a PoolDictionary),
+     This cares for the namespace in which the class is located
+
+     Notice, that for source compatibility with other smalltalks,
+     the pool's namespace in a class definition is not in the pool name, 
+     as to make it is easy to fileIn an alien class into an ST/X namespace,
+     and also to allow filing out smalltalk-namespace classes for import into
+     another smalltalk. 
+     However, then we must resolve the actual pool later - i.e. here"
+
+    |pool ns ns2|
+
+    ns := self nameSpace.
+    ns2 := self topNameSpace.
+
+    (ns notNil and:[ns ~= Smalltalk]) ifTrue:[
+        (pool := ns classNamed:aPoolName) notNil ifTrue:[^ pool].
+    ].
+    (ns2 notNil and:[ns2 ~~ ns and:[ns2 ~= Smalltalk]]) ifTrue:[
+        (pool := ns2 classNamed:aPoolName) notNil ifTrue:[^ pool].
+    ].
+    pool := Smalltalk classNamed:aPoolName.
+    pool isNil ifTrue:[
+        Logger notNil ifTrue:[ Logger warning:('Warning: no such pool: ',aPoolName)].
+    ].
+    ^ pool.
+    "
+     an example for a pool inside a namespace (in this case: a private pool):
+        UnixOperatingSystem::ELFFileHeader sharedPools
+
+     Smalltalk allClasses 
+            collect:[:cls | cls -> cls sharedPools]
+            thenSelect:[:assoc | assoc value notEmptyOrNil].
+
+     OSI::ASN1_Coder sharedPoolNames
+     ZipArchive sharedPools
+     Croquet::OpenGL sharedPools
+     OpenGLRenderingContext sharedPools
+     Character sharedPools
+     Win32OperatingSystem sharedPools
+    "
+
+    "Modified: / 29-05-2012 / 12:09:27 / cg"
+!
+
 sharedPoolNames
     "this returns a collection of the plain (non-namespace aware) pool names"
 
@@ -1164,39 +1210,15 @@
      into an ST/X namespace. 
      However, then we must resolve the actual pool later - i.e. here"
 
-    |poolNames ns ns2 pools|
+    |poolNames|
 
     poolNames := self sharedPoolNames.
     poolNames isEmptyOrNil ifTrue:[^ #() ].
 
-    ns := self nameSpace.
-    ns2 := self topNameSpace.
-    pools :=
-         poolNames
-            collect:[:eachName |
-                    |pool|
-
-                    (ns notNil and:[ns ~= Smalltalk]) ifTrue:[
-                        pool := ns classNamed:eachName.
-                    ].
-                    pool isNil ifTrue:[
-                        (ns2 notNil and:[ns2 ~~ ns and:[ns2 ~= Smalltalk]]) ifTrue:[
-                            pool := ns2 classNamed:eachName.
-                        ].
-                        pool isNil ifTrue:[
-                            pool := Smalltalk classNamed:eachName.
-                            pool isNil ifTrue:[
-                                Transcript showCR:('Warning: no such pool: ',eachName).
-                            ]
-                        ].
-                    ].
-                    pool
-                ]
+    ^ poolNames
+            collect:[:eachName | self sharedPoolNamed:eachName]
             thenSelect:[:pool | pool notNil].
 
-    ^ pools.
-
-
     "
      an example for a pool inside a namespace (in this case: a private pool):
         UnixOperatingSystem::ELFFileHeader sharedPools