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