1
|
1 |
"{ Package: 'stx:goodies/metacello' }"
|
|
2 |
|
|
3 |
Object subclass:#MetacelloSpec
|
|
4 |
instanceVariableNames:'project loader mutable'
|
|
5 |
classVariableNames:''
|
|
6 |
poolDictionaries:''
|
|
7 |
category:'Metacello-Core-Specs'
|
|
8 |
!
|
|
9 |
|
|
10 |
|
|
11 |
!MetacelloSpec class methodsFor:'instance creation'!
|
|
12 |
|
|
13 |
for: aVersionMap
|
|
14 |
|
|
15 |
^(self platformClass new)
|
|
16 |
for: aVersionMap;
|
|
17 |
yourself
|
|
18 |
! !
|
|
19 |
|
|
20 |
!MetacelloSpec class methodsFor:'accessing'!
|
|
21 |
|
|
22 |
platformClass
|
|
23 |
|
|
24 |
^self
|
|
25 |
! !
|
|
26 |
|
|
27 |
!MetacelloSpec methodsFor:'accessing'!
|
|
28 |
|
|
29 |
loader
|
|
30 |
|
|
31 |
loader == nil
|
|
32 |
ifTrue: [ | prjctLoader |
|
|
33 |
(prjctLoader := self project loader) == nil
|
|
34 |
ifTrue: [ self loader: (self project loaderClass on: self) ]
|
|
35 |
ifFalse: [ self loader: prjctLoader ]].
|
|
36 |
^loader
|
|
37 |
!
|
|
38 |
|
|
39 |
loader: aLoader
|
|
40 |
"We're interested in propogating the loader state, _except_ for the spec"
|
|
41 |
|
|
42 |
self shouldBeMutable.
|
|
43 |
loader := aLoader copy.
|
|
44 |
loader spec: self
|
|
45 |
! !
|
|
46 |
|
|
47 |
!MetacelloSpec methodsFor:'copying'!
|
|
48 |
|
|
49 |
postCopy
|
|
50 |
super postCopy.
|
|
51 |
mutable := nil.
|
|
52 |
loader ~~ nil
|
|
53 |
ifTrue: [ self loader: loader ].
|
|
54 |
! !
|
|
55 |
|
|
56 |
!MetacelloSpec methodsFor:'doits'!
|
|
57 |
|
|
58 |
doItBlock: selector
|
|
59 |
|
|
60 |
selector == nil ifTrue: [ ^nil ].
|
|
61 |
selector numArgs = 0
|
|
62 |
ifTrue: [ ^[ self project configuration perform: selector ] ].
|
|
63 |
selector numArgs = 1
|
|
64 |
ifTrue: [ ^[:aLoader | self project configuration perform: selector with: aLoader ] ].
|
|
65 |
selector numArgs = 2
|
|
66 |
ifTrue: [ ^[:aLoader :pkgSpec | self project configuration perform: selector with: aLoader with: pkgSpec ] ].
|
|
67 |
^nil
|
|
68 |
!
|
|
69 |
|
|
70 |
postLoadDoIt
|
|
71 |
"noop unless non-nil value returned"
|
|
72 |
|
|
73 |
^nil
|
|
74 |
!
|
|
75 |
|
|
76 |
postLoadDoItBlock
|
|
77 |
|
|
78 |
^self doItBlock: self postLoadDoIt value
|
|
79 |
!
|
|
80 |
|
|
81 |
preLoadDoIt
|
|
82 |
"noop unless non-nil value returned"
|
|
83 |
|
|
84 |
^nil
|
|
85 |
!
|
|
86 |
|
|
87 |
preLoadDoItBlock
|
|
88 |
|
|
89 |
^self doItBlock: self preLoadDoIt value
|
|
90 |
! !
|
|
91 |
|
|
92 |
!MetacelloSpec methodsFor:'importing'!
|
|
93 |
|
|
94 |
mergeImportLoads: aLoadList
|
|
95 |
self error: 'import: can only be used with baseline project specs'
|
|
96 |
! !
|
|
97 |
|
|
98 |
!MetacelloSpec methodsFor:'initialization'!
|
|
99 |
|
|
100 |
for: aProject
|
|
101 |
self shouldBeMutable.
|
|
102 |
project := aProject
|
|
103 |
! !
|
|
104 |
|
|
105 |
!MetacelloSpec methodsFor:'merging'!
|
|
106 |
|
|
107 |
aboutToCopy
|
|
108 |
!
|
|
109 |
|
|
110 |
mergeMap
|
|
111 |
|
|
112 |
^Dictionary new.
|
|
113 |
!
|
|
114 |
|
|
115 |
mergeSpec: aSpec
|
|
116 |
| newSpec nonOverridable |
|
|
117 |
self validateMergeForSpec: aSpec.
|
|
118 |
newSpec := self copy.
|
|
119 |
nonOverridable := self nonOverridable.
|
|
120 |
aSpec mergeMap
|
|
121 |
keysAndValuesDo: [ :key :value |
|
|
122 |
(nonOverridable includes: key)
|
|
123 |
ifFalse: [
|
|
124 |
value ~~ nil
|
|
125 |
ifTrue: [ newSpec instVarNamed: key asString put: value ] ] ].
|
|
126 |
^ newSpec
|
|
127 |
!
|
|
128 |
|
|
129 |
nonOverridable
|
|
130 |
|
|
131 |
^#()
|
|
132 |
!
|
|
133 |
|
|
134 |
validateMergeForSpec: aSpec
|
|
135 |
aSpec class = self class
|
|
136 |
ifFalse: [
|
|
137 |
self
|
|
138 |
error:
|
|
139 |
'The project spec ' , self name printString , ' in project ' , self project label , ' has incompatible specs. '
|
|
140 |
, aSpec class name asString , ' and ' , self class name asString , ' are not compatible.' ]
|
|
141 |
! !
|
|
142 |
|
|
143 |
!MetacelloSpec methodsFor:'mutability'!
|
|
144 |
|
|
145 |
copyOnWrite: aBlock
|
|
146 |
"assume that only registered projects are immutable ... otherwise you'll get an error"
|
|
147 |
|
|
148 |
| copy |
|
|
149 |
copy := self copy.
|
|
150 |
aBlock value: copy.
|
|
151 |
^ copy
|
|
152 |
!
|
|
153 |
|
|
154 |
immutable
|
|
155 |
mutable := false
|
|
156 |
!
|
|
157 |
|
|
158 |
isMutable
|
|
159 |
mutable ifNil: [ ^ true ].
|
|
160 |
^ mutable
|
|
161 |
!
|
|
162 |
|
|
163 |
mutable
|
|
164 |
mutable := true
|
|
165 |
!
|
|
166 |
|
|
167 |
shouldBeMutable
|
|
168 |
self isMutable
|
|
169 |
ifTrue: [ ^ self ].
|
|
170 |
self error: 'Not allowed to modify an immutable object'
|
|
171 |
! !
|
|
172 |
|
|
173 |
!MetacelloSpec methodsFor:'printing'!
|
|
174 |
|
|
175 |
configMethodOn: aStream
|
|
176 |
|
|
177 |
self configMethodOn: aStream indent: 0
|
|
178 |
|
|
179 |
!
|
|
180 |
|
|
181 |
configMethodOn: aStream indent: indent
|
|
182 |
|
|
183 |
self subclassResponsibility
|
|
184 |
|
|
185 |
!
|
|
186 |
|
|
187 |
label
|
|
188 |
|
|
189 |
^self printString
|
|
190 |
!
|
|
191 |
|
|
192 |
printOn: aStream
|
|
193 |
|
|
194 |
self configMethodOn: aStream indent: 0
|
|
195 |
|
|
196 |
! !
|
|
197 |
|
|
198 |
!MetacelloSpec methodsFor:'querying'!
|
|
199 |
|
|
200 |
answers
|
|
201 |
|
|
202 |
^#()
|
|
203 |
!
|
|
204 |
|
|
205 |
project
|
|
206 |
|
|
207 |
^project
|
|
208 |
! !
|
|
209 |
|
|
210 |
!MetacelloSpec methodsFor:'spec creation'!
|
|
211 |
|
|
212 |
addMember
|
|
213 |
|
|
214 |
^MetacelloAddMemberSpec for: self project
|
|
215 |
!
|
|
216 |
|
|
217 |
copyMember
|
|
218 |
|
|
219 |
^MetacelloCopyMemberSpec for: self project
|
|
220 |
!
|
|
221 |
|
|
222 |
mergeMember
|
|
223 |
|
|
224 |
^MetacelloMergeMemberSpec for: self project
|
|
225 |
!
|
|
226 |
|
|
227 |
removeMember
|
|
228 |
|
|
229 |
^MetacelloRemoveMemberSpec for: self project
|
|
230 |
! !
|
|
231 |
|
|
232 |
!MetacelloSpec class methodsFor:'documentation'!
|
|
233 |
|
|
234 |
version_SVN
|
|
235 |
^ '$Id:: $'
|
|
236 |
! !
|