ClassCategoryReader.st
author claus
Wed, 15 Feb 1995 11:22:05 +0100
changeset 249 810798c5c2e5
parent 216 a8abff749575
child 328 7b542c0bf1dd
permissions -rw-r--r--
.

"
 COPYRIGHT (c) 1989 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 privacy ignore primSpec'
       classVariableNames:''
       poolDictionaries:''
       category:'Kernel-Support'
!

ClassCategoryReader comment:'
COPYRIGHT (c) 1989 by Claus Gittinger
	     All Rights Reserved

$Header: /cvs/stx/stx/libbasic/ClassCategoryReader.st,v 1.13 1995-02-15 10:21:24 claus Exp $
'!

!ClassCategoryReader class methodsFor:'documentation'!

copyright
"
 COPYRIGHT (c) 1989 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.
"
!

version
"
$Header: /cvs/stx/stx/libbasic/ClassCategoryReader.st,v 1.13 1995-02-15 10:21:24 claus Exp $
"
!

documentation
"
    a helper class for fileIn - keeps track of class and category to filein for.
    Instances of this are created by the #methodsFor: methods in Class, to
    read the next chunk(s) from a stream.
"
! !

!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
!

class:aClass primitiveSpec:which
    "return a ClassCategoryReader to read a primitiveSpec chunk"

    ^ self new class:aClass primitiveSpec:which
!

skippingChunks
    "return a class categoryReader which skips chunks up to the next empty one"

    ^ self new ignoreMethods
! !

!ClassCategoryReader methodsFor:'private'!

class:aClass category:aCategory
    "set the instance variables"

    myClass := aClass.
    myCategory := aCategory.
    ignore := false
!

class:aClass primitiveSpec:which
    "set the instance variables"

    myClass := aClass.
    primSpec := which.
    ignore := false
! !

!ClassCategoryReader methodsFor:'special'!

privateProtocol
    privacy := #private
! 

protectedProtocol
    privacy := #protected
! 

ignoreMethods 
    ignore := true
! !

!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 and 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:[
		primSpec notNil ifTrue:[
		    myClass perform:primSpec with:aString.
		    "
		     ignore rest
		    "
		    ignore := true
		].
		ignore ifFalse:[
		    method := myClass compilerClass
				 compile:aString
				 forClass:myClass
				 inCategory:myCategory
				 notifying:requestor
				 install:true
				 skipIfSame:true.
		    privacy notNil ifTrue:[
			privacy == #private ifTrue:[
			    method setToPrivate
			] ifFalse:[
			    privacy == #protected ifTrue:[
				method setToProtected
			    ]
			]
		    ]
		]
	    ]
	]
    ]
!

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
! !