1226
|
1 |
"{ Package: 'stx:libbasic3' }"
|
|
2 |
|
|
3 |
"{ NameSpace: Packages }"
|
|
4 |
|
|
5 |
AbstractPackage subclass:#Package
|
|
6 |
instanceVariableNames:'packageHandler packagedClasses packagedMethods packageComment
|
|
7 |
prerequisites scripts isDirty isInstalled packageVersion
|
|
8 |
overriddenChanges blockedMethods'
|
|
9 |
classVariableNames:''
|
|
10 |
poolDictionaries:''
|
|
11 |
category:'Package'
|
|
12 |
!
|
|
13 |
|
|
14 |
Package class instanceVariableNames:'CurrentPackage'
|
|
15 |
|
|
16 |
"
|
|
17 |
No other class instance variables are inherited by this class.
|
|
18 |
"
|
|
19 |
!
|
|
20 |
|
|
21 |
Object subclass:#PackagedClass
|
|
22 |
instanceVariableNames:'name package instanceDefinition classDefinition
|
|
23 |
instanceVariableNames classVariableNames
|
|
24 |
classInstanceVariableNames poolDictionaries category'
|
|
25 |
classVariableNames:''
|
|
26 |
poolDictionaries:''
|
|
27 |
privateIn:Package
|
|
28 |
!
|
|
29 |
|
|
30 |
Object subclass:#PackagedMethod
|
|
31 |
instanceVariableNames:'name package source ownedClassName'
|
|
32 |
classVariableNames:''
|
|
33 |
poolDictionaries:''
|
|
34 |
privateIn:Package
|
|
35 |
!
|
|
36 |
|
|
37 |
Object subclass:#PackagedScript
|
|
38 |
instanceVariableNames:'string receiver'
|
|
39 |
classVariableNames:''
|
|
40 |
poolDictionaries:''
|
|
41 |
privateIn:Package
|
|
42 |
!
|
|
43 |
|
|
44 |
!Package class methodsFor:'documentation'!
|
|
45 |
|
|
46 |
documentation
|
|
47 |
"
|
|
48 |
documentation to be added.
|
|
49 |
|
|
50 |
[author:]
|
|
51 |
(james@miraculix)
|
|
52 |
|
|
53 |
[instance variables:]
|
|
54 |
|
|
55 |
blockedMethods <Dictionary>
|
|
56 |
A reference of methods that the receiver is NOT responsible for
|
|
57 |
but the receiver is responsible for the method's class. It usage is
|
|
58 |
the same as a filter would be.
|
|
59 |
|
|
60 |
overriddenChanges <Dictionary1><Dictionary2><Dictionary3>
|
|
61 |
This variable helps the receiver keep its original state. When a
|
|
62 |
method changes it is held here so we can get the original. So the package
|
|
63 |
is still responsible for the overridden changes.
|
|
64 |
|
|
65 |
There are two way items can become added to overriddenChanges:
|
|
66 |
1) through loading packages - too many of these may not be desirable.
|
|
67 |
2) through editing a package - default package 'overrides it!!'
|
|
68 |
|
|
69 |
DESIGN: it is designed with dictionaries containing dictionaries as - for the
|
|
70 |
time being - to cope with different types of change. At the moment being
|
|
71 |
methodChanges (and soon classChanges). It is easier to search for changes
|
|
72 |
by using this hierarchy of dictionaries, and - i think - it is quite
|
|
73 |
extendable.
|
|
74 |
The only problem i can see with it is lingering dictionaries which are not deleted
|
|
75 |
when they contain nothing.
|
|
76 |
|
|
77 |
|
|
78 |
|
|
79 |
|
|
80 |
|
|
81 |
[class variables:]
|
|
82 |
|
|
83 |
[see also:]
|
|
84 |
|
|
85 |
"
|
|
86 |
!
|
|
87 |
|
|
88 |
examples
|
|
89 |
"
|
|
90 |
|
|
91 |
more examples to be added:
|
|
92 |
[exBegin]
|
|
93 |
... add code fragment for
|
|
94 |
... executable example here ...
|
|
95 |
[exEnd]
|
|
96 |
"
|
|
97 |
!
|
|
98 |
|
|
99 |
history
|
|
100 |
"Created: / 31.3.2003 / 16:45:04 / james"
|
|
101 |
! !
|
|
102 |
|
|
103 |
!Package class methodsFor:'instance creation'!
|
|
104 |
|
|
105 |
named:aString
|
|
106 |
"create a new package named aString "
|
|
107 |
^ self named:aString addToManager:nil. "or 'self defaultPackageManager'"
|
|
108 |
!
|
|
109 |
|
|
110 |
named:aString addToManager:aManager
|
|
111 |
^ self named:aString withClasses:nil withMethods:nil addToManager:aManager
|
|
112 |
!
|
|
113 |
|
|
114 |
named:aString withClasses:classes
|
|
115 |
^ self named:aString withClasses:classes withMethods:nil addToManager:nil
|
|
116 |
!
|
|
117 |
|
|
118 |
named:aString withClasses:classes withMethods:methods addToManager:aManager
|
|
119 |
"create a new package named aString "
|
|
120 |
|anInstance |
|
|
121 |
anInstance := self new name:aString.
|
|
122 |
classes ifNotNil:[
|
|
123 |
anInstance addedClasses:classes.
|
|
124 |
].
|
|
125 |
methods ifNotNil:[
|
|
126 |
anInstance addedMethods:methods.
|
|
127 |
].
|
|
128 |
|
|
129 |
aManager ifNotNil:[
|
|
130 |
aManager addPackage:anInstance.
|
|
131 |
].
|
|
132 |
^ anInstance
|
|
133 |
!
|
|
134 |
|
|
135 |
named:aString withMethods:methods
|
|
136 |
^ self named:aString withClasses:nil withMethods:methods addToManager:nil
|
|
137 |
! !
|
|
138 |
|
|
139 |
!Package class methodsFor:'constant'!
|
|
140 |
|
|
141 |
classChangeNamespace
|
|
142 |
"just returns a constant."
|
|
143 |
^ #ClassChange
|
|
144 |
!
|
|
145 |
|
|
146 |
emptyDictionaryConstant
|
|
147 |
"could eventually be a variable in class... but i doubt it would buy is
|
|
148 |
much time savings..."
|
|
149 |
^ Dictionary new
|
|
150 |
!
|
|
151 |
|
|
152 |
methodChangeNamespace
|
|
153 |
"just returns a constant."
|
|
154 |
^ #MethodChange
|
|
155 |
! !
|
|
156 |
|
|
157 |
!Package class methodsFor:'defaults'!
|
|
158 |
|
|
159 |
defaultBlockedMethodsCollection
|
|
160 |
^ Dictionary new
|
|
161 |
!
|
|
162 |
|
|
163 |
defaultOverriddenChangesCollection
|
|
164 |
"a dictionary of sets. The keys are the classes and
|
|
165 |
the sets are a collection of selectors!!"
|
|
166 |
^ Dictionary new
|
|
167 |
!
|
|
168 |
|
|
169 |
defaultPackagedClassesCollection
|
|
170 |
^ Dictionary new
|
|
171 |
!
|
|
172 |
|
|
173 |
defaultPackagedMethodsCollection
|
|
174 |
^ Dictionary new
|
|
175 |
!
|
|
176 |
|
|
177 |
defaultPrerequisiteCollection
|
|
178 |
^ PrerequisiteCollection new
|
|
179 |
!
|
|
180 |
|
|
181 |
defaultScriptsCollection
|
|
182 |
^ IdentityDictionary new
|
|
183 |
!
|
|
184 |
|
|
185 |
newDefaultPackage
|
|
186 |
^ self named:#'__NoProject__'.
|
|
187 |
!
|
|
188 |
|
|
189 |
packageHandlerClass
|
|
190 |
^ StxPackageHandler
|
|
191 |
!
|
|
192 |
|
|
193 |
packageManager
|
|
194 |
^ self packageManagerClass smalltalkPackageManager.
|
|
195 |
!
|
|
196 |
|
|
197 |
packageManagerClass
|
|
198 |
^ PackageManager.
|
|
199 |
! !
|
|
200 |
|
|
201 |
!Package class methodsFor:'private - instance creation'!
|
|
202 |
|
|
203 |
new
|
|
204 |
"creates a new package and initialize's"
|
|
205 |
| anInstance |
|
|
206 |
anInstance := self basicNew initialize.
|
|
207 |
^ anInstance
|
|
208 |
! !
|
|
209 |
|
|
210 |
!Package methodsFor:'accessing'!
|
|
211 |
|
|
212 |
blockedMethods
|
|
213 |
"return the value of the instance variable 'blockedMethods' (automatically generated)"
|
|
214 |
|
|
215 |
^ blockedMethods
|
|
216 |
!
|
|
217 |
|
|
218 |
blockedMethods:something
|
|
219 |
"set the value of the instance variable 'blockedMethods' (automatically generated)"
|
|
220 |
|
|
221 |
blockedMethods := something.
|
|
222 |
!
|
|
223 |
|
|
224 |
classNamed:aSymbol
|
|
225 |
"return the class named aSymbol if it exists in the receiver. Otherwise
|
|
226 |
return nil"
|
|
227 |
(self includesClassNamed:aSymbol) ifTrue:[
|
|
228 |
^ Smalltalk classNamed:aSymbol
|
|
229 |
].
|
|
230 |
|
|
231 |
^ nil
|
|
232 |
!
|
|
233 |
|
|
234 |
classNames
|
|
235 |
^ self packagedClasses values collect:[:aPackagedClass |
|
|
236 |
aPackagedClass name
|
|
237 |
].
|
|
238 |
!
|
|
239 |
|
|
240 |
classPrerequisites
|
|
241 |
^ prerequisites select:[:aPre |
|
|
242 |
aPre isClassPrerequisite
|
|
243 |
].
|
|
244 |
|
|
245 |
!
|
|
246 |
|
|
247 |
filename
|
|
248 |
"return the value of the instance variable 'filename' (automatically generated)"
|
|
249 |
|
|
250 |
^ packageHandler filename
|
|
251 |
!
|
|
252 |
|
|
253 |
isDirty
|
|
254 |
"has the receiver been changed by adding scripts or added classes since the
|
|
255 |
time it is loaded. This instance variable is NOT affected by changes in the image!!"
|
|
256 |
|
|
257 |
^ isDirty "? true" "not needed because set by initialize"
|
|
258 |
!
|
|
259 |
|
|
260 |
isDirty:aBoolean
|
|
261 |
isDirty := aBoolean
|
|
262 |
!
|
|
263 |
|
|
264 |
isInstalled
|
|
265 |
"return the value of the instance variable 'isInstalled' (automatically generated)"
|
|
266 |
|
|
267 |
^ isInstalled
|
|
268 |
!
|
|
269 |
|
|
270 |
isInstalled:something
|
|
271 |
"set the value of the instance variable 'isInstalled' (automatically generated)"
|
|
272 |
|
|
273 |
isInstalled := something.
|
|
274 |
!
|
|
275 |
|
|
276 |
isOverridden
|
|
277 |
^ overriddenChanges notEmpty
|
|
278 |
!
|
|
279 |
|
|
280 |
looseMethodAtClass:aClassName atMethodName:aMethodName
|
|
281 |
self looseMethods do:[:aLooseMethod |
|
|
282 |
((aLooseMethod name == aMethodName) and:[
|
|
283 |
aLooseMethod className == aClassName]) ifTrue:[
|
|
284 |
^ aLooseMethod
|
|
285 |
].
|
|
286 |
|
|
287 |
].
|
|
288 |
^ nil
|
|
289 |
!
|
|
290 |
|
|
291 |
looseMethods
|
|
292 |
| col mthdInImage |
|
|
293 |
col := OrderedCollection new.
|
|
294 |
self packagedMethods keysAndValuesDo:[:key :aDic | | looseMethodsInKey|
|
|
295 |
|
|
296 |
looseMethodsInKey := aDic keysAndValuesDo:[:selector :aPackagedMethod | |collectValue|
|
|
297 |
aPackagedMethod isLoose ifTrue:[
|
|
298 |
mthdInImage := aPackagedMethod methodInImage.
|
|
299 |
mthdInImage ifNil:[
|
|
300 |
col add:aPackagedMethod.
|
|
301 |
] ifNotNil:[
|
|
302 |
col add:mthdInImage.
|
|
303 |
].
|
|
304 |
].
|
|
305 |
].
|
|
306 |
|
|
307 |
].
|
|
308 |
|
|
309 |
^ col.
|
|
310 |
!
|
|
311 |
|
|
312 |
packageComment
|
|
313 |
"return the value of the instance variable 'packageComment' (automatically generated)"
|
|
314 |
|
|
315 |
^ packageComment
|
|
316 |
!
|
|
317 |
|
|
318 |
packageComment:something
|
|
319 |
"set the value of the instance variable 'packageComment' (automatically generated)"
|
|
320 |
|
|
321 |
packageComment := something.
|
|
322 |
!
|
|
323 |
|
|
324 |
packageHandler
|
|
325 |
"return the value of the instance variable 'packageHandler' (automatically generated)"
|
|
326 |
|
|
327 |
packageHandler isNil ifTrue:[
|
|
328 |
packageHandler := PackageHandler forPackage:self.
|
|
329 |
].
|
|
330 |
^ packageHandler
|
|
331 |
!
|
|
332 |
|
|
333 |
packageHandler:something
|
|
334 |
"set the value of the instance variable 'packageHandler' (automatically generated)"
|
|
335 |
|
|
336 |
packageHandler := something.
|
|
337 |
!
|
|
338 |
|
|
339 |
packageType
|
|
340 |
^ 'STX Package' copy.
|
|
341 |
!
|
|
342 |
|
|
343 |
packageVersion
|
|
344 |
"return the value of the instance variable 'packageVersion' (automatically generated)"
|
|
345 |
|
|
346 |
^ packageVersion
|
|
347 |
!
|
|
348 |
|
|
349 |
packageVersion:something
|
|
350 |
"set the value of the instance variable 'packageVersion' (automatically generated)"
|
|
351 |
|
|
352 |
packageVersion := something.
|
|
353 |
!
|
|
354 |
|
|
355 |
packagedClasses
|
|
356 |
"return the value of the instance variable 'packagedClasses' (automatically generated)"
|
|
357 |
|
|
358 |
^ packagedClasses
|
|
359 |
!
|
|
360 |
|
|
361 |
packagedMethods
|
|
362 |
"return the value of the instance variable 'packagedMethods' (automatically generated)"
|
|
363 |
|
|
364 |
^ packagedMethods
|
|
365 |
!
|
|
366 |
|
|
367 |
prerequisites
|
|
368 |
"return the value of the instance variable 'prerequisites' (automatically generated)"
|
|
369 |
|
|
370 |
^ prerequisites
|
|
371 |
!
|
|
372 |
|
|
373 |
scripts
|
|
374 |
"return the value of the instance variable 'scripts' (automatically generated)"
|
|
375 |
|
|
376 |
^ scripts
|
|
377 |
! !
|
|
378 |
|
|
379 |
!Package methodsFor:'adding & removing'!
|
|
380 |
|
|
381 |
addBlockedMethodNamed:aMethodName forClassNamed:aClassName
|
|
382 |
^ (self blockedMethodsAt:aClassName ifAbsentPut:[Set new]) add:aMethodName.
|
|
383 |
!
|
|
384 |
|
|
385 |
addOverriddenClassChange:aPackagedClass
|
|
386 |
"add an overridden method. under #methodClassName -> #methodChangeNamespace -> #methodChange"
|
|
387 |
self
|
|
388 |
addOverriddenClassChange:aPackagedClass
|
|
389 |
byPackageNamed:(self class packageManager workingPackage) "the only way???"
|
|
390 |
!
|
|
391 |
|
|
392 |
addOverriddenClassChange:aPackagedClass byPackageNamed:byPackageName
|
|
393 |
"add an overridden method. under #package -> #className -> #classChangeNamespace -> aPackagedClass"
|
|
394 |
| className classChangeNamespace |
|
|
395 |
className := aPackagedClass name.
|
|
396 |
classChangeNamespace := self class classChangeNamespace.
|
|
397 |
|
|
398 |
(((overriddenChanges at:byPackageName ifAbsentPut:[Dictionary new])
|
|
399 |
at:className ifAbsentPut:[Dictionary new])
|
|
400 |
at:classChangeNamespace
|
|
401 |
ifAbsentPut:[Set new]) add:aPackagedClass
|
|
402 |
!
|
|
403 |
|
|
404 |
addOverriddenMethodChange:aPackagedMethod
|
|
405 |
"add an overridden method. under #methodClassName -> #methodChangeNamespace -> #methodChange"
|
|
406 |
self
|
|
407 |
addOverriddenMethodChange:aPackagedMethod
|
|
408 |
byPackageNamed:(self class packageManager workingPackage) "the only way???"
|
|
409 |
!
|
|
410 |
|
|
411 |
addOverriddenMethodChange:aPackagedMethod byPackageNamed:byPackageNamed
|
|
412 |
"add an overridden method. under #package -> #methodClassName -> #methodChangeNamespace -> #methodChange"
|
|
413 |
| methodClassName methodChangeNamespace |
|
|
414 |
methodClassName := aPackagedMethod ownedClassName.
|
|
415 |
methodChangeNamespace := self class methodChangeNamespace.
|
|
416 |
|
|
417 |
(((overriddenChanges at:byPackageNamed ifAbsentPut:[Dictionary new])
|
|
418 |
at:methodClassName ifAbsentPut:[Dictionary new])
|
|
419 |
at:methodChangeNamespace
|
|
420 |
ifAbsentPut:[Dictionary new]) at:aPackagedMethod name put:aPackagedMethod
|
|
421 |
!
|
|
422 |
|
|
423 |
addPackagedClass:aPackagedClass
|
|
424 |
"add or replace aPackagedClass"
|
|
425 |
packagedClasses at:aPackagedClass put:aPackagedClass
|
|
426 |
!
|
|
427 |
|
|
428 |
addPackagedClasses:somePackagedClasses
|
|
429 |
somePackagedClasses do:[:each |
|
|
430 |
self addPackagedClass:each
|
|
431 |
].
|
|
432 |
^ somePackagedClasses
|
|
433 |
!
|
|
434 |
|
|
435 |
addPackagedMethod:aPackagedMethod
|
|
436 |
"add or replace aPackagedMethod from the receiver"
|
|
437 |
^ (self packagedMethodsAt:aPackagedMethod mclass name ifAbsentPut:[Dictionary new])
|
|
438 |
at:aPackagedMethod name put:aPackagedMethod.
|
|
439 |
!
|
|
440 |
|
|
441 |
addPackagedMethods:somePackageMethods
|
|
442 |
|
|
443 |
somePackageMethods do:[:aPackageMethod |
|
|
444 |
self addPackagedMethod:aPackageMethod copy.
|
|
445 |
].
|
|
446 |
^ somePackageMethods
|
|
447 |
!
|
|
448 |
|
|
449 |
blockedMethodsAt:arg
|
|
450 |
^ (blockedMethods at:arg ifAbsent:[nil])
|
|
451 |
!
|
|
452 |
|
|
453 |
blockedMethodsAt:aClassName ifAbsentPut:anObject
|
|
454 |
^ blockedMethods at:aClassName ifAbsentPut:anObject
|
|
455 |
!
|
|
456 |
|
|
457 |
blockedMethodsRemoveKey:aKey
|
|
458 |
^ (self blockedMethodsRemoveKey:aKey ifAbsent:[nil"Q: be quiet or show error???"])
|
|
459 |
!
|
|
460 |
|
|
461 |
blockedMethodsRemoveKey:arg ifAbsent:aBlock
|
|
462 |
^ (blockedMethods removeKey:arg ifAbsent:aBlock)
|
|
463 |
!
|
|
464 |
|
|
465 |
packagedClassAt:arg
|
|
466 |
^ (packagedClasses at:arg ifAbsent:[nil])
|
|
467 |
!
|
|
468 |
|
|
469 |
packagedClassesRemoveKey:aKey ifAbsent:aBlock
|
|
470 |
^ self packagedClasses removeKey:aKey ifAbsent:aBlock
|
|
471 |
!
|
|
472 |
|
|
473 |
packagedMethodsAt:arg
|
|
474 |
^ (packagedMethods at:arg ifAbsent:[nil])
|
|
475 |
!
|
|
476 |
|
|
477 |
packagedMethodsAt:arg ifAbsent:aBlock
|
|
478 |
^ (packagedMethods at:arg ifAbsent:aBlock)
|
|
479 |
!
|
|
480 |
|
|
481 |
packagedMethodsAt:arg ifAbsentPut:aBlock
|
|
482 |
^ (packagedMethods at:arg ifAbsentPut:aBlock)
|
|
483 |
!
|
|
484 |
|
|
485 |
removeBlockedMethodNamed:aMethodName forClassNamed:aClassName
|
|
486 |
^ (self blockedMethodsAt:aClassName) remove:aMethodName.
|
|
487 |
!
|
|
488 |
|
|
489 |
removeOverriddenMethodNamed:aMethodName forClassNamed:aClassName
|
|
490 |
| classOverridenChanges methodOverridenChanges|
|
|
491 |
|
|
492 |
classOverridenChanges := (overriddenChanges
|
|
493 |
at:self class methodChangeNamespace
|
|
494 |
ifAbsent:[ ^ self"jump out of method here!!"]).
|
|
495 |
methodOverridenChanges := (classOverridenChanges
|
|
496 |
at:aClassName
|
|
497 |
ifAbsent:[ ^ self"jump out of method here!!"]).
|
|
498 |
|
|
499 |
(methodOverridenChanges
|
|
500 |
removeKey:aMethodName
|
|
501 |
ifAbsent:[self error:'trying to remove a method that does not exist!!'"should i keep this?"]).
|
|
502 |
!
|
|
503 |
|
|
504 |
scriptAt:aSymbol
|
|
505 |
^ scripts at:aSymbol ifAbsent:[PackagedScript string:(String new) receiver:self]
|
|
506 |
!
|
|
507 |
|
|
508 |
scriptAt:aSymbol put:aString
|
|
509 |
scripts at:aSymbol put:aString
|
|
510 |
! !
|
|
511 |
|
|
512 |
!Package methodsFor:'adding & removing - basic'!
|
|
513 |
|
|
514 |
basicAddMethodNamed:aMethodName forClassNamed:aClassName
|
|
515 |
"add a method to the responsibility to the receiver."
|
|
516 |
| aPackagedMethod aClass doesNotOwnClass|
|
|
517 |
|
|
518 |
(self blockedMethodsIncludeMethodName:aMethodName forClassNamed:aClassName) ifTrue:[
|
|
519 |
self removeBlockedMethodNamed:aMethodName forClassNamed:aClassName.
|
|
520 |
^ aPackagedMethod.
|
|
521 |
].
|
|
522 |
|
|
523 |
aClass := (Smalltalk classNamed:aClassName).
|
|
524 |
|
|
525 |
aClass ifNil:[self error
|
|
526 |
].
|
|
527 |
|
|
528 |
doesNotOwnClass := (self classNamed:aClassName) isNil.
|
|
529 |
|
|
530 |
doesNotOwnClass ifTrue:[| aMethod |
|
|
531 |
aMethod := aClass compiledMethodAt:aMethodName.
|
|
532 |
aPackagedMethod := (self newPackagedMethodWithMethod:aMethod).
|
|
533 |
|
|
534 |
(self packagedMethodsAt:aClassName ifAbsentPut:[Dictionary new])
|
|
535 |
at:aMethodName put:aPackagedMethod.
|
|
536 |
].
|
|
537 |
|
|
538 |
(self overriddenChangesIncludesMethodName:aMethodName forClass:aClassName) ifTrue:[
|
|
539 |
"it should not be consider overriden anymore has the method has just been
|
|
540 |
added to the receiver!!"
|
|
541 |
self removeOverriddenMethodNamed:aMethodName forClassNamed:aClassName
|
|
542 |
].
|
|
543 |
^ aPackagedMethod "if nil, the method is still to be installed. Could use a dummy here instead??"
|
|
544 |
!
|
|
545 |
|
|
546 |
basicAddPackagedClass:aPackageClass
|
|
547 |
"adds a class to the receiver.
|
|
548 |
NOTE: Does not mark the receiver as dirty.
|
|
549 |
That is the responsibility of the called of this method!!"
|
|
550 |
aPackageClass isClass ifTrue:[
|
|
551 |
self halt.
|
|
552 |
].
|
|
553 |
self packagedClasses at:aPackageClass name put:(aPackageClass).
|
|
554 |
^ aPackageClass
|
|
555 |
!
|
|
556 |
|
|
557 |
basicAddPrerequisite:aPrerequisite
|
|
558 |
prerequisites add:aPrerequisite
|
|
559 |
!
|
|
560 |
|
|
561 |
basicAddedClass:aClass
|
|
562 |
"add a representation of a class (PackagedClass) to the receiver.
|
|
563 |
Look in aClass to see if we need to add any blocked methods - this could
|
|
564 |
be done by the manager but is done locally to avoid too many message sends"
|
|
565 |
| methodDic|
|
|
566 |
self basicAddPackagedClass:(self newPackagedClass:aClass).
|
|
567 |
methodDic := aClass methodDictionary copy.
|
|
568 |
methodDic keysAndValuesDo:[:aMethodName :aMethod |
|
|
569 |
(aMethod package == self name) ifFalse:[
|
|
570 |
self addBlockedMethodNamed:aMethodName forClassNamed:aClass name
|
|
571 |
].
|
|
572 |
].
|
|
573 |
^ aClass
|
|
574 |
!
|
|
575 |
|
|
576 |
basicAddedMethod:aMethod
|
|
577 |
|
|
578 |
| aPackagedMethod aClass doesNotOwnClass aMethodName aClassName|
|
|
579 |
aMethodName := aMethod name.
|
|
580 |
(aClass := aMethod mclass) ifNil:[self error
|
|
581 |
].
|
|
582 |
aClassName := aClass name.
|
|
583 |
|
|
584 |
(self blockedMethodsIncludeMethodName:aMethodName forClassNamed:aClassName) ifTrue:[
|
|
585 |
self removeBlockedMethodNamed:aMethodName forClassNamed:aClassName.
|
|
586 |
^ aMethod.
|
|
587 |
].
|
|
588 |
|
|
589 |
doesNotOwnClass := (self classNamed:aClassName) isNil.
|
|
590 |
doesNotOwnClass ifTrue:[
|
|
591 |
aPackagedMethod := (self newPackagedMethodWithMethod:aMethod).
|
|
592 |
(self packagedMethodsAt:aClassName ifAbsentPut:[Dictionary new])
|
|
593 |
at:aMethodName put:aPackagedMethod.
|
|
594 |
].
|
|
595 |
|
|
596 |
(self overriddenChangesIncludesMethodName:aMethodName forClass:aClassName) ifTrue:[
|
|
597 |
"it should not be consider overriden anymore has the method has just been
|
|
598 |
added to the receiver!!"
|
|
599 |
self removeOverriddenMethodNamed:aMethodName forClassNamed:aClassName
|
|
600 |
].
|
|
601 |
^ aMethod "if nil, the method is still to be installed. Could use a dummy here instead??"
|
|
602 |
!
|
|
603 |
|
|
604 |
basicRemoveClassNamed:aSymbol
|
|
605 |
|
|
606 |
self packagedClassesRemoveKey:aSymbol ifAbsent:[
|
|
607 |
"how much information do i need to recover from this error?"
|
|
608 |
self raisePackageError:'Cannot remove packagedClass ', aSymbol asString,
|
|
609 |
' from package: ', name string.
|
|
610 |
].
|
|
611 |
self blockedMethodsRemoveKey:aSymbol ifAbsent:[nil "this is not always there!!"].
|
|
612 |
^ aSymbol
|
|
613 |
|
|
614 |
|
|
615 |
|
|
616 |
|
|
617 |
|
|
618 |
!
|
|
619 |
|
|
620 |
basicRemoveMethodNamed:aMethodName forClassNamed:aClassName
|
|
621 |
"note: could also create a loose method object which could be more useful"
|
|
622 |
^ self basicRemoveMethodNamed:aMethodName forClassNamed:aClassName ifAbsent:[self error.]
|
|
623 |
!
|
|
624 |
|
|
625 |
basicRemoveMethodNamed:aMethodName forClassNamed:aClassName ifAbsent:aBlock
|
|
626 |
"remove method named aMethodName from the receiver. If it is in loose methods, remove it,
|
|
627 |
if the receiver just owns the class, add it to the blockedMethods if teh blockedMethods already have it,
|
|
628 |
evaluate aBlock"
|
|
629 |
| aPackagedMethod |
|
|
630 |
aPackagedMethod :=
|
|
631 |
(self packagedMethodsAt:aClassName ifAbsent:[self class emptyDictionaryConstant "is absent now"])
|
|
632 |
removeKey:aMethodName
|
|
633 |
ifAbsent:[
|
|
634 |
(self blockedMethodsIncludeMethodName:aMethodName forClassNamed:aClassName) ifTrue:[
|
|
635 |
^ aBlock value. "the receiver does not know this method!!"
|
|
636 |
].
|
|
637 |
"i own the class of the method"
|
|
638 |
self addBlockedMethodNamed:aMethodName forClassNamed:aClassName
|
|
639 |
].
|
|
640 |
|
|
641 |
(self overriddenChangesIncludesMethodName:aMethodName forClass:aClassName) ifTrue:[
|
|
642 |
self halt:'I need to remove the overriden change here as once the method
|
|
643 |
is removed from me i dont want to know about it any more!!'.
|
|
644 |
].
|
|
645 |
|
|
646 |
^ aPackagedMethod
|
|
647 |
! !
|
|
648 |
|
|
649 |
!Package methodsFor:'api - accessing'!
|
|
650 |
|
|
651 |
changeSet
|
|
652 |
| changeSet |
|
|
653 |
changeSet := ChangeSet new.
|
|
654 |
packagedClasses do:[:aPackagedClass |
|
|
655 |
changeSet addAll:aPackagedClass changeSet
|
|
656 |
].
|
|
657 |
self looseMethods do:[:aPackageMethod | | aMethod aClass |
|
|
658 |
changeSet addMethodChange:aPackageMethod method in:aPackageMethod ownedClass
|
|
659 |
].
|
|
660 |
|
|
661 |
^ changeSet
|
|
662 |
!
|
|
663 |
|
|
664 |
classCategories
|
|
665 |
| return |
|
|
666 |
return := Set new.
|
|
667 |
self packagedClassesDo:[:aPackagedClass |
|
|
668 |
return add:aPackagedClass category.
|
|
669 |
].
|
|
670 |
^ return asOrderedCollection sort:[:x :y | x > y].
|
|
671 |
!
|
|
672 |
|
|
673 |
classesInCategory:aCategory
|
|
674 |
| collectingClasses |
|
|
675 |
collectingClasses := OrderedCollection new.
|
|
676 |
|
|
677 |
self packagedClassesDo:[:aPackagedClass |
|
|
678 |
aPackagedClass category == aCategory ifTrue:[
|
|
679 |
collectingClasses add: aPackagedClass classInImage.
|
|
680 |
].
|
|
681 |
].
|
|
682 |
^ collectingClasses
|
|
683 |
!
|
|
684 |
|
|
685 |
getSourceForClass:aClass
|
|
686 |
"get the source of a class in the context of the receiver"
|
|
687 |
| currentSourceStream |
|
|
688 |
currentSourceStream := aClass currentSourceStream.
|
|
689 |
self halt.
|
|
690 |
!
|
|
691 |
|
|
692 |
looseMethodNames
|
|
693 |
^ self looseMethods collect:[:aMethod | aMethod name].
|
|
694 |
! !
|
|
695 |
|
|
696 |
!Package methodsFor:'api - adding & removing'!
|
|
697 |
|
|
698 |
addClassNamed:aClass
|
|
699 |
"called when adding a class on startup. So far this is a kludge. To be replaced by a
|
|
700 |
loaded package class - this is soley an installed class"
|
|
701 |
^ self basicAddPackagedClass:(PackagedClass name:aClass package:self)
|
|
702 |
!
|
|
703 |
|
|
704 |
addMethodNamed:aMethodName forClassNamed:aClassName
|
|
705 |
|
|
706 |
| aPackagedMethod doesNotOwnClass |
|
|
707 |
|
|
708 |
aPackagedMethod := (self newPackagedMethodSelector:aMethodName className:aClassName).
|
|
709 |
|
|
710 |
(self blockedMethodsIncludeMethodName:aMethodName forClassNamed:aClassName) ifTrue:[
|
|
711 |
self removeBlockedMethodNamed:aMethodName forClassNamed:aClassName.
|
|
712 |
^ aPackagedMethod.
|
|
713 |
].
|
|
714 |
|
|
715 |
doesNotOwnClass := (self classNamed:aClassName) isNil.
|
|
716 |
doesNotOwnClass ifTrue:[
|
|
717 |
(self packagedMethodsAt:aClassName ifAbsentPut:[Dictionary new])
|
|
718 |
at:aMethodName put:aPackagedMethod.
|
|
719 |
].
|
|
720 |
|
|
721 |
(self overriddenChangesIncludesMethodName:aMethodName forClass:aClassName) ifTrue:[
|
|
722 |
"it should not be consider overriden anymore has the method has just been
|
|
723 |
added to the receiver!!"
|
|
724 |
self removeOverriddenMethodNamed:aMethodName forClassNamed:aClassName
|
|
725 |
].
|
|
726 |
^ aPackagedMethod "if nil, the method is still to be installed. Could use a dummy here instead??"
|
|
727 |
!
|
|
728 |
|
|
729 |
addedClass:aClass
|
|
730 |
"Add a class to a package. Return the aClass.
|
|
731 |
This only works when 'aClass package == name' if not and error will occur.
|
|
732 |
This method is called only AFTER the class package has changed!! This class
|
|
733 |
is NOT responsible for changing values in classes!!
|
|
734 |
"
|
|
735 |
(aClass package == self name) ifFalse:[
|
|
736 |
self error:'Cannot add ', aClass name, ' to package ''', name,
|
|
737 |
''' as the class ', aClass name, Character cr asString,
|
|
738 |
' belongs in the package''', aClass package asString,''''.
|
|
739 |
].
|
|
740 |
self basicAddedClass:aClass.
|
|
741 |
self markDirty.
|
|
742 |
self changed:#addedClass: with:aClass.
|
|
743 |
^ aClass
|
|
744 |
!
|
|
745 |
|
|
746 |
addedClasses:aClasses
|
|
747 |
"Add a class to a package. Return the aClass"
|
|
748 |
aClasses do:[:aClass |
|
|
749 |
self basicAddedClass:aClass.
|
|
750 |
].
|
|
751 |
|
|
752 |
self markDirty.
|
|
753 |
self changed:#addClasses: with:aClasses.
|
|
754 |
^ aClasses
|
|
755 |
!
|
|
756 |
|
|
757 |
addedMethod:aMethod
|
|
758 |
"Add a method to a package. Return the aMethod"
|
|
759 |
self basicAddedMethod:aMethod.
|
|
760 |
self markDirty.
|
|
761 |
self changed:#addedMethod: with:aMethod.
|
|
762 |
^ aMethod
|
|
763 |
!
|
|
764 |
|
|
765 |
addedMethods:someMethods
|
|
766 |
"Add someMethods to a package. Return the someMethods"
|
|
767 |
someMethods do:[:aMethod |
|
|
768 |
self basicAddedMethod:aMethod.
|
|
769 |
].
|
|
770 |
self markDirty.
|
|
771 |
self changed:#addedMethods: with:someMethods.
|
|
772 |
^ someMethods
|
|
773 |
!
|
|
774 |
|
|
775 |
addedPackage:aPackage
|
|
776 |
"this is a little like inherits from but with packages. It could also be
|
|
777 |
considered to be a prerequisit that aPackageClass must be in the image before this
|
|
778 |
is installed!!"
|
|
779 |
self shouldImplement."soon"
|
|
780 |
!
|
|
781 |
|
|
782 |
removePackage:aPackage
|
|
783 |
"this is a little like inherits from but with packages. It could also be
|
|
784 |
considered to be a prerequisit that aPackageClass must be in the image before this
|
|
785 |
is installed!!"
|
|
786 |
self shouldImplement."soon"
|
|
787 |
!
|
|
788 |
|
|
789 |
removedClass:aClass
|
|
790 |
"Add a class to a package. Return the aClass"
|
|
791 |
^ self removedClassNamed:aClass name.
|
|
792 |
!
|
|
793 |
|
|
794 |
removedClassNamed:aSymbol
|
|
795 |
self basicRemoveClassNamed:aSymbol.
|
|
796 |
self markDirty.
|
|
797 |
self changed:#removedClassNamed: with:aSymbol.
|
|
798 |
^ aSymbol
|
|
799 |
!
|
|
800 |
|
|
801 |
removedMethod:aMethod
|
|
802 |
^ self
|
|
803 |
removedMethodNamed:aMethod name
|
|
804 |
forClassNamed:aMethod mclass name.
|
|
805 |
!
|
|
806 |
|
|
807 |
removedMethodNamed:aMethodName forClassNamed:aClassName
|
|
808 |
"note: could also create a loose method object which could be more useful"
|
|
809 |
^ self removedMethodNamed:aMethodName forClassNamed:aClassName ifAbsent:[]
|
|
810 |
!
|
|
811 |
|
|
812 |
removedMethodNamed:aMethodName forClassNamed:aClassName ifAbsent:aBlock
|
|
813 |
"note: could also create a loose method object which could be more useful"
|
|
814 |
| aPackagedMethod |
|
|
815 |
aPackagedMethod := self basicRemoveMethodNamed:aMethodName forClassNamed:aClassName ifAbsent:aBlock.
|
|
816 |
self markDirty.
|
|
817 |
self changed:#removedMethodNamed:forClassNamed: with:(Array with:(aMethodName)with:(aClassName)).
|
|
818 |
^ aPackagedMethod
|
|
819 |
! !
|
|
820 |
|
|
821 |
!Package methodsFor:'api - prerequisites'!
|
|
822 |
|
|
823 |
addClassNamePrerequisite:aClassName
|
|
824 |
"changed sent in the following call"
|
|
825 |
^ self addClassNamePrerequisite:aClassName ifFailString:''.
|
|
826 |
!
|
|
827 |
|
|
828 |
addClassNamePrerequisite:aName ifFailString:aString
|
|
829 |
| returnValue |
|
|
830 |
returnValue := self basicAddPrerequisite:(self newClassPrerequisiteNamed:aName ifFailString:aString).
|
|
831 |
self changed:#addClassNamePrerequisite: with:aName.
|
|
832 |
^ returnValue.
|
|
833 |
!
|
|
834 |
|
|
835 |
addPackageNamePrerequisite:aName
|
|
836 |
"changed sent in the following call"
|
|
837 |
^ self addPackageNamePrerequisite:aName ifFailString:''.
|
|
838 |
!
|
|
839 |
|
|
840 |
addPackageNamePrerequisite:aName ifFailString:aString
|
|
841 |
| returnValue |
|
|
842 |
returnValue := self basicAddPrerequisite:(self newPackagePrerequisiteNamed:aName
|
|
843 |
ifFailString:aString).
|
|
844 |
|
|
845 |
self changed:#addPackageNamePrerequisite: with:aName.
|
|
846 |
^ returnValue.
|
|
847 |
! !
|
|
848 |
|
|
849 |
!Package methodsFor:'api - scripts'!
|
|
850 |
|
|
851 |
postInstallScript
|
|
852 |
^ self scriptAt:#postInstall
|
|
853 |
!
|
|
854 |
|
|
855 |
postInstallScriptString:aString
|
|
856 |
self scriptAt:#postInstall put:(self newPackageScriptWithString:aString).
|
|
857 |
self changed:#postInstallScriptString: with:aString.
|
|
858 |
!
|
|
859 |
|
|
860 |
postUninstallScript
|
|
861 |
^ self scriptAt:#postUninstall
|
|
862 |
!
|
|
863 |
|
|
864 |
postUninstallScriptString:aString
|
|
865 |
self scriptAt:#postUninstall put:(self newPackageScriptWithString:aString).
|
|
866 |
self changed:#postUninstallScriptString: with:aString.
|
|
867 |
!
|
|
868 |
|
|
869 |
preInstallScript
|
|
870 |
^ (self scriptAt:#preInstall)
|
|
871 |
!
|
|
872 |
|
|
873 |
preInstallScriptString:aString
|
|
874 |
self scriptAt:#preInstall put:(self newPackageScriptWithString:aString).
|
|
875 |
self changed:#preInstallScriptString: with:aString.
|
|
876 |
!
|
|
877 |
|
|
878 |
preUninstallScript
|
|
879 |
^ self scriptAt:#preUninstall
|
|
880 |
!
|
|
881 |
|
|
882 |
preUninstallScriptString:aString
|
|
883 |
self scriptAt:#preUninstall put:(self newPackageScriptWithString:aString).
|
|
884 |
self changed:#preUninstallScriptString: with:aString.
|
|
885 |
! !
|
|
886 |
|
|
887 |
!Package methodsFor:'api - temporary'!
|
|
888 |
|
|
889 |
basicPackagesInImage
|
|
890 |
^ PackageManager basicPackagesInImage
|
|
891 |
!
|
|
892 |
|
|
893 |
mergeFromImage
|
|
894 |
"get everything related to my package name in the image and add it to self."
|
|
895 |
| myGhost |
|
|
896 |
|
|
897 |
myGhost := self basicPackagesInImage at:name.
|
|
898 |
self addPackagedClasses:(myGhost packagedClasses values asSet - self packagedClasses values asSet).
|
|
899 |
self addPackagedMethods:(myGhost looseMethods asSet - self looseMethods asSet).
|
|
900 |
"
|
|
901 |
(self named:#'__NoProject__') mergeFromImage
|
|
902 |
"
|
|
903 |
! !
|
|
904 |
|
|
905 |
!Package methodsFor:'api - uninstall'!
|
|
906 |
|
|
907 |
uninstall
|
|
908 |
self checkOkToUninstall.
|
|
909 |
self basicUninstall.
|
|
910 |
! !
|
|
911 |
|
|
912 |
!Package methodsFor:'api-moving'!
|
|
913 |
|
|
914 |
movedClass:aClass toPackage:newOwnerPackage
|
|
915 |
"Note: all the methods of the class have also been moved to newOwnerPackage BUT
|
|
916 |
we do not have to do anything about that here!! We also do not get any change messages
|
|
917 |
and we - in effect - get this change for free :-) as now newOwnerPackage owns the class!!"
|
|
918 |
self removedClass:aClass.
|
|
919 |
newOwnerPackage addedClass:aClass.
|
|
920 |
!
|
|
921 |
|
|
922 |
movedMethod:aMethod toPackage:newOwnerPackage
|
|
923 |
self removedMethod:aMethod.
|
|
924 |
newOwnerPackage addedMethod:aMethod.
|
|
925 |
! !
|
|
926 |
|
|
927 |
!Package methodsFor:'changes'!
|
|
928 |
|
|
929 |
classChange:classChange
|
|
930 |
"assumes that checks to see if the receiver is affected by the change have been made.
|
|
931 |
"
|
|
932 |
|
|
933 |
self changed:#classChange: with:classChange
|
|
934 |
!
|
|
935 |
|
|
936 |
classDefinitionChange:aClassDefinitionChange
|
|
937 |
"assumes that checks to see if the receiver is affected by the change have been made.
|
|
938 |
At present a classDefinitionChange does not result in a class changing packages!!
|
|
939 |
If it does then this method needs to change and put this change type in overridden changes!!
|
|
940 |
"
|
|
941 |
self markDirty.
|
|
942 |
self changed:#classDefinitionChange: with:aClassDefinitionChange
|
|
943 |
!
|
|
944 |
|
|
945 |
classInstVarDefinitionChange:aClassInstVarDefinitionChange
|
|
946 |
"assumes that checks to see if the receiver is affected by the change have been made.
|
|
947 |
At present a classInstVarDefinitionChange does not result in a class changing packages!!
|
|
948 |
If it does then this method needs to change and put this change type in overridden changes!!
|
|
949 |
"
|
|
950 |
self markDirty.
|
|
951 |
self changed:#classInstVarDefinitionChange: with:aClassInstVarDefinitionChange
|
|
952 |
!
|
|
953 |
|
|
954 |
classRemoveChange:aClassRemoveChange
|
|
955 |
"assumes that checks to see if the receiver is affected by the change have been made.
|
|
956 |
At the moment i store the original package information in the instance variable
|
|
957 |
packagedClasses, and this is where i get the original class definition from!! It might be
|
|
958 |
an idea to get this info from aClassRemoveChange like it is done in methodRemoveChange.
|
|
959 |
Then we would not need the packageClasses themselves and just storing symbolic links
|
|
960 |
to the classesand create the packageClasses on the fly when needed.
|
|
961 |
"
|
|
962 |
|classBeingRemoved originalClassDefinition |
|
|
963 |
|
|
964 |
classBeingRemoved := ClassRemoveChange::ClassBeingRemovedQuery query.
|
|
965 |
originalClassDefinition := (self packagedClassAt: classBeingRemoved name).
|
|
966 |
self addOverriddenClassChange:originalClassDefinition.
|
|
967 |
self changed:#classRemoveChange:aClassRemoveChange
|
|
968 |
!
|
|
969 |
|
|
970 |
classRenameChange:aClassRenameChange
|
|
971 |
"assumes that checks to see if the receiver is affected by the change have been made.
|
|
972 |
This action requires the receiver to change all references to the old class name to the
|
|
973 |
new name.
|
|
974 |
"
|
|
975 |
| newClass |
|
|
976 |
newClass := (Smalltalk classNamed:aClassRenameChange className).
|
|
977 |
newClass ifNil:[
|
|
978 |
self error:'The class named ', newClass name,
|
|
979 |
'does not exist!! It is expected to exist from a rename action!!'
|
|
980 |
].
|
|
981 |
self removedClassNamed:aClassRenameChange oldName.
|
|
982 |
self addedClass:newClass "not expected to be nil".
|
|
983 |
|
|
984 |
self changed:#classRenameChange: with:aClassRenameChange
|
|
985 |
!
|
|
986 |
|
|
987 |
markClean
|
|
988 |
self isDirty:false.
|
|
989 |
!
|
|
990 |
|
|
991 |
markDirty
|
|
992 |
self isDirty:true
|
|
993 |
!
|
|
994 |
|
|
995 |
methodCategoryChange:aChange
|
|
996 |
"assumes that checks to see if the receiver is affected by the change have been made.
|
|
997 |
This is not considered a 'major change'. Therefore do nothing to the receiver to indicate that
|
|
998 |
this method (specified by aChange) has been overriden or change. Just mark the receiver as
|
|
999 |
dirty
|
|
1000 |
"
|
|
1001 |
self markDirty.
|
|
1002 |
self changed:#methodCategoryRenameChange: with:aChange
|
|
1003 |
!
|
|
1004 |
|
|
1005 |
methodCategoryRenameChange:aChange
|
|
1006 |
"assumes that checks to see if the receiver is affected by the change have been made.
|
|
1007 |
This is not considered a 'major change'. Therefore do nothing to the receiver to indicate that
|
|
1008 |
this method (specified by aChange) has been overriden or change. Just mark the receiver as
|
|
1009 |
dirty
|
|
1010 |
"
|
|
1011 |
self markDirty.
|
|
1012 |
self changed:#methodCategoryRenameChange: with:aChange
|
|
1013 |
!
|
|
1014 |
|
|
1015 |
methodChanged:aMethodChange
|
|
1016 |
"assumes that checks to see if the receiver is affected by the change have been made
|
|
1017 |
a method as changed.
|
|
1018 |
|
|
1019 |
There are really two types of change that come in here. A 'new method change' and a
|
|
1020 |
'method redefinition'.
|
|
1021 |
|
|
1022 |
If the receiver is dependent on the change there are two things that
|
|
1023 |
can happen depending on the change:
|
|
1024 |
|
|
1025 |
1) if the receiver owns the class but not the method
|
|
1026 |
- to keep the package consistant - we add a blocked method to the receiver
|
|
1027 |
|
|
1028 |
2) if the receiver has a loose method defining the method
|
|
1029 |
add an overriddenMethod change - to store the original.
|
|
1030 |
|
|
1031 |
Context note:
|
|
1032 |
at present a change to a methods results ALWAYS in the default package owning the method.
|
|
1033 |
so here we assume that the current version package is NEVER the receiver!! This could be
|
|
1034 |
added functionality option later on (i have no way of testing this now).
|
|
1035 |
"
|
|
1036 |
| previousVersion aMethodName aClassName aPackagedMethod byPackageName |
|
|
1037 |
|
|
1038 |
aMethodName := aMethodChange selector.
|
|
1039 |
aClassName := aMethodChange className.
|
|
1040 |
previousVersion := aMethodChange previousVersion.
|
|
1041 |
aPackagedMethod := self
|
|
1042 |
newPackagedMethodSelector:aMethodName
|
|
1043 |
className:aClassName
|
|
1044 |
source:previousVersion.
|
|
1045 |
byPackageName := aPackagedMethod currentPackageOwner.
|
|
1046 |
|
|
1047 |
(self includesClassNamed:aClassName) ifTrue:[
|
|
1048 |
previousVersion ifNil:[
|
|
1049 |
"should only really happen in Default class - at least for the time being.
|
|
1050 |
This is because as is noted in - 'Context note' - above"
|
|
1051 |
^ self newMethodChanged:aMethodChange
|
|
1052 |
].
|
|
1053 |
previousVersion package asSymbol == self name ifTrue:[
|
|
1054 |
^ self addOverriddenMethodChange:aPackagedMethod byPackageNamed:byPackageName.
|
|
1055 |
].
|
|
1056 |
self error:'i should NEVER be here.... either isDependentOnMethodChange does not
|
|
1057 |
work correctly OR i have just gone a bit bonkers!!'
|
|
1058 |
].
|
|
1059 |
|
|
1060 |
"when i am here aMethodChange is in with my packageMethods (loose method)
|
|
1061 |
the following should be true(but is it needed???):
|
|
1062 |
previousVersion package asSymbol == self name
|
|
1063 |
"
|
|
1064 |
|
|
1065 |
self addOverriddenMethodChange:aPackagedMethod byPackageNamed:byPackageName.
|
|
1066 |
|
|
1067 |
self changed:#methodChanged: with:aMethodChange
|
|
1068 |
!
|
|
1069 |
|
|
1070 |
methodRemoveChange:aMethodRemoveChange
|
|
1071 |
"assumes that checks to see if the receiver is affected by the change have been made.
|
|
1072 |
A method that i am dependant on has been removed. I could be dependent on it's class
|
|
1073 |
or the method itself (then it would be a loose method).
|
|
1074 |
|
|
1075 |
There is one special case where i would be dependent on the class but not the method.
|
|
1076 |
In this case i just remove the blocked method from my blocked method list!!
|
|
1077 |
Otherwise adds changes to overriddenChanges.
|
|
1078 |
"
|
|
1079 |
| previousVersion aMethodName aClassName aPackagedMethod|
|
|
1080 |
aMethodName := aMethodRemoveChange selector.
|
|
1081 |
aClassName := aMethodRemoveChange className.
|
|
1082 |
previousVersion := aMethodRemoveChange previousVersion.
|
|
1083 |
aPackagedMethod := self
|
|
1084 |
newPackagedMethodSelector:aMethodName
|
|
1085 |
className:aClassName
|
|
1086 |
source:previousVersion source.
|
|
1087 |
|
|
1088 |
(self blockedMethodsIncludeMethodName:aMethodName forClassNamed:aClassName) ifTrue:[
|
|
1089 |
self removeBlockedMethodNamed:aMethodName forClassNamed:aClassName.
|
|
1090 |
^ self.
|
|
1091 |
].
|
|
1092 |
|
|
1093 |
(self includesClassNamed:aMethodRemoveChange className asSymbol) ifTrue:[
|
|
1094 |
|
|
1095 |
previousVersion package asSymbol == self name ifTrue:[
|
|
1096 |
^ self addOverriddenMethodChange:aPackagedMethod."never be nil"
|
|
1097 |
].
|
|
1098 |
self error:'i should NEVER be here.... either isDependentOnMethodChange does not
|
|
1099 |
work correctly OR i have just gone a bit bonkers!!'
|
|
1100 |
].
|
|
1101 |
|
|
1102 |
"when i am here aMethodChange is in with my packageMethods"
|
|
1103 |
self addOverriddenMethodChange:aPackagedMethod.
|
|
1104 |
|
|
1105 |
self changed:#methodChanged: with:aMethodRemoveChange
|
|
1106 |
!
|
|
1107 |
|
|
1108 |
newMethodChanged:aMethodChange
|
|
1109 |
"a new method has been created. In this case i must be dependent on the method's class
|
|
1110 |
so i need to block this method from my 'view of the world'."
|
|
1111 |
| aMethodName aClassName |
|
|
1112 |
aMethodName := aMethodChange selector.
|
|
1113 |
aClassName := aMethodChange className.
|
|
1114 |
^ self addBlockedMethodNamed:aMethodName forClassNamed:aClassName
|
|
1115 |
! !
|
|
1116 |
|
|
1117 |
!Package methodsFor:'checks'!
|
|
1118 |
|
|
1119 |
readyForInstall
|
|
1120 |
#ToDo.
|
|
1121 |
!
|
|
1122 |
|
|
1123 |
readyForUninstall
|
|
1124 |
#ToDo.
|
|
1125 |
! !
|
|
1126 |
|
|
1127 |
!Package methodsFor:'enumerating'!
|
|
1128 |
|
|
1129 |
classNamesDo:aOneArgBlock
|
|
1130 |
self classNames do:[:aClassName|
|
|
1131 |
aOneArgBlock value:aClassName
|
|
1132 |
].
|
|
1133 |
!
|
|
1134 |
|
|
1135 |
classesDo:aBlock
|
|
1136 |
self packagedClassesDo:[:aPackage | | aClass |
|
|
1137 |
(aClass"orNil" := aPackage classInImage) ifNotNil:[
|
|
1138 |
aBlock value:aClass
|
|
1139 |
].
|
|
1140 |
].
|
|
1141 |
!
|
|
1142 |
|
|
1143 |
looseMethodNamesAndClassNamesDo:aTwoArgBlock
|
|
1144 |
self looseMethods do:[:aMethod |
|
|
1145 |
aTwoArgBlock value:aMethod name value:aMethod mclass name
|
|
1146 |
].
|
|
1147 |
!
|
|
1148 |
|
|
1149 |
looseMethodsDo:aBlock
|
|
1150 |
self looseMethods do:aBlock.
|
|
1151 |
!
|
|
1152 |
|
|
1153 |
packagePrerequisites
|
|
1154 |
^ prerequisites select:[:aPre |
|
|
1155 |
aPre isPackagePrerequisite
|
|
1156 |
].
|
|
1157 |
|
|
1158 |
!
|
|
1159 |
|
|
1160 |
packagedClassesCollect:aBlock
|
|
1161 |
^ self packagedClasses collect:aBlock
|
|
1162 |
!
|
|
1163 |
|
|
1164 |
packagedClassesDo:aOneArgBlock
|
|
1165 |
^ packagedClasses do:aOneArgBlock
|
|
1166 |
! !
|
|
1167 |
|
|
1168 |
!Package methodsFor:'exceptions'!
|
|
1169 |
|
|
1170 |
packageError:aString
|
|
1171 |
PackageError
|
|
1172 |
raiseFromPackage:self
|
|
1173 |
withString:aString.
|
|
1174 |
!
|
|
1175 |
|
|
1176 |
packageNotification:arg
|
|
1177 |
self halt:'please define packageNotification: here'.
|
|
1178 |
!
|
|
1179 |
|
|
1180 |
raisePackageError:aString
|
|
1181 |
PackageError raiseErrorString:aString.
|
|
1182 |
! !
|
|
1183 |
|
|
1184 |
!Package methodsFor:'factory'!
|
|
1185 |
|
|
1186 |
newClassPrerequisiteNamed:aName ifFailString:aString
|
|
1187 |
^ ClassPrerequisite named:aName ifFailString:aString.
|
|
1188 |
!
|
|
1189 |
|
|
1190 |
newOverriddenChangeWithChange:aChange
|
|
1191 |
^ OverriddenChange newChange:aChange package:self.
|
|
1192 |
!
|
|
1193 |
|
|
1194 |
newPackagePrerequisiteNamed:aName ifFailString:aString
|
|
1195 |
^ PackagePrerequisite named:aName ifFailString:aString.
|
|
1196 |
!
|
|
1197 |
|
|
1198 |
newPackageScriptWithString:aString
|
|
1199 |
^ PackagedScript string:aString receiver:self
|
|
1200 |
!
|
|
1201 |
|
|
1202 |
newPackagedClass:aClass
|
|
1203 |
^ (PackagedClass class:aClass package:self)
|
|
1204 |
!
|
|
1205 |
|
|
1206 |
newPackagedMethodSelector:aMethodSelector className:aClassName
|
|
1207 |
^ PackagedMethod new
|
|
1208 |
name:aMethodSelector;
|
|
1209 |
ownedClassName: aClassName;
|
|
1210 |
package:self.
|
|
1211 |
!
|
|
1212 |
|
|
1213 |
newPackagedMethodSelector:aMethodSelector className:aClassName source:aSourceString
|
|
1214 |
^ PackagedMethod
|
|
1215 |
name:aMethodSelector
|
|
1216 |
ownedClassName: aClassName
|
|
1217 |
package:self
|
|
1218 |
source:aSourceString
|
|
1219 |
!
|
|
1220 |
|
|
1221 |
newPackagedMethodWithMethod:aMethod
|
|
1222 |
^ PackagedMethod
|
|
1223 |
name:aMethod selector
|
|
1224 |
ownedClassName: aMethod mclass name
|
|
1225 |
package:self
|
|
1226 |
source:aMethod source
|
|
1227 |
! !
|
|
1228 |
|
|
1229 |
!Package methodsFor:'initialization'!
|
|
1230 |
|
|
1231 |
initialize
|
|
1232 |
|
|
1233 |
packagedClasses := self class defaultPackagedClassesCollection.
|
|
1234 |
packagedMethods := self class defaultPackagedMethodsCollection.
|
|
1235 |
blockedMethods := self class defaultBlockedMethodsCollection.
|
|
1236 |
overriddenChanges := self class defaultOverriddenChangesCollection.
|
|
1237 |
prerequisites := self class defaultPrerequisiteCollection.
|
|
1238 |
scripts := self class defaultScriptsCollection.
|
|
1239 |
|
|
1240 |
isDirty := false.
|
|
1241 |
isInstalled := false. "not sure about this..."
|
|
1242 |
super initialize.
|
|
1243 |
!
|
|
1244 |
|
|
1245 |
initializeClasses
|
|
1246 |
self classesDo:[:aClass |
|
|
1247 |
aClass initialize.
|
|
1248 |
].
|
|
1249 |
!
|
|
1250 |
|
|
1251 |
initializeInstalled
|
|
1252 |
"initialize as if the receiver as if it has just been loaded"
|
|
1253 |
| myName packagedClass |
|
|
1254 |
myName := self name.
|
|
1255 |
self isDirty:false.
|
|
1256 |
self isInstalled:true.
|
|
1257 |
self classesDo:[:aClass |
|
|
1258 |
aClass setPackage:myName.
|
|
1259 |
"get initial information"
|
|
1260 |
packagedClass := (self packagedClassAt:aClass name).
|
|
1261 |
packagedClass instanceDefinition: aClass definition.
|
|
1262 |
packagedClass classDefinition: aClass class definition.
|
|
1263 |
].
|
|
1264 |
|
|
1265 |
self looseMethodsDo:[:aMethod |
|
|
1266 |
aMethod setPackage:myName
|
|
1267 |
].
|
|
1268 |
!
|
|
1269 |
|
|
1270 |
initializeLoaded
|
|
1271 |
"initialize as if the receiver as just been loaded"
|
|
1272 |
self isDirty:false.
|
|
1273 |
self isInstalled:false.
|
|
1274 |
! !
|
|
1275 |
|
|
1276 |
!Package methodsFor:'printing'!
|
|
1277 |
|
|
1278 |
printOn:aStream
|
|
1279 |
|
|
1280 |
'named:', self name.
|
|
1281 |
aStream nextPutAll:self class printString.
|
|
1282 |
aStream nextPutAll:' named:'.
|
|
1283 |
aStream nextPut:$'.
|
|
1284 |
aStream nextPutAll:self name.
|
|
1285 |
aStream nextPut:$'.
|
|
1286 |
! !
|
|
1287 |
|
|
1288 |
!Package methodsFor:'queries'!
|
|
1289 |
|
|
1290 |
blockedMethodsIncludeMethodName:aMethodName forClassNamed:aClassName
|
|
1291 |
| blockedMethods |
|
|
1292 |
blockedMethods := (self blockedMethodsAt:aClassName).
|
|
1293 |
blockedMethods ifNil:[
|
|
1294 |
^ false.
|
|
1295 |
].
|
|
1296 |
|
|
1297 |
^ blockedMethods includes:aMethodName
|
|
1298 |
!
|
|
1299 |
|
|
1300 |
definesSelector:aSymbol forClass:aClass
|
|
1301 |
| dictionaryOfPackagedMethods |
|
|
1302 |
dictionaryOfPackagedMethods := self packagedMethods at:aClass name ifAbsent:[^ false].
|
|
1303 |
dictionaryOfPackagedMethods at:aSymbol ifAbsent:[^ false].
|
|
1304 |
^ true
|
|
1305 |
!
|
|
1306 |
|
|
1307 |
includesClassNamed:aSymbol
|
|
1308 |
| classWithoutClassEnding |
|
|
1309 |
classWithoutClassEnding := (aSymbol asString copyUpTo:Character space) asSymbol.
|
|
1310 |
self packagedClasses at:classWithoutClassEnding ifAbsent:[^ false].
|
|
1311 |
^ true
|
|
1312 |
!
|
|
1313 |
|
|
1314 |
includesSelector:aMethodSymbol forClass:aClassSymbol
|
|
1315 |
"checks to see if the receiver is dependent on a method selector associated
|
|
1316 |
with a class symbol. if the current method package name is not the same as the receiver's
|
|
1317 |
i am not responsible for this method any more."
|
|
1318 |
|
|
1319 |
| theClass |
|
|
1320 |
(theClass := self classNamed:aClassSymbol) ifNil:[
|
|
1321 |
^ false.
|
|
1322 |
].
|
|
1323 |
|
|
1324 |
(theClass compiledMethodAt:aMethodSymbol) package == name ifFalse:[
|
|
1325 |
^ false.
|
|
1326 |
].
|
|
1327 |
|
|
1328 |
^ true.
|
|
1329 |
!
|
|
1330 |
|
|
1331 |
isDependentOnClassChange:classChange
|
|
1332 |
"checks to see if the receiver is affected by the change. returns a boolean
|
|
1333 |
"
|
|
1334 |
^ (self includesClassNamed:(classChange className))
|
|
1335 |
!
|
|
1336 |
|
|
1337 |
isDependentOnClassDefinitionChange:aClassDefinitionChange
|
|
1338 |
^ (self includesClassNamed:(aClassDefinitionChange className))
|
|
1339 |
!
|
|
1340 |
|
|
1341 |
isDependentOnClassInstVarDefinitionChange:aClassInstVarDefinitionChange
|
|
1342 |
^ (self includesClassNamed:(aClassInstVarDefinitionChange className))
|
|
1343 |
!
|
|
1344 |
|
|
1345 |
isDependentOnClassRemoveChange:aClassRemoveChange
|
|
1346 |
^ (self includesClassNamed:(aClassRemoveChange className))
|
|
1347 |
!
|
|
1348 |
|
|
1349 |
isDependentOnClassRenameChange:classChange
|
|
1350 |
"checks to see if the receiver is affected by the change. returns a boolean
|
|
1351 |
"
|
|
1352 |
^ (self includesClassNamed:(classChange oldName))
|
|
1353 |
!
|
|
1354 |
|
|
1355 |
isDependentOnMethodCategoryChange:aMethodCategoryChange
|
|
1356 |
"if you want to later to be dependent on this MethodCategoryChange needs to probably store the
|
|
1357 |
previous version in its already available instance variable. Implement this method also in DefaultPackage.
|
|
1358 |
Also do we really need a MethodCategoryChange as well as a MethodCategoryRenameChange??"
|
|
1359 |
^ false
|
|
1360 |
!
|
|
1361 |
|
|
1362 |
isDependentOnMethodCategoryRenameChange:aMethodChange
|
|
1363 |
"if you want to later to be dependent on this MethodCategoryChange needs to probably store the
|
|
1364 |
previous version in its already available instance variable. Implement this method also in DefaultPackage.
|
|
1365 |
Also do we really need a MethodCategoryChange as well as a MethodCategoryRenameChange??"
|
|
1366 |
^ false
|
|
1367 |
!
|
|
1368 |
|
|
1369 |
isDependentOnMethodChange:aMethodChange
|
|
1370 |
"a method as changed. If the receiver is responsible for the change return true
|
|
1371 |
or false."
|
|
1372 |
| previousVersion aMethodChangeSelector aMethodChangeClassName |
|
|
1373 |
aMethodChangeSelector := aMethodChange selector.
|
|
1374 |
aMethodChangeClassName := aMethodChange className.
|
|
1375 |
|
|
1376 |
(previousVersion := aMethodChange previousVersion) ifNotNil:[
|
|
1377 |
previousVersion package == self name ifTrue:[
|
|
1378 |
^ true
|
|
1379 |
].
|
|
1380 |
].
|
|
1381 |
(self includesClassNamed:aMethodChange className asSymbol) ifTrue:[
|
|
1382 |
(self blockedMethodsIncludeMethodName:aMethodChangeSelector forClassNamed:aMethodChangeClassName) ifTrue:[
|
|
1383 |
^ false.
|
|
1384 |
].
|
|
1385 |
|
|
1386 |
(self overriddenChangesIncludesMethodChange:aMethodChange) ifTrue:[
|
|
1387 |
^ false.
|
|
1388 |
].
|
|
1389 |
previousVersion ifNil:[
|
|
1390 |
^ true
|
|
1391 |
].
|
|
1392 |
|
|
1393 |
].
|
|
1394 |
|
|
1395 |
aMethodChange package == self name ifTrue:[
|
|
1396 |
^ true
|
|
1397 |
].
|
|
1398 |
^ false
|
|
1399 |
!
|
|
1400 |
|
|
1401 |
isDependentOnMethodRemoveChange:aMethodRemoveChange
|
|
1402 |
"a method as been removed. If the receiver is responsible for the change return true
|
|
1403 |
or false."
|
|
1404 |
| previousVersion aMethodChangeSelector aMethodChangeClassName |
|
|
1405 |
aMethodChangeSelector := aMethodRemoveChange selector.
|
|
1406 |
aMethodChangeClassName := aMethodRemoveChange className.
|
|
1407 |
|
|
1408 |
(previousVersion := aMethodRemoveChange previousVersion) ifNotNil:[
|
|
1409 |
previousVersion package == self name ifTrue:[
|
|
1410 |
^ true
|
|
1411 |
].
|
|
1412 |
].
|
|
1413 |
(self includesClassNamed:aMethodRemoveChange className asSymbol) ifTrue:[
|
|
1414 |
(self blockedMethodsIncludeMethodName:aMethodChangeSelector forClassNamed:aMethodChangeClassName) ifTrue:[
|
|
1415 |
^ true.
|
|
1416 |
].
|
|
1417 |
|
|
1418 |
(self overriddenChangesIncludesMethodChange:aMethodRemoveChange) ifTrue:[
|
|
1419 |
^ true.
|
|
1420 |
].
|
|
1421 |
|
|
1422 |
].
|
|
1423 |
|
|
1424 |
aMethodRemoveChange package == self name ifTrue:[
|
|
1425 |
^ true
|
|
1426 |
].
|
|
1427 |
^ false
|
|
1428 |
!
|
|
1429 |
|
|
1430 |
isLooseMethod:aMethod
|
|
1431 |
^ (self includesClassNamed:aMethod mclass) not
|
|
1432 |
!
|
|
1433 |
|
|
1434 |
isPackage
|
|
1435 |
^ true
|
|
1436 |
!
|
|
1437 |
|
|
1438 |
overriddenChangesIncludesMethodChange:aMethodChange
|
|
1439 |
^ self
|
|
1440 |
overriddenChangesIncludesMethodName:aMethodChange selector
|
|
1441 |
forClass:aMethodChange changeClass name
|
|
1442 |
!
|
|
1443 |
|
|
1444 |
overriddenChangesIncludesMethodName:aMethodName forClass:aClassName
|
|
1445 |
| classOverridenChanges methodOverridenChanges|
|
|
1446 |
classOverridenChanges := (overriddenChanges
|
|
1447 |
at:self class methodChangeNamespace
|
|
1448 |
ifAbsent:[ ^ false"jump out of method here!!"]).
|
|
1449 |
methodOverridenChanges := (classOverridenChanges
|
|
1450 |
at:aClassName
|
|
1451 |
ifAbsent:[ ^ false"jump out of method here!!"]).
|
|
1452 |
|
|
1453 |
(methodOverridenChanges
|
|
1454 |
at:aMethodName
|
|
1455 |
ifAbsent:[ ^ false"jump out of method here!!"]).
|
|
1456 |
|
|
1457 |
^ true
|
|
1458 |
! !
|
|
1459 |
|
|
1460 |
!Package methodsFor:'uninstall'!
|
|
1461 |
|
|
1462 |
basicUninstall
|
|
1463 |
|
|
1464 |
self preUninstallScript evaluate.
|
|
1465 |
self uninstallDependentPackages.
|
|
1466 |
self uninstallClasses.
|
|
1467 |
self uninstallLooseMethods.
|
|
1468 |
self initializeLoaded.
|
|
1469 |
self postUninstallScript evaluate.
|
|
1470 |
!
|
|
1471 |
|
|
1472 |
checkOkToUninstall
|
|
1473 |
#toDo.
|
|
1474 |
!
|
|
1475 |
|
|
1476 |
uninstallClasses
|
|
1477 |
self classesDo:[:aClass |
|
|
1478 |
aClass removeFromSystem.
|
|
1479 |
]
|
|
1480 |
!
|
|
1481 |
|
|
1482 |
uninstallDependentPackages
|
|
1483 |
#toDo
|
|
1484 |
!
|
|
1485 |
|
|
1486 |
uninstallLooseMethods
|
|
1487 |
self looseMethodNamesAndClassNamesDo:[:aMethodName :aClassName |
|
|
1488 |
(Smalltalk at:aClassName) removeSelector:aMethodName.
|
|
1489 |
].
|
|
1490 |
!
|
|
1491 |
|
|
1492 |
uninstallLooseMethodsFromPackage:aPackage in:aPackageManager
|
|
1493 |
aPackage looseMethodNamesAndClassNamesDo:[:aMethodName :aClassName |
|
|
1494 |
(Smalltalk at:aClassName) removeSelector:aMethodName.
|
|
1495 |
].
|
|
1496 |
#ToLookAt.
|
|
1497 |
! !
|
|
1498 |
|
|
1499 |
!Package::PackagedClass class methodsFor:'instance creation'!
|
|
1500 |
|
|
1501 |
class:aClass package:aPackage
|
|
1502 |
| anInstance|
|
|
1503 |
anInstance := (self basicNew name:aClass name package:aPackage).
|
|
1504 |
(aClass isLoaded) ifFalse:[
|
|
1505 |
"could also be dependant on Smalltalk!!"
|
|
1506 |
aClass addDependent:anInstance. "get the definition when the class is autoloaded"
|
|
1507 |
^ anInstance.
|
|
1508 |
].
|
|
1509 |
anInstance instanceDefinition: aClass definition.
|
|
1510 |
anInstance classDefinition: aClass class definition.
|
|
1511 |
|
|
1512 |
^ anInstance
|
|
1513 |
!
|
|
1514 |
|
|
1515 |
name:aClassName package:aPackage
|
|
1516 |
^ (self basicNew name:aClassName package:aPackage).
|
|
1517 |
! !
|
|
1518 |
|
|
1519 |
!Package::PackagedClass methodsFor:'accessing'!
|
|
1520 |
|
|
1521 |
category
|
|
1522 |
^ self classInImage category
|
|
1523 |
!
|
|
1524 |
|
|
1525 |
category:something
|
|
1526 |
"set the value of the instance variable 'category' (automatically generated)"
|
|
1527 |
|
|
1528 |
category := something.
|
|
1529 |
!
|
|
1530 |
|
|
1531 |
classDefinition
|
|
1532 |
"return the value of the instance variable 'classDefinition' (automatically generated)"
|
|
1533 |
|
|
1534 |
^ classDefinition
|
|
1535 |
!
|
|
1536 |
|
|
1537 |
classDefinition:something
|
|
1538 |
"set the value of the instance variable 'classDefinition' (automatically generated)"
|
|
1539 |
|
|
1540 |
classDefinition := something.
|
|
1541 |
!
|
|
1542 |
|
|
1543 |
classInstanceVariableNames
|
|
1544 |
"return the value of the instance variable 'classInstanceVariableNames' (automatically generated)"
|
|
1545 |
|
|
1546 |
^ classInstanceVariableNames
|
|
1547 |
!
|
|
1548 |
|
|
1549 |
classInstanceVariableNames:something
|
|
1550 |
"set the value of the instance variable 'classInstanceVariableNames' (automatically generated)"
|
|
1551 |
|
|
1552 |
classInstanceVariableNames := something.
|
|
1553 |
!
|
|
1554 |
|
|
1555 |
classVariableNames
|
|
1556 |
"return the value of the instance variable 'classVariableNames' (automatically generated)"
|
|
1557 |
|
|
1558 |
^ classVariableNames
|
|
1559 |
!
|
|
1560 |
|
|
1561 |
classVariableNames:something
|
|
1562 |
"set the value of the instance variable 'classVariableNames' (automatically generated)"
|
|
1563 |
|
|
1564 |
classVariableNames := something.
|
|
1565 |
!
|
|
1566 |
|
|
1567 |
instanceDefinition
|
|
1568 |
"return the value of the instance variable 'instanceDefinition' (automatically generated)"
|
|
1569 |
|
|
1570 |
^ instanceDefinition
|
|
1571 |
!
|
|
1572 |
|
|
1573 |
instanceDefinition:something
|
|
1574 |
"set the value of the instance variable 'instanceDefinition' (automatically generated)"
|
|
1575 |
|
|
1576 |
instanceDefinition := something.
|
|
1577 |
!
|
|
1578 |
|
|
1579 |
instanceVariableNames
|
|
1580 |
"return the value of the instance variable 'instanceVariableNames' (automatically generated)"
|
|
1581 |
|
|
1582 |
^ instanceVariableNames
|
|
1583 |
!
|
|
1584 |
|
|
1585 |
instanceVariableNames:something
|
|
1586 |
"set the value of the instance variable 'instanceVariableNames' (automatically generated)"
|
|
1587 |
|
|
1588 |
instanceVariableNames := something.
|
|
1589 |
!
|
|
1590 |
|
|
1591 |
name
|
|
1592 |
"return the value of the instance variable 'name' (automatically generated)"
|
|
1593 |
|
|
1594 |
^ name
|
|
1595 |
!
|
|
1596 |
|
|
1597 |
name:something
|
|
1598 |
"set the value of the instance variable 'name' (automatically generated)"
|
|
1599 |
|
|
1600 |
name := something.
|
|
1601 |
!
|
|
1602 |
|
|
1603 |
name:nameArg package:packageArg
|
|
1604 |
"set instance variables (automatically generated)"
|
|
1605 |
|
|
1606 |
name := nameArg.
|
|
1607 |
package := packageArg.
|
|
1608 |
!
|
|
1609 |
|
|
1610 |
package
|
|
1611 |
"return the value of the instance variable 'package' (automatically generated)"
|
|
1612 |
|
|
1613 |
^ package
|
|
1614 |
!
|
|
1615 |
|
|
1616 |
package:something
|
|
1617 |
"set the value of the instance variable 'package' (automatically generated)"
|
|
1618 |
|
|
1619 |
package := something.
|
|
1620 |
!
|
|
1621 |
|
|
1622 |
poolDictionaries
|
|
1623 |
"return the value of the instance variable 'poolDictionaries' (automatically generated)"
|
|
1624 |
|
|
1625 |
^ poolDictionaries
|
|
1626 |
!
|
|
1627 |
|
|
1628 |
poolDictionaries:something
|
|
1629 |
"set the value of the instance variable 'poolDictionaries' (automatically generated)"
|
|
1630 |
|
|
1631 |
poolDictionaries := something.
|
|
1632 |
! !
|
|
1633 |
|
|
1634 |
!Package::PackagedClass methodsFor:'api'!
|
|
1635 |
|
|
1636 |
changeSet
|
|
1637 |
| theClass |
|
|
1638 |
(theClass := self classInImage) ifNil:[
|
|
1639 |
^ ChangeSet new
|
|
1640 |
].
|
|
1641 |
|
|
1642 |
theClass autoload.
|
|
1643 |
|
|
1644 |
^ ChangeSet forExistingClass:theClass
|
|
1645 |
!
|
|
1646 |
|
|
1647 |
classInImage
|
|
1648 |
^ Smalltalk at:name
|
|
1649 |
!
|
|
1650 |
|
|
1651 |
isInImage
|
|
1652 |
"just looks for the class with the same name"
|
|
1653 |
^ self classInImage notNil
|
|
1654 |
! !
|
|
1655 |
|
|
1656 |
!Package::PackagedClass methodsFor:'change & update'!
|
|
1657 |
|
|
1658 |
update:something with:aParameter from:changedObject
|
|
1659 |
|
|
1660 |
(changedObject == self classInImage) ifTrue:[
|
|
1661 |
changedObject isLoaded ifTrue:[
|
|
1662 |
changedObject removeDependent:self. "dont need you any more"
|
|
1663 |
definition := changedObject definition.
|
|
1664 |
].
|
|
1665 |
].
|
|
1666 |
! !
|
|
1667 |
|
|
1668 |
!Package::PackagedClass methodsFor:'printing'!
|
|
1669 |
|
|
1670 |
printOn:aStream
|
|
1671 |
aStream nextPutAll:'(PackagedClass named:#', name, ')'.
|
|
1672 |
! !
|
|
1673 |
|
|
1674 |
!Package::PackagedClass methodsFor:'queries'!
|
|
1675 |
|
|
1676 |
isLoaded
|
|
1677 |
^ self classInImage isLoaded.
|
|
1678 |
! !
|
|
1679 |
|
|
1680 |
!Package::PackagedMethod class methodsFor:'instance creation'!
|
|
1681 |
|
|
1682 |
name:aMethodName ownedClassName: aClassName package:aPackageName source:source
|
|
1683 |
^ self basicNew name:aMethodName ownedClassName: aClassName package:aPackageName source:source
|
|
1684 |
! !
|
|
1685 |
|
|
1686 |
!Package::PackagedMethod methodsFor:'* uncategorized *'!
|
|
1687 |
|
|
1688 |
currentPackageOwner
|
|
1689 |
| class method |
|
|
1690 |
class := (Smalltalk classNamed:ownedClassName).
|
|
1691 |
class ifNil:[
|
|
1692 |
^ nil.
|
|
1693 |
].
|
|
1694 |
method := class compiledMethodAt:self name.
|
|
1695 |
|
|
1696 |
method ifNil:[
|
|
1697 |
^ nil
|
|
1698 |
].
|
|
1699 |
|
|
1700 |
^ method package
|
|
1701 |
! !
|
|
1702 |
|
|
1703 |
!Package::PackagedMethod methodsFor:'accessing'!
|
|
1704 |
|
|
1705 |
category
|
|
1706 |
(self isInImage) ifTrue:[
|
|
1707 |
^ self method category.
|
|
1708 |
].
|
|
1709 |
^ nil.
|
|
1710 |
!
|
|
1711 |
|
|
1712 |
methodInImage
|
|
1713 |
| myClass |
|
|
1714 |
myClass := Smalltalk classNamed:ownedClassName.
|
|
1715 |
myClass ifNil:[^ nil].
|
|
1716 |
|
|
1717 |
^ myClass compiledMethodAt:self name.
|
|
1718 |
!
|
|
1719 |
|
|
1720 |
name
|
|
1721 |
"return the value of the instance variable 'name' (automatically generated)"
|
|
1722 |
|
|
1723 |
^ name
|
|
1724 |
!
|
|
1725 |
|
|
1726 |
name:something
|
|
1727 |
"set the value of the instance variable 'name' (automatically generated)"
|
|
1728 |
|
|
1729 |
name := something.
|
|
1730 |
!
|
|
1731 |
|
|
1732 |
name:nameArg ownedClassName:classNameArg package:packageArg
|
|
1733 |
"set instance variables (automatically generated)"
|
|
1734 |
|
|
1735 |
name := nameArg.
|
|
1736 |
ownedClassName := classNameArg.
|
|
1737 |
package := packageArg.
|
|
1738 |
!
|
|
1739 |
|
|
1740 |
name:nameArg ownedClassName:classNameArg package:packageArg source:sourceArg
|
|
1741 |
"set instance variables (automatically generated)"
|
|
1742 |
|
|
1743 |
name := nameArg.
|
|
1744 |
ownedClassName := classNameArg.
|
|
1745 |
package := packageArg.
|
|
1746 |
source := sourceArg.
|
|
1747 |
!
|
|
1748 |
|
|
1749 |
ownedClass
|
|
1750 |
^ Compiler evaluate:ownedClassName
|
|
1751 |
in:nil
|
|
1752 |
receiver:nil
|
|
1753 |
notifying:nil
|
|
1754 |
logged:false
|
|
1755 |
ifFail:[nil]
|
|
1756 |
compile:false
|
|
1757 |
|
|
1758 |
|
|
1759 |
|
|
1760 |
"
|
|
1761 |
(self new ownedClassName:'asdfasdf') ownedClass
|
|
1762 |
"
|
|
1763 |
!
|
|
1764 |
|
|
1765 |
ownedClassName
|
|
1766 |
"return the value of the instance variable 'className' (automatically generated)"
|
|
1767 |
|
|
1768 |
^ ownedClassName
|
|
1769 |
!
|
|
1770 |
|
|
1771 |
ownedClassName:something
|
|
1772 |
"set the value of the instance variable 'className' (automatically generated)"
|
|
1773 |
|
|
1774 |
ownedClassName := something.
|
|
1775 |
!
|
|
1776 |
|
|
1777 |
package
|
|
1778 |
"return the value of the instance variable 'package' (automatically generated)"
|
|
1779 |
|
|
1780 |
^ package
|
|
1781 |
!
|
|
1782 |
|
|
1783 |
package:something
|
|
1784 |
"set the value of the instance variable 'package' (automatically generated)"
|
|
1785 |
|
|
1786 |
package := something.
|
|
1787 |
!
|
|
1788 |
|
|
1789 |
source
|
|
1790 |
source isNil ifTrue:[
|
|
1791 |
self isInImage ifFalse:[
|
|
1792 |
^ '** no method - no source **' copy.
|
|
1793 |
].
|
|
1794 |
source := self method source.
|
|
1795 |
].
|
|
1796 |
|
|
1797 |
^ source.
|
|
1798 |
!
|
|
1799 |
|
|
1800 |
source:something
|
|
1801 |
"set the value of the instance variable 'source' (automatically generated)"
|
|
1802 |
|
|
1803 |
source := something.
|
|
1804 |
! !
|
|
1805 |
|
|
1806 |
!Package::PackagedMethod methodsFor:'fileIn/Out'!
|
|
1807 |
|
|
1808 |
fileOutOn:aWriteStream
|
|
1809 |
|
|
1810 |
aWriteStream nextPut:$!!.
|
|
1811 |
aWriteStream nextPutAll:ownedClassName asString.
|
|
1812 |
aWriteStream nextPutAll:' methodsFor:'.
|
|
1813 |
aWriteStream nextPut:$'.
|
|
1814 |
aWriteStream nextPutAll:(self category).
|
|
1815 |
aWriteStream nextPut:$'.
|
|
1816 |
aWriteStream nextPut:$!!.
|
|
1817 |
aWriteStream cr.
|
|
1818 |
|
|
1819 |
aWriteStream nextPutAll:self source.
|
|
1820 |
aWriteStream nextPut:$!!.
|
|
1821 |
aWriteStream cr.
|
|
1822 |
! !
|
|
1823 |
|
|
1824 |
!Package::PackagedMethod methodsFor:'method - api'!
|
|
1825 |
|
|
1826 |
mclass
|
|
1827 |
^ (Smalltalk classNamed:ownedClassName)
|
|
1828 |
!
|
|
1829 |
|
|
1830 |
selector
|
|
1831 |
^ name
|
|
1832 |
! !
|
|
1833 |
|
|
1834 |
!Package::PackagedMethod methodsFor:'printing'!
|
|
1835 |
|
|
1836 |
printOn:aStream
|
|
1837 |
self isLoose ifTrue:[
|
|
1838 |
aStream nextPutAll:'LooseMethod:'.
|
|
1839 |
] ifFalse:[
|
|
1840 |
aStream nextPutAll:'Method:'.
|
|
1841 |
].
|
|
1842 |
|
|
1843 |
aStream nextPutAll:self ownedClassName.
|
|
1844 |
aStream nextPutAll:'->', name printString.
|
|
1845 |
aStream cr.
|
|
1846 |
! !
|
|
1847 |
|
|
1848 |
!Package::PackagedMethod methodsFor:'queries'!
|
|
1849 |
|
|
1850 |
isInImage
|
|
1851 |
| myClass|
|
|
1852 |
(myClass := self ownedClass) ifNotNil:[
|
|
1853 |
^ (myClass methodDictionary at:name ifAbsent:[nil])~~ nil.
|
|
1854 |
].
|
|
1855 |
|
|
1856 |
^ false.
|
|
1857 |
!
|
|
1858 |
|
|
1859 |
isLoose
|
|
1860 |
^ (package includesClassNamed:ownedClassName) not
|
|
1861 |
!
|
|
1862 |
|
|
1863 |
isTheSameAsInImage
|
|
1864 |
| myClass method|
|
|
1865 |
self halt.
|
|
1866 |
(myClass := (Smalltalk at:ownedClassName)) ifNotNil:[
|
|
1867 |
(method :=(myClass methodDictionary at:name ifAbsent:[nil])) ifNotNil:[
|
|
1868 |
^ method source = source. "there is a more efficient way but i have forgotten"
|
|
1869 |
].
|
|
1870 |
|
|
1871 |
].
|
|
1872 |
^ false.
|
|
1873 |
!
|
|
1874 |
|
|
1875 |
method
|
|
1876 |
| myClass|
|
|
1877 |
(myClass := self ownedClass) ifNotNil:[
|
|
1878 |
^ (myClass methodDictionary at:name ifAbsent:[nil]).
|
|
1879 |
].
|
|
1880 |
self halt.
|
|
1881 |
^ nil.
|
|
1882 |
! !
|
|
1883 |
|
|
1884 |
!Package::PackagedScript class methodsFor:'instance creation'!
|
|
1885 |
|
|
1886 |
string:aString receiver:aPackage
|
|
1887 |
^ self basicNew string:aString receiver:aPackage
|
|
1888 |
! !
|
|
1889 |
|
|
1890 |
!Package::PackagedScript methodsFor:'accessing'!
|
|
1891 |
|
|
1892 |
getString
|
|
1893 |
^ string
|
|
1894 |
!
|
|
1895 |
|
|
1896 |
string:stringArg receiver:receiverArg
|
|
1897 |
"set instance variables (automatically generated)"
|
|
1898 |
|
|
1899 |
string := stringArg.
|
|
1900 |
receiver := receiverArg.
|
|
1901 |
! !
|
|
1902 |
|
|
1903 |
!Package::PackagedScript methodsFor:'evaluation'!
|
|
1904 |
|
|
1905 |
evaluate
|
|
1906 |
^ Compiler evaluate:string receiver:receiver.
|
|
1907 |
! !
|
|
1908 |
|
|
1909 |
!Package::PackagedScript methodsFor:'printing'!
|
|
1910 |
|
|
1911 |
printOn:aStream
|
|
1912 |
aStream nextPutAll:'Compiler evaluate:'.
|
|
1913 |
aStream nextPut:$'.
|
|
1914 |
aStream nextPutAll:string.
|
|
1915 |
aStream nextPut:$'.
|
|
1916 |
aStream nextPutAll:' receiver:('.
|
|
1917 |
aStream nextPutAll:(receiver printString).
|
|
1918 |
aStream nextPut:$).
|
|
1919 |
|
|
1920 |
"
|
|
1921 |
self string:'1 + 1' receiver:nil
|
|
1922 |
"
|
|
1923 |
! !
|
|
1924 |
|
|
1925 |
!Package class methodsFor:'documentation'!
|
|
1926 |
|
|
1927 |
version
|
|
1928 |
^ '$Header: /cvs/stx/stx/libbasic3/packages/Package.st,v 1.1 2003-04-09 11:22:18 james Exp $'
|
|
1929 |
! !
|