|
1 " |
|
2 COPYRIGHT (c) 2012 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 " |
|
12 "{ Package: 'stx:libbasic3' }" |
|
13 |
|
14 "{ NameSpace: Smalltalk }" |
|
15 |
|
16 SmalltalkChunkFileSourceWriter subclass:#VSEChunkFileSourceWriter |
|
17 instanceVariableNames:'' |
|
18 classVariableNames:'' |
|
19 poolDictionaries:'' |
|
20 category:'Kernel-Classes-Support' |
|
21 ! |
|
22 |
|
23 Object subclass:#VSESourceRewriter |
|
24 instanceVariableNames:'source method methodClass' |
|
25 classVariableNames:'' |
|
26 poolDictionaries:'' |
|
27 privateIn:VSEChunkFileSourceWriter |
|
28 ! |
|
29 |
|
30 !VSEChunkFileSourceWriter class methodsFor:'documentation'! |
|
31 |
|
32 copyright |
|
33 " |
|
34 COPYRIGHT (c) 2012 by eXept Software AG |
|
35 All Rights Reserved |
|
36 |
|
37 This software is furnished under a license and may be used |
|
38 only in accordance with the terms of that license and with the |
|
39 inclusion of the above copyright notice. This software may not |
|
40 be provided or otherwise made available to, or used by, any |
|
41 other person. No title to or ownership of the software is |
|
42 hereby transferred. |
|
43 " |
|
44 ! |
|
45 |
|
46 documentation |
|
47 " |
|
48 fileout in a format which can be read by visualAge. |
|
49 For transporting software. |
|
50 " |
|
51 ! |
|
52 |
|
53 examples |
|
54 " |
|
55 [exBegin] |
|
56 |s| |
|
57 |
|
58 s := 'test.st' asFilename writeStream. |
|
59 [ |
|
60 VisualAgeChunkFileSourceWriter new |
|
61 fileOut:OrderedCollection on:s |
|
62 ] ensure:[ |
|
63 s close |
|
64 ] |
|
65 [exEnd] |
|
66 |
|
67 [exBegin] |
|
68 |s| |
|
69 |
|
70 s := '' writeStream. |
|
71 [ |
|
72 VisualAgeChunkFileSourceWriter new |
|
73 fileOut:OrderedCollection on:s |
|
74 ] ensure:[ |
|
75 s close |
|
76 ]. |
|
77 s contents |
|
78 [exEnd] |
|
79 " |
|
80 ! ! |
|
81 |
|
82 !VSEChunkFileSourceWriter methodsFor:'source writing'! |
|
83 |
|
84 fileOutCategory:aCategory of:aClass except:skippedMethods only:savedMethods methodFilter:methodFilter on:aStream |
|
85 "file out all methods belonging to aCategory, aString onto aStream. |
|
86 If skippedMethods is nonNil, those are not saved. |
|
87 If savedMethods is nonNil, only those are saved. |
|
88 If both are nil, all are saved. See version-method handling in |
|
89 fileOut for what this is needed." |
|
90 |
|
91 |sortedSelectors first prevPrivacy privacy interestingMethods| |
|
92 |
|
93 interestingMethods := OrderedCollection new. |
|
94 aClass methodsDo:[:aMethod | |
|
95 |wanted| |
|
96 |
|
97 (methodsAlreadySaved includes:aMethod) ifFalse:[ |
|
98 (aCategory = aMethod category) ifTrue:[ |
|
99 (methodFilter isNil or:[methodFilter value:aMethod]) ifTrue:[ |
|
100 skippedMethods notNil ifTrue:[ |
|
101 wanted := (skippedMethods includesIdentical:aMethod) not |
|
102 ] ifFalse:[ |
|
103 wanted := savedMethods isNil or:[ savedMethods includesIdentical:aMethod ]. |
|
104 ]. |
|
105 wanted ifTrue:[ |
|
106 aMethod selector isSymbol ifTrue:[ |
|
107 interestingMethods add:aMethod |
|
108 ] ifFalse:[ |
|
109 Transcript showCR:'skipping non-symbol method ', aMethod selector printString. |
|
110 ]. |
|
111 ]. |
|
112 ] |
|
113 ] |
|
114 ] |
|
115 ]. |
|
116 interestingMethods notEmpty ifTrue:[ |
|
117 first := true. |
|
118 prevPrivacy := nil. |
|
119 |
|
120 "/ |
|
121 "/ sort by selector |
|
122 "/ |
|
123 sortedSelectors := interestingMethods collect:[:m | aClass selectorAtMethod:m]. |
|
124 sortedSelectors sortWith:interestingMethods. |
|
125 |
|
126 interestingMethods do:[:eachMethod | |
|
127 privacy := eachMethod privacy. |
|
128 |
|
129 first ifFalse:[ |
|
130 privacy ~~ prevPrivacy ifTrue:[ |
|
131 first := true. |
|
132 aStream space. |
|
133 aStream nextPutChunkSeparator. |
|
134 ]. |
|
135 aStream cr; cr |
|
136 ]. |
|
137 |
|
138 first ifTrue:[ |
|
139 aStream nextPutChunkSeparator. |
|
140 aClass printClassNameOn:aStream. |
|
141 privacy ~~ #public ifTrue:[ |
|
142 aStream nextPutAll:' privateMethods'. |
|
143 ] ifFalse:[ |
|
144 aStream nextPutAll:' publicMethods'. |
|
145 ]. |
|
146 aStream nextPutChunkSeparator; cr; cr. |
|
147 first := false. |
|
148 ]. |
|
149 self fileOutMethod:eachMethod on:aStream. |
|
150 methodsAlreadySaved add:eachMethod. |
|
151 |
|
152 prevPrivacy := privacy. |
|
153 ]. |
|
154 aStream space. |
|
155 aStream nextPutChunkSeparator. |
|
156 aStream cr |
|
157 ]. |
|
158 aStream cr |
|
159 ! |
|
160 |
|
161 fileOutDefinitionOf:aClass on:aStream |
|
162 "append an expression on aStream, which defines myself." |
|
163 |
|
164 |s owner ns superclass nm| |
|
165 |
|
166 owner := aClass owningClass. |
|
167 ns := aClass topNameSpace. |
|
168 |
|
169 "take care of nil-superclass" |
|
170 superclass := aClass superclass. |
|
171 superclass isNil ifTrue:[ |
|
172 s := 'nil' |
|
173 ] ifFalse:[ |
|
174 s := superclass nameWithNameSpacePrefix. |
|
175 ]. |
|
176 |
|
177 aStream nextPutAll:s. "/ superclass |
|
178 aStream space. |
|
179 aClass basicFileOutInstvarTypeKeywordOn:aStream. |
|
180 |
|
181 nm := aClass nameWithoutPrefix. |
|
182 aStream nextPut:$#. |
|
183 aStream nextPutAll:nm. |
|
184 |
|
185 aStream crtab. |
|
186 aStream nextPutAll:'instanceVariableNames:'''. |
|
187 aClass printInstVarNamesOn:aStream indent:16. |
|
188 aStream nextPutAll:''''. |
|
189 |
|
190 aStream crtab. |
|
191 aStream nextPutAll:'classVariableNames:'''. |
|
192 aClass printClassVarNamesOn:aStream indent:16. |
|
193 aStream nextPutAll:''''. |
|
194 |
|
195 aStream crtab. |
|
196 aStream nextPutAll:'poolDictionaries:'''. |
|
197 aClass printSharedPoolNamesOn:aStream indent:16. |
|
198 aStream nextPutAll:''''. |
|
199 |
|
200 aStream cr. |
|
201 ! ! |
|
202 |
|
203 !VSEChunkFileSourceWriter::VSESourceRewriter class methodsFor:'translation'! |
|
204 |
|
205 rewriteMethod:method |
|
206 ^ self new rewriteMethod:method |
|
207 ! ! |
|
208 |
|
209 !VSEChunkFileSourceWriter::VSESourceRewriter methodsFor:'accessing'! |
|
210 |
|
211 method |
|
212 ^ method |
|
213 ! |
|
214 |
|
215 method:something |
|
216 method := something. |
|
217 ! |
|
218 |
|
219 methodClass |
|
220 ^ methodClass |
|
221 ! |
|
222 |
|
223 methodClass:something |
|
224 methodClass := something. |
|
225 ! |
|
226 |
|
227 source |
|
228 ^ source |
|
229 ! |
|
230 |
|
231 source:something |
|
232 source := something. |
|
233 ! ! |
|
234 |
|
235 !VSEChunkFileSourceWriter::VSESourceRewriter methodsFor:'translation'! |
|
236 |
|
237 doRewrite |
|
238 self halt. |
|
239 ! |
|
240 |
|
241 rewriteMethod:methodArg |
|
242 method := methodArg. |
|
243 source := method source. |
|
244 methodClass := method mclass. |
|
245 |
|
246 self doRewrite. |
|
247 ! ! |
|
248 |
|
249 !VSEChunkFileSourceWriter class methodsFor:'documentation'! |
|
250 |
|
251 version |
|
252 ^ '$Header: /cvs/stx/stx/libbasic3/VSEChunkFileSourceWriter.st,v 1.1 2015-01-20 13:20:43 cg Exp $' |
|
253 ! |
|
254 |
|
255 version_CVS |
|
256 ^ '$Header: /cvs/stx/stx/libbasic3/VSEChunkFileSourceWriter.st,v 1.1 2015-01-20 13:20:43 cg Exp $' |
|
257 ! ! |
|
258 |