--- a/Smalltalk.st Thu Apr 04 20:13:09 2013 +0200
+++ b/Smalltalk.st Mon Apr 08 11:23:14 2013 +0200
@@ -5614,309 +5614,310 @@
wasLazy := Compiler compileLazy:loadLazy.
beSilent notNil ifTrue:[
- wasSilent := self silentLoading:beSilent.
+ wasSilent := self silentLoading:beSilent.
].
classFileName := Smalltalk fileNameForClass:aClassName.
(classFileName = aClassName) ifTrue:[
- "/ no abbrev.stc translation for className
- (aClassName includes:$:) ifTrue:[
- "/ a nameSpace name
- alternativeClassFileName := classFileName copyFrom:(classFileName lastIndexOf:$:)+1
- ].
+ "/ no abbrev.stc translation for className
+ (aClassName includes:$:) ifTrue:[
+ "/ a nameSpace name
+ alternativeClassFileName := classFileName copyFrom:(classFileName lastIndexOf:$:)+1
+ ].
].
classFileName asFilename isAbsolute ifTrue:[
- classFileName asFilename suffix notEmptyOrNil ifTrue:[
- ok := self fileIn:classFileName lazy:loadLazy silent:beSilent.
- ] ifFalse:[
- ok := self fileInSourceFile:classFileName lazy:loadLazy silent:beSilent.
- ]
+ classFileName asFilename suffix notEmptyOrNil ifTrue:[
+ ok := self fileIn:classFileName lazy:loadLazy silent:beSilent.
+ ] ifFalse:[
+ ok := self fileInSourceFile:classFileName lazy:loadLazy silent:beSilent.
+ ]
] ifFalse:[
- classFileName := classFileName copyReplaceAll:$: with:$_.
- [
- Class withoutUpdatingChangesDo:[
- |zarFn zar entry|
-
- ok := false.
-
- package notNil ifTrue:[
- packageDir := package asPackageId projectDirectory.
- "/ packageDir := package asString.
- "/ packageDir := packageDir copyReplaceAll:$: with:$/.
- packageDir isNil ifTrue:[
- packageDir := self packageDirectoryForPackageId:package
- ].
- ].
-
- Class packageQuerySignal answer:package do:[
- "
- then, if dynamic linking is available,
- "
- (LoadBinaries and:[ObjectFileLoader notNil]) ifTrue:[
- sharedLibExtension := ObjectFileLoader sharedLibraryExtension.
- "
- first look for a class packages shared binary in binary/xxx.o
- "
- libName := self libraryFileNameOfClass:aClassName.
- libName notNil ifTrue:[
- (ok := self fileInClass:aClassName fromObject:(libName, sharedLibExtension))
- ifFalse:[
- sharedLibExtension ~= '.o' ifTrue:[
- ok := self fileInClass:aClassName fromObject:(libName, '.o')
- ]
- ].
- ].
- "
- then, look for a shared binary in binary/xxx.o
- "
- ok ifFalse:[
- (ok := self fileInClass:aClassName fromObject:(classFileName, sharedLibExtension))
- ifFalse:[
- sharedLibExtension ~= '.o' ifTrue:[
- ok := self fileInClass:aClassName fromObject:(classFileName, '.o')
- ].
- ok ifFalse:[
- alternativeClassFileName notNil ifTrue:[
- (ok := self fileInClass:aClassName fromObject:(alternativeClassFileName, sharedLibExtension))
- ifFalse:[
- sharedLibExtension ~= '.o' ifTrue:[
- ok := self fileInClass:aClassName fromObject:(alternativeClassFileName, '.o')
- ]
- ]
- ].
- ].
- ].
- ].
- ].
-
- "
- if that did not work, look for a compiled-bytecode file ...
- "
- ok ifFalse:[
- (ok := self fileIn:(classFileName , '.cls') lazy:loadLazy silent:beSilent)
- ifFalse:[
- alternativeClassFileName notNil ifTrue:[
- ok := self fileIn:(alternativeClassFileName , '.cls') lazy:loadLazy silent:beSilent
- ]
- ]
- ].
- "
- if that did not work, and the classes package is known,
- look for an st-cls file
- in a package subdir of the source-directory ...
- "
- ok ifFalse:[
- (packageDir notNil and:[BinaryObjectStorage notNil]) ifTrue:[
- packageFile := self getPackageFileName:(packageDir , '/classes/' , classFileName , '.cls').
- packageFile isNil ifTrue:[
- packageFile := (packageDir , '/classes/' , classFileName , '.cls').
- ].
- (ok := self fileIn:packageFile lazy:loadLazy silent:beSilent)
- ifFalse:[
- alternativeClassFileName notNil ifTrue:[
- packageFile := self getPackageFileName:(packageDir , '/classes/' , alternativeClassFileName , '.cls').
- packageFile isNil ifTrue:[
- packageFile := (packageDir , '/classes/' , alternativeClassFileName , '.cls').
- ].
- ok := self fileIn:packageFile lazy:loadLazy silent:beSilent
- ]
- ].
-
- zarFn := self getPackageFileName:(packageDir , '/classes.zip').
- zarFn notNil ifTrue:[
- zar := ZipArchive oldFileNamed:zarFn.
- zar notNil ifTrue:[
- entry := zar extract:(classFileName , '.cls').
- (entry isNil and:[alternativeClassFileName notNil]) ifTrue:[
- entry := zar extract:(alternativeClassFileName , '.cls').
- ].
- entry notNil ifTrue:[
- bos := BinaryObjectStorage onOld:(entry asByteArray readStream).
- bos next.
- bos close.
- ok := true
- ].
- ]
- ]
- ]
- ].
-
- "
- if that did not work, look for an st-source file ...
- "
- ok ifFalse:[
- filenameToSet := classFileName.
- (ok := self fileInSourceFile:filenameToSet lazy:loadLazy silent:beSilent)
- ifFalse:[
- alternativeClassFileName notNil ifTrue:[
- filenameToSet := alternativeClassFileName.
- ok := self fileInSourceFile:filenameToSet lazy:loadLazy silent:beSilent
- ].
- ok ifFalse:[
- "
- ... and in the standard source-directory
- "
- filenameToSet := 'source/' , classFileName.
- (ok := self fileInSourceFile:filenameToSet lazy:loadLazy silent:beSilent)
- ifFalse:[
- alternativeClassFileName notNil ifTrue:[
- filenameToSet := 'source/' , alternativeClassFileName.
- ok := self fileInSourceFile:filenameToSet lazy:loadLazy silent:beSilent
- ]
- ]
- ]
- ].
- "
- if that did not work, and the classes package is known,
- look for an st-source file
- in a package subdir of the source-directory ...
- "
- ok ifFalse:[
- packageDir notNil ifTrue:[
- packageFile := self getPackageSourceFileName:(packageDir , '/source/' , classFileName).
- packageFile isNil ifTrue:[
- packageFile := (packageDir , '/source/' , classFileName).
- ].
- filenameToSet := packageFile.
- (ok := self fileInSourceFile:packageFile lazy:loadLazy silent:beSilent)
- ifFalse:[
- alternativeClassFileName notNil ifTrue:[
- packageFile := self getPackageSourceFileName:(packageDir , '/source/' , alternativeClassFileName).
- packageFile isNil ifTrue:[
- packageFile := (packageDir , '/source/' , alternativeClassFileName).
- ].
- filenameToSet := packageFile.
- ok := self fileInSourceFile:packageFile lazy:loadLazy silent:beSilent
- ].
- ok ifFalse:[
- packageFile := self getPackageSourceFileName:(packageDir , '/' , classFileName).
- packageFile isNil ifTrue:[
- packageFile := (packageDir , '/' , classFileName).
- ].
- filenameToSet := packageFile.
- (ok := self fileInSourceFile:packageFile lazy:loadLazy silent:beSilent)
- ifFalse:[
- alternativeClassFileName notNil ifTrue:[
- packageFile := self getPackageFileName:(packageDir , '/' , alternativeClassFileName).
- packageFile isNil ifTrue:[
- packageFile := (packageDir , '/' , alternativeClassFileName).
- ].
- filenameToSet := packageFile.
- ok := self fileInSourceFile:packageFile lazy:loadLazy silent:beSilent
- ].
- ok ifFalse:[
- "
- ... and in the standard source-directory
- "
- filenameToSet := 'source/' , packageDir , '/' , classFileName.
- (ok := self fileInSourceFile:filenameToSet lazy:loadLazy silent:beSilent)
- ifFalse:[
- alternativeClassFileName notNil ifTrue:[
- filenameToSet := 'source/' , packageDir , '/' , alternativeClassFileName.
- ok := self fileInSourceFile:filenameToSet lazy:loadLazy silent:beSilent
- ]
- ]
- ]
- ].
- ].
- ].
- ]
- ].
- "
- if that did not work, and the classes package is known,
- look for a zipArchive containing a class entry.
- "
- ok ifFalse:[
- packageDir notNil ifTrue:[
- zarFn := self getPackageFileName:(packageDir , '/source.zip').
- zarFn isNil ifTrue:[
- zarFn := packageDir asFilename withSuffix:'zip'.
- zarFn := self getSourceFileName:zarFn.
- ].
- (zarFn notNil and:[zarFn asFilename exists]) ifTrue:[
- zar := ZipArchive oldFileNamed:zarFn.
- zar notNil ifTrue:[
- entry := zar extract:(classFileName , '.st').
- (entry isNil and:[alternativeClassFileName notNil]) ifTrue:[
- entry := zar extract:(alternativeClassFileName , '.st').
- ].
- entry notNil ifTrue:[
- filenameToSet := zarFn.
- ok := self
- fileInStream:(entry asString readStream)
- lazy:loadLazy
- silent:beSilent
- logged:false
- addPath:nil
- ].
- ]
- ]
- ]
- ].
-
- "
- if that did not work,
- look for a zipArchive containing a class entry.
- "
- ok ifFalse:[
- zarFn := self getSourceFileName:'source.zip'.
- zarFn notNil ifTrue:[
- zar := ZipArchive oldFileNamed:zarFn.
- zar notNil ifTrue:[
- entry := zar extract:(zarFn := classFileName , '.st').
- (entry isNil and:[alternativeClassFileName notNil]) ifTrue:[
- entry := zar extract:(zarFn := alternativeClassFileName , '.st').
- ].
- entry notNil ifTrue:[
- filenameToSet := zarFn.
- ok := self
- fileInStream:(entry asString readStream)
- lazy:loadLazy
- silent:beSilent
- logged:false
- addPath:nil
- ].
- ]
- ]
- ].
- ok ifFalse:[
- "
- if there is a sourceCodeManager, ask it for the classes sourceCode
- "
- (mgr := Smalltalk at:#SourceCodeManager) notNil ifTrue:[
- inStream := mgr getMostRecentSourceStreamForClassNamed:aClassName inPackage:package.
- inStream notNil ifTrue:[
- filenameToSet := nil.
- ok := self fileInStream:inStream lazy:loadLazy silent:beSilent logged:false addPath:nil.
- ]
- ].
- ].
- ].
- ]
- ].
- ] ensure:[
- Compiler compileLazy:wasLazy.
- wasSilent notNil ifTrue:[
- self silentLoading:wasSilent
- ]
- ].
+ classFileName := classFileName copyReplaceAll:$: with:$_.
+ [
+ Class withoutUpdatingChangesDo:[
+ |zarFn zar entry|
+
+ ok := false.
+
+ package notNil ifTrue:[
+ packageDir := package asPackageId projectDirectory.
+ "/ packageDir := package asString.
+ "/ packageDir := packageDir copyReplaceAll:$: with:$/.
+ packageDir isNil ifTrue:[
+ packageDir := self packageDirectoryForPackageId:package
+ ].
+ packageDir := packageDir asFilename.
+ ].
+
+ Class packageQuerySignal answer:package do:[
+ "
+ then, if dynamic linking is available,
+ "
+ (LoadBinaries and:[ObjectFileLoader notNil]) ifTrue:[
+ sharedLibExtension := ObjectFileLoader sharedLibraryExtension.
+ "
+ first look for a class packages shared binary in binary/xxx.o
+ "
+ libName := self libraryFileNameOfClass:aClassName.
+ libName notNil ifTrue:[
+ (ok := self fileInClass:aClassName fromObject:(libName, sharedLibExtension))
+ ifFalse:[
+ sharedLibExtension ~= '.o' ifTrue:[
+ ok := self fileInClass:aClassName fromObject:(libName, '.o')
+ ]
+ ].
+ ].
+ "
+ then, look for a shared binary in binary/xxx.o
+ "
+ ok ifFalse:[
+ (ok := self fileInClass:aClassName fromObject:(classFileName, sharedLibExtension))
+ ifFalse:[
+ sharedLibExtension ~= '.o' ifTrue:[
+ ok := self fileInClass:aClassName fromObject:(classFileName, '.o')
+ ].
+ ok ifFalse:[
+ alternativeClassFileName notNil ifTrue:[
+ (ok := self fileInClass:aClassName fromObject:(alternativeClassFileName, sharedLibExtension))
+ ifFalse:[
+ sharedLibExtension ~= '.o' ifTrue:[
+ ok := self fileInClass:aClassName fromObject:(alternativeClassFileName, '.o')
+ ]
+ ]
+ ].
+ ].
+ ].
+ ].
+ ].
+
+ "
+ if that did not work, look for a compiled-bytecode file ...
+ "
+ ok ifFalse:[
+ (ok := self fileIn:(classFileName , '.cls') lazy:loadLazy silent:beSilent)
+ ifFalse:[
+ alternativeClassFileName notNil ifTrue:[
+ ok := self fileIn:(alternativeClassFileName , '.cls') lazy:loadLazy silent:beSilent
+ ]
+ ]
+ ].
+ "
+ if that did not work, and the classes package is known,
+ look for an st-cls file
+ in a package subdir of the source-directory ...
+ "
+ ok ifFalse:[
+ (packageDir notNil and:[BinaryObjectStorage notNil]) ifTrue:[
+ packageFile := self getPackageFileName:((packageDir / 'classes' / classFileName) addSuffix:'cls').
+ packageFile isNil ifTrue:[
+ packageFile := (packageDir / 'classes' / classFileName) addSuffix:'cls'.
+ ].
+ (ok := self fileIn:packageFile lazy:loadLazy silent:beSilent)
+ ifFalse:[
+ alternativeClassFileName notNil ifTrue:[
+ packageFile := self getPackageFileName:((packageDir / 'classes' / alternativeClassFileName) addSuffix:'cls').
+ packageFile isNil ifTrue:[
+ packageFile := ((packageDir / 'classes' / alternativeClassFileName) addSuffix:'cls').
+ ].
+ ok := self fileIn:packageFile lazy:loadLazy silent:beSilent
+ ]
+ ].
+
+ zarFn := self getPackageFileName:(packageDir / 'classes.zip').
+ zarFn notNil ifTrue:[
+ zar := ZipArchive oldFileNamed:zarFn.
+ zar notNil ifTrue:[
+ entry := zar extract:(classFileName , '.cls').
+ (entry isNil and:[alternativeClassFileName notNil]) ifTrue:[
+ entry := zar extract:(alternativeClassFileName , '.cls').
+ ].
+ entry notNil ifTrue:[
+ bos := BinaryObjectStorage onOld:(entry asByteArray readStream).
+ bos next.
+ bos close.
+ ok := true
+ ].
+ ]
+ ]
+ ]
+ ].
+
+ "
+ if that did not work, look for an st-source file ...
+ "
+ ok ifFalse:[
+ filenameToSet := classFileName.
+ (ok := self fileInSourceFile:filenameToSet lazy:loadLazy silent:beSilent)
+ ifFalse:[
+ alternativeClassFileName notNil ifTrue:[
+ filenameToSet := alternativeClassFileName.
+ ok := self fileInSourceFile:filenameToSet lazy:loadLazy silent:beSilent
+ ].
+ ok ifFalse:[
+ "
+ ... and in the standard source-directory
+ "
+ filenameToSet := 'source' asFilename / classFileName.
+ (ok := self fileInSourceFile:filenameToSet lazy:loadLazy silent:beSilent)
+ ifFalse:[
+ alternativeClassFileName notNil ifTrue:[
+ filenameToSet := 'source' asFilename / alternativeClassFileName.
+ ok := self fileInSourceFile:filenameToSet lazy:loadLazy silent:beSilent
+ ]
+ ]
+ ]
+ ].
+ "
+ if that did not work, and the classes package is known,
+ look for an st-source file
+ in a package subdir of the source-directory ...
+ "
+ ok ifFalse:[
+ packageDir notNil ifTrue:[
+ packageFile := self getPackageSourceFileName:(packageDir / 'source' / classFileName).
+ packageFile isNil ifTrue:[
+ packageFile := (packageDir / 'source' / classFileName).
+ ].
+ filenameToSet := packageFile.
+ (ok := self fileInSourceFile:packageFile lazy:loadLazy silent:beSilent)
+ ifFalse:[
+ alternativeClassFileName notNil ifTrue:[
+ packageFile := self getPackageSourceFileName:(packageDir / 'source' / alternativeClassFileName).
+ packageFile isNil ifTrue:[
+ packageFile := (packageDir / 'source' / alternativeClassFileName).
+ ].
+ filenameToSet := packageFile.
+ ok := self fileInSourceFile:packageFile lazy:loadLazy silent:beSilent
+ ].
+ ok ifFalse:[
+ packageFile := self getPackageSourceFileName:(packageDir / classFileName).
+ packageFile isNil ifTrue:[
+ packageFile := (packageDir / classFileName).
+ ].
+ filenameToSet := packageFile.
+ (ok := self fileInSourceFile:packageFile lazy:loadLazy silent:beSilent)
+ ifFalse:[
+ alternativeClassFileName notNil ifTrue:[
+ packageFile := self getPackageFileName:(packageDir / alternativeClassFileName).
+ packageFile isNil ifTrue:[
+ packageFile := packageDir / alternativeClassFileName.
+ ].
+ filenameToSet := packageFile.
+ ok := self fileInSourceFile:packageFile lazy:loadLazy silent:beSilent
+ ].
+ ok ifFalse:[
+ "
+ ... and in the standard source-directory
+ "
+ filenameToSet := 'source' asFilename / packageDir / classFileName.
+ (ok := self fileInSourceFile:filenameToSet lazy:loadLazy silent:beSilent)
+ ifFalse:[
+ alternativeClassFileName notNil ifTrue:[
+ filenameToSet := 'source' asFilename / packageDir / alternativeClassFileName.
+ ok := self fileInSourceFile:filenameToSet lazy:loadLazy silent:beSilent
+ ]
+ ]
+ ]
+ ].
+ ].
+ ].
+ ]
+ ].
+ "
+ if that did not work, and the classes package is known,
+ look for a zipArchive containing a class entry.
+ "
+ ok ifFalse:[
+ packageDir notNil ifTrue:[
+ zarFn := self getPackageFileName:(packageDir / 'source.zip').
+ zarFn isNil ifTrue:[
+ zarFn := packageDir withSuffix:'zip'.
+ zarFn := self getSourceFileName:zarFn.
+ ].
+ (zarFn notNil and:[zarFn asFilename exists]) ifTrue:[
+ zar := ZipArchive oldFileNamed:zarFn.
+ zar notNil ifTrue:[
+ entry := zar extract:(classFileName , '.st').
+ (entry isNil and:[alternativeClassFileName notNil]) ifTrue:[
+ entry := zar extract:(alternativeClassFileName , '.st').
+ ].
+ entry notNil ifTrue:[
+ filenameToSet := zarFn.
+ ok := self
+ fileInStream:(entry asString readStream)
+ lazy:loadLazy
+ silent:beSilent
+ logged:false
+ addPath:nil
+ ].
+ ]
+ ]
+ ]
+ ].
+
+ "
+ if that did not work,
+ look for a zipArchive containing a class entry.
+ "
+ ok ifFalse:[
+ zarFn := self getSourceFileName:'source.zip'.
+ zarFn notNil ifTrue:[
+ zar := ZipArchive oldFileNamed:zarFn.
+ zar notNil ifTrue:[
+ entry := zar extract:(zarFn := classFileName , '.st').
+ (entry isNil and:[alternativeClassFileName notNil]) ifTrue:[
+ entry := zar extract:(zarFn := alternativeClassFileName , '.st').
+ ].
+ entry notNil ifTrue:[
+ filenameToSet := zarFn.
+ ok := self
+ fileInStream:(entry asString readStream)
+ lazy:loadLazy
+ silent:beSilent
+ logged:false
+ addPath:nil
+ ].
+ ]
+ ]
+ ].
+ ok ifFalse:[
+ "
+ if there is a sourceCodeManager, ask it for the classes sourceCode
+ "
+ (mgr := Smalltalk at:#SourceCodeManager) notNil ifTrue:[
+ inStream := mgr getMostRecentSourceStreamForClassNamed:aClassName inPackage:package.
+ inStream notNil ifTrue:[
+ filenameToSet := nil.
+ ok := self fileInStream:inStream lazy:loadLazy silent:beSilent logged:false addPath:nil.
+ ]
+ ].
+ ].
+ ].
+ ]
+ ].
+ ] ensure:[
+ Compiler compileLazy:wasLazy.
+ wasSilent notNil ifTrue:[
+ self silentLoading:wasSilent
+ ]
+ ].
].
ok ifTrue:[
- newClass := self at:(aClassName asSymbol).
- newClass notNil ifTrue:[
- "set the classes name - but do not change if already set"
- filenameToSet notNil ifTrue:[
- newClass getClassFilename isNil ifTrue:[
- newClass setClassFilename:(filenameToSet asFilename baseName)
- ].
- ].
-
- doInit ifTrue:[
- newClass initialize
- ]
- ]
+ newClass := self at:(aClassName asSymbol).
+ newClass notNil ifTrue:[
+ "set the classes name - but do not change if already set"
+ filenameToSet notNil ifTrue:[
+ newClass getClassFilename isNil ifTrue:[
+ newClass setClassFilename:(filenameToSet asFilename baseName)
+ ].
+ ].
+
+ doInit ifTrue:[
+ newClass initialize
+ ]
+ ]
].
^ newClass
@@ -6009,18 +6010,20 @@
"Modified: / 08-10-2011 / 00:08:51 / cg"
!
-fileInSourceFile:filename lazy:loadLazy silent:beSilent
-
+fileInSourceFile:filenameArg lazy:loadLazy silent:beSilent
"Try all available programming languages"
- ProgrammingLanguage allDo:
- [:lang| | f |
- f := (filename endsWith: ('.' , lang sourceFileSuffix))
- ifTrue:[filename]
- ifFalse:[filename , '.' , lang sourceFileSuffix].
- (self fileIn:f lazy:loadLazy silent:beSilent)
- ifTrue:[^true]].
- ^false
+ |filename|
+
+ filename := filenameArg asFilename.
+ ProgrammingLanguage allDo:[:lang| | f |
+ f := (filename hasSuffix:lang sourceFileSuffix)
+ ifTrue:[filename]
+ ifFalse:[filename addSuffix:lang sourceFileSuffix].
+ (self fileIn:f lazy:loadLazy silent:beSilent)
+ ifTrue:[^ true]
+ ].
+ ^ false
"Created: / 16-08-2009 / 14:45:41 / Jan Vrany <vranyj1@fel.cvut.cz>"
!
@@ -7892,11 +7895,11 @@
!Smalltalk class methodsFor:'documentation'!
version
- ^ '$Header: /cvs/stx/stx/libbasic/Smalltalk.st,v 1.1020 2013-04-04 11:50:52 cg Exp $'
+ ^ '$Header: /cvs/stx/stx/libbasic/Smalltalk.st,v 1.1021 2013-04-08 09:23:14 stefan Exp $'
!
version_CVS
- ^ '$Header: /cvs/stx/stx/libbasic/Smalltalk.st,v 1.1020 2013-04-04 11:50:52 cg Exp $'
+ ^ '$Header: /cvs/stx/stx/libbasic/Smalltalk.st,v 1.1021 2013-04-08 09:23:14 stefan Exp $'
!
version_SVN