author | Jan Vrany <jan.vrany@fit.cvut.cz> |
Thu, 01 Jul 2010 19:21:34 +0100 | |
branch | jv |
changeset 17772 | 6e0b3c06c364 |
parent 17767 | a4a32df3aa5e |
child 17780 | b6e42c92eba0 |
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 |
||
51 |
!ProtoObject methodsFor:'error handling'! |
|
52 |
||
53 |
doesNotUnderstand:aMessage |
|
54 |
"this message is sent by the runtime system (VM) when |
|
55 |
a message is not understood by some object (i.e. there |
|
56 |
is no method for that selector). The original message has |
|
57 |
been packed into aMessage (i.e. the receiver, selector and |
|
58 |
any arguments) and the original receiver is then sent the |
|
59 |
#doesNotUnderstand: message. |
|
60 |
Here, we raise another signal which usually enters the debugger. |
|
61 |
You can of course redefine #doesNotUnderstand: in your classes |
|
62 |
to implement message delegation, |
|
8500
10d47cede03c
Speed up MessageNotUnderstood exception sending by layz computation
Stefan Vogel <sv@exept.de>
parents:
7661
diff
changeset
|
63 |
or handle the MessageNotUnderstood exception gracefully." |
6844 | 64 |
|
65 |
<context: #return> |
|
66 |
||
8500
10d47cede03c
Speed up MessageNotUnderstood exception sending by layz computation
Stefan Vogel <sv@exept.de>
parents:
7661
diff
changeset
|
67 |
^ MessageNotUnderstood raiseRequestWith:aMessage |
6844 | 68 |
! ! |
69 |
||
70 |
!ProtoObject methodsFor:'queries'! |
|
71 |
||
72 |
class |
|
73 |
"return the receivers class" |
|
74 |
||
75 |
%{ /* NOCONTEXT */ |
|
76 |
||
77 |
RETURN ( __Class(self) ); |
|
78 |
%} |
|
79 |
||
80 |
" |
|
81 |
*** WARNING |
|
82 |
*** |
|
83 |
*** this method has been automatically created, |
|
84 |
*** since all nil-subclasses should respond to some minimum required |
|
85 |
*** protocol. |
|
86 |
*** |
|
87 |
*** Inspection and/or debugging of instances may not be possible, |
|
88 |
*** if you remove/change this method. |
|
89 |
" |
|
10589 | 90 |
! |
91 |
||
92 |
identityHash |
|
93 |
"return an Integer useful as a hash key for the receiver. |
|
94 |
This hash should return same values for the same object (i.e. use |
|
95 |
this to hash on identity of objects). |
|
96 |
||
97 |
We cannot use the Objects address (as other smalltalks do) since |
|
98 |
no object-table exists and the hashval must not change when objects |
|
99 |
are moved by the collector. Therefore we assign each object a unique |
|
100 |
Id in the object header itself as its hashed upon. |
|
101 |
(luckily we have 11 bits spare to do this - unluckily its only 11 bits). |
|
102 |
Time will show, if 11 bits are enough; if not, another entry in the |
|
103 |
object header will be needed, adding 4 bytes to every object. Alternatively, |
|
104 |
hashed-upon objects could add an instvar containing the hash value." |
|
105 |
||
106 |
%{ /* NOCONTEXT */ |
|
107 |
||
108 |
REGISTER unsigned INT hash; |
|
109 |
static unsigned nextHash = 0; |
|
110 |
||
111 |
if (__isNonNilObject(self)) { |
|
112 |
hash = __GET_HASH(self); |
|
113 |
if (hash == 0) { |
|
114 |
/* has no hash yet */ |
|
115 |
||
116 |
if (++nextHash > __MAX_HASH__) { |
|
117 |
nextHash = 1; |
|
118 |
} |
|
119 |
hash = nextHash; |
|
120 |
__SET_HASH(self, hash); |
|
121 |
} |
|
122 |
||
123 |
/* |
|
124 |
* now, we got 11 bits for hashing; |
|
125 |
* make it as large as possible; since most hashers use the returned |
|
126 |
* key and take it modulo some prime number, this will allow for |
|
127 |
* better distribution (i.e. bigger empty spaces) in hashed collection. |
|
128 |
*/ |
|
129 |
hash = __MAKE_HASH__(hash); |
|
130 |
RETURN ( __mkSmallInteger(hash) ); |
|
131 |
} |
|
132 |
%}. |
|
133 |
^ 0 "never reached, since redefined in UndefinedObject and SmallInteger" |
|
134 |
||
135 |
"Created: / 31-05-2007 / 23:18:40 / cg" |
|
6844 | 136 |
! ! |
137 |
||
138 |
!ProtoObject methodsFor:'testing'! |
|
139 |
||
17736 | 140 |
ifNil:aBlock |
141 |
^ self |
|
142 |
! |
|
143 |
||
144 |
ifNotNil:aBlockOrValue |
|
145 |
^ aBlockOrValue value |
|
146 |
! |
|
147 |
||
6844 | 148 |
isBehavior |
9222 | 149 |
"return true, if the receiver is describing another objects behavior. |
150 |
False is returned here - the method is only redefined in Behavior." |
|
151 |
||
6844 | 152 |
^ false |
7661
71d2cac1b959
some tests aded to avoid trouble in debugger
Claus Gittinger <cg@exept.de>
parents:
7659
diff
changeset
|
153 |
! |
6844 | 154 |
|
7661
71d2cac1b959
some tests aded to avoid trouble in debugger
Claus Gittinger <cg@exept.de>
parents:
7659
diff
changeset
|
155 |
isBlock |
71d2cac1b959
some tests aded to avoid trouble in debugger
Claus Gittinger <cg@exept.de>
parents:
7659
diff
changeset
|
156 |
^ false |
7659 | 157 |
! |
158 |
||
159 |
isException |
|
160 |
^ false |
|
161 |
! |
|
162 |
||
163 |
isExceptionHandler |
|
164 |
^ false |
|
165 |
! |
|
166 |
||
167 |
isJavaObject |
|
168 |
^ false |
|
10589 | 169 |
! |
170 |
||
171 |
isLazyValue |
|
172 |
^ false |
|
173 |
||
174 |
"Created: / 03-06-2007 / 14:02:12 / cg" |
|
10591 | 175 |
! |
176 |
||
177 |
isLiteral |
|
178 |
^ false |
|
179 |
||
180 |
"Created: / 04-06-2007 / 17:19:10 / cg" |
|
6844 | 181 |
! ! |
182 |
||
183 |
!ProtoObject class methodsFor:'documentation'! |
|
184 |
||
185 |
version |
|
17772
6e0b3c06c364
Method reverted to r10532
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
17767
diff
changeset
|
186 |
^ '$Id: ProtoObject.st 10534 2010-07-01 18:21:34Z vranyj1 $' |
17736 | 187 |
! |
188 |
||
189 |
version_CVS |
|
17772
6e0b3c06c364
Method reverted to r10532
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
17767
diff
changeset
|
190 |
^ 'Header: /cvs/stx/stx/libbasic/ProtoObject.st,v 1.13 2009/12/01 19:59:38 cg Exp ยง' |
17761
b0e5971141bc
Added Lookup and BuiltinLookup classes
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
17736
diff
changeset
|
191 |
! |
b0e5971141bc
Added Lookup and BuiltinLookup classes
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
17736
diff
changeset
|
192 |
|
b0e5971141bc
Added Lookup and BuiltinLookup classes
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
17736
diff
changeset
|
193 |
version_SVN |
17772
6e0b3c06c364
Method reverted to r10532
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
17767
diff
changeset
|
194 |
^ '$Id: ProtoObject.st 10534 2010-07-01 18:21:34Z vranyj1 $' |
6844 | 195 |
! ! |
17767 | 196 |
|
17772
6e0b3c06c364
Method reverted to r10532
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
17767
diff
changeset
|
197 |