--- a/Project.st Sat Sep 18 15:55:43 1999 +0200
+++ b/Project.st Mon Sep 20 08:58:11 1999 +0200
@@ -20,15 +20,15 @@
category:'System-Support'
!
-Object subclass:#MethodInfo
- instanceVariableNames:'conditionForInclusion methodName className fileName'
+Object subclass:#ClassInfo
+ instanceVariableNames:'conditionForInclusion className classFileName'
classVariableNames:''
poolDictionaries:''
privateIn:Project
!
-Object subclass:#ClassInfo
- instanceVariableNames:'conditionForInclusion className classFileName'
+Object subclass:#MethodInfo
+ instanceVariableNames:'conditionForInclusion methodName className fileName'
classVariableNames:''
poolDictionaries:''
privateIn:Project
@@ -910,7 +910,7 @@
loadFromProjectFile:aFilename
"fill all of my attributes from a projects file (.prj-file)"
- |f l pack targetConditions s sourcesSubDir files module|
+ |f l pack targetConditions s sourcesSubDir files module methodsFile|
f := aFilename asFilename.
directoryName := f directory pathName.
@@ -922,6 +922,8 @@
packageName := pack at:'package' ifAbsent:packageName.
name := pack at:'name' ifAbsent:name.
+ self type:(pack at:'type' ifAbsent:#application) asSymbol.
+
module := pack at:'repository.module' ifAbsent:nil.
module notNil ifTrue:[
repositoryModule := module.
@@ -933,7 +935,7 @@
s := pack at:'nameSpace' ifAbsent:nil.
s notNil ifTrue:[
- self defaultNameSpace:(Namespace name:s).
+ self defaultNameSpace:(Namespace name:s asSymbol).
].
subProjects := pack at:'subProjects' ifAbsent:subProjects.
@@ -961,6 +963,10 @@
sourcesSubDir notNil ifTrue:[
properties at:#'sourcesDirectory' put:sourcesSubDir.
].
+ methodsFile := pack at:'methodsFile' ifAbsent:nil.
+ methodsFile notNil ifTrue:[
+ properties at:#'methodsFile' put:methodsFile.
+ ].
files := pack at:'files' ifAbsent:nil.
files notNil ifTrue:[
properties at:#'files' put:files.
@@ -977,9 +983,9 @@
] ifFalse:[
className := info at:1.
info size > 1 ifTrue:[
- optionalFileName := info at:2.
+ condKey := info at:2.
info size > 2 ifTrue:[
- condKey := info at:3.
+ optionalFileName := info at:3.
]
].
].
@@ -1033,10 +1039,12 @@
"store all of my attributes into a projects file (.prj-file)
(in the project-directory and named as <projectName>.prj)"
- |fn s|
-
- fn := self directory asFilename.
- fn := fn construct:self name.
+ |dir fn nm s|
+
+ dir := self directory asFilename.
+ nm := self name.
+ nm := nm copyFrom:(nm lastIndexOf:$/)+1.
+ fn := dir construct:nm.
fn := fn withSuffix:'prj'.
fn exists ifTrue:[
@@ -1059,17 +1067,24 @@
Actually, the format is the same as used for resources (i.e. key - value pairs)
and the code below could be much simpler - if there where no humans to read it ..."
- |s coll first maxLen t defNS|
+ |s coll first maxLen t defNS methodsFile|
s := aStream.
s nextPutLine:'; $Header' , '$'; nextPutLine:';'.
s nextPutLine:'; Project saved ' , Smalltalk timeStamp; nextPutLine:';'.
- s nextPutLine:'; Be careful when editing - do not corrupt the files syntax.'.
- s nextPutLine:'; (Lines starting with a semicolon are comment lines)'.
- s nextPutLine:'; (Lines ending with a backslash are concatenated with the following line)'.
-
- s cr; nextPutLine:';'; nextPutLine:'; general:'; nextPutLine:';'.
+ s nextPutAll:'; Be careful when editing - do not corrupt the files syntax.
+; Lines starting with a semicolon are comment lines.
+; Lines ending with a backslash are concatenated with the following line.
+; Entries are key-value pairs, separated by whitespace;
+; the value is a smalltalk literal expression.
+'.
+
+ s nextPutAll:'
+;
+; general:
+;
+'.
s nextPutAll:'comment'.
s tab. s nextPutLine:(self comment storeString).
@@ -1089,7 +1104,11 @@
s tab. s nextPutLine:(defNS name storeString).
].
- s cr; nextPutLine:';'; nextPutLine:'; repository:'; nextPutLine:';'.
+ s nextPutAll:'
+;
+; repository:
+;
+'.
s nextPutAll:'repository.module'.
s tab. s nextPutLine:(repositoryModule ? 'private') storeString.
s nextPutAll:'repository.directory'.
@@ -1109,15 +1128,29 @@
targetconditions
classes
classInfo
+ methodInfo
prerequisiteClasses
files
+ sourcesDirectory
+ methodsFile
+ type
+ defaultNameSpace
) includes:key) ifFalse:[
first ifTrue:[
first := false.
- s cr; nextPutLine:';'; nextPutLine:'; properties:'; nextPutLine:';'.
+ s nextPutAll:'
+;
+; properties:
+;
+'.
].
s nextPutAll:'property.'; nextPutAll:key.
- s tab. s nextPutLine:val storeString.
+ s tab.
+ key == #defaultNameSpace ifTrue:[
+ s nextPutLine:val name storeString.
+ ] ifFalse:[
+ s nextPutLine:val storeString.
+ ]
]
].
@@ -1129,7 +1162,11 @@
"/ ].
"/ ].
- s cr; nextPutLine:';'; nextPutLine:'; required packages:'; nextPutLine:';'.
+ s nextPutAll:'
+;
+; required packages:
+;
+'.
s nextPutAll:'prerequisites'; tab.
coll := self prerequisites.
coll size = 0 ifTrue:[
@@ -1162,74 +1199,134 @@
s nextPutLine:')'.
].
- s cr; nextPutLine:';'; nextPutLine:'; required classes:'; nextPutLine:';'.
+ s nextPutAll:'
+;
+; required classes:
+;
+'.
s nextPutAll:'prerequisiteClasses'; tab.
coll := self prerequisiteClasses.
- s nextPutLine:'#( \'.
- coll do:[:aClassOrSymbol | |className|
-
- (className := aClassOrSymbol) isSymbol ifFalse:[
- className := aClassOrSymbol name
+ coll size = 0 ifTrue:[
+ s nextPutLine:'#()'.
+ ] ifFalse:[
+ s nextPutLine:'#( \'.
+ coll do:[:aClassOrSymbol | |className|
+
+ (className := aClassOrSymbol) isSymbol ifFalse:[
+ className := aClassOrSymbol name
+ ].
+ s tab. s nextPutAll:(className storeString); nextPutLine:' \'.
].
- s tab. s nextPutAll:(className storeString); nextPutLine:' \'.
+ s nextPutLine:')'.
].
- s nextPutLine:')'.
-
- s cr; nextPutLine:';'; nextPutLine:'; classes:'; nextPutLine:';'.
- s nextPutLine:'; (for each class, one line of the form: ( #''className'' [fileName [condition]] )'.
- s nextPutLine:'; (where fileName and condition are optional)'.
- s nextPutLine:';'.
+
+ s nextPutAll:'
+;
+; classes:
+; (for each class, one line of the form: ( #''className'' [condition [fileName]] )
+; (where fileName and condition are optional)
+;
+'.
+
+ s nextPutAll:'classes'; tab.
coll := self classInfo.
- s nextPutAll:'classes'; tab; nextPutLine:'#( \'.
- "/ find the longest className (for layout only)
-
- maxLen := coll inject:0 into:[:maxSoFar :aClassInfo |
- |clsName|
-
- clsName := aClassInfo className.
- maxSoFar max:clsName storeString size
- ].
-
- coll do:[:aClassInfo |
- |clsName fileName cond|
-
- clsName := aClassInfo className.
- fileName := aClassInfo classFileName.
- fileName isNil ifTrue:[
- fileName := clsName , '.st'
+ coll size = 0 ifTrue:[
+ s nextPutLine:'#()'.
+ ] ifFalse:[
+ s nextPutLine:'#( \'.
+ "/ find the longest className (for layout only)
+
+ maxLen := coll inject:0 into:[:maxSoFar :aClassInfo |
+ |clsName|
+
+ clsName := aClassInfo className.
+ maxSoFar max:clsName storeString size
+ ].
+
+ coll do:[:aClassInfo |
+ |clsName fileName cond|
+
+ clsName := aClassInfo className.
+ fileName := aClassInfo classFileName.
+ fileName = (clsName , '.st') ifTrue:[
+ fileName := nil
+ ].
+ cond := (aClassInfo conditionForInclusion) ? #always.
+ s tab. s nextPutAll:'( ';
+ nextPutAll:(clsName storeString paddedTo:maxLen).
+ (cond ~~ #always or:[fileName notNil]) ifTrue:[
+ s tab; nextPutAll:cond storeString.
+ ].
+ fileName notNil ifTrue:[
+ s tab; nextPutAll:fileName storeString.
+ ].
+ s nextPutLine:') \'.
].
- cond := aClassInfo conditionForInclusion.
- s tab. s nextPutAll:'( ';
- nextPutAll:(clsName storeString paddedTo:maxLen);
- tab; nextPutAll:fileName storeString.
- cond == #always ifFalse:[
- s tab; nextPutAll:cond storeString.
- ].
- s nextPutLine:') \'.
+ s nextPutLine:')'.
].
- s nextPutLine:')'.
-
- s cr; nextPutLine:';'; nextPutLine:'; files (for deployment):'; nextPutLine:';'.
-"/
-"/ already in properties
-"/
-"/ s nextPutAll:'installDirectoryUnix'; tab.
-"/ s nextPutLine:self installDirectoryUnix.
-"/ s nextPutAll:'installDirectoryWin32'; tab.
-"/ s nextPutLine:self installDirectoryWin32.
-"/ s nextPutAll:'installDirectoryVMS'; tab.
-"/ s nextPutLine:self installDirectoryVMS.
-"/ s nextPutAll:'installDirectoryMacOS'; tab.
-"/ s nextPutLine:self installDirectoryMacOS.
+
+ s nextPutAll:'
+;
+; methods (patches & extensions):
+; (for each method, one line of the form: ( #''className'' #''methodName'' )
+; (for metaclasses, #''name class'' is used)
+;
+'.
+
+ s nextPutAll:'methods'; tab.
+
+ coll := self methodInfo.
+ coll size = 0 ifTrue:[
+ s nextPutLine:'#()'.
+ ] ifFalse:[
+ s nextPutLine:'#( \'.
+ "/ find the longest className (for layout only)
+
+ maxLen := coll inject:0 into:[:maxSoFar :aMethodInfo |
+ |clsName|
+
+ clsName := aMethodInfo className.
+ maxSoFar max:clsName storeString size
+ ].
+
+ coll do:[:aMethodInfo |
+ |clsName mthdName fileName cond|
+
+ clsName := aMethodInfo className.
+ mthdName := aMethodInfo methodName.
+ s tab. s nextPutAll:'( ';
+ nextPutAll:(clsName storeString paddedTo:maxLen);
+ tab; nextPutAll:mthdName storeString.
+ s nextPutLine:') \'.
+ ].
+ s nextPutLine:')'.
+ ].
+
+ methodsFile := properties at:#methodsFile ifAbsent:nil.
+ methodsFile notNil ifTrue:[
+ s cr; nextPutLine:';'; nextPutLine:'; methods above are stored in:'; nextPutLine:';'.
+ s nextPutLine:';'.
+ s nextPutAll:'methodsFile'; tab; nextPutLine:'''' , methodsFile , ''''.
+ ].
+
+ s nextPutAll:'
+;
+; files (for deployment):
+;
+'.
s nextPutAll:'files'; tab.
coll := properties at:#'files' ifAbsent:#().
- s nextPutLine:'#( \'.
- coll do:[:aFileEntry |
- s tab. s nextPutAll:(aFileEntry storeString); nextPutLine:' \'.
+ coll size = 0 ifTrue:[
+ s nextPutLine:'#()'.
+ ] ifFalse:[
+ s nextPutLine:'#( \'.
+ coll do:[:aFileEntry |
+ s tab. s nextPutAll:(aFileEntry storeString); nextPutLine:' \'.
+ ].
+ s nextPutLine:')'.
].
- s nextPutLine:')'.
"
Project current saveOn:Transcript
@@ -1857,11 +1954,16 @@
type:aSymbol
"set the projects type (one of #application, #library, #smalltalk)"
- (#(application library smalltalk) includes:aSymbol) ifFalse:[
+ |sym|
+
+ (sym := aSymbol) == #classLibrary ifTrue:[
+ sym := #library
+ ].
+ (#(application library extension smalltalk) includes:sym) ifFalse:[
self warn:'invalid project type'.
^ self
].
- self propertyAt:#type put:aSymbol
+ self propertyAt:#type put:sym
!
wasLoadedFromFile
@@ -2017,7 +2119,7 @@
"return true, if all of this project-package has been loaded
into the system"
- |binaryModule|
+ |binaryModule cls|
isLoaded notNil ifTrue:[^ isLoaded].
@@ -2027,6 +2129,22 @@
^ true
].
+ "/ check for all classes ...
+ self classes do:[:aClassOrClassName |
+ aClassOrClassName isBehavior ifFalse:[
+ aClassOrClassName isSymbol ifTrue:[
+ (cls := Smalltalk at:aClassOrClassName) isNil ifTrue:[
+ ^ false
+ ].
+ cls isBehavior ifFalse:[^ false].
+ cls isLoaded ifFalse:[^ false].
+ ] ifFalse:[
+ self halt.
+ ^ false
+ ]
+ ]
+ ].
+
self halt.
"
@@ -2220,6 +2338,44 @@
"Modified: 14.2.1997 / 15:38:47 / cg"
! !
+!Project::ClassInfo methodsFor:'accessing'!
+
+classFileName
+ "return the value of the instance variable 'classFileName' (automatically generated)"
+
+ ^ classFileName!
+
+classFileName:something
+ "set the value of the instance variable 'classFileName' (automatically generated)"
+
+ classFileName := something.!
+
+className
+ "return the value of the instance variable 'className' (automatically generated)"
+
+ ^ className!
+
+className:something
+ "set the value of the instance variable 'className' (automatically generated)"
+
+ className := something.!
+
+conditionForInclusion
+ "return the value of the instance variable 'conditionForInclusion' (automatically generated)"
+
+ ^ conditionForInclusion!
+
+conditionForInclusion:something
+ "set the value of the instance variable 'conditionForInclusion' (automatically generated)"
+
+ conditionForInclusion := something.! !
+
+!Project::ClassInfo methodsFor:'printing & storing'!
+
+displayString
+ ^ 'ClassInfo: ' , className
+! !
+
!Project::MethodInfo methodsFor:'accessing'!
className
@@ -2270,47 +2426,9 @@
! !
-!Project::ClassInfo methodsFor:'accessing'!
-
-classFileName
- "return the value of the instance variable 'classFileName' (automatically generated)"
-
- ^ classFileName!
-
-classFileName:something
- "set the value of the instance variable 'classFileName' (automatically generated)"
-
- classFileName := something.!
-
-className
- "return the value of the instance variable 'className' (automatically generated)"
-
- ^ className!
-
-className:something
- "set the value of the instance variable 'className' (automatically generated)"
-
- className := something.!
-
-conditionForInclusion
- "return the value of the instance variable 'conditionForInclusion' (automatically generated)"
-
- ^ conditionForInclusion!
-
-conditionForInclusion:something
- "set the value of the instance variable 'conditionForInclusion' (automatically generated)"
-
- conditionForInclusion := something.! !
-
-!Project::ClassInfo methodsFor:'printing & storing'!
-
-displayString
- ^ 'ClassInfo: ' , className
-! !
-
!Project class methodsFor:'documentation'!
version
- ^ '$Header: /cvs/stx/stx/libbasic/Project.st,v 1.95 1999-09-17 16:58:48 cg Exp $'
+ ^ '$Header: /cvs/stx/stx/libbasic/Project.st,v 1.96 1999-09-20 06:58:11 cg Exp $'
! !
Project initialize!