author | fm |
Tue, 29 Sep 2009 19:20:13 +0200 | |
changeset 12045 | ccb1c727370b |
parent 12043 | 80c7abaa0adf |
child 12108 | ed9288e408b7 |
permissions | -rw-r--r-- |
8728 | 1 |
" |
2 |
COPYRIGHT (c) 2004 by eXept Software AG |
|
3 |
All Rights Reserved |
|
4 |
||
5 |
This software is furnished under a license and may be used |
|
6 |
only in accordance with the terms of that license and with the |
|
7 |
inclusion of the above copyright notice. This software may not |
|
8 |
be provided or otherwise made available to, or used by, any |
|
9 |
other person. No title to or ownership of the software is |
|
10 |
hereby transferred. |
|
11 |
" |
|
8227 | 12 |
"{ Package: 'stx:libbasic' }" |
13 |
||
11963 | 14 |
AbstractSourceFileWriter subclass:#SmalltalkChunkFileSourceWriter |
11853
7c3265d8931e
save typedef methods before others to ensure that types
Claus Gittinger <cg@exept.de>
parents:
11703
diff
changeset
|
15 |
instanceVariableNames:'classBeingSaved methodsAlreadySaved' |
8227 | 16 |
classVariableNames:'' |
17 |
poolDictionaries:'' |
|
18 |
category:'Kernel-Classes' |
|
19 |
! |
|
20 |
||
8728 | 21 |
!SmalltalkChunkFileSourceWriter class methodsFor:'documentation'! |
22 |
||
23 |
copyright |
|
24 |
" |
|
25 |
COPYRIGHT (c) 2004 by eXept Software AG |
|
26 |
All Rights Reserved |
|
27 |
||
28 |
This software is furnished under a license and may be used |
|
29 |
only in accordance with the terms of that license and with the |
|
30 |
inclusion of the above copyright notice. This software may not |
|
31 |
be provided or otherwise made available to, or used by, any |
|
32 |
other person. No title to or ownership of the software is |
|
33 |
hereby transferred. |
|
34 |
" |
|
35 |
! ! |
|
8227 | 36 |
|
37 |
!SmalltalkChunkFileSourceWriter methodsFor:'source writing'! |
|
38 |
||
39 |
fileOut:aClass on:outStreamArg withTimeStamp:stampIt withInitialize:initIt withDefinition:withDefinition methodFilter:methodFilter encoder:encoderOrNil |
|
40 |
"file out my definition and all methods onto aStream. |
|
41 |
If stampIt is true, a timeStamp comment is prepended. |
|
42 |
If initIt is true, and the class implements a class-initialize method, |
|
43 |
append a corresponding doIt expression for initialization. |
|
44 |
The order by which the fileOut is done is used to put the version string at the end. |
|
45 |
Thus, if the version string is expanded (by CVS), the characterPositions of methods should not move" |
|
46 |
||
12043 | 47 |
|collectionOfCategories comment versionMethods |
8227 | 48 |
nonMeta meta classesImplementingInitialize outStream| |
49 |
||
11853
7c3265d8931e
save typedef methods before others to ensure that types
Claus Gittinger <cg@exept.de>
parents:
11703
diff
changeset
|
50 |
classBeingSaved := nonMeta := aClass theNonMetaclass. |
8227 | 51 |
meta := nonMeta class. |
11853
7c3265d8931e
save typedef methods before others to ensure that types
Claus Gittinger <cg@exept.de>
parents:
11703
diff
changeset
|
52 |
methodsAlreadySaved := Set new. |
8227 | 53 |
|
54 |
nonMeta isLoaded ifFalse:[ |
|
55 |
^ ClassDescription fileOutErrorSignal |
|
56 |
raiseRequestWith:nonMeta |
|
57 |
errorString:' - will not fileOut unloaded class: ', nonMeta name |
|
58 |
]. |
|
59 |
||
60 |
encoderOrNil isNil ifTrue:[ |
|
61 |
outStream := outStreamArg. |
|
62 |
] ifFalse:[ |
|
63 |
outStream := EncodedStream stream:outStreamArg encoder:encoderOrNil. |
|
64 |
outStream nextPutAll:'"{ Encoding: ' , encoderOrNil nameOfEncoding , ' }"'; cr; cr. |
|
65 |
]. |
|
66 |
||
67 |
" |
|
68 |
if there is a copyright method, add a copyright comment |
|
69 |
at the beginning, taking the string from the copyright method. |
|
70 |
We cannot do this unconditionally - that would lead to my copyrights |
|
71 |
being put on your code ;-). |
|
72 |
On the other hand: I want every file created by myself to have the |
|
73 |
copyright string at the beginning be preserved .... even if the |
|
74 |
code was edited in the browser and filedOut. |
|
75 |
" |
|
11853
7c3265d8931e
save typedef methods before others to ensure that types
Claus Gittinger <cg@exept.de>
parents:
11703
diff
changeset
|
76 |
self generateHeaderWithCopyrightOn:outStream. |
8227 | 77 |
|
78 |
stampIt ifTrue:[ |
|
79 |
"/ |
|
80 |
"/ first, a timestamp |
|
81 |
"/ |
|
82 |
outStream nextPutAll:(Smalltalk timeStamp). |
|
83 |
outStream nextPutChunkSeparator. |
|
84 |
outStream cr; cr. |
|
85 |
]. |
|
86 |
||
87 |
withDefinition ifTrue:[ |
|
88 |
"/ |
|
89 |
"/ then the definition(s) |
|
90 |
"/ |
|
91 |
self fileOutAllDefinitionsOf:nonMeta on:outStream. |
|
92 |
"/ |
|
93 |
"/ a comment - if any |
|
94 |
"/ |
|
95 |
(comment := nonMeta comment) notNil ifTrue:[ |
|
96 |
nonMeta fileOutCommentOn:outStream. |
|
97 |
outStream cr. |
|
98 |
]. |
|
99 |
"/ |
|
11853
7c3265d8931e
save typedef methods before others to ensure that types
Claus Gittinger <cg@exept.de>
parents:
11703
diff
changeset
|
100 |
"/ ST/X primitive definitions - if any |
8227 | 101 |
"/ |
102 |
nonMeta fileOutPrimitiveSpecsOn:outStream. |
|
103 |
]. |
|
104 |
||
105 |
"/ |
|
106 |
"/ methods from all categories in metaclass (i.e. class methods) |
|
107 |
"/ EXCEPT: the version method is placed at the very end, to |
|
108 |
"/ avoid sourcePosition-shifts when checked out later. |
|
109 |
"/ (RCS expands this string, so its size is not constant) |
|
110 |
"/ |
|
111 |
collectionOfCategories := meta categories asSortedCollection. |
|
12045
ccb1c727370b
changed: #fileOut:on:withTimeStamp:withInitialize:withDefinition:methodFilter:encoder:
fm
parents:
12043
diff
changeset
|
112 |
versionMethods := meta methodDictionary values select:[:mthd | mthd isVersionMethod]. |
ccb1c727370b
changed: #fileOut:on:withTimeStamp:withInitialize:withDefinition:methodFilter:encoder:
fm
parents:
12043
diff
changeset
|
113 |
|
8227 | 114 |
collectionOfCategories notNil ifTrue:[ |
115 |
"/ |
|
116 |
"/ documentation first (if any), but not the version method |
|
117 |
"/ |
|
118 |
(collectionOfCategories includes:'documentation') ifTrue:[ |
|
12043 | 119 |
|
120 |
versionMethods do:[:versionMethod | |
|
11595
f1b9ec9e73ba
when filing out, check that version method source looks ok.
Stefan Vogel <sv@exept.de>
parents:
10037
diff
changeset
|
121 |
|source| |
f1b9ec9e73ba
when filing out, check that version method source looks ok.
Stefan Vogel <sv@exept.de>
parents:
10037
diff
changeset
|
122 |
|
f1b9ec9e73ba
when filing out, check that version method source looks ok.
Stefan Vogel <sv@exept.de>
parents:
10037
diff
changeset
|
123 |
source := versionMethod source. |
f1b9ec9e73ba
when filing out, check that version method source looks ok.
Stefan Vogel <sv@exept.de>
parents:
10037
diff
changeset
|
124 |
(source isEmptyOrNil or:[(source startsWith:nonMeta nameOfVersionMethod) not]) ifTrue:[ |
f1b9ec9e73ba
when filing out, check that version method source looks ok.
Stefan Vogel <sv@exept.de>
parents:
10037
diff
changeset
|
125 |
"something bad happend to the classes code" |
f1b9ec9e73ba
when filing out, check that version method source looks ok.
Stefan Vogel <sv@exept.de>
parents:
10037
diff
changeset
|
126 |
|
f1b9ec9e73ba
when filing out, check that version method source looks ok.
Stefan Vogel <sv@exept.de>
parents:
10037
diff
changeset
|
127 |
Class fileOutErrorSignal |
f1b9ec9e73ba
when filing out, check that version method source looks ok.
Stefan Vogel <sv@exept.de>
parents:
10037
diff
changeset
|
128 |
raiseRequestWith:aClass |
f1b9ec9e73ba
when filing out, check that version method source looks ok.
Stefan Vogel <sv@exept.de>
parents:
10037
diff
changeset
|
129 |
errorString:' - bad source for version method (uncompiled class file?): ', (versionMethod displayString) |
f1b9ec9e73ba
when filing out, check that version method source looks ok.
Stefan Vogel <sv@exept.de>
parents:
10037
diff
changeset
|
130 |
]. |
8227 | 131 |
]. |
12043 | 132 |
|
133 |
self fileOutCategory:'documentation' of:meta except:versionMethods only:nil methodFilter:methodFilter on:outStream. |
|
8227 | 134 |
outStream cr. |
135 |
]. |
|
136 |
||
137 |
"/ |
|
138 |
"/ initialization next (if any) |
|
139 |
"/ |
|
140 |
(collectionOfCategories includes:'initialization') ifTrue:[ |
|
141 |
self fileOutCategory:'initialization' of:meta methodFilter:methodFilter on:outStream. |
|
142 |
outStream cr. |
|
143 |
]. |
|
144 |
||
145 |
"/ |
|
146 |
"/ instance creation next (if any) |
|
147 |
"/ |
|
148 |
(collectionOfCategories includes:'instance creation') ifTrue:[ |
|
149 |
self fileOutCategory:'instance creation' of:meta methodFilter:methodFilter on:outStream. |
|
150 |
outStream cr. |
|
151 |
]. |
|
152 |
collectionOfCategories do:[:aCategory | |
|
153 |
((aCategory ~= 'documentation') |
|
154 |
and:[(aCategory ~= 'initialization') |
|
155 |
and:[aCategory ~= 'instance creation']]) ifTrue:[ |
|
156 |
self fileOutCategory:aCategory of:meta methodFilter:methodFilter on:outStream. |
|
157 |
outStream cr |
|
158 |
] |
|
159 |
] |
|
160 |
]. |
|
161 |
||
11853
7c3265d8931e
save typedef methods before others to ensure that types
Claus Gittinger <cg@exept.de>
parents:
11703
diff
changeset
|
162 |
"/ if there are any primitive definitions (vw-like ffi-primitives), |
7c3265d8931e
save typedef methods before others to ensure that types
Claus Gittinger <cg@exept.de>
parents:
11703
diff
changeset
|
163 |
"/ file them out first in the order: defines, types. |
7c3265d8931e
save typedef methods before others to ensure that types
Claus Gittinger <cg@exept.de>
parents:
11703
diff
changeset
|
164 |
"/ Otherwise, we might have trouble when filing in later, because the types are needed |
7c3265d8931e
save typedef methods before others to ensure that types
Claus Gittinger <cg@exept.de>
parents:
11703
diff
changeset
|
165 |
"/ for the primitive calls. |
7c3265d8931e
save typedef methods before others to ensure that types
Claus Gittinger <cg@exept.de>
parents:
11703
diff
changeset
|
166 |
nonMeta methodDictionary keysAndValuesDo:[:sel :m | |
7c3265d8931e
save typedef methods before others to ensure that types
Claus Gittinger <cg@exept.de>
parents:
11703
diff
changeset
|
167 |
m isVisualWorksTypedef ifTrue:[ |
7c3265d8931e
save typedef methods before others to ensure that types
Claus Gittinger <cg@exept.de>
parents:
11703
diff
changeset
|
168 |
self fileOutCategory:m category of:nonMeta except:nil only:(Array with:m) methodFilter:methodFilter on:outStream. |
7c3265d8931e
save typedef methods before others to ensure that types
Claus Gittinger <cg@exept.de>
parents:
11703
diff
changeset
|
169 |
]. |
7c3265d8931e
save typedef methods before others to ensure that types
Claus Gittinger <cg@exept.de>
parents:
11703
diff
changeset
|
170 |
]. |
7c3265d8931e
save typedef methods before others to ensure that types
Claus Gittinger <cg@exept.de>
parents:
11703
diff
changeset
|
171 |
|
8227 | 172 |
"/ |
173 |
"/ methods from all categories |
|
174 |
"/ |
|
175 |
collectionOfCategories := nonMeta categories asSortedCollection. |
|
176 |
collectionOfCategories notNil ifTrue:[ |
|
177 |
collectionOfCategories do:[:aCategory | |
|
178 |
self fileOutCategory:aCategory of:nonMeta methodFilter:methodFilter on:outStream. |
|
179 |
outStream cr |
|
180 |
] |
|
181 |
]. |
|
182 |
||
183 |
"/ |
|
184 |
"/ any private classes' methods |
|
185 |
"/ |
|
186 |
nonMeta privateClassesSorted do:[:aClass | |
|
187 |
self fileOutAllMethodsOf:aClass on:outStream methodFilter:methodFilter |
|
188 |
]. |
|
189 |
||
190 |
||
191 |
"/ |
|
192 |
"/ finally, the previously skipped version method |
|
193 |
"/ |
|
12043 | 194 |
versionMethods notEmpty ifTrue: [ |
195 |
self fileOutCategory:'documentation' of:meta except:nil only:versionMethods methodFilter:methodFilter on:outStream. |
|
8227 | 196 |
]. |
197 |
||
198 |
initIt ifTrue:[ |
|
199 |
"/ |
|
200 |
"/ optionally an initialize message |
|
201 |
"/ |
|
202 |
classesImplementingInitialize := OrderedCollection new. |
|
203 |
||
204 |
(meta includesSelector:#initialize) ifTrue:[ |
|
205 |
classesImplementingInitialize add:nonMeta |
|
206 |
]. |
|
207 |
nonMeta privateClassesSorted do:[:aPrivateClass | |
|
208 |
(aPrivateClass theMetaclass includesSelector:#initialize) ifTrue:[ |
|
209 |
classesImplementingInitialize add:aPrivateClass |
|
210 |
] |
|
211 |
]. |
|
212 |
classesImplementingInitialize size ~~ 0 ifTrue:[ |
|
213 |
classesImplementingInitialize topologicalSort:[:a :b | b isSubclassOf:a]. |
|
214 |
outStream cr. |
|
215 |
classesImplementingInitialize do:[:eachClass | |
|
216 |
eachClass printClassNameOn:outStream. outStream nextPutAll:' initialize'. |
|
217 |
outStream nextPutChunkSeparator. |
|
218 |
outStream cr. |
|
219 |
]. |
|
220 |
]. |
|
221 |
] |
|
222 |
||
10036
51489deaf8c5
care for non-comment in copyright method (JUN stuff)
Claus Gittinger <cg@exept.de>
parents:
8728
diff
changeset
|
223 |
"Created: / 15-11-1995 / 12:53:06 / cg" |
51489deaf8c5
care for non-comment in copyright method (JUN stuff)
Claus Gittinger <cg@exept.de>
parents:
8728
diff
changeset
|
224 |
"Modified: / 01-04-1997 / 16:01:05 / stefan" |
10037 | 225 |
"Modified: / 04-10-2006 / 17:28:33 / cg" |
8227 | 226 |
! |
227 |
||
228 |
fileOutAllDefinitionsOf:aNonMetaClass on:aStream |
|
229 |
"append expressions on aStream, which defines myself and all of my private classes." |
|
230 |
||
231 |
aNonMetaClass fileOutDefinitionOn:aStream. |
|
232 |
aStream nextPutChunkSeparator. |
|
233 |
aStream cr; cr. |
|
234 |
||
235 |
"/ |
|
236 |
"/ optional classInstanceVariables |
|
237 |
"/ |
|
238 |
aNonMetaClass class instanceVariableString isBlank ifFalse:[ |
|
239 |
aNonMetaClass fileOutClassInstVarDefinitionOn:aStream. |
|
240 |
aStream nextPutChunkSeparator. |
|
241 |
aStream cr; cr |
|
242 |
]. |
|
243 |
||
244 |
"/ here, the full nameSpace prefixes are output, |
|
245 |
"/ to avoid confusing stc |
|
246 |
"/ (which otherwise could not find the correct superclass) |
|
247 |
"/ |
|
248 |
Class fileOutNameSpaceQuerySignal answer:false do:[ |
|
249 |
Class forceNoNameSpaceQuerySignal answer:true do:[ |
|
250 |
aNonMetaClass privateClassesSorted do:[:aClass | |
|
251 |
self fileOutAllDefinitionsOf:aClass on:aStream |
|
252 |
] |
|
253 |
] |
|
254 |
]. |
|
255 |
||
256 |
"Created: 15.10.1996 / 11:15:19 / cg" |
|
257 |
"Modified: 22.3.1997 / 16:11:56 / cg" |
|
258 |
! |
|
259 |
||
260 |
fileOutAllMethodsOf:aClass on:aStream methodFilter:methodFilter |
|
261 |
|collectionOfCategories| |
|
262 |
||
263 |
collectionOfCategories := aClass class categories asSortedCollection. |
|
264 |
collectionOfCategories notNil ifTrue:[ |
|
265 |
collectionOfCategories do:[:aCategory | |
|
266 |
self fileOutCategory:aCategory of:aClass class methodFilter:methodFilter on:aStream. |
|
267 |
aStream cr |
|
268 |
] |
|
269 |
]. |
|
270 |
collectionOfCategories := aClass categories asSortedCollection. |
|
271 |
collectionOfCategories notNil ifTrue:[ |
|
272 |
collectionOfCategories do:[:aCategory | |
|
273 |
self fileOutCategory:aCategory of:aClass methodFilter:methodFilter on:aStream. |
|
274 |
aStream cr |
|
275 |
] |
|
276 |
]. |
|
277 |
||
278 |
aClass privateClassesSorted do:[:aClass | |
|
279 |
self fileOutAllMethodsOf:aClass on:aStream methodFilter:methodFilter |
|
280 |
]. |
|
281 |
||
282 |
"Created: 15.10.1996 / 11:13:00 / cg" |
|
283 |
"Modified: 22.3.1997 / 16:12:17 / cg" |
|
284 |
! |
|
285 |
||
286 |
fileOutCategory:aCategory of:aClass except:skippedMethods only:savedMethods methodFilter:methodFilter on:aStream |
|
287 |
"file out all methods belonging to aCategory, aString onto aStream. |
|
288 |
If skippedMethods is nonNil, those are not saved. |
|
289 |
If savedMethods is nonNil, only those are saved. |
|
290 |
If both are nil, all are saved. See version-method handling in |
|
291 |
fileOut for what this is needed." |
|
292 |
||
11853
7c3265d8931e
save typedef methods before others to ensure that types
Claus Gittinger <cg@exept.de>
parents:
11703
diff
changeset
|
293 |
|sortedSelectors first prevPrivacy privacy interestingMethods cat| |
11701 | 294 |
|
295 |
interestingMethods := OrderedCollection new. |
|
296 |
aClass methodsDo:[:aMethod | |
|
297 |
|wanted| |
|
8227 | 298 |
|
11853
7c3265d8931e
save typedef methods before others to ensure that types
Claus Gittinger <cg@exept.de>
parents:
11703
diff
changeset
|
299 |
(methodsAlreadySaved includes:aMethod) ifFalse:[ |
11701 | 300 |
(aCategory = aMethod category) ifTrue:[ |
11853
7c3265d8931e
save typedef methods before others to ensure that types
Claus Gittinger <cg@exept.de>
parents:
11703
diff
changeset
|
301 |
(methodFilter isNil or:[methodFilter value:aMethod]) ifTrue:[ |
7c3265d8931e
save typedef methods before others to ensure that types
Claus Gittinger <cg@exept.de>
parents:
11703
diff
changeset
|
302 |
skippedMethods notNil ifTrue:[ |
7c3265d8931e
save typedef methods before others to ensure that types
Claus Gittinger <cg@exept.de>
parents:
11703
diff
changeset
|
303 |
wanted := (skippedMethods includesIdentical:aMethod) not |
8227 | 304 |
] ifFalse:[ |
11853
7c3265d8931e
save typedef methods before others to ensure that types
Claus Gittinger <cg@exept.de>
parents:
11703
diff
changeset
|
305 |
wanted := savedMethods isNil or:[ savedMethods includesIdentical:aMethod ]. |
11703
54e2c3acf7a7
skip non-symbol-selector methods when filing out
Claus Gittinger <cg@exept.de>
parents:
11701
diff
changeset
|
306 |
]. |
11853
7c3265d8931e
save typedef methods before others to ensure that types
Claus Gittinger <cg@exept.de>
parents:
11703
diff
changeset
|
307 |
wanted ifTrue:[ |
7c3265d8931e
save typedef methods before others to ensure that types
Claus Gittinger <cg@exept.de>
parents:
11703
diff
changeset
|
308 |
aMethod selector isSymbol ifTrue:[ |
7c3265d8931e
save typedef methods before others to ensure that types
Claus Gittinger <cg@exept.de>
parents:
11703
diff
changeset
|
309 |
interestingMethods add:aMethod |
7c3265d8931e
save typedef methods before others to ensure that types
Claus Gittinger <cg@exept.de>
parents:
11703
diff
changeset
|
310 |
] ifFalse:[ |
7c3265d8931e
save typedef methods before others to ensure that types
Claus Gittinger <cg@exept.de>
parents:
11703
diff
changeset
|
311 |
Transcript showCR:'skipping non-symbol method ',aMethod selector. |
7c3265d8931e
save typedef methods before others to ensure that types
Claus Gittinger <cg@exept.de>
parents:
11703
diff
changeset
|
312 |
]. |
7c3265d8931e
save typedef methods before others to ensure that types
Claus Gittinger <cg@exept.de>
parents:
11703
diff
changeset
|
313 |
]. |
7c3265d8931e
save typedef methods before others to ensure that types
Claus Gittinger <cg@exept.de>
parents:
11703
diff
changeset
|
314 |
] |
8227 | 315 |
] |
11701 | 316 |
] |
317 |
]. |
|
318 |
interestingMethods notEmpty ifTrue:[ |
|
319 |
first := true. |
|
11853
7c3265d8931e
save typedef methods before others to ensure that types
Claus Gittinger <cg@exept.de>
parents:
11703
diff
changeset
|
320 |
prevPrivacy := nil. |
8227 | 321 |
|
11701 | 322 |
"/ |
323 |
"/ sort by selector |
|
324 |
"/ |
|
325 |
sortedSelectors := interestingMethods collect:[:m | aClass selectorAtMethod:m]. |
|
326 |
sortedSelectors sortWith:interestingMethods. |
|
8227 | 327 |
|
11853
7c3265d8931e
save typedef methods before others to ensure that types
Claus Gittinger <cg@exept.de>
parents:
11703
diff
changeset
|
328 |
interestingMethods do:[:eachMethod | |
7c3265d8931e
save typedef methods before others to ensure that types
Claus Gittinger <cg@exept.de>
parents:
11703
diff
changeset
|
329 |
privacy := eachMethod privacy. |
7c3265d8931e
save typedef methods before others to ensure that types
Claus Gittinger <cg@exept.de>
parents:
11703
diff
changeset
|
330 |
|
11701 | 331 |
first ifFalse:[ |
11853
7c3265d8931e
save typedef methods before others to ensure that types
Claus Gittinger <cg@exept.de>
parents:
11703
diff
changeset
|
332 |
privacy ~~ prevPrivacy ifTrue:[ |
11701 | 333 |
first := true. |
334 |
aStream space. |
|
8227 | 335 |
aStream nextPutChunkSeparator. |
11701 | 336 |
]. |
337 |
aStream cr; cr |
|
338 |
]. |
|
339 |
||
340 |
first ifTrue:[ |
|
341 |
aStream nextPutChunkSeparator. |
|
342 |
aClass printClassNameOn:aStream. |
|
343 |
privacy ~~ #public ifTrue:[ |
|
344 |
aStream space; nextPutAll:privacy; nextPutAll:'MethodsFor:'. |
|
345 |
] ifFalse:[ |
|
346 |
aStream nextPutAll:' methodsFor:'. |
|
8227 | 347 |
]. |
11701 | 348 |
cat := aCategory. |
349 |
cat isNil ifTrue:[ cat := '' ]. |
|
350 |
aStream nextPutAll:aCategory asString storeString. |
|
351 |
aStream nextPutChunkSeparator; cr; cr. |
|
352 |
first := false. |
|
8227 | 353 |
]. |
11853
7c3265d8931e
save typedef methods before others to ensure that types
Claus Gittinger <cg@exept.de>
parents:
11703
diff
changeset
|
354 |
self fileOutMethod:eachMethod on:aStream. |
7c3265d8931e
save typedef methods before others to ensure that types
Claus Gittinger <cg@exept.de>
parents:
11703
diff
changeset
|
355 |
methodsAlreadySaved add:eachMethod. |
7c3265d8931e
save typedef methods before others to ensure that types
Claus Gittinger <cg@exept.de>
parents:
11703
diff
changeset
|
356 |
|
7c3265d8931e
save typedef methods before others to ensure that types
Claus Gittinger <cg@exept.de>
parents:
11703
diff
changeset
|
357 |
prevPrivacy := privacy. |
11701 | 358 |
]. |
359 |
aStream space. |
|
360 |
aStream nextPutChunkSeparator. |
|
361 |
aStream cr |
|
8227 | 362 |
] |
363 |
||
364 |
"Modified: 28.8.1995 / 14:30:41 / claus" |
|
365 |
"Modified: 12.6.1996 / 11:37:33 / stefan" |
|
366 |
"Modified: 15.11.1996 / 11:32:21 / cg" |
|
367 |
"Created: 1.4.1997 / 16:04:33 / stefan" |
|
368 |
! |
|
369 |
||
370 |
fileOutCategory:aCategory of:aClass methodFilter:methodFilter on:aStream |
|
371 |
"file out all methods belonging to aCategory, aString onto aStream" |
|
372 |
||
373 |
self fileOutCategory:aCategory of:aClass except:nil only:nil methodFilter:methodFilter on:aStream |
|
374 |
||
375 |
"Created: 1.4.1997 / 16:04:44 / stefan" |
|
11853
7c3265d8931e
save typedef methods before others to ensure that types
Claus Gittinger <cg@exept.de>
parents:
11703
diff
changeset
|
376 |
! |
7c3265d8931e
save typedef methods before others to ensure that types
Claus Gittinger <cg@exept.de>
parents:
11703
diff
changeset
|
377 |
|
7c3265d8931e
save typedef methods before others to ensure that types
Claus Gittinger <cg@exept.de>
parents:
11703
diff
changeset
|
378 |
fileOutMethod:aMethod on:aStream |
7c3265d8931e
save typedef methods before others to ensure that types
Claus Gittinger <cg@exept.de>
parents:
11703
diff
changeset
|
379 |
"file a single method onto aStream." |
7c3265d8931e
save typedef methods before others to ensure that types
Claus Gittinger <cg@exept.de>
parents:
11703
diff
changeset
|
380 |
|
12043 | 381 |
|source possiblyRewrittenSource rewriteQuery| |
11853
7c3265d8931e
save typedef methods before others to ensure that types
Claus Gittinger <cg@exept.de>
parents:
11703
diff
changeset
|
382 |
|
7c3265d8931e
save typedef methods before others to ensure that types
Claus Gittinger <cg@exept.de>
parents:
11703
diff
changeset
|
383 |
source := aMethod source. |
7c3265d8931e
save typedef methods before others to ensure that types
Claus Gittinger <cg@exept.de>
parents:
11703
diff
changeset
|
384 |
source isNil ifTrue:[ |
7c3265d8931e
save typedef methods before others to ensure that types
Claus Gittinger <cg@exept.de>
parents:
11703
diff
changeset
|
385 |
Class fileOutErrorSignal |
7c3265d8931e
save typedef methods before others to ensure that types
Claus Gittinger <cg@exept.de>
parents:
11703
diff
changeset
|
386 |
raiseRequestWith:aMethod mclass |
7c3265d8931e
save typedef methods before others to ensure that types
Claus Gittinger <cg@exept.de>
parents:
11703
diff
changeset
|
387 |
errorString:' - no source for method: ', (aMethod displayString) |
7c3265d8931e
save typedef methods before others to ensure that types
Claus Gittinger <cg@exept.de>
parents:
11703
diff
changeset
|
388 |
] ifFalse:[ |
12043 | 389 |
"/ hook to allow for just-in-time rewriting of a method's sourceCode while filing out |
390 |
"/ used when saving version_XXX methods in a non-XXX sourceCodeManager |
|
391 |
"/ (i.e. to rewrite all non-CVS version methods while saving into a CVS repository) |
|
392 |
"/ this is required because we cannot save an SVN version method (dollar-ID-...-dollar) into a |
|
393 |
"/ CVS repository without loosing the original string with the next checkout, because it also gets |
|
394 |
"/ expanded by CVS. The same is true vice-versa for CVS-Ids, which get clobbered by SVN. |
|
395 |
rewriteQuery := AbstractSourceFileWriter methodSourceRewriteQuery new. |
|
396 |
rewriteQuery method:aMethod source:source. |
|
397 |
possiblyRewrittenSource := (rewriteQuery query) ? source. |
|
398 |
aStream nextChunkPut:possiblyRewrittenSource. |
|
399 |
"/possiblyRewrittenSource ~= source ifTrue: [ |
|
400 |
"/ Transcript showCR: possiblyRewrittenSource. |
|
401 |
"/]. |
|
11853
7c3265d8931e
save typedef methods before others to ensure that types
Claus Gittinger <cg@exept.de>
parents:
11703
diff
changeset
|
402 |
]. |
7c3265d8931e
save typedef methods before others to ensure that types
Claus Gittinger <cg@exept.de>
parents:
11703
diff
changeset
|
403 |
! |
7c3265d8931e
save typedef methods before others to ensure that types
Claus Gittinger <cg@exept.de>
parents:
11703
diff
changeset
|
404 |
|
7c3265d8931e
save typedef methods before others to ensure that types
Claus Gittinger <cg@exept.de>
parents:
11703
diff
changeset
|
405 |
generateHeaderWithCopyrightOn:outStream |
7c3265d8931e
save typedef methods before others to ensure that types
Claus Gittinger <cg@exept.de>
parents:
11703
diff
changeset
|
406 |
|copyrightMethod copyrightText| |
7c3265d8931e
save typedef methods before others to ensure that types
Claus Gittinger <cg@exept.de>
parents:
11703
diff
changeset
|
407 |
|
7c3265d8931e
save typedef methods before others to ensure that types
Claus Gittinger <cg@exept.de>
parents:
11703
diff
changeset
|
408 |
"if there is a copyright method, add a copyright comment |
7c3265d8931e
save typedef methods before others to ensure that types
Claus Gittinger <cg@exept.de>
parents:
11703
diff
changeset
|
409 |
at the beginning, taking the string from the copyright method. |
7c3265d8931e
save typedef methods before others to ensure that types
Claus Gittinger <cg@exept.de>
parents:
11703
diff
changeset
|
410 |
We cannot do this unconditionally - that would lead to my copyrights |
7c3265d8931e
save typedef methods before others to ensure that types
Claus Gittinger <cg@exept.de>
parents:
11703
diff
changeset
|
411 |
being put on your code ;-). |
7c3265d8931e
save typedef methods before others to ensure that types
Claus Gittinger <cg@exept.de>
parents:
11703
diff
changeset
|
412 |
On the other hand: I want every file created by myself to have the |
7c3265d8931e
save typedef methods before others to ensure that types
Claus Gittinger <cg@exept.de>
parents:
11703
diff
changeset
|
413 |
copyright string at the beginning be preserved .... even if the |
7c3265d8931e
save typedef methods before others to ensure that types
Claus Gittinger <cg@exept.de>
parents:
11703
diff
changeset
|
414 |
code was edited in the browser and filedOut." |
7c3265d8931e
save typedef methods before others to ensure that types
Claus Gittinger <cg@exept.de>
parents:
11703
diff
changeset
|
415 |
|
7c3265d8931e
save typedef methods before others to ensure that types
Claus Gittinger <cg@exept.de>
parents:
11703
diff
changeset
|
416 |
(copyrightMethod := classBeingSaved theMetaclass compiledMethodAt:#copyright) notNil ifTrue:[ |
7c3265d8931e
save typedef methods before others to ensure that types
Claus Gittinger <cg@exept.de>
parents:
11703
diff
changeset
|
417 |
" |
7c3265d8931e
save typedef methods before others to ensure that types
Claus Gittinger <cg@exept.de>
parents:
11703
diff
changeset
|
418 |
get the copyright method's comment-text, strip off empty and blank lines |
7c3265d8931e
save typedef methods before others to ensure that types
Claus Gittinger <cg@exept.de>
parents:
11703
diff
changeset
|
419 |
and insert at beginning. |
7c3265d8931e
save typedef methods before others to ensure that types
Claus Gittinger <cg@exept.de>
parents:
11703
diff
changeset
|
420 |
" |
7c3265d8931e
save typedef methods before others to ensure that types
Claus Gittinger <cg@exept.de>
parents:
11703
diff
changeset
|
421 |
copyrightText := copyrightMethod comment. |
7c3265d8931e
save typedef methods before others to ensure that types
Claus Gittinger <cg@exept.de>
parents:
11703
diff
changeset
|
422 |
copyrightText notEmptyOrNil ifTrue:[ |
7c3265d8931e
save typedef methods before others to ensure that types
Claus Gittinger <cg@exept.de>
parents:
11703
diff
changeset
|
423 |
copyrightText := copyrightText asCollectionOfLines asStringCollection. |
7c3265d8931e
save typedef methods before others to ensure that types
Claus Gittinger <cg@exept.de>
parents:
11703
diff
changeset
|
424 |
copyrightText := copyrightText withoutLeadingBlankLines. |
7c3265d8931e
save typedef methods before others to ensure that types
Claus Gittinger <cg@exept.de>
parents:
11703
diff
changeset
|
425 |
copyrightText := copyrightText withoutTrailingBlankLines. |
7c3265d8931e
save typedef methods before others to ensure that types
Claus Gittinger <cg@exept.de>
parents:
11703
diff
changeset
|
426 |
copyrightText notEmpty ifTrue:[ |
7c3265d8931e
save typedef methods before others to ensure that types
Claus Gittinger <cg@exept.de>
parents:
11703
diff
changeset
|
427 |
copyrightText addFirst:'"'. |
7c3265d8931e
save typedef methods before others to ensure that types
Claus Gittinger <cg@exept.de>
parents:
11703
diff
changeset
|
428 |
copyrightText addLast:'"'. |
7c3265d8931e
save typedef methods before others to ensure that types
Claus Gittinger <cg@exept.de>
parents:
11703
diff
changeset
|
429 |
copyrightText := copyrightText asString. |
7c3265d8931e
save typedef methods before others to ensure that types
Claus Gittinger <cg@exept.de>
parents:
11703
diff
changeset
|
430 |
outStream nextPutAllAsChunk:copyrightText. |
7c3265d8931e
save typedef methods before others to ensure that types
Claus Gittinger <cg@exept.de>
parents:
11703
diff
changeset
|
431 |
]. |
7c3265d8931e
save typedef methods before others to ensure that types
Claus Gittinger <cg@exept.de>
parents:
11703
diff
changeset
|
432 |
]. |
7c3265d8931e
save typedef methods before others to ensure that types
Claus Gittinger <cg@exept.de>
parents:
11703
diff
changeset
|
433 |
]. |
8227 | 434 |
! ! |
435 |
||
436 |
!SmalltalkChunkFileSourceWriter class methodsFor:'documentation'! |
|
437 |
||
438 |
version |
|
12045
ccb1c727370b
changed: #fileOut:on:withTimeStamp:withInitialize:withDefinition:methodFilter:encoder:
fm
parents:
12043
diff
changeset
|
439 |
^ '$Header: /cvs/stx/stx/libbasic/SmalltalkChunkFileSourceWriter.st,v 1.11 2009-09-29 17:20:13 fm Exp $' |
12043 | 440 |
! |
441 |
||
442 |
version_CVS |
|
12045
ccb1c727370b
changed: #fileOut:on:withTimeStamp:withInitialize:withDefinition:methodFilter:encoder:
fm
parents:
12043
diff
changeset
|
443 |
^ '$Header: /cvs/stx/stx/libbasic/SmalltalkChunkFileSourceWriter.st,v 1.11 2009-09-29 17:20:13 fm Exp $' |
8227 | 444 |
! ! |