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