CCReader.st
changeset 1 a27a279701f8
child 3 24d81bf47225
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/CCReader.st	Fri Jul 16 11:39:45 1993 +0200
@@ -0,0 +1,81 @@
+"
+ COPYRIGHT (c) 1989-92 by Claus Gittinger
+              All Rights Reserved
+
+ This software is furnished under a license and may be used
+ only in accordance with the terms of that license and with the
+ inclusion of the above copyright notice.   This software may not
+ be provided or otherwise made available to, or used by, any
+ other person.  No title to or ownership of the software is
+ hereby transferred.
+"
+
+Object subclass:#ClassCategoryReader
+       instanceVariableNames:'myClass myCategory'
+       classVariableNames:''
+       poolDictionaries:''
+       category:'Kernel-Support'
+!
+
+ClassCategoryReader comment:'
+
+COPYRIGHT (c) 1989-92 by Claus Gittinger
+             All Rights Reserved
+
+a helper class for fileIn - keeps track of class and category to filein for.
+
+%W% %E%
+written 89 by claus
+'!
+
+!ClassCategoryReader class methodsFor:'instance creation'!
+
+class:aClass category:aCategory
+    "return a new ClassCategoryReader to read methods for aClass with
+     methodCategory aCategory"
+
+    ^ self new class:aClass category:aCategory
+! !
+
+!ClassCategoryReader methodsFor:'private'!
+
+class:aClass category:aCategory
+    "set the instance variables"
+
+    myClass := aClass.
+    myCategory := aCategory
+! !
+
+!ClassCategoryReader methodsFor:'fileIn'!
+
+fileInFrom:aStream notifying:requestor
+    "read method-chunks from the input stream, aStream; compile them
+     and add the methods to the class defined by the class-instance var;
+     errors notifications are passed to requestor"
+
+    |aString done method|
+
+    done := false.
+    [done] whileFalse:[
+        done := aStream atEnd.
+        done ifFalse:[
+            aString := aStream nextChunk.
+            done := aString isNil or:[aString isEmpty].
+            done ifFalse:[
+                method := Compiler compile:aString
+                                  forClass:myClass
+                                inCategory:myCategory
+                                 notifying:requestor
+                                   install:true
+                                skipIfSame:true
+            ]
+        ]
+    ]
+!
+
+fileInFrom:aStream
+    "read method-chunks from the input stream, aStream; compile them
+     and add the methods to the class defined by the class-instance var"
+
+    self fileInFrom:aStream notifying:nil
+! !