Character.st
changeset 4655 b9405ca0bb4e
parent 4340 523ef8410fad
child 4682 4158042a9c8c
--- a/Character.st	Wed Sep 01 21:52:42 1999 +0200
+++ b/Character.st	Wed Sep 01 21:55:23 1999 +0200
@@ -64,7 +64,7 @@
     Some of these have been modified a bit.
 
     WARNING: characters are known by compiler and runtime system -
-             do not change the instance layout. 
+	     do not change the instance layout. 
 
     Also, although you can create subclasses of Character, the compiler always
     creates instances of Character for literals ...
@@ -73,11 +73,11 @@
     Therefore, it may not make sense to create a character-subclass.
 
     [author:]
-        Claus Gittinger
+	Claus Gittinger
 
     [see also:]
-        String TwoByteString
-        StringCollection
+	String TwoByteString
+	StringCollection
 "
 ! !
 
@@ -297,13 +297,15 @@
     "
 !
 
-hasImmediateInstances
-    "return true if this class has immediate instances.
-     Redefined from Behavior"
+hasSharedInstances
+    "return true if this class has shared instances, that is, instances
+     with the same value are identical.
+     False is returned here, only redefined in classes which have unified
+     instances (or should be treated so)."
 
-    ^ self == Character
+    ^ true
 
-    "Created: 3.6.1997 / 12:01:52 / cg"
+
 !
 
 isBuiltInClass
@@ -319,11 +321,11 @@
     "added for squeak compatibility: return a collection of separator chars"
 
     ^ Array 
-        with:Character space
-        with:Character cr
-        with:Character tab
-        with:Character lf
-        with:Character ff
+	with:Character space
+	with:Character cr
+	with:Character tab
+	with:Character lf
+	with:Character ff
         
     "
      Character separators
@@ -383,12 +385,12 @@
     "Return the Character that is <aMagnitude> lower than the receiver.  
      Wrap if the resulting value is not a legal Character value. (JS)
      claus: 
-        modified to return the difference as integer, if the argument
-        is another character. If the argument is a number, a character is
-        returned."
+	modified to return the difference as integer, if the argument
+	is another character. If the argument is a number, a character is
+	returned."
 
     aMagnitude isCharacter ifTrue:[
-        ^ self asciiValue - aMagnitude asciiValue
+	^ self asciiValue - aMagnitude asciiValue
     ].
     ^ Character value:(asciivalue - aMagnitude asInteger \\ 256)
 
@@ -428,13 +430,11 @@
      with a special type-code followed by the asciiValue."
 
     (asciivalue < 256) ifTrue:[
-        stream nextPut:manager codeForCharacter; nextPut:asciivalue.
+	stream nextPut:manager codeForCharacter; nextPut:asciivalue.
     ] ifFalse:[
-        stream nextPut:manager codeForTwoByteCharacter.
-        stream nextPutShort:asciivalue MSB:true
+	stream nextPut:manager codeForTwoByteCharacter.
+	stream nextPutShort:asciivalue MSB:true
     ]
-
-    "Modified: / 2.11.1997 / 14:14:50 / cg"
 ! !
 
 !Character methodsFor:'comparing'!
@@ -532,13 +532,13 @@
 
     "/ ISO Latin-1
     ((code >= $A asciiValue) and:[code <= $Z asciiValue]) ifTrue:[
-        ^ Character value:(code + ($a asciiValue - $A asciiValue))
+	^ Character value:(code + ($a asciiValue - $A asciiValue))
     ].
     code < 16r00C0 ifTrue:[^ self].
     code < 16r0100 ifTrue:[
-        code >= 16r00DF ifTrue:[^ self].
-        code == 16r00D7 ifTrue:[^ self].
-        ^ Character value:(code + 16r20)
+	code >= 16r00DF ifTrue:[^ self].
+	code == 16r00D7 ifTrue:[^ self].
+	^ Character value:(code + 16r20)
     ].
 
     "/ mhmh - in which encoding is this character.
@@ -565,16 +565,16 @@
 
     val = __intVal(_characterVal(self));
     if (val <= 0xFF) {
-        buffer[0] = (char) val;
-        buffer[1] = '\0';
-        s = __MKSTRING_L(buffer, 1 COMMA_SND);
-        if (s != nil) {
-            RETURN (s);
-        }
+	buffer[0] = (char) val;
+	buffer[1] = '\0';
+	s = __MKSTRING_L(buffer, 1 COMMA_SND);
+	if (s != nil) {
+	    RETURN (s);
+	}
     }
 %}.
     asciivalue > 255 ifTrue:[
-        ^ (TwoByteString new:1) at:1 put:self; yourself
+	^ (TwoByteString new:1) at:1 put:self; yourself
     ].
 
 "/
@@ -612,15 +612,15 @@
 
     "/ ISO Latin-1
     ((code >= $a asciiValue) and:[code <= $z asciiValue]) ifTrue:[
-        ^ Character value:(code + ($A asciiValue - $a asciiValue))
+	^ Character value:(code + ($A asciiValue - $a asciiValue))
     ].
     code < 16r00E0 ifTrue:[^ self].
     code < 16r0100 ifTrue:[
-        code == 16r00F7 ifTrue:[^ self]. "/ division
+	code == 16r00F7 ifTrue:[^ self]. "/ division
 "/        code == 16r00FF ifTrue:[^ Character value:16r0178].  "/ y diaresis (no uppercase equivalent in ISO-latin 1
-        code == 16r00FF ifTrue:[^ self]. 
+	code == 16r00FF ifTrue:[^ self]. 
 
-        ^ Character value:(code - 16r20)
+	^ Character value:(code - 16r20)
     ].
 
     "/ mhmh - in which encoding is this character.
@@ -756,7 +756,7 @@
 
     "stupid - should be configurable from a table ...
      ... good thing is, that iso8859 puts all national
-         characters above 16rC0"
+	 characters above 16rC0"
 
     self isLetterOrDigit ifTrue:[^ true].
     ^ self isNationalLetter
@@ -770,7 +770,7 @@
 
     "stupid - should be configurable from a table ...
      ... good thing is, that iso8859 puts all national
-         characters above 16rC0"
+	 characters above 16rC0"
 
     self isLetter ifTrue:[^ true].
     (asciivalue between:16rC0 and:16rD6) ifTrue:[^ true].
@@ -791,7 +791,7 @@
 !
 
 isLiteral
-    "return true, if the receiver can be used as a literal
+    "return true, if the receiver can be used as a literal constant in ST syntax
      (i.e. can be used in constant arrays)"
 
     ^ true
@@ -831,30 +831,30 @@
     |special|
 
     (asciivalue between:33 and:127) ifFalse:[
-        (self == Character space) ifTrue:[
-            special := 'space'
-        ] ifFalse:[
-            (self == Character cr) ifTrue:[
-                special := 'cr'.
-            ] ifFalse:[
-                (self == Character tab) ifTrue:[
-                    special := 'tab'.
-                ] ifFalse:[
-                    (self == Character esc) ifTrue:[
-                        special := 'esc'.
-                    ]
-                ]
-            ]
-        ].
-        special notNil ifTrue:[
-            aStream nextPutAll:'(Character '; nextPutAll:special; nextPut:$).
-            ^ self
-        ].
-        aStream nextPutAll:'(Character value:16r'.
-        asciivalue printOn:aStream base:16.
-        aStream nextPut:$)
+	(self == Character space) ifTrue:[
+	    special := 'space'
+	] ifFalse:[
+	    (self == Character cr) ifTrue:[
+		special := 'cr'.
+	    ] ifFalse:[
+		(self == Character tab) ifTrue:[
+		    special := 'tab'.
+		] ifFalse:[
+		    (self == Character esc) ifTrue:[
+			special := 'esc'.
+		    ]
+		]
+	    ]
+	].
+	special notNil ifTrue:[
+	    aStream nextPutAll:'(Character '; nextPutAll:special; nextPut:$).
+	    ^ self
+	].
+	aStream nextPutAll:'(Character value:16r'.
+	asciivalue printOn:aStream base:16.
+	aStream nextPut:$)
     ] ifTrue:[
-        aStream nextPut:$$; nextPut:self
+	aStream nextPut:$$; nextPut:self
     ]
 
     "Modified: / 23.2.1996 / 23:27:32 / cg"
@@ -898,7 +898,7 @@
 
     val = __intVal(__INST(asciivalue));
     if (val < ' ') {
-        RETURN ( true );
+	RETURN ( true );
     }
 #endif
 %}.
@@ -921,13 +921,13 @@
 
     (asciivalue < $0 asciiValue) ifTrue:[^ false]. 
     (r > 10) ifTrue:[
-        (asciivalue between:($0 asciiValue) and:($9 asciiValue)) ifTrue:[
-            ^ true
-        ].
-        ((asciivalue - $a asciiValue) between:0 and:(r - 11)) ifTrue:[
-            ^ true
-        ].
-        ^ (asciivalue - $A asciiValue) between:0 and:(r - 11)
+	(asciivalue between:($0 asciiValue) and:($9 asciiValue)) ifTrue:[
+	    ^ true
+	].
+	((asciivalue - $a asciiValue) between:0 and:(r - 11)) ifTrue:[
+	    ^ true
+	].
+	^ (asciivalue - $A asciiValue) between:0 and:(r - 11)
     ].
     (asciivalue - $0 asciiValue) < r ifTrue:[^ true].
     ^ false
@@ -1077,8 +1077,17 @@
     ^ false
 ! !
 
+!Character methodsFor:'tracing'!
+
+traceInto:aRequestor level:level
+    "double dispatch into tracer, passing my type implicitely in the selector"
+
+    ^ aRequestor traceCharacter:self level:level
+
+! !
+
 !Character class methodsFor:'documentation'!
 
 version
-    ^ '$Header: /cvs/stx/stx/libbasic/Character.st,v 1.53 1999-07-06 23:59:20 cg Exp $'
+    ^ '$Header: /cvs/stx/stx/libbasic/Character.st,v 1.54 1999-09-01 19:55:23 cg Exp $'
 ! !