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