author | Claus Gittinger <cg@exept.de> |
Mon, 12 Oct 2009 19:17:14 +0200 | |
changeset 12212 | 0333af779522 |
parent 12199 | 54519c32fa75 |
child 12329 | add6c9d0452c |
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 |
" |
|
10230 | 12 |
"{ Package: 'stx:libbasic' }" |
9571 | 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 |
||
12212 | 70 |
!PackageId class methodsFor:'defaults'! |
71 |
||
72 |
noProjectID |
|
73 |
"return the symbol used to tag classes and methods which are loose. |
|
74 |
This means: not yet assigned to a particular project." |
|
75 |
||
76 |
^ #'__NoProject__'. |
|
77 |
! ! |
|
78 |
||
9571 | 79 |
!PackageId methodsFor:'accessing'! |
80 |
||
9840 | 81 |
module:moduleString directory:directoryString |
82 |
packageIdString := moduleString,':',directoryString. |
|
83 |
||
84 |
"Created: / 12-09-2006 / 15:26:48 / cg" |
|
85 |
! |
|
86 |
||
9571 | 87 |
packageIdString:something |
88 |
packageIdString := something. |
|
89 |
||
90 |
"Created: / 18-08-2006 / 12:14:45 / cg" |
|
91 |
! |
|
92 |
||
93 |
string |
|
94 |
^ packageIdString |
|
95 |
||
96 |
"Created: / 18-08-2006 / 12:20:54 / cg" |
|
97 |
! ! |
|
98 |
||
99 |
!PackageId methodsFor:'comparing'! |
|
100 |
||
101 |
= aPackageId |
|
9841 | 102 |
"compares equal to a corresponding string" |
103 |
||
9571 | 104 |
^ packageIdString = aPackageId asPackageId string |
105 |
||
106 |
" |
|
9841 | 107 |
'stx:libbasic' asPackageId = 'stx:libbasic' |
9571 | 108 |
'stx:libbasic' asPackageId = 'stx:libbasic' asSymbol asPackageId |
109 |
'stx:libbasic' asPackageId = 'stx:libbasic' asPackageId |
|
110 |
'stx:libbasic2' asPackageId = 'stx:libbasic3' asPackageId |
|
111 |
" |
|
112 |
||
113 |
"Created: / 18-08-2006 / 12:20:47 / cg" |
|
9841 | 114 |
"Modified: / 12-09-2006 / 15:33:00 / cg" |
9571 | 115 |
! |
116 |
||
117 |
hash |
|
118 |
^ packageIdString hash |
|
119 |
||
120 |
"Created: / 18-08-2006 / 12:21:19 / cg" |
|
121 |
! ! |
|
122 |
||
123 |
!PackageId methodsFor:'converting'! |
|
124 |
||
125 |
asPackageId |
|
126 |
^ self |
|
127 |
||
128 |
"Created: / 18-08-2006 / 12:22:10 / cg" |
|
129 |
! |
|
130 |
||
131 |
asString |
|
12185 | 132 |
^ packageIdString asString |
9571 | 133 |
|
134 |
"Created: / 18-08-2006 / 12:12:22 / cg" |
|
135 |
! |
|
136 |
||
137 |
asSymbol |
|
138 |
^ packageIdString asSymbol |
|
139 |
||
140 |
"Created: / 18-08-2006 / 12:12:29 / cg" |
|
141 |
! ! |
|
142 |
||
10075 | 143 |
!PackageId methodsFor:'printing'! |
144 |
||
145 |
printOn:aStream |
|
146 |
aStream |
|
147 |
nextPutAll:'PackageId('; nextPutAll:packageIdString; nextPutAll:')' |
|
148 |
||
149 |
"Created: / 12-10-2006 / 10:30:10 / cg" |
|
150 |
! ! |
|
151 |
||
9577 | 152 |
!PackageId methodsFor:'queries'! |
153 |
||
154 |
directory |
|
155 |
"return the directory component. Thats the rest after the colon. |
|
156 |
The module is typically used to define the project-path or project-id within its |
|
157 |
sourcecode repository (which is selected via the module)." |
|
158 |
||
10208
8248266e5c0d
report erro, when asking NoProject for directory/module
Claus Gittinger <cg@exept.de>
parents:
10190
diff
changeset
|
159 |
|idx| |
8248266e5c0d
report erro, when asking NoProject for directory/module
Claus Gittinger <cg@exept.de>
parents:
10190
diff
changeset
|
160 |
|
8248266e5c0d
report erro, when asking NoProject for directory/module
Claus Gittinger <cg@exept.de>
parents:
10190
diff
changeset
|
161 |
idx := packageIdString indexOf:$:. |
8248266e5c0d
report erro, when asking NoProject for directory/module
Claus Gittinger <cg@exept.de>
parents:
10190
diff
changeset
|
162 |
idx == 0 ifTrue:[ |
11405
c9d1023b1e4e
Return empty string for package without directory
Stefan Vogel <sv@exept.de>
parents:
10284
diff
changeset
|
163 |
^ ''. |
10208
8248266e5c0d
report erro, when asking NoProject for directory/module
Claus Gittinger <cg@exept.de>
parents:
10190
diff
changeset
|
164 |
]. |
8248266e5c0d
report erro, when asking NoProject for directory/module
Claus Gittinger <cg@exept.de>
parents:
10190
diff
changeset
|
165 |
^ packageIdString copyFrom:idx+1 |
9577 | 166 |
|
167 |
" |
|
168 |
(PackageId from:'stx:libbasic') module |
|
169 |
(PackageId from:'stx:libbasic') directory |
|
11405
c9d1023b1e4e
Return empty string for package without directory
Stefan Vogel <sv@exept.de>
parents:
10284
diff
changeset
|
170 |
(PackageId from:'stx') module |
c9d1023b1e4e
Return empty string for package without directory
Stefan Vogel <sv@exept.de>
parents:
10284
diff
changeset
|
171 |
(PackageId from:'stx') directory |
9577 | 172 |
(PackageId from:'stx:goodies/xml/stx') module |
173 |
(PackageId from:'stx:goodies/xml/stx') directory |
|
174 |
" |
|
175 |
||
176 |
"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
|
177 |
"Modified: / 28-11-2006 / 11:39:14 / cg" |
9577 | 178 |
! |
179 |
||
180 |
libraryName |
|
181 |
"return the name of the library, when compiled to a binary (i.e. dll/so). |
|
182 |
To avoid conflicts with the projectDefinition class |
|
183 |
(which is named <module>_<directory_components>), we prefix the library name |
|
184 |
with 'lib'. This has the added advantage, that under unix, linking can be done with |
|
185 |
'-l'shortName." |
|
186 |
||
187 |
^ 'lib' , (packageIdString copy asString replaceAny:':/' with:$_) |
|
188 |
||
189 |
" |
|
190 |
(PackageId from:'stx:libbasic') libraryName |
|
191 |
(PackageId from:'stx:goodies/xml/stx') libraryName |
|
192 |
(PackageId from:'bosch:dapasx') libraryName |
|
193 |
(PackageId from:'exept:expecco') libraryName |
|
194 |
" |
|
195 |
||
196 |
"Created: / 18-08-2006 / 12:35:04 / cg" |
|
197 |
! |
|
198 |
||
199 |
module |
|
200 |
"return the module component. Thats the first component up to the colon. |
|
201 |
The module is typically used to select a corresponding sourcecode repository." |
|
202 |
||
10208
8248266e5c0d
report erro, when asking NoProject for directory/module
Claus Gittinger <cg@exept.de>
parents:
10190
diff
changeset
|
203 |
|idx| |
8248266e5c0d
report erro, when asking NoProject for directory/module
Claus Gittinger <cg@exept.de>
parents:
10190
diff
changeset
|
204 |
|
8248266e5c0d
report erro, when asking NoProject for directory/module
Claus Gittinger <cg@exept.de>
parents:
10190
diff
changeset
|
205 |
idx := packageIdString indexOf:$:. |
8248266e5c0d
report erro, when asking NoProject for directory/module
Claus Gittinger <cg@exept.de>
parents:
10190
diff
changeset
|
206 |
idx == 0 ifTrue:[ |
10284 | 207 |
^ packageIdString. |
10208
8248266e5c0d
report erro, when asking NoProject for directory/module
Claus Gittinger <cg@exept.de>
parents:
10190
diff
changeset
|
208 |
]. |
8248266e5c0d
report erro, when asking NoProject for directory/module
Claus Gittinger <cg@exept.de>
parents:
10190
diff
changeset
|
209 |
^ packageIdString copyTo:idx-1 |
9577 | 210 |
|
211 |
" |
|
212 |
(PackageId from:'stx:libbasic') module |
|
213 |
(PackageId from:'stx:libbasic') directory |
|
214 |
" |
|
215 |
||
216 |
"Created: / 18-08-2006 / 12:13:53 / cg" |
|
10284 | 217 |
"Modified: / 27-12-2006 / 11:51:25 / cg" |
9668 | 218 |
! |
219 |
||
220 |
parentPackage |
|
221 |
|dir idx| |
|
222 |
||
223 |
dir := self directory. |
|
10211
6516bfb2ae56
changed #parentPackage - handle nil
Stefan Vogel <sv@exept.de>
parents:
10208
diff
changeset
|
224 |
dir isNil ifTrue:[ |
6516bfb2ae56
changed #parentPackage - handle nil
Stefan Vogel <sv@exept.de>
parents:
10208
diff
changeset
|
225 |
^ nil. |
6516bfb2ae56
changed #parentPackage - handle nil
Stefan Vogel <sv@exept.de>
parents:
10208
diff
changeset
|
226 |
]. |
9668 | 227 |
idx := dir lastIndexOf:$/. |
228 |
idx == 0 ifTrue:[ |
|
229 |
^ nil |
|
230 |
]. |
|
231 |
^ self class from:(self module , ':' , (dir copyTo:idx-1)) |
|
232 |
||
233 |
" |
|
234 |
(PackageId from:'stx:libbasic') parentPackage |
|
235 |
(PackageId from:'stx:goodies/xml/stx') parentPackage |
|
236 |
(PackageId from:'stx:goodies/xml/stx') parentPackage parentPackage |
|
237 |
" |
|
238 |
||
239 |
"Created: / 23-08-2006 / 15:10:13 / cg" |
|
12185 | 240 |
! |
241 |
||
242 |
pathRelativeToTopDirectory |
|
243 |
^ (self module asFilename construct:(self directory)) pathName. |
|
244 |
||
245 |
" |
|
246 |
'stx:libbasic' asPackageId pathRelativeToTopDirectory |
|
247 |
'stx:goodies/net/ssl' asPackageId pathRelativeToTopDirectory |
|
248 |
" |
|
249 |
! |
|
250 |
||
251 |
pathRelativeToTopDirectory:aDirectory |
|
252 |
^ aDirectory asFilename construct:(self pathRelativeToTopDirectory) |
|
253 |
||
254 |
" |
|
255 |
|top| |
|
256 |
||
257 |
top := Smalltalk packagePath first. |
|
258 |
'stx:goodies/net/ssl' asPackageId pathRelativeToTopDirectory:top |
|
259 |
" |
|
12199 | 260 |
! |
261 |
||
262 |
projectDefinitionClass |
|
263 |
^ ProjectDefinition definitionClassForPackage:self |
|
264 |
||
265 |
" |
|
266 |
'stx:libbasic' asPackageId projectDefinitionClass |
|
267 |
" |
|
9577 | 268 |
! ! |
269 |
||
9571 | 270 |
!PackageId class methodsFor:'documentation'! |
271 |
||
272 |
version |
|
12212 | 273 |
^ '$Header: /cvs/stx/stx/libbasic/PackageId.st,v 1.15 2009-10-12 17:17:14 cg Exp $' |
12185 | 274 |
! |
275 |
||
276 |
version_CVS |
|
12212 | 277 |
^ '$Header: /cvs/stx/stx/libbasic/PackageId.st,v 1.15 2009-10-12 17:17:14 cg Exp $' |
9571 | 278 |
! ! |