code cleanup
authorClaus Gittinger <cg@exept.de>
Thu, 17 Aug 2006 16:11:34 +0200
changeset 9559 06e8b0498471
parent 9558 510ca1ebce30
child 9560 555afa00a3c1
code cleanup
ProjectDefinition.st
--- a/ProjectDefinition.st	Thu Aug 17 16:11:00 2006 +0200
+++ b/ProjectDefinition.st	Thu Aug 17 16:11:34 2006 +0200
@@ -13,10 +13,10 @@
 "{ Package: 'stx:libbasic3' }"
 
 Object subclass:#BuildDefinition
-	instanceVariableNames:''
-	classVariableNames:''
-	poolDictionaries:''
-	category:'System-Support-Projects'
+        instanceVariableNames:''
+        classVariableNames:''
+        poolDictionaries:''
+        category:'System-Support-Projects'
 !
 
 !BuildDefinition class methodsFor:'documentation'!
@@ -35,6 +35,38 @@
 "
 ! !
 
+!BuildDefinition class methodsFor:'instance creation'!
+
+newForPackage:packageID
+    ^ self 
+        newNamed:(self initialClassNameForDefinitionOf:packageID) 
+        package:packageID.
+
+    "Created: / 11-08-2006 / 14:27:19 / cg"
+!
+
+newNamed:newName package:packageID
+    |newClass|
+
+    "/ for now, we are strict.
+    self assert:(self initialClassNameForDefinitionOf:packageID) = newName.
+    self assert:(self ~~ BuildDefinition).  "BuildDefinition is abstract"
+
+    newClass := self
+                    subclass:(newName asSymbol)
+                    instanceVariableNames:''
+                    classVariableNames:''
+                    poolDictionaries:''
+                    category:(self defaultCategory).
+
+    newClass package:packageID asSymbol.
+    ^ newClass
+
+    "Created: / 09-08-2006 / 17:57:37 / fm"
+    "Modified: / 09-08-2006 / 19:27:53 / fm"
+    "Modified: / 17-08-2006 / 14:35:02 / cg"
+! !
+
 !BuildDefinition class methodsFor:'accessing'!
 
 defaultCategory
@@ -63,138 +95,152 @@
 !
 
 libraryName
-       ^ self libraryNameFor: self package
+    ^ self libraryNameFor:self package
 
-"
-   bosch_dapasx_datenbasis_Definition libraryName   
-"
+    "
+       bosch_dapasx_datenbasis_Definition libraryName
+    "
 
     "Modified: / 09-08-2006 / 18:20:29 / fm"
+    "Modified: / 17-08-2006 / 14:13:14 / cg"
 !
 
-libraryNameFor: aProjectID
-       ^ aProjectID asString copy replaceAny:':/' with:$_
+libraryNameFor:aProjectID 
+    ^ aProjectID asString copy replaceAny:':/' with:$_
 
-"
-   bosch_dapasx_datenbasis libraryName   
-"
+    "
+       bosch_dapasx_datenbasis libraryName
+    "
 
     "Modified: / 09-08-2006 / 18:20:29 / fm"
-    "Modified: / 11-08-2006 / 14:02:06 / cg"
+    "Modified: / 17-08-2006 / 14:13:21 / cg"
 !
 
 module
-
-^self moduleOfClass: self
+    ^ self moduleOfClass:self
 
-"
-   bosch_dapasx_datenbasis_Definition module
-   DapasX_Datenbasis module
-"
+    "
+       bosch_dapasx_datenbasis_Definition module
+       DapasX_Datenbasis module
+    "
 
     "Created: / 08-08-2006 / 20:24:53 / fm"
     "Modified: / 09-08-2006 / 16:16:37 / fm"
+    "Modified: / 17-08-2006 / 14:13:28 / cg"
 !
 
 moduleDirectory
-
-^self moduleDirectoryFor: self package 
+    ^ self moduleDirectoryFor:self package
 
-"
-    bosch_dapasx_datenbasis_Definition moduleDirectory    
-    bosch_dapasx_parameter_system_Definition moduleDirectory
-"
+    "
+        bosch_dapasx_datenbasis_Definition moduleDirectory
+        bosch_dapasx_parameter_system_Definition moduleDirectory
+    "
 
     "Created: / 08-08-2006 / 20:25:39 / fm"
+    "Modified: / 17-08-2006 / 14:13:36 / cg"
 !
 
-moduleDirectoryFor: aProjectID
-
-^(aProjectID subStrings: $:) last
+moduleDirectoryFor:aProjectID 
+    ^ (aProjectID subStrings:$:) last
 
-"
-    bosch_dapasx_datenbasis_Definition moduleDirectory    
-    bosch_dapasx_parameter_system_Definition moduleDirectory
-"
+    "
+        bosch_dapasx_datenbasis_Definition moduleDirectory
+        bosch_dapasx_parameter_system_Definition moduleDirectory
+    "
 
     "Created: / 08-08-2006 / 20:25:39 / fm"
+    "Modified: / 17-08-2006 / 14:13:41 / cg"
 !
 
-moduleFor: aProjectID
-
-^(aProjectID subStrings: $:) first
+moduleFor:aProjectID 
+    ^ (aProjectID subStrings:$:) first
 
-"
-   DapasXProject module
-   DapasX_Datenbasis module
-"
+    "
+       DapasXProject module
+       DapasX_Datenbasis module
+    "
 
     "Created: / 09-08-2006 / 16:16:16 / fm"
+    "Modified: / 17-08-2006 / 14:13:46 / cg"
 !
 
-moduleOfClass: aClass
-
-^self moduleFor: aClass package 
+moduleOfClass:aClass 
+    ^ self moduleFor:aClass package
 
-"
-   DapasXProject module
-   DapasX_Datenbasis module
-"
+    "
+       DapasXProject module
+       DapasX_Datenbasis module
+    "
 
     "Created: / 09-08-2006 / 16:16:16 / fm"
+    "Modified: / 17-08-2006 / 14:13:51 / cg"
 !
 
-msdosPathToPackage:aPackageID
-"Returns the path to stx counting the number of $/ and $: in the package name and adding for each one '../' to get the ST/X top directory"
+msdosPathToPackage:aPackageID 
+    "Returns the path to the package defined by aPackageID relative to my path"
+    
+    ^ self msdosPathToTop , '\..\' , (self msdosTopRelativePathToPackage:aPackageID)
 
-        ^ self msdosPathToTop , '\..\' , (aPackageID asString copy replaceAny:':/' with:$\)
-
-"
-  self msdosPathToPackage:'bosch:dapasx/kernel'
-"
+    "
+     self msdosPathToPackage:'bosch:dapasx/kernel'
+    "
 
     "Created: / 09-08-2006 / 16:35:22 / fm"
-    "Modified: / 16-08-2006 / 18:39:37 / User"
+    "Modified: / 17-08-2006 / 14:21:53 / cg"
 !
 
-msdosPathToProjectFor: aProjectID
-
-       ^ aProjectID asString copy replaceAny:':/' with:$\
+msdosPathToPackage:toPackageID from:fromPackageID
+    "Returns the path to the package defined by aPackageID relative to my path"
+    
+    ^ (self msdosPathToTopFor:fromPackageID) , '\..\' , (self msdosTopRelativePathToPackage:toPackageID)
 
-"
-   self msdosPathToProjectFor: #'bosch:dapasx/datenbasis'   
-"
+    "
+     self msdosPathToPackage:'bosch:dapasx/kernel' from:'bosch:dapasx/application'
+    "
 
-    "Modified: / 09-08-2006 / 18:20:29 / fm"
+    "Created: / 17-08-2006 / 14:26:39 / cg"
 !
 
 msdosPathToTop
-"Returns the path to stx counting the number of $/ and $: in the package name and adding for each one '../' to get the ST/X top directory"
+    "Returns the path to stx counting the number of $/ and $: in the package name and adding for each one '../' to get the ST/X top directory"
 
-
-       ^self msdosPathToTopFor: self package 
+    ^self msdosPathToTopFor: self package 
 
-"
-   bosch_dapasx_datenbasis_Definition msdosPathToTop    
-   DapasX_Datenbasis pathToTop  
-"
+    "
+     bosch_dapasx_datenbasis_Definition msdosPathToTop    
+     DapasX_Datenbasis pathToTop  
+    "
 
     "Created: / 09-08-2006 / 15:45:54 / fm"
+    "Modified: / 17-08-2006 / 14:25:28 / cg"
 !
 
 msdosPathToTopFor: aProjectID
-"Returns the path to stx counting the number of $/ and $: in the package name and adding for each one '../' to get the ST/X top directory"
+    "Returns the path to stx counting the number of $/ and $: in the package name and adding for each one '../' to get the ST/X top directory"
 
-
-       ^ (((1 to:(aProjectID asCollectionOfSubstringsSeparatedByAny:':/') size)
+    ^ (((1 to:(aProjectID asCollectionOfSubstringsSeparatedByAny:':/') size)
             collect:[:n | '..\']) asStringWith:'') , 'stx'    
 
-"
-   self msdosPathToTopFor: #'bosch:dapasx/datenbasis'   
-
-"
+    "
+     self msdosPathToTopFor: #'bosch:dapasx/datenbasis'   
+    "
 
     "Created: / 09-08-2006 / 15:45:54 / fm"
+    "Modified: / 17-08-2006 / 14:25:18 / cg"
+!
+
+msdosTopRelativePathToPackage:aPackageID 
+    "Returns the path to the package as specified by aPackageID relative to the top directory"
+    
+    ^ aPackageID asString copy replaceAny:':/' with:$\
+
+    "
+     self msdosTopRelativePathToPackage:'stx:goodies/xml'
+     self msdosTopRelativePathToPackage:'bosch:dapasx/kernel'
+    "
+
+    "Created: / 17-08-2006 / 14:20:44 / cg"
 !
 
 packageName
@@ -259,43 +305,59 @@
 ^self preRequisites, self subProjects
 !
 
-unixPathToPackage:aPackageID
-"Returns the path to stx counting the number of $/ and $: in the package name and adding for each one '../' to get the ST/X top directory"
+topRelativeMsdosPathToPackage:aPackageID 
+    "Returns the path to the package as specified by aPackageID relative to the top directory"
+    
+    ^ aPackageID asString copy replaceAny:':/' with:$\
+
+    "
+     self topRelativePathToPackage:'stx:goodies/xml'
+     self topRelativePathToPackage:'bosch:dapasx/kernel'
+    "
 
-        ^ self unixPathToTop , '/../' , (aPackageID asString copy replaceAll:$: with:$/)
+    "Created: / 17-08-2006 / 14:16:28 / cg"
+!
+
+unixPathToPackage:aPackageID
+    "Returns the path to stx counting the number of $/ and $: in the package name and adding for each one '../' to get the ST/X top directory"
 
-"
-   DapasX_Datenbasis pathToPackage:'bosch:dapasx/kernel'
-"
+    ^ self unixPathToTop , '/../' , (self unixTopRelativePathToPackage:aPackageID)
+
+    "
+     bosch_dapasx_kernel unixPathToPackage:'bosch:dapasx/kernel'
+    "
 
     "Created: / 09-08-2006 / 16:35:22 / fm"
     "Modified: / 16-08-2006 / 18:55:41 / User"
-!
-
-unixPathToProjectFor: aProjectID
-
-       ^ aProjectID asString copy replaceAny:':/' with:$/
-
-"
-   self unixPathToProjectFor: #'bosch:dapasx/datenbasis'   
-"
-
-    "Modified: / 09-08-2006 / 18:20:29 / fm"
+    "Modified: / 17-08-2006 / 14:20:28 / cg"
 !
 
 unixPathToTop
-"Returns the path to stx counting the number of $/ and $: in the package name and adding for each one '../' to get the ST/X top directory"
+    "Returns the path to stx counting the number of $/ and $: in the package name and adding for each one '../' to get the ST/X top directory"
 
+    ^ (((1 to:(self package asCollectionOfSubstringsSeparatedByAny:':/') size)
+        collect:[:n | '../']) asStringWith:'') , 'stx'    
 
-       ^ (((1 to:(self package asCollectionOfSubstringsSeparatedByAny:':/') size)
-            collect:[:n | '../']) asStringWith:'') , 'stx'    
-
-"
-   DapasXProject pathToTop    
-   DapasX_Datenbasis pathToTop  
-"
+    "
+     bosch_dapasx_kernel unixPathToTop        
+     stx_goodies_xml unixPathToTop  
+    "
 
     "Created: / 09-08-2006 / 15:45:54 / fm"
+    "Modified: / 17-08-2006 / 14:17:59 / cg"
+!
+
+unixTopRelativePathToPackage:aPackageID 
+    "Returns the path to the package as specified by aPackageID relative to the top directory"
+    
+    ^ aPackageID asString copy replaceAny:':/' with:$/
+
+    "
+     self unixTopRelativePathToPackage:'stx:goodies/xml'
+     self unixTopRelativePathToPackage:'bosch:dapasx/kernel'
+    "
+
+    "Created: / 17-08-2006 / 14:20:18 / cg"
 ! !
 
 !BuildDefinition class methodsFor:'defaults'!
@@ -793,12 +855,39 @@
 !BuildDefinition class methodsFor:'queries'!
 
 definitionClassForPackage: aPackageID
-    |packageDefinitionClassName|
+    ^ self definitionClassForPackage:aPackageID createIfAbsent:false
+
+    "Modified: / 17-08-2006 / 14:33:35 / cg"
+!
+
+definitionClassForPackage: aPackageID createIfAbsent: doCreateIfAbsent
+    |packageDefinitionClassName class|
 
     packageDefinitionClassName := ProjectDefinition initialClassNameForDefinitionOf:aPackageID.
-    ^ Smalltalk at:packageDefinitionClassName asSymbol.
+    class := Smalltalk classNamed:packageDefinitionClassName.
+    class isNil ifTrue:[
+        doCreateIfAbsent ifTrue:[
+            ^ self newForPackage:aPackageID    
+        ].
+    ].
+    ^ class
+
+    "Created: / 17-08-2006 / 14:33:02 / cg"
+!
 
-    "Created: / 17-08-2006 / 09:53:09 / cg"
+definitionClassForPackage:newProjectID type:type createIfAbsent:createIfAbsent
+    ^ (self definitionClassForType:type)
+        definitionClassForPackage:newProjectID createIfAbsent:createIfAbsent
+
+    "Created: / 17-08-2006 / 14:48:01 / cg"
+!
+
+definitionClassForType: type
+    (type = 'Application') ifTrue:[ ^ ApplicationDefinition ].
+    (type = 'Library') ifTrue:[ ^ ProjectDefinition ].
+    self error.
+
+    "Created: / 17-08-2006 / 14:46:28 / cg"
 !
 
 hasAllClassesLoaded
@@ -830,9 +919,10 @@
 !BuildDefinition class methodsFor:'testing'!
 
 isProjectDefinition
-    ^ self ~~ ProjectDefinition
+    ^ self ~~ BuildDefinition
 
     "Created: / 10-08-2006 / 16:24:02 / cg"
+    "Modified: / 17-08-2006 / 14:12:04 / cg"
 ! !
 
 !BuildDefinition class methodsFor:'update description'!
@@ -982,5 +1072,5 @@
 !BuildDefinition class methodsFor:'documentation'!
 
 version
-    ^ '$Header: /cvs/stx/stx/libbasic/ProjectDefinition.st,v 1.10 2006-08-17 07:55:05 cg Exp $'
+    ^ '$Header: /cvs/stx/stx/libbasic/ProjectDefinition.st,v 1.11 2006-08-17 14:11:34 cg Exp $'
 ! !