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