Message.st
author Claus Gittinger <cg@exept.de>
Tue, 16 Apr 1996 11:29:01 +0200
changeset 1183 e3d58d115e53
parent 530 07d0bce293c9
child 1264 8d916aa63bce
permissions -rw-r--r--
subclasses of fixed classes are still possible

"
 COPYRIGHT (c) 1988 by Claus Gittinger
	      All Rights Reserved

 This software is furnished under a license and may be used
 only in accordance with the terms of that license and with the
 inclusion of the above copyright notice.   This software may not
 be provided or otherwise made available to, or used by, any
 other person.  No title to or ownership of the software is
 hereby transferred.
"

Object subclass:#Message
	instanceVariableNames:'selector args'
	classVariableNames:''
	poolDictionaries:''
	category:'Kernel-Methods'
!

!Message class methodsFor:'documentation'!

copyright
"
 COPYRIGHT (c) 1988 by Claus Gittinger
	      All Rights Reserved

 This software is furnished under a license and may be used
 only in accordance with the terms of that license and with the
 inclusion of the above copyright notice.   This software may not
 be provided or otherwise made available to, or used by, any
 other person.  No title to or ownership of the software is
 hereby transferred.
"
!

documentation
"
    Instances of Message are only created, when a message send fails 
    (i.e. some message is not understood).
    In this case, the selector and arguments are put into an instance of 
    Message, which is then passed to #doesNotUnderstand: as argument.

    Typically, Object>>doesNotUnderstand: is evaluated, which starts up
    a debugger, but it is possible to redefine this method, which
    allows for re-evaluation of the failed send (after some cleanup).

    As an example of its use, see the implementation of the Autoload-class,
    or how ScrollableView forwards unknown messages to its slave-view.

    Notice:
    Since the layout of Message-objects is known by the runtime system, it is 
    not allowed to change the definition of this class.
"
! !

!Message class methodsFor:'instance creation'!

selector:aSymbol
    "return a new message object for a send without arguments"

    ^ self basicNew setSelector:aSymbol arguments:nil
!

selector:aSymbol argument:anArg
    "return a new message object for a send with one argument"

    ^ self basicNew setSelector:aSymbol arguments:(Array with:anArg)
!

selector:aSymbol arguments:argArray
    "return a new message object for a send with many arguments"

    ^ self basicNew setSelector:aSymbol arguments:argArray
!

selector:aSymbol with:anArg
    "return a new message object for a send with one argument.
     OBSOLETE: use #selector:argument: for ST-80 compatibility."

    ^ self basicNew setSelector:aSymbol arguments:(Array with:anArg)
!

selector:aSymbol with:arg1 with:arg2
    "return a new message object for a send with two arguments.
     OBSOLETE: use #selector:arguments: for ST-80 compatibility."

    ^ self basicNew setSelector:aSymbol arguments:(Array with:arg1 with:arg2)
!

selector:aSymbol withAll:argArray
    "return a new message object for a send with many arguments.
     OBSOLETE: use #selector:arguments: for ST-80 compatibilty."

    ^ self basicNew setSelector:aSymbol arguments:argArray
! !

!Message class methodsFor:'queries'!

isBuiltInClass
    "this class is known by the run-time-system"

    ^ self == Message
! !

!Message methodsFor:'accessing'!

arguments
    "return the arguments of the message"

    ^ args
!

selector
    "return the selector of the message"

    ^ selector
! !

!Message methodsFor:'printing & storing'!

displayString
    "return a string for display in inspectors etc."

    ^ 'Message(' , selector , ')'
!

printOn:aStream
    "return a string for printing the receiver"

    selector printOn:aStream
! !

!Message methodsFor:'private accessing'!

setSelector:aSymbol arguments:argArray
    "set selector and arguments of the receiver"

    selector := aSymbol.
    args := argArray
! !

!Message methodsFor:'sending'!

reinvokeFor:aReceiver
    "send the selector with argument to a receiver.
     Same as sendTo: - for GNU-ST compatibility."

    ^ self sendTo:aReceiver
!

sendTo:aReceiver
    "send the selector with argument to some receiver"

    ^ aReceiver perform:selector withArguments:args
! !

!Message class methodsFor:'documentation'!

version
    ^ '$Header: /cvs/stx/stx/libbasic/Message.st,v 1.16 1996-04-16 09:29:01 cg Exp $'
! !