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
|
|
14 |
instanceVariableNames:'selector args'
|
|
15 |
classVariableNames:''
|
|
16 |
poolDictionaries:''
|
|
17 |
category:'Kernel-Methods'
|
|
18 |
!
|
|
19 |
|
|
20 |
Message comment:'
|
88
|
21 |
COPYRIGHT (c) 1988 by Claus Gittinger
|
362
|
22 |
All Rights Reserved
|
93
|
23 |
|
384
|
24 |
$Header: /cvs/stx/stx/libbasic/Message.st,v 1.14 1995-08-11 03:01:45 claus Exp $
|
88
|
25 |
'!
|
1
|
26 |
|
88
|
27 |
!Message class methodsFor:'documentation'!
|
|
28 |
|
|
29 |
copyright
|
|
30 |
"
|
|
31 |
COPYRIGHT (c) 1988 by Claus Gittinger
|
362
|
32 |
All Rights Reserved
|
1
|
33 |
|
88
|
34 |
This software is furnished under a license and may be used
|
|
35 |
only in accordance with the terms of that license and with the
|
|
36 |
inclusion of the above copyright notice. This software may not
|
|
37 |
be provided or otherwise made available to, or used by, any
|
|
38 |
other person. No title to or ownership of the software is
|
|
39 |
hereby transferred.
|
|
40 |
"
|
|
41 |
!
|
1
|
42 |
|
88
|
43 |
version
|
|
44 |
"
|
384
|
45 |
$Header: /cvs/stx/stx/libbasic/Message.st,v 1.14 1995-08-11 03:01:45 claus Exp $
|
88
|
46 |
"
|
|
47 |
!
|
1
|
48 |
|
88
|
49 |
documentation
|
|
50 |
"
|
|
51 |
Instances of Message are only created, when a message send fails
|
|
52 |
(i.e. some message is not understood).
|
|
53 |
In this case, the selector and arguments are put into an instance of
|
|
54 |
Message, which is then passed to #doesNotUnderstand: as argument.
|
|
55 |
|
93
|
56 |
Typically, Object>>doesNotUnderstand: is evaluated, which starts up
|
|
57 |
a debugger, but it is possible to redefine this method, which
|
|
58 |
allows for re-evaluation of the failed send (after some cleanup).
|
|
59 |
|
|
60 |
As an example of its use, see the implementation of the Autoload-class,
|
|
61 |
or how ScrollableView forwards unknown messages to its slave-view.
|
|
62 |
|
|
63 |
Notice:
|
|
64 |
Since the layout of Message-objects is known by the runtime system, it is
|
|
65 |
not allowed to change the definition of this class.
|
88
|
66 |
"
|
|
67 |
! !
|
1
|
68 |
|
|
69 |
!Message class methodsFor:'instance creation'!
|
|
70 |
|
|
71 |
selector:aSymbol
|
|
72 |
"return a new message object for a send without arguments"
|
|
73 |
|
159
|
74 |
^ self basicNew setSelector:aSymbol arguments:nil
|
1
|
75 |
!
|
|
76 |
|
|
77 |
selector:aSymbol with:anArg
|
159
|
78 |
"return a new message object for a send with one argument.
|
|
79 |
OBSOLETE: use #selector:argument: for ST-80 compatibility."
|
1
|
80 |
|
159
|
81 |
^ self basicNew setSelector:aSymbol arguments:(Array with:anArg)
|
1
|
82 |
!
|
|
83 |
|
|
84 |
selector:aSymbol with:arg1 with:arg2
|
159
|
85 |
"return a new message object for a send with two arguments.
|
|
86 |
OBSOLETE: use #selector:arguments: for ST-80 compatibility."
|
1
|
87 |
|
159
|
88 |
^ self basicNew setSelector:aSymbol arguments:(Array with:arg1 with:arg2)
|
1
|
89 |
!
|
|
90 |
|
|
91 |
selector:aSymbol withAll:argArray
|
93
|
92 |
"return a new message object for a send with many arguments.
|
159
|
93 |
OBSOLETE: use #selector:arguments: for ST-80 compatibilty."
|
|
94 |
|
|
95 |
^ self basicNew setSelector:aSymbol arguments:argArray
|
|
96 |
!
|
93
|
97 |
|
159
|
98 |
selector:aSymbol argument:anArg
|
|
99 |
"return a new message object for a send with one argument"
|
|
100 |
|
|
101 |
^ self basicNew setSelector:aSymbol arguments:(Array with:anArg)
|
93
|
102 |
!
|
|
103 |
|
|
104 |
selector:aSymbol arguments:argArray
|
1
|
105 |
"return a new message object for a send with many arguments"
|
|
106 |
|
159
|
107 |
^ self basicNew setSelector:aSymbol arguments:argArray
|
93
|
108 |
! !
|
|
109 |
|
|
110 |
!Message class methodsFor:'queries'!
|
|
111 |
|
|
112 |
isBuiltInClass
|
|
113 |
"this class is known by the run-time-system"
|
|
114 |
|
|
115 |
^ self == Message
|
1
|
116 |
! !
|
|
117 |
|
|
118 |
!Message methodsFor:'private accessing'!
|
|
119 |
|
159
|
120 |
setSelector:aSymbol arguments:argArray
|
1
|
121 |
"set selector and arguments of the receiver"
|
|
122 |
|
|
123 |
selector := aSymbol.
|
|
124 |
args := argArray
|
|
125 |
! !
|
|
126 |
|
10
|
127 |
!Message methodsFor:'sending'!
|
|
128 |
|
|
129 |
sendTo:aReceiver
|
152
|
130 |
"send the selector with argument to some receiver"
|
10
|
131 |
|
152
|
132 |
^ aReceiver perform:selector withArguments:args
|
85
|
133 |
!
|
|
134 |
|
362
|
135 |
reinvokeFor:aReceiver
|
85
|
136 |
"send the selector with argument to a receiver.
|
|
137 |
Same as sendTo: - for GNU-ST compatibility."
|
93
|
138 |
|
85
|
139 |
^ self sendTo:aReceiver
|
10
|
140 |
! !
|
|
141 |
|
1
|
142 |
!Message methodsFor:'accessing'!
|
|
143 |
|
|
144 |
selector
|
|
145 |
"return the selector of the message"
|
|
146 |
|
|
147 |
^ selector
|
|
148 |
!
|
|
149 |
|
|
150 |
arguments
|
|
151 |
"return the arguments of the message"
|
|
152 |
|
|
153 |
^ args
|
|
154 |
! !
|
|
155 |
|
93
|
156 |
!Message methodsFor:'printing & storing'!
|
1
|
157 |
|
56
|
158 |
displayString
|
|
159 |
"return a string for display in inspectors etc."
|
|
160 |
|
|
161 |
^ 'Message(' , selector , ')'
|
|
162 |
!
|
|
163 |
|
|
164 |
printOn:aStream
|
1
|
165 |
"return a string for printing the receiver"
|
|
166 |
|
56
|
167 |
selector printOn:aStream
|
1
|
168 |
! !
|