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