1443
|
1 |
"
|
|
2 |
COPYRIGHT (c) 2003 by eXept Software AG
|
1674
|
3 |
All Rights Reserved
|
1443
|
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 |
|
1226
|
13 |
"{ Package: 'stx:libbasic3' }"
|
|
14 |
|
|
15 |
"{ NameSpace: Packages }"
|
|
16 |
|
|
17 |
AbstractPackage subclass:#Package
|
1268
|
18 |
instanceVariableNames:'packageHandler packagedClasses packagedMethods packageComment
|
|
19 |
prerequisites scripts isDirty isInstalled packageVersion
|
|
20 |
overriddenClassChanges overriddenMethodChanges blockedMethods'
|
|
21 |
classVariableNames:''
|
|
22 |
poolDictionaries:''
|
|
23 |
category:'Package'
|
1226
|
24 |
!
|
|
25 |
|
|
26 |
Package class instanceVariableNames:'CurrentPackage'
|
|
27 |
|
|
28 |
"
|
|
29 |
No other class instance variables are inherited by this class.
|
|
30 |
"
|
|
31 |
!
|
|
32 |
|
|
33 |
Object subclass:#PackagedClass
|
1268
|
34 |
instanceVariableNames:'name package instanceDefinition classDefinition
|
|
35 |
instanceVariableNames classVariableNames
|
|
36 |
classInstanceVariableNames poolDictionaries category'
|
|
37 |
classVariableNames:''
|
|
38 |
poolDictionaries:''
|
|
39 |
privateIn:Package
|
1226
|
40 |
!
|
|
41 |
|
1277
|
42 |
Object subclass:#ClassSide
|
|
43 |
instanceVariableNames:'instanceSide'
|
|
44 |
classVariableNames:''
|
|
45 |
poolDictionaries:''
|
|
46 |
privateIn:Package::PackagedClass
|
|
47 |
!
|
|
48 |
|
1226
|
49 |
Object subclass:#PackagedMethod
|
1268
|
50 |
instanceVariableNames:'name package category source ownedClassName'
|
|
51 |
classVariableNames:''
|
|
52 |
poolDictionaries:''
|
|
53 |
privateIn:Package
|
1226
|
54 |
!
|
|
55 |
|
|
56 |
Object subclass:#PackagedScript
|
1268
|
57 |
instanceVariableNames:'string receiver'
|
|
58 |
classVariableNames:''
|
|
59 |
poolDictionaries:''
|
|
60 |
privateIn:Package
|
1226
|
61 |
!
|
|
62 |
|
|
63 |
!Package class methodsFor:'documentation'!
|
|
64 |
|
1443
|
65 |
copyright
|
|
66 |
"
|
|
67 |
COPYRIGHT (c) 2003 by eXept Software AG
|
1674
|
68 |
All Rights Reserved
|
1443
|
69 |
|
|
70 |
This software is furnished under a license and may be used
|
|
71 |
only in accordance with the terms of that license and with the
|
|
72 |
inclusion of the above copyright notice. This software may not
|
|
73 |
be provided or otherwise made available to, or used by, any
|
|
74 |
other person. No title to or ownership of the software is
|
|
75 |
hereby transferred.
|
|
76 |
"
|
|
77 |
!
|
|
78 |
|
1226
|
79 |
documentation
|
|
80 |
"
|
|
81 |
documentation to be added.
|
|
82 |
|
|
83 |
[author:]
|
1674
|
84 |
(james@miraculix)
|
1226
|
85 |
|
|
86 |
[instance variables:]
|
|
87 |
|
1674
|
88 |
blockedMethods <Dictionary>
|
|
89 |
A reference of methods that the receiver is NOT responsible for
|
|
90 |
but the receiver is responsible for the method's class. It usage is
|
|
91 |
the same as a filter would be.
|
|
92 |
|
|
93 |
overriddenChanges <Dictionary1><Dictionary2><Dictionary3>
|
|
94 |
This variable helps the receiver keep its original state. When a
|
|
95 |
method changes it is held here so we can get the original. So the package
|
|
96 |
is still responsible for the overridden changes.
|
|
97 |
|
|
98 |
There are two way items can become added to overriddenChanges:
|
|
99 |
1) through loading packages - too many of these may not be desirable.
|
|
100 |
2) through editing a package - default package 'overrides it!!'
|
|
101 |
|
|
102 |
DESIGN: it is designed with dictionaries containing dictionaries as - for the
|
|
103 |
time being - to cope with different types of change. At the moment being
|
|
104 |
methodChanges (and soon classChanges). It is easier to search for changes
|
|
105 |
by using this hierarchy of dictionaries, and - i think - it is quite
|
|
106 |
extendable.
|
|
107 |
The only problem i can see with it is lingering dictionaries which are not deleted
|
|
108 |
when they contain nothing.
|
|
109 |
|
1226
|
110 |
|
|
111 |
|
|
112 |
|
|
113 |
|
|
114 |
[class variables:]
|
|
115 |
|
|
116 |
[see also:]
|
|
117 |
|
|
118 |
"
|
|
119 |
!
|
|
120 |
|
|
121 |
examples
|
|
122 |
"
|
|
123 |
|
1277
|
124 |
more examples to be added:
|
1674
|
125 |
[exBegin]
|
|
126 |
... add code fragment for
|
1226
|
127 |
... executable example here ...
|
1674
|
128 |
[exEnd]
|
1226
|
129 |
"
|
|
130 |
!
|
|
131 |
|
|
132 |
history
|
|
133 |
"Created: / 31.3.2003 / 16:45:04 / james"
|
|
134 |
! !
|
|
135 |
|
|
136 |
!Package class methodsFor:'instance creation'!
|
|
137 |
|
|
138 |
named:aString
|
|
139 |
"create a new package named aString "
|
1268
|
140 |
^ self named:aString asSymbol addToManager:nil. "or 'self defaultPackageManager'"
|
1226
|
141 |
!
|
|
142 |
|
|
143 |
named:aString addToManager:aManager
|
|
144 |
^ self named:aString withClasses:nil withMethods:nil addToManager:aManager
|
|
145 |
!
|
|
146 |
|
1674
|
147 |
named:aString withClasses:classes
|
1226
|
148 |
^ self named:aString withClasses:classes withMethods:nil addToManager:nil
|
|
149 |
!
|
|
150 |
|
|
151 |
named:aString withClasses:classes withMethods:methods addToManager:aManager
|
|
152 |
"create a new package named aString "
|
|
153 |
|anInstance |
|
|
154 |
anInstance := self new name:aString.
|
|
155 |
classes ifNotNil:[
|
1674
|
156 |
anInstance addedClasses:classes.
|
1226
|
157 |
].
|
|
158 |
methods ifNotNil:[
|
1674
|
159 |
anInstance addedMethods:methods.
|
1226
|
160 |
].
|
|
161 |
|
|
162 |
aManager ifNotNil:[
|
1674
|
163 |
aManager addPackage:anInstance.
|
1226
|
164 |
].
|
1674
|
165 |
^ anInstance
|
1226
|
166 |
!
|
|
167 |
|
1674
|
168 |
named:aString withMethods:methods
|
1226
|
169 |
^ self named:aString withClasses:nil withMethods:methods addToManager:nil
|
|
170 |
! !
|
|
171 |
|
|
172 |
!Package class methodsFor:'defaults'!
|
|
173 |
|
|
174 |
defaultBlockedMethodsCollection
|
|
175 |
^ Dictionary new
|
|
176 |
!
|
|
177 |
|
|
178 |
defaultOverriddenChangesCollection
|
1674
|
179 |
"a dictionary of sets. The keys are the classes and
|
1226
|
180 |
the sets are a collection of selectors!!"
|
|
181 |
^ Dictionary new
|
|
182 |
!
|
|
183 |
|
|
184 |
defaultPackagedClassesCollection
|
|
185 |
^ Dictionary new
|
|
186 |
!
|
|
187 |
|
|
188 |
defaultPackagedMethodsCollection
|
|
189 |
^ Dictionary new
|
|
190 |
!
|
|
191 |
|
|
192 |
defaultPrerequisiteCollection
|
|
193 |
^ PrerequisiteCollection new
|
|
194 |
!
|
|
195 |
|
|
196 |
defaultScriptsCollection
|
|
197 |
^ IdentityDictionary new
|
|
198 |
!
|
|
199 |
|
|
200 |
newDefaultPackage
|
1674
|
201 |
^ self named:(Project noProjectID).
|
1226
|
202 |
!
|
|
203 |
|
|
204 |
packageManager
|
|
205 |
^ self packageManagerClass smalltalkPackageManager.
|
|
206 |
!
|
|
207 |
|
|
208 |
packageManagerClass
|
|
209 |
^ PackageManager.
|
|
210 |
! !
|
|
211 |
|
|
212 |
!Package class methodsFor:'private - instance creation'!
|
|
213 |
|
|
214 |
new
|
|
215 |
"creates a new package and initialize's"
|
|
216 |
| anInstance |
|
|
217 |
anInstance := self basicNew initialize.
|
|
218 |
^ anInstance
|
|
219 |
! !
|
|
220 |
|
|
221 |
!Package methodsFor:'accessing'!
|
|
222 |
|
|
223 |
blockedMethods
|
|
224 |
"return the value of the instance variable 'blockedMethods' (automatically generated)"
|
|
225 |
|
|
226 |
^ blockedMethods
|
|
227 |
!
|
|
228 |
|
|
229 |
blockedMethods:something
|
|
230 |
"set the value of the instance variable 'blockedMethods' (automatically generated)"
|
|
231 |
|
|
232 |
blockedMethods := something.
|
|
233 |
!
|
|
234 |
|
1674
|
235 |
blockedMethodsAtClassNamed:arg
|
1268
|
236 |
^ (blockedMethods at:arg ifAbsent:[nil])
|
|
237 |
!
|
|
238 |
|
1674
|
239 |
blockedMethodsAtClassNamed:aClassName ifAbsentPut:anObject
|
|
240 |
^ blockedMethods at:aClassName ifAbsentPut:anObject
|
1268
|
241 |
!
|
|
242 |
|
1674
|
243 |
blockedMethodsRemoveAtClassNamed:arg ifAbsent:aBlock
|
1268
|
244 |
^ (blockedMethods removeKey:arg ifAbsent:aBlock)
|
1226
|
245 |
!
|
|
246 |
|
|
247 |
classNames
|
|
248 |
^ self packagedClasses values collect:[:aPackagedClass |
|
1674
|
249 |
aPackagedClass name
|
1226
|
250 |
].
|
|
251 |
!
|
|
252 |
|
|
253 |
classPrerequisites
|
|
254 |
^ prerequisites select:[:aPre |
|
1674
|
255 |
aPre isClassPrerequisite
|
1226
|
256 |
].
|
|
257 |
|
|
258 |
!
|
|
259 |
|
|
260 |
filename
|
|
261 |
"return the value of the instance variable 'filename' (automatically generated)"
|
|
262 |
|
|
263 |
^ packageHandler filename
|
|
264 |
!
|
|
265 |
|
1268
|
266 |
getInterestedMethodsFromClass:aClass
|
|
267 |
| aClassName |
|
|
268 |
aClassName := aClass name.
|
1674
|
269 |
^ aClass methodDictionary copy values select:[:aMethod |
|
|
270 |
self definesSelector:aMethod name forClassNamed:aClassName
|
1268
|
271 |
]
|
|
272 |
!
|
|
273 |
|
|
274 |
getInterestedPackagedMethodsFromClass:aClass
|
|
275 |
| aClassName aPackagedClass|
|
|
276 |
|
|
277 |
aClassName := aClass name.
|
|
278 |
(aPackagedClass := self packagedClassNamed:aClassName) ifNotNil:[
|
1674
|
279 |
^ aPackagedClass packagedMethods
|
1268
|
280 |
].
|
|
281 |
|
|
282 |
^ (packagedMethods at:aClassName ifAbsent:[^ OrderedCollection new ]) values
|
1674
|
283 |
"/ ^ aClass methodDictionary copy values collectAndselect:[:aMethod |
|
1268
|
284 |
"/ self definesSelector:aMethod name forClassNamed:aClassName
|
|
285 |
"/ ]
|
|
286 |
"/
|
|
287 |
|
|
288 |
!
|
|
289 |
|
1226
|
290 |
isDirty
|
|
291 |
"has the receiver been changed by adding scripts or added classes since the
|
1268
|
292 |
time it is loaded. This instance variable is NOT affected by changes in the image!!
|
|
293 |
but it could be worked out by looking at the receivers variables!!"
|
1226
|
294 |
|
|
295 |
^ isDirty "? true" "not needed because set by initialize"
|
|
296 |
!
|
|
297 |
|
|
298 |
isDirty:aBoolean
|
|
299 |
isDirty := aBoolean
|
|
300 |
!
|
|
301 |
|
|
302 |
isInstalled
|
|
303 |
"return the value of the instance variable 'isInstalled' (automatically generated)"
|
|
304 |
|
|
305 |
^ isInstalled
|
|
306 |
!
|
|
307 |
|
|
308 |
isInstalled:something
|
|
309 |
"set the value of the instance variable 'isInstalled' (automatically generated)"
|
|
310 |
|
|
311 |
isInstalled := something.
|
|
312 |
!
|
|
313 |
|
1674
|
314 |
looseMethodAtClass:aClassName atMethodName:aMethodName
|
1226
|
315 |
self looseMethods do:[:aLooseMethod |
|
1674
|
316 |
((aLooseMethod name == aMethodName) and:[
|
|
317 |
aLooseMethod className == aClassName]) ifTrue:[
|
|
318 |
^ aLooseMethod
|
|
319 |
].
|
|
320 |
|
1226
|
321 |
].
|
|
322 |
^ nil
|
|
323 |
!
|
|
324 |
|
|
325 |
looseMethods
|
|
326 |
| col mthdInImage |
|
|
327 |
col := OrderedCollection new.
|
|
328 |
self packagedMethods keysAndValuesDo:[:key :aDic | | looseMethodsInKey|
|
|
329 |
|
1674
|
330 |
looseMethodsInKey := aDic keysAndValuesDo:[:selector :aPackagedMethod | |collectValue|
|
|
331 |
aPackagedMethod isLoose ifTrue:[
|
|
332 |
mthdInImage := aPackagedMethod methodInImage.
|
|
333 |
col add:aPackagedMethod.
|
|
334 |
].
|
|
335 |
].
|
1226
|
336 |
|
|
337 |
].
|
|
338 |
|
|
339 |
^ col.
|
|
340 |
!
|
|
341 |
|
|
342 |
packageComment
|
|
343 |
"return the value of the instance variable 'packageComment' (automatically generated)"
|
|
344 |
|
|
345 |
^ packageComment
|
|
346 |
!
|
|
347 |
|
|
348 |
packageComment:something
|
|
349 |
"set the value of the instance variable 'packageComment' (automatically generated)"
|
|
350 |
|
|
351 |
packageComment := something.
|
|
352 |
!
|
|
353 |
|
|
354 |
packageHandler
|
|
355 |
"return the value of the instance variable 'packageHandler' (automatically generated)"
|
|
356 |
|
|
357 |
packageHandler isNil ifTrue:[
|
1674
|
358 |
packageHandler := PackageHandler forPackage:self.
|
1226
|
359 |
].
|
|
360 |
^ packageHandler
|
|
361 |
!
|
|
362 |
|
|
363 |
packageHandler:something
|
|
364 |
"set the value of the instance variable 'packageHandler' (automatically generated)"
|
|
365 |
|
|
366 |
packageHandler := something.
|
|
367 |
!
|
|
368 |
|
1268
|
369 |
packagePrerequisites
|
|
370 |
^ prerequisites select:[:aPre |
|
1674
|
371 |
aPre isPackagePrerequisite
|
1268
|
372 |
].
|
|
373 |
|
|
374 |
!
|
|
375 |
|
1226
|
376 |
packageType
|
|
377 |
^ 'STX Package' copy.
|
|
378 |
!
|
|
379 |
|
|
380 |
packageVersion
|
|
381 |
"return the value of the instance variable 'packageVersion' (automatically generated)"
|
|
382 |
|
|
383 |
^ packageVersion
|
|
384 |
!
|
|
385 |
|
|
386 |
packageVersion:something
|
|
387 |
"set the value of the instance variable 'packageVersion' (automatically generated)"
|
|
388 |
|
|
389 |
packageVersion := something.
|
|
390 |
!
|
|
391 |
|
|
392 |
packagedClasses
|
|
393 |
"return the value of the instance variable 'packagedClasses' (automatically generated)"
|
|
394 |
|
|
395 |
^ packagedClasses
|
|
396 |
!
|
|
397 |
|
|
398 |
packagedMethods
|
|
399 |
"return the value of the instance variable 'packagedMethods' (automatically generated)"
|
|
400 |
|
|
401 |
^ packagedMethods
|
|
402 |
!
|
|
403 |
|
1268
|
404 |
packagedMethodsAtClassName:arg ifAbsent:aBlock
|
|
405 |
^ (packagedMethods at:arg ifAbsent:aBlock)
|
|
406 |
!
|
|
407 |
|
|
408 |
packagedMethodsAtClassNamed:arg
|
|
409 |
^ (self packagedMethodsAtClassNamed:arg ifAbsent:[])
|
|
410 |
!
|
|
411 |
|
|
412 |
packagedMethodsAtClassNamed:arg ifAbsent:aBlock
|
|
413 |
^ (packagedMethods at:arg ifAbsent:aBlock)
|
|
414 |
!
|
|
415 |
|
|
416 |
packagedMethodsAtClassNamed:arg ifAbsentPut:aBlock
|
|
417 |
^ (packagedMethods at:arg ifAbsentPut:aBlock)
|
|
418 |
!
|
|
419 |
|
|
420 |
packagedMethodsForClass:arg ifAbsent:aBlock
|
|
421 |
^ (packagedMethods at:arg ifAbsent:aBlock)
|
|
422 |
!
|
|
423 |
|
1226
|
424 |
prerequisites
|
|
425 |
"return the value of the instance variable 'prerequisites' (automatically generated)"
|
|
426 |
|
|
427 |
^ prerequisites
|
|
428 |
!
|
|
429 |
|
|
430 |
scripts
|
|
431 |
"return the value of the instance variable 'scripts' (automatically generated)"
|
|
432 |
|
|
433 |
^ scripts
|
|
434 |
! !
|
|
435 |
|
|
436 |
!Package methodsFor:'adding & removing'!
|
|
437 |
|
|
438 |
addBlockedMethodNamed:aMethodName forClassNamed:aClassName
|
1268
|
439 |
^ (self blockedMethodsAtClassNamed:aClassName ifAbsentPut:[Set new]) add:aMethodName.
|
1226
|
440 |
!
|
|
441 |
|
|
442 |
addOverriddenClassChange:aPackagedClass byPackageNamed:byPackageName
|
|
443 |
"add an overridden method. under #package -> #className -> #classChangeNamespace -> aPackagedClass"
|
1268
|
444 |
| className |
|
|
445 |
self assert:(byPackageName isSymbol).
|
1226
|
446 |
className := aPackagedClass name.
|
1268
|
447 |
|
|
448 |
((overriddenClassChanges at:byPackageName ifAbsentPut:[Set new])
|
1674
|
449 |
add:className)
|
1226
|
450 |
!
|
|
451 |
|
1674
|
452 |
addOverriddenMethodChange:aPackagedMethod byPackageNamed:byPackageNamed
|
1268
|
453 |
"add an overridden method. under #package -> #methodClassName -> #packagedMethod"
|
|
454 |
| methodClassName |
|
1226
|
455 |
methodClassName := aPackagedMethod ownedClassName.
|
1277
|
456 |
"so that we have this method stored"
|
|
457 |
self addPackagedMethod:aPackagedMethod.
|
1268
|
458 |
|
|
459 |
(((overriddenMethodChanges at:byPackageNamed ifAbsentPut:[Dictionary new])
|
1674
|
460 |
at:methodClassName ifAbsentPut:[Set new]) add:aPackagedMethod name)
|
1226
|
461 |
!
|
|
462 |
|
1674
|
463 |
addPackagedClass:aPackagedClass
|
1268
|
464 |
"adds a class to the receiver.
|
1674
|
465 |
NOTE: Does not mark the receiver as dirty.
|
1268
|
466 |
That is the responsibility of the called of this method!!"
|
|
467 |
aPackagedClass isClass ifTrue:[
|
1674
|
468 |
self error:'I am expected a PackagedClass not a Class'.
|
1226
|
469 |
].
|
1268
|
470 |
self packagedClasses at:aPackagedClass name put:(aPackagedClass).
|
|
471 |
^ aPackagedClass
|
1226
|
472 |
!
|
|
473 |
|
1674
|
474 |
addPackagedMethod:aPackagedMethod
|
1226
|
475 |
"add or replace aPackagedMethod from the receiver"
|
1277
|
476 |
| aPackagedMethodsOwnedClass |
|
|
477 |
aPackagedMethodsOwnedClass := aPackagedMethod ownedClassName.
|
1674
|
478 |
^ (self packagedMethodsAtClassNamed:aPackagedMethodsOwnedClass ifAbsentPut:[Dictionary new])
|
|
479 |
at:aPackagedMethod name put:aPackagedMethod.
|
1226
|
480 |
!
|
|
481 |
|
1674
|
482 |
addPackagedMethods:somePackageMethods
|
1226
|
483 |
|
|
484 |
somePackageMethods do:[:aPackageMethod |
|
1674
|
485 |
self addPackagedMethod:aPackageMethod copy.
|
1226
|
486 |
].
|
|
487 |
^ somePackageMethods
|
|
488 |
!
|
|
489 |
|
1674
|
490 |
addPrerequisite:aPrerequisite
|
1268
|
491 |
prerequisites add:aPrerequisite
|
1226
|
492 |
!
|
|
493 |
|
1674
|
494 |
addedPackagedClasses:somePackagedClasses
|
1268
|
495 |
somePackagedClasses do:[:each |
|
1674
|
496 |
self addedPackagedClass:each
|
1268
|
497 |
].
|
|
498 |
^ somePackagedClasses
|
1226
|
499 |
!
|
|
500 |
|
1268
|
501 |
packagedClassesRemoveAtClassName:aKey ifAbsent:aBlock
|
|
502 |
^ self packagedClasses removeKey:aKey ifAbsent:aBlock
|
1226
|
503 |
!
|
|
504 |
|
|
505 |
removeBlockedMethodNamed:aMethodName forClassNamed:aClassName
|
1268
|
506 |
^ (self blockedMethodsAtClassNamed:aClassName) remove:aMethodName.
|
|
507 |
!
|
|
508 |
|
|
509 |
removeBlockedMethodsForClassNamed:aClassName ifAbsent:aBlock
|
|
510 |
^ (blockedMethods removeKey:aClassName ifAbsent:aBlock).
|
1226
|
511 |
!
|
|
512 |
|
|
513 |
removeOverriddenMethodNamed:aMethodName forClassNamed:aClassName
|
1674
|
514 |
^ self
|
|
515 |
removeOverriddenMethodNamed:aMethodName
|
|
516 |
forClassNamed:aClassName
|
|
517 |
ifAbsent:[self error:'trying to remove a method that does not exist!!'"should i keep this?"]
|
1268
|
518 |
!
|
|
519 |
|
|
520 |
removeOverriddenMethodNamed:aMethodName forClassNamed:aClassName ifAbsent:aBlock
|
|
521 |
|
|
522 |
| dictionaryOfMethodNamesAndPackagedMethods removedPackagedMethod|
|
|
523 |
|
|
524 |
overriddenMethodChanges values do:[:aDictionaryOfClassNamesAndPackagedMethods |
|
1674
|
525 |
(dictionaryOfMethodNamesAndPackagedMethods :=
|
|
526 |
aDictionaryOfClassNamesAndPackagedMethods at:aClassName ifAbsent:[nil]).
|
|
527 |
dictionaryOfMethodNamesAndPackagedMethods ifNotNil:[
|
|
528 |
removedPackagedMethod := (dictionaryOfMethodNamesAndPackagedMethods remove:aMethodName ifAbsent:[nil]).
|
|
529 |
removedPackagedMethod ifNotNil:[ "once found it can just exit as there should not be any more here!!"
|
|
530 |
^ self
|
|
531 |
].
|
|
532 |
].
|
1268
|
533 |
|
|
534 |
].
|
1226
|
535 |
!
|
|
536 |
|
|
537 |
scriptAt:aSymbol
|
|
538 |
^ scripts at:aSymbol ifAbsent:[PackagedScript string:(String new) receiver:self]
|
|
539 |
!
|
|
540 |
|
|
541 |
scriptAt:aSymbol put:aString
|
|
542 |
scripts at:aSymbol put:aString
|
|
543 |
! !
|
|
544 |
|
|
545 |
!Package methodsFor:'adding & removing - basic'!
|
|
546 |
|
|
547 |
basicAddedClass:aClass
|
|
548 |
"add a representation of a class (PackagedClass) to the receiver.
|
|
549 |
Look in aClass to see if we need to add any blocked methods - this could
|
|
550 |
be done by the manager but is done locally to avoid too many message sends"
|
1277
|
551 |
| newPackagedClass |
|
|
552 |
self assert:(aClass isMeta not).
|
|
553 |
newPackagedClass := (self newPackagedClass:aClass).
|
|
554 |
self basicAddedPackagedClass:newPackagedClass.
|
1268
|
555 |
|
|
556 |
(aClass methodDictionary copy) keysAndValuesDo:[:aMethodName :aMethod |
|
1674
|
557 |
(aMethod package == self name) ifFalse:[
|
|
558 |
newPackagedClass addBlockedMethodNamed:aMethodName.
|
|
559 |
].
|
1226
|
560 |
].
|
|
561 |
^ aClass
|
1277
|
562 |
|
|
563 |
|
1226
|
564 |
!
|
|
565 |
|
|
566 |
basicAddedMethod:aMethod
|
1268
|
567 |
"needed for as it does not have a change notification and does not mark the receiver
|
|
568 |
as dirty"
|
|
569 |
| aPackagedMethod aMethodName aMethodClassName|
|
|
570 |
|
1277
|
571 |
aMethodClassName := aMethod mclass name asSymbol.
|
1226
|
572 |
aMethodName := aMethod name.
|
1268
|
573 |
|
|
574 |
(self includesPackagedClassNamed:aMethodClassName) ifTrue:[
|
1674
|
575 |
^ (self packagedClassNamed:aMethodClassName) addMethodNamed:aMethodName
|
1226
|
576 |
].
|
|
577 |
|
1268
|
578 |
aPackagedMethod := (self newPackagedMethodSelector:aMethodName className:aMethodClassName source:aMethod source).
|
|
579 |
|
1674
|
580 |
self addPackagedMethod:aPackagedMethod.
|
1268
|
581 |
|
|
582 |
^ aPackagedMethod "if nil, the method is still to be installed. Could use a dummy here instead??"
|
|
583 |
!
|
|
584 |
|
|
585 |
basicAddedPackagedClass:aPackagedClass
|
|
586 |
"Add a class to a package. Return the aClass.
|
|
587 |
This only works when 'aClass package == name' if not and error will occur.
|
|
588 |
This method is called only AFTER the class package has changed!! This class
|
|
589 |
is NOT responsible for changing values in classes!!
|
|
590 |
"
|
|
591 |
| aPackagedClassName |
|
|
592 |
aPackagedClassName := aPackagedClass name.
|
1674
|
593 |
self assert:(aPackagedClassName isSymbol).
|
1268
|
594 |
(aPackagedClass package == self) ifFalse:[
|
1674
|
595 |
self error:'Cannot add ', aPackagedClassName, ' to package ''', name,
|
|
596 |
''' as the class ', aPackagedClassName, Character cr asString,
|
|
597 |
' belongs in the package''', aPackagedClass package name asString,''''.
|
1226
|
598 |
].
|
1268
|
599 |
(self includesPackagedClassNamed:aPackagedClass name) ifTrue:[
|
1674
|
600 |
(self overriddenClassChangesIncludesClassNamed:aPackagedClass name) ifFalse:[
|
|
601 |
PackageError raiseAddedClassFailedNamed:aPackagedClass name toPackage:self.
|
|
602 |
].
|
1226
|
603 |
].
|
1268
|
604 |
|
|
605 |
self removeOverriddenClassNamed:aPackagedClassName ifAbsent:[nil].
|
1674
|
606 |
self removeBlockedMethodsForClassNamed:aPackagedClassName ifAbsent:[nil].
|
1268
|
607 |
self packagedClasses at:aPackagedClassName put:(aPackagedClass).
|
|
608 |
^ aPackagedClass
|
1226
|
609 |
!
|
|
610 |
|
1674
|
611 |
basicRemoveClassNamed:aSymbol
|
1226
|
612 |
|
1268
|
613 |
packagedClasses removeKey:aSymbol ifAbsent:[
|
1674
|
614 |
"how much information do i need to recover from this error?"
|
|
615 |
PackageError raiseCannotRemoveClassNamed:aSymbol fromPackage:self
|
|
616 |
"'Cannot remove packagedClass ', aSymbol asString,
|
|
617 |
' from package: ', name string."
|
|
618 |
].
|
|
619 |
self blockedMethodsRemoveAtClassNamed:aSymbol ifAbsent:[nil "a blocked method is not always there!!"].
|
1268
|
620 |
self removeOverriddenClassNamed:aSymbol ifAbsent:[nil "a overridden class is not always there!!"].
|
1226
|
621 |
^ aSymbol
|
|
622 |
!
|
|
623 |
|
|
624 |
basicRemoveMethodNamed:aMethodName forClassNamed:aClassName ifAbsent:aBlock
|
|
625 |
"remove method named aMethodName from the receiver. If it is in loose methods, remove it,
|
|
626 |
if the receiver just owns the class, add it to the blockedMethods if teh blockedMethods already have it,
|
1674
|
627 |
evaluate aBlock"
|
1226
|
628 |
| aPackagedMethod |
|
1268
|
629 |
(self includesPackagedClassNamed:aClassName) ifTrue:[
|
1674
|
630 |
^ (self packagedClassNamed:aClassName) basicRemoveMethodNamed:aMethodName ifAbsent:aBlock
|
1268
|
631 |
].
|
|
632 |
|
|
633 |
(self packagedMethodsAtClassName:aClassName ifAbsent:aBlock)
|
1674
|
634 |
removeKey:aMethodName ifAbsent:aBlock.
|
1268
|
635 |
|
|
636 |
(self overriddenChangesIncludesMethodName:aMethodName forClassNamed:aClassName) ifTrue:[
|
1674
|
637 |
self removeOverriddenMethodNamed:aMethodName forClassNamed:aClassName ifAbsent:aBlock
|
1226
|
638 |
].
|
|
639 |
|
|
640 |
^ aPackagedMethod
|
1268
|
641 |
|
|
642 |
|
1226
|
643 |
! !
|
|
644 |
|
|
645 |
!Package methodsFor:'api - accessing'!
|
|
646 |
|
1674
|
647 |
changePackageOverrideFromPackage:fromPackage toPackage:toPackage forClassNamed:className
|
1268
|
648 |
"assumes that all the checks have been made that this className and these
|
|
649 |
packages do exist!!"
|
|
650 |
| overridenClassChangesHoldersForPackage |
|
1674
|
651 |
overridenClassChangesHoldersForPackage := (overriddenClassChanges at:fromPackage name).
|
1268
|
652 |
overridenClassChangesHoldersForPackage remove:className.
|
|
653 |
|
|
654 |
self overrideClassNamed:className byPackageNamed:toPackage name.
|
|
655 |
|
|
656 |
"cleanUp empty collections which are not needed!!"
|
|
657 |
overriddenClassChanges size == 0 ifTrue:[
|
1674
|
658 |
(overriddenClassChanges removeKey:fromPackage name)
|
1268
|
659 |
].
|
|
660 |
!
|
|
661 |
|
1226
|
662 |
changeSet
|
|
663 |
| changeSet |
|
|
664 |
changeSet := ChangeSet new.
|
|
665 |
packagedClasses do:[:aPackagedClass |
|
|
666 |
changeSet addAll:aPackagedClass changeSet
|
|
667 |
].
|
|
668 |
self looseMethods do:[:aPackageMethod | | aMethod aClass |
|
1674
|
669 |
changeSet addMethodChange:aPackageMethod method in:aPackageMethod ownedClass
|
1226
|
670 |
].
|
|
671 |
|
|
672 |
^ changeSet
|
|
673 |
!
|
|
674 |
|
|
675 |
classCategories
|
|
676 |
| return |
|
1268
|
677 |
return := Set new. "to make sure that each category is unique"
|
1226
|
678 |
self packagedClassesDo:[:aPackagedClass |
|
1674
|
679 |
return add:aPackagedClass category.
|
1226
|
680 |
].
|
|
681 |
^ return asOrderedCollection sort:[:x :y | x > y].
|
|
682 |
!
|
|
683 |
|
|
684 |
classesInCategory:aCategory
|
|
685 |
| collectingClasses |
|
|
686 |
collectingClasses := OrderedCollection new.
|
|
687 |
|
|
688 |
self packagedClassesDo:[:aPackagedClass |
|
1674
|
689 |
aPackagedClass category == aCategory ifTrue:[
|
|
690 |
collectingClasses add: aPackagedClass.
|
|
691 |
].
|
1226
|
692 |
].
|
|
693 |
^ collectingClasses
|
|
694 |
!
|
|
695 |
|
1674
|
696 |
overriddenClassNamesByPackage:aPackage
|
1268
|
697 |
^ (overriddenClassChanges at:aPackage name ifAbsent:[^#() "empty"]) asOrderedCollection.
|
|
698 |
!
|
|
699 |
|
1674
|
700 |
overriddenClassesByPackage:aPackage
|
1268
|
701 |
^ (self overriddenClassNamesByPackage:aPackage) collect:[:aPackagedClassName |
|
1674
|
702 |
self packagedClassNamed:aPackagedClassName
|
|
703 |
]
|
1268
|
704 |
!
|
|
705 |
|
1674
|
706 |
overriddingPackageNameAtClassName:aClassName
|
1268
|
707 |
"returns a PackagedClass or nil"
|
|
708 |
overriddenClassChanges keysAndValuesDo:[:packageName :aSetOfClassNames |
|
1674
|
709 |
(aSetOfClassNames includes:aClassName) ifTrue:[
|
|
710 |
^ packageName
|
|
711 |
].
|
1268
|
712 |
].
|
|
713 |
^ nil.
|
|
714 |
!
|
|
715 |
|
|
716 |
packagedClassNamed:aSymbol
|
|
717 |
^ (self packagedClassNamed:aSymbol ifAbsent:[nil])
|
|
718 |
!
|
|
719 |
|
1674
|
720 |
packagedClassNamed:aSymbol ifAbsent:aBlock
|
1277
|
721 |
| classWithoutClassEnding |
|
1674
|
722 |
classWithoutClassEnding := (aSymbol asString copyUpTo:Character space) asSymbol.
|
1277
|
723 |
|
|
724 |
(classWithoutClassEnding size < aSymbol asString size) ifTrue:[
|
1674
|
725 |
"here i am making a crude assumption that aSymbol is refering to the class side of a class.
|
|
726 |
whether i should check if this is true or not is another matter..."
|
|
727 |
^ (packagedClasses at:classWithoutClassEnding ifAbsent:[^ aBlock value]) classSide
|
1277
|
728 |
].
|
|
729 |
|
|
730 |
^ (packagedClasses at:aSymbol "or classWithoutClassEnding" ifAbsent:[^ aBlock value])
|
1226
|
731 |
!
|
|
732 |
|
1268
|
733 |
packagedMethodNamed:aSymbol forClassNamed:aClassName
|
|
734 |
^ (self packagedMethodNamed:aSymbol forClassNamed:aClassName ifAbsent:[nil])
|
|
735 |
!
|
|
736 |
|
|
737 |
packagedMethodNamed:aMethodName forClassNamed:aClassName ifAbsent:aBlock
|
|
738 |
| returnValue packagedMethodsAtClassName |
|
1674
|
739 |
packagedMethodsAtClassName := (self packagedMethods at:aClassName ifAbsent:[nil]).
|
1268
|
740 |
packagedMethodsAtClassName ifNotNil:[
|
1674
|
741 |
returnValue := packagedMethodsAtClassName at:aMethodName ifAbsent:[nil].
|
1268
|
742 |
].
|
|
743 |
|
|
744 |
returnValue ifNil:[
|
1674
|
745 |
(self definesSelector:aMethodName forClassNamed:aClassName) ifTrue:[| smalltalkMethod|
|
|
746 |
smalltalkMethod := (Smalltalk classNamed:aClassName) compiledMethodAt:aMethodName.
|
|
747 |
smalltalkMethod ifNil:[^ self error:'I am in an impossible state!!'].
|
|
748 |
^ self newPackagedMethodWithMethod:smalltalkMethod
|
|
749 |
|
|
750 |
].
|
|
751 |
aBlock value
|
1268
|
752 |
].
|
|
753 |
|
1674
|
754 |
^ returnValue.
|
1268
|
755 |
!
|
|
756 |
|
|
757 |
workingPackage
|
|
758 |
"Breaks encapsulation, but handy... may need a re-think"
|
|
759 |
^ Class packageQuerySignal query.
|
1226
|
760 |
! !
|
|
761 |
|
|
762 |
!Package methodsFor:'api - adding & removing'!
|
|
763 |
|
|
764 |
addClassNamed:aClass
|
1268
|
765 |
"called when adding a class on startup."
|
|
766 |
^ self addPackagedClass:(PackagedClass name:aClass package:self)
|
1226
|
767 |
!
|
|
768 |
|
1268
|
769 |
addMethodNamed:aMethodName forClassNamed:aClassName
|
|
770 |
"This is what i should sort out on MONDAY!!!!!!!!!! This is wrong!!!!!! I should be handed down the
|
|
771 |
REAL methods which are added to me so that i can extract the source!!"
|
|
772 |
| aPackagedMethod |
|
|
773 |
|
|
774 |
(self includesPackagedClassNamed:aClassName) ifTrue:[
|
1674
|
775 |
^ (self packagedClassNamed:aClassName) addMethodNamed:aMethodName
|
1268
|
776 |
].
|
1226
|
777 |
|
|
778 |
aPackagedMethod := (self newPackagedMethodSelector:aMethodName className:aClassName).
|
|
779 |
|
1674
|
780 |
self addPackagedMethod:aPackagedMethod.
|
1268
|
781 |
|
|
782 |
self markDirty.
|
1226
|
783 |
^ aPackagedMethod "if nil, the method is still to be installed. Could use a dummy here instead??"
|
|
784 |
!
|
|
785 |
|
|
786 |
addedClass:aClass
|
|
787 |
"Add a class to a package. Return the aClass.
|
|
788 |
This only works when 'aClass package == name' if not and error will occur.
|
|
789 |
This method is called only AFTER the class package has changed!! This class
|
|
790 |
is NOT responsible for changing values in classes!!
|
|
791 |
"
|
|
792 |
self basicAddedClass:aClass.
|
|
793 |
self markDirty.
|
|
794 |
self changed:#addedClass: with:aClass.
|
|
795 |
^ aClass
|
|
796 |
!
|
|
797 |
|
|
798 |
addedClasses:aClasses
|
|
799 |
"Add a class to a package. Return the aClass"
|
|
800 |
aClasses do:[:aClass |
|
1674
|
801 |
self basicAddedClass:aClass.
|
1226
|
802 |
].
|
|
803 |
|
|
804 |
self markDirty.
|
|
805 |
self changed:#addClasses: with:aClasses.
|
|
806 |
^ aClasses
|
|
807 |
!
|
|
808 |
|
|
809 |
addedMethod:aMethod
|
|
810 |
"Add a method to a package. Return the aMethod"
|
|
811 |
self basicAddedMethod:aMethod.
|
|
812 |
self markDirty.
|
|
813 |
self changed:#addedMethod: with:aMethod.
|
|
814 |
^ aMethod
|
|
815 |
!
|
|
816 |
|
|
817 |
addedMethods:someMethods
|
|
818 |
"Add someMethods to a package. Return the someMethods"
|
|
819 |
someMethods do:[:aMethod |
|
1674
|
820 |
self basicAddedMethod:aMethod.
|
1226
|
821 |
].
|
|
822 |
self markDirty.
|
|
823 |
self changed:#addedMethods: with:someMethods.
|
|
824 |
^ someMethods
|
|
825 |
!
|
|
826 |
|
1268
|
827 |
addedPackagedClass:aPackagedClass
|
|
828 |
"Add a class to a package. Return the aClass.
|
|
829 |
This only works when 'aClass package == name' if not and error will occur.
|
|
830 |
This method is called only AFTER the class package has changed!! This class
|
|
831 |
is NOT responsible for changing values in classes!!
|
|
832 |
"
|
|
833 |
|
|
834 |
self basicAddedPackagedClass:aPackagedClass.
|
|
835 |
self markDirty.
|
|
836 |
self changed:#addedPackagedClass: with:aPackagedClass.
|
|
837 |
^ aPackagedClass
|
|
838 |
!
|
|
839 |
|
|
840 |
addedPackagedClass:packagedClass blockedMethods:aSetOfBlockedMethods
|
|
841 |
"Add a class to a package. Return the aClass.
|
|
842 |
This only works when 'aClass package == name' if not and error will occur.
|
|
843 |
This method is called only AFTER the class package has changed!! This class
|
|
844 |
is NOT responsible for changing values in classes!!
|
|
845 |
"
|
|
846 |
| blockedMethodsAtClassName |
|
|
847 |
|
|
848 |
self addedPackagedClass:packagedClass.
|
|
849 |
aSetOfBlockedMethods size > 0 ifTrue:[
|
1674
|
850 |
blockedMethodsAtClassName := (self blockedMethodsAtClassNamed:packagedClass name ifAbsentPut:[Set new]).
|
|
851 |
blockedMethodsAtClassName addAll:aSetOfBlockedMethods.
|
1268
|
852 |
].
|
|
853 |
^ packagedClass
|
|
854 |
!
|
|
855 |
|
1674
|
856 |
overrideClassNamed:classBeingOverriddenName byPackageNamed:byPackageName
|
1268
|
857 |
| originalClassDefinition |
|
|
858 |
|
|
859 |
self assert:(byPackageName ~= name).
|
|
860 |
originalClassDefinition := (self packagedClassNamed: classBeingOverriddenName).
|
|
861 |
originalClassDefinition ifNil:[
|
1674
|
862 |
PackageError raiseWithOverrideClassErrorClassNotFound:classBeingOverriddenName fromPackage:self
|
1268
|
863 |
].
|
|
864 |
|
|
865 |
self addOverriddenClassChange:originalClassDefinition byPackageNamed:byPackageName.
|
|
866 |
self changed:#overrideClassNamed:byPackageNamed: with:(Array with:classBeingOverriddenName with:byPackageName)
|
1226
|
867 |
!
|
|
868 |
|
1674
|
869 |
overrideMethod:methodBeingOverridden byPackageNamed:byPackageName
|
1268
|
870 |
| originalMethodDefinition |
|
|
871 |
|
1674
|
872 |
originalMethodDefinition :=
|
|
873 |
(self newPackagedMethodSelector:methodBeingOverridden name
|
|
874 |
className:methodBeingOverridden mclass name asSymbol
|
|
875 |
source:methodBeingOverridden source).
|
1268
|
876 |
|
|
877 |
originalMethodDefinition ifNil:[
|
1674
|
878 |
PackageError raiseWithOverrideMethodErrorMethodNotFound:methodBeingOverridden fromPackage:self
|
1268
|
879 |
].
|
|
880 |
|
|
881 |
self addOverriddenMethodChange:originalMethodDefinition byPackageNamed:byPackageName.
|
|
882 |
self changed:#overrideMethod: with:methodBeingOverridden
|
1226
|
883 |
!
|
|
884 |
|
1674
|
885 |
overrideMethod:methodBeingOverridden forClassNamed:aClassName byPackageNamed:byPackageName
|
1268
|
886 |
| originalMethodDefinition methodName |
|
|
887 |
|
|
888 |
self assert:(byPackageName ~= name).
|
|
889 |
(methodBeingOverridden isKindOf:Method) ifTrue:[
|
1674
|
890 |
"unbound methods do not know there name so i have to do this... This could be done in Method>>selector"
|
|
891 |
(methodName := methodBeingOverridden name) ifNil:[
|
|
892 |
methodName := (methodBeingOverridden source upTo:Character space) asSymbol.
|
|
893 |
].
|
|
894 |
|
|
895 |
originalMethodDefinition :=
|
|
896 |
(self newPackagedMethodSelector:methodName
|
|
897 |
className:aClassName
|
|
898 |
source:methodBeingOverridden source).
|
|
899 |
|
|
900 |
originalMethodDefinition ifNil:[
|
|
901 |
PackageError raiseWithOverrideMethodErrorMethodNotFound:methodBeingOverridden fromPackage:self
|
|
902 |
].
|
1268
|
903 |
] ifFalse:[
|
1674
|
904 |
(methodBeingOverridden isKindOf:(Package::PackagedMethod)) ifFalse:[
|
|
905 |
self error:'This method needs a PackagedMethod or a Method'
|
|
906 |
].
|
|
907 |
originalMethodDefinition := methodBeingOverridden.
|
1268
|
908 |
].
|
|
909 |
|
|
910 |
self addOverriddenMethodChange:originalMethodDefinition byPackageNamed:byPackageName.
|
|
911 |
self changed:#overrideMethod: with:methodBeingOverridden
|
|
912 |
!
|
|
913 |
|
1277
|
914 |
removeFromSystem
|
|
915 |
self packagedClassesDo:[:aPackagedClass |
|
1674
|
916 |
aPackagedClass removeFromSystem
|
1277
|
917 |
].
|
|
918 |
|
|
919 |
self packagedMethodsDo:[:aPackagedMethod |
|
1674
|
920 |
aPackagedMethod removeFromSystem
|
1277
|
921 |
].
|
|
922 |
!
|
|
923 |
|
1268
|
924 |
removeOverriddenClassNamed:aClassNameSymbol
|
|
925 |
|
|
926 |
^ self removeOverriddenClassNamed:aClassNameSymbol ifAbsent:[self error:'Class not found!!']
|
|
927 |
!
|
|
928 |
|
|
929 |
removeOverriddenClassNamed:aClassNameSymbol ifAbsent:aBlock
|
|
930 |
|
|
931 |
overriddenClassChanges copy keysAndValuesDo:[:aPackageName :aSet |
|
1674
|
932 |
aSet remove:aClassNameSymbol ifAbsent:aBlock.
|
|
933 |
aSet isEmpty ifTrue:[
|
|
934 |
overriddenClassChanges removeKey:aPackageName.
|
|
935 |
].
|
1268
|
936 |
].
|
|
937 |
|
|
938 |
overriddenMethodChanges copy keysAndValuesDo:[:aPackageName :aDic |
|
1674
|
939 |
(aDic removeKey:aClassNameSymbol ifAbsent:aBlock).
|
|
940 |
aDic isEmpty ifTrue:[
|
|
941 |
overriddenMethodChanges removeKey:aPackageName
|
|
942 |
].
|
1268
|
943 |
].
|
1226
|
944 |
!
|
|
945 |
|
1674
|
946 |
removedClassNamed:aSymbol
|
1226
|
947 |
self basicRemoveClassNamed:aSymbol.
|
|
948 |
self markDirty.
|
|
949 |
self changed:#removedClassNamed: with:aSymbol.
|
|
950 |
^ aSymbol
|
|
951 |
!
|
|
952 |
|
|
953 |
removedMethod:aMethod
|
1674
|
954 |
^ self
|
|
955 |
removedMethodNamed:aMethod name
|
|
956 |
forClassNamed:aMethod mclass name.
|
1226
|
957 |
!
|
|
958 |
|
|
959 |
removedMethodNamed:aMethodName forClassNamed:aClassName
|
|
960 |
"note: could also create a loose method object which could be more useful"
|
1268
|
961 |
^ self removedMethodNamed:aMethodName forClassNamed:aClassName ifAbsent:[self error:'I should know this method!!']
|
1226
|
962 |
!
|
|
963 |
|
|
964 |
removedMethodNamed:aMethodName forClassNamed:aClassName ifAbsent:aBlock
|
|
965 |
"note: could also create a loose method object which could be more useful"
|
|
966 |
| aPackagedMethod |
|
|
967 |
aPackagedMethod := self basicRemoveMethodNamed:aMethodName forClassNamed:aClassName ifAbsent:aBlock.
|
|
968 |
self markDirty.
|
|
969 |
self changed:#removedMethodNamed:forClassNamed: with:(Array with:(aMethodName)with:(aClassName)).
|
|
970 |
^ aPackagedMethod
|
|
971 |
! !
|
|
972 |
|
1268
|
973 |
!Package methodsFor:'api - changes'!
|
1226
|
974 |
|
1674
|
975 |
classDefinitionChange:aClassDefinitionChange
|
|
976 |
"assumes that checks to see if the receiver is affected by the change have been made.
|
|
977 |
At present a classDefinitionChange does not result in a class changing packages!!
|
1226
|
978 |
If it does then this method needs to change and put this change type in overridden changes!!
|
|
979 |
"
|
|
980 |
self markDirty.
|
|
981 |
self changed:#classDefinitionChange: with:aClassDefinitionChange
|
|
982 |
!
|
|
983 |
|
1674
|
984 |
classInstVarDefinitionChange:aClassInstVarDefinitionChange
|
|
985 |
"assumes that checks to see if the receiver is affected by the change have been made.
|
|
986 |
At present a classInstVarDefinitionChange does not result in a class changing packages!!
|
1226
|
987 |
If it does then this method needs to change and put this change type in overridden changes!!
|
|
988 |
"
|
|
989 |
self markDirty.
|
|
990 |
self changed:#classInstVarDefinitionChange: with:aClassInstVarDefinitionChange
|
|
991 |
!
|
|
992 |
|
|
993 |
classRemoveChange:aClassRemoveChange
|
|
994 |
"assumes that checks to see if the receiver is affected by the change have been made.
|
1674
|
995 |
At the moment i store the original package information in the instance variable
|
1226
|
996 |
packagedClasses, and this is where i get the original class definition from!! It might be
|
|
997 |
an idea to get this info from aClassRemoveChange like it is done in methodRemoveChange.
|
1674
|
998 |
Then we would not need the packageClasses themselves and just storing symbolic links
|
1226
|
999 |
to the classesand create the packageClasses on the fly when needed.
|
|
1000 |
"
|
1268
|
1001 |
|classBeingRemoved originalClassDefinition interestedMethods |
|
1226
|
1002 |
|
|
1003 |
classBeingRemoved := ClassRemoveChange::ClassBeingRemovedQuery query.
|
1268
|
1004 |
originalClassDefinition := (self packagedClassNamed: classBeingRemoved name).
|
1674
|
1005 |
interestedMethods := self getInterestedPackagedMethodsFromClass:classBeingRemoved.
|
1268
|
1006 |
interestedMethods do:[:aPackagedMethod |
|
1674
|
1007 |
self addPackagedMethod:aPackagedMethod.
|
|
1008 |
self overrideMethod:aPackagedMethod forClassNamed:classBeingRemoved name byPackageNamed:#Smalltalk
|
1268
|
1009 |
].
|
1674
|
1010 |
(originalClassDefinition isNil and:[interestedMethods isEmpty]) ifTrue:[
|
|
1011 |
self error:'Oops. I should know this!! look #isDependentOnClassRemoveChange: This should be called
|
|
1012 |
before me and should work!!)'
|
1268
|
1013 |
].
|
|
1014 |
originalClassDefinition ifNotNil:[
|
1674
|
1015 |
self addOverriddenClassChange:originalClassDefinition byPackageNamed:#Smalltalk.
|
1268
|
1016 |
].
|
|
1017 |
self changed:#classRemoveChange:
|
1226
|
1018 |
!
|
|
1019 |
|
1674
|
1020 |
classRenameChange:aClassRenameChange
|
|
1021 |
"assumes that checks to see if the receiver is affected by the change have been made.
|
1226
|
1022 |
This action requires the receiver to change all references to the old class name to the
|
|
1023 |
new name.
|
|
1024 |
"
|
1268
|
1025 |
| newClass newPackagedClass|
|
1226
|
1026 |
newClass := (Smalltalk classNamed:aClassRenameChange className).
|
|
1027 |
newClass ifNil:[
|
1674
|
1028 |
self error:'The class named ', newClass name,
|
|
1029 |
'does not exist!! It is expected to exist from a rename action!!'
|
1226
|
1030 |
].
|
1268
|
1031 |
|
|
1032 |
self packagedClassesRemoveAtClassName:aClassRenameChange oldName ifAbsent:[nil].
|
|
1033 |
newPackagedClass := self newPackagedClass:newClass.
|
1674
|
1034 |
self addedPackagedClass:newPackagedClass.
|
1268
|
1035 |
self markDirty.
|
1226
|
1036 |
self changed:#classRenameChange: with:aClassRenameChange
|
|
1037 |
!
|
|
1038 |
|
|
1039 |
markClean
|
|
1040 |
self isDirty:false.
|
|
1041 |
!
|
|
1042 |
|
|
1043 |
markDirty
|
|
1044 |
self isDirty:true
|
|
1045 |
!
|
|
1046 |
|
|
1047 |
methodCategoryChange:aChange
|
1674
|
1048 |
"assumes that checks to see if the receiver is affected by the change have been made.
|
1226
|
1049 |
This is not considered a 'major change'. Therefore do nothing to the receiver to indicate that
|
|
1050 |
this method (specified by aChange) has been overriden or change. Just mark the receiver as
|
|
1051 |
dirty
|
|
1052 |
"
|
|
1053 |
self markDirty.
|
|
1054 |
self changed:#methodCategoryRenameChange: with:aChange
|
|
1055 |
!
|
|
1056 |
|
|
1057 |
methodCategoryRenameChange:aChange
|
1674
|
1058 |
"assumes that checks to see if the receiver is affected by the change have been made.
|
1226
|
1059 |
This is not considered a 'major change'. Therefore do nothing to the receiver to indicate that
|
|
1060 |
this method (specified by aChange) has been overriden or change. Just mark the receiver as
|
|
1061 |
dirty
|
|
1062 |
"
|
|
1063 |
self markDirty.
|
|
1064 |
self changed:#methodCategoryRenameChange: with:aChange
|
|
1065 |
!
|
|
1066 |
|
|
1067 |
methodChanged:aMethodChange
|
|
1068 |
"assumes that checks to see if the receiver is affected by the change have been made
|
|
1069 |
a method as changed.
|
|
1070 |
|
|
1071 |
There are really two types of change that come in here. A 'new method change' and a
|
|
1072 |
'method redefinition'.
|
1674
|
1073 |
|
1226
|
1074 |
If the receiver is dependent on the change there are two things that
|
|
1075 |
can happen depending on the change:
|
|
1076 |
|
1674
|
1077 |
1) if the receiver owns the class but not the method
|
|
1078 |
- to keep the package consistant - we add a blocked method to the receiver
|
|
1079 |
|
|
1080 |
2) if the receiver has a loose method defining the method
|
|
1081 |
add an overriddenMethod change - to store the original.
|
1226
|
1082 |
|
|
1083 |
Context note:
|
1674
|
1084 |
at present a change to a methods results ALWAYS in the default package owning the method.
|
|
1085 |
so here we assume that the current version package is NEVER the receiver!! This could be
|
|
1086 |
added functionality option later on (i have no way of testing this now).
|
1226
|
1087 |
"
|
|
1088 |
| previousVersion aMethodName aClassName aPackagedMethod byPackageName |
|
|
1089 |
|
|
1090 |
aMethodName := aMethodChange selector.
|
1277
|
1091 |
aClassName := aMethodChange className asSymbol.
|
1226
|
1092 |
previousVersion := aMethodChange previousVersion.
|
1674
|
1093 |
aPackagedMethod := self
|
|
1094 |
newPackagedMethodSelector:aMethodName
|
|
1095 |
className:aClassName
|
|
1096 |
source:previousVersion.
|
1226
|
1097 |
byPackageName := aPackagedMethod currentPackageOwner.
|
|
1098 |
|
1268
|
1099 |
(self includesPackagedClassNamed:aClassName) ifTrue:[
|
1674
|
1100 |
previousVersion ifNil:[
|
|
1101 |
"should only really happen in Default class - at least for the time being.
|
|
1102 |
This is because as is noted in - 'Context note' - above"
|
|
1103 |
^ self newMethodChanged:aMethodChange
|
|
1104 |
].
|
|
1105 |
|
|
1106 |
previousVersion package asSymbol == self name ifTrue:[
|
|
1107 |
^ self addOverriddenMethodChange:aPackagedMethod byPackageNamed:byPackageName.
|
|
1108 |
].
|
|
1109 |
Transcript nextPutAll:'i should NEVER be here.... either isDependentOnMethodChange does not
|
|
1110 |
work correctly OR i have just gone a bit bonkers!! From Package>>#methodChanged:';cr.
|
|
1111 |
].
|
1226
|
1112 |
|
|
1113 |
"when i am here aMethodChange is in with my packageMethods (loose method)
|
|
1114 |
the following should be true(but is it needed???):
|
1674
|
1115 |
previousVersion package asSymbol == self name
|
1226
|
1116 |
"
|
|
1117 |
|
1674
|
1118 |
self addOverriddenMethodChange:aPackagedMethod byPackageNamed:byPackageName.
|
1226
|
1119 |
|
|
1120 |
self changed:#methodChanged: with:aMethodChange
|
|
1121 |
!
|
|
1122 |
|
1674
|
1123 |
methodRemoveChange:aMethodRemoveChange
|
|
1124 |
"assumes that checks to see if the receiver is affected by the change have been made.
|
1226
|
1125 |
A method that i am dependant on has been removed. I could be dependent on it's class
|
1674
|
1126 |
or the method itself (then it would be a loose method).
|
1226
|
1127 |
|
|
1128 |
There is one special case where i would be dependent on the class but not the method.
|
|
1129 |
In this case i just remove the blocked method from my blocked method list!!
|
|
1130 |
Otherwise adds changes to overriddenChanges.
|
|
1131 |
"
|
1268
|
1132 |
| aMethodName aClassName methodBeingRemoved overriddenByPackage |
|
1226
|
1133 |
aMethodName := aMethodRemoveChange selector.
|
1277
|
1134 |
aClassName := aMethodRemoveChange className asSymbol.
|
1268
|
1135 |
methodBeingRemoved := aMethodRemoveChange previousVersion.
|
1226
|
1136 |
|
|
1137 |
(self blockedMethodsIncludeMethodName:aMethodName forClassNamed:aClassName) ifTrue:[
|
1674
|
1138 |
self removeBlockedMethodNamed:aMethodName forClassNamed:aClassName.
|
|
1139 |
self changed:#methodChanged: with:aMethodRemoveChange.
|
|
1140 |
^ self.
|
1226
|
1141 |
].
|
1268
|
1142 |
overriddenByPackage := self workingPackage.
|
|
1143 |
overriddenByPackage == name ifTrue:[
|
1674
|
1144 |
overriddenByPackage := #Smalltalk
|
1268
|
1145 |
].
|
|
1146 |
self overrideMethod:methodBeingRemoved forClassNamed:aClassName byPackageNamed:#Smalltalk.
|
|
1147 |
self changed:#methodChanged: with:aMethodRemoveChange.
|
1226
|
1148 |
!
|
|
1149 |
|
1674
|
1150 |
newMethodChanged:aMethodChange
|
1226
|
1151 |
"a new method has been created. In this case i must be dependent on the method's class
|
|
1152 |
so i need to block this method from my 'view of the world'."
|
|
1153 |
| aMethodName aClassName |
|
|
1154 |
aMethodName := aMethodChange selector.
|
|
1155 |
aClassName := aMethodChange className.
|
1674
|
1156 |
^ self addBlockedMethodNamed:aMethodName forClassNamed:aClassName
|
1226
|
1157 |
! !
|
|
1158 |
|
1268
|
1159 |
!Package methodsFor:'api - prerequisites'!
|
|
1160 |
|
|
1161 |
addClassNamePrerequisite:aClassName
|
|
1162 |
"changed sent in the following call"
|
|
1163 |
^ self addClassNamePrerequisite:aClassName ifFailString:''.
|
|
1164 |
!
|
|
1165 |
|
1674
|
1166 |
addClassNamePrerequisite:aName ifFailString:aString
|
1268
|
1167 |
|returnValue|
|
|
1168 |
|
1674
|
1169 |
returnValue := self
|
|
1170 |
addPrerequisite:(self newClassPrerequisiteNamed:aName
|
|
1171 |
ifFailString:aString).
|
1268
|
1172 |
self changed:#addClassNamePrerequisite: with:aName.
|
|
1173 |
^ returnValue
|
|
1174 |
!
|
|
1175 |
|
1674
|
1176 |
addPackageNamePrerequisite:aName
|
1268
|
1177 |
"changed sent in the following call"
|
|
1178 |
^ self addPackageNamePrerequisite:aName ifFailString:''.
|
|
1179 |
!
|
|
1180 |
|
1674
|
1181 |
addPackageNamePrerequisite:aName ifFailString:aString
|
1268
|
1182 |
|returnValue|
|
|
1183 |
|
1674
|
1184 |
returnValue := self
|
|
1185 |
addPrerequisite:(self newPackagePrerequisiteNamed:aName
|
|
1186 |
ifFailString:aString).
|
1268
|
1187 |
self changed:#addPackageNamePrerequisite: with:aName.
|
|
1188 |
^ returnValue
|
|
1189 |
! !
|
|
1190 |
|
|
1191 |
!Package methodsFor:'api - scripts'!
|
|
1192 |
|
|
1193 |
postInstallScript
|
1674
|
1194 |
^ self scriptAt:#postInstall
|
1268
|
1195 |
!
|
|
1196 |
|
|
1197 |
postInstallScriptString:aString
|
|
1198 |
self scriptAt:#postInstall put:(self newPackageScriptWithString:aString).
|
|
1199 |
self changed:#postInstallScriptString: with:aString.
|
|
1200 |
!
|
|
1201 |
|
|
1202 |
postUninstallScript
|
1674
|
1203 |
^ self scriptAt:#postUninstall
|
1268
|
1204 |
!
|
|
1205 |
|
|
1206 |
postUninstallScriptString:aString
|
|
1207 |
self scriptAt:#postUninstall put:(self newPackageScriptWithString:aString).
|
|
1208 |
self changed:#postUninstallScriptString: with:aString.
|
|
1209 |
!
|
|
1210 |
|
|
1211 |
preInstallScript
|
1674
|
1212 |
^ (self scriptAt:#preInstall)
|
1268
|
1213 |
!
|
|
1214 |
|
|
1215 |
preInstallScriptString:aString
|
|
1216 |
self scriptAt:#preInstall put:(self newPackageScriptWithString:aString).
|
|
1217 |
self changed:#preInstallScriptString: with:aString.
|
|
1218 |
!
|
|
1219 |
|
|
1220 |
preUninstallScript
|
1674
|
1221 |
^ self scriptAt:#preUninstall
|
1268
|
1222 |
!
|
|
1223 |
|
|
1224 |
preUninstallScriptString:aString
|
|
1225 |
self scriptAt:#preUninstall put:(self newPackageScriptWithString:aString).
|
|
1226 |
self changed:#preUninstallScriptString: with:aString.
|
|
1227 |
! !
|
|
1228 |
|
|
1229 |
!Package methodsFor:'api - uninstall'!
|
|
1230 |
|
|
1231 |
uninstallFromManager:aPackageManager
|
|
1232 |
|
|
1233 |
self packagedClasses copy do:[:aPackagedClass |
|
1674
|
1234 |
"i remove here from packagedClasses so a shallow copy is needed!!"
|
|
1235 |
aPackageManager
|
|
1236 |
removeClassNamed:aPackagedClass name
|
|
1237 |
fromPackage:self
|
|
1238 |
moveToDefaultPackage:false.
|
1268
|
1239 |
].
|
|
1240 |
|
|
1241 |
self checkOkToUninstall.
|
|
1242 |
self basicUninstall.
|
|
1243 |
! !
|
|
1244 |
|
|
1245 |
!Package methodsFor:'api-moving'!
|
|
1246 |
|
|
1247 |
movedClassNamed:aClassName toPackage:newOwnerPackage
|
1674
|
1248 |
"Note: all the methods of the class have also been moved to newOwnerPackage BUT
|
|
1249 |
we do not have to do anything about that here!! We also do not get any change messages
|
1268
|
1250 |
and we - in effect - get this change for free :-) as now newOwnerPackage owns the class!!"
|
|
1251 |
| packagedClass blockedMethods|
|
1674
|
1252 |
packagedClass := self packagedClassNamed:aClassName.
|
1268
|
1253 |
blockedMethods := self blockedMethodsAtClassNamed:aClassName.
|
|
1254 |
|
|
1255 |
packagedClass ifNil:[
|
1674
|
1256 |
PackageError raiseCannotMoveClassNamed:aClassName toPackage:newOwnerPackage.
|
1268
|
1257 |
].
|
|
1258 |
packagedClass package:newOwnerPackage.
|
|
1259 |
|
|
1260 |
PackageError removeClassError handle:[:ex |
|
1674
|
1261 |
PackageError raiseCannotMoveClassNamed:aClassName toPackage:newOwnerPackage.
|
1268
|
1262 |
] do:[
|
1674
|
1263 |
self removedClassNamed:aClassName.
|
1268
|
1264 |
].
|
|
1265 |
newOwnerPackage addedPackagedClass:packagedClass blockedMethods:blockedMethods.
|
|
1266 |
self markDirty.
|
1674
|
1267 |
self changed:#'movedClassNamed:toPackage:'
|
|
1268 |
with:(Array with:aClassName with:newOwnerPackage).
|
1268
|
1269 |
|
|
1270 |
!
|
|
1271 |
|
1674
|
1272 |
movedMethod:aMethod toPackage:newOwnerPackage
|
1268
|
1273 |
self removedMethod:aMethod.
|
|
1274 |
newOwnerPackage addedMethod:aMethod.
|
|
1275 |
! !
|
|
1276 |
|
1226
|
1277 |
!Package methodsFor:'checks'!
|
|
1278 |
|
|
1279 |
readyForInstall
|
|
1280 |
#ToDo.
|
|
1281 |
!
|
|
1282 |
|
|
1283 |
readyForUninstall
|
|
1284 |
#ToDo.
|
|
1285 |
! !
|
|
1286 |
|
|
1287 |
!Package methodsFor:'enumerating'!
|
|
1288 |
|
1674
|
1289 |
classesInSystemDo:aBlock
|
1226
|
1290 |
self packagedClassesDo:[:aPackage | | aClass |
|
1674
|
1291 |
(aClass"orNil" := aPackage classInSmalltalk) ifNotNil:[
|
|
1292 |
aBlock value:aClass
|
|
1293 |
].
|
1226
|
1294 |
].
|
|
1295 |
!
|
|
1296 |
|
1674
|
1297 |
loosePackagedMethodsDo:aBlock
|
1226
|
1298 |
self looseMethods do:aBlock.
|
|
1299 |
!
|
|
1300 |
|
1674
|
1301 |
packagedClassesDo:aOneArgBlock
|
1226
|
1302 |
^ packagedClasses do:aOneArgBlock
|
1277
|
1303 |
!
|
|
1304 |
|
1674
|
1305 |
packagedMethodsDo:aBlock
|
1277
|
1306 |
self packagedMethods values do:[:aDicOfPackagedMethods |
|
1674
|
1307 |
aDicOfPackagedMethods values do:aBlock
|
1277
|
1308 |
].
|
|
1309 |
|
|
1310 |
|
|
1311 |
|
1226
|
1312 |
! !
|
|
1313 |
|
|
1314 |
!Package methodsFor:'factory'!
|
|
1315 |
|
|
1316 |
newClassPrerequisiteNamed:aName ifFailString:aString
|
|
1317 |
^ ClassPrerequisite named:aName ifFailString:aString.
|
|
1318 |
!
|
|
1319 |
|
1674
|
1320 |
newOverriddenChangeWithChange:aChange
|
1226
|
1321 |
^ OverriddenChange newChange:aChange package:self.
|
|
1322 |
!
|
|
1323 |
|
|
1324 |
newPackagePrerequisiteNamed:aName ifFailString:aString
|
|
1325 |
^ PackagePrerequisite named:aName ifFailString:aString.
|
|
1326 |
!
|
|
1327 |
|
|
1328 |
newPackageScriptWithString:aString
|
|
1329 |
^ PackagedScript string:aString receiver:self
|
|
1330 |
!
|
|
1331 |
|
|
1332 |
newPackagedClass:aClass
|
|
1333 |
^ (PackagedClass class:aClass package:self)
|
|
1334 |
!
|
|
1335 |
|
|
1336 |
newPackagedMethodSelector:aMethodSelector className:aClassName
|
|
1337 |
^ PackagedMethod new
|
1674
|
1338 |
name:aMethodSelector;
|
|
1339 |
ownedClassName: aClassName;
|
|
1340 |
package:self.
|
1226
|
1341 |
!
|
|
1342 |
|
|
1343 |
newPackagedMethodSelector:aMethodSelector className:aClassName source:aSourceString
|
1674
|
1344 |
^ PackagedMethod
|
|
1345 |
name:aMethodSelector
|
|
1346 |
ownedClassName: aClassName
|
|
1347 |
category:String new
|
|
1348 |
package:self
|
|
1349 |
source:aSourceString
|
1226
|
1350 |
!
|
|
1351 |
|
1674
|
1352 |
newPackagedMethodWithMethod:aMethod
|
|
1353 |
^ PackagedMethod
|
|
1354 |
name:aMethod selector
|
|
1355 |
ownedClassName: aMethod mclass name
|
|
1356 |
category:aMethod category
|
|
1357 |
package:self
|
|
1358 |
source:aMethod source
|
1226
|
1359 |
! !
|
|
1360 |
|
|
1361 |
!Package methodsFor:'initialization'!
|
|
1362 |
|
|
1363 |
initialize
|
|
1364 |
|
|
1365 |
packagedClasses := self class defaultPackagedClassesCollection.
|
|
1366 |
packagedMethods := self class defaultPackagedMethodsCollection.
|
|
1367 |
blockedMethods := self class defaultBlockedMethodsCollection.
|
1268
|
1368 |
|
|
1369 |
overriddenClassChanges := self class defaultOverriddenChangesCollection.
|
|
1370 |
overriddenMethodChanges := self class defaultOverriddenChangesCollection.
|
|
1371 |
|
1226
|
1372 |
prerequisites := self class defaultPrerequisiteCollection.
|
|
1373 |
scripts := self class defaultScriptsCollection.
|
|
1374 |
|
|
1375 |
isDirty := false.
|
|
1376 |
isInstalled := false. "not sure about this..."
|
|
1377 |
super initialize.
|
|
1378 |
!
|
|
1379 |
|
|
1380 |
initializeClasses
|
1277
|
1381 |
self classesInSystemDo:[:aClass |
|
1674
|
1382 |
aClass initialize.
|
1226
|
1383 |
].
|
|
1384 |
!
|
|
1385 |
|
|
1386 |
initializeInstalled
|
|
1387 |
"initialize as if the receiver as if it has just been loaded"
|
|
1388 |
| myName packagedClass |
|
|
1389 |
myName := self name.
|
|
1390 |
self isDirty:false.
|
|
1391 |
self isInstalled:true.
|
1277
|
1392 |
self classesInSystemDo:[:aClass |
|
1674
|
1393 |
aClass setPackage:myName.
|
|
1394 |
"get initial information"
|
|
1395 |
packagedClass := (self packagedClassNamed:aClass name).
|
|
1396 |
packagedClass instanceDefinition:aClass definition
|
|
1397 |
classDefinition:aClass class definition
|
|
1398 |
category:aClass category
|
1268
|
1399 |
|
1226
|
1400 |
].
|
1268
|
1401 |
"you need to set the working package to the package you are loading... maybe???"
|
|
1402 |
"/ self looseMethodsDo:[:aMethod |
|
|
1403 |
"/ aMethod setPackage:myName
|
|
1404 |
"/ ].
|
1226
|
1405 |
!
|
|
1406 |
|
|
1407 |
initializeLoaded
|
|
1408 |
"initialize as if the receiver as just been loaded"
|
|
1409 |
self isDirty:false.
|
|
1410 |
self isInstalled:false.
|
|
1411 |
! !
|
|
1412 |
|
|
1413 |
!Package methodsFor:'printing'!
|
|
1414 |
|
|
1415 |
printOn:aStream
|
1674
|
1416 |
|
1226
|
1417 |
'named:', self name.
|
|
1418 |
aStream nextPutAll:self class printString.
|
|
1419 |
aStream nextPutAll:' named:'.
|
|
1420 |
aStream nextPut:$'.
|
|
1421 |
aStream nextPutAll:self name.
|
|
1422 |
aStream nextPut:$'.
|
|
1423 |
! !
|
|
1424 |
|
|
1425 |
!Package methodsFor:'queries'!
|
|
1426 |
|
|
1427 |
blockedMethodsIncludeMethodName:aMethodName forClassNamed:aClassName
|
|
1428 |
| blockedMethods |
|
1268
|
1429 |
blockedMethods := (self blockedMethodsAtClassNamed:aClassName).
|
1226
|
1430 |
blockedMethods ifNil:[
|
1674
|
1431 |
^ false.
|
1226
|
1432 |
].
|
|
1433 |
|
|
1434 |
^ blockedMethods includes:aMethodName
|
|
1435 |
!
|
|
1436 |
|
1268
|
1437 |
definesSelector:aMethodSymbol forClassNamed:aClassSymbol
|
1674
|
1438 |
"checks to see if the receiver defines a method selector associated
|
1268
|
1439 |
with a class symbol."
|
|
1440 |
|
|
1441 |
| theClass dictionaryOfPackagedMethods |
|
|
1442 |
|
|
1443 |
(theClass := self packagedClassNamed:aClassSymbol) ifNil:[
|
1674
|
1444 |
dictionaryOfPackagedMethods := self packagedMethods at:aClassSymbol ifAbsent:[^ false].
|
|
1445 |
dictionaryOfPackagedMethods at:aMethodSymbol ifAbsent:[^ false]. "assumes a packagedMethod is returned"
|
|
1446 |
aMethodSymbol ifNil:[
|
|
1447 |
^ false.
|
|
1448 |
].
|
|
1449 |
^ true.
|
1268
|
1450 |
].
|
|
1451 |
|
|
1452 |
"if i am here then i know the class!!"
|
|
1453 |
(self blockedMethodsIncludeMethodName:aMethodSymbol forClassNamed:aClassSymbol) ifTrue:[
|
1674
|
1454 |
^ false.
|
1226
|
1455 |
].
|
|
1456 |
|
1268
|
1457 |
aMethodSymbol ifNil:[
|
1674
|
1458 |
^ false.
|
1226
|
1459 |
].
|
|
1460 |
|
|
1461 |
^ true.
|
|
1462 |
!
|
|
1463 |
|
1674
|
1464 |
includesPackagedClassNamed:aSymbol
|
1277
|
1465 |
|
|
1466 |
^ (self packagedClassNamed:aSymbol) notNil
|
1226
|
1467 |
!
|
|
1468 |
|
1268
|
1469 |
isOverridden
|
|
1470 |
^ ((overriddenMethodChanges notEmpty) or:[(overriddenClassChanges notEmpty)])
|
1226
|
1471 |
!
|
|
1472 |
|
|
1473 |
isPackage
|
|
1474 |
^ true
|
|
1475 |
!
|
|
1476 |
|
1268
|
1477 |
overriddenChangesIncludesClassNamed:aClassName
|
|
1478 |
|
|
1479 |
|
1674
|
1480 |
overriddenClassChanges values do:[:aSetOfClassNames |
|
|
1481 |
(aSetOfClassNames includes:aClassName) ifTrue:[
|
|
1482 |
^ true
|
|
1483 |
].
|
|
1484 |
].
|
1268
|
1485 |
overriddenMethodChanges values do:[:aColOfDics |
|
1674
|
1486 |
(aColOfDics keys includes:aClassName) ifTrue:[
|
|
1487 |
^ true
|
|
1488 |
].
|
|
1489 |
].
|
|
1490 |
|
|
1491 |
^ false
|
1268
|
1492 |
|
|
1493 |
!
|
|
1494 |
|
|
1495 |
overriddenChangesIncludesMethodName:aMethodName forClassNamed:aClassName
|
1277
|
1496 |
| aSetOfPackageMethods |
|
1268
|
1497 |
|
|
1498 |
overriddenMethodChanges values do:[:aDicOfClassNamesAndMethods |
|
1674
|
1499 |
aSetOfPackageMethods := (aDicOfClassNamesAndMethods at:aClassName ifAbsent:[nil]).
|
|
1500 |
aSetOfPackageMethods ifNotNil:[
|
|
1501 |
(aSetOfPackageMethods includes:aMethodName) ifTrue:[
|
|
1502 |
^ true
|
|
1503 |
].
|
|
1504 |
].
|
1268
|
1505 |
|
|
1506 |
].
|
|
1507 |
|
1674
|
1508 |
^ false
|
1268
|
1509 |
!
|
|
1510 |
|
|
1511 |
overriddenClassChangesIncludesClassNamed:aClassName
|
|
1512 |
|
|
1513 |
overriddenClassChanges isEmpty ifTrue:[
|
1674
|
1514 |
^ false
|
1268
|
1515 |
].
|
|
1516 |
|
1674
|
1517 |
overriddenClassChanges values do:[:aSetOfClassNames |
|
|
1518 |
(aSetOfClassNames includes:aClassName) ifTrue:[
|
|
1519 |
^ true
|
|
1520 |
].
|
|
1521 |
].
|
|
1522 |
|
|
1523 |
^ false
|
1226
|
1524 |
!
|
|
1525 |
|
1268
|
1526 |
overriddenMethodChangesIncludesClassNamed:aClassName
|
|
1527 |
|
|
1528 |
overriddenMethodChanges isEmpty ifTrue:[
|
1674
|
1529 |
^ false
|
1268
|
1530 |
].
|
|
1531 |
|
1674
|
1532 |
overriddenClassChanges values do:[:aDic |
|
|
1533 |
(aDic keys includes:aClassName) ifTrue:[
|
|
1534 |
^ true
|
|
1535 |
].
|
|
1536 |
].
|
|
1537 |
|
|
1538 |
^ false
|
1268
|
1539 |
! !
|
|
1540 |
|
|
1541 |
!Package methodsFor:'queries - dependents'!
|
|
1542 |
|
|
1543 |
hasRelationshipWithClassNamed:aClassName
|
|
1544 |
"checks to see if the receiver has got some sort of relationship with
|
|
1545 |
aClassName such as a method or a class. returns a boolean
|
|
1546 |
"
|
|
1547 |
self assert:aClassName isSymbol.
|
|
1548 |
|
|
1549 |
^ ((self includesPackagedClassNamed:aClassName) or:[
|
1674
|
1550 |
(self packagedMethods at:aClassName ifAbsent:[nil])notNil] )
|
1268
|
1551 |
!
|
|
1552 |
|
|
1553 |
isDependentOnClassNamed:aClassName
|
|
1554 |
"checks to see if the receiver is dependent on aClassName. returns a boolean
|
|
1555 |
"
|
|
1556 |
| packagedClass classCheck methodCheck packagedMethods |
|
|
1557 |
self assert:aClassName isSymbol.
|
|
1558 |
classCheck := true.
|
|
1559 |
methodCheck := true.
|
|
1560 |
|
|
1561 |
(self hasRelationshipWithClassNamed:aClassName) ifFalse:[
|
1674
|
1562 |
^ false
|
1268
|
1563 |
].
|
|
1564 |
|
|
1565 |
packagedClass := (self packagedClassNamed:aClassName) ifNotNil:[
|
1674
|
1566 |
classCheck := (self overriddingPackageNameAtClassName:aClassName) isNil
|
1268
|
1567 |
].
|
|
1568 |
|
|
1569 |
(packagedMethods := self packagedMethods at:aClassName ifAbsent:[nil]) ifNotNil:[
|
1674
|
1570 |
packagedMethods keys do:[:aMethodSelector |
|
|
1571 |
(self isDependentOnMethodNamed:aMethodSelector forClassNamed:aClassName) ifFalse:[
|
|
1572 |
methodCheck := false.
|
|
1573 |
].
|
|
1574 |
].
|
|
1575 |
|
1268
|
1576 |
].
|
|
1577 |
|
|
1578 |
^ classCheck or:[methodCheck].
|
|
1579 |
!
|
|
1580 |
|
|
1581 |
isDependentOnMethodNamed:aMethodSelector forClassNamed:aMethodClassName
|
|
1582 |
"If the receiver is responsible for the change return true or false."
|
|
1583 |
(self definesSelector:aMethodSelector forClassNamed:aMethodClassName) ifTrue:[
|
1674
|
1584 |
(self includesPackagedClassNamed:aMethodClassName) ifTrue:[
|
|
1585 |
(self blockedMethodsIncludeMethodName:aMethodSelector forClassNamed:aMethodClassName) ifTrue:[
|
|
1586 |
^ false.
|
|
1587 |
].
|
|
1588 |
].
|
|
1589 |
|
|
1590 |
(self overriddenChangesIncludesMethodName:aMethodSelector forClassNamed:aMethodClassName) ifTrue:[
|
|
1591 |
^ false.
|
|
1592 |
].
|
|
1593 |
^ true.
|
1268
|
1594 |
].
|
|
1595 |
|
|
1596 |
|
|
1597 |
|
1674
|
1598 |
^ false
|
1226
|
1599 |
! !
|
|
1600 |
|
|
1601 |
!Package methodsFor:'uninstall'!
|
|
1602 |
|
|
1603 |
basicUninstall
|
|
1604 |
|
|
1605 |
self preUninstallScript evaluate.
|
|
1606 |
self uninstallDependentPackages.
|
|
1607 |
self uninstallClasses.
|
|
1608 |
self uninstallLooseMethods.
|
|
1609 |
self initializeLoaded.
|
|
1610 |
self postUninstallScript evaluate.
|
|
1611 |
!
|
|
1612 |
|
|
1613 |
checkOkToUninstall
|
|
1614 |
#toDo.
|
|
1615 |
!
|
|
1616 |
|
|
1617 |
uninstallClasses
|
1277
|
1618 |
self classesInSystemDo:[:aClass |
|
1674
|
1619 |
aClass removeFromSystem.
|
1226
|
1620 |
]
|
|
1621 |
!
|
|
1622 |
|
|
1623 |
uninstallDependentPackages
|
|
1624 |
#toDo
|
|
1625 |
!
|
|
1626 |
|
|
1627 |
uninstallLooseMethods
|
1277
|
1628 |
self loosePackagedMethodsDo:[:aLooseMethod |
|
1674
|
1629 |
aLooseMethod removeFromSystem.
|
1226
|
1630 |
].
|
|
1631 |
! !
|
|
1632 |
|
|
1633 |
!Package::PackagedClass class methodsFor:'instance creation'!
|
|
1634 |
|
|
1635 |
class:aClass package:aPackage
|
|
1636 |
| anInstance|
|
|
1637 |
anInstance := (self basicNew name:aClass name package:aPackage).
|
|
1638 |
(aClass isLoaded) ifFalse:[
|
1674
|
1639 |
"could also be dependant on Smalltalk!!"
|
|
1640 |
aClass addDependent:anInstance. "get the definition when the class is autoloaded"
|
|
1641 |
anInstance category: aClass category.
|
|
1642 |
^ anInstance.
|
1226
|
1643 |
].
|
1674
|
1644 |
anInstance instanceDefinition: aClass definition
|
|
1645 |
classDefinition: aClass class definition
|
|
1646 |
category: aClass category.
|
1226
|
1647 |
|
|
1648 |
^ anInstance
|
|
1649 |
!
|
|
1650 |
|
|
1651 |
name:aClassName package:aPackage
|
|
1652 |
^ (self basicNew name:aClassName package:aPackage).
|
|
1653 |
! !
|
|
1654 |
|
|
1655 |
!Package::PackagedClass methodsFor:'accessing'!
|
|
1656 |
|
|
1657 |
category
|
1268
|
1658 |
^ category ifNil:['' copy].
|
1226
|
1659 |
!
|
|
1660 |
|
|
1661 |
category:something
|
|
1662 |
"set the value of the instance variable 'category' (automatically generated)"
|
|
1663 |
|
|
1664 |
category := something.
|
|
1665 |
!
|
|
1666 |
|
|
1667 |
classDefinition
|
|
1668 |
"return the value of the instance variable 'classDefinition' (automatically generated)"
|
|
1669 |
|
|
1670 |
^ classDefinition
|
|
1671 |
!
|
|
1672 |
|
|
1673 |
classInstanceVariableNames
|
|
1674 |
"return the value of the instance variable 'classInstanceVariableNames' (automatically generated)"
|
|
1675 |
|
|
1676 |
^ classInstanceVariableNames
|
|
1677 |
!
|
|
1678 |
|
|
1679 |
classVariableNames
|
|
1680 |
"return the value of the instance variable 'classVariableNames' (automatically generated)"
|
|
1681 |
|
|
1682 |
^ classVariableNames
|
|
1683 |
!
|
|
1684 |
|
|
1685 |
instanceDefinition
|
|
1686 |
"return the value of the instance variable 'instanceDefinition' (automatically generated)"
|
|
1687 |
|
|
1688 |
^ instanceDefinition
|
|
1689 |
!
|
|
1690 |
|
1674
|
1691 |
instanceDefinition:instanceDefinitionArg classDefinition:classDefinitionArg category:categoryArg
|
1268
|
1692 |
"set instance variables (automatically generated)"
|
|
1693 |
|
|
1694 |
instanceDefinition := instanceDefinitionArg.
|
|
1695 |
classDefinition := classDefinitionArg.
|
|
1696 |
category := categoryArg.
|
1226
|
1697 |
!
|
|
1698 |
|
|
1699 |
instanceVariableNames
|
|
1700 |
"return the value of the instance variable 'instanceVariableNames' (automatically generated)"
|
|
1701 |
|
|
1702 |
^ instanceVariableNames
|
|
1703 |
!
|
|
1704 |
|
|
1705 |
name
|
|
1706 |
"return the value of the instance variable 'name' (automatically generated)"
|
|
1707 |
|
|
1708 |
^ name
|
|
1709 |
!
|
|
1710 |
|
1674
|
1711 |
name:nameArg package:packageArg
|
1226
|
1712 |
"set instance variables (automatically generated)"
|
|
1713 |
|
|
1714 |
name := nameArg.
|
|
1715 |
package := packageArg.
|
|
1716 |
!
|
|
1717 |
|
|
1718 |
package
|
|
1719 |
"return the value of the instance variable 'package' (automatically generated)"
|
|
1720 |
|
|
1721 |
^ package
|
|
1722 |
!
|
|
1723 |
|
1268
|
1724 |
package:aPackage
|
|
1725 |
"if the receiver IS in smalltalk change the class in smalltalk.
|
|
1726 |
I hope this wont make the functionality get a bit hairy..."
|
|
1727 |
|
|
1728 |
self isInSmalltalk ifTrue:[
|
1674
|
1729 |
self classInSmalltalk package:aPackage name
|
1268
|
1730 |
].
|
|
1731 |
package := aPackage.
|
|
1732 |
!
|
|
1733 |
|
|
1734 |
privateClasses
|
|
1735 |
"borrowed implementation from Class>>privateClasses.
|
|
1736 |
This implementation looks into the receiver's package to look for
|
|
1737 |
privateClasses. IF the receiver is installed in Smalltalk then these private classes
|
|
1738 |
associated with the receiver are also its privateClasses!! Although this may not happen
|
|
1739 |
often
|
|
1740 |
"
|
1674
|
1741 |
^ self privateClassesOrAll:false
|
1268
|
1742 |
|
|
1743 |
|
|
1744 |
|
1226
|
1745 |
!
|
|
1746 |
|
1674
|
1747 |
privateClassesOrAll:allOfThem
|
1268
|
1748 |
"implementation based on Class>>privateClasesOrNil: "
|
|
1749 |
|classes myName myNamePrefix myNamePrefixLen cls|
|
|
1750 |
|
|
1751 |
myName := self name.
|
|
1752 |
myNamePrefix := myName , '::'.
|
|
1753 |
myNamePrefixLen := myNamePrefix size.
|
|
1754 |
|
|
1755 |
package packagedClasses keys do:[:nm |
|
1674
|
1756 |
(nm startsWith:myNamePrefix) ifTrue:[
|
|
1757 |
(allOfThem
|
|
1758 |
or:[(nm indexOf:$: startingAt:myNamePrefixLen + 1) == 0]) ifTrue:[
|
|
1759 |
cls := package packagedClassNamed:nm.
|
|
1760 |
|
|
1761 |
(cls notNil) ifTrue:[
|
|
1762 |
classes isNil ifTrue:[
|
|
1763 |
classes := IdentitySet new:10.
|
|
1764 |
].
|
|
1765 |
classes add:cls.
|
|
1766 |
]
|
|
1767 |
]
|
|
1768 |
]
|
1268
|
1769 |
].
|
|
1770 |
self isInSmalltalk ifTrue:[
|
1674
|
1771 |
^ classes ? (OrderedCollection new) addAll:(self classInSmalltalk privateClasses)
|
1268
|
1772 |
].
|
|
1773 |
^ classes ? #()
|
1226
|
1774 |
!
|
|
1775 |
|
1268
|
1776 |
shortName
|
|
1777 |
"copied from ClassDescription>>nameWithoutPrefix "
|
|
1778 |
|nm idx|
|
|
1779 |
|
|
1780 |
nm := self name.
|
|
1781 |
idx := nm lastIndexOf:$:.
|
|
1782 |
idx == 0 ifTrue:[
|
1674
|
1783 |
^ nm
|
1268
|
1784 |
].
|
|
1785 |
^ (nm copyFrom:idx+1) asSymbol. "asSymbol was added"
|
1226
|
1786 |
! !
|
|
1787 |
|
|
1788 |
!Package::PackagedClass methodsFor:'api'!
|
|
1789 |
|
1674
|
1790 |
addBlockedMethodNamed:aMethodName
|
1268
|
1791 |
^ package addBlockedMethodNamed:aMethodName forClassNamed:name
|
|
1792 |
!
|
|
1793 |
|
1674
|
1794 |
addMethodNamed:aMethodName
|
1268
|
1795 |
| aPackagedMethod |
|
|
1796 |
(self blockedMethodsIncludeMethodName:aMethodName) ifTrue:[
|
1674
|
1797 |
self removeBlockedMethodNamed:aMethodName.
|
|
1798 |
self markDirty.
|
|
1799 |
^ aPackagedMethod.
|
1268
|
1800 |
].
|
|
1801 |
|
|
1802 |
(self overriddenChangesIncludesMethodName:aMethodName) ifTrue:[
|
|
1803 |
"it should not be consider overriden anymore has the method has just been
|
|
1804 |
added to the receiver!! And we dont need to add it as an extra method either
|
|
1805 |
as i now am a 'holder for this method!!' But to show this i need to mark myself dirty"
|
1674
|
1806 |
self markDirty.
|
|
1807 |
self removeOverriddenMethodNamed:aMethodName.
|
|
1808 |
^ aPackagedMethod.
|
1268
|
1809 |
].
|
|
1810 |
|
|
1811 |
"if i am here the method is in effect added as the package the receiver is related to
|
|
1812 |
knows the class and does not include any blocked methods for the method aMethodName"
|
|
1813 |
!
|
|
1814 |
|
|
1815 |
applyIntoSmalltalk
|
|
1816 |
|
|
1817 |
Parser evaluate:(instanceDefinition).
|
|
1818 |
Parser evaluate:(classDefinition).
|
|
1819 |
|
|
1820 |
!
|
|
1821 |
|
1674
|
1822 |
basicRemoveMethodNamed:aMethodName ifAbsent:aBlock
|
1268
|
1823 |
(self blockedMethodsIncludeMethodName:aMethodName) ifTrue:[
|
1674
|
1824 |
^ aBlock value
|
1268
|
1825 |
]. "the receiver does not know this method!!"
|
|
1826 |
|
|
1827 |
self addBlockedMethodNamed:aMethodName.
|
|
1828 |
|
|
1829 |
(self overriddenChangesIncludesMethodName:aMethodName) ifTrue:[
|
1674
|
1830 |
self removeOverriddenMethodNamed:aMethodName
|
1268
|
1831 |
].
|
|
1832 |
!
|
|
1833 |
|
1226
|
1834 |
changeSet
|
|
1835 |
| theClass |
|
1268
|
1836 |
(theClass := self classInSmalltalk) ifNil:[
|
1674
|
1837 |
^ ChangeSet new
|
1226
|
1838 |
].
|
|
1839 |
|
|
1840 |
theClass autoload.
|
|
1841 |
|
|
1842 |
^ ChangeSet forExistingClass:theClass
|
|
1843 |
!
|
|
1844 |
|
1268
|
1845 |
classInSmalltalk
|
|
1846 |
self isInSmalltalk ifTrue:[
|
1674
|
1847 |
^ Smalltalk classNamed:name
|
1268
|
1848 |
].
|
|
1849 |
|
|
1850 |
^ nil
|
1226
|
1851 |
!
|
|
1852 |
|
1277
|
1853 |
classSide
|
|
1854 |
"an interface to the class side of the receiver"
|
|
1855 |
^ ClassSide instanceSide:self.
|
|
1856 |
!
|
|
1857 |
|
1674
|
1858 |
definesSelector:aSelector
|
1277
|
1859 |
^ package definesSelector:aSelector forClassNamed:name
|
|
1860 |
!
|
|
1861 |
|
1268
|
1862 |
isInSmalltalk
|
|
1863 |
"if evaluates to false, it should not be in Smalltalk."
|
|
1864 |
| classInSmalltalk|
|
|
1865 |
((package packagedClassNamed:name) == self) ifFalse:[
|
1674
|
1866 |
^ false.
|
1268
|
1867 |
].
|
|
1868 |
|
|
1869 |
^ (package isDependentOnClassNamed:name) and:[
|
1674
|
1870 |
(classInSmalltalk := Smalltalk classNamed:name) notNil and:[
|
|
1871 |
(classInSmalltalk package == package name)
|
|
1872 |
].
|
1268
|
1873 |
].
|
|
1874 |
!
|
|
1875 |
|
|
1876 |
markDirty
|
|
1877 |
^ package markDirty
|
|
1878 |
!
|
|
1879 |
|
1674
|
1880 |
overriddenChangesIncludesMethodName:aMethodName
|
|
1881 |
^ package overriddenChangesIncludesMethodName:aMethodName forClassNamed:name
|
1277
|
1882 |
!
|
|
1883 |
|
|
1884 |
packagedMethods
|
|
1885 |
| isMyClassInSmalltalkGone possibleClassRemoved classInSmalltalk definedMethods packagedMethodsInClass |
|
|
1886 |
|
|
1887 |
possibleClassRemoved := ClassRemoveChange::ClassBeingRemovedQuery query.
|
|
1888 |
isMyClassInSmalltalkGone := possibleClassRemoved notNil.
|
|
1889 |
|
|
1890 |
isMyClassInSmalltalkGone ifTrue:[
|
1674
|
1891 |
definedMethods := possibleClassRemoved methodDictionary copy values select:[:aMethod |
|
|
1892 |
self definesSelector:aMethod name
|
|
1893 |
].
|
|
1894 |
|
|
1895 |
^ definedMethods collect:[:aMethod |
|
|
1896 |
package newPackagedMethodWithMethod:aMethod
|
|
1897 |
].
|
1277
|
1898 |
].
|
|
1899 |
packagedMethodsInClass := (package packagedMethods at:name ifAbsent:[Dictionary new]).
|
|
1900 |
|
|
1901 |
(classInSmalltalk := Smalltalk classNamed: name) ifNil:[
|
1674
|
1902 |
^ packagedMethodsInClass
|
1277
|
1903 |
].
|
|
1904 |
|
1674
|
1905 |
definedMethods := classInSmalltalk methodDictionary copy values select:[:aMethod |
|
|
1906 |
self definesSelector:aMethod name
|
1277
|
1907 |
].
|
|
1908 |
"get from package or create on the fly packaged methods"
|
|
1909 |
^ definedMethods collect:[:aMethod |
|
1674
|
1910 |
packagedMethodsInClass at:aMethod name ifAbsent:[
|
|
1911 |
package newPackagedMethodWithMethod:aMethod
|
|
1912 |
].
|
1277
|
1913 |
].
|
1268
|
1914 |
!
|
|
1915 |
|
1674
|
1916 |
removeBlockedMethodNamed:aMethodName
|
1268
|
1917 |
^ package removeBlockedMethodNamed:aMethodName forClassNamed:name
|
|
1918 |
!
|
|
1919 |
|
|
1920 |
removeFromPackage
|
|
1921 |
^ package basicRemoveClassNamed:name
|
|
1922 |
!
|
|
1923 |
|
1277
|
1924 |
removeFromSystem
|
|
1925 |
| class |
|
|
1926 |
self removeFromPackage.
|
|
1927 |
(class := self classInSmalltalk) ifNotNil:[
|
1674
|
1928 |
class removeFromSystem.
|
1277
|
1929 |
].
|
|
1930 |
!
|
|
1931 |
|
1674
|
1932 |
removeOverriddenMethodNamed:aMethodName
|
1268
|
1933 |
^ package removeOverriddenMethodNamed:aMethodName forClassNamed:name.
|
1226
|
1934 |
! !
|
|
1935 |
|
|
1936 |
!Package::PackagedClass methodsFor:'change & update'!
|
|
1937 |
|
|
1938 |
update:something with:aParameter from:changedObject
|
1268
|
1939 |
| definition|
|
|
1940 |
(changedObject == self classInSmalltalk) ifTrue:[
|
1674
|
1941 |
changedObject isLoaded ifTrue:[
|
|
1942 |
changedObject removeDependent:self. "dont need you any more"
|
|
1943 |
definition := changedObject definition.
|
|
1944 |
].
|
1226
|
1945 |
].
|
|
1946 |
! !
|
|
1947 |
|
|
1948 |
!Package::PackagedClass methodsFor:'printing'!
|
|
1949 |
|
|
1950 |
printOn:aStream
|
|
1951 |
aStream nextPutAll:'(PackagedClass named:#', name, ')'.
|
|
1952 |
! !
|
|
1953 |
|
|
1954 |
!Package::PackagedClass methodsFor:'queries'!
|
|
1955 |
|
1674
|
1956 |
blockedMethodsIncludeMethodName:aMethodName
|
|
1957 |
^ package blockedMethodsIncludeMethodName:aMethodName forClassNamed:name.
|
1268
|
1958 |
!
|
|
1959 |
|
1226
|
1960 |
isLoaded
|
1268
|
1961 |
^ self classInSmalltalk isLoaded.
|
|
1962 |
!
|
|
1963 |
|
|
1964 |
isPrivate
|
|
1965 |
"there may be a better way of doing this... but i cannot get this information
|
|
1966 |
out from the image as this class may not implemented!!"
|
|
1967 |
| readStream |
|
|
1968 |
self isInSmalltalk ifTrue:[
|
1674
|
1969 |
^ self classInSmalltalk isPrivate.
|
1268
|
1970 |
].
|
|
1971 |
readStream := ((Parser parseExpression:instanceDefinition) selector readStream).
|
|
1972 |
|
|
1973 |
[readStream atEnd] whileFalse:[
|
1674
|
1974 |
((readStream upTo:$:) asSymbol == #privateIn:) ifTrue:[
|
|
1975 |
^ true
|
|
1976 |
].
|
1268
|
1977 |
].
|
|
1978 |
|
|
1979 |
^ false
|
1226
|
1980 |
! !
|
|
1981 |
|
1277
|
1982 |
!Package::PackagedClass::ClassSide class methodsFor:'instance creation'!
|
|
1983 |
|
|
1984 |
instanceSide:aPackagedClass
|
|
1985 |
^ self basicNew instanceSide:aPackagedClass
|
|
1986 |
! !
|
|
1987 |
|
|
1988 |
!Package::PackagedClass::ClassSide methodsFor:'accessing'!
|
|
1989 |
|
|
1990 |
instanceSide
|
|
1991 |
"return the value of the instance variable 'instanceSide' (automatically generated)"
|
|
1992 |
|
|
1993 |
^ instanceSide
|
|
1994 |
!
|
|
1995 |
|
|
1996 |
instanceSide:something
|
|
1997 |
"set the value of the instance variable 'instanceSide' (automatically generated)"
|
|
1998 |
|
|
1999 |
instanceSide := something.
|
|
2000 |
!
|
|
2001 |
|
|
2002 |
name
|
|
2003 |
^ (instanceSide name, ' class') asSymbol
|
|
2004 |
!
|
|
2005 |
|
|
2006 |
package
|
|
2007 |
^ instanceSide package
|
|
2008 |
! !
|
|
2009 |
|
|
2010 |
!Package::PackagedClass::ClassSide methodsFor:'api'!
|
|
2011 |
|
1674
|
2012 |
addBlockedMethodNamed:aMethodName
|
1277
|
2013 |
^ self package addBlockedMethodNamed:aMethodName forClassNamed:self name
|
|
2014 |
!
|
|
2015 |
|
1674
|
2016 |
addMethodNamed:aMethodName
|
1277
|
2017 |
| aPackagedMethod |
|
|
2018 |
(self blockedMethodsIncludeMethodName:aMethodName) ifTrue:[
|
1674
|
2019 |
self removeBlockedMethodNamed:aMethodName.
|
|
2020 |
self markDirty.
|
|
2021 |
^ aPackagedMethod.
|
1277
|
2022 |
].
|
|
2023 |
|
|
2024 |
(self overriddenChangesIncludesMethodName:aMethodName) ifTrue:[
|
|
2025 |
"it should not be consider overriden anymore has the method has just been
|
|
2026 |
added to the receiver!! And we dont need to add it as an extra method either
|
|
2027 |
as i now am a 'holder for this method!!' But to show this i need to mark myself dirty"
|
1674
|
2028 |
self markDirty.
|
|
2029 |
self removeOverriddenMethodNamed:aMethodName.
|
|
2030 |
^ aPackagedMethod.
|
1277
|
2031 |
].
|
|
2032 |
|
|
2033 |
"if i am here the method is in effect added as the package the receiver is related to
|
|
2034 |
knows the class and does not include any blocked methods for the method aMethodName"
|
|
2035 |
!
|
|
2036 |
|
1674
|
2037 |
basicRemoveMethodNamed:aMethodName ifAbsent:aBlock
|
1277
|
2038 |
(self blockedMethodsIncludeMethodName:aMethodName) ifTrue:[
|
1674
|
2039 |
^ aBlock value
|
1277
|
2040 |
]. "the receiver does not know this method!!"
|
|
2041 |
|
|
2042 |
self addBlockedMethodNamed:aMethodName.
|
|
2043 |
|
|
2044 |
(self overriddenChangesIncludesMethodName:aMethodName) ifTrue:[
|
1674
|
2045 |
self removeOverriddenMethodNamed:aMethodName
|
1277
|
2046 |
].
|
|
2047 |
!
|
|
2048 |
|
1674
|
2049 |
blockedMethodsIncludeMethodName:aMethodName
|
|
2050 |
^ self package blockedMethodsIncludeMethodName:aMethodName forClassNamed:self name.
|
1277
|
2051 |
!
|
|
2052 |
|
|
2053 |
markDirty
|
|
2054 |
^ self package markDirty
|
|
2055 |
!
|
|
2056 |
|
1674
|
2057 |
overriddenChangesIncludesMethodName:aMethodName
|
|
2058 |
^ self package overriddenChangesIncludesMethodName:aMethodName forClassNamed:self name
|
1277
|
2059 |
!
|
|
2060 |
|
1674
|
2061 |
removeBlockedMethodNamed:aMethodName
|
1277
|
2062 |
^ self package removeBlockedMethodNamed:aMethodName forClassNamed:self name
|
|
2063 |
!
|
|
2064 |
|
1674
|
2065 |
removeOverriddenMethodNamed:aMethodName
|
1277
|
2066 |
^ self package removeOverriddenMethodNamed:aMethodName forClassNamed:self name.
|
|
2067 |
! !
|
|
2068 |
|
1226
|
2069 |
!Package::PackagedMethod class methodsFor:'instance creation'!
|
|
2070 |
|
1674
|
2071 |
name:aMethodName ownedClassName: aClassName category:aCategory package:aPackage source:source
|
1277
|
2072 |
self assert:(aClassName isSymbol).
|
|
2073 |
self assert:(aMethodName isSymbol).
|
1674
|
2074 |
^ self basicNew name:aMethodName ownedClassName: aClassName category:aCategory package:aPackage source:source
|
1226
|
2075 |
! !
|
|
2076 |
|
|
2077 |
!Package::PackagedMethod methodsFor:'accessing'!
|
|
2078 |
|
|
2079 |
category
|
1268
|
2080 |
(self isInSmalltalk) ifTrue:[
|
1674
|
2081 |
^ self method category.
|
1226
|
2082 |
].
|
|
2083 |
^ nil.
|
|
2084 |
!
|
|
2085 |
|
1268
|
2086 |
currentPackageOwner
|
|
2087 |
| class method |
|
|
2088 |
class := (Smalltalk classNamed:ownedClassName).
|
|
2089 |
class ifNil:[
|
1674
|
2090 |
^ nil.
|
1268
|
2091 |
].
|
|
2092 |
method := class compiledMethodAt:self name.
|
|
2093 |
|
|
2094 |
method ifNil:[
|
1674
|
2095 |
^ nil
|
1268
|
2096 |
].
|
|
2097 |
|
|
2098 |
^ method package
|
|
2099 |
!
|
|
2100 |
|
|
2101 |
isCommitted
|
|
2102 |
"return the value of the instance variable 'isCommitted' (automatically generated)"
|
|
2103 |
|
|
2104 |
^ isCommitted
|
|
2105 |
!
|
|
2106 |
|
1226
|
2107 |
methodInImage
|
|
2108 |
| myClass |
|
|
2109 |
myClass := Smalltalk classNamed:ownedClassName.
|
|
2110 |
myClass ifNil:[^ nil].
|
|
2111 |
|
|
2112 |
^ myClass compiledMethodAt:self name.
|
|
2113 |
!
|
|
2114 |
|
|
2115 |
name
|
|
2116 |
"return the value of the instance variable 'name' (automatically generated)"
|
|
2117 |
|
|
2118 |
^ name
|
|
2119 |
!
|
|
2120 |
|
|
2121 |
name:something
|
|
2122 |
"set the value of the instance variable 'name' (automatically generated)"
|
|
2123 |
|
|
2124 |
name := something.
|
|
2125 |
!
|
|
2126 |
|
1674
|
2127 |
name:nameArg ownedClassName:classNameArg category:categoryArg package:packageArg source:sourceArg
|
1268
|
2128 |
name := nameArg.
|
|
2129 |
ownedClassName := classNameArg.
|
|
2130 |
category := categoryArg.
|
|
2131 |
package := packageArg.
|
|
2132 |
source := sourceArg.
|
|
2133 |
!
|
|
2134 |
|
1226
|
2135 |
ownedClass
|
1674
|
2136 |
^ Compiler evaluate:ownedClassName
|
|
2137 |
in:nil
|
|
2138 |
receiver:nil
|
|
2139 |
notifying:nil
|
|
2140 |
logged:false
|
|
2141 |
ifFail:[nil]
|
|
2142 |
compile:false
|
1226
|
2143 |
|
|
2144 |
|
|
2145 |
|
|
2146 |
"
|
1674
|
2147 |
(self new ownedClassName:'Integer') ownedClass
|
1226
|
2148 |
"
|
|
2149 |
!
|
|
2150 |
|
|
2151 |
ownedClassName
|
|
2152 |
"return the value of the instance variable 'className' (automatically generated)"
|
|
2153 |
|
|
2154 |
^ ownedClassName
|
|
2155 |
!
|
|
2156 |
|
|
2157 |
ownedClassName:something
|
|
2158 |
"set the value of the instance variable 'className' (automatically generated)"
|
1277
|
2159 |
self assert:(something isSymbol).
|
1226
|
2160 |
ownedClassName := something.
|
|
2161 |
!
|
|
2162 |
|
1268
|
2163 |
ownedClassShortName
|
|
2164 |
"copied from ClassDescription>>nameWithoutPrefix "
|
|
2165 |
|nm idx|
|
|
2166 |
|
|
2167 |
nm := self ownedClassName.
|
|
2168 |
idx := nm lastIndexOf:$:.
|
|
2169 |
idx == 0 ifTrue:[
|
1674
|
2170 |
^ nm
|
1268
|
2171 |
].
|
|
2172 |
^ (nm copyFrom:idx+1) asSymbol. "asSymbol was added"
|
|
2173 |
!
|
|
2174 |
|
1226
|
2175 |
package
|
|
2176 |
"return the value of the instance variable 'package' (automatically generated)"
|
|
2177 |
|
|
2178 |
^ package
|
|
2179 |
!
|
|
2180 |
|
|
2181 |
package:something
|
|
2182 |
"set the value of the instance variable 'package' (automatically generated)"
|
|
2183 |
|
|
2184 |
package := something.
|
|
2185 |
!
|
|
2186 |
|
|
2187 |
source
|
|
2188 |
source isNil ifTrue:[
|
1674
|
2189 |
self isInSmalltalk ifFalse:[
|
|
2190 |
^ '** no method - no source **' copy.
|
|
2191 |
].
|
|
2192 |
source := self method source.
|
1226
|
2193 |
].
|
|
2194 |
|
|
2195 |
^ source.
|
|
2196 |
!
|
|
2197 |
|
|
2198 |
source:something
|
|
2199 |
"set the value of the instance variable 'source' (automatically generated)"
|
|
2200 |
|
|
2201 |
source := something.
|
|
2202 |
! !
|
|
2203 |
|
|
2204 |
!Package::PackagedMethod methodsFor:'fileIn/Out'!
|
|
2205 |
|
1674
|
2206 |
fileOutOn:aWriteStream
|
1226
|
2207 |
|
|
2208 |
aWriteStream nextPut:$!!.
|
|
2209 |
aWriteStream nextPutAll:ownedClassName asString.
|
|
2210 |
aWriteStream nextPutAll:' methodsFor:'.
|
|
2211 |
aWriteStream nextPut:$'.
|
|
2212 |
aWriteStream nextPutAll:(self category).
|
|
2213 |
aWriteStream nextPut:$'.
|
|
2214 |
aWriteStream nextPut:$!!.
|
|
2215 |
aWriteStream cr.
|
|
2216 |
|
|
2217 |
aWriteStream nextPutAll:self source.
|
|
2218 |
aWriteStream nextPut:$!!.
|
|
2219 |
aWriteStream cr.
|
|
2220 |
! !
|
|
2221 |
|
|
2222 |
!Package::PackagedMethod methodsFor:'method - api'!
|
|
2223 |
|
|
2224 |
mclass
|
|
2225 |
^ (Smalltalk classNamed:ownedClassName)
|
|
2226 |
!
|
|
2227 |
|
1268
|
2228 |
removeFromPackage
|
|
2229 |
^ package removedMethodNamed:name forClassNamed:ownedClassName ifAbsent:[nil]
|
|
2230 |
!
|
|
2231 |
|
|
2232 |
removeFromSystem
|
|
2233 |
| classInSmalltalk |
|
|
2234 |
self removeFromPackage.
|
|
2235 |
(self isInSmalltalk) ifTrue:[
|
1674
|
2236 |
classInSmalltalk := Smalltalk classNamed:ownedClassName.
|
|
2237 |
classInSmalltalk ifNotNil:[
|
|
2238 |
classInSmalltalk removeSelector:name.
|
|
2239 |
]
|
1268
|
2240 |
].
|
|
2241 |
!
|
|
2242 |
|
1226
|
2243 |
selector
|
|
2244 |
^ name
|
|
2245 |
! !
|
|
2246 |
|
|
2247 |
!Package::PackagedMethod methodsFor:'printing'!
|
|
2248 |
|
|
2249 |
printOn:aStream
|
|
2250 |
self isLoose ifTrue:[
|
1674
|
2251 |
aStream nextPutAll:'LooseMethod:'.
|
1226
|
2252 |
] ifFalse:[
|
1674
|
2253 |
aStream nextPutAll:'Method:'.
|
1226
|
2254 |
].
|
|
2255 |
|
1268
|
2256 |
aStream nextPutAll:self ownedClassShortName.
|
1226
|
2257 |
aStream nextPutAll:'->', name printString.
|
|
2258 |
aStream cr.
|
|
2259 |
! !
|
|
2260 |
|
|
2261 |
!Package::PackagedMethod methodsFor:'queries'!
|
|
2262 |
|
1268
|
2263 |
isInSmalltalk
|
|
2264 |
^ (package overriddenChangesIncludesMethodName:name forClassNamed:ownedClassName) not and:[
|
1674
|
2265 |
(package blockedMethodsIncludeMethodName:name forClassNamed:ownedClassName) not
|
1268
|
2266 |
]
|
|
2267 |
|
|
2268 |
|
1226
|
2269 |
!
|
|
2270 |
|
|
2271 |
isLoose
|
1268
|
2272 |
^ (package includesPackagedClassNamed:ownedClassName) not
|
1226
|
2273 |
!
|
|
2274 |
|
|
2275 |
isTheSameAsInImage
|
|
2276 |
| myClass method|
|
|
2277 |
(myClass := (Smalltalk at:ownedClassName)) ifNotNil:[
|
1674
|
2278 |
(method :=(myClass methodDictionary at:name ifAbsent:[nil])) ifNotNil:[
|
|
2279 |
^ method source = source. "there is a more efficient way but i have forgotten"
|
|
2280 |
].
|
|
2281 |
|
1226
|
2282 |
].
|
|
2283 |
^ false.
|
|
2284 |
!
|
|
2285 |
|
|
2286 |
method
|
|
2287 |
| myClass|
|
|
2288 |
(myClass := self ownedClass) ifNotNil:[
|
1674
|
2289 |
^ (myClass methodDictionary at:name ifAbsent:[nil]).
|
1226
|
2290 |
].
|
1674
|
2291 |
self halt.
|
1226
|
2292 |
^ nil.
|
|
2293 |
! !
|
|
2294 |
|
|
2295 |
!Package::PackagedScript class methodsFor:'instance creation'!
|
|
2296 |
|
|
2297 |
string:aString receiver:aPackage
|
|
2298 |
^ self basicNew string:aString receiver:aPackage
|
|
2299 |
! !
|
|
2300 |
|
|
2301 |
!Package::PackagedScript methodsFor:'accessing'!
|
|
2302 |
|
|
2303 |
getString
|
|
2304 |
^ string
|
|
2305 |
!
|
|
2306 |
|
1674
|
2307 |
string:stringArg receiver:receiverArg
|
1226
|
2308 |
"set instance variables (automatically generated)"
|
|
2309 |
|
|
2310 |
string := stringArg.
|
|
2311 |
receiver := receiverArg.
|
|
2312 |
! !
|
|
2313 |
|
|
2314 |
!Package::PackagedScript methodsFor:'evaluation'!
|
|
2315 |
|
|
2316 |
evaluate
|
|
2317 |
^ Compiler evaluate:string receiver:receiver.
|
|
2318 |
! !
|
|
2319 |
|
|
2320 |
!Package::PackagedScript methodsFor:'printing'!
|
|
2321 |
|
|
2322 |
printOn:aStream
|
|
2323 |
aStream nextPutAll:'Compiler evaluate:'.
|
|
2324 |
aStream nextPut:$'.
|
|
2325 |
aStream nextPutAll:string.
|
|
2326 |
aStream nextPut:$'.
|
|
2327 |
aStream nextPutAll:' receiver:('.
|
|
2328 |
aStream nextPutAll:(receiver printString).
|
|
2329 |
aStream nextPut:$).
|
|
2330 |
|
|
2331 |
"
|
1674
|
2332 |
self string:'1 + 1' receiver:nil
|
1226
|
2333 |
"
|
|
2334 |
! !
|
|
2335 |
|
|
2336 |
!Package class methodsFor:'documentation'!
|
|
2337 |
|
|
2338 |
version
|
1674
|
2339 |
^ '$Header: /cvs/stx/stx/libbasic3/packages/Package.st,v 1.9 2006-08-24 08:38:50 cg Exp $'
|
1226
|
2340 |
! !
|