author | Claus Gittinger <cg@exept.de> |
Tue, 28 Nov 2006 15:46:37 +0100 | |
changeset 10208 | 8248266e5c0d |
parent 10190 | 806d4a4369d7 |
child 10211 | 6516bfb2ae56 |
permissions | -rw-r--r-- |
9571 | 1 |
" |
2 |
COPYRIGHT (c) 2006 by eXept Software AG |
|
3 |
All Rights Reserved |
|
4 |
||
5 |
This software is furnished under a license and may be used |
|
6 |
only in accordance with the terms of that license and with the |
|
7 |
inclusion of the above copyright notice. This software may not |
|
8 |
be provided or otherwise made available to, or used by, any |
|
9 |
other person. No title to or ownership of the software is |
|
10 |
hereby transferred. |
|
11 |
" |
|
12 |
"{ Package: 'stx:libbasic3' }" |
|
13 |
||
14 |
Object subclass:#PackageId |
|
15 |
instanceVariableNames:'packageIdString' |
|
16 |
classVariableNames:'' |
|
17 |
poolDictionaries:'' |
|
18 |
category:'System-Support-Projects' |
|
19 |
! |
|
20 |
||
21 |
!PackageId class methodsFor:'documentation'! |
|
22 |
||
23 |
copyright |
|
24 |
" |
|
25 |
COPYRIGHT (c) 2006 by eXept Software AG |
|
26 |
All Rights Reserved |
|
27 |
||
28 |
This software is furnished under a license and may be used |
|
29 |
only in accordance with the terms of that license and with the |
|
30 |
inclusion of the above copyright notice. This software may not |
|
31 |
be provided or otherwise made available to, or used by, any |
|
32 |
other person. No title to or ownership of the software is |
|
33 |
hereby transferred. |
|
34 |
" |
|
35 |
! |
|
36 |
||
37 |
documentation |
|
38 |
" |
|
39 |
Represents packageID's. |
|
40 |
Knows the relationship between modules and directories in the package-organization. |
|
41 |
" |
|
42 |
! ! |
|
43 |
||
44 |
!PackageId class methodsFor:'instance creation'! |
|
45 |
||
46 |
from: aStringOrSymbol |
|
47 |
^ self new packageIdString:aStringOrSymbol |
|
48 |
||
9840 | 49 |
" |
50 |
(self from:'stx:libbasic') module |
|
51 |
(self from:'stx:libbasic') directory |
|
52 |
" |
|
53 |
||
9571 | 54 |
"Created: / 18-08-2006 / 12:11:58 / cg" |
9840 | 55 |
"Modified: / 12-09-2006 / 15:27:42 / cg" |
56 |
! |
|
57 |
||
58 |
module:moduleString directory:directoryString |
|
59 |
^ self new module:moduleString directory:directoryString |
|
60 |
||
61 |
" |
|
10190 | 62 |
(PackageId module:'stx' directory:'libbasic') module |
63 |
(PackageId module:'stx' directory:'libbasic') directory |
|
9840 | 64 |
" |
65 |
||
66 |
"Created: / 12-09-2006 / 15:26:24 / cg" |
|
10190 | 67 |
"Modified: / 18-11-2006 / 17:09:12 / cg" |
9571 | 68 |
! ! |
69 |
||
70 |
!PackageId methodsFor:'accessing'! |
|
71 |
||
9840 | 72 |
module:moduleString directory:directoryString |
73 |
packageIdString := moduleString,':',directoryString. |
|
74 |
||
75 |
"Created: / 12-09-2006 / 15:26:48 / cg" |
|
76 |
! |
|
77 |
||
9571 | 78 |
packageIdString:something |
79 |
packageIdString := something. |
|
80 |
||
81 |
"Created: / 18-08-2006 / 12:14:45 / cg" |
|
82 |
! |
|
83 |
||
84 |
string |
|
85 |
^ packageIdString |
|
86 |
||
87 |
"Created: / 18-08-2006 / 12:20:54 / cg" |
|
88 |
! ! |
|
89 |
||
90 |
!PackageId methodsFor:'comparing'! |
|
91 |
||
92 |
= aPackageId |
|
9841 | 93 |
"compares equal to a corresponding string" |
94 |
||
9571 | 95 |
^ packageIdString = aPackageId asPackageId string |
96 |
||
97 |
" |
|
9841 | 98 |
'stx:libbasic' asPackageId = 'stx:libbasic' |
9571 | 99 |
'stx:libbasic' asPackageId = 'stx:libbasic' asSymbol asPackageId |
100 |
'stx:libbasic' asPackageId = 'stx:libbasic' asPackageId |
|
101 |
'stx:libbasic2' asPackageId = 'stx:libbasic3' asPackageId |
|
102 |
" |
|
103 |
||
104 |
"Created: / 18-08-2006 / 12:20:47 / cg" |
|
9841 | 105 |
"Modified: / 12-09-2006 / 15:33:00 / cg" |
9571 | 106 |
! |
107 |
||
108 |
hash |
|
109 |
^ packageIdString hash |
|
110 |
||
111 |
"Created: / 18-08-2006 / 12:21:19 / cg" |
|
112 |
! ! |
|
113 |
||
114 |
!PackageId methodsFor:'converting'! |
|
115 |
||
116 |
asPackageId |
|
117 |
^ self |
|
118 |
||
119 |
"Created: / 18-08-2006 / 12:22:10 / cg" |
|
120 |
! |
|
121 |
||
122 |
asString |
|
123 |
^ packageIdString |
|
124 |
||
125 |
"Created: / 18-08-2006 / 12:12:22 / cg" |
|
126 |
! |
|
127 |
||
128 |
asSymbol |
|
129 |
^ packageIdString asSymbol |
|
130 |
||
131 |
"Created: / 18-08-2006 / 12:12:29 / cg" |
|
132 |
! ! |
|
133 |
||
10075 | 134 |
!PackageId methodsFor:'printing'! |
135 |
||
136 |
printOn:aStream |
|
137 |
aStream |
|
138 |
nextPutAll:'PackageId('; nextPutAll:packageIdString; nextPutAll:')' |
|
139 |
||
140 |
"Created: / 12-10-2006 / 10:30:10 / cg" |
|
141 |
! ! |
|
142 |
||
9577 | 143 |
!PackageId methodsFor:'queries'! |
144 |
||
145 |
directory |
|
146 |
"return the directory component. Thats the rest after the colon. |
|
147 |
The module is typically used to define the project-path or project-id within its |
|
148 |
sourcecode repository (which is selected via the module)." |
|
149 |
||
10208
8248266e5c0d
report erro, when asking NoProject for directory/module
Claus Gittinger <cg@exept.de>
parents:
10190
diff
changeset
|
150 |
|idx| |
8248266e5c0d
report erro, when asking NoProject for directory/module
Claus Gittinger <cg@exept.de>
parents:
10190
diff
changeset
|
151 |
|
8248266e5c0d
report erro, when asking NoProject for directory/module
Claus Gittinger <cg@exept.de>
parents:
10190
diff
changeset
|
152 |
idx := packageIdString indexOf:$:. |
8248266e5c0d
report erro, when asking NoProject for directory/module
Claus Gittinger <cg@exept.de>
parents:
10190
diff
changeset
|
153 |
idx == 0 ifTrue:[ |
8248266e5c0d
report erro, when asking NoProject for directory/module
Claus Gittinger <cg@exept.de>
parents:
10190
diff
changeset
|
154 |
self error:'NoProject asked for its directory' mayProceed:true. |
8248266e5c0d
report erro, when asking NoProject for directory/module
Claus Gittinger <cg@exept.de>
parents:
10190
diff
changeset
|
155 |
^ nil. |
8248266e5c0d
report erro, when asking NoProject for directory/module
Claus Gittinger <cg@exept.de>
parents:
10190
diff
changeset
|
156 |
]. |
8248266e5c0d
report erro, when asking NoProject for directory/module
Claus Gittinger <cg@exept.de>
parents:
10190
diff
changeset
|
157 |
^ packageIdString copyFrom:idx+1 |
9577 | 158 |
|
159 |
" |
|
160 |
(PackageId from:'stx:libbasic') module |
|
161 |
(PackageId from:'stx:libbasic') directory |
|
162 |
(PackageId from:'stx:goodies/xml/stx') module |
|
163 |
(PackageId from:'stx:goodies/xml/stx') directory |
|
164 |
" |
|
165 |
||
166 |
"Created: / 18-08-2006 / 12:15:33 / cg" |
|
10208
8248266e5c0d
report erro, when asking NoProject for directory/module
Claus Gittinger <cg@exept.de>
parents:
10190
diff
changeset
|
167 |
"Modified: / 28-11-2006 / 11:39:14 / cg" |
9577 | 168 |
! |
169 |
||
170 |
libraryName |
|
171 |
"return the name of the library, when compiled to a binary (i.e. dll/so). |
|
172 |
To avoid conflicts with the projectDefinition class |
|
173 |
(which is named <module>_<directory_components>), we prefix the library name |
|
174 |
with 'lib'. This has the added advantage, that under unix, linking can be done with |
|
175 |
'-l'shortName." |
|
176 |
||
177 |
^ 'lib' , (packageIdString copy asString replaceAny:':/' with:$_) |
|
178 |
||
179 |
" |
|
180 |
(PackageId from:'stx:libbasic') libraryName |
|
181 |
(PackageId from:'stx:goodies/xml/stx') libraryName |
|
182 |
(PackageId from:'bosch:dapasx') libraryName |
|
183 |
(PackageId from:'exept:expecco') libraryName |
|
184 |
" |
|
185 |
||
186 |
"Created: / 18-08-2006 / 12:35:04 / cg" |
|
187 |
! |
|
188 |
||
189 |
module |
|
190 |
"return the module component. Thats the first component up to the colon. |
|
191 |
The module is typically used to select a corresponding sourcecode repository." |
|
192 |
||
10208
8248266e5c0d
report erro, when asking NoProject for directory/module
Claus Gittinger <cg@exept.de>
parents:
10190
diff
changeset
|
193 |
|idx| |
8248266e5c0d
report erro, when asking NoProject for directory/module
Claus Gittinger <cg@exept.de>
parents:
10190
diff
changeset
|
194 |
|
8248266e5c0d
report erro, when asking NoProject for directory/module
Claus Gittinger <cg@exept.de>
parents:
10190
diff
changeset
|
195 |
idx := packageIdString indexOf:$:. |
8248266e5c0d
report erro, when asking NoProject for directory/module
Claus Gittinger <cg@exept.de>
parents:
10190
diff
changeset
|
196 |
idx == 0 ifTrue:[ |
8248266e5c0d
report erro, when asking NoProject for directory/module
Claus Gittinger <cg@exept.de>
parents:
10190
diff
changeset
|
197 |
self error:'NoProject asked for its module' mayProceed:true. |
8248266e5c0d
report erro, when asking NoProject for directory/module
Claus Gittinger <cg@exept.de>
parents:
10190
diff
changeset
|
198 |
^ nil. |
8248266e5c0d
report erro, when asking NoProject for directory/module
Claus Gittinger <cg@exept.de>
parents:
10190
diff
changeset
|
199 |
]. |
8248266e5c0d
report erro, when asking NoProject for directory/module
Claus Gittinger <cg@exept.de>
parents:
10190
diff
changeset
|
200 |
^ packageIdString copyTo:idx-1 |
9577 | 201 |
|
202 |
" |
|
203 |
(PackageId from:'stx:libbasic') module |
|
204 |
(PackageId from:'stx:libbasic') directory |
|
205 |
" |
|
206 |
||
207 |
"Created: / 18-08-2006 / 12:13:53 / cg" |
|
10208
8248266e5c0d
report erro, when asking NoProject for directory/module
Claus Gittinger <cg@exept.de>
parents:
10190
diff
changeset
|
208 |
"Modified: / 28-11-2006 / 11:38:53 / cg" |
9668 | 209 |
! |
210 |
||
211 |
parentPackage |
|
212 |
|dir idx| |
|
213 |
||
214 |
dir := self directory. |
|
215 |
idx := dir lastIndexOf:$/. |
|
216 |
idx == 0 ifTrue:[ |
|
217 |
^ nil |
|
218 |
]. |
|
219 |
^ self class from:(self module , ':' , (dir copyTo:idx-1)) |
|
220 |
||
221 |
" |
|
222 |
(PackageId from:'stx:libbasic') parentPackage |
|
223 |
(PackageId from:'stx:goodies/xml/stx') parentPackage |
|
224 |
(PackageId from:'stx:goodies/xml/stx') parentPackage parentPackage |
|
225 |
" |
|
226 |
||
227 |
"Created: / 23-08-2006 / 15:10:13 / cg" |
|
9577 | 228 |
! ! |
229 |
||
9571 | 230 |
!PackageId class methodsFor:'documentation'! |
231 |
||
232 |
version |
|
10208
8248266e5c0d
report erro, when asking NoProject for directory/module
Claus Gittinger <cg@exept.de>
parents:
10190
diff
changeset
|
233 |
^ '$Header: /cvs/stx/stx/libbasic/PackageId.st,v 1.8 2006-11-28 14:46:37 cg Exp $' |
9571 | 234 |
! ! |