ClassDescr.st
author claus
Mon, 20 Dec 1993 18:32:29 +0100
changeset 27 d98f9dd437f7
parent 10 4f1f9a91e406
child 68 59faa75185ba
permissions -rw-r--r--
*** empty log message ***

"
 COPYRIGHT (c) 1993 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.
"

Behavior subclass:#ClassDescription
       instanceVariableNames:'name category instvars'
       classVariableNames:''
       poolDictionaries:''
       category:'Kernel-Classes'
!

ClassDescription comment:'

COPYRIGHT (c) 1993 by Claus Gittinger
              All Rights Reserved

this class has been added for ST-80 compatibility only.
All class stuff used to be in Behavior and Class - but, to be
able to file in some PD code, it became nescessary to add it.

Instance variables:

name            <String>        the classes name
category        <String>        the classes category
instvars        <String>        the names of the instance variables

$Header: /cvs/stx/stx/libbasic/Attic/ClassDescr.st,v 1.4 1993-11-08 02:29:45 claus Exp $
'!

!ClassDescription methodsFor:'accessing'!

instanceVariableString
    "return a string of the instance variable names"

    instvars isNil ifTrue:[^ ''].
    ^ instvars
!

instanceVariableString:aString
    "set the classes instvarnames string - notice, that this
     should be used only during class creation; the number of
     instance variables is determined by another instance 
     (see Behavior)."

    instvars := aString.
    self changed
!

instVarNames
    "return a collection of the instance variable name-strings"

    instvars isNil ifTrue:[
        ^ OrderedCollection new
    ].
    ^ instvars asCollectionOfWords
!

allInstVarNames
    "return a collection of all the instance variable name-strings
     this includes all superclass-instance variables"

    ^ self addAllInstVarNamesTo:(OrderedCollection new)
!


setName:aString
    "set the classes name - be careful, it will be still
     in the Smalltalk dictionary - under another key"

    name := aString
!

name
    "return the name (aString) of the class"

    ^ name
!

category
    "return the category (aString) of the class"

    ^ category
!

category:aStringOrSymbol
    "set the category of the class to be the argument, aString"

    category := aStringOrSymbol asSymbol
! !

!ClassDescription methodsFor:'renaming'!

renameTo:newName
    "change the name of the class - this writes a change record"

    |oldName oldSym|

    oldName := name.
    oldSym := name asSymbol.
    self setName:newName.

    Smalltalk at:oldSym put:nil.
    Smalltalk removeKey:oldSym.             "26.jun 93"
    Smalltalk at:(newName asSymbol) put:self.
! !

!ClassDescription methodsFor:'private'!

addAllInstVarNamesTo:aCollection
    "helper - add the name-strings of the instance variables and of the inst-vars
     of all superclasses to the argument, aCollection. Return aCollection"

    (superclass notNil) ifTrue:[
        superclass addAllInstVarNamesTo:aCollection
    ].
    instvars notNil ifTrue:[
        aCollection addAll:(instvars asCollectionOfWords).
    ].
    ^ aCollection
! !