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