author | Claus Gittinger <cg@exept.de> |
Thu, 03 Nov 2016 13:22:28 +0100 | |
changeset 1014 | 8e77e7bafd66 |
parent 797 | cd859a8a835d |
child 1026 | d7026d017d04 |
child 1099 | df7f9c846b88 |
permissions | -rw-r--r-- |
42 | 1 |
"{ Package: 'stx:goodies/monticello' }" |
2 |
||
3 |
MCWriter subclass:#MCStWriter |
|
4 |
instanceVariableNames:'initStream' |
|
5 |
classVariableNames:'' |
|
6 |
poolDictionaries:'' |
|
685 | 7 |
category:'SCM-Monticello-Chunk Format' |
42 | 8 |
! |
9 |
||
797 | 10 |
!MCStWriter class methodsFor:'documentation'! |
11 |
||
12 |
documentation |
|
13 |
" |
|
14 |
I write Category/Classes/Methods/.... definitions into Monticello source.st file format found in .mcz packages. |
|
15 |
||
16 |
See also MCStReader |
|
17 |
||
18 |
Example: |
|
19 |
||
20 |
String streamContents: [:aStream| |writer| |
|
21 |
writer := MCStWriter on: aStream. |
|
22 |
writer writeDefinitions: {True asClassDefinition. False asClassDefinition}. |
|
23 |
] |
|
24 |
" |
|
25 |
! ! |
|
42 | 26 |
|
27 |
!MCStWriter class methodsFor:'as yet unclassified'! |
|
28 |
||
29 |
readerClass |
|
30 |
^ MCStReader |
|
31 |
! ! |
|
32 |
||
33 |
!MCStWriter methodsFor:'visiting'! |
|
34 |
||
35 |
visitClassDefinition: definition |
|
36 |
self writeClassDefinition: definition. |
|
37 |
definition hasClassInstanceVariables ifTrue: [self writeMetaclassDefinition: definition]. |
|
38 |
definition hasComment ifTrue: [self writeClassComment: definition]. |
|
39 |
! |
|
40 |
||
197 | 41 |
visitClassTraitDefinition: definition |
42 |
self chunkContents: [:s | s |
|
43 |
nextPutAll: definition baseTrait; |
|
44 |
nextPutAll: ' classTrait'; |
|
45 |
cr; tab; |
|
46 |
nextPutAll: 'uses: '; |
|
47 |
nextPutAll: (definition classTraitComposition ifNil: ['{}'])] |
|
48 |
||
49 |
! |
|
50 |
||
51 |
visitMetaclassDefinition: definition |
|
52 |
self writeMetaclassDefinition: definition |
|
53 |
! |
|
54 |
||
42 | 55 |
visitMethodDefinition: definition |
56 |
self writeMethodPreamble: definition. |
|
57 |
self writeMethodSource: definition. |
|
58 |
self writeMethodPostscript. |
|
59 |
self writeMethodInitializer: definition. |
|
60 |
! |
|
61 |
||
62 |
visitOrganizationDefinition: defintion |
|
63 |
defintion categories do: [:cat | self writeCategory: cat]. |
|
197 | 64 |
|
65 |
! |
|
66 |
||
67 |
visitTraitDefinition: definition |
|
68 |
self writeClassDefinition: definition. |
|
69 |
definition hasComment ifTrue: [self writeClassComment: definition]. |
|
42 | 70 |
! ! |
71 |
||
72 |
!MCStWriter methodsFor:'writing'! |
|
73 |
||
74 |
chunkContents: aBlock |
|
75 |
stream cr; nextChunkPut: (String streamContents: aBlock); cr |
|
76 |
! |
|
77 |
||
78 |
writeCategory: categoryName |
|
197 | 79 |
stream |
80 |
nextChunkPut: 'SystemOrganization addCategory: ', categoryName storeString; |
|
81 |
cr |
|
82 |
||
83 |
"Modified: / 12-09-2010 / 15:36:20 / Jan Vrany <jan.vrany@fit.cvut.cz>" |
|
42 | 84 |
! |
85 |
||
86 |
writeClassComment: definition |
|
197 | 87 |
stream |
88 |
cr; |
|
89 |
nextPut: $!!; |
|
90 |
nextPutAll: definition className; |
|
91 |
nextPutAll: ' commentStamp: '; |
|
92 |
store: definition commentStamp; |
|
93 |
nextPutAll: ' prior: 0!!'; |
|
94 |
cr; |
|
95 |
nextChunkPut: definition comment ? ''; |
|
96 |
cr. |
|
97 |
||
98 |
"Modified: / 12-09-2010 / 17:05:20 / Jan Vrany <jan.vrany@fit.cvut.cz>" |
|
42 | 99 |
! |
100 |
||
101 |
writeClassDefinition: definition |
|
102 |
self chunkContents: [:s | definition printDefinitionOn: stream] |
|
103 |
! |
|
104 |
||
105 |
writeDefinitions: aCollection |
|
197 | 106 |
"initStream is an ugly hack until we have proper init defs" |
107 |
initStream := String new writeStream. |
|
42 | 108 |
|
197 | 109 |
(MCDependencySorter sortItems: aCollection) |
110 |
do: [:ea | ea accept: self] |
|
111 |
displayingProgress: 'Writing definitions...'. |
|
112 |
||
113 |
stream nextPutAll: initStream contents. |
|
42 | 114 |
! |
115 |
||
116 |
writeMetaclassDefinition: definition |
|
197 | 117 |
self chunkContents: [:str | |
118 |
str nextPutAll: definition className; |
|
119 |
nextPutAll: ' class'; |
|
120 |
cr; tab. |
|
121 |
definition hasClassTraitComposition ifTrue: [ |
|
122 |
str nextPutAll: 'uses: '; |
|
123 |
nextPutAll: definition classTraitCompositionString; |
|
124 |
cr; tab]. |
|
125 |
str nextPutAll: 'instanceVariableNames: '''; |
|
126 |
nextPutAll: definition classInstanceVariablesString; |
|
127 |
nextPut: $'] |
|
42 | 128 |
! |
129 |
||
130 |
writeMethodInitializer: aMethodDefinition |
|
131 |
aMethodDefinition isInitializer ifTrue: |
|
132 |
[initStream nextChunkPut: aMethodDefinition className, ' initialize'; cr] |
|
133 |
! |
|
134 |
||
135 |
writeMethodPostscript |
|
136 |
stream |
|
137 |
space; |
|
138 |
nextPut: $!!; |
|
139 |
cr |
|
140 |
! |
|
141 |
||
142 |
writeMethodPreamble: definition |
|
197 | 143 |
stream |
144 |
cr; |
|
145 |
nextPut: $!!; |
|
146 |
nextPutAll: definition fullClassName; |
|
147 |
nextPutAll: ' methodsFor: '; |
|
148 |
nextPutAll: definition category asString storeString; |
|
149 |
nextPutAll: ' stamp: '; |
|
150 |
nextPutAll: definition timeStamp asString storeString; |
|
151 |
nextPutAll: '!!'; |
|
152 |
cr |
|
153 |
||
154 |
"Modified: / 12-09-2010 / 15:39:59 / Jan Vrany <jan.vrany@fit.cvut.cz>" |
|
42 | 155 |
! |
156 |
||
157 |
writeMethodSource: definition |
|
158 |
stream nextChunkPut: definition source |
|
159 |
! |
|
160 |
||
161 |
writeSnapshot: aSnapshot |
|
162 |
self writeDefinitions: aSnapshot definitions |
|
163 |
! ! |
|
164 |
||
165 |
!MCStWriter class methodsFor:'documentation'! |
|
166 |
||
284 | 167 |
version |
797 | 168 |
^ '$Header: /cvs/stx/stx/goodies/monticello/MCStWriter.st,v 1.6 2013-05-15 12:03:48 cg Exp $' |
284 | 169 |
! |
170 |
||
197 | 171 |
version_CVS |
797 | 172 |
^ '$Header: /cvs/stx/stx/goodies/monticello/MCStWriter.st,v 1.6 2013-05-15 12:03:48 cg Exp $' |
143
d7354b2599b6
more porting (but still unfinished)
Claus Gittinger <cg@exept.de>
parents:
42
diff
changeset
|
173 |
! |
d7354b2599b6
more porting (but still unfinished)
Claus Gittinger <cg@exept.de>
parents:
42
diff
changeset
|
174 |
|
197 | 175 |
version_SVN |
797 | 176 |
^ '$Id: MCStWriter.st,v 1.6 2013-05-15 12:03:48 cg Exp $' |
42 | 177 |
! ! |
797 | 178 |