6844
|
1 |
"{ Package: 'stx:libbasic' }"
|
|
2 |
|
|
3 |
nil subclass:#ProtoObject
|
|
4 |
instanceVariableNames:''
|
|
5 |
classVariableNames:''
|
|
6 |
poolDictionaries:''
|
6912
|
7 |
category:'Kernel-Objects'
|
6844
|
8 |
!
|
|
9 |
|
|
10 |
!ProtoObject class methodsFor:'documentation'!
|
|
11 |
|
|
12 |
documentation
|
|
13 |
"
|
|
14 |
a minimum object without much protocol;
|
|
15 |
provides the minimum required to prevent inspectors from
|
|
16 |
crashing.
|
|
17 |
Named after a similar class found in Dolphin-Smalltalk.
|
|
18 |
|
|
19 |
[author:]
|
|
20 |
Claus Gittinger (not much authoring, though)
|
|
21 |
"
|
|
22 |
! !
|
|
23 |
|
|
24 |
!ProtoObject methodsFor:'error handling'!
|
|
25 |
|
|
26 |
doesNotUnderstand:aMessage
|
|
27 |
"this message is sent by the runtime system (VM) when
|
|
28 |
a message is not understood by some object (i.e. there
|
|
29 |
is no method for that selector). The original message has
|
|
30 |
been packed into aMessage (i.e. the receiver, selector and
|
|
31 |
any arguments) and the original receiver is then sent the
|
|
32 |
#doesNotUnderstand: message.
|
|
33 |
Here, we raise another signal which usually enters the debugger.
|
|
34 |
You can of course redefine #doesNotUnderstand: in your classes
|
|
35 |
to implement message delegation,
|
|
36 |
or handle the MessageNotUnderstoodSignal gracefully."
|
|
37 |
|
|
38 |
<context: #return>
|
|
39 |
|
|
40 |
|sel selStr errorString cls|
|
|
41 |
|
|
42 |
sel := aMessage selector.
|
|
43 |
selStr := sel printString.
|
|
44 |
|
|
45 |
"/ Although sel should always be a symbol,
|
|
46 |
"/ always use printStrings in the code below.
|
|
47 |
"/ Non-symbol selector may happen when things go mad in a primitive,
|
|
48 |
"/ or a method has been called by valueWithReceiver: with a wrong arg.
|
|
49 |
|
|
50 |
"/ handle the case of an error during early startup
|
|
51 |
"/ (output streams not yet initialized)
|
|
52 |
|
|
53 |
Stdout isNil ifTrue:[
|
|
54 |
Smalltalk fatalAbort:'error during init: ' , selStr , ' not understood'.
|
|
55 |
].
|
|
56 |
|
|
57 |
"/
|
|
58 |
"/ extract the class that should have implemented the message.
|
|
59 |
"/ (in case of a super-send, this is not the receivers class)
|
|
60 |
"/
|
|
61 |
cls := thisContext sender searchClass.
|
|
62 |
cls isNil ifTrue:[
|
|
63 |
"it was NOT a super or directed send ..."
|
|
64 |
cls := self class
|
|
65 |
].
|
|
66 |
|
|
67 |
cls notNil ifTrue:[
|
|
68 |
"/
|
|
69 |
"/ displayString is better than 'cls name',
|
|
70 |
"/ since it appends (obsolete) for outdated classes.
|
|
71 |
"/ (this happens if you send messages to old instances
|
|
72 |
"/ after changing a classes definition)
|
|
73 |
"/
|
|
74 |
errorString := cls displayString.
|
|
75 |
] ifFalse:[
|
|
76 |
errorString := '(** nil-class **)'
|
|
77 |
].
|
|
78 |
sel class ~~ Symbol ifTrue:[
|
|
79 |
errorString := errorString , ' nonSymbol selector: ' , selStr , ' not understood'.
|
|
80 |
] ifFalse:[
|
|
81 |
errorString := errorString , ' does not understand: ' , selStr.
|
|
82 |
].
|
|
83 |
|
|
84 |
"/
|
|
85 |
"/ this only happens, when YOU play around with my classvars ...
|
|
86 |
"/ (or an error occurs during very early startup, when signals are not yet set)
|
|
87 |
"/
|
|
88 |
MessageNotUnderstood isNil ifTrue:[
|
|
89 |
^ MiniDebugger
|
|
90 |
enterWithMessage:'oops - MessageNotUnderstoodSignal is gone (nil)'
|
|
91 |
mayProceed:true.
|
|
92 |
].
|
|
93 |
|
|
94 |
"/
|
|
95 |
"/ thats where we end up normally - raise a signal which (if unhandled) opens a debugger
|
|
96 |
"/
|
|
97 |
^ MessageNotUnderstood
|
|
98 |
raiseRequestWith:aMessage
|
|
99 |
errorString:errorString
|
|
100 |
|
|
101 |
"Modified: / 9.6.1999 / 17:46:17 / cg"
|
|
102 |
|
|
103 |
"
|
|
104 |
*** WARNING
|
|
105 |
***
|
|
106 |
*** this method has been automatically created,
|
|
107 |
*** since all nil-subclasses should respond to some minimum required
|
|
108 |
*** protocol.
|
|
109 |
***
|
|
110 |
*** Inspection and/or debugging of instances may not be possible,
|
|
111 |
*** if you remove/change this method.
|
|
112 |
"
|
|
113 |
! !
|
|
114 |
|
|
115 |
!ProtoObject methodsFor:'queries'!
|
|
116 |
|
|
117 |
class
|
|
118 |
"return the receivers class"
|
|
119 |
|
|
120 |
%{ /* NOCONTEXT */
|
|
121 |
|
|
122 |
RETURN ( __Class(self) );
|
|
123 |
%}
|
|
124 |
|
|
125 |
"
|
|
126 |
*** WARNING
|
|
127 |
***
|
|
128 |
*** this method has been automatically created,
|
|
129 |
*** since all nil-subclasses should respond to some minimum required
|
|
130 |
*** protocol.
|
|
131 |
***
|
|
132 |
*** Inspection and/or debugging of instances may not be possible,
|
|
133 |
*** if you remove/change this method.
|
|
134 |
"
|
|
135 |
! !
|
|
136 |
|
|
137 |
!ProtoObject methodsFor:'testing'!
|
|
138 |
|
|
139 |
isBehavior
|
|
140 |
"return true, if the receiver is some kind of class (i.e. behavior);
|
|
141 |
false is returned here - the method is only redefined in Behavior."
|
|
142 |
|
|
143 |
^ false
|
|
144 |
|
|
145 |
"
|
|
146 |
*** WARNING
|
|
147 |
***
|
|
148 |
*** this method has been automatically created,
|
|
149 |
*** since all nil-subclasses should respond to some minimum required
|
|
150 |
*** protocol.
|
|
151 |
***
|
|
152 |
*** Inspection and/or debugging of instances may not be possible,
|
|
153 |
*** if you remove/change this method.
|
|
154 |
"
|
|
155 |
! !
|
|
156 |
|
|
157 |
!ProtoObject class methodsFor:'documentation'!
|
|
158 |
|
|
159 |
version
|
6912
|
160 |
^ '$Header: /cvs/stx/stx/libbasic/ProtoObject.st,v 1.5 2002-11-26 18:45:09 cg Exp $'
|
6844
|
161 |
! !
|