1
|
1 |
"
|
5
|
2 |
COPYRIGHT (c) 1989 by Claus Gittinger
|
167
|
3 |
All Rights Reserved
|
1
|
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 |
|
|
13 |
Object subclass:#ClassCategoryReader
|
216
|
14 |
instanceVariableNames:'myClass myCategory privacy ignore primSpec'
|
1
|
15 |
classVariableNames:''
|
|
16 |
poolDictionaries:''
|
|
17 |
category:'Kernel-Support'
|
|
18 |
!
|
|
19 |
|
|
20 |
ClassCategoryReader comment:'
|
5
|
21 |
COPYRIGHT (c) 1989 by Claus Gittinger
|
167
|
22 |
All Rights Reserved
|
92
|
23 |
|
350
|
24 |
$Header: /cvs/stx/stx/libbasic/ClassCategoryReader.st,v 1.15 1995-05-18 22:49:17 claus Exp $
|
88
|
25 |
'!
|
1
|
26 |
|
88
|
27 |
!ClassCategoryReader class methodsFor:'documentation'!
|
|
28 |
|
|
29 |
copyright
|
|
30 |
"
|
|
31 |
COPYRIGHT (c) 1989 by Claus Gittinger
|
167
|
32 |
All Rights Reserved
|
1
|
33 |
|
88
|
34 |
This software is furnished under a license and may be used
|
|
35 |
only in accordance with the terms of that license and with the
|
|
36 |
inclusion of the above copyright notice. This software may not
|
|
37 |
be provided or otherwise made available to, or used by, any
|
|
38 |
other person. No title to or ownership of the software is
|
|
39 |
hereby transferred.
|
|
40 |
"
|
|
41 |
!
|
|
42 |
|
|
43 |
version
|
|
44 |
"
|
350
|
45 |
$Header: /cvs/stx/stx/libbasic/ClassCategoryReader.st,v 1.15 1995-05-18 22:49:17 claus Exp $
|
88
|
46 |
"
|
|
47 |
!
|
|
48 |
|
|
49 |
documentation
|
|
50 |
"
|
|
51 |
a helper class for fileIn - keeps track of class and category to filein for.
|
|
52 |
Instances of this are created by the #methodsFor: methods in Class, to
|
|
53 |
read the next chunk(s) from a stream.
|
|
54 |
"
|
|
55 |
! !
|
1
|
56 |
|
|
57 |
!ClassCategoryReader class methodsFor:'instance creation'!
|
|
58 |
|
|
59 |
class:aClass category:aCategory
|
|
60 |
"return a new ClassCategoryReader to read methods for aClass with
|
|
61 |
methodCategory aCategory"
|
|
62 |
|
|
63 |
^ self new class:aClass category:aCategory
|
167
|
64 |
!
|
|
65 |
|
216
|
66 |
class:aClass primitiveSpec:which
|
|
67 |
"return a ClassCategoryReader to read a primitiveSpec chunk"
|
|
68 |
|
|
69 |
^ self new class:aClass primitiveSpec:which
|
|
70 |
!
|
|
71 |
|
167
|
72 |
skippingChunks
|
|
73 |
"return a class categoryReader which skips chunks up to the next empty one"
|
|
74 |
|
|
75 |
^ self new ignoreMethods
|
1
|
76 |
! !
|
|
77 |
|
|
78 |
!ClassCategoryReader methodsFor:'private'!
|
|
79 |
|
|
80 |
class:aClass category:aCategory
|
|
81 |
"set the instance variables"
|
|
82 |
|
|
83 |
myClass := aClass.
|
68
|
84 |
myCategory := aCategory.
|
216
|
85 |
ignore := false
|
|
86 |
!
|
|
87 |
|
|
88 |
class:aClass primitiveSpec:which
|
|
89 |
"set the instance variables"
|
|
90 |
|
|
91 |
myClass := aClass.
|
|
92 |
primSpec := which.
|
135
|
93 |
ignore := false
|
68
|
94 |
! !
|
|
95 |
|
|
96 |
!ClassCategoryReader methodsFor:'special'!
|
|
97 |
|
|
98 |
privateProtocol
|
167
|
99 |
privacy := #private
|
|
100 |
!
|
|
101 |
|
|
102 |
protectedProtocol
|
|
103 |
privacy := #protected
|
135
|
104 |
!
|
|
105 |
|
|
106 |
ignoreMethods
|
|
107 |
ignore := true
|
1
|
108 |
! !
|
|
109 |
|
|
110 |
!ClassCategoryReader methodsFor:'fileIn'!
|
|
111 |
|
328
|
112 |
fileInFrom:aStream notifying:requestor passChunk:passChunk
|
1
|
113 |
"read method-chunks from the input stream, aStream; compile them
|
|
114 |
and add the methods to the class defined by the class-instance var;
|
12
|
115 |
errors and notifications are passed to requestor"
|
1
|
116 |
|
350
|
117 |
|aString done method compiler|
|
1
|
118 |
|
328
|
119 |
Smalltalk silentLoading ifFalse:[
|
|
120 |
Transcript show:' '; show:myClass name; show:' -> '; showCr:myCategory.
|
|
121 |
].
|
|
122 |
|
1
|
123 |
done := false.
|
|
124 |
[done] whileFalse:[
|
167
|
125 |
done := aStream atEnd.
|
|
126 |
done ifFalse:[
|
|
127 |
aString := aStream nextChunk.
|
|
128 |
done := aString isNil or:[aString isEmpty].
|
|
129 |
done ifFalse:[
|
216
|
130 |
primSpec notNil ifTrue:[
|
|
131 |
myClass perform:primSpec with:aString.
|
|
132 |
"
|
|
133 |
ignore rest
|
|
134 |
"
|
|
135 |
ignore := true
|
|
136 |
].
|
167
|
137 |
ignore ifFalse:[
|
328
|
138 |
passChunk ifTrue:[
|
|
139 |
requestor source:aString
|
|
140 |
].
|
|
141 |
|
350
|
142 |
compiler := myClass compilerClass.
|
|
143 |
|
|
144 |
"/
|
|
145 |
"/ kludge - have to make ST/X's compiler protocol
|
|
146 |
"/ be compatible to ST-80's
|
|
147 |
"/
|
|
148 |
(compiler respondsTo:#compile:forClass:inCategory:notifying:install:skipIfSame:)
|
|
149 |
ifTrue:[
|
|
150 |
method :=compiler
|
|
151 |
compile:aString
|
|
152 |
forClass:myClass
|
|
153 |
inCategory:myCategory
|
|
154 |
notifying:requestor
|
|
155 |
install:true
|
|
156 |
skipIfSame:true.
|
|
157 |
|
|
158 |
] ifFalse:[
|
|
159 |
method := compiler new
|
|
160 |
compile:aString
|
|
161 |
in:myClass
|
|
162 |
notifying:requestor
|
|
163 |
ifFail:nil
|
|
164 |
].
|
328
|
165 |
|
167
|
166 |
privacy notNil ifTrue:[
|
|
167 |
privacy == #private ifTrue:[
|
|
168 |
method setToPrivate
|
|
169 |
] ifFalse:[
|
|
170 |
privacy == #protected ifTrue:[
|
|
171 |
method setToProtected
|
|
172 |
]
|
|
173 |
]
|
|
174 |
]
|
|
175 |
]
|
|
176 |
]
|
|
177 |
]
|
1
|
178 |
]
|
|
179 |
!
|
|
180 |
|
|
181 |
fileInFrom:aStream
|
|
182 |
"read method-chunks from the input stream, aStream; compile them
|
|
183 |
and add the methods to the class defined by the class-instance var"
|
|
184 |
|
328
|
185 |
self fileInFrom:aStream notifying:nil passChunk:false
|
1
|
186 |
! !
|