author | Claus Gittinger <cg@exept.de> |
Sat, 16 May 2015 11:50:57 +0200 | |
changeset 18351 | dc6c93a03b6d |
parent 16158 | 93042fc9827e |
child 18366 | a6e62e167c32 |
child 18439 | b9ef8e4966e4 |
permissions | -rw-r--r-- |
18351 | 1 |
"{ Encoding: utf8 }" |
2 |
||
8728 | 3 |
" |
4 |
COPYRIGHT (c) 2004 by eXept Software AG |
|
5 |
All Rights Reserved |
|
6 |
||
7 |
This software is furnished under a license and may be used |
|
8 |
only in accordance with the terms of that license and with the |
|
9 |
inclusion of the above copyright notice. This software may not |
|
10 |
be provided or otherwise made available to, or used by, any |
|
11 |
other person. No title to or ownership of the software is |
|
12 |
hereby transferred. |
|
13 |
" |
|
6844 | 14 |
"{ Package: 'stx:libbasic' }" |
15 |
||
18351 | 16 |
"{ NameSpace: Smalltalk }" |
17 |
||
6844 | 18 |
nil subclass:#ProtoObject |
19 |
instanceVariableNames:'' |
|
20 |
classVariableNames:'' |
|
21 |
poolDictionaries:'' |
|
6912 | 22 |
category:'Kernel-Objects' |
6844 | 23 |
! |
24 |
||
25 |
!ProtoObject class methodsFor:'documentation'! |
|
26 |
||
8728 | 27 |
copyright |
28 |
" |
|
29 |
COPYRIGHT (c) 2004 by eXept Software AG |
|
30 |
All Rights Reserved |
|
31 |
||
32 |
This software is furnished under a license and may be used |
|
33 |
only in accordance with the terms of that license and with the |
|
34 |
inclusion of the above copyright notice. This software may not |
|
35 |
be provided or otherwise made available to, or used by, any |
|
36 |
other person. No title to or ownership of the software is |
|
37 |
hereby transferred. |
|
38 |
" |
|
39 |
! |
|
40 |
||
6844 | 41 |
documentation |
42 |
" |
|
43 |
a minimum object without much protocol; |
|
7659 | 44 |
Provides the minimum required to prevent inspectors from crashing, |
45 |
and debuggers from blocking. |
|
46 |
(i.e. instead of inheriting from nil, better inherit from this). |
|
47 |
||
6844 | 48 |
Named after a similar class found in Dolphin-Smalltalk. |
49 |
||
50 |
[author:] |
|
51 |
Claus Gittinger (not much authoring, though) |
|
52 |
" |
|
53 |
! ! |
|
54 |
||
55 |
!ProtoObject methodsFor:'error handling'! |
|
56 |
||
57 |
doesNotUnderstand:aMessage |
|
58 |
"this message is sent by the runtime system (VM) when |
|
59 |
a message is not understood by some object (i.e. there |
|
60 |
is no method for that selector). The original message has |
|
61 |
been packed into aMessage (i.e. the receiver, selector and |
|
62 |
any arguments) and the original receiver is then sent the |
|
63 |
#doesNotUnderstand: message. |
|
64 |
Here, we raise another signal which usually enters the debugger. |
|
65 |
You can of course redefine #doesNotUnderstand: in your classes |
|
66 |
to implement message delegation, |
|
8500
10d47cede03c
Speed up MessageNotUnderstood exception sending by layz computation
Stefan Vogel <sv@exept.de>
parents:
7661
diff
changeset
|
67 |
or handle the MessageNotUnderstood exception gracefully." |
6844 | 68 |
|
69 |
<context: #return> |
|
70 |
||
8500
10d47cede03c
Speed up MessageNotUnderstood exception sending by layz computation
Stefan Vogel <sv@exept.de>
parents:
7661
diff
changeset
|
71 |
^ MessageNotUnderstood raiseRequestWith:aMessage |
6844 | 72 |
! ! |
73 |
||
74 |
!ProtoObject methodsFor:'queries'! |
|
75 |
||
76 |
class |
|
77 |
"return the receivers class" |
|
78 |
||
79 |
%{ /* NOCONTEXT */ |
|
80 |
||
81 |
RETURN ( __Class(self) ); |
|
82 |
%} |
|
83 |
||
84 |
" |
|
85 |
*** WARNING |
|
86 |
*** |
|
87 |
*** this method has been automatically created, |
|
88 |
*** since all nil-subclasses should respond to some minimum required |
|
89 |
*** protocol. |
|
90 |
*** |
|
91 |
*** Inspection and/or debugging of instances may not be possible, |
|
92 |
*** if you remove/change this method. |
|
93 |
" |
|
10589 | 94 |
! |
95 |
||
96 |
identityHash |
|
97 |
"return an Integer useful as a hash key for the receiver. |
|
98 |
This hash should return same values for the same object (i.e. use |
|
99 |
this to hash on identity of objects). |
|
100 |
||
101 |
We cannot use the Objects address (as other smalltalks do) since |
|
102 |
no object-table exists and the hashval must not change when objects |
|
103 |
are moved by the collector. Therefore we assign each object a unique |
|
104 |
Id in the object header itself as its hashed upon. |
|
105 |
(luckily we have 11 bits spare to do this - unluckily its only 11 bits). |
|
106 |
Time will show, if 11 bits are enough; if not, another entry in the |
|
107 |
object header will be needed, adding 4 bytes to every object. Alternatively, |
|
108 |
hashed-upon objects could add an instvar containing the hash value." |
|
109 |
||
110 |
%{ /* NOCONTEXT */ |
|
111 |
||
112 |
REGISTER unsigned INT hash; |
|
113 |
static unsigned nextHash = 0; |
|
114 |
||
115 |
if (__isNonNilObject(self)) { |
|
116 |
hash = __GET_HASH(self); |
|
117 |
if (hash == 0) { |
|
118 |
/* has no hash yet */ |
|
119 |
||
120 |
if (++nextHash > __MAX_HASH__) { |
|
121 |
nextHash = 1; |
|
122 |
} |
|
123 |
hash = nextHash; |
|
124 |
__SET_HASH(self, hash); |
|
125 |
} |
|
126 |
||
127 |
/* |
|
128 |
* now, we got 11 bits for hashing; |
|
129 |
* make it as large as possible; since most hashers use the returned |
|
130 |
* key and take it modulo some prime number, this will allow for |
|
131 |
* better distribution (i.e. bigger empty spaces) in hashed collection. |
|
132 |
*/ |
|
133 |
hash = __MAKE_HASH__(hash); |
|
134 |
RETURN ( __mkSmallInteger(hash) ); |
|
135 |
} |
|
136 |
%}. |
|
137 |
^ 0 "never reached, since redefined in UndefinedObject and SmallInteger" |
|
138 |
||
139 |
"Created: / 31-05-2007 / 23:18:40 / cg" |
|
6844 | 140 |
! ! |
141 |
||
142 |
!ProtoObject methodsFor:'testing'! |
|
143 |
||
12571 | 144 |
ifNil:aBlock |
145 |
^ self |
|
146 |
! |
|
147 |
||
148 |
ifNotNil:aBlockOrValue |
|
16158 | 149 |
(aBlockOrValue isBlock and:[aBlockOrValue numArgs == 1]) ifTrue:[ |
150 |
^ aBlockOrValue value:self. |
|
151 |
]. |
|
12571 | 152 |
^ aBlockOrValue value |
153 |
! |
|
154 |
||
6844 | 155 |
isBehavior |
18351 | 156 |
"return true, if the receiver is describing another object's behavior. |
9222 | 157 |
False is returned here - the method is only redefined in Behavior." |
158 |
||
6844 | 159 |
^ false |
7661
71d2cac1b959
some tests aded to avoid trouble in debugger
Claus Gittinger <cg@exept.de>
parents:
7659
diff
changeset
|
160 |
! |
6844 | 161 |
|
7661
71d2cac1b959
some tests aded to avoid trouble in debugger
Claus Gittinger <cg@exept.de>
parents:
7659
diff
changeset
|
162 |
isBlock |
71d2cac1b959
some tests aded to avoid trouble in debugger
Claus Gittinger <cg@exept.de>
parents:
7659
diff
changeset
|
163 |
^ false |
7659 | 164 |
! |
165 |
||
166 |
isException |
|
167 |
^ false |
|
168 |
! |
|
169 |
||
170 |
isExceptionHandler |
|
171 |
^ false |
|
172 |
! |
|
173 |
||
174 |
isJavaObject |
|
175 |
^ false |
|
10589 | 176 |
! |
177 |
||
178 |
isLazyValue |
|
179 |
^ false |
|
180 |
||
181 |
"Created: / 03-06-2007 / 14:02:12 / cg" |
|
10591 | 182 |
! |
183 |
||
184 |
isLiteral |
|
185 |
^ false |
|
186 |
||
187 |
"Created: / 04-06-2007 / 17:19:10 / cg" |
|
6844 | 188 |
! ! |
189 |
||
190 |
!ProtoObject class methodsFor:'documentation'! |
|
191 |
||
192 |
version |
|
18351 | 193 |
^ '$Header: /cvs/stx/stx/libbasic/ProtoObject.st,v 1.15 2015-05-16 09:50:57 cg Exp $' |
12571 | 194 |
! |
195 |
||
196 |
version_CVS |
|
18351 | 197 |
^ '$Header: /cvs/stx/stx/libbasic/ProtoObject.st,v 1.15 2015-05-16 09:50:57 cg Exp $' |
6844 | 198 |
! ! |
16158 | 199 |