ProtoObject.st
author Claus Gittinger <cg@exept.de>
Tue, 26 Nov 2002 19:45:25 +0100
changeset 6912 d2e78827a065
parent 6911 2404dd9badab
child 7659 4def16a2e6e1
permissions -rw-r--r--
*** empty log message ***

"{ Package: 'stx:libbasic' }"

nil subclass:#ProtoObject
	instanceVariableNames:''
	classVariableNames:''
	poolDictionaries:''
	category:'Kernel-Objects'
!

!ProtoObject class methodsFor:'documentation'!

documentation
"
    a minimum object without much protocol;
    provides the minimum required to prevent inspectors from
    crashing.
    Named after a similar class found in Dolphin-Smalltalk.

    [author:]
        Claus Gittinger (not much authoring, though)
"
! !

!ProtoObject methodsFor:'error handling'!

doesNotUnderstand:aMessage
    "this message is sent by the runtime system (VM) when
     a message is not understood by some object (i.e. there
     is no method for that selector). The original message has
     been packed into aMessage (i.e. the receiver, selector and
     any arguments) and the original receiver is then sent the
     #doesNotUnderstand: message.
     Here, we raise another signal which usually enters the debugger.
     You can of course redefine #doesNotUnderstand: in your classes
     to implement message delegation, 
     or handle the MessageNotUnderstoodSignal gracefully."

    <context: #return>

    |sel selStr errorString cls|

    sel := aMessage selector.
    selStr := sel printString.

    "/ Although sel should always be a symbol,
    "/ always use printStrings in the code below.
    "/ Non-symbol selector may happen when things go mad in a primitive, 
    "/ or a method has been called by valueWithReceiver: with a wrong arg.

    "/ handle the case of an error during early startup
    "/ (output streams not yet initialized)

    Stdout isNil ifTrue:[
        Smalltalk fatalAbort:'error during init: ' , selStr , ' not understood'.
    ].

    "/
    "/ extract the class that should have implemented the message.
    "/ (in case of a super-send, this is not the receivers class)
    "/
    cls := thisContext sender searchClass.
    cls isNil ifTrue:[
        "it was NOT a super or directed send ..."
        cls := self class
    ].

    cls notNil ifTrue:[
        "/
        "/ displayString is better than 'cls name',
        "/ since it appends (obsolete) for outdated classes.
        "/ (this happens if you send messages to old instances
        "/  after changing a classes definition)
        "/
        errorString := cls displayString.
    ] ifFalse:[    
        errorString := '(** nil-class **)'
    ].
    sel class ~~ Symbol ifTrue:[
        errorString := errorString , ' nonSymbol selector: ' , selStr , ' not understood'.
    ] ifFalse:[
        errorString := errorString , ' does not understand: ' , selStr.
    ].

    "/
    "/ this only happens, when YOU play around with my classvars ...
    "/ (or an error occurs during very early startup, when signals are not yet set)
    "/
    MessageNotUnderstood isNil ifTrue:[
        ^ MiniDebugger 
            enterWithMessage:'oops - MessageNotUnderstoodSignal is gone (nil)'
            mayProceed:true.
    ].

    "/
    "/ thats where we end up normally - raise a signal which (if unhandled) opens a debugger
    "/
    ^ MessageNotUnderstood
                raiseRequestWith:aMessage
                errorString:errorString

    "Modified: / 9.6.1999 / 17:46:17 / cg"

"
*** WARNING
***
*** this method has been automatically created,
*** since all nil-subclasses should respond to some minimum required
*** protocol.
***
*** Inspection and/or debugging of instances may not be possible,
*** if you remove/change this method. 
"
! !

!ProtoObject methodsFor:'queries'!

class
    "return the receivers class"

%{  /* NOCONTEXT */

    RETURN ( __Class(self) );
%}

"
*** WARNING
***
*** this method has been automatically created,
*** since all nil-subclasses should respond to some minimum required
*** protocol.
***
*** Inspection and/or debugging of instances may not be possible,
*** if you remove/change this method. 
"
! !

!ProtoObject methodsFor:'testing'!

isBehavior
    "return true, if the receiver is some kind of class (i.e. behavior);
     false is returned here - the method is only redefined in Behavior."

    ^ false

"
*** WARNING
***
*** this method has been automatically created,
*** since all nil-subclasses should respond to some minimum required
*** protocol.
***
*** Inspection and/or debugging of instances may not be possible,
*** if you remove/change this method. 
"
! !

!ProtoObject class methodsFor:'documentation'!

version
    ^ '$Header: /cvs/stx/stx/libbasic/ProtoObject.st,v 1.5 2002-11-26 18:45:09 cg Exp $'
! !