author | Claus Gittinger <cg@exept.de> |
Mon, 01 Oct 2001 23:00:30 +0200 | |
changeset 6062 | c8b8b9d382f1 |
parent 5751 | ceba525a9c2a |
child 6253 | 15f294576641 |
permissions | -rw-r--r-- |
1 | 1 |
" |
5 | 2 |
COPYRIGHT (c) 1988 by Claus Gittinger |
362 | 3 |
All Rights Reserved |
1 | 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 |
" |
|
12 |
||
5591 | 13 |
"{ Package: 'stx:libbasic' }" |
14 |
||
1 | 15 |
Object subclass:#Message |
1183
e3d58d115e53
subclasses of fixed classes are still possible
Claus Gittinger <cg@exept.de>
parents:
530
diff
changeset
|
16 |
instanceVariableNames:'selector args' |
e3d58d115e53
subclasses of fixed classes are still possible
Claus Gittinger <cg@exept.de>
parents:
530
diff
changeset
|
17 |
classVariableNames:'' |
e3d58d115e53
subclasses of fixed classes are still possible
Claus Gittinger <cg@exept.de>
parents:
530
diff
changeset
|
18 |
poolDictionaries:'' |
e3d58d115e53
subclasses of fixed classes are still possible
Claus Gittinger <cg@exept.de>
parents:
530
diff
changeset
|
19 |
category:'Kernel-Methods' |
1 | 20 |
! |
21 |
||
88 | 22 |
!Message class methodsFor:'documentation'! |
23 |
||
24 |
copyright |
|
25 |
" |
|
26 |
COPYRIGHT (c) 1988 by Claus Gittinger |
|
362 | 27 |
All Rights Reserved |
1 | 28 |
|
88 | 29 |
This software is furnished under a license and may be used |
30 |
only in accordance with the terms of that license and with the |
|
31 |
inclusion of the above copyright notice. This software may not |
|
32 |
be provided or otherwise made available to, or used by, any |
|
33 |
other person. No title to or ownership of the software is |
|
34 |
hereby transferred. |
|
35 |
" |
|
36 |
! |
|
1 | 37 |
|
88 | 38 |
documentation |
39 |
" |
|
1268 | 40 |
Instances of Message represent a message being sent. |
41 |
During normal execution, message objects are NEVER used - |
|
42 |
instead, argument passing is done more performant via the stack |
|
43 |
or in registers (depends on how your C compiler passes arguments). |
|
44 |
||
45 |
However, messageObjects ARE created, when a message send fails |
|
88 | 46 |
(i.e. some message is not understood). |
1268 | 47 |
In this case, the selector and arguments of the failing messare |
48 |
are squashed into a new instance of Message, and a #doesNotUnderstand: |
|
49 |
message is sent to the original receiver, passing the message object |
|
50 |
as argument. |
|
88 | 51 |
|
1268 | 52 |
Typically, #doesNotUnderstand: is not redefined in the receivers class, |
53 |
therefore Object>>doesNotUnderstand: gets evaluated. |
|
54 |
There, a debugger is opened and the thread is suspended. |
|
55 |
However, it is possible to redefine this method, which |
|
56 |
allows for re-evaluation of the failed send (after some cleanup), |
|
57 |
to upload some code or to simply ignore the error. |
|
93 | 58 |
|
59 |
As an example of its use, see the implementation of the Autoload-class, |
|
60 |
or how ScrollableView forwards unknown messages to its slave-view. |
|
61 |
||
1268 | 62 |
Elegance hint: actually, Object>>doesNotUnderstand: raises an exception |
63 |
which can be handled - in most situations, providing an exception handler |
|
64 |
instead of redefining #doesNotUnderstand is the better way to do things. |
|
65 |
||
66 |
||
93 | 67 |
Notice: |
1268 | 68 |
Since the layout of Message-objects is known by the runtime system |
69 |
(it has to create those objects in case of a failure) |
|
70 |
it is not allowed to change the definition of this class. |
|
71 |
||
72 |
[See also:] |
|
73 |
Signal Exception MessageSend |
|
1293 | 74 |
|
75 |
[author:] |
|
76 |
Claus Gittinger |
|
88 | 77 |
" |
78 |
! ! |
|
1 | 79 |
|
80 |
!Message class methodsFor:'instance creation'! |
|
81 |
||
82 |
selector:aSymbol |
|
83 |
"return a new message object for a send without arguments" |
|
84 |
||
159 | 85 |
^ self basicNew setSelector:aSymbol arguments:nil |
1 | 86 |
! |
87 |
||
1183
e3d58d115e53
subclasses of fixed classes are still possible
Claus Gittinger <cg@exept.de>
parents:
530
diff
changeset
|
88 |
selector:aSymbol argument:anArg |
e3d58d115e53
subclasses of fixed classes are still possible
Claus Gittinger <cg@exept.de>
parents:
530
diff
changeset
|
89 |
"return a new message object for a send with one argument" |
e3d58d115e53
subclasses of fixed classes are still possible
Claus Gittinger <cg@exept.de>
parents:
530
diff
changeset
|
90 |
|
e3d58d115e53
subclasses of fixed classes are still possible
Claus Gittinger <cg@exept.de>
parents:
530
diff
changeset
|
91 |
^ self basicNew setSelector:aSymbol arguments:(Array with:anArg) |
e3d58d115e53
subclasses of fixed classes are still possible
Claus Gittinger <cg@exept.de>
parents:
530
diff
changeset
|
92 |
! |
e3d58d115e53
subclasses of fixed classes are still possible
Claus Gittinger <cg@exept.de>
parents:
530
diff
changeset
|
93 |
|
5751 | 94 |
selector:aSymbol argument:arg1 argument:arg2 |
95 |
"return a new message object for a send with two arguments" |
|
96 |
||
97 |
^ self basicNew setSelector:aSymbol arguments:(Array with:arg1 with:arg2) |
|
98 |
! |
|
99 |
||
1183
e3d58d115e53
subclasses of fixed classes are still possible
Claus Gittinger <cg@exept.de>
parents:
530
diff
changeset
|
100 |
selector:aSymbol arguments:argArray |
e3d58d115e53
subclasses of fixed classes are still possible
Claus Gittinger <cg@exept.de>
parents:
530
diff
changeset
|
101 |
"return a new message object for a send with many arguments" |
e3d58d115e53
subclasses of fixed classes are still possible
Claus Gittinger <cg@exept.de>
parents:
530
diff
changeset
|
102 |
|
e3d58d115e53
subclasses of fixed classes are still possible
Claus Gittinger <cg@exept.de>
parents:
530
diff
changeset
|
103 |
^ self basicNew setSelector:aSymbol arguments:argArray |
e3d58d115e53
subclasses of fixed classes are still possible
Claus Gittinger <cg@exept.de>
parents:
530
diff
changeset
|
104 |
! |
e3d58d115e53
subclasses of fixed classes are still possible
Claus Gittinger <cg@exept.de>
parents:
530
diff
changeset
|
105 |
|
1 | 106 |
selector:aSymbol with:anArg |
159 | 107 |
"return a new message object for a send with one argument. |
108 |
OBSOLETE: use #selector:argument: for ST-80 compatibility." |
|
1 | 109 |
|
159 | 110 |
^ self basicNew setSelector:aSymbol arguments:(Array with:anArg) |
1 | 111 |
! |
112 |
||
113 |
selector:aSymbol with:arg1 with:arg2 |
|
159 | 114 |
"return a new message object for a send with two arguments. |
115 |
OBSOLETE: use #selector:arguments: for ST-80 compatibility." |
|
1 | 116 |
|
159 | 117 |
^ self basicNew setSelector:aSymbol arguments:(Array with:arg1 with:arg2) |
1 | 118 |
! |
119 |
||
120 |
selector:aSymbol withAll:argArray |
|
93 | 121 |
"return a new message object for a send with many arguments. |
159 | 122 |
OBSOLETE: use #selector:arguments: for ST-80 compatibilty." |
123 |
||
124 |
^ self basicNew setSelector:aSymbol arguments:argArray |
|
93 | 125 |
! ! |
126 |
||
127 |
!Message class methodsFor:'queries'! |
|
128 |
||
129 |
isBuiltInClass |
|
1264 | 130 |
"return true if this class is known by the run-time-system. |
131 |
Here, true is returned for myself, false for subclasses." |
|
93 | 132 |
|
133 |
^ self == Message |
|
1264 | 134 |
|
135 |
"Modified: 23.4.1996 / 15:59:30 / cg" |
|
1 | 136 |
! ! |
137 |
||
1183
e3d58d115e53
subclasses of fixed classes are still possible
Claus Gittinger <cg@exept.de>
parents:
530
diff
changeset
|
138 |
!Message methodsFor:'accessing'! |
10 | 139 |
|
1183
e3d58d115e53
subclasses of fixed classes are still possible
Claus Gittinger <cg@exept.de>
parents:
530
diff
changeset
|
140 |
arguments |
e3d58d115e53
subclasses of fixed classes are still possible
Claus Gittinger <cg@exept.de>
parents:
530
diff
changeset
|
141 |
"return the arguments of the message" |
85 | 142 |
|
6062
c8b8b9d382f1
always return a colelction from #arguments.
Claus Gittinger <cg@exept.de>
parents:
5751
diff
changeset
|
143 |
^ args ? #() |
1183
e3d58d115e53
subclasses of fixed classes are still possible
Claus Gittinger <cg@exept.de>
parents:
530
diff
changeset
|
144 |
! |
1 | 145 |
|
146 |
selector |
|
147 |
"return the selector of the message" |
|
148 |
||
149 |
^ selector |
|
150 |
! ! |
|
151 |
||
93 | 152 |
!Message methodsFor:'printing & storing'! |
1 | 153 |
|
56 | 154 |
displayString |
155 |
"return a string for display in inspectors etc." |
|
156 |
||
5591 | 157 |
^ self class name , '(' , selector printString , ')' |
1833 | 158 |
|
159 |
"Modified: 28.10.1996 / 17:04:29 / cg" |
|
56 | 160 |
! |
161 |
||
162 |
printOn:aStream |
|
4392 | 163 |
"append a user printed representation of the receiver to aStream. |
164 |
The format is suitable for a human - not meant to be read back." |
|
1 | 165 |
|
56 | 166 |
selector printOn:aStream |
1 | 167 |
! ! |
1183
e3d58d115e53
subclasses of fixed classes are still possible
Claus Gittinger <cg@exept.de>
parents:
530
diff
changeset
|
168 |
|
e3d58d115e53
subclasses of fixed classes are still possible
Claus Gittinger <cg@exept.de>
parents:
530
diff
changeset
|
169 |
!Message methodsFor:'private accessing'! |
e3d58d115e53
subclasses of fixed classes are still possible
Claus Gittinger <cg@exept.de>
parents:
530
diff
changeset
|
170 |
|
e3d58d115e53
subclasses of fixed classes are still possible
Claus Gittinger <cg@exept.de>
parents:
530
diff
changeset
|
171 |
setSelector:aSymbol arguments:argArray |
e3d58d115e53
subclasses of fixed classes are still possible
Claus Gittinger <cg@exept.de>
parents:
530
diff
changeset
|
172 |
"set selector and arguments of the receiver" |
e3d58d115e53
subclasses of fixed classes are still possible
Claus Gittinger <cg@exept.de>
parents:
530
diff
changeset
|
173 |
|
e3d58d115e53
subclasses of fixed classes are still possible
Claus Gittinger <cg@exept.de>
parents:
530
diff
changeset
|
174 |
selector := aSymbol. |
e3d58d115e53
subclasses of fixed classes are still possible
Claus Gittinger <cg@exept.de>
parents:
530
diff
changeset
|
175 |
args := argArray |
e3d58d115e53
subclasses of fixed classes are still possible
Claus Gittinger <cg@exept.de>
parents:
530
diff
changeset
|
176 |
! ! |
e3d58d115e53
subclasses of fixed classes are still possible
Claus Gittinger <cg@exept.de>
parents:
530
diff
changeset
|
177 |
|
e3d58d115e53
subclasses of fixed classes are still possible
Claus Gittinger <cg@exept.de>
parents:
530
diff
changeset
|
178 |
!Message methodsFor:'sending'! |
e3d58d115e53
subclasses of fixed classes are still possible
Claus Gittinger <cg@exept.de>
parents:
530
diff
changeset
|
179 |
|
e3d58d115e53
subclasses of fixed classes are still possible
Claus Gittinger <cg@exept.de>
parents:
530
diff
changeset
|
180 |
reinvokeFor:aReceiver |
e3d58d115e53
subclasses of fixed classes are still possible
Claus Gittinger <cg@exept.de>
parents:
530
diff
changeset
|
181 |
"send the selector with argument to a receiver. |
e3d58d115e53
subclasses of fixed classes are still possible
Claus Gittinger <cg@exept.de>
parents:
530
diff
changeset
|
182 |
Same as sendTo: - for GNU-ST compatibility." |
e3d58d115e53
subclasses of fixed classes are still possible
Claus Gittinger <cg@exept.de>
parents:
530
diff
changeset
|
183 |
|
e3d58d115e53
subclasses of fixed classes are still possible
Claus Gittinger <cg@exept.de>
parents:
530
diff
changeset
|
184 |
^ self sendTo:aReceiver |
e3d58d115e53
subclasses of fixed classes are still possible
Claus Gittinger <cg@exept.de>
parents:
530
diff
changeset
|
185 |
! |
e3d58d115e53
subclasses of fixed classes are still possible
Claus Gittinger <cg@exept.de>
parents:
530
diff
changeset
|
186 |
|
e3d58d115e53
subclasses of fixed classes are still possible
Claus Gittinger <cg@exept.de>
parents:
530
diff
changeset
|
187 |
sendTo:aReceiver |
e3d58d115e53
subclasses of fixed classes are still possible
Claus Gittinger <cg@exept.de>
parents:
530
diff
changeset
|
188 |
"send the selector with argument to some receiver" |
e3d58d115e53
subclasses of fixed classes are still possible
Claus Gittinger <cg@exept.de>
parents:
530
diff
changeset
|
189 |
|
e3d58d115e53
subclasses of fixed classes are still possible
Claus Gittinger <cg@exept.de>
parents:
530
diff
changeset
|
190 |
^ aReceiver perform:selector withArguments:args |
e3d58d115e53
subclasses of fixed classes are still possible
Claus Gittinger <cg@exept.de>
parents:
530
diff
changeset
|
191 |
! ! |
e3d58d115e53
subclasses of fixed classes are still possible
Claus Gittinger <cg@exept.de>
parents:
530
diff
changeset
|
192 |
|
e3d58d115e53
subclasses of fixed classes are still possible
Claus Gittinger <cg@exept.de>
parents:
530
diff
changeset
|
193 |
!Message class methodsFor:'documentation'! |
e3d58d115e53
subclasses of fixed classes are still possible
Claus Gittinger <cg@exept.de>
parents:
530
diff
changeset
|
194 |
|
e3d58d115e53
subclasses of fixed classes are still possible
Claus Gittinger <cg@exept.de>
parents:
530
diff
changeset
|
195 |
version |
6062
c8b8b9d382f1
always return a colelction from #arguments.
Claus Gittinger <cg@exept.de>
parents:
5751
diff
changeset
|
196 |
^ '$Header: /cvs/stx/stx/libbasic/Message.st,v 1.24 2001-10-01 21:00:30 cg Exp $' |
1183
e3d58d115e53
subclasses of fixed classes are still possible
Claus Gittinger <cg@exept.de>
parents:
530
diff
changeset
|
197 |
! ! |