Class.st
changeset 5514 0db3f902e1df
parent 5474 c7c69123fd48
child 5545 1faf1228868d
equal deleted inserted replaced
5513:17d96aee4111 5514:0db3f902e1df
   480     "return a collection of the class variable name-strings.
   480     "return a collection of the class variable name-strings.
   481      Only names of class variables defined in this class are included
   481      Only names of class variables defined in this class are included
   482      in the returned collection - use allClassVarNames, to get all known names."
   482      in the returned collection - use allClassVarNames, to get all known names."
   483 
   483 
   484     classvars isNil ifTrue:[
   484     classvars isNil ifTrue:[
   485 	^ OrderedCollection new
   485         ^ OrderedCollection new
   486     ].
   486     ].
   487     ^ classvars asCollectionOfWords
   487     classvars isString ifTrue:[
       
   488         classvars := classvars asCollectionOfWords asArray.
       
   489         ^ classvars
       
   490     ].
       
   491 
       
   492     ^ classvars
   488 
   493 
   489     "
   494     "
   490      Object classVarNames 
   495      Object classVarNames 
   491      Float classVarNames
   496      Float classVarNames
   492     "
   497     "
   496     "return a string of the class variables names.
   501     "return a string of the class variables names.
   497      Only names of class variables defined in this class are in the
   502      Only names of class variables defined in this class are in the
   498      returned string."
   503      returned string."
   499 
   504 
   500     classvars isNil ifTrue:[^ ''].
   505     classvars isNil ifTrue:[^ ''].
   501     ^ classvars
   506     classvars isString ifTrue:[
       
   507         ^ classvars
       
   508     ].
       
   509 
       
   510     ^ classvars asStringWith:(Character space)
   502 
   511 
   503     "
   512     "
   504      Object classVariableString 
   513      Object classVariableString 
   505      Float classVariableString  
   514      Float classVariableString  
   506     "
   515     "
   511      Initialize new class variables with nil, clear and remove old ones. 
   520      Initialize new class variables with nil, clear and remove old ones. 
   512      No change record is written and no classes are recompiled."
   521      No change record is written and no classes are recompiled."
   513 
   522 
   514     |prevVarNames varNames any|
   523     |prevVarNames varNames any|
   515 
   524 
   516     (classvars = aString) ifFalse:[
   525     (aString = self classVariableString) ifFalse:[
   517 	prevVarNames := self classVarNames.
   526         prevVarNames := self classVarNames.
   518 	classvars := aString.
   527         classvars := aString.
   519 	varNames := self classVarNames.
   528         varNames := self classVarNames.
   520 
   529 
   521 	"new ones get initialized to nil;
   530         "new ones get initialized to nil;
   522 	 - old ones are nilled and removed from Smalltalk"
   531          - old ones are nilled and removed from Smalltalk"
   523 	any := false.
   532         any := false.
   524 
   533 
   525 	varNames do:[:aName |
   534         varNames do:[:aName |
   526 	    (prevVarNames includes:aName) ifFalse:[
   535             (prevVarNames includes:aName) ifFalse:[
   527 		"a new one"
   536                 "a new one"
   528 		self classVarAt:aName put:nil.
   537                 self classVarAt:aName put:nil.
   529 		any := true.
   538                 any := true.
   530 	    ] ifTrue:[
   539             ] ifTrue:[
   531 		prevVarNames remove:aName
   540                 prevVarNames remove:aName
   532 	    ]
   541             ]
   533 	].
   542         ].
   534 	"left overs are gone"
   543         "left overs are gone"
   535 	prevVarNames do:[:aName |
   544         prevVarNames do:[:aName |
   536 	    self classVarAt:aName put:nil.
   545             self classVarAt:aName put:nil.
   537 	    Smalltalk removeKey:(self name , ':' , aName) asSymbol.
   546             Smalltalk removeKey:(self name , ':' , aName) asSymbol.
   538 	].
   547         ].
   539 	any ifTrue:[
   548         any ifTrue:[
   540 	    Smalltalk changed:#classVariables with:self
   549             Smalltalk changed:#classVariables with:self
   541 	].
   550         ].
   542     ]
   551     ]
   543 
   552 
   544     "Modified: 2.4.1997 / 00:16:05 / stefan"
   553     "Modified: 2.4.1997 / 00:16:05 / stefan"
   545 !
   554 !
   546 
   555 
  1334     name storeBinaryOn:stream manager:manager.
  1343     name storeBinaryOn:stream manager:manager.
  1335     flags storeBinaryOn:stream manager:manager.
  1344     flags storeBinaryOn:stream manager:manager.
  1336     (instvars isNil or:[instvars isEmpty]) ifTrue:[
  1345     (instvars isNil or:[instvars isEmpty]) ifTrue:[
  1337         s := nil
  1346         s := nil
  1338     ] ifFalse:[
  1347     ] ifFalse:[
  1339         s := instvars isString ifTrue:[instvars] ifFalse:[instvars asStringCollection asString]
  1348         s := self instanceVariableString
  1340     ].
  1349     ].
  1341     s storeBinaryOn:stream manager:manager.
  1350     s storeBinaryOn:stream manager:manager.
  1342 
  1351 
  1343     (classvars notNil and:[classvars isEmpty]) ifTrue:[
  1352     (classvars isNil or:[classvars isEmpty]) ifTrue:[
  1344         s := nil
  1353         s := nil
  1345     ] ifFalse:[
  1354     ] ifFalse:[
  1346         s := classvars isString ifTrue:[classvars] ifFalse:[classvars asStringCollection asString]
  1355         s := self classVariableString
  1347     ].
  1356     ].
  1348     s storeBinaryOn:stream manager:manager.
  1357     s storeBinaryOn:stream manager:manager.
  1349 
  1358 
  1350     "/ the category
  1359     "/ the category
  1351     owner notNil ifTrue:[
  1360     owner notNil ifTrue:[
  4450 ! !
  4459 ! !
  4451 
  4460 
  4452 !Class class methodsFor:'documentation'!
  4461 !Class class methodsFor:'documentation'!
  4453 
  4462 
  4454 version
  4463 version
  4455     ^ '$Header: /cvs/stx/stx/libbasic/Class.st,v 1.374 2000-07-20 14:02:47 cg Exp $'
  4464     ^ '$Header: /cvs/stx/stx/libbasic/Class.st,v 1.375 2000-08-11 17:38:27 cg Exp $'
  4456 ! !
  4465 ! !