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