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