author | Claus Gittinger <cg@exept.de> |
Mon, 26 Oct 2009 16:25:23 +0100 | |
changeset 143 | d7354b2599b6 |
parent 42 | df170417877c |
child 197 | 833c1cc5eafd |
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 |
||
25 |
visitMethodDefinition: definition |
|
26 |
self writeMethodPreamble: definition. |
|
27 |
self writeMethodSource: definition. |
|
28 |
self writeMethodPostscript. |
|
29 |
self writeMethodInitializer: definition. |
|
30 |
! |
|
31 |
||
32 |
visitOrganizationDefinition: defintion |
|
33 |
defintion categories do: [:cat | self writeCategory: cat]. |
|
34 |
! ! |
|
35 |
||
36 |
!MCStWriter methodsFor:'writing'! |
|
37 |
||
38 |
chunkContents: aBlock |
|
39 |
stream cr; nextChunkPut: (String streamContents: aBlock); cr |
|
40 |
! |
|
41 |
||
42 |
writeCategory: categoryName |
|
43 |
stream |
|
44 |
nextChunkPut: 'SystemOrganization addCategory: ', categoryName printString; |
|
45 |
cr |
|
46 |
! |
|
47 |
||
48 |
writeClassComment: definition |
|
49 |
stream |
|
50 |
cr; |
|
51 |
nextPut: $!!; |
|
52 |
nextPutAll: definition className; |
|
53 |
nextPutAll: ' commentStamp: '; |
|
54 |
store: definition commentStamp; |
|
55 |
nextPutAll: ' prior: 0!!'; |
|
56 |
cr; |
|
57 |
nextChunkPut: definition comment; |
|
58 |
cr. |
|
59 |
! |
|
60 |
||
61 |
writeClassDefinition: definition |
|
62 |
self chunkContents: [:s | definition printDefinitionOn: stream] |
|
63 |
! |
|
64 |
||
65 |
writeDefinitions: aCollection |
|
143
d7354b2599b6
more porting (but still unfinished)
Claus Gittinger <cg@exept.de>
parents:
42
diff
changeset
|
66 |
"initStream is an ugly hack until we have proper init defs" |
d7354b2599b6
more porting (but still unfinished)
Claus Gittinger <cg@exept.de>
parents:
42
diff
changeset
|
67 |
|
d7354b2599b6
more porting (but still unfinished)
Claus Gittinger <cg@exept.de>
parents:
42
diff
changeset
|
68 |
initStream := String new writeStream. |
42 | 69 |
|
143
d7354b2599b6
more porting (but still unfinished)
Claus Gittinger <cg@exept.de>
parents:
42
diff
changeset
|
70 |
Smalltalk isSmalltalkX ifTrue:[ |
d7354b2599b6
more porting (but still unfinished)
Claus Gittinger <cg@exept.de>
parents:
42
diff
changeset
|
71 |
(MCDependencySorter sortItems: aCollection) |
d7354b2599b6
more porting (but still unfinished)
Claus Gittinger <cg@exept.de>
parents:
42
diff
changeset
|
72 |
do: [:ea | ea accept: self] |
d7354b2599b6
more porting (but still unfinished)
Claus Gittinger <cg@exept.de>
parents:
42
diff
changeset
|
73 |
] ifFalse:[ |
d7354b2599b6
more porting (but still unfinished)
Claus Gittinger <cg@exept.de>
parents:
42
diff
changeset
|
74 |
(MCDependencySorter sortItems: aCollection) |
d7354b2599b6
more porting (but still unfinished)
Claus Gittinger <cg@exept.de>
parents:
42
diff
changeset
|
75 |
do: [:ea | ea accept: self] |
d7354b2599b6
more porting (but still unfinished)
Claus Gittinger <cg@exept.de>
parents:
42
diff
changeset
|
76 |
displayingProgress: 'Writing definitions...'. |
d7354b2599b6
more porting (but still unfinished)
Claus Gittinger <cg@exept.de>
parents:
42
diff
changeset
|
77 |
]. |
d7354b2599b6
more porting (but still unfinished)
Claus Gittinger <cg@exept.de>
parents:
42
diff
changeset
|
78 |
stream nextPutAll: initStream contents. |
42 | 79 |
! |
80 |
||
81 |
writeMetaclassDefinition: definition |
|
82 |
self chunkContents: [:s | s |
|
83 |
nextPutAll: definition className; |
|
84 |
nextPutAll: ' class'; |
|
85 |
cr; tab; |
|
86 |
nextPutAll: 'instanceVariableNames: '''; |
|
87 |
nextPutAll: definition classInstanceVariablesString; |
|
88 |
nextPut: $'. |
|
89 |
] |
|
90 |
! |
|
91 |
||
92 |
writeMethodInitializer: aMethodDefinition |
|
93 |
aMethodDefinition isInitializer ifTrue: |
|
94 |
[initStream nextChunkPut: aMethodDefinition className, ' initialize'; cr] |
|
95 |
! |
|
96 |
||
97 |
writeMethodPostscript |
|
98 |
stream |
|
99 |
space; |
|
100 |
nextPut: $!!; |
|
101 |
cr |
|
102 |
! |
|
103 |
||
104 |
writeMethodPreamble: definition |
|
105 |
stream |
|
106 |
cr; |
|
107 |
nextPut: $!!; |
|
108 |
nextPutAll: definition fullClassName; |
|
109 |
nextPutAll: ' methodsFor: '; |
|
110 |
nextPutAll: definition category asString printString; |
|
111 |
nextPutAll: ' stamp: '; |
|
112 |
nextPutAll: definition timeStamp asString printString; |
|
113 |
nextPutAll: '!!'; |
|
114 |
cr |
|
115 |
! |
|
116 |
||
117 |
writeMethodSource: definition |
|
118 |
stream nextChunkPut: definition source |
|
119 |
! |
|
120 |
||
121 |
writeSnapshot: aSnapshot |
|
122 |
self writeDefinitions: aSnapshot definitions |
|
123 |
! ! |
|
124 |
||
125 |
!MCStWriter class methodsFor:'documentation'! |
|
126 |
||
127 |
version |
|
143
d7354b2599b6
more porting (but still unfinished)
Claus Gittinger <cg@exept.de>
parents:
42
diff
changeset
|
128 |
^ '$Header: /cvs/stx/stx/goodies/monticello/MCStWriter.st,v 1.2 2009-10-26 15:25:23 cg Exp $' |
d7354b2599b6
more porting (but still unfinished)
Claus Gittinger <cg@exept.de>
parents:
42
diff
changeset
|
129 |
! |
d7354b2599b6
more porting (but still unfinished)
Claus Gittinger <cg@exept.de>
parents:
42
diff
changeset
|
130 |
|
d7354b2599b6
more porting (but still unfinished)
Claus Gittinger <cg@exept.de>
parents:
42
diff
changeset
|
131 |
version_CVS |
d7354b2599b6
more porting (but still unfinished)
Claus Gittinger <cg@exept.de>
parents:
42
diff
changeset
|
132 |
^ '$Header: /cvs/stx/stx/goodies/monticello/MCStWriter.st,v 1.2 2009-10-26 15:25:23 cg Exp $' |
42 | 133 |
! ! |