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