author | Claus Gittinger <cg@exept.de> |
Tue, 19 Aug 1997 22:40:49 +0200 | |
changeset 2868 | 772c890f907c |
parent 2416 | 588d5d510c10 |
child 3070 | 1bf5a29fddc9 |
permissions | -rw-r--r-- |
1 | 1 |
" |
5 | 2 |
COPYRIGHT (c) 1988 by Claus Gittinger |
159 | 3 |
All Rights Reserved |
1 | 4 |
|
5 |
This software is furnished under a license and may be used |
|
6 |
only in accordance with the terms of that license and with the |
|
7 |
inclusion of the above copyright notice. This software may not |
|
8 |
be provided or otherwise made available to, or used by, any |
|
9 |
other person. No title to or ownership of the software is |
|
10 |
hereby transferred. |
|
11 |
" |
|
12 |
||
13 |
Object subclass:#Boolean |
|
1245 | 14 |
instanceVariableNames:'' |
15 |
classVariableNames:'' |
|
16 |
poolDictionaries:'' |
|
17 |
category:'Kernel-Objects' |
|
1 | 18 |
! |
19 |
||
88 | 20 |
!Boolean class methodsFor:'documentation'! |
21 |
||
22 |
copyright |
|
23 |
" |
|
24 |
COPYRIGHT (c) 1988 by Claus Gittinger |
|
159 | 25 |
All Rights Reserved |
1 | 26 |
|
88 | 27 |
This software is furnished under a license and may be used |
28 |
only in accordance with the terms of that license and with the |
|
29 |
inclusion of the above copyright notice. This software may not |
|
30 |
be provided or otherwise made available to, or used by, any |
|
31 |
other person. No title to or ownership of the software is |
|
32 |
hereby transferred. |
|
33 |
" |
|
34 |
! |
|
1 | 35 |
|
88 | 36 |
documentation |
37 |
" |
|
38 |
Boolean is an abstract class defining the common protocol for logical |
|
39 |
values. The logical values are represented by its two subclasses True and False. |
|
40 |
||
41 |
There are no instances of Boolean in the system and there is only one |
|
42 |
instance of True (which is the global true) and one of False (false). |
|
1 | 43 |
|
88 | 44 |
Boolean redefines some messages which deal with copying Booleans, |
45 |
to make certain there is only one instance of each. |
|
46 |
The system will behave strange if you fiddle around here and create |
|
47 |
new instances of True or False (i.e. it will not recognize these new |
|
48 |
instances as being true or false). |
|
1294 | 49 |
|
50 |
[author:] |
|
51 |
Claus Gittinger |
|
88 | 52 |
" |
53 |
! ! |
|
1 | 54 |
|
55 |
!Boolean class methodsFor:'instance creation'! |
|
56 |
||
57 |
basicNew |
|
1119
956d62a5656c
compile seldom used methods with optSpace (is this a good idea ?)
Claus Gittinger <cg@exept.de>
parents:
698
diff
changeset
|
58 |
"{ Pragma: +optSpace }" |
956d62a5656c
compile seldom used methods with optSpace (is this a good idea ?)
Claus Gittinger <cg@exept.de>
parents:
698
diff
changeset
|
59 |
|
1 | 60 |
"catch instance creation |
2 | 61 |
- there must be exactly one instance of each - no more" |
1 | 62 |
|
63 |
self error:'new instances of True/False are not allowed' |
|
64 |
! ! |
|
65 |
||
3 | 66 |
!Boolean class methodsFor:'queries'! |
67 |
||
68 |
isBuiltInClass |
|
1266 | 69 |
"return true if this class is known by the run-time-system. |
70 |
Here, true is returned (for my two subclasses)." |
|
3 | 71 |
|
72 |
^ true |
|
1266 | 73 |
|
74 |
"Modified: 23.4.1996 / 15:58:22 / cg" |
|
3 | 75 |
! ! |
76 |
||
698 | 77 |
!Boolean methodsFor:'binary storage'! |
78 |
||
79 |
hasSpecialBinaryRepresentation |
|
80 |
"return true, if the receiver has a special binary representation" |
|
81 |
||
82 |
^true |
|
83 |
! ! |
|
84 |
||
422 | 85 |
!Boolean methodsFor:'converting'! |
86 |
||
2416 | 87 |
decodeAsLiteralArray |
88 |
"given a literalEncoding in the receiver, |
|
89 |
create & return the corresponding object. |
|
90 |
The inverse operation to #literalArrayEncoding." |
|
91 |
||
92 |
^ self |
|
93 |
||
94 |
"Created: 25.2.1997 / 19:16:43 / cg" |
|
95 |
"Modified: 25.2.1997 / 19:17:45 / cg" |
|
96 |
! |
|
97 |
||
422 | 98 |
literalArrayEncoding |
1245 | 99 |
"encode myself as an array literal, from which a copy of the receiver |
100 |
can be reconstructed with #decodeAsLiteralArray." |
|
422 | 101 |
|
102 |
^ self |
|
103 |
||
104 |
"Modified: 5.9.1995 / 22:46:57 / claus" |
|
1245 | 105 |
"Modified: 22.4.1996 / 13:00:05 / cg" |
422 | 106 |
! ! |
107 |
||
1 | 108 |
!Boolean methodsFor:'copying'! |
109 |
||
159 | 110 |
copy |
111 |
"return a shallow copy of the receiver |
|
112 |
- since both true and false are unique, return the receiver" |
|
113 |
||
114 |
^ self |
|
115 |
! |
|
116 |
||
1 | 117 |
deepCopy |
118 |
"return a deep copy of the receiver |
|
119 |
- since both true and false are unique, return the receiver" |
|
120 |
||
121 |
^ self |
|
12 | 122 |
! |
123 |
||
124 |
deepCopyUsing:aDictionary |
|
125 |
"return a deep copy of the receiver |
|
126 |
- since both true and false are unique, return the receiver" |
|
127 |
||
128 |
^ self |
|
129 |
! |
|
130 |
||
698 | 131 |
shallowCopy |
132 |
"return a shallow copy of the receiver |
|
133 |
- since both true and false are unique, return the receiver" |
|
134 |
||
135 |
^ self |
|
136 |
! |
|
137 |
||
12 | 138 |
simpleDeepCopy |
139 |
"return a deep copy of the receiver |
|
140 |
- since both true and false are unique, return the receiver" |
|
141 |
||
142 |
^ self |
|
1 | 143 |
! ! |
144 |
||
698 | 145 |
!Boolean methodsFor:'printing & storing'! |
146 |
||
147 |
printOn:aStream |
|
148 |
"append a character sequence representing the receiver to the argument, |
|
149 |
aStream" |
|
150 |
||
151 |
aStream nextPutAll:self printString |
|
152 |
! |
|
153 |
||
154 |
storeOn:aStream |
|
155 |
"append a character sequence to the argument, aStream from which the |
|
156 |
receiver can be reconstructed using readFrom:." |
|
157 |
||
158 |
^ self printOn:aStream |
|
159 |
! |
|
160 |
||
161 |
storeString |
|
162 |
"return a character sequence to the argument, aStream from which the |
|
163 |
receiver can be reconstructed using readFrom:." |
|
164 |
||
165 |
^ self printString |
|
166 |
! ! |
|
167 |
||
379 | 168 |
!Boolean methodsFor:'queries'! |
169 |
||
170 |
isLiteral |
|
171 |
"return true, if the receiver can be used as a literal |
|
172 |
(i.e. can be used in constant arrays)" |
|
173 |
||
174 |
^ true |
|
175 |
! ! |
|
176 |
||
698 | 177 |
!Boolean class methodsFor:'documentation'! |
54 | 178 |
|
698 | 179 |
version |
2416 | 180 |
^ '$Header: /cvs/stx/stx/libbasic/Boolean.st,v 1.21 1997-02-25 18:19:23 cg Exp $' |
1 | 181 |
! ! |