1
|
1 |
"
|
5
|
2 |
COPYRIGHT (c) 1988 by Claus Gittinger
|
1
|
3 |
All Rights Reserved
|
|
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:'
|
|
21 |
|
5
|
22 |
COPYRIGHT (c) 1988 by Claus Gittinger
|
1
|
23 |
All Rights Reserved
|
|
24 |
|
|
25 |
these are only created, when a message fails (i.e. is not understood) -
|
|
26 |
the selector and arguments are put into an instance of Message, which is then
|
|
27 |
passed to doesNotUnderstand:aMessage as argument.
|
|
28 |
|
|
29 |
This allows for re-evaluation of the failed send (after some cleanup).
|
|
30 |
As an example of its use, see the implementation of the Autoload-class.
|
|
31 |
|
56
|
32 |
$Header: /cvs/stx/stx/libbasic/Message.st,v 1.6 1994-02-25 13:00:38 claus Exp $
|
1
|
33 |
'!
|
|
34 |
|
|
35 |
!Message class methodsFor:'instance creation'!
|
|
36 |
|
|
37 |
selector:aSymbol
|
|
38 |
"return a new message object for a send without arguments"
|
|
39 |
|
|
40 |
^ self basicNew selector:aSymbol
|
|
41 |
arguments:nil
|
|
42 |
!
|
|
43 |
|
|
44 |
selector:aSymbol with:anArg
|
|
45 |
"return a new message object for a send with one argument"
|
|
46 |
|
|
47 |
^ self basicNew selector:aSymbol
|
|
48 |
arguments:(Array with:anArg)
|
|
49 |
!
|
|
50 |
|
|
51 |
selector:aSymbol with:arg1 with:arg2
|
|
52 |
"return a new message object for a send with two arguments"
|
|
53 |
|
|
54 |
^ self basicNew selector:aSymbol
|
|
55 |
arguments:(Array with:arg1 with:arg2)
|
|
56 |
!
|
|
57 |
|
|
58 |
selector:aSymbol withAll:argArray
|
|
59 |
"return a new message object for a send with many arguments"
|
|
60 |
|
|
61 |
^ self basicNew selector:aSymbol
|
|
62 |
arguments:argArray
|
|
63 |
! !
|
|
64 |
|
|
65 |
!Message methodsFor:'private accessing'!
|
|
66 |
|
|
67 |
selector:aSymbol arguments:argArray
|
|
68 |
"set selector and arguments of the receiver"
|
|
69 |
|
|
70 |
selector := aSymbol.
|
|
71 |
args := argArray
|
|
72 |
! !
|
|
73 |
|
10
|
74 |
!Message methodsFor:'sending'!
|
|
75 |
|
|
76 |
sendTo:aReceiver
|
|
77 |
"send the selector with argument to a receiver"
|
|
78 |
|
|
79 |
aReceiver perform:selector withArguments:args
|
|
80 |
! !
|
|
81 |
|
1
|
82 |
!Message methodsFor:'accessing'!
|
|
83 |
|
|
84 |
selector
|
|
85 |
"return the selector of the message"
|
|
86 |
|
|
87 |
^ selector
|
|
88 |
!
|
|
89 |
|
|
90 |
arguments
|
|
91 |
"return the arguments of the message"
|
|
92 |
|
|
93 |
^ args
|
|
94 |
! !
|
|
95 |
|
|
96 |
!Message methodsFor:'printing'!
|
|
97 |
|
56
|
98 |
displayString
|
|
99 |
"return a string for display in inspectors etc."
|
|
100 |
|
|
101 |
^ 'Message(' , selector , ')'
|
|
102 |
!
|
|
103 |
|
|
104 |
printOn:aStream
|
1
|
105 |
"return a string for printing the receiver"
|
|
106 |
|
56
|
107 |
selector printOn:aStream
|
1
|
108 |
! !
|