author | Claus Gittinger <cg@exept.de> |
Fri, 28 Jun 2019 08:49:56 +0200 | |
changeset 24385 | dd84e4dfb5cc |
parent 21979 | 8eeb75bc1e59 |
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 |
||
17333
937efc261475
class: SmalltalkChunkFileSourceWriter
Claus Gittinger <cg@exept.de>
parents:
17153
diff
changeset
|
14 |
"{ NameSpace: Smalltalk }" |
937efc261475
class: SmalltalkChunkFileSourceWriter
Claus Gittinger <cg@exept.de>
parents:
17153
diff
changeset
|
15 |
|
11963 | 16 |
AbstractSourceFileWriter subclass:#SmalltalkChunkFileSourceWriter |
16878
19f06d12b7da
Moved #generatingSourceForOriginal: from SmalltalkChunkFileSourceWriter to
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
15953
diff
changeset
|
17 |
instanceVariableNames:'classBeingSaved methodsAlreadySaved' |
8227 | 18 |
classVariableNames:'' |
19 |
poolDictionaries:'' |
|
15421
bfe697cc8b21
class: AbstractSourceFileWriter
Claus Gittinger <cg@exept.de>
parents:
15085
diff
changeset
|
20 |
category:'Kernel-Classes-Support' |
8227 | 21 |
! |
22 |
||
8728 | 23 |
!SmalltalkChunkFileSourceWriter class methodsFor:'documentation'! |
24 |
||
25 |
copyright |
|
26 |
" |
|
27 |
COPYRIGHT (c) 2004 by eXept Software AG |
|
28 |
All Rights Reserved |
|
29 |
||
30 |
This software is furnished under a license and may be used |
|
31 |
only in accordance with the terms of that license and with the |
|
32 |
inclusion of the above copyright notice. This software may not |
|
33 |
be provided or otherwise made available to, or used by, any |
|
34 |
other person. No title to or ownership of the software is |
|
35 |
hereby transferred. |
|
36 |
" |
|
14409 | 37 |
! |
38 |
||
39 |
documentation |
|
40 |
" |
|
41 |
I know how to write smalltalk chunk file format |
|
42 |
" |
|
8728 | 43 |
! ! |
8227 | 44 |
|
14596
45bb7ac30ab0
class: SmalltalkChunkFileSourceWriter
Claus Gittinger <cg@exept.de>
parents:
14409
diff
changeset
|
45 |
!SmalltalkChunkFileSourceWriter class methodsFor:'simple API'! |
45bb7ac30ab0
class: SmalltalkChunkFileSourceWriter
Claus Gittinger <cg@exept.de>
parents:
14409
diff
changeset
|
46 |
|
45bb7ac30ab0
class: SmalltalkChunkFileSourceWriter
Claus Gittinger <cg@exept.de>
parents:
14409
diff
changeset
|
47 |
fileOut:aClass on:aStream |
45bb7ac30ab0
class: SmalltalkChunkFileSourceWriter
Claus Gittinger <cg@exept.de>
parents:
14409
diff
changeset
|
48 |
self fileOut:aClass on:aStream withTimeStamp:true |
45bb7ac30ab0
class: SmalltalkChunkFileSourceWriter
Claus Gittinger <cg@exept.de>
parents:
14409
diff
changeset
|
49 |
withInitialize:true withDefinition:true |
45bb7ac30ab0
class: SmalltalkChunkFileSourceWriter
Claus Gittinger <cg@exept.de>
parents:
14409
diff
changeset
|
50 |
methodFilter:nil encoder:nil |
45bb7ac30ab0
class: SmalltalkChunkFileSourceWriter
Claus Gittinger <cg@exept.de>
parents:
14409
diff
changeset
|
51 |
! |
45bb7ac30ab0
class: SmalltalkChunkFileSourceWriter
Claus Gittinger <cg@exept.de>
parents:
14409
diff
changeset
|
52 |
|
45bb7ac30ab0
class: SmalltalkChunkFileSourceWriter
Claus Gittinger <cg@exept.de>
parents:
14409
diff
changeset
|
53 |
fileOut:aClass on:aStream withTimeStamp:withTimeStamp |
45bb7ac30ab0
class: SmalltalkChunkFileSourceWriter
Claus Gittinger <cg@exept.de>
parents:
14409
diff
changeset
|
54 |
withInitialize:initIt withDefinition:withDefinition |
45bb7ac30ab0
class: SmalltalkChunkFileSourceWriter
Claus Gittinger <cg@exept.de>
parents:
14409
diff
changeset
|
55 |
methodFilter:methodFilter encoder:encoderOrNil |
45bb7ac30ab0
class: SmalltalkChunkFileSourceWriter
Claus Gittinger <cg@exept.de>
parents:
14409
diff
changeset
|
56 |
|
45bb7ac30ab0
class: SmalltalkChunkFileSourceWriter
Claus Gittinger <cg@exept.de>
parents:
14409
diff
changeset
|
57 |
self new |
45bb7ac30ab0
class: SmalltalkChunkFileSourceWriter
Claus Gittinger <cg@exept.de>
parents:
14409
diff
changeset
|
58 |
fileOut:aClass on:aStream withTimeStamp:withTimeStamp |
45bb7ac30ab0
class: SmalltalkChunkFileSourceWriter
Claus Gittinger <cg@exept.de>
parents:
14409
diff
changeset
|
59 |
withInitialize:initIt withDefinition:withDefinition |
45bb7ac30ab0
class: SmalltalkChunkFileSourceWriter
Claus Gittinger <cg@exept.de>
parents:
14409
diff
changeset
|
60 |
methodFilter:methodFilter encoder:encoderOrNil |
45bb7ac30ab0
class: SmalltalkChunkFileSourceWriter
Claus Gittinger <cg@exept.de>
parents:
14409
diff
changeset
|
61 |
! ! |
45bb7ac30ab0
class: SmalltalkChunkFileSourceWriter
Claus Gittinger <cg@exept.de>
parents:
14409
diff
changeset
|
62 |
|
14326 | 63 |
!SmalltalkChunkFileSourceWriter class methodsFor:'utilities - source code'! |
64 |
||
65 |
methodTemplate |
|
19672 | 66 |
<resource: #obsolete> |
14326 | 67 |
"return a method definition template string" |
68 |
||
69 |
|s| |
|
70 |
||
19672 | 71 |
self obsoleteMethodWarning:'use codeGenerator'. |
20979 | 72 |
^ SmalltalkLanguage instance methodTemplate. |
14326 | 73 |
|
20979 | 74 |
"/ s := (TextStream ? WriteStream) on:''. |
75 |
"/ s nextPutAll: |
|
76 |
"/'message "selector and argument names" |
|
77 |
"/ "comment stating purpose of this message" |
|
78 |
"/ |
|
79 |
"/ |temporaries| |
|
80 |
"/ |
|
81 |
"/ "statement." |
|
82 |
"/ "statement." |
|
83 |
"/ |
|
84 |
"/ " |
|
85 |
"/ optional: comment giving example use |
|
86 |
"/ " |
|
87 |
"/'. |
|
88 |
"/ s cr. |
|
89 |
"/ s emphasis:(UserPreferences current commentEmphasisAndColor). |
|
90 |
"/ s nextPutAll: |
|
91 |
"/'" |
|
92 |
"/ change the above template into real code; |
|
93 |
"/ remove this comment. |
|
94 |
"/ Then `accept'' either via the menu |
|
95 |
"/ or via the keyboard (usually CMD-A). |
|
96 |
"/ |
|
97 |
"/ You do not need this template; you can also |
|
98 |
"/ select any existing methods code, change it, |
|
99 |
"/ and finally `accept''. The method will then be |
|
100 |
"/ installed under the selector as defined in the |
|
101 |
"/ actual text - no matter which method is selected |
|
102 |
"/ in the browser. |
|
103 |
"/ |
|
104 |
"/ Or clear this text, type in the method from scratch |
|
105 |
"/ and install it with `accept''. |
|
106 |
"/ |
|
107 |
"/ If you don''t like this method template to appear, |
|
108 |
"/ disable it either via the global or browser''s settings dialog, |
|
109 |
"/ or by evaluating: |
|
110 |
"/ UserPreferences current showMethodTemplate:false |
|
111 |
"/" |
|
112 |
"/'. |
|
113 |
"/ ^ s contents |
|
14326 | 114 |
|
20979 | 115 |
"Modified: / 18-11-2016 / 01:36:39 / cg" |
14326 | 116 |
! |
117 |
||
19672 | 118 |
methodTemplateForDocumentation |
119 |
<resource: #obsolete> |
|
120 |
"return a method definition template string" |
|
121 |
||
122 |
|s| |
|
123 |
||
124 |
self obsoleteMethodWarning:'use codeGenerator'. |
|
20979 | 125 |
^ SmalltalkLanguage instance methodTemplateForDocumentation. |
19672 | 126 |
|
20979 | 127 |
"/ s := (TextStream ? WriteStream) on:''. |
128 |
"/ s nextPutAll: |
|
129 |
"/'documentation |
|
130 |
"/'. |
|
131 |
"/ s emphasis:(UserPreferences current commentEmphasisAndColor). |
|
132 |
"/ s nextPutAll:( |
|
133 |
"/'" |
|
134 |
"/ comment describing this class. |
|
135 |
"/ you can disable the generation of this template by evaluating: |
|
136 |
"/ UserPreferences current showMethodTemplate:false |
|
137 |
"/ |
|
138 |
"/ [instance variables:] |
|
139 |
"/ describe instance variables |
|
140 |
"/ [class variables:] |
|
141 |
"/ describe class variables |
|
142 |
"/ [see also:] |
|
143 |
"/ |
|
144 |
"/ [author:] |
|
145 |
"/ %1 |
|
146 |
"/" |
|
147 |
"/' bindWith:(OperatingSystem getFullUserName)). |
|
148 |
"/ ^ s contents |
|
149 |
||
150 |
"Modified: / 18-11-2016 / 01:37:41 / cg" |
|
19672 | 151 |
! |
152 |
||
14326 | 153 |
versionMethodTemplateForCVS |
19672 | 154 |
<resource: #obsolete> |
14326 | 155 |
"careful to avoid expansion by cvs here!!" |
156 |
||
19672 | 157 |
self obsoleteMethodWarning:'use methodTemplateForVersionMethodCVS'. |
18554
ead4614d7aaa
class: SmalltalkChunkFileSourceWriter
Claus Gittinger <cg@exept.de>
parents:
17401
diff
changeset
|
158 |
^ ('version_CVS\ ^ ''$' , 'Header$''') withCRs |
14326 | 159 |
|
160 |
"Created: / 21-08-2012 / 11:52:27 / cg" |
|
161 |
! ! |
|
162 |
||
8227 | 163 |
!SmalltalkChunkFileSourceWriter methodsFor:'source writing'! |
164 |
||
16880
150ff012bd46
Oops, fixes to class fileout to handle non-ASCII code correctly.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
16878
diff
changeset
|
165 |
fileOut:aClass on:outStreamArg withTimeStamp:stampIt withInitialize:initIt withDefinition:withDefinition methodFilter:methodFilter |
150ff012bd46
Oops, fixes to class fileout to handle non-ASCII code correctly.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
16878
diff
changeset
|
166 |
|encoder any16Bit| |
150ff012bd46
Oops, fixes to class fileout to handle non-ASCII code correctly.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
16878
diff
changeset
|
167 |
|
150ff012bd46
Oops, fixes to class fileout to handle non-ASCII code correctly.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
16878
diff
changeset
|
168 |
any16Bit := aClass withAllPrivateClasses contains:[:cls | |
150ff012bd46
Oops, fixes to class fileout to handle non-ASCII code correctly.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
16878
diff
changeset
|
169 |
cls instAndClassMethods contains:[:m | |
150ff012bd46
Oops, fixes to class fileout to handle non-ASCII code correctly.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
16878
diff
changeset
|
170 |
(methodFilter isNil or:[ (methodFilter value:m) ]) |
150ff012bd46
Oops, fixes to class fileout to handle non-ASCII code correctly.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
16878
diff
changeset
|
171 |
and:[ |
150ff012bd46
Oops, fixes to class fileout to handle non-ASCII code correctly.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
16878
diff
changeset
|
172 |
|src| |
150ff012bd46
Oops, fixes to class fileout to handle non-ASCII code correctly.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
16878
diff
changeset
|
173 |
|
150ff012bd46
Oops, fixes to class fileout to handle non-ASCII code correctly.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
16878
diff
changeset
|
174 |
src := m source. |
150ff012bd46
Oops, fixes to class fileout to handle non-ASCII code correctly.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
16878
diff
changeset
|
175 |
src notNil and:[src isWideString] |
150ff012bd46
Oops, fixes to class fileout to handle non-ASCII code correctly.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
16878
diff
changeset
|
176 |
]]]. |
150ff012bd46
Oops, fixes to class fileout to handle non-ASCII code correctly.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
16878
diff
changeset
|
177 |
|
150ff012bd46
Oops, fixes to class fileout to handle non-ASCII code correctly.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
16878
diff
changeset
|
178 |
any16Bit ifTrue:[ |
150ff012bd46
Oops, fixes to class fileout to handle non-ASCII code correctly.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
16878
diff
changeset
|
179 |
encoder := CharacterEncoder encoderForUTF8. |
150ff012bd46
Oops, fixes to class fileout to handle non-ASCII code correctly.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
16878
diff
changeset
|
180 |
]. |
150ff012bd46
Oops, fixes to class fileout to handle non-ASCII code correctly.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
16878
diff
changeset
|
181 |
^ self |
150ff012bd46
Oops, fixes to class fileout to handle non-ASCII code correctly.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
16878
diff
changeset
|
182 |
fileOut: aClass |
150ff012bd46
Oops, fixes to class fileout to handle non-ASCII code correctly.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
16878
diff
changeset
|
183 |
on:outStreamArg |
150ff012bd46
Oops, fixes to class fileout to handle non-ASCII code correctly.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
16878
diff
changeset
|
184 |
withTimeStamp:stampIt |
150ff012bd46
Oops, fixes to class fileout to handle non-ASCII code correctly.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
16878
diff
changeset
|
185 |
withInitialize:initIt |
150ff012bd46
Oops, fixes to class fileout to handle non-ASCII code correctly.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
16878
diff
changeset
|
186 |
withDefinition:withDefinition |
150ff012bd46
Oops, fixes to class fileout to handle non-ASCII code correctly.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
16878
diff
changeset
|
187 |
methodFilter:methodFilter |
150ff012bd46
Oops, fixes to class fileout to handle non-ASCII code correctly.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
16878
diff
changeset
|
188 |
encoder:encoder |
150ff012bd46
Oops, fixes to class fileout to handle non-ASCII code correctly.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
16878
diff
changeset
|
189 |
|
150ff012bd46
Oops, fixes to class fileout to handle non-ASCII code correctly.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
16878
diff
changeset
|
190 |
"Created: / 04-10-2014 / 12:11:49 / Jan Vrany <jan.vrany@fit.cvut.cz>" |
150ff012bd46
Oops, fixes to class fileout to handle non-ASCII code correctly.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
16878
diff
changeset
|
191 |
! |
150ff012bd46
Oops, fixes to class fileout to handle non-ASCII code correctly.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
16878
diff
changeset
|
192 |
|
8227 | 193 |
fileOut:aClass on:outStreamArg withTimeStamp:stampIt withInitialize:initIt withDefinition:withDefinition methodFilter:methodFilter encoder:encoderOrNil |
194 |
"file out my definition and all methods onto aStream. |
|
195 |
If stampIt is true, a timeStamp comment is prepended. |
|
196 |
If initIt is true, and the class implements a class-initialize method, |
|
197 |
append a corresponding doIt expression for initialization. |
|
17153
91e8d99118e0
class: SmalltalkChunkFileSourceWriter
Claus Gittinger <cg@exept.de>
parents:
16880
diff
changeset
|
198 |
The order by which the fileOut is done is used to put the version method at the end. |
91e8d99118e0
class: SmalltalkChunkFileSourceWriter
Claus Gittinger <cg@exept.de>
parents:
16880
diff
changeset
|
199 |
Thus, if the version string is expanded (by CVS), the characterPositions of all other methods should not move. |
91e8d99118e0
class: SmalltalkChunkFileSourceWriter
Claus Gittinger <cg@exept.de>
parents:
16880
diff
changeset
|
200 |
Notice that any extensions version method is NOT written when a project definition is saved; |
91e8d99118e0
class: SmalltalkChunkFileSourceWriter
Claus Gittinger <cg@exept.de>
parents:
16880
diff
changeset
|
201 |
it is ABSOLUTELY required, that it is saved to the extensions.st file only (because the expanded version string |
91e8d99118e0
class: SmalltalkChunkFileSourceWriter
Claus Gittinger <cg@exept.de>
parents:
16880
diff
changeset
|
202 |
would be the version string of the project definition file and NOT the version string of the extensions file). |
91e8d99118e0
class: SmalltalkChunkFileSourceWriter
Claus Gittinger <cg@exept.de>
parents:
16880
diff
changeset
|
203 |
todo: code duplication with JavaScriptSourceFileWriter - please refactor" |
8227 | 204 |
|
17153
91e8d99118e0
class: SmalltalkChunkFileSourceWriter
Claus Gittinger <cg@exept.de>
parents:
16880
diff
changeset
|
205 |
|collectionOfCategories comment versionMethods extensionVersionMethods |
91e8d99118e0
class: SmalltalkChunkFileSourceWriter
Claus Gittinger <cg@exept.de>
parents:
16880
diff
changeset
|
206 |
nonMeta meta classesImplementingInitialize outStream |
91e8d99118e0
class: SmalltalkChunkFileSourceWriter
Claus Gittinger <cg@exept.de>
parents:
16880
diff
changeset
|
207 |
allMetaClassSelectors versionSelectors extensionVersionSelectors |
91e8d99118e0
class: SmalltalkChunkFileSourceWriter
Claus Gittinger <cg@exept.de>
parents:
16880
diff
changeset
|
208 |
allVersionMethods| |
91e8d99118e0
class: SmalltalkChunkFileSourceWriter
Claus Gittinger <cg@exept.de>
parents:
16880
diff
changeset
|
209 |
|
91e8d99118e0
class: SmalltalkChunkFileSourceWriter
Claus Gittinger <cg@exept.de>
parents:
16880
diff
changeset
|
210 |
self todo:'code duplication with JavaScriptSourceFileWriter - please refactor'. |
8227 | 211 |
|
11853
7c3265d8931e
save typedef methods before others to ensure that types
Claus Gittinger <cg@exept.de>
parents:
11703
diff
changeset
|
212 |
classBeingSaved := nonMeta := aClass theNonMetaclass. |
8227 | 213 |
meta := nonMeta class. |
11853
7c3265d8931e
save typedef methods before others to ensure that types
Claus Gittinger <cg@exept.de>
parents:
11703
diff
changeset
|
214 |
methodsAlreadySaved := Set new. |
8227 | 215 |
|
216 |
nonMeta isLoaded ifFalse:[ |
|
217 |
^ ClassDescription fileOutErrorSignal |
|
218 |
raiseRequestWith:nonMeta |
|
219 |
errorString:' - will not fileOut unloaded class: ', nonMeta name |
|
220 |
]. |
|
221 |
||
222 |
encoderOrNil isNil ifTrue:[ |
|
223 |
outStream := outStreamArg. |
|
224 |
] ifFalse:[ |
|
225 |
outStream := EncodedStream stream:outStreamArg encoder:encoderOrNil. |
|
226 |
outStream nextPutAll:'"{ Encoding: ' , encoderOrNil nameOfEncoding , ' }"'; cr; cr. |
|
227 |
]. |
|
228 |
||
229 |
" |
|
230 |
if there is a copyright method, add a copyright comment |
|
231 |
at the beginning, taking the string from the copyright method. |
|
232 |
We cannot do this unconditionally - that would lead to my copyrights |
|
233 |
being put on your code ;-). |
|
234 |
On the other hand: I want every file created by myself to have the |
|
235 |
copyright string at the beginning be preserved .... even if the |
|
236 |
code was edited in the browser and filedOut. |
|
237 |
" |
|
11853
7c3265d8931e
save typedef methods before others to ensure that types
Claus Gittinger <cg@exept.de>
parents:
11703
diff
changeset
|
238 |
self generateHeaderWithCopyrightOn:outStream. |
8227 | 239 |
|
240 |
stampIt ifTrue:[ |
|
241 |
"/ |
|
242 |
"/ first, a timestamp |
|
243 |
"/ |
|
14596
45bb7ac30ab0
class: SmalltalkChunkFileSourceWriter
Claus Gittinger <cg@exept.de>
parents:
14409
diff
changeset
|
244 |
self generateTimestampOn:outStream. |
8227 | 245 |
]. |
246 |
||
247 |
withDefinition ifTrue:[ |
|
248 |
"/ |
|
249 |
"/ then the definition(s) |
|
250 |
"/ |
|
251 |
self fileOutAllDefinitionsOf:nonMeta on:outStream. |
|
252 |
"/ |
|
253 |
"/ a comment - if any |
|
254 |
"/ |
|
255 |
(comment := nonMeta comment) notNil ifTrue:[ |
|
17335
1e44f87fe4d6
class: SmalltalkChunkFileSourceWriter
Claus Gittinger <cg@exept.de>
parents:
17333
diff
changeset
|
256 |
self fileOutClassCommentOf:nonMeta on:outStream. |
8227 | 257 |
]. |
258 |
"/ |
|
11853
7c3265d8931e
save typedef methods before others to ensure that types
Claus Gittinger <cg@exept.de>
parents:
11703
diff
changeset
|
259 |
"/ ST/X primitive definitions - if any |
8227 | 260 |
"/ |
261 |
nonMeta fileOutPrimitiveSpecsOn:outStream. |
|
262 |
]. |
|
263 |
||
264 |
"/ |
|
265 |
"/ methods from all categories in metaclass (i.e. class methods) |
|
266 |
"/ EXCEPT: the version method is placed at the very end, to |
|
267 |
"/ avoid sourcePosition-shifts when checked out later. |
|
268 |
"/ (RCS expands this string, so its size is not constant) |
|
269 |
"/ |
|
21979 | 270 |
collectionOfCategories := meta methodCategories asSortedCollection. |
17153
91e8d99118e0
class: SmalltalkChunkFileSourceWriter
Claus Gittinger <cg@exept.de>
parents:
16880
diff
changeset
|
271 |
|
91e8d99118e0
class: SmalltalkChunkFileSourceWriter
Claus Gittinger <cg@exept.de>
parents:
16880
diff
changeset
|
272 |
allMetaClassSelectors := meta methodDictionary keys. |
91e8d99118e0
class: SmalltalkChunkFileSourceWriter
Claus Gittinger <cg@exept.de>
parents:
16880
diff
changeset
|
273 |
versionSelectors := allMetaClassSelectors select:[:selector | AbstractSourceCodeManager isVersionMethodSelector:selector ]. |
91e8d99118e0
class: SmalltalkChunkFileSourceWriter
Claus Gittinger <cg@exept.de>
parents:
16880
diff
changeset
|
274 |
versionMethods := versionSelectors collect:[:eachSelector | meta methodDictionary at:eachSelector]. |
91e8d99118e0
class: SmalltalkChunkFileSourceWriter
Claus Gittinger <cg@exept.de>
parents:
16880
diff
changeset
|
275 |
extensionVersionSelectors := allMetaClassSelectors select:[:selector | AbstractSourceCodeManager isExtensionsVersionMethodSelector:selector ]. |
91e8d99118e0
class: SmalltalkChunkFileSourceWriter
Claus Gittinger <cg@exept.de>
parents:
16880
diff
changeset
|
276 |
extensionVersionMethods := extensionVersionSelectors collect:[:eachSelector | meta methodDictionary at:eachSelector]. |
91e8d99118e0
class: SmalltalkChunkFileSourceWriter
Claus Gittinger <cg@exept.de>
parents:
16880
diff
changeset
|
277 |
allVersionMethods := Set new addAll:versionMethods; addAll:extensionVersionMethods; yourself. |
12045
ccb1c727370b
changed: #fileOut:on:withTimeStamp:withInitialize:withDefinition:methodFilter:encoder:
fm
parents:
12043
diff
changeset
|
278 |
|
8227 | 279 |
collectionOfCategories notNil ifTrue:[ |
280 |
"/ |
|
281 |
"/ documentation first (if any), but not the version method |
|
282 |
"/ |
|
283 |
(collectionOfCategories includes:'documentation') ifTrue:[ |
|
12043 | 284 |
|
13754
0ce8b7b9e6ee
changed: #fileOut:on:withTimeStamp:withInitialize:withDefinition:methodFilter:encoder:
Claus Gittinger <cg@exept.de>
parents:
13462
diff
changeset
|
285 |
"/ versionMethods do:[:versionMethod | |
0ce8b7b9e6ee
changed: #fileOut:on:withTimeStamp:withInitialize:withDefinition:methodFilter:encoder:
Claus Gittinger <cg@exept.de>
parents:
13462
diff
changeset
|
286 |
"/ |source| |
0ce8b7b9e6ee
changed: #fileOut:on:withTimeStamp:withInitialize:withDefinition:methodFilter:encoder:
Claus Gittinger <cg@exept.de>
parents:
13462
diff
changeset
|
287 |
"/ |
0ce8b7b9e6ee
changed: #fileOut:on:withTimeStamp:withInitialize:withDefinition:methodFilter:encoder:
Claus Gittinger <cg@exept.de>
parents:
13462
diff
changeset
|
288 |
"/ source := versionMethod source. |
0ce8b7b9e6ee
changed: #fileOut:on:withTimeStamp:withInitialize:withDefinition:methodFilter:encoder:
Claus Gittinger <cg@exept.de>
parents:
13462
diff
changeset
|
289 |
"/ (source isEmptyOrNil or:[(source startsWith:nonMeta nameOfOldVersionMethod) not]) ifTrue:[ |
0ce8b7b9e6ee
changed: #fileOut:on:withTimeStamp:withInitialize:withDefinition:methodFilter:encoder:
Claus Gittinger <cg@exept.de>
parents:
13462
diff
changeset
|
290 |
"/ "something bad happend to the classes code" |
0ce8b7b9e6ee
changed: #fileOut:on:withTimeStamp:withInitialize:withDefinition:methodFilter:encoder:
Claus Gittinger <cg@exept.de>
parents:
13462
diff
changeset
|
291 |
"/ |
0ce8b7b9e6ee
changed: #fileOut:on:withTimeStamp:withInitialize:withDefinition:methodFilter:encoder:
Claus Gittinger <cg@exept.de>
parents:
13462
diff
changeset
|
292 |
"/ Class fileOutErrorSignal |
0ce8b7b9e6ee
changed: #fileOut:on:withTimeStamp:withInitialize:withDefinition:methodFilter:encoder:
Claus Gittinger <cg@exept.de>
parents:
13462
diff
changeset
|
293 |
"/ raiseRequestWith:aClass |
0ce8b7b9e6ee
changed: #fileOut:on:withTimeStamp:withInitialize:withDefinition:methodFilter:encoder:
Claus Gittinger <cg@exept.de>
parents:
13462
diff
changeset
|
294 |
"/ errorString:' - bad source for version method (uncompiled class file?): ', (versionMethod displayString) |
0ce8b7b9e6ee
changed: #fileOut:on:withTimeStamp:withInitialize:withDefinition:methodFilter:encoder:
Claus Gittinger <cg@exept.de>
parents:
13462
diff
changeset
|
295 |
"/ ]. |
0ce8b7b9e6ee
changed: #fileOut:on:withTimeStamp:withInitialize:withDefinition:methodFilter:encoder:
Claus Gittinger <cg@exept.de>
parents:
13462
diff
changeset
|
296 |
"/ ]. |
12043 | 297 |
|
17153
91e8d99118e0
class: SmalltalkChunkFileSourceWriter
Claus Gittinger <cg@exept.de>
parents:
16880
diff
changeset
|
298 |
self fileOutCategory:'documentation' of:meta except:allVersionMethods only:nil methodFilter:methodFilter on:outStream. |
8227 | 299 |
]. |
300 |
||
301 |
"/ |
|
302 |
"/ initialization next (if any) |
|
303 |
"/ |
|
304 |
(collectionOfCategories includes:'initialization') ifTrue:[ |
|
305 |
self fileOutCategory:'initialization' of:meta methodFilter:methodFilter on:outStream. |
|
306 |
]. |
|
307 |
||
308 |
"/ |
|
309 |
"/ instance creation next (if any) |
|
310 |
"/ |
|
311 |
(collectionOfCategories includes:'instance creation') ifTrue:[ |
|
312 |
self fileOutCategory:'instance creation' of:meta methodFilter:methodFilter on:outStream. |
|
313 |
]. |
|
314 |
collectionOfCategories do:[:aCategory | |
|
315 |
((aCategory ~= 'documentation') |
|
316 |
and:[(aCategory ~= 'initialization') |
|
317 |
and:[aCategory ~= 'instance creation']]) ifTrue:[ |
|
318 |
self fileOutCategory:aCategory of:meta methodFilter:methodFilter on:outStream. |
|
319 |
] |
|
320 |
] |
|
321 |
]. |
|
322 |
||
11853
7c3265d8931e
save typedef methods before others to ensure that types
Claus Gittinger <cg@exept.de>
parents:
11703
diff
changeset
|
323 |
"/ 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
|
324 |
"/ 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
|
325 |
"/ 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
|
326 |
"/ for the primitive calls. |
7c3265d8931e
save typedef methods before others to ensure that types
Claus Gittinger <cg@exept.de>
parents:
11703
diff
changeset
|
327 |
nonMeta methodDictionary keysAndValuesDo:[:sel :m | |
7c3265d8931e
save typedef methods before others to ensure that types
Claus Gittinger <cg@exept.de>
parents:
11703
diff
changeset
|
328 |
m isVisualWorksTypedef ifTrue:[ |
7c3265d8931e
save typedef methods before others to ensure that types
Claus Gittinger <cg@exept.de>
parents:
11703
diff
changeset
|
329 |
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
|
330 |
]. |
7c3265d8931e
save typedef methods before others to ensure that types
Claus Gittinger <cg@exept.de>
parents:
11703
diff
changeset
|
331 |
]. |
7c3265d8931e
save typedef methods before others to ensure that types
Claus Gittinger <cg@exept.de>
parents:
11703
diff
changeset
|
332 |
|
8227 | 333 |
"/ |
334 |
"/ methods from all categories |
|
335 |
"/ |
|
21979 | 336 |
collectionOfCategories := nonMeta methodCategories asSortedCollection. |
8227 | 337 |
collectionOfCategories notNil ifTrue:[ |
338 |
collectionOfCategories do:[:aCategory | |
|
339 |
self fileOutCategory:aCategory of:nonMeta methodFilter:methodFilter on:outStream. |
|
340 |
] |
|
341 |
]. |
|
342 |
||
343 |
"/ |
|
344 |
"/ any private classes' methods |
|
345 |
"/ |
|
17153
91e8d99118e0
class: SmalltalkChunkFileSourceWriter
Claus Gittinger <cg@exept.de>
parents:
16880
diff
changeset
|
346 |
nonMeta privateClassesSorted do:[:eachPrivateClass | |
91e8d99118e0
class: SmalltalkChunkFileSourceWriter
Claus Gittinger <cg@exept.de>
parents:
16880
diff
changeset
|
347 |
self fileOutAllMethodsOf:eachPrivateClass on:outStream methodFilter:methodFilter |
8227 | 348 |
]. |
349 |
||
350 |
||
351 |
"/ |
|
17153
91e8d99118e0
class: SmalltalkChunkFileSourceWriter
Claus Gittinger <cg@exept.de>
parents:
16880
diff
changeset
|
352 |
"/ finally, the previously skipped version method (but not the extensionsVersion methods!!) |
8227 | 353 |
"/ |
12043 | 354 |
versionMethods notEmpty ifTrue: [ |
355 |
self fileOutCategory:'documentation' of:meta except:nil only:versionMethods methodFilter:methodFilter on:outStream. |
|
8227 | 356 |
]. |
357 |
||
358 |
initIt ifTrue:[ |
|
359 |
"/ |
|
360 |
"/ optionally an initialize message |
|
361 |
"/ |
|
362 |
classesImplementingInitialize := OrderedCollection new. |
|
363 |
||
364 |
(meta includesSelector:#initialize) ifTrue:[ |
|
365 |
classesImplementingInitialize add:nonMeta |
|
366 |
]. |
|
367 |
nonMeta privateClassesSorted do:[:aPrivateClass | |
|
368 |
(aPrivateClass theMetaclass includesSelector:#initialize) ifTrue:[ |
|
369 |
classesImplementingInitialize add:aPrivateClass |
|
370 |
] |
|
371 |
]. |
|
17333
937efc261475
class: SmalltalkChunkFileSourceWriter
Claus Gittinger <cg@exept.de>
parents:
17153
diff
changeset
|
372 |
classesImplementingInitialize notEmpty ifTrue:[ |
937efc261475
class: SmalltalkChunkFileSourceWriter
Claus Gittinger <cg@exept.de>
parents:
17153
diff
changeset
|
373 |
outStream cr. |
8227 | 374 |
classesImplementingInitialize topologicalSort:[:a :b | b isSubclassOf:a]. |
375 |
classesImplementingInitialize do:[:eachClass | |
|
17333
937efc261475
class: SmalltalkChunkFileSourceWriter
Claus Gittinger <cg@exept.de>
parents:
17153
diff
changeset
|
376 |
self generateCallToInitializerFor:eachClass on:outStream |
8227 | 377 |
]. |
378 |
]. |
|
379 |
] |
|
380 |
||
10036
51489deaf8c5
care for non-comment in copyright method (JUN stuff)
Claus Gittinger <cg@exept.de>
parents:
8728
diff
changeset
|
381 |
"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
|
382 |
"Modified: / 01-04-1997 / 16:01:05 / stefan" |
21979 | 383 |
"Modified: / 05-07-2017 / 10:53:16 / cg" |
8227 | 384 |
! |
385 |
||
386 |
fileOutAllDefinitionsOf:aNonMetaClass on:aStream |
|
15953 | 387 |
self fileOutAllDefinitionsOf:aNonMetaClass on:aStream withNameSpace: true. |
388 |
||
389 |
"Created: / 15-10-1996 / 11:15:19 / cg" |
|
390 |
"Modified: / 22-03-1997 / 16:11:56 / cg" |
|
391 |
"Modified: / 04-02-2014 / 20:00:59 / Jan Vrany <jan.vrany@fit.cvut.cz>" |
|
392 |
! |
|
393 |
||
394 |
fileOutAllDefinitionsOf:aNonMetaClass on:aStream withNameSpace: withNameSpacePragma |
|
8227 | 395 |
"append expressions on aStream, which defines myself and all of my private classes." |
396 |
||
15085
328f314c2e19
class: SmalltalkChunkFileSourceWriter
Claus Gittinger <cg@exept.de>
parents:
14985
diff
changeset
|
397 |
|s| |
328f314c2e19
class: SmalltalkChunkFileSourceWriter
Claus Gittinger <cg@exept.de>
parents:
14985
diff
changeset
|
398 |
|
328f314c2e19
class: SmalltalkChunkFileSourceWriter
Claus Gittinger <cg@exept.de>
parents:
14985
diff
changeset
|
399 |
s := CharacterWriteStream on:(String new:50). |
15953 | 400 |
self fileOutDefinitionOf:aNonMetaClass on:s withNameSpace: withNameSpacePragma. |
15085
328f314c2e19
class: SmalltalkChunkFileSourceWriter
Claus Gittinger <cg@exept.de>
parents:
14985
diff
changeset
|
401 |
aStream nextChunkPut:(s contents). |
328f314c2e19
class: SmalltalkChunkFileSourceWriter
Claus Gittinger <cg@exept.de>
parents:
14985
diff
changeset
|
402 |
|
328f314c2e19
class: SmalltalkChunkFileSourceWriter
Claus Gittinger <cg@exept.de>
parents:
14985
diff
changeset
|
403 |
"/ self fileOutDefinitionOf:aNonMetaClass on:aStream. |
328f314c2e19
class: SmalltalkChunkFileSourceWriter
Claus Gittinger <cg@exept.de>
parents:
14985
diff
changeset
|
404 |
"/ aStream nextPutChunkSeparator. |
8227 | 405 |
aStream cr; cr. |
406 |
||
407 |
"/ |
|
408 |
"/ optional classInstanceVariables |
|
409 |
"/ |
|
410 |
aNonMetaClass class instanceVariableString isBlank ifFalse:[ |
|
17333
937efc261475
class: SmalltalkChunkFileSourceWriter
Claus Gittinger <cg@exept.de>
parents:
17153
diff
changeset
|
411 |
self fileOutClassInstVarDefinitionOf:aNonMetaClass on:aStream |
8227 | 412 |
]. |
413 |
||
414 |
"/ here, the full nameSpace prefixes are output, |
|
415 |
"/ to avoid confusing stc |
|
416 |
"/ (which otherwise could not find the correct superclass) |
|
417 |
"/ |
|
418 |
Class fileOutNameSpaceQuerySignal answer:false do:[ |
|
419 |
Class forceNoNameSpaceQuerySignal answer:true do:[ |
|
420 |
aNonMetaClass privateClassesSorted do:[:aClass | |
|
15953 | 421 |
self fileOutAllDefinitionsOf:aClass on:aStream withNameSpace: false |
8227 | 422 |
] |
423 |
] |
|
424 |
]. |
|
425 |
||
15953 | 426 |
"Created: / 04-02-2014 / 20:00:37 / Jan Vrany <jan.vrany@fit.cvut.cz>" |
8227 | 427 |
! |
428 |
||
429 |
fileOutAllMethodsOf:aClass on:aStream methodFilter:methodFilter |
|
430 |
|collectionOfCategories| |
|
431 |
||
21979 | 432 |
collectionOfCategories := aClass class methodCategories asSortedCollection. |
8227 | 433 |
collectionOfCategories notNil ifTrue:[ |
434 |
collectionOfCategories do:[:aCategory | |
|
435 |
self fileOutCategory:aCategory of:aClass class methodFilter:methodFilter on:aStream. |
|
436 |
] |
|
437 |
]. |
|
21979 | 438 |
collectionOfCategories := aClass methodCategories asSortedCollection. |
8227 | 439 |
collectionOfCategories notNil ifTrue:[ |
440 |
collectionOfCategories do:[:aCategory | |
|
441 |
self fileOutCategory:aCategory of:aClass methodFilter:methodFilter on:aStream. |
|
442 |
] |
|
443 |
]. |
|
444 |
||
445 |
aClass privateClassesSorted do:[:aClass | |
|
446 |
self fileOutAllMethodsOf:aClass on:aStream methodFilter:methodFilter |
|
447 |
]. |
|
448 |
||
21979 | 449 |
"Created: / 15-10-1996 / 11:13:00 / cg" |
450 |
"Modified: / 05-07-2017 / 10:52:04 / cg" |
|
8227 | 451 |
! |
452 |
||
453 |
fileOutCategory:aCategory of:aClass except:skippedMethods only:savedMethods methodFilter:methodFilter on:aStream |
|
454 |
"file out all methods belonging to aCategory, aString onto aStream. |
|
455 |
If skippedMethods is nonNil, those are not saved. |
|
456 |
If savedMethods is nonNil, only those are saved. |
|
457 |
If both are nil, all are saved. See version-method handling in |
|
458 |
fileOut for what this is needed." |
|
459 |
||
14983
a0b8519d7c50
class: SmalltalkChunkFileSourceWriter
Claus Gittinger <cg@exept.de>
parents:
14596
diff
changeset
|
460 |
|sortedSelectors first prevPrivacy privacy interestingMethods cat prjDef| |
11701 | 461 |
|
462 |
interestingMethods := OrderedCollection new. |
|
16878
19f06d12b7da
Moved #generatingSourceForOriginal: from SmalltalkChunkFileSourceWriter to
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
15953
diff
changeset
|
463 |
aClass methodsDo:[:each | |
19f06d12b7da
Moved #generatingSourceForOriginal: from SmalltalkChunkFileSourceWriter to
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
15953
diff
changeset
|
464 |
| wanted method shadowed | |
8227 | 465 |
|
16878
19f06d12b7da
Moved #generatingSourceForOriginal: from SmalltalkChunkFileSourceWriter to
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
15953
diff
changeset
|
466 |
method := each. |
19f06d12b7da
Moved #generatingSourceForOriginal: from SmalltalkChunkFileSourceWriter to
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
15953
diff
changeset
|
467 |
(methodsAlreadySaved includes:method) ifFalse:[ |
19f06d12b7da
Moved #generatingSourceForOriginal: from SmalltalkChunkFileSourceWriter to
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
15953
diff
changeset
|
468 |
(aCategory = method category) ifTrue:[ |
19f06d12b7da
Moved #generatingSourceForOriginal: from SmalltalkChunkFileSourceWriter to
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
15953
diff
changeset
|
469 |
wanted := methodFilter isNil or:[methodFilter value:method]. |
19f06d12b7da
Moved #generatingSourceForOriginal: from SmalltalkChunkFileSourceWriter to
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
15953
diff
changeset
|
470 |
wanted ifFalse:[ |
19f06d12b7da
Moved #generatingSourceForOriginal: from SmalltalkChunkFileSourceWriter to
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
15953
diff
changeset
|
471 |
"/ care for methods which have been shadowed by an extension from another package!! |
19f06d12b7da
Moved #generatingSourceForOriginal: from SmalltalkChunkFileSourceWriter to
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
15953
diff
changeset
|
472 |
"/ The problem is that we cannot easily introspect the filter, so we cannot know |
19f06d12b7da
Moved #generatingSourceForOriginal: from SmalltalkChunkFileSourceWriter to
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
15953
diff
changeset
|
473 |
"/ if the filter is for package or not. In most (all?) cases it is as this method |
19f06d12b7da
Moved #generatingSourceForOriginal: from SmalltalkChunkFileSourceWriter to
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
15953
diff
changeset
|
474 |
"/ is mostly used by source code management, so if the filter filters method out, |
19f06d12b7da
Moved #generatingSourceForOriginal: from SmalltalkChunkFileSourceWriter to
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
15953
diff
changeset
|
475 |
"/ try afain for possibly shadowed method. |
19f06d12b7da
Moved #generatingSourceForOriginal: from SmalltalkChunkFileSourceWriter to
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
15953
diff
changeset
|
476 |
methodFilter notNil ifTrue:[ |
19f06d12b7da
Moved #generatingSourceForOriginal: from SmalltalkChunkFileSourceWriter to
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
15953
diff
changeset
|
477 |
shadowed := method shadowedMethod. |
19f06d12b7da
Moved #generatingSourceForOriginal: from SmalltalkChunkFileSourceWriter to
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
15953
diff
changeset
|
478 |
shadowed notNil ifTrue:[ |
19f06d12b7da
Moved #generatingSourceForOriginal: from SmalltalkChunkFileSourceWriter to
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
15953
diff
changeset
|
479 |
wanted := methodFilter value: shadowed. |
19f06d12b7da
Moved #generatingSourceForOriginal: from SmalltalkChunkFileSourceWriter to
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
15953
diff
changeset
|
480 |
]. |
19f06d12b7da
Moved #generatingSourceForOriginal: from SmalltalkChunkFileSourceWriter to
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
15953
diff
changeset
|
481 |
]. |
19f06d12b7da
Moved #generatingSourceForOriginal: from SmalltalkChunkFileSourceWriter to
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
15953
diff
changeset
|
482 |
]. |
19f06d12b7da
Moved #generatingSourceForOriginal: from SmalltalkChunkFileSourceWriter to
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
15953
diff
changeset
|
483 |
wanted ifTrue:[ |
11853
7c3265d8931e
save typedef methods before others to ensure that types
Claus Gittinger <cg@exept.de>
parents:
11703
diff
changeset
|
484 |
skippedMethods notNil ifTrue:[ |
16878
19f06d12b7da
Moved #generatingSourceForOriginal: from SmalltalkChunkFileSourceWriter to
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
15953
diff
changeset
|
485 |
wanted := (skippedMethods includesIdentical:method) not |
8227 | 486 |
] ifFalse:[ |
16878
19f06d12b7da
Moved #generatingSourceForOriginal: from SmalltalkChunkFileSourceWriter to
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
15953
diff
changeset
|
487 |
wanted := savedMethods isNil or:[ savedMethods includesIdentical:method ]. |
11703
54e2c3acf7a7
skip non-symbol-selector methods when filing out
Claus Gittinger <cg@exept.de>
parents:
11701
diff
changeset
|
488 |
]. |
11853
7c3265d8931e
save typedef methods before others to ensure that types
Claus Gittinger <cg@exept.de>
parents:
11703
diff
changeset
|
489 |
wanted ifTrue:[ |
16878
19f06d12b7da
Moved #generatingSourceForOriginal: from SmalltalkChunkFileSourceWriter to
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
15953
diff
changeset
|
490 |
(method selector isSymbol) ifTrue:[ |
19f06d12b7da
Moved #generatingSourceForOriginal: from SmalltalkChunkFileSourceWriter to
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
15953
diff
changeset
|
491 |
interestingMethods add:method |
11853
7c3265d8931e
save typedef methods before others to ensure that types
Claus Gittinger <cg@exept.de>
parents:
11703
diff
changeset
|
492 |
] ifFalse:[ |
16878
19f06d12b7da
Moved #generatingSourceForOriginal: from SmalltalkChunkFileSourceWriter to
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
15953
diff
changeset
|
493 |
Transcript showCR:'skipping non-symbol method ', method selector printString. |
11853
7c3265d8931e
save typedef methods before others to ensure that types
Claus Gittinger <cg@exept.de>
parents:
11703
diff
changeset
|
494 |
]. |
7c3265d8931e
save typedef methods before others to ensure that types
Claus Gittinger <cg@exept.de>
parents:
11703
diff
changeset
|
495 |
]. |
7c3265d8931e
save typedef methods before others to ensure that types
Claus Gittinger <cg@exept.de>
parents:
11703
diff
changeset
|
496 |
] |
8227 | 497 |
] |
11701 | 498 |
] |
499 |
]. |
|
14983
a0b8519d7c50
class: SmalltalkChunkFileSourceWriter
Claus Gittinger <cg@exept.de>
parents:
14596
diff
changeset
|
500 |
|
11701 | 501 |
interestingMethods notEmpty ifTrue:[ |
502 |
"/ |
|
503 |
"/ sort by selector |
|
504 |
"/ |
|
505 |
sortedSelectors := interestingMethods collect:[:m | aClass selectorAtMethod:m]. |
|
506 |
sortedSelectors sortWith:interestingMethods. |
|
8227 | 507 |
|
14985
2e24694bc6f4
class: SmalltalkChunkFileSourceWriter
Claus Gittinger <cg@exept.de>
parents:
14983
diff
changeset
|
508 |
generatingSourceForOriginal == true ifTrue:[ |
2e24694bc6f4
class: SmalltalkChunkFileSourceWriter
Claus Gittinger <cg@exept.de>
parents:
14983
diff
changeset
|
509 |
"/ care for methods which have been shadowed by an extension from another package!! |
2e24694bc6f4
class: SmalltalkChunkFileSourceWriter
Claus Gittinger <cg@exept.de>
parents:
14983
diff
changeset
|
510 |
(prjDef := aClass theNonMetaclass projectDefinitionClass) notNil ifTrue:[ |
2e24694bc6f4
class: SmalltalkChunkFileSourceWriter
Claus Gittinger <cg@exept.de>
parents:
14983
diff
changeset
|
511 |
prjDef hasSavedOverwrittenMethods ifTrue:[ |
2e24694bc6f4
class: SmalltalkChunkFileSourceWriter
Claus Gittinger <cg@exept.de>
parents:
14983
diff
changeset
|
512 |
interestingMethods := interestingMethods collect:[:m | |
2e24694bc6f4
class: SmalltalkChunkFileSourceWriter
Claus Gittinger <cg@exept.de>
parents:
14983
diff
changeset
|
513 |
|originalOrNil| |
2e24694bc6f4
class: SmalltalkChunkFileSourceWriter
Claus Gittinger <cg@exept.de>
parents:
14983
diff
changeset
|
514 |
|
2e24694bc6f4
class: SmalltalkChunkFileSourceWriter
Claus Gittinger <cg@exept.de>
parents:
14983
diff
changeset
|
515 |
(m package ~~ aClass package) ifTrue:[ |
16878
19f06d12b7da
Moved #generatingSourceForOriginal: from SmalltalkChunkFileSourceWriter to
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
15953
diff
changeset
|
516 |
originalOrNil := prjDef savedOverwrittenMethodForClass:aClass selector:m selector. |
14985
2e24694bc6f4
class: SmalltalkChunkFileSourceWriter
Claus Gittinger <cg@exept.de>
parents:
14983
diff
changeset
|
517 |
originalOrNil notNil ifTrue:[ |
16878
19f06d12b7da
Moved #generatingSourceForOriginal: from SmalltalkChunkFileSourceWriter to
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
15953
diff
changeset
|
518 |
1. |
14985
2e24694bc6f4
class: SmalltalkChunkFileSourceWriter
Claus Gittinger <cg@exept.de>
parents:
14983
diff
changeset
|
519 |
self breakPoint:#cg |
2e24694bc6f4
class: SmalltalkChunkFileSourceWriter
Claus Gittinger <cg@exept.de>
parents:
14983
diff
changeset
|
520 |
]. |
2e24694bc6f4
class: SmalltalkChunkFileSourceWriter
Claus Gittinger <cg@exept.de>
parents:
14983
diff
changeset
|
521 |
]. |
2e24694bc6f4
class: SmalltalkChunkFileSourceWriter
Claus Gittinger <cg@exept.de>
parents:
14983
diff
changeset
|
522 |
originalOrNil ? m |
2e24694bc6f4
class: SmalltalkChunkFileSourceWriter
Claus Gittinger <cg@exept.de>
parents:
14983
diff
changeset
|
523 |
]. |
2e24694bc6f4
class: SmalltalkChunkFileSourceWriter
Claus Gittinger <cg@exept.de>
parents:
14983
diff
changeset
|
524 |
] |
2e24694bc6f4
class: SmalltalkChunkFileSourceWriter
Claus Gittinger <cg@exept.de>
parents:
14983
diff
changeset
|
525 |
]. |
2e24694bc6f4
class: SmalltalkChunkFileSourceWriter
Claus Gittinger <cg@exept.de>
parents:
14983
diff
changeset
|
526 |
]. |
2e24694bc6f4
class: SmalltalkChunkFileSourceWriter
Claus Gittinger <cg@exept.de>
parents:
14983
diff
changeset
|
527 |
|
2e24694bc6f4
class: SmalltalkChunkFileSourceWriter
Claus Gittinger <cg@exept.de>
parents:
14983
diff
changeset
|
528 |
first := true. |
2e24694bc6f4
class: SmalltalkChunkFileSourceWriter
Claus Gittinger <cg@exept.de>
parents:
14983
diff
changeset
|
529 |
prevPrivacy := nil. |
2e24694bc6f4
class: SmalltalkChunkFileSourceWriter
Claus Gittinger <cg@exept.de>
parents:
14983
diff
changeset
|
530 |
|
11853
7c3265d8931e
save typedef methods before others to ensure that types
Claus Gittinger <cg@exept.de>
parents:
11703
diff
changeset
|
531 |
interestingMethods do:[:eachMethod | |
7c3265d8931e
save typedef methods before others to ensure that types
Claus Gittinger <cg@exept.de>
parents:
11703
diff
changeset
|
532 |
privacy := eachMethod privacy. |
7c3265d8931e
save typedef methods before others to ensure that types
Claus Gittinger <cg@exept.de>
parents:
11703
diff
changeset
|
533 |
|
11701 | 534 |
first ifFalse:[ |
11853
7c3265d8931e
save typedef methods before others to ensure that types
Claus Gittinger <cg@exept.de>
parents:
11703
diff
changeset
|
535 |
privacy ~~ prevPrivacy ifTrue:[ |
11701 | 536 |
first := true. |
537 |
aStream space. |
|
8227 | 538 |
aStream nextPutChunkSeparator. |
11701 | 539 |
]. |
540 |
aStream cr; cr |
|
541 |
]. |
|
542 |
||
543 |
first ifTrue:[ |
|
544 |
aStream nextPutChunkSeparator. |
|
545 |
aClass printClassNameOn:aStream. |
|
546 |
privacy ~~ #public ifTrue:[ |
|
547 |
aStream space; nextPutAll:privacy; nextPutAll:'MethodsFor:'. |
|
548 |
] ifFalse:[ |
|
549 |
aStream nextPutAll:' methodsFor:'. |
|
8227 | 550 |
]. |
11701 | 551 |
cat := aCategory. |
552 |
cat isNil ifTrue:[ cat := '' ]. |
|
553 |
aStream nextPutAll:aCategory asString storeString. |
|
554 |
aStream nextPutChunkSeparator; cr; cr. |
|
555 |
first := false. |
|
8227 | 556 |
]. |
11853
7c3265d8931e
save typedef methods before others to ensure that types
Claus Gittinger <cg@exept.de>
parents:
11703
diff
changeset
|
557 |
self fileOutMethod:eachMethod on:aStream. |
7c3265d8931e
save typedef methods before others to ensure that types
Claus Gittinger <cg@exept.de>
parents:
11703
diff
changeset
|
558 |
methodsAlreadySaved add:eachMethod. |
7c3265d8931e
save typedef methods before others to ensure that types
Claus Gittinger <cg@exept.de>
parents:
11703
diff
changeset
|
559 |
|
7c3265d8931e
save typedef methods before others to ensure that types
Claus Gittinger <cg@exept.de>
parents:
11703
diff
changeset
|
560 |
prevPrivacy := privacy. |
11701 | 561 |
]. |
562 |
aStream space. |
|
563 |
aStream nextPutChunkSeparator. |
|
564 |
aStream cr |
|
14596
45bb7ac30ab0
class: SmalltalkChunkFileSourceWriter
Claus Gittinger <cg@exept.de>
parents:
14409
diff
changeset
|
565 |
]. |
45bb7ac30ab0
class: SmalltalkChunkFileSourceWriter
Claus Gittinger <cg@exept.de>
parents:
14409
diff
changeset
|
566 |
aStream cr |
8227 | 567 |
|
16878
19f06d12b7da
Moved #generatingSourceForOriginal: from SmalltalkChunkFileSourceWriter to
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
15953
diff
changeset
|
568 |
"Modified: / 28-08-1995 / 14:30:41 / claus" |
19f06d12b7da
Moved #generatingSourceForOriginal: from SmalltalkChunkFileSourceWriter to
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
15953
diff
changeset
|
569 |
"Modified: / 12-06-1996 / 11:37:33 / stefan" |
19f06d12b7da
Moved #generatingSourceForOriginal: from SmalltalkChunkFileSourceWriter to
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
15953
diff
changeset
|
570 |
"Modified: / 15-11-1996 / 11:32:21 / cg" |
19f06d12b7da
Moved #generatingSourceForOriginal: from SmalltalkChunkFileSourceWriter to
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
15953
diff
changeset
|
571 |
"Created: / 01-04-1997 / 16:04:33 / stefan" |
19f06d12b7da
Moved #generatingSourceForOriginal: from SmalltalkChunkFileSourceWriter to
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
15953
diff
changeset
|
572 |
"Modified: / 03-10-2014 / 23:16:52 / Jan Vrany <jan.vrany@fit.cvut.cz>" |
8227 | 573 |
! |
574 |
||
575 |
fileOutCategory:aCategory of:aClass methodFilter:methodFilter on:aStream |
|
576 |
"file out all methods belonging to aCategory, aString onto aStream" |
|
577 |
||
578 |
self fileOutCategory:aCategory of:aClass except:nil only:nil methodFilter:methodFilter on:aStream |
|
579 |
||
580 |
"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
|
581 |
! |
7c3265d8931e
save typedef methods before others to ensure that types
Claus Gittinger <cg@exept.de>
parents:
11703
diff
changeset
|
582 |
|
17335
1e44f87fe4d6
class: SmalltalkChunkFileSourceWriter
Claus Gittinger <cg@exept.de>
parents:
17333
diff
changeset
|
583 |
fileOutClassCommentOf:aNonMetaClass on:aStream |
1e44f87fe4d6
class: SmalltalkChunkFileSourceWriter
Claus Gittinger <cg@exept.de>
parents:
17333
diff
changeset
|
584 |
aNonMetaClass fileOutCommentOn:aStream. |
1e44f87fe4d6
class: SmalltalkChunkFileSourceWriter
Claus Gittinger <cg@exept.de>
parents:
17333
diff
changeset
|
585 |
! |
1e44f87fe4d6
class: SmalltalkChunkFileSourceWriter
Claus Gittinger <cg@exept.de>
parents:
17333
diff
changeset
|
586 |
|
17333
937efc261475
class: SmalltalkChunkFileSourceWriter
Claus Gittinger <cg@exept.de>
parents:
17153
diff
changeset
|
587 |
fileOutClassInstVarDefinitionOf:aNonMetaClass on:aStream |
937efc261475
class: SmalltalkChunkFileSourceWriter
Claus Gittinger <cg@exept.de>
parents:
17153
diff
changeset
|
588 |
aNonMetaClass fileOutClassInstVarDefinitionOn:aStream. |
937efc261475
class: SmalltalkChunkFileSourceWriter
Claus Gittinger <cg@exept.de>
parents:
17153
diff
changeset
|
589 |
aStream nextPutChunkSeparator. |
937efc261475
class: SmalltalkChunkFileSourceWriter
Claus Gittinger <cg@exept.de>
parents:
17153
diff
changeset
|
590 |
aStream cr; cr |
937efc261475
class: SmalltalkChunkFileSourceWriter
Claus Gittinger <cg@exept.de>
parents:
17153
diff
changeset
|
591 |
! |
937efc261475
class: SmalltalkChunkFileSourceWriter
Claus Gittinger <cg@exept.de>
parents:
17153
diff
changeset
|
592 |
|
12108 | 593 |
fileOutCommentEndOn:aStream |
594 |
"Writes a comment end mark on aStream." |
|
595 |
||
596 |
"/ intentionally left blank - make each line an EOL-comment instead |
|
597 |
! |
|
598 |
||
599 |
fileOutCommentLine:aString on:aStream |
|
600 |
"Writes a single line of comment on a comment to a stream." |
|
601 |
||
602 |
aStream |
|
603 |
nextPutAll:'"/ '; |
|
604 |
nextPutAll: aString |
|
605 |
! |
|
606 |
||
607 |
fileOutCommentStartOn:aStream |
|
608 |
"Writes a comment start mark on aStream." |
|
609 |
||
610 |
"/ intentionally left blank - make each line an EOL-comment instead |
|
611 |
! |
|
612 |
||
14596
45bb7ac30ab0
class: SmalltalkChunkFileSourceWriter
Claus Gittinger <cg@exept.de>
parents:
14409
diff
changeset
|
613 |
fileOutDefinitionOf:aNonMetaClass on:aStream |
45bb7ac30ab0
class: SmalltalkChunkFileSourceWriter
Claus Gittinger <cg@exept.de>
parents:
14409
diff
changeset
|
614 |
aNonMetaClass fileOutDefinitionOn:aStream. |
45bb7ac30ab0
class: SmalltalkChunkFileSourceWriter
Claus Gittinger <cg@exept.de>
parents:
14409
diff
changeset
|
615 |
! |
45bb7ac30ab0
class: SmalltalkChunkFileSourceWriter
Claus Gittinger <cg@exept.de>
parents:
14409
diff
changeset
|
616 |
|
15953 | 617 |
fileOutDefinitionOf:aNonMetaClass on:aStream withNameSpace: withNameSpacePragma |
618 |
aNonMetaClass basicFileOutDefinitionOn:aStream withNameSpace: withNameSpacePragma |
|
619 |
||
620 |
"Created: / 04-02-2014 / 20:00:17 / Jan Vrany <jan.vrany@fit.cvut.cz>" |
|
621 |
! |
|
622 |
||
11853
7c3265d8931e
save typedef methods before others to ensure that types
Claus Gittinger <cg@exept.de>
parents:
11703
diff
changeset
|
623 |
fileOutMethod:aMethod on:aStream |
7c3265d8931e
save typedef methods before others to ensure that types
Claus Gittinger <cg@exept.de>
parents:
11703
diff
changeset
|
624 |
"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
|
625 |
|
12043 | 626 |
|source possiblyRewrittenSource rewriteQuery| |
11853
7c3265d8931e
save typedef methods before others to ensure that types
Claus Gittinger <cg@exept.de>
parents:
11703
diff
changeset
|
627 |
|
7c3265d8931e
save typedef methods before others to ensure that types
Claus Gittinger <cg@exept.de>
parents:
11703
diff
changeset
|
628 |
source := aMethod source. |
7c3265d8931e
save typedef methods before others to ensure that types
Claus Gittinger <cg@exept.de>
parents:
11703
diff
changeset
|
629 |
source isNil ifTrue:[ |
7c3265d8931e
save typedef methods before others to ensure that types
Claus Gittinger <cg@exept.de>
parents:
11703
diff
changeset
|
630 |
Class fileOutErrorSignal |
7c3265d8931e
save typedef methods before others to ensure that types
Claus Gittinger <cg@exept.de>
parents:
11703
diff
changeset
|
631 |
raiseRequestWith:aMethod mclass |
7c3265d8931e
save typedef methods before others to ensure that types
Claus Gittinger <cg@exept.de>
parents:
11703
diff
changeset
|
632 |
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
|
633 |
] ifFalse:[ |
12043 | 634 |
"/ hook to allow for just-in-time rewriting of a method's sourceCode while filing out |
635 |
"/ used when saving version_XXX methods in a non-XXX sourceCodeManager |
|
636 |
"/ (i.e. to rewrite all non-CVS version methods while saving into a CVS repository) |
|
637 |
"/ this is required because we cannot save an SVN version method (dollar-ID-...-dollar) into a |
|
638 |
"/ CVS repository without loosing the original string with the next checkout, because it also gets |
|
639 |
"/ expanded by CVS. The same is true vice-versa for CVS-Ids, which get clobbered by SVN. |
|
17401
2d776a4f4258
class: SmalltalkChunkFileSourceWriter
Claus Gittinger <cg@exept.de>
parents:
17335
diff
changeset
|
640 |
"/ also used, when generating sourcecode for another Smalltalk system (VSE fileout) |
2d776a4f4258
class: SmalltalkChunkFileSourceWriter
Claus Gittinger <cg@exept.de>
parents:
17335
diff
changeset
|
641 |
|
12043 | 642 |
rewriteQuery := AbstractSourceFileWriter methodSourceRewriteQuery new. |
643 |
rewriteQuery method:aMethod source:source. |
|
644 |
possiblyRewrittenSource := (rewriteQuery query) ? source. |
|
645 |
aStream nextChunkPut:possiblyRewrittenSource. |
|
646 |
"/possiblyRewrittenSource ~= source ifTrue: [ |
|
647 |
"/ Transcript showCR: possiblyRewrittenSource. |
|
648 |
"/]. |
|
11853
7c3265d8931e
save typedef methods before others to ensure that types
Claus Gittinger <cg@exept.de>
parents:
11703
diff
changeset
|
649 |
]. |
7c3265d8931e
save typedef methods before others to ensure that types
Claus Gittinger <cg@exept.de>
parents:
11703
diff
changeset
|
650 |
! |
7c3265d8931e
save typedef methods before others to ensure that types
Claus Gittinger <cg@exept.de>
parents:
11703
diff
changeset
|
651 |
|
13420 | 652 |
fileOutMethods: methods on: stream |
653 |
||
15953 | 654 |
methods do:[:method| |
655 |
|cat source privacy| |
|
13420 | 656 |
|
657 |
stream nextPutChunkSeparator. |
|
15953 | 658 |
"JV@2012-09-05: Support for filing out Java extension methods" |
659 |
method mclass theNonMetaclass isJavaClass ifTrue:[ |
|
660 |
| class classBinaryName comps | |
|
661 |
||
662 |
class := method mclass theNonMetaclass . |
|
663 |
"Sigh, make it compatible with old and new naming of Java classes |
|
664 |
||
665 |
old -> aJavaClass name == #'java/lang/Object' |
|
666 |
new -> aJavaClass name == JAVA::java::lang::Object |
|
667 |
aJavaClass binaryName == #'java/lang/Object' |
|
668 |
" |
|
669 |
classBinaryName := (class respondsTo: #binaryName) |
|
670 |
ifTrue:[ class binaryName ] |
|
671 |
ifFalse:[ class name ]. |
|
672 |
stream nextPutAll:'(Java classForName:'''. |
|
673 |
stream nextPutAll:(classBinaryName copyReplaceAll:$/ with: $.). |
|
674 |
stream nextPutAll:''')'. |
|
675 |
method mclass isMetaclass ifTrue:[ |
|
676 |
stream nextPutAll: ' class'. |
|
677 |
]. |
|
678 |
] ifFalse:[ |
|
679 |
method mclass name printOn:stream. |
|
680 |
]. |
|
13420 | 681 |
"/ self printClassNameOn:aStream. |
682 |
||
683 |
(privacy := method privacy) ~~ #public ifTrue:[ |
|
684 |
stream space; nextPutAll:privacy; nextPutAll:'MethodsFor:'. |
|
685 |
] ifFalse:[ |
|
686 |
stream nextPutAll:' methodsFor:'. |
|
687 |
]. |
|
688 |
||
689 |
cat := method category ? ''. |
|
690 |
stream nextPutAll:cat asString storeString. |
|
691 |
stream nextPutChunkSeparator; cr; cr. |
|
692 |
||
693 |
self fileOutMethod: method on: stream. |
|
694 |
||
695 |
stream space. |
|
696 |
stream nextPutChunkSeparator. |
|
697 |
stream cr] |
|
698 |
||
699 |
"Created: / 30-12-2009 / 18:43:57 / Jan Vrany <jan.vrany@fit.cvut.cz>" |
|
15953 | 700 |
"Modified: / 09-10-2013 / 08:57:46 / Jan Vrany <jan.vrany@fit.cvut.cz>" |
13420 | 701 |
! |
702 |
||
703 |
fileOutPackageDefinition:pkg on:aStream |
|
704 |
(pkg notNil and:[ pkg ~= PackageId noProjectID ]) ifTrue:[ |
|
705 |
aStream nextPutAll:'"{ Package: '''. |
|
706 |
aStream nextPutAll:pkg asString. |
|
707 |
aStream |
|
708 |
nextPutAll:''' }"'; cr; cr; |
|
709 |
nextPut:$!!; cr; cr |
|
710 |
] |
|
711 |
! |
|
712 |
||
17333
937efc261475
class: SmalltalkChunkFileSourceWriter
Claus Gittinger <cg@exept.de>
parents:
17153
diff
changeset
|
713 |
generateCallToInitializerFor:aClass on:aStream |
937efc261475
class: SmalltalkChunkFileSourceWriter
Claus Gittinger <cg@exept.de>
parents:
17153
diff
changeset
|
714 |
aClass printClassNameOn:aStream. aStream nextPutAll:' initialize'. |
937efc261475
class: SmalltalkChunkFileSourceWriter
Claus Gittinger <cg@exept.de>
parents:
17153
diff
changeset
|
715 |
aStream nextPutChunkSeparator. |
937efc261475
class: SmalltalkChunkFileSourceWriter
Claus Gittinger <cg@exept.de>
parents:
17153
diff
changeset
|
716 |
aStream cr. |
937efc261475
class: SmalltalkChunkFileSourceWriter
Claus Gittinger <cg@exept.de>
parents:
17153
diff
changeset
|
717 |
! |
937efc261475
class: SmalltalkChunkFileSourceWriter
Claus Gittinger <cg@exept.de>
parents:
17153
diff
changeset
|
718 |
|
11853
7c3265d8931e
save typedef methods before others to ensure that types
Claus Gittinger <cg@exept.de>
parents:
11703
diff
changeset
|
719 |
generateHeaderWithCopyrightOn:outStream |
7c3265d8931e
save typedef methods before others to ensure that types
Claus Gittinger <cg@exept.de>
parents:
11703
diff
changeset
|
720 |
|copyrightMethod copyrightText| |
7c3265d8931e
save typedef methods before others to ensure that types
Claus Gittinger <cg@exept.de>
parents:
11703
diff
changeset
|
721 |
|
7c3265d8931e
save typedef methods before others to ensure that types
Claus Gittinger <cg@exept.de>
parents:
11703
diff
changeset
|
722 |
"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
|
723 |
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
|
724 |
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
|
725 |
being put on your code ;-). |
7c3265d8931e
save typedef methods before others to ensure that types
Claus Gittinger <cg@exept.de>
parents:
11703
diff
changeset
|
726 |
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
|
727 |
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
|
728 |
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
|
729 |
|
7c3265d8931e
save typedef methods before others to ensure that types
Claus Gittinger <cg@exept.de>
parents:
11703
diff
changeset
|
730 |
(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
|
731 |
" |
7c3265d8931e
save typedef methods before others to ensure that types
Claus Gittinger <cg@exept.de>
parents:
11703
diff
changeset
|
732 |
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
|
733 |
and insert at beginning. |
7c3265d8931e
save typedef methods before others to ensure that types
Claus Gittinger <cg@exept.de>
parents:
11703
diff
changeset
|
734 |
" |
7c3265d8931e
save typedef methods before others to ensure that types
Claus Gittinger <cg@exept.de>
parents:
11703
diff
changeset
|
735 |
copyrightText := copyrightMethod comment. |
7c3265d8931e
save typedef methods before others to ensure that types
Claus Gittinger <cg@exept.de>
parents:
11703
diff
changeset
|
736 |
copyrightText notEmptyOrNil ifTrue:[ |
7c3265d8931e
save typedef methods before others to ensure that types
Claus Gittinger <cg@exept.de>
parents:
11703
diff
changeset
|
737 |
copyrightText := copyrightText asCollectionOfLines asStringCollection. |
19875 | 738 |
copyrightText := copyrightText withoutLeadingAndTrailingBlankLines. |
11853
7c3265d8931e
save typedef methods before others to ensure that types
Claus Gittinger <cg@exept.de>
parents:
11703
diff
changeset
|
739 |
copyrightText notEmpty ifTrue:[ |
7c3265d8931e
save typedef methods before others to ensure that types
Claus Gittinger <cg@exept.de>
parents:
11703
diff
changeset
|
740 |
copyrightText addFirst:'"'. |
7c3265d8931e
save typedef methods before others to ensure that types
Claus Gittinger <cg@exept.de>
parents:
11703
diff
changeset
|
741 |
copyrightText addLast:'"'. |
7c3265d8931e
save typedef methods before others to ensure that types
Claus Gittinger <cg@exept.de>
parents:
11703
diff
changeset
|
742 |
copyrightText := copyrightText asString. |
7c3265d8931e
save typedef methods before others to ensure that types
Claus Gittinger <cg@exept.de>
parents:
11703
diff
changeset
|
743 |
outStream nextPutAllAsChunk:copyrightText. |
7c3265d8931e
save typedef methods before others to ensure that types
Claus Gittinger <cg@exept.de>
parents:
11703
diff
changeset
|
744 |
]. |
7c3265d8931e
save typedef methods before others to ensure that types
Claus Gittinger <cg@exept.de>
parents:
11703
diff
changeset
|
745 |
]. |
7c3265d8931e
save typedef methods before others to ensure that types
Claus Gittinger <cg@exept.de>
parents:
11703
diff
changeset
|
746 |
]. |
14596
45bb7ac30ab0
class: SmalltalkChunkFileSourceWriter
Claus Gittinger <cg@exept.de>
parents:
14409
diff
changeset
|
747 |
! |
45bb7ac30ab0
class: SmalltalkChunkFileSourceWriter
Claus Gittinger <cg@exept.de>
parents:
14409
diff
changeset
|
748 |
|
45bb7ac30ab0
class: SmalltalkChunkFileSourceWriter
Claus Gittinger <cg@exept.de>
parents:
14409
diff
changeset
|
749 |
generateTimestampOn:outStream |
45bb7ac30ab0
class: SmalltalkChunkFileSourceWriter
Claus Gittinger <cg@exept.de>
parents:
14409
diff
changeset
|
750 |
outStream nextPutAll:(Smalltalk timeStamp). |
45bb7ac30ab0
class: SmalltalkChunkFileSourceWriter
Claus Gittinger <cg@exept.de>
parents:
14409
diff
changeset
|
751 |
outStream nextPutChunkSeparator. |
45bb7ac30ab0
class: SmalltalkChunkFileSourceWriter
Claus Gittinger <cg@exept.de>
parents:
14409
diff
changeset
|
752 |
outStream cr; cr. |
8227 | 753 |
! ! |
754 |
||
755 |
!SmalltalkChunkFileSourceWriter class methodsFor:'documentation'! |
|
756 |
||
14985
2e24694bc6f4
class: SmalltalkChunkFileSourceWriter
Claus Gittinger <cg@exept.de>
parents:
14983
diff
changeset
|
757 |
version |
18554
ead4614d7aaa
class: SmalltalkChunkFileSourceWriter
Claus Gittinger <cg@exept.de>
parents:
17401
diff
changeset
|
758 |
^ '$Header$' |
14985
2e24694bc6f4
class: SmalltalkChunkFileSourceWriter
Claus Gittinger <cg@exept.de>
parents:
14983
diff
changeset
|
759 |
! |
2e24694bc6f4
class: SmalltalkChunkFileSourceWriter
Claus Gittinger <cg@exept.de>
parents:
14983
diff
changeset
|
760 |
|
13420 | 761 |
version_CVS |
18554
ead4614d7aaa
class: SmalltalkChunkFileSourceWriter
Claus Gittinger <cg@exept.de>
parents:
17401
diff
changeset
|
762 |
^ '$Header$' |
12043 | 763 |
! |
764 |
||
13420 | 765 |
version_SVN |
15421
bfe697cc8b21
class: AbstractSourceFileWriter
Claus Gittinger <cg@exept.de>
parents:
15085
diff
changeset
|
766 |
^ '$ Id: SmalltalkChunkFileSourceWriter.st 10643 2011-06-08 21:53:07Z vranyj1 $' |
8227 | 767 |
! ! |
14596
45bb7ac30ab0
class: SmalltalkChunkFileSourceWriter
Claus Gittinger <cg@exept.de>
parents:
14409
diff
changeset
|
768 |