author | fm |
Thu, 17 Sep 2009 16:14:59 +0200 | |
changeset 11963 | 0419e28049e4 |
parent 11853 | 7c3265d8931e |
child 12043 | 80c7abaa0adf |
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 |
||
11853
7c3265d8931e
save typedef methods before others to ensure that types
Claus Gittinger <cg@exept.de>
parents:
11703
diff
changeset
|
47 |
|collectionOfCategories comment versionMethod skippedMethods |
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. |
|
112 |
collectionOfCategories notNil ifTrue:[ |
|
113 |
"/ |
|
114 |
"/ documentation first (if any), but not the version method |
|
115 |
"/ |
|
116 |
(collectionOfCategories includes:'documentation') ifTrue:[ |
|
117 |
versionMethod := meta compiledMethodAt:(nonMeta nameOfVersionMethod). |
|
118 |
versionMethod notNil ifTrue:[ |
|
11595
f1b9ec9e73ba
when filing out, check that version method source looks ok.
Stefan Vogel <sv@exept.de>
parents:
10037
diff
changeset
|
119 |
|source| |
f1b9ec9e73ba
when filing out, check that version method source looks ok.
Stefan Vogel <sv@exept.de>
parents:
10037
diff
changeset
|
120 |
|
f1b9ec9e73ba
when filing out, check that version method source looks ok.
Stefan Vogel <sv@exept.de>
parents:
10037
diff
changeset
|
121 |
source := versionMethod source. |
f1b9ec9e73ba
when filing out, check that version method source looks ok.
Stefan Vogel <sv@exept.de>
parents:
10037
diff
changeset
|
122 |
(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
|
123 |
"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
|
124 |
|
f1b9ec9e73ba
when filing out, check that version method source looks ok.
Stefan Vogel <sv@exept.de>
parents:
10037
diff
changeset
|
125 |
Class fileOutErrorSignal |
f1b9ec9e73ba
when filing out, check that version method source looks ok.
Stefan Vogel <sv@exept.de>
parents:
10037
diff
changeset
|
126 |
raiseRequestWith:aClass |
f1b9ec9e73ba
when filing out, check that version method source looks ok.
Stefan Vogel <sv@exept.de>
parents:
10037
diff
changeset
|
127 |
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
|
128 |
]. |
f1b9ec9e73ba
when filing out, check that version method source looks ok.
Stefan Vogel <sv@exept.de>
parents:
10037
diff
changeset
|
129 |
skippedMethods := Array with:versionMethod. |
8227 | 130 |
]. |
131 |
self fileOutCategory:'documentation' of:meta except:skippedMethods only:nil methodFilter:methodFilter on:outStream. |
|
132 |
outStream cr. |
|
133 |
]. |
|
134 |
||
135 |
"/ |
|
136 |
"/ initialization next (if any) |
|
137 |
"/ |
|
138 |
(collectionOfCategories includes:'initialization') ifTrue:[ |
|
139 |
self fileOutCategory:'initialization' of:meta methodFilter:methodFilter on:outStream. |
|
140 |
outStream cr. |
|
141 |
]. |
|
142 |
||
143 |
"/ |
|
144 |
"/ instance creation next (if any) |
|
145 |
"/ |
|
146 |
(collectionOfCategories includes:'instance creation') ifTrue:[ |
|
147 |
self fileOutCategory:'instance creation' of:meta methodFilter:methodFilter on:outStream. |
|
148 |
outStream cr. |
|
149 |
]. |
|
150 |
collectionOfCategories do:[:aCategory | |
|
151 |
((aCategory ~= 'documentation') |
|
152 |
and:[(aCategory ~= 'initialization') |
|
153 |
and:[aCategory ~= 'instance creation']]) ifTrue:[ |
|
154 |
self fileOutCategory:aCategory of:meta methodFilter:methodFilter on:outStream. |
|
155 |
outStream cr |
|
156 |
] |
|
157 |
] |
|
158 |
]. |
|
159 |
||
11853
7c3265d8931e
save typedef methods before others to ensure that types
Claus Gittinger <cg@exept.de>
parents:
11703
diff
changeset
|
160 |
"/ 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
|
161 |
"/ 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
|
162 |
"/ 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
|
163 |
"/ for the primitive calls. |
7c3265d8931e
save typedef methods before others to ensure that types
Claus Gittinger <cg@exept.de>
parents:
11703
diff
changeset
|
164 |
nonMeta methodDictionary keysAndValuesDo:[:sel :m | |
7c3265d8931e
save typedef methods before others to ensure that types
Claus Gittinger <cg@exept.de>
parents:
11703
diff
changeset
|
165 |
m isVisualWorksTypedef ifTrue:[ |
7c3265d8931e
save typedef methods before others to ensure that types
Claus Gittinger <cg@exept.de>
parents:
11703
diff
changeset
|
166 |
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
|
167 |
]. |
7c3265d8931e
save typedef methods before others to ensure that types
Claus Gittinger <cg@exept.de>
parents:
11703
diff
changeset
|
168 |
]. |
7c3265d8931e
save typedef methods before others to ensure that types
Claus Gittinger <cg@exept.de>
parents:
11703
diff
changeset
|
169 |
|
8227 | 170 |
"/ |
171 |
"/ methods from all categories |
|
172 |
"/ |
|
173 |
collectionOfCategories := nonMeta categories asSortedCollection. |
|
174 |
collectionOfCategories notNil ifTrue:[ |
|
175 |
collectionOfCategories do:[:aCategory | |
|
176 |
self fileOutCategory:aCategory of:nonMeta methodFilter:methodFilter on:outStream. |
|
177 |
outStream cr |
|
178 |
] |
|
179 |
]. |
|
180 |
||
181 |
"/ |
|
182 |
"/ any private classes' methods |
|
183 |
"/ |
|
184 |
nonMeta privateClassesSorted do:[:aClass | |
|
185 |
self fileOutAllMethodsOf:aClass on:outStream methodFilter:methodFilter |
|
186 |
]. |
|
187 |
||
188 |
||
189 |
"/ |
|
190 |
"/ finally, the previously skipped version method |
|
191 |
"/ |
|
192 |
versionMethod notNil ifTrue:[ |
|
193 |
self fileOutCategory:'documentation' of:meta except:nil only:skippedMethods methodFilter:methodFilter on:outStream. |
|
194 |
]. |
|
195 |
||
196 |
initIt ifTrue:[ |
|
197 |
"/ |
|
198 |
"/ optionally an initialize message |
|
199 |
"/ |
|
200 |
classesImplementingInitialize := OrderedCollection new. |
|
201 |
||
202 |
(meta includesSelector:#initialize) ifTrue:[ |
|
203 |
classesImplementingInitialize add:nonMeta |
|
204 |
]. |
|
205 |
nonMeta privateClassesSorted do:[:aPrivateClass | |
|
206 |
(aPrivateClass theMetaclass includesSelector:#initialize) ifTrue:[ |
|
207 |
classesImplementingInitialize add:aPrivateClass |
|
208 |
] |
|
209 |
]. |
|
210 |
classesImplementingInitialize size ~~ 0 ifTrue:[ |
|
211 |
classesImplementingInitialize topologicalSort:[:a :b | b isSubclassOf:a]. |
|
212 |
outStream cr. |
|
213 |
classesImplementingInitialize do:[:eachClass | |
|
214 |
eachClass printClassNameOn:outStream. outStream nextPutAll:' initialize'. |
|
215 |
outStream nextPutChunkSeparator. |
|
216 |
outStream cr. |
|
217 |
]. |
|
218 |
]. |
|
219 |
] |
|
220 |
||
10036
51489deaf8c5
care for non-comment in copyright method (JUN stuff)
Claus Gittinger <cg@exept.de>
parents:
8728
diff
changeset
|
221 |
"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
|
222 |
"Modified: / 01-04-1997 / 16:01:05 / stefan" |
10037 | 223 |
"Modified: / 04-10-2006 / 17:28:33 / cg" |
8227 | 224 |
! |
225 |
||
226 |
fileOutAllDefinitionsOf:aNonMetaClass on:aStream |
|
227 |
"append expressions on aStream, which defines myself and all of my private classes." |
|
228 |
||
229 |
aNonMetaClass fileOutDefinitionOn:aStream. |
|
230 |
aStream nextPutChunkSeparator. |
|
231 |
aStream cr; cr. |
|
232 |
||
233 |
"/ |
|
234 |
"/ optional classInstanceVariables |
|
235 |
"/ |
|
236 |
aNonMetaClass class instanceVariableString isBlank ifFalse:[ |
|
237 |
aNonMetaClass fileOutClassInstVarDefinitionOn:aStream. |
|
238 |
aStream nextPutChunkSeparator. |
|
239 |
aStream cr; cr |
|
240 |
]. |
|
241 |
||
242 |
"/ here, the full nameSpace prefixes are output, |
|
243 |
"/ to avoid confusing stc |
|
244 |
"/ (which otherwise could not find the correct superclass) |
|
245 |
"/ |
|
246 |
Class fileOutNameSpaceQuerySignal answer:false do:[ |
|
247 |
Class forceNoNameSpaceQuerySignal answer:true do:[ |
|
248 |
aNonMetaClass privateClassesSorted do:[:aClass | |
|
249 |
self fileOutAllDefinitionsOf:aClass on:aStream |
|
250 |
] |
|
251 |
] |
|
252 |
]. |
|
253 |
||
254 |
"Created: 15.10.1996 / 11:15:19 / cg" |
|
255 |
"Modified: 22.3.1997 / 16:11:56 / cg" |
|
256 |
! |
|
257 |
||
258 |
fileOutAllMethodsOf:aClass on:aStream methodFilter:methodFilter |
|
259 |
|collectionOfCategories| |
|
260 |
||
261 |
collectionOfCategories := aClass class categories asSortedCollection. |
|
262 |
collectionOfCategories notNil ifTrue:[ |
|
263 |
collectionOfCategories do:[:aCategory | |
|
264 |
self fileOutCategory:aCategory of:aClass class methodFilter:methodFilter on:aStream. |
|
265 |
aStream cr |
|
266 |
] |
|
267 |
]. |
|
268 |
collectionOfCategories := aClass categories asSortedCollection. |
|
269 |
collectionOfCategories notNil ifTrue:[ |
|
270 |
collectionOfCategories do:[:aCategory | |
|
271 |
self fileOutCategory:aCategory of:aClass methodFilter:methodFilter on:aStream. |
|
272 |
aStream cr |
|
273 |
] |
|
274 |
]. |
|
275 |
||
276 |
aClass privateClassesSorted do:[:aClass | |
|
277 |
self fileOutAllMethodsOf:aClass on:aStream methodFilter:methodFilter |
|
278 |
]. |
|
279 |
||
280 |
"Created: 15.10.1996 / 11:13:00 / cg" |
|
281 |
"Modified: 22.3.1997 / 16:12:17 / cg" |
|
282 |
! |
|
283 |
||
284 |
fileOutCategory:aCategory of:aClass except:skippedMethods only:savedMethods methodFilter:methodFilter on:aStream |
|
285 |
"file out all methods belonging to aCategory, aString onto aStream. |
|
286 |
If skippedMethods is nonNil, those are not saved. |
|
287 |
If savedMethods is nonNil, only those are saved. |
|
288 |
If both are nil, all are saved. See version-method handling in |
|
289 |
fileOut for what this is needed." |
|
290 |
||
11853
7c3265d8931e
save typedef methods before others to ensure that types
Claus Gittinger <cg@exept.de>
parents:
11703
diff
changeset
|
291 |
|sortedSelectors first prevPrivacy privacy interestingMethods cat| |
11701 | 292 |
|
293 |
interestingMethods := OrderedCollection new. |
|
294 |
aClass methodsDo:[:aMethod | |
|
295 |
|wanted| |
|
8227 | 296 |
|
11853
7c3265d8931e
save typedef methods before others to ensure that types
Claus Gittinger <cg@exept.de>
parents:
11703
diff
changeset
|
297 |
(methodsAlreadySaved includes:aMethod) ifFalse:[ |
11701 | 298 |
(aCategory = aMethod category) ifTrue:[ |
11853
7c3265d8931e
save typedef methods before others to ensure that types
Claus Gittinger <cg@exept.de>
parents:
11703
diff
changeset
|
299 |
(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
|
300 |
skippedMethods notNil ifTrue:[ |
7c3265d8931e
save typedef methods before others to ensure that types
Claus Gittinger <cg@exept.de>
parents:
11703
diff
changeset
|
301 |
wanted := (skippedMethods includesIdentical:aMethod) not |
8227 | 302 |
] ifFalse:[ |
11853
7c3265d8931e
save typedef methods before others to ensure that types
Claus Gittinger <cg@exept.de>
parents:
11703
diff
changeset
|
303 |
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
|
304 |
]. |
11853
7c3265d8931e
save typedef methods before others to ensure that types
Claus Gittinger <cg@exept.de>
parents:
11703
diff
changeset
|
305 |
wanted ifTrue:[ |
7c3265d8931e
save typedef methods before others to ensure that types
Claus Gittinger <cg@exept.de>
parents:
11703
diff
changeset
|
306 |
aMethod selector isSymbol ifTrue:[ |
7c3265d8931e
save typedef methods before others to ensure that types
Claus Gittinger <cg@exept.de>
parents:
11703
diff
changeset
|
307 |
interestingMethods add:aMethod |
7c3265d8931e
save typedef methods before others to ensure that types
Claus Gittinger <cg@exept.de>
parents:
11703
diff
changeset
|
308 |
] ifFalse:[ |
7c3265d8931e
save typedef methods before others to ensure that types
Claus Gittinger <cg@exept.de>
parents:
11703
diff
changeset
|
309 |
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
|
310 |
]. |
7c3265d8931e
save typedef methods before others to ensure that types
Claus Gittinger <cg@exept.de>
parents:
11703
diff
changeset
|
311 |
]. |
7c3265d8931e
save typedef methods before others to ensure that types
Claus Gittinger <cg@exept.de>
parents:
11703
diff
changeset
|
312 |
] |
8227 | 313 |
] |
11701 | 314 |
] |
315 |
]. |
|
316 |
interestingMethods notEmpty ifTrue:[ |
|
317 |
first := true. |
|
11853
7c3265d8931e
save typedef methods before others to ensure that types
Claus Gittinger <cg@exept.de>
parents:
11703
diff
changeset
|
318 |
prevPrivacy := nil. |
8227 | 319 |
|
11701 | 320 |
"/ |
321 |
"/ sort by selector |
|
322 |
"/ |
|
323 |
sortedSelectors := interestingMethods collect:[:m | aClass selectorAtMethod:m]. |
|
324 |
sortedSelectors sortWith:interestingMethods. |
|
8227 | 325 |
|
11853
7c3265d8931e
save typedef methods before others to ensure that types
Claus Gittinger <cg@exept.de>
parents:
11703
diff
changeset
|
326 |
interestingMethods do:[:eachMethod | |
7c3265d8931e
save typedef methods before others to ensure that types
Claus Gittinger <cg@exept.de>
parents:
11703
diff
changeset
|
327 |
privacy := eachMethod privacy. |
7c3265d8931e
save typedef methods before others to ensure that types
Claus Gittinger <cg@exept.de>
parents:
11703
diff
changeset
|
328 |
|
11701 | 329 |
first ifFalse:[ |
11853
7c3265d8931e
save typedef methods before others to ensure that types
Claus Gittinger <cg@exept.de>
parents:
11703
diff
changeset
|
330 |
privacy ~~ prevPrivacy ifTrue:[ |
11701 | 331 |
first := true. |
332 |
aStream space. |
|
8227 | 333 |
aStream nextPutChunkSeparator. |
11701 | 334 |
]. |
335 |
aStream cr; cr |
|
336 |
]. |
|
337 |
||
338 |
first ifTrue:[ |
|
339 |
aStream nextPutChunkSeparator. |
|
340 |
aClass printClassNameOn:aStream. |
|
341 |
privacy ~~ #public ifTrue:[ |
|
342 |
aStream space; nextPutAll:privacy; nextPutAll:'MethodsFor:'. |
|
343 |
] ifFalse:[ |
|
344 |
aStream nextPutAll:' methodsFor:'. |
|
8227 | 345 |
]. |
11701 | 346 |
cat := aCategory. |
347 |
cat isNil ifTrue:[ cat := '' ]. |
|
348 |
aStream nextPutAll:aCategory asString storeString. |
|
349 |
aStream nextPutChunkSeparator; cr; cr. |
|
350 |
first := false. |
|
8227 | 351 |
]. |
11853
7c3265d8931e
save typedef methods before others to ensure that types
Claus Gittinger <cg@exept.de>
parents:
11703
diff
changeset
|
352 |
self fileOutMethod:eachMethod on:aStream. |
7c3265d8931e
save typedef methods before others to ensure that types
Claus Gittinger <cg@exept.de>
parents:
11703
diff
changeset
|
353 |
methodsAlreadySaved add:eachMethod. |
7c3265d8931e
save typedef methods before others to ensure that types
Claus Gittinger <cg@exept.de>
parents:
11703
diff
changeset
|
354 |
|
7c3265d8931e
save typedef methods before others to ensure that types
Claus Gittinger <cg@exept.de>
parents:
11703
diff
changeset
|
355 |
prevPrivacy := privacy. |
11701 | 356 |
]. |
357 |
aStream space. |
|
358 |
aStream nextPutChunkSeparator. |
|
359 |
aStream cr |
|
8227 | 360 |
] |
361 |
||
362 |
"Modified: 28.8.1995 / 14:30:41 / claus" |
|
363 |
"Modified: 12.6.1996 / 11:37:33 / stefan" |
|
364 |
"Modified: 15.11.1996 / 11:32:21 / cg" |
|
365 |
"Created: 1.4.1997 / 16:04:33 / stefan" |
|
366 |
! |
|
367 |
||
368 |
fileOutCategory:aCategory of:aClass methodFilter:methodFilter on:aStream |
|
369 |
"file out all methods belonging to aCategory, aString onto aStream" |
|
370 |
||
371 |
self fileOutCategory:aCategory of:aClass except:nil only:nil methodFilter:methodFilter on:aStream |
|
372 |
||
373 |
"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
|
374 |
! |
7c3265d8931e
save typedef methods before others to ensure that types
Claus Gittinger <cg@exept.de>
parents:
11703
diff
changeset
|
375 |
|
7c3265d8931e
save typedef methods before others to ensure that types
Claus Gittinger <cg@exept.de>
parents:
11703
diff
changeset
|
376 |
fileOutMethod:aMethod on:aStream |
7c3265d8931e
save typedef methods before others to ensure that types
Claus Gittinger <cg@exept.de>
parents:
11703
diff
changeset
|
377 |
"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
|
378 |
|
7c3265d8931e
save typedef methods before others to ensure that types
Claus Gittinger <cg@exept.de>
parents:
11703
diff
changeset
|
379 |
|source| |
7c3265d8931e
save typedef methods before others to ensure that types
Claus Gittinger <cg@exept.de>
parents:
11703
diff
changeset
|
380 |
|
7c3265d8931e
save typedef methods before others to ensure that types
Claus Gittinger <cg@exept.de>
parents:
11703
diff
changeset
|
381 |
source := aMethod source. |
7c3265d8931e
save typedef methods before others to ensure that types
Claus Gittinger <cg@exept.de>
parents:
11703
diff
changeset
|
382 |
source isNil ifTrue:[ |
7c3265d8931e
save typedef methods before others to ensure that types
Claus Gittinger <cg@exept.de>
parents:
11703
diff
changeset
|
383 |
Class fileOutErrorSignal |
7c3265d8931e
save typedef methods before others to ensure that types
Claus Gittinger <cg@exept.de>
parents:
11703
diff
changeset
|
384 |
raiseRequestWith:aMethod mclass |
7c3265d8931e
save typedef methods before others to ensure that types
Claus Gittinger <cg@exept.de>
parents:
11703
diff
changeset
|
385 |
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
|
386 |
] ifFalse:[ |
7c3265d8931e
save typedef methods before others to ensure that types
Claus Gittinger <cg@exept.de>
parents:
11703
diff
changeset
|
387 |
aStream nextChunkPut:source. |
7c3265d8931e
save typedef methods before others to ensure that types
Claus Gittinger <cg@exept.de>
parents:
11703
diff
changeset
|
388 |
]. |
7c3265d8931e
save typedef methods before others to ensure that types
Claus Gittinger <cg@exept.de>
parents:
11703
diff
changeset
|
389 |
! |
7c3265d8931e
save typedef methods before others to ensure that types
Claus Gittinger <cg@exept.de>
parents:
11703
diff
changeset
|
390 |
|
7c3265d8931e
save typedef methods before others to ensure that types
Claus Gittinger <cg@exept.de>
parents:
11703
diff
changeset
|
391 |
generateHeaderWithCopyrightOn:outStream |
7c3265d8931e
save typedef methods before others to ensure that types
Claus Gittinger <cg@exept.de>
parents:
11703
diff
changeset
|
392 |
|copyrightMethod copyrightText| |
7c3265d8931e
save typedef methods before others to ensure that types
Claus Gittinger <cg@exept.de>
parents:
11703
diff
changeset
|
393 |
|
7c3265d8931e
save typedef methods before others to ensure that types
Claus Gittinger <cg@exept.de>
parents:
11703
diff
changeset
|
394 |
"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
|
395 |
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
|
396 |
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
|
397 |
being put on your code ;-). |
7c3265d8931e
save typedef methods before others to ensure that types
Claus Gittinger <cg@exept.de>
parents:
11703
diff
changeset
|
398 |
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
|
399 |
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
|
400 |
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
|
401 |
|
7c3265d8931e
save typedef methods before others to ensure that types
Claus Gittinger <cg@exept.de>
parents:
11703
diff
changeset
|
402 |
(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
|
403 |
" |
7c3265d8931e
save typedef methods before others to ensure that types
Claus Gittinger <cg@exept.de>
parents:
11703
diff
changeset
|
404 |
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
|
405 |
and insert at beginning. |
7c3265d8931e
save typedef methods before others to ensure that types
Claus Gittinger <cg@exept.de>
parents:
11703
diff
changeset
|
406 |
" |
7c3265d8931e
save typedef methods before others to ensure that types
Claus Gittinger <cg@exept.de>
parents:
11703
diff
changeset
|
407 |
copyrightText := copyrightMethod comment. |
7c3265d8931e
save typedef methods before others to ensure that types
Claus Gittinger <cg@exept.de>
parents:
11703
diff
changeset
|
408 |
copyrightText notEmptyOrNil ifTrue:[ |
7c3265d8931e
save typedef methods before others to ensure that types
Claus Gittinger <cg@exept.de>
parents:
11703
diff
changeset
|
409 |
copyrightText := copyrightText asCollectionOfLines asStringCollection. |
7c3265d8931e
save typedef methods before others to ensure that types
Claus Gittinger <cg@exept.de>
parents:
11703
diff
changeset
|
410 |
copyrightText := copyrightText withoutLeadingBlankLines. |
7c3265d8931e
save typedef methods before others to ensure that types
Claus Gittinger <cg@exept.de>
parents:
11703
diff
changeset
|
411 |
copyrightText := copyrightText withoutTrailingBlankLines. |
7c3265d8931e
save typedef methods before others to ensure that types
Claus Gittinger <cg@exept.de>
parents:
11703
diff
changeset
|
412 |
copyrightText notEmpty ifTrue:[ |
7c3265d8931e
save typedef methods before others to ensure that types
Claus Gittinger <cg@exept.de>
parents:
11703
diff
changeset
|
413 |
copyrightText addFirst:'"'. |
7c3265d8931e
save typedef methods before others to ensure that types
Claus Gittinger <cg@exept.de>
parents:
11703
diff
changeset
|
414 |
copyrightText addLast:'"'. |
7c3265d8931e
save typedef methods before others to ensure that types
Claus Gittinger <cg@exept.de>
parents:
11703
diff
changeset
|
415 |
copyrightText := copyrightText asString. |
7c3265d8931e
save typedef methods before others to ensure that types
Claus Gittinger <cg@exept.de>
parents:
11703
diff
changeset
|
416 |
outStream nextPutAllAsChunk:copyrightText. |
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 |
]. |
7c3265d8931e
save typedef methods before others to ensure that types
Claus Gittinger <cg@exept.de>
parents:
11703
diff
changeset
|
419 |
]. |
8227 | 420 |
! ! |
421 |
||
422 |
!SmalltalkChunkFileSourceWriter class methodsFor:'documentation'! |
|
423 |
||
424 |
version |
|
11963 | 425 |
^ '$Header: /cvs/stx/stx/libbasic/SmalltalkChunkFileSourceWriter.st,v 1.9 2009-09-17 14:14:59 fm Exp $' |
8227 | 426 |
! ! |