comment/format in: #loadPackageWithId:fromDirectory:asAutoloaded:
authorClaus Gittinger <cg@exept.de>
Wed, 23 Sep 2009 21:59:59 +0200
changeset 12019 4fb7ba173794
parent 12018 a24a9968fdf4
child 12020 bf2165daff68
comment/format in: #loadPackageWithId:fromDirectory:asAutoloaded:
Smalltalk.st
--- a/Smalltalk.st	Wed Sep 23 20:04:30 2009 +0200
+++ b/Smalltalk.st	Wed Sep 23 21:59:59 2009 +0200
@@ -5290,60 +5290,6 @@
     ^ nil
 !
 
-fileNameForClass:aClassOrClassName
-    "return a actual or expected (or most wanted) filename for aClassOrClassName
-     - only the base name (without directory part) and without suffix."
-
-    |cls nonMetaclass nm nameWithPrefix nameWithoutPrefix|
-
-    aClassOrClassName isBehavior ifTrue:[
-        cls := aClassOrClassName.    
-    ] ifFalse:[
-        cls := Smalltalk classNamed:aClassOrClassName.
-        cls isNil ifTrue:[
-            nameWithPrefix := aClassOrClassName.
-            nameWithoutPrefix := (aClassOrClassName copyFrom:(aClassOrClassName lastIndexOf:$:)+1).
-        ].
-    ].
-
-    cls notNil ifTrue:[
-        nonMetaclass := cls theNonMetaclass.
-        nm := nonMetaclass getClassFilename.
-        nm notNil ifTrue:[^ nm asFilename withoutSuffix baseName].
-        nameWithPrefix := nonMetaclass name.
-        nameWithoutPrefix := nonMetaclass nameWithoutPrefix.
-    ].
-        
-    CachedAbbreviations notNil ifTrue:[
-        nameWithPrefix := nameWithPrefix asSymbol.
-        (CachedAbbreviations includesKey:nameWithPrefix) ifTrue:[
-            ^ (CachedAbbreviations at:nameWithPrefix) asFilename baseName
-        ].
-        nameWithoutPrefix := nameWithoutPrefix asSymbol.
-        (CachedAbbreviations includesKey:nameWithoutPrefix) ifTrue:[
-            ^ (CachedAbbreviations at:nameWithoutPrefix) asFilename baseName
-        ].
-    ].
-
-    ^ nameWithPrefix copyReplaceAll:$: with:$_
-
-    "
-     Smalltalk fileNameForClass:#Complex
-     Smalltalk fileNameForClass:'SmallInteger'
-     Smalltalk fileNameForClass:'UnixOperatingSystem'
-     Smalltalk fileNameForClass:'Launcher'
-     Smalltalk fileNameForClass:'SomeUnknownClass'
-
-     Smalltalk fileNameForClass:HTML::Encoder
-     Smalltalk fileNameForClass:OSI::FTAMOperation
-     Smalltalk fileNameForClass:'OSI::Foobar'
-     Smalltalk fileNameForClass:(Workflow::UnsuccessfulFinishReasons)
-     Workflow::UnsuccessfulFinishReasons classFilename
-    "
-
-    "Modified: / 06-10-2006 / 16:16:01 / cg"
-!
-
 filenameAbbreviations
     "return a dictionary containing the classname-to-filename
      mappings. (needed for sys5.3 users, where filenames are limited
@@ -6613,34 +6559,6 @@
     "
 !
 
-loadPackageWithId:aPackageId asAutoloaded:doLoadAsAutoloaded
-    "make certain, that some particular package is loaded into the system.
-     Experimental."
-
-    |packageDir|
-
-    packageDir := self packageDirectoryForPackageId:aPackageId.
-    packageDir isNil ifTrue:[
-	(aPackageId includes:$:) ifFalse:[
-	    "/ assume stx
-	    packageDir := self packageDirectoryForPackageId:('stx:',aPackageId).
-	].
-    ].
-
-    ^ self
-	loadPackageWithId:aPackageId
-	fromDirectory:packageDir
-	asAutoloaded:doLoadAsAutoloaded.
-
-    "
-     Smalltalk loadPackageWithId:'stx:libbasic'
-     Smalltalk loadPackageWithId:'stx:goodies/persistency'
-     Smalltalk loadPackageWithId:'exept:ctypes'
-    "
-
-    "Modified: / 07-12-2006 / 15:04:39 / cg"
-!
-
 loadPackageWithId:aPackageId fromDirectory:packageDirOrStringOrNil asAutoloaded:doLoadAsAutoloaded
     "load a package referenced by aPackageId - a string like 'stx:libbasic'.
      The package is either located in packageDirOrStringOrNil, or in the current directory"
@@ -6649,7 +6567,7 @@
      projectDefinitionClass projectDefinitionClassName silent somethingHasBeenLoaded|
 
     packageDirOrStringOrNil notNil ifTrue:[
-	packageDir := packageDirOrStringOrNil asFilename.
+        packageDir := packageDirOrStringOrNil asFilename.
     ].
     silent := SilentLoading or:[ StandAlone ].
 
@@ -6664,27 +6582,27 @@
 
     "if not, file it in ..."
     (projectDefinitionClass isNil and:[packageDir notNil]) ifTrue:[
-	projectDefinitionClassName := ProjectDefinition initialClassNameForDefinitionOf:aPackageId.
-	"/ try to load the project definition class
-	filename := (packageDir construct:projectDefinitionClassName) withSuffix:'st'.
-	filename exists ifFalse:[
-	    filename := ((packageDir construct:'source') construct:projectDefinitionClassName) withSuffix:'st'.
-	].
-	filename exists ifTrue:[
-	    Class withoutUpdatingChangesDo:[
-		filename fileIn.
-	    ].
-	    projectDefinitionClass := ProjectDefinition definitionClassForPackage:aPackageId.
-	].
+        projectDefinitionClassName := ProjectDefinition initialClassNameForDefinitionOf:aPackageId.
+        "/ try to load the project definition class
+        filename := (packageDir construct:projectDefinitionClassName) withSuffix:'st'.
+        filename exists ifFalse:[
+            filename := ((packageDir construct:'source') construct:projectDefinitionClassName) withSuffix:'st'.
+        ].
+        filename exists ifTrue:[
+            Class withoutUpdatingChangesDo:[
+                filename fileIn.
+            ].
+            projectDefinitionClass := ProjectDefinition definitionClassForPackage:aPackageId.
+        ].
     ].
 
     projectDefinitionClass notNil ifTrue:[
-	projectDefinitionClass autoload.
-	somethingHasBeenLoaded := projectDefinitionClass loadAsAutoloaded:doLoadAsAutoloaded.
-	(silent not and:[somethingHasBeenLoaded]) ifTrue:[
-	    Transcript showCR:('Smalltalk [info]: loaded package: ' , aPackageId , ' from project definition').
-	].
-	^ true.
+        projectDefinitionClass autoload.
+        somethingHasBeenLoaded := projectDefinitionClass loadAsAutoloaded:doLoadAsAutoloaded.
+        (silent not and:[somethingHasBeenLoaded]) ifTrue:[
+            Transcript showCR:('Smalltalk [info]: loaded package: ' , aPackageId , ' from project definition').
+        ].
+        ^ true.
     ].
 
     "Is there a shared library (.dll or .so) ?"
@@ -6692,45 +6610,45 @@
 
     filename := Filename currentDirectory construct:shLibName.
     filename exists ifFalse:[
-	packageDir notNil ifTrue:[
-	    filename := packageDir construct:shLibName.
-	    filename exists ifFalse:[
-		filename := (packageDir construct:'objbc') construct:shLibName.
-	    ]
-	]
+        packageDir notNil ifTrue:[
+            filename := packageDir construct:shLibName.
+            filename exists ifFalse:[
+                filename := (packageDir construct:'objbc') construct:shLibName.
+            ]
+        ]
     ].
     filename exists ifTrue:[
-	(self loadPackage:aPackageId fromClassLibrary:filename) ifTrue:[
-	    silent ifFalse:[
-		Transcript showCR:('loaded package: ' , aPackageId , ' from binary classLib file: ' , filename pathName).
-	    ].
-	    doLoadAsAutoloaded ifFalse:[
-		"/ force autoloading...
-		Smalltalk allClassesDo:[:eachClass |
-		    eachClass package == aPackageId ifTrue:[eachClass autoload].
-		].
-	    ].
-	    ^ true
-	]
+        (self loadPackage:aPackageId fromClassLibrary:filename) ifTrue:[
+            silent ifFalse:[
+                Transcript showCR:('loaded package: ' , aPackageId , ' from binary classLib file: ' , filename pathName).
+            ].
+            doLoadAsAutoloaded ifFalse:[
+                "/ force autoloading...
+                Smalltalk allClassesDo:[:eachClass |
+                    eachClass package == aPackageId ifTrue:[eachClass autoload].
+                ].
+            ].
+            ^ true
+        ]
     ].
 
     packageDir isNil ifTrue:[
-	^ false.
+        ^ false.
     ].
 
 
     "/ loadAll ? - will be soon obsolete
     filename := packageDir construct:'loadAll'.
     filename exists ifFalse:[
-	filename := packageDir construct:'loadall'.
+        filename := packageDir construct:'loadall'.
     ].
     filename exists ifTrue:[
-	(self loadPackage:aPackageId fromLoadAllFile:filename) ifTrue:[
-	    silent ifFalse:[
-		Transcript showCR:('loaded package: ' , aPackageId , ' from loadAll file: ' , filename pathName).
-	    ].
-	    ^ true
-	]
+        (self loadPackage:aPackageId fromLoadAllFile:filename) ifTrue:[
+            silent ifFalse:[
+                Transcript showCR:('loaded package: ' , aPackageId , ' from loadAll file: ' , filename pathName).
+            ].
+            ^ true
+        ]
     ].
 
     packageName := packageDir baseName.
@@ -6773,13 +6691,24 @@
 "/    ].
 
 "/ source files-file loading no longer supported
-"/    "/ source files
-"/    (self loadPackage:aPackageId fromAllSourceFilesInDirectory:packageDir) ifTrue:[
-"/        silent ifFalse:[
-"/            Transcript showCR:('loaded package: ' , aPackageId , ' from source files in:' , packageDir pathName).
+"/    self
+"/        recursiveInstallAutoloadedClassesFrom:packageDir
+"/        rememberIn:(Set new)
+"/        maxLevels:2
+"/        noAutoload:false
+"/        packageTop:packageDir
+"/        showSplashInLevels:0.
+"/
+"/    doLoadAsAutoloaded ifFalse:[
+"/        "/ source files
+"/        (self loadPackage:aPackageId fromAllSourceFilesInDirectory:packageDir) ifTrue:[
+"/            silent ifFalse:[
+"/                Transcript showCR:('loaded package: ' , aPackageId , ' from source files in:' , packageDir pathName).
+"/            ].
+"/            ^ true
 "/        ].
-"/        ^ true
 "/    ].
+"/    ^ true
 
     ^ false
 
@@ -7201,5 +7130,5 @@
 !Smalltalk class methodsFor:'documentation'!
 
 version
-    ^ '$Header: /cvs/stx/stx/libbasic/Smalltalk.st,v 1.885 2009-09-22 11:28:56 cg Exp $'
+    ^ '$Header: /cvs/stx/stx/libbasic/Smalltalk.st,v 1.886 2009-09-23 19:59:59 cg Exp $'
 ! !