Signal.st
author Claus Gittinger <cg@exept.de>
Fri, 26 Jul 1996 16:44:57 +0200
changeset 1610 2c076ee64e11
parent 1608 440faca45e37
child 2207 ee6d4213b9df
permissions -rw-r--r--
added #raiseErrorString:in:
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
1
a27a279701f8 Initial revision
claus
parents:
diff changeset
     1
"
a27a279701f8 Initial revision
claus
parents:
diff changeset
     2
 COPYRIGHT (c) 1993 by Claus Gittinger
159
514c749165c3 *** empty log message ***
claus
parents: 145
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:#Signal
1249
2d5d0edd3359 commentary
Claus Gittinger <cg@exept.de>
parents: 854
diff changeset
    14
	instanceVariableNames:'mayProceed notifierString nameClass message handlerBlock parent'
2d5d0edd3359 commentary
Claus Gittinger <cg@exept.de>
parents: 854
diff changeset
    15
	classVariableNames:'NoHandlerSignal'
2d5d0edd3359 commentary
Claus Gittinger <cg@exept.de>
parents: 854
diff changeset
    16
	poolDictionaries:''
2d5d0edd3359 commentary
Claus Gittinger <cg@exept.de>
parents: 854
diff changeset
    17
	category:'Kernel-Exceptions'
1
a27a279701f8 Initial revision
claus
parents:
diff changeset
    18
!
a27a279701f8 Initial revision
claus
parents:
diff changeset
    19
1608
440faca45e37 comment
Claus Gittinger <cg@exept.de>
parents: 1362
diff changeset
    20
!Signal  class methodsFor:'documentation'!
44
b262907c93ea *** empty log message ***
claus
parents: 27
diff changeset
    21
88
81dacba7a63a *** empty log message ***
claus
parents: 77
diff changeset
    22
copyright
81dacba7a63a *** empty log message ***
claus
parents: 77
diff changeset
    23
"
81dacba7a63a *** empty log message ***
claus
parents: 77
diff changeset
    24
 COPYRIGHT (c) 1993 by Claus Gittinger
159
514c749165c3 *** empty log message ***
claus
parents: 145
diff changeset
    25
	      All Rights Reserved
88
81dacba7a63a *** empty log message ***
claus
parents: 77
diff changeset
    26
81dacba7a63a *** empty log message ***
claus
parents: 77
diff changeset
    27
 This software is furnished under a license and may be used
81dacba7a63a *** empty log message ***
claus
parents: 77
diff changeset
    28
 only in accordance with the terms of that license and with the
81dacba7a63a *** empty log message ***
claus
parents: 77
diff changeset
    29
 inclusion of the above copyright notice.   This software may not
81dacba7a63a *** empty log message ***
claus
parents: 77
diff changeset
    30
 be provided or otherwise made available to, or used by, any
81dacba7a63a *** empty log message ***
claus
parents: 77
diff changeset
    31
 other person.  No title to or ownership of the software is
81dacba7a63a *** empty log message ***
claus
parents: 77
diff changeset
    32
 hereby transferred.
81dacba7a63a *** empty log message ***
claus
parents: 77
diff changeset
    33
"
81dacba7a63a *** empty log message ***
claus
parents: 77
diff changeset
    34
!
81dacba7a63a *** empty log message ***
claus
parents: 77
diff changeset
    35
44
b262907c93ea *** empty log message ***
claus
parents: 27
diff changeset
    36
documentation
b262907c93ea *** empty log message ***
claus
parents: 27
diff changeset
    37
"
70
73055652dd21 *** empty log message ***
claus
parents: 61
diff changeset
    38
    Signal and Exception provide a framework for exception handling.
44
b262907c93ea *** empty log message ***
claus
parents: 27
diff changeset
    39
70
73055652dd21 *** empty log message ***
claus
parents: 61
diff changeset
    40
    A Signal object is usually defined somewhere up in the calling chain
73055652dd21 *** empty log message ***
claus
parents: 61
diff changeset
    41
    and associated with some abnormal event. Many signals are also
73055652dd21 *** empty log message ***
claus
parents: 61
diff changeset
    42
    created at startup time and reused.
44
b262907c93ea *** empty log message ***
claus
parents: 27
diff changeset
    43
70
73055652dd21 *** empty log message ***
claus
parents: 61
diff changeset
    44
    When the event is raised (by Signal>>raise) the control will be either 
73055652dd21 *** empty log message ***
claus
parents: 61
diff changeset
    45
    given to a debugger or - if a handler was defined - to the handler. 
73055652dd21 *** empty log message ***
claus
parents: 61
diff changeset
    46
    The handler will get a description of what (and where) happened in an 
120
9a2e74ed2f81 added per-process handler
claus
parents: 95
diff changeset
    47
    Exception object and can decide how to react on the situation (i.e. 
9a2e74ed2f81 added per-process handler
claus
parents: 95
diff changeset
    48
    proceed, return or restart).
70
73055652dd21 *** empty log message ***
claus
parents: 61
diff changeset
    49
73055652dd21 *** empty log message ***
claus
parents: 61
diff changeset
    50
    There is also a companion class called SignalSet, which allows handling
73055652dd21 *** empty log message ***
claus
parents: 61
diff changeset
    51
    multiple signals with one handler (for example all arithmetic signals).
73055652dd21 *** empty log message ***
claus
parents: 61
diff changeset
    52
    And, finally there is a very special SignalSet which allows catching
73055652dd21 *** empty log message ***
claus
parents: 61
diff changeset
    53
    any signal (SignalSet>>anySignal).
73055652dd21 *** empty log message ***
claus
parents: 61
diff changeset
    54
171
129f0e2e23df handling now in Exception
claus
parents: 159
diff changeset
    55
    Since there is no official documentation on signal handling (i.e. none
129f0e2e23df handling now in Exception
claus
parents: 159
diff changeset
    56
    of the books describes it), this Signal implementation has been modeled
129f0e2e23df handling now in Exception
claus
parents: 159
diff changeset
    57
    after what some PD programs seem to expect and what alpha/beta testers told
129f0e2e23df handling now in Exception
claus
parents: 159
diff changeset
    58
    me it should look like.
129f0e2e23df handling now in Exception
claus
parents: 159
diff changeset
    59
    It may not be perfect and undergo minor changes.
44
b262907c93ea *** empty log message ***
claus
parents: 27
diff changeset
    60
120
9a2e74ed2f81 added per-process handler
claus
parents: 95
diff changeset
    61
    special:
9a2e74ed2f81 added per-process handler
claus
parents: 95
diff changeset
    62
70
73055652dd21 *** empty log message ***
claus
parents: 61
diff changeset
    63
    In addition to the nested catch & throw mechanism, signals can also be
120
9a2e74ed2f81 added per-process handler
claus
parents: 95
diff changeset
    64
    used when no such handler scope exists. To support this, signals can be 
9a2e74ed2f81 added per-process handler
claus
parents: 95
diff changeset
    65
    assigned a handlerBlock, which gets evaluated with the exception as argument 
9a2e74ed2f81 added per-process handler
claus
parents: 95
diff changeset
    66
    in case no handler was found (on the stack).
70
73055652dd21 *** empty log message ***
claus
parents: 61
diff changeset
    67
171
129f0e2e23df handling now in Exception
claus
parents: 159
diff changeset
    68
    If no handler was found (i.e. neither a handler context on the stack, nor
129f0e2e23df handling now in Exception
claus
parents: 159
diff changeset
    69
    a static handler block), the NoHandlerSignal will be raised instead,
120
9a2e74ed2f81 added per-process handler
claus
parents: 95
diff changeset
    70
    passing it the original exception in its exception-parameter.
171
129f0e2e23df handling now in Exception
claus
parents: 159
diff changeset
    71
    This NoHandlerSignal can be handled just like any other signal.
129f0e2e23df handling now in Exception
claus
parents: 159
diff changeset
    72
    (therefore, it is possible to catch any error by catching NoHandlerSignal.
70
73055652dd21 *** empty log message ***
claus
parents: 61
diff changeset
    73
120
9a2e74ed2f81 added per-process handler
claus
parents: 95
diff changeset
    74
    When the NoHandler signal is raised, and neither a handler-context, nor 
9a2e74ed2f81 added per-process handler
claus
parents: 95
diff changeset
    75
    a handler block is defined for it, an emergencyHandler(-block) is evaluated.
9a2e74ed2f81 added per-process handler
claus
parents: 95
diff changeset
    76
    This block is either provided by the current process 
9a2e74ed2f81 added per-process handler
claus
parents: 95
diff changeset
    77
    (see Process>>emergencySignalHandler) or as a global default by the Exception
9a2e74ed2f81 added per-process handler
claus
parents: 95
diff changeset
    78
    class (see Exception>>emergencyHandler).
9a2e74ed2f81 added per-process handler
claus
parents: 95
diff changeset
    79
    The default emergencyHandlerBlock (from Exception) will bring up a debugger.
9a2e74ed2f81 added per-process handler
claus
parents: 95
diff changeset
    80
9a2e74ed2f81 added per-process handler
claus
parents: 95
diff changeset
    81
    HandlerBlocks allow a global (if its the EmergencyHandler in Exception)
9a2e74ed2f81 added per-process handler
claus
parents: 95
diff changeset
    82
    or per-process signal handling to be added. Even to code which was never
9a2e74ed2f81 added per-process handler
claus
parents: 95
diff changeset
    83
    planned to handle signals.
70
73055652dd21 *** empty log message ***
claus
parents: 61
diff changeset
    84
171
129f0e2e23df handling now in Exception
claus
parents: 159
diff changeset
    85
    See samples in 'doc/coding' and actual raise code in Exception.
1
a27a279701f8 Initial revision
claus
parents:
diff changeset
    86
1275
2079f4776628 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1249
diff changeset
    87
    [Instance variables:]
70
73055652dd21 *** empty log message ***
claus
parents: 61
diff changeset
    88
1275
2079f4776628 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1249
diff changeset
    89
        mayProceed      <Boolean>       hint for the debugger - program may 
2079f4776628 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1249
diff changeset
    90
                                        proceed (currently not honored by the
2079f4776628 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1249
diff changeset
    91
                                        debugger)
2079f4776628 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1249
diff changeset
    92
2079f4776628 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1249
diff changeset
    93
        notifierString  <String>        error message to be output 
70
73055652dd21 *** empty log message ***
claus
parents: 61
diff changeset
    94
1275
2079f4776628 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1249
diff changeset
    95
        nameClass       <Class>         for the printOn-implementation; nameClass
2079f4776628 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1249
diff changeset
    96
                                        is the class, to which message (below) 
2079f4776628 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1249
diff changeset
    97
                                        should be sent to create the receiver.
1
a27a279701f8 Initial revision
claus
parents:
diff changeset
    98
1275
2079f4776628 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1249
diff changeset
    99
        message         <Symbol>        for the printOn-implementation; message
2079f4776628 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1249
diff changeset
   100
                                        is the selector, which should be sent to 
2079f4776628 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1249
diff changeset
   101
                                        nameClass (above) to create the receiver.
1
a27a279701f8 Initial revision
claus
parents:
diff changeset
   102
1275
2079f4776628 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1249
diff changeset
   103
        handlerBlock    <Block>         if nonNil, a 1-arg block to be 
2079f4776628 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1249
diff changeset
   104
                                        evaluated when no handler context is 
2079f4776628 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1249
diff changeset
   105
                                        found. The block gets the exception
2079f4776628 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1249
diff changeset
   106
                                        object as argument. This will play the role
2079f4776628 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1249
diff changeset
   107
                                        of an on-stack handler.
2079f4776628 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1249
diff changeset
   108
2079f4776628 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1249
diff changeset
   109
    [Class variables:]
70
73055652dd21 *** empty log message ***
claus
parents: 61
diff changeset
   110
1275
2079f4776628 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1249
diff changeset
   111
        NoHandlerSignal <Signal>        signal raised when no handler for a signal
2079f4776628 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1249
diff changeset
   112
                                        was found in raise.
2079f4776628 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1249
diff changeset
   113
                                        If this one is not handled either,
2079f4776628 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1249
diff changeset
   114
                                        Exceptions emergencyHandler will be evaluated
2079f4776628 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1249
diff changeset
   115
                                        instead (or a per-proces handler, if there
2079f4776628 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1249
diff changeset
   116
                                        is one).
1292
89497fff7f87 documentation
Claus Gittinger <cg@exept.de>
parents: 1275
diff changeset
   117
89497fff7f87 documentation
Claus Gittinger <cg@exept.de>
parents: 1275
diff changeset
   118
    [author:]
89497fff7f87 documentation
Claus Gittinger <cg@exept.de>
parents: 1275
diff changeset
   119
        Claus Gittinger
89497fff7f87 documentation
Claus Gittinger <cg@exept.de>
parents: 1275
diff changeset
   120
1275
2079f4776628 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1249
diff changeset
   121
    [see also:]
2079f4776628 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1249
diff changeset
   122
        Exception 
2079f4776628 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1249
diff changeset
   123
        SignalSet QuerySignal
2079f4776628 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1249
diff changeset
   124
        Object
1362
36e887173783 dok & errorString passing fixed (include parameter)
Claus Gittinger <cg@exept.de>
parents: 1326
diff changeset
   125
        (``Exception handling and signals'': programming/exceptions.html)
44
b262907c93ea *** empty log message ***
claus
parents: 27
diff changeset
   126
"
b262907c93ea *** empty log message ***
claus
parents: 27
diff changeset
   127
! !
1
a27a279701f8 Initial revision
claus
parents:
diff changeset
   128
1608
440faca45e37 comment
Claus Gittinger <cg@exept.de>
parents: 1362
diff changeset
   129
!Signal  class methodsFor:'initialization'!
1
a27a279701f8 Initial revision
claus
parents:
diff changeset
   130
159
514c749165c3 *** empty log message ***
claus
parents: 145
diff changeset
   131
initialize 
44
b262907c93ea *** empty log message ***
claus
parents: 27
diff changeset
   132
    "setup the signal used to handle unhandled signals"
b262907c93ea *** empty log message ***
claus
parents: 27
diff changeset
   133
61
claus
parents: 44
diff changeset
   134
    NoHandlerSignal isNil ifTrue:[
302
1f76060d58a4 *** empty log message ***
claus
parents: 259
diff changeset
   135
	NoHandlerSignal := ErrorSignal newSignalMayProceed:true.
159
514c749165c3 *** empty log message ***
claus
parents: 145
diff changeset
   136
	NoHandlerSignal nameClass:self message:#noHandlerSignal.
514c749165c3 *** empty log message ***
claus
parents: 145
diff changeset
   137
	NoHandlerSignal notifierString:'unhandled exception'.
61
claus
parents: 44
diff changeset
   138
    ]
1
a27a279701f8 Initial revision
claus
parents:
diff changeset
   139
! !
a27a279701f8 Initial revision
claus
parents:
diff changeset
   140
1608
440faca45e37 comment
Claus Gittinger <cg@exept.de>
parents: 1362
diff changeset
   141
!Signal  class methodsFor:'instance creation'!
1
a27a279701f8 Initial revision
claus
parents:
diff changeset
   142
a27a279701f8 Initial revision
claus
parents:
diff changeset
   143
new
a27a279701f8 Initial revision
claus
parents:
diff changeset
   144
    "return a new signal"
a27a279701f8 Initial revision
claus
parents:
diff changeset
   145
419
62f39bdfe99d *** empty log message ***
claus
parents: 406
diff changeset
   146
    ^ (self basicNew) notifierString:'signal'
1
a27a279701f8 Initial revision
claus
parents:
diff changeset
   147
! !
a27a279701f8 Initial revision
claus
parents:
diff changeset
   148
1608
440faca45e37 comment
Claus Gittinger <cg@exept.de>
parents: 1362
diff changeset
   149
!Signal  class methodsFor:'Signal constants'!
1
a27a279701f8 Initial revision
claus
parents:
diff changeset
   150
a27a279701f8 Initial revision
claus
parents:
diff changeset
   151
noHandlerSignal
44
b262907c93ea *** empty log message ***
claus
parents: 27
diff changeset
   152
    "return the signal used to handle unhandled signals"
b262907c93ea *** empty log message ***
claus
parents: 27
diff changeset
   153
1
a27a279701f8 Initial revision
claus
parents:
diff changeset
   154
    ^ NoHandlerSignal
a27a279701f8 Initial revision
claus
parents:
diff changeset
   155
! !
a27a279701f8 Initial revision
claus
parents:
diff changeset
   156
622
a17084b7ac06 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 530
diff changeset
   157
!Signal methodsFor:'accessing'!
1
a27a279701f8 Initial revision
claus
parents:
diff changeset
   158
622
a17084b7ac06 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 530
diff changeset
   159
errorString
a17084b7ac06 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 530
diff changeset
   160
    "return the notifier string"
1
a27a279701f8 Initial revision
claus
parents:
diff changeset
   161
622
a17084b7ac06 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 530
diff changeset
   162
    ^ notifierString
a17084b7ac06 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 530
diff changeset
   163
!
159
514c749165c3 *** empty log message ***
claus
parents: 145
diff changeset
   164
622
a17084b7ac06 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 530
diff changeset
   165
handlerBlock
a17084b7ac06 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 530
diff changeset
   166
    "return the handlerblock - if non-nil, this will be evaluated with the exception 
a17084b7ac06 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 530
diff changeset
   167
     object as argument, if no #handle:do: context was found on the stack."
a17084b7ac06 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 530
diff changeset
   168
a17084b7ac06 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 530
diff changeset
   169
    ^ handlerBlock
1
a27a279701f8 Initial revision
claus
parents:
diff changeset
   170
!
a27a279701f8 Initial revision
claus
parents:
diff changeset
   171
622
a17084b7ac06 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 530
diff changeset
   172
handlerBlock:aOneArgBlock
a17084b7ac06 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 530
diff changeset
   173
    "set the handlerblock - this will be evaluated with the exception 
a17084b7ac06 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 530
diff changeset
   174
     object as argument, if no #handle:do: context was found on the stack."
159
514c749165c3 *** empty log message ***
claus
parents: 145
diff changeset
   175
622
a17084b7ac06 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 530
diff changeset
   176
    handlerBlock := aOneArgBlock
a17084b7ac06 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 530
diff changeset
   177
!
159
514c749165c3 *** empty log message ***
claus
parents: 145
diff changeset
   178
622
a17084b7ac06 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 530
diff changeset
   179
mayProceed
a17084b7ac06 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 530
diff changeset
   180
    "return the signals ability to proceed.
a17084b7ac06 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 530
diff changeset
   181
     This flag is (currently) not checked by the system;
a17084b7ac06 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 530
diff changeset
   182
     be prepared for changes here, to eventually have nonProceedable
a17084b7ac06 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 530
diff changeset
   183
     signals refuse to let you continue execution."
1
a27a279701f8 Initial revision
claus
parents:
diff changeset
   184
622
a17084b7ac06 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 530
diff changeset
   185
    ^ mayProceed
1
a27a279701f8 Initial revision
claus
parents:
diff changeset
   186
!
a27a279701f8 Initial revision
claus
parents:
diff changeset
   187
a27a279701f8 Initial revision
claus
parents:
diff changeset
   188
mayProceed:aBoolean
44
b262907c93ea *** empty log message ***
claus
parents: 27
diff changeset
   189
    "set/clear the signals ability to proceed.
419
62f39bdfe99d *** empty log message ***
claus
parents: 406
diff changeset
   190
     This flag is (currently) not checked by the system;
62f39bdfe99d *** empty log message ***
claus
parents: 406
diff changeset
   191
     be prepared for changes here, to eventually have nonProceedable
62f39bdfe99d *** empty log message ***
claus
parents: 406
diff changeset
   192
     signals refuse to let you continue execution."
1
a27a279701f8 Initial revision
claus
parents:
diff changeset
   193
a27a279701f8 Initial revision
claus
parents:
diff changeset
   194
    mayProceed := aBoolean
a27a279701f8 Initial revision
claus
parents:
diff changeset
   195
!
a27a279701f8 Initial revision
claus
parents:
diff changeset
   196
622
a17084b7ac06 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 530
diff changeset
   197
nameClass:aClass message:aSelector
a17084b7ac06 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 530
diff changeset
   198
    "this sets the class & selector of a method which returns
a17084b7ac06 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 530
diff changeset
   199
     that signal - this is simply for documentation purposes -
a17084b7ac06 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 530
diff changeset
   200
     see Signal>>printOn: implementation.
a17084b7ac06 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 530
diff changeset
   201
     (took me a while to find that one out ;-)"
419
62f39bdfe99d *** empty log message ***
claus
parents: 406
diff changeset
   202
622
a17084b7ac06 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 530
diff changeset
   203
    nameClass := aClass.
a17084b7ac06 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 530
diff changeset
   204
    message := aSelector
419
62f39bdfe99d *** empty log message ***
claus
parents: 406
diff changeset
   205
!
62f39bdfe99d *** empty log message ***
claus
parents: 406
diff changeset
   206
622
a17084b7ac06 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 530
diff changeset
   207
notifierString
a17084b7ac06 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 530
diff changeset
   208
    "return the notifier string"
159
514c749165c3 *** empty log message ***
claus
parents: 145
diff changeset
   209
622
a17084b7ac06 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 530
diff changeset
   210
    ^ notifierString
a17084b7ac06 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 530
diff changeset
   211
!
a17084b7ac06 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 530
diff changeset
   212
a17084b7ac06 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 530
diff changeset
   213
notifierString:aString
a17084b7ac06 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 530
diff changeset
   214
    "set the notifier string"
a17084b7ac06 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 530
diff changeset
   215
a17084b7ac06 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 530
diff changeset
   216
    notifierString := aString
159
514c749165c3 *** empty log message ***
claus
parents: 145
diff changeset
   217
!
514c749165c3 *** empty log message ***
claus
parents: 145
diff changeset
   218
514c749165c3 *** empty log message ***
claus
parents: 145
diff changeset
   219
parent
514c749165c3 *** empty log message ***
claus
parents: 145
diff changeset
   220
    "return the parent-signal of the receiver"
514c749165c3 *** empty log message ***
claus
parents: 145
diff changeset
   221
514c749165c3 *** empty log message ***
claus
parents: 145
diff changeset
   222
    ^ parent
514c749165c3 *** empty log message ***
claus
parents: 145
diff changeset
   223
!
514c749165c3 *** empty log message ***
claus
parents: 145
diff changeset
   224
622
a17084b7ac06 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 530
diff changeset
   225
parent:aSignal 
a17084b7ac06 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 530
diff changeset
   226
    "set the parent-signal of the receiver."
a17084b7ac06 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 530
diff changeset
   227
a17084b7ac06 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 530
diff changeset
   228
    parent := aSignal
a17084b7ac06 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 530
diff changeset
   229
! !
a17084b7ac06 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 530
diff changeset
   230
a17084b7ac06 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 530
diff changeset
   231
!Signal methodsFor:'copying'!
a17084b7ac06 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 530
diff changeset
   232
a17084b7ac06 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 530
diff changeset
   233
deepCopy
a17084b7ac06 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 530
diff changeset
   234
    "raise an error - deepCopy is not allowed for signals"
1
a27a279701f8 Initial revision
claus
parents:
diff changeset
   235
622
a17084b7ac06 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 530
diff changeset
   236
    ^ self deepCopyError
a17084b7ac06 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 530
diff changeset
   237
! !
a17084b7ac06 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 530
diff changeset
   238
a17084b7ac06 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 530
diff changeset
   239
!Signal methodsFor:'instance creation'!
1
a27a279701f8 Initial revision
claus
parents:
diff changeset
   240
622
a17084b7ac06 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 530
diff changeset
   241
newSignal
a17084b7ac06 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 530
diff changeset
   242
    "create a new signal, using the receiver as a prototype and
a17084b7ac06 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 530
diff changeset
   243
     setting the parent of the new signal to the receiver."
1
a27a279701f8 Initial revision
claus
parents:
diff changeset
   244
622
a17084b7ac06 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 530
diff changeset
   245
    ^ (self copy) parent:self
70
73055652dd21 *** empty log message ***
claus
parents: 61
diff changeset
   246
!
73055652dd21 *** empty log message ***
claus
parents: 61
diff changeset
   247
622
a17084b7ac06 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 530
diff changeset
   248
newSignalMayProceed:aBoolean
a17084b7ac06 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 530
diff changeset
   249
    "create a new signal, using the receiver as a prototype and
a17084b7ac06 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 530
diff changeset
   250
     setting the parent of the new signal to the receiver."
362
claus
parents: 345
diff changeset
   251
622
a17084b7ac06 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 530
diff changeset
   252
    |newSignal|
70
73055652dd21 *** empty log message ***
claus
parents: 61
diff changeset
   253
622
a17084b7ac06 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 530
diff changeset
   254
    newSignal := (self copy) mayProceed:aBoolean.
a17084b7ac06 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 530
diff changeset
   255
    newSignal parent:self.
a17084b7ac06 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 530
diff changeset
   256
    ^ newSignal
1
a27a279701f8 Initial revision
claus
parents:
diff changeset
   257
! !
a27a279701f8 Initial revision
claus
parents:
diff changeset
   258
159
514c749165c3 *** empty log message ***
claus
parents: 145
diff changeset
   259
!Signal methodsFor:'printing'!
514c749165c3 *** empty log message ***
claus
parents: 145
diff changeset
   260
514c749165c3 *** empty log message ***
claus
parents: 145
diff changeset
   261
printOn:aStream
514c749165c3 *** empty log message ***
claus
parents: 145
diff changeset
   262
    "append a printed representation of the receiver on aStream"
514c749165c3 *** empty log message ***
claus
parents: 145
diff changeset
   263
514c749165c3 *** empty log message ***
claus
parents: 145
diff changeset
   264
    nameClass notNil ifTrue:[
514c749165c3 *** empty log message ***
claus
parents: 145
diff changeset
   265
	aStream nextPutAll:nameClass name.
514c749165c3 *** empty log message ***
claus
parents: 145
diff changeset
   266
	aStream space.
514c749165c3 *** empty log message ***
claus
parents: 145
diff changeset
   267
	aStream nextPutAll:message.
514c749165c3 *** empty log message ***
claus
parents: 145
diff changeset
   268
	^ self
514c749165c3 *** empty log message ***
claus
parents: 145
diff changeset
   269
    ].
514c749165c3 *** empty log message ***
claus
parents: 145
diff changeset
   270
    ^ super printOn:aStream
514c749165c3 *** empty log message ***
claus
parents: 145
diff changeset
   271
! !
514c749165c3 *** empty log message ***
claus
parents: 145
diff changeset
   272
622
a17084b7ac06 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 530
diff changeset
   273
!Signal methodsFor:'private'!
a17084b7ac06 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 530
diff changeset
   274
1362
36e887173783 dok & errorString passing fixed (include parameter)
Claus Gittinger <cg@exept.de>
parents: 1326
diff changeset
   275
errorStringFor:errorString with:aParameter
36e887173783 dok & errorString passing fixed (include parameter)
Claus Gittinger <cg@exept.de>
parents: 1326
diff changeset
   276
    "used when raising with a given error string and/or parameter; 
36e887173783 dok & errorString passing fixed (include parameter)
Claus Gittinger <cg@exept.de>
parents: 1326
diff changeset
   277
     if the errorString starts with a space, it is appended to the receivers
622
a17084b7ac06 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 530
diff changeset
   278
     notifier string; if it ends with a space, it is prepended.
1362
36e887173783 dok & errorString passing fixed (include parameter)
Claus Gittinger <cg@exept.de>
parents: 1326
diff changeset
   279
     Otherwise, the errorString is returned.
36e887173783 dok & errorString passing fixed (include parameter)
Claus Gittinger <cg@exept.de>
parents: 1326
diff changeset
   280
     If no errorString is given, use the signals default notifierString."
36e887173783 dok & errorString passing fixed (include parameter)
Claus Gittinger <cg@exept.de>
parents: 1326
diff changeset
   281
36e887173783 dok & errorString passing fixed (include parameter)
Claus Gittinger <cg@exept.de>
parents: 1326
diff changeset
   282
    |t pS|
622
a17084b7ac06 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 530
diff changeset
   283
1362
36e887173783 dok & errorString passing fixed (include parameter)
Claus Gittinger <cg@exept.de>
parents: 1326
diff changeset
   284
    errorString isNil ifTrue:[
36e887173783 dok & errorString passing fixed (include parameter)
Claus Gittinger <cg@exept.de>
parents: 1326
diff changeset
   285
        t := notifierString
36e887173783 dok & errorString passing fixed (include parameter)
Claus Gittinger <cg@exept.de>
parents: 1326
diff changeset
   286
    ] ifFalse:[
36e887173783 dok & errorString passing fixed (include parameter)
Claus Gittinger <cg@exept.de>
parents: 1326
diff changeset
   287
        t := errorString
36e887173783 dok & errorString passing fixed (include parameter)
Claus Gittinger <cg@exept.de>
parents: 1326
diff changeset
   288
    ].
36e887173783 dok & errorString passing fixed (include parameter)
Claus Gittinger <cg@exept.de>
parents: 1326
diff changeset
   289
36e887173783 dok & errorString passing fixed (include parameter)
Claus Gittinger <cg@exept.de>
parents: 1326
diff changeset
   290
    aParameter isNil ifTrue:[
36e887173783 dok & errorString passing fixed (include parameter)
Claus Gittinger <cg@exept.de>
parents: 1326
diff changeset
   291
        ^ t
622
a17084b7ac06 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 530
diff changeset
   292
    ].
1362
36e887173783 dok & errorString passing fixed (include parameter)
Claus Gittinger <cg@exept.de>
parents: 1326
diff changeset
   293
36e887173783 dok & errorString passing fixed (include parameter)
Claus Gittinger <cg@exept.de>
parents: 1326
diff changeset
   294
    (t startsWith:' ') ifTrue:[
36e887173783 dok & errorString passing fixed (include parameter)
Claus Gittinger <cg@exept.de>
parents: 1326
diff changeset
   295
        ^ aParameter printString , t
622
a17084b7ac06 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 530
diff changeset
   296
    ].
1362
36e887173783 dok & errorString passing fixed (include parameter)
Claus Gittinger <cg@exept.de>
parents: 1326
diff changeset
   297
    (t endsWith:' ') ifTrue:[
36e887173783 dok & errorString passing fixed (include parameter)
Claus Gittinger <cg@exept.de>
parents: 1326
diff changeset
   298
        ^ t , aParameter printString
36e887173783 dok & errorString passing fixed (include parameter)
Claus Gittinger <cg@exept.de>
parents: 1326
diff changeset
   299
    ].
36e887173783 dok & errorString passing fixed (include parameter)
Claus Gittinger <cg@exept.de>
parents: 1326
diff changeset
   300
    ^ t
36e887173783 dok & errorString passing fixed (include parameter)
Claus Gittinger <cg@exept.de>
parents: 1326
diff changeset
   301
36e887173783 dok & errorString passing fixed (include parameter)
Claus Gittinger <cg@exept.de>
parents: 1326
diff changeset
   302
    "Modified: 9.5.1996 / 15:18:58 / cg"
622
a17084b7ac06 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 530
diff changeset
   303
! !
a17084b7ac06 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 530
diff changeset
   304
a17084b7ac06 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 530
diff changeset
   305
!Signal methodsFor:'queries'!
a17084b7ac06 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 530
diff changeset
   306
a17084b7ac06 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 530
diff changeset
   307
accepts:aSignal
a17084b7ac06 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 530
diff changeset
   308
    "return true, if the receiver accepts the argument, aSignal.
a17084b7ac06 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 530
diff changeset
   309
     (i.e. the receiver is aSignal or a parent of it). False otherwise."
a17084b7ac06 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 530
diff changeset
   310
a17084b7ac06 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 530
diff changeset
   311
    |s|
a17084b7ac06 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 530
diff changeset
   312
a17084b7ac06 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 530
diff changeset
   313
    aSignal isQuerySignal ifTrue:[^ false].
a17084b7ac06 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 530
diff changeset
   314
a17084b7ac06 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 530
diff changeset
   315
    s := aSignal.
a17084b7ac06 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 530
diff changeset
   316
    [s notNil] whileTrue:[
a17084b7ac06 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 530
diff changeset
   317
	self == s ifTrue:[^ true].
a17084b7ac06 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 530
diff changeset
   318
	s := s parent
a17084b7ac06 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 530
diff changeset
   319
    ].
a17084b7ac06 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 530
diff changeset
   320
    ^ false
a17084b7ac06 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 530
diff changeset
   321
!
a17084b7ac06 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 530
diff changeset
   322
a17084b7ac06 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 530
diff changeset
   323
inheritsFrom:anotherSignal
a17084b7ac06 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 530
diff changeset
   324
    "return true, if the receiver is a child of anotherSignal
a17084b7ac06 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 530
diff changeset
   325
     (i.e. if handling anotherSignal also handles the receiver)
a17084b7ac06 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 530
diff changeset
   326
     This is almost the same as accepts, but returns false, if
a17084b7ac06 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 530
diff changeset
   327
     the receiver is identical to anotherSignal."
a17084b7ac06 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 530
diff changeset
   328
a17084b7ac06 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 530
diff changeset
   329
    self == anotherSignal ifTrue:[^ false].
a17084b7ac06 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 530
diff changeset
   330
    ^ anotherSignal accepts:self
a17084b7ac06 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 530
diff changeset
   331
!
a17084b7ac06 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 530
diff changeset
   332
a17084b7ac06 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 530
diff changeset
   333
isHandled
a17084b7ac06 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 530
diff changeset
   334
    "return true, if there is a handler for the receiver signal.
a17084b7ac06 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 530
diff changeset
   335
     Raising an unhandled signal will usually lead into the debugger,
a17084b7ac06 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 530
diff changeset
   336
     but can be cought globally by setting Exceptions EmergencyHandler."
a17084b7ac06 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 530
diff changeset
   337
a17084b7ac06 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 530
diff changeset
   338
    ^ self isHandledIn:(thisContext sender).
a17084b7ac06 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 530
diff changeset
   339
!
a17084b7ac06 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 530
diff changeset
   340
a17084b7ac06 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 530
diff changeset
   341
isHandledIn:aContext
a17084b7ac06 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 530
diff changeset
   342
    "return true, if there is a handler for the receiver signal in the 
a17084b7ac06 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 530
diff changeset
   343
     contextChain starting with aContext."
a17084b7ac06 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 530
diff changeset
   344
a17084b7ac06 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 530
diff changeset
   345
    |con sel|
a17084b7ac06 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 530
diff changeset
   346
a17084b7ac06 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 530
diff changeset
   347
    con := aContext.
a17084b7ac06 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 530
diff changeset
   348
    [con notNil] whileTrue:[
a17084b7ac06 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 530
diff changeset
   349
	(((sel := con selector) == #handle:do:) 
a17084b7ac06 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 530
diff changeset
   350
	or:[sel == #handle:from:do:]) ifTrue:[
a17084b7ac06 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 530
diff changeset
   351
	    "
854
301f87015cc5 commentary
Claus Gittinger <cg@exept.de>
parents: 622
diff changeset
   352
	     is this is a #handle:do: or a #handle:from:do: context
301f87015cc5 commentary
Claus Gittinger <cg@exept.de>
parents: 622
diff changeset
   353
	     with self in it ?
622
a17084b7ac06 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 530
diff changeset
   354
	    "
a17084b7ac06 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 530
diff changeset
   355
	    (con receiver accepts:self) ifTrue:[
a17084b7ac06 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 530
diff changeset
   356
		"found a handler context"
a17084b7ac06 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 530
diff changeset
   357
a17084b7ac06 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 530
diff changeset
   358
		^ true
a17084b7ac06 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 530
diff changeset
   359
	    ].
a17084b7ac06 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 530
diff changeset
   360
	].
a17084b7ac06 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 530
diff changeset
   361
	con := con sender
a17084b7ac06 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 530
diff changeset
   362
    ].
a17084b7ac06 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 530
diff changeset
   363
    ^ false
a17084b7ac06 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 530
diff changeset
   364
!
a17084b7ac06 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 530
diff changeset
   365
a17084b7ac06 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 530
diff changeset
   366
isQuerySignal
1249
2d5d0edd3359 commentary
Claus Gittinger <cg@exept.de>
parents: 854
diff changeset
   367
    "return true, if this is a querySignal - always return false here"
2d5d0edd3359 commentary
Claus Gittinger <cg@exept.de>
parents: 854
diff changeset
   368
622
a17084b7ac06 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 530
diff changeset
   369
    ^ false
1249
2d5d0edd3359 commentary
Claus Gittinger <cg@exept.de>
parents: 854
diff changeset
   370
2d5d0edd3359 commentary
Claus Gittinger <cg@exept.de>
parents: 854
diff changeset
   371
    "Modified: 22.4.1996 / 13:45:06 / cg"
622
a17084b7ac06 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 530
diff changeset
   372
!
a17084b7ac06 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 530
diff changeset
   373
a17084b7ac06 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 530
diff changeset
   374
isSignal
a17084b7ac06 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 530
diff changeset
   375
    "return true, if the receiver is some kind of signal;
a17084b7ac06 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 530
diff changeset
   376
     true returned here - the method is redefined from Object."
a17084b7ac06 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 530
diff changeset
   377
a17084b7ac06 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 530
diff changeset
   378
    ^ true
a17084b7ac06 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 530
diff changeset
   379
! !
a17084b7ac06 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 530
diff changeset
   380
a17084b7ac06 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 530
diff changeset
   381
!Signal methodsFor:'raising'!
a17084b7ac06 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 530
diff changeset
   382
a17084b7ac06 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 530
diff changeset
   383
raise
1326
60ea3687ee49 commentary
Claus Gittinger <cg@exept.de>
parents: 1292
diff changeset
   384
    "raise a signal nonproceedable
60ea3687ee49 commentary
Claus Gittinger <cg@exept.de>
parents: 1292
diff changeset
   385
     - notice, ST/X does not (for now) distinguish between proceedable and
60ea3687ee49 commentary
Claus Gittinger <cg@exept.de>
parents: 1292
diff changeset
   386
       non proceedable exceptions.
622
a17084b7ac06 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 530
diff changeset
   387
     The signals notifierString is used as errorString."
a17084b7ac06 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 530
diff changeset
   388
a17084b7ac06 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 530
diff changeset
   389
    ^ (Exception  
1326
60ea3687ee49 commentary
Claus Gittinger <cg@exept.de>
parents: 1292
diff changeset
   390
              signal:self
60ea3687ee49 commentary
Claus Gittinger <cg@exept.de>
parents: 1292
diff changeset
   391
              parameter:nil 
60ea3687ee49 commentary
Claus Gittinger <cg@exept.de>
parents: 1292
diff changeset
   392
              errorString:notifierString
60ea3687ee49 commentary
Claus Gittinger <cg@exept.de>
parents: 1292
diff changeset
   393
              suspendedContext:thisContext sender) raise.
60ea3687ee49 commentary
Claus Gittinger <cg@exept.de>
parents: 1292
diff changeset
   394
60ea3687ee49 commentary
Claus Gittinger <cg@exept.de>
parents: 1292
diff changeset
   395
    "Modified: 2.5.1996 / 16:36:23 / cg"
622
a17084b7ac06 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 530
diff changeset
   396
!
a17084b7ac06 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 530
diff changeset
   397
a17084b7ac06 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 530
diff changeset
   398
raiseErrorString:aString
1326
60ea3687ee49 commentary
Claus Gittinger <cg@exept.de>
parents: 1292
diff changeset
   399
    "raise a signal nonproceedable.
60ea3687ee49 commentary
Claus Gittinger <cg@exept.de>
parents: 1292
diff changeset
   400
     - notice, ST/X does not (for now) distinguish between proceedable and
60ea3687ee49 commentary
Claus Gittinger <cg@exept.de>
parents: 1292
diff changeset
   401
       non proceedable exceptions.
622
a17084b7ac06 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 530
diff changeset
   402
     The argument is used as errorString."
a17084b7ac06 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 530
diff changeset
   403
a17084b7ac06 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 530
diff changeset
   404
    ^ (Exception  
1326
60ea3687ee49 commentary
Claus Gittinger <cg@exept.de>
parents: 1292
diff changeset
   405
              signal:self
60ea3687ee49 commentary
Claus Gittinger <cg@exept.de>
parents: 1292
diff changeset
   406
              parameter:nil 
1362
36e887173783 dok & errorString passing fixed (include parameter)
Claus Gittinger <cg@exept.de>
parents: 1326
diff changeset
   407
              errorString:(self errorStringFor:aString with:nil)
1326
60ea3687ee49 commentary
Claus Gittinger <cg@exept.de>
parents: 1292
diff changeset
   408
              suspendedContext:thisContext sender) raise.
60ea3687ee49 commentary
Claus Gittinger <cg@exept.de>
parents: 1292
diff changeset
   409
1362
36e887173783 dok & errorString passing fixed (include parameter)
Claus Gittinger <cg@exept.de>
parents: 1326
diff changeset
   410
    "Modified: 9.5.1996 / 15:17:59 / cg"
622
a17084b7ac06 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 530
diff changeset
   411
!
a17084b7ac06 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 530
diff changeset
   412
1610
2c076ee64e11 added #raiseErrorString:in:
Claus Gittinger <cg@exept.de>
parents: 1608
diff changeset
   413
raiseErrorString:aString in:aContext
2c076ee64e11 added #raiseErrorString:in:
Claus Gittinger <cg@exept.de>
parents: 1608
diff changeset
   414
    "raise a signal nonproceedable.
2c076ee64e11 added #raiseErrorString:in:
Claus Gittinger <cg@exept.de>
parents: 1608
diff changeset
   415
     - notice, ST/X does not (for now) distinguish between proceedable and
2c076ee64e11 added #raiseErrorString:in:
Claus Gittinger <cg@exept.de>
parents: 1608
diff changeset
   416
       non proceedable exceptions.
2c076ee64e11 added #raiseErrorString:in:
Claus Gittinger <cg@exept.de>
parents: 1608
diff changeset
   417
     The argument is used as errorString.
2c076ee64e11 added #raiseErrorString:in:
Claus Gittinger <cg@exept.de>
parents: 1608
diff changeset
   418
     The additional context is passed as the context responsible for the raise,
2c076ee64e11 added #raiseErrorString:in:
Claus Gittinger <cg@exept.de>
parents: 1608
diff changeset
   419
     allowing a raise to mimicri the exception happened somewhere else."
2c076ee64e11 added #raiseErrorString:in:
Claus Gittinger <cg@exept.de>
parents: 1608
diff changeset
   420
2c076ee64e11 added #raiseErrorString:in:
Claus Gittinger <cg@exept.de>
parents: 1608
diff changeset
   421
    ^ (Exception  
2c076ee64e11 added #raiseErrorString:in:
Claus Gittinger <cg@exept.de>
parents: 1608
diff changeset
   422
              signal:self
2c076ee64e11 added #raiseErrorString:in:
Claus Gittinger <cg@exept.de>
parents: 1608
diff changeset
   423
              parameter:nil 
2c076ee64e11 added #raiseErrorString:in:
Claus Gittinger <cg@exept.de>
parents: 1608
diff changeset
   424
              errorString:(self errorStringFor:aString with:nil)
2c076ee64e11 added #raiseErrorString:in:
Claus Gittinger <cg@exept.de>
parents: 1608
diff changeset
   425
              suspendedContext:aContext) raise.
2c076ee64e11 added #raiseErrorString:in:
Claus Gittinger <cg@exept.de>
parents: 1608
diff changeset
   426
2c076ee64e11 added #raiseErrorString:in:
Claus Gittinger <cg@exept.de>
parents: 1608
diff changeset
   427
    "Created: 26.7.1996 / 16:42:32 / cg"
2c076ee64e11 added #raiseErrorString:in:
Claus Gittinger <cg@exept.de>
parents: 1608
diff changeset
   428
    "Modified: 26.7.1996 / 16:42:47 / cg"
2c076ee64e11 added #raiseErrorString:in:
Claus Gittinger <cg@exept.de>
parents: 1608
diff changeset
   429
!
2c076ee64e11 added #raiseErrorString:in:
Claus Gittinger <cg@exept.de>
parents: 1608
diff changeset
   430
622
a17084b7ac06 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 530
diff changeset
   431
raiseFrom:something
1326
60ea3687ee49 commentary
Claus Gittinger <cg@exept.de>
parents: 1292
diff changeset
   432
    "raise a signal nonproceedable.
60ea3687ee49 commentary
Claus Gittinger <cg@exept.de>
parents: 1292
diff changeset
   433
     - notice, ST/X does not (for now) distinguish between proceedable and
60ea3687ee49 commentary
Claus Gittinger <cg@exept.de>
parents: 1292
diff changeset
   434
       non proceedable exceptions.
622
a17084b7ac06 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 530
diff changeset
   435
     The argument, something is passed both as parameter and originator.
a17084b7ac06 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 530
diff changeset
   436
     XXX: I am not certain, if this is the correct behavior (seen in remoteInvocation-goodie)"
a17084b7ac06 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 530
diff changeset
   437
a17084b7ac06 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 530
diff changeset
   438
    ^ (Exception 
1326
60ea3687ee49 commentary
Claus Gittinger <cg@exept.de>
parents: 1292
diff changeset
   439
              signal:self
60ea3687ee49 commentary
Claus Gittinger <cg@exept.de>
parents: 1292
diff changeset
   440
              parameter:something 
60ea3687ee49 commentary
Claus Gittinger <cg@exept.de>
parents: 1292
diff changeset
   441
              errorString:notifierString
60ea3687ee49 commentary
Claus Gittinger <cg@exept.de>
parents: 1292
diff changeset
   442
              suspendedContext:thisContext sender
60ea3687ee49 commentary
Claus Gittinger <cg@exept.de>
parents: 1292
diff changeset
   443
              originator:something) raise.
60ea3687ee49 commentary
Claus Gittinger <cg@exept.de>
parents: 1292
diff changeset
   444
60ea3687ee49 commentary
Claus Gittinger <cg@exept.de>
parents: 1292
diff changeset
   445
    "Modified: 2.5.1996 / 16:36:38 / cg"
622
a17084b7ac06 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 530
diff changeset
   446
!
a17084b7ac06 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 530
diff changeset
   447
a17084b7ac06 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 530
diff changeset
   448
raiseIn:aContext
1326
60ea3687ee49 commentary
Claus Gittinger <cg@exept.de>
parents: 1292
diff changeset
   449
    "raise a signal nonproceedable.
60ea3687ee49 commentary
Claus Gittinger <cg@exept.de>
parents: 1292
diff changeset
   450
     - notice, ST/X does not (for now) distinguish between proceedable and
60ea3687ee49 commentary
Claus Gittinger <cg@exept.de>
parents: 1292
diff changeset
   451
       non proceedable exceptions.
622
a17084b7ac06 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 530
diff changeset
   452
     The signals notifierString is used as errorString.
a17084b7ac06 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 530
diff changeset
   453
     The additional context is passed as the context responsible for the raise,
a17084b7ac06 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 530
diff changeset
   454
     allowing a raise to mimicri the exception happened somewhere else."
a17084b7ac06 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 530
diff changeset
   455
a17084b7ac06 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 530
diff changeset
   456
    ^ (Exception 
1326
60ea3687ee49 commentary
Claus Gittinger <cg@exept.de>
parents: 1292
diff changeset
   457
              signal:self
60ea3687ee49 commentary
Claus Gittinger <cg@exept.de>
parents: 1292
diff changeset
   458
              parameter:nil 
60ea3687ee49 commentary
Claus Gittinger <cg@exept.de>
parents: 1292
diff changeset
   459
              errorString:notifierString
60ea3687ee49 commentary
Claus Gittinger <cg@exept.de>
parents: 1292
diff changeset
   460
              suspendedContext:aContext) raise.
60ea3687ee49 commentary
Claus Gittinger <cg@exept.de>
parents: 1292
diff changeset
   461
60ea3687ee49 commentary
Claus Gittinger <cg@exept.de>
parents: 1292
diff changeset
   462
    "Modified: 2.5.1996 / 16:36:44 / cg"
622
a17084b7ac06 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 530
diff changeset
   463
!
a17084b7ac06 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 530
diff changeset
   464
a17084b7ac06 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 530
diff changeset
   465
raiseRequest
1326
60ea3687ee49 commentary
Claus Gittinger <cg@exept.de>
parents: 1292
diff changeset
   466
    "raise a signal proceedable.
622
a17084b7ac06 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 530
diff changeset
   467
     The signals notifierString is used as errorString."
a17084b7ac06 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 530
diff changeset
   468
a17084b7ac06 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 530
diff changeset
   469
    ^ (Exception  
1326
60ea3687ee49 commentary
Claus Gittinger <cg@exept.de>
parents: 1292
diff changeset
   470
              signal:self
60ea3687ee49 commentary
Claus Gittinger <cg@exept.de>
parents: 1292
diff changeset
   471
              parameter:nil 
60ea3687ee49 commentary
Claus Gittinger <cg@exept.de>
parents: 1292
diff changeset
   472
              errorString:notifierString
60ea3687ee49 commentary
Claus Gittinger <cg@exept.de>
parents: 1292
diff changeset
   473
              suspendedContext:thisContext sender) raiseRequest.
60ea3687ee49 commentary
Claus Gittinger <cg@exept.de>
parents: 1292
diff changeset
   474
60ea3687ee49 commentary
Claus Gittinger <cg@exept.de>
parents: 1292
diff changeset
   475
    "Modified: 2.5.1996 / 16:36:52 / cg"
622
a17084b7ac06 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 530
diff changeset
   476
!
a17084b7ac06 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 530
diff changeset
   477
a17084b7ac06 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 530
diff changeset
   478
raiseRequestWith:aParameter
1326
60ea3687ee49 commentary
Claus Gittinger <cg@exept.de>
parents: 1292
diff changeset
   479
    "raise a signal proceedable.
622
a17084b7ac06 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 530
diff changeset
   480
     The signals notifierString is used as errorString."
a17084b7ac06 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 530
diff changeset
   481
a17084b7ac06 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 530
diff changeset
   482
    ^ (Exception 
1326
60ea3687ee49 commentary
Claus Gittinger <cg@exept.de>
parents: 1292
diff changeset
   483
              signal:self
60ea3687ee49 commentary
Claus Gittinger <cg@exept.de>
parents: 1292
diff changeset
   484
              parameter:aParameter 
1362
36e887173783 dok & errorString passing fixed (include parameter)
Claus Gittinger <cg@exept.de>
parents: 1326
diff changeset
   485
              errorString:(self errorStringFor:nil with:aParameter)
1326
60ea3687ee49 commentary
Claus Gittinger <cg@exept.de>
parents: 1292
diff changeset
   486
              suspendedContext:thisContext sender) raiseRequest.
60ea3687ee49 commentary
Claus Gittinger <cg@exept.de>
parents: 1292
diff changeset
   487
1362
36e887173783 dok & errorString passing fixed (include parameter)
Claus Gittinger <cg@exept.de>
parents: 1326
diff changeset
   488
    "Modified: 9.5.1996 / 15:13:20 / cg"
622
a17084b7ac06 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 530
diff changeset
   489
!
a17084b7ac06 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 530
diff changeset
   490
a17084b7ac06 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 530
diff changeset
   491
raiseRequestWith:aParameter errorString:aString
1326
60ea3687ee49 commentary
Claus Gittinger <cg@exept.de>
parents: 1292
diff changeset
   492
    "raise a signal proceedable.
622
a17084b7ac06 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 530
diff changeset
   493
     The argument, aString is used as errorString."
a17084b7ac06 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 530
diff changeset
   494
a17084b7ac06 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 530
diff changeset
   495
    ^ (Exception 
1326
60ea3687ee49 commentary
Claus Gittinger <cg@exept.de>
parents: 1292
diff changeset
   496
              signal:self
60ea3687ee49 commentary
Claus Gittinger <cg@exept.de>
parents: 1292
diff changeset
   497
              parameter:aParameter 
1362
36e887173783 dok & errorString passing fixed (include parameter)
Claus Gittinger <cg@exept.de>
parents: 1326
diff changeset
   498
              errorString:(self errorStringFor:aString with:aParameter)
1326
60ea3687ee49 commentary
Claus Gittinger <cg@exept.de>
parents: 1292
diff changeset
   499
              suspendedContext:thisContext sender) raiseRequest
60ea3687ee49 commentary
Claus Gittinger <cg@exept.de>
parents: 1292
diff changeset
   500
1362
36e887173783 dok & errorString passing fixed (include parameter)
Claus Gittinger <cg@exept.de>
parents: 1326
diff changeset
   501
    "Modified: 9.5.1996 / 15:13:35 / cg"
622
a17084b7ac06 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 530
diff changeset
   502
!
a17084b7ac06 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 530
diff changeset
   503
a17084b7ac06 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 530
diff changeset
   504
raiseRequestWith:aParameter errorString:aString in:aContext
1326
60ea3687ee49 commentary
Claus Gittinger <cg@exept.de>
parents: 1292
diff changeset
   505
    "raise a signal proceedable.
622
a17084b7ac06 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 530
diff changeset
   506
     The argument, aString is used as errorString.
1608
440faca45e37 comment
Claus Gittinger <cg@exept.de>
parents: 1362
diff changeset
   507
     The additional context is passed as the context responsible for the raise,
440faca45e37 comment
Claus Gittinger <cg@exept.de>
parents: 1362
diff changeset
   508
     allowing a raise to mimicri the exception happened somewhere else."
622
a17084b7ac06 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 530
diff changeset
   509
a17084b7ac06 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 530
diff changeset
   510
    ^ (Exception 
1326
60ea3687ee49 commentary
Claus Gittinger <cg@exept.de>
parents: 1292
diff changeset
   511
              signal:self
60ea3687ee49 commentary
Claus Gittinger <cg@exept.de>
parents: 1292
diff changeset
   512
              parameter:aParameter 
1362
36e887173783 dok & errorString passing fixed (include parameter)
Claus Gittinger <cg@exept.de>
parents: 1326
diff changeset
   513
              errorString:(self errorStringFor:aString with:aParameter)
1326
60ea3687ee49 commentary
Claus Gittinger <cg@exept.de>
parents: 1292
diff changeset
   514
              suspendedContext:aContext) raiseRequest
60ea3687ee49 commentary
Claus Gittinger <cg@exept.de>
parents: 1292
diff changeset
   515
1608
440faca45e37 comment
Claus Gittinger <cg@exept.de>
parents: 1362
diff changeset
   516
    "Modified: 26.7.1996 / 16:29:27 / cg"
622
a17084b7ac06 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 530
diff changeset
   517
!
a17084b7ac06 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 530
diff changeset
   518
a17084b7ac06 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 530
diff changeset
   519
raiseRequestWith:aParameter in:aContext
1326
60ea3687ee49 commentary
Claus Gittinger <cg@exept.de>
parents: 1292
diff changeset
   520
    "raise a signal proceedable.
622
a17084b7ac06 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 530
diff changeset
   521
     The signals notifierString is used as errorString.
1608
440faca45e37 comment
Claus Gittinger <cg@exept.de>
parents: 1362
diff changeset
   522
     The additional context is passed as the context responsible for the raise,
440faca45e37 comment
Claus Gittinger <cg@exept.de>
parents: 1362
diff changeset
   523
     allowing a raise to mimicri the exception happened somewhere else."
622
a17084b7ac06 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 530
diff changeset
   524
a17084b7ac06 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 530
diff changeset
   525
    ^ (Exception 
1326
60ea3687ee49 commentary
Claus Gittinger <cg@exept.de>
parents: 1292
diff changeset
   526
              signal:self
60ea3687ee49 commentary
Claus Gittinger <cg@exept.de>
parents: 1292
diff changeset
   527
              parameter:aParameter 
1362
36e887173783 dok & errorString passing fixed (include parameter)
Claus Gittinger <cg@exept.de>
parents: 1326
diff changeset
   528
              errorString:(self errorStringFor:nil with:aParameter)
1326
60ea3687ee49 commentary
Claus Gittinger <cg@exept.de>
parents: 1292
diff changeset
   529
              suspendedContext:aContext) raiseRequest.
60ea3687ee49 commentary
Claus Gittinger <cg@exept.de>
parents: 1292
diff changeset
   530
1608
440faca45e37 comment
Claus Gittinger <cg@exept.de>
parents: 1362
diff changeset
   531
    "Modified: 26.7.1996 / 16:29:33 / cg"
622
a17084b7ac06 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 530
diff changeset
   532
!
a17084b7ac06 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 530
diff changeset
   533
a17084b7ac06 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 530
diff changeset
   534
raiseWith:aParameter
1326
60ea3687ee49 commentary
Claus Gittinger <cg@exept.de>
parents: 1292
diff changeset
   535
    "raise a signal nonproceedable.
60ea3687ee49 commentary
Claus Gittinger <cg@exept.de>
parents: 1292
diff changeset
   536
     - notice, ST/X does not (for now) distinguish between proceedable and
60ea3687ee49 commentary
Claus Gittinger <cg@exept.de>
parents: 1292
diff changeset
   537
       non proceedable exceptions.
622
a17084b7ac06 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 530
diff changeset
   538
     The argument, aParameter is passed as parameter.
a17084b7ac06 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 530
diff changeset
   539
     XXX: I am not certain, if this is the correct behavior (seen in remoteInvocation-goodie)"
a17084b7ac06 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 530
diff changeset
   540
a17084b7ac06 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 530
diff changeset
   541
    ^ (Exception 
1326
60ea3687ee49 commentary
Claus Gittinger <cg@exept.de>
parents: 1292
diff changeset
   542
              signal:self
60ea3687ee49 commentary
Claus Gittinger <cg@exept.de>
parents: 1292
diff changeset
   543
              parameter:aParameter 
1362
36e887173783 dok & errorString passing fixed (include parameter)
Claus Gittinger <cg@exept.de>
parents: 1326
diff changeset
   544
              errorString:(self errorStringFor:nil with:aParameter)
1326
60ea3687ee49 commentary
Claus Gittinger <cg@exept.de>
parents: 1292
diff changeset
   545
              suspendedContext:thisContext sender) raise.
60ea3687ee49 commentary
Claus Gittinger <cg@exept.de>
parents: 1292
diff changeset
   546
1362
36e887173783 dok & errorString passing fixed (include parameter)
Claus Gittinger <cg@exept.de>
parents: 1326
diff changeset
   547
    "Modified: 9.5.1996 / 15:14:24 / cg"
622
a17084b7ac06 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 530
diff changeset
   548
!
a17084b7ac06 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 530
diff changeset
   549
a17084b7ac06 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 530
diff changeset
   550
raiseWith:aParameter errorString:aString
1326
60ea3687ee49 commentary
Claus Gittinger <cg@exept.de>
parents: 1292
diff changeset
   551
    "raise a signal nonproceedable 
60ea3687ee49 commentary
Claus Gittinger <cg@exept.de>
parents: 1292
diff changeset
   552
     - notice, ST/X does not (for now) distinguish between proceedable and
60ea3687ee49 commentary
Claus Gittinger <cg@exept.de>
parents: 1292
diff changeset
   553
       non proceedable exceptions.
622
a17084b7ac06 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 530
diff changeset
   554
     The argument, aString is used as errorString, aParameter is passed
a17084b7ac06 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 530
diff changeset
   555
     as exception parameter."
a17084b7ac06 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 530
diff changeset
   556
a17084b7ac06 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 530
diff changeset
   557
    ^ (Exception 
1326
60ea3687ee49 commentary
Claus Gittinger <cg@exept.de>
parents: 1292
diff changeset
   558
              signal:self
60ea3687ee49 commentary
Claus Gittinger <cg@exept.de>
parents: 1292
diff changeset
   559
              parameter:aParameter 
1362
36e887173783 dok & errorString passing fixed (include parameter)
Claus Gittinger <cg@exept.de>
parents: 1326
diff changeset
   560
              errorString:(self errorStringFor:aString with:aParameter)
1326
60ea3687ee49 commentary
Claus Gittinger <cg@exept.de>
parents: 1292
diff changeset
   561
              suspendedContext:thisContext sender) raise.
60ea3687ee49 commentary
Claus Gittinger <cg@exept.de>
parents: 1292
diff changeset
   562
1362
36e887173783 dok & errorString passing fixed (include parameter)
Claus Gittinger <cg@exept.de>
parents: 1326
diff changeset
   563
    "Modified: 9.5.1996 / 15:14:32 / cg"
1326
60ea3687ee49 commentary
Claus Gittinger <cg@exept.de>
parents: 1292
diff changeset
   564
!
60ea3687ee49 commentary
Claus Gittinger <cg@exept.de>
parents: 1292
diff changeset
   565
60ea3687ee49 commentary
Claus Gittinger <cg@exept.de>
parents: 1292
diff changeset
   566
raiseWith:aParameter errorString:aString in:aContext
60ea3687ee49 commentary
Claus Gittinger <cg@exept.de>
parents: 1292
diff changeset
   567
    "raise a signal nonproceedable 
60ea3687ee49 commentary
Claus Gittinger <cg@exept.de>
parents: 1292
diff changeset
   568
     - notice, ST/X does not (for now) distinguish between proceedable and
60ea3687ee49 commentary
Claus Gittinger <cg@exept.de>
parents: 1292
diff changeset
   569
       non proceedable exceptions.
60ea3687ee49 commentary
Claus Gittinger <cg@exept.de>
parents: 1292
diff changeset
   570
     The argument, aString is used as errorString, aParameter is passed
1608
440faca45e37 comment
Claus Gittinger <cg@exept.de>
parents: 1362
diff changeset
   571
     as exception parameter.
440faca45e37 comment
Claus Gittinger <cg@exept.de>
parents: 1362
diff changeset
   572
     The additional context is passed as the context responsible for the raise,
440faca45e37 comment
Claus Gittinger <cg@exept.de>
parents: 1362
diff changeset
   573
     allowing a raise to mimicri the exception happened somewhere else."
440faca45e37 comment
Claus Gittinger <cg@exept.de>
parents: 1362
diff changeset
   574
1326
60ea3687ee49 commentary
Claus Gittinger <cg@exept.de>
parents: 1292
diff changeset
   575
60ea3687ee49 commentary
Claus Gittinger <cg@exept.de>
parents: 1292
diff changeset
   576
    ^ (Exception 
60ea3687ee49 commentary
Claus Gittinger <cg@exept.de>
parents: 1292
diff changeset
   577
              signal:self
60ea3687ee49 commentary
Claus Gittinger <cg@exept.de>
parents: 1292
diff changeset
   578
              parameter:aParameter 
1362
36e887173783 dok & errorString passing fixed (include parameter)
Claus Gittinger <cg@exept.de>
parents: 1326
diff changeset
   579
              errorString:(self errorStringFor:aString with:aParameter)
1326
60ea3687ee49 commentary
Claus Gittinger <cg@exept.de>
parents: 1292
diff changeset
   580
              suspendedContext:aContext) raise.
60ea3687ee49 commentary
Claus Gittinger <cg@exept.de>
parents: 1292
diff changeset
   581
60ea3687ee49 commentary
Claus Gittinger <cg@exept.de>
parents: 1292
diff changeset
   582
    "Created: 2.5.1996 / 16:37:25 / cg"
1608
440faca45e37 comment
Claus Gittinger <cg@exept.de>
parents: 1362
diff changeset
   583
    "Modified: 26.7.1996 / 16:29:42 / cg"
622
a17084b7ac06 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 530
diff changeset
   584
! !
a17084b7ac06 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 530
diff changeset
   585
1
a27a279701f8 Initial revision
claus
parents:
diff changeset
   586
!Signal methodsFor:'save evaluation'!
a27a279701f8 Initial revision
claus
parents:
diff changeset
   587
622
a17084b7ac06 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 530
diff changeset
   588
catch:aBlock
a17084b7ac06 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 530
diff changeset
   589
     "evaluate the argument, aBlock.
a17084b7ac06 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 530
diff changeset
   590
      If the receiver-signal is raised during evaluation, abort
a17084b7ac06 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 530
diff changeset
   591
      the evaluation and return true; otherwise return false. 
a17084b7ac06 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 530
diff changeset
   592
      This is the catch & throw mechanism found in other languages,
a17084b7ac06 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 530
diff changeset
   593
      where the returned value indicates if an exception occured."
a17084b7ac06 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 530
diff changeset
   594
a17084b7ac06 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 530
diff changeset
   595
      |raiseOccurred|
a17084b7ac06 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 530
diff changeset
   596
a17084b7ac06 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 530
diff changeset
   597
      raiseOccurred := false.
a17084b7ac06 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 530
diff changeset
   598
      self handle:[:ex | raiseOccurred := true. ex return] do:aBlock.
a17084b7ac06 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 530
diff changeset
   599
      ^ raiseOccurred
a17084b7ac06 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 530
diff changeset
   600
a17084b7ac06 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 530
diff changeset
   601
      "
a17084b7ac06 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 530
diff changeset
   602
       Object messageNotUnderstoodSignal catch:[
a17084b7ac06 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 530
diff changeset
   603
	  123 size open   
a17084b7ac06 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 530
diff changeset
   604
       ]
a17084b7ac06 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 530
diff changeset
   605
      "
a17084b7ac06 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 530
diff changeset
   606
!
a17084b7ac06 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 530
diff changeset
   607
1
a27a279701f8 Initial revision
claus
parents:
diff changeset
   608
handle:handleBlock do:aBlock
a27a279701f8 Initial revision
claus
parents:
diff changeset
   609
    "evaluate the argument, aBlock.
a27a279701f8 Initial revision
claus
parents:
diff changeset
   610
     If the receiver-signal is raised during evaluation,
a27a279701f8 Initial revision
claus
parents:
diff changeset
   611
     evaluate the handleBlock passing it an Exception argument.
a27a279701f8 Initial revision
claus
parents:
diff changeset
   612
     The handler may decide how to react to the signal by sending
a27a279701f8 Initial revision
claus
parents:
diff changeset
   613
     a corresponding message to the exception (see there).
a27a279701f8 Initial revision
claus
parents:
diff changeset
   614
     If the signal is not raised, return the value of evaluating
a27a279701f8 Initial revision
claus
parents:
diff changeset
   615
     aBlock."
a27a279701f8 Initial revision
claus
parents:
diff changeset
   616
a27a279701f8 Initial revision
claus
parents:
diff changeset
   617
     ^ aBlock value  "the real logic is in raise/Exception"
95
d22739a0c6e9 *** empty log message ***
claus
parents: 88
diff changeset
   618
d22739a0c6e9 *** empty log message ***
claus
parents: 88
diff changeset
   619
      "
d22739a0c6e9 *** empty log message ***
claus
parents: 88
diff changeset
   620
       Object messageNotUnderstoodSignal handle:[:ex |
159
514c749165c3 *** empty log message ***
claus
parents: 145
diff changeset
   621
	  'oops' printNL.
514c749165c3 *** empty log message ***
claus
parents: 145
diff changeset
   622
	  ex return
95
d22739a0c6e9 *** empty log message ***
claus
parents: 88
diff changeset
   623
       ] do:[
159
514c749165c3 *** empty log message ***
claus
parents: 145
diff changeset
   624
	  123 size open   
95
d22739a0c6e9 *** empty log message ***
claus
parents: 88
diff changeset
   625
       ]
d22739a0c6e9 *** empty log message ***
claus
parents: 88
diff changeset
   626
      "
120
9a2e74ed2f81 added per-process handler
claus
parents: 95
diff changeset
   627
95
d22739a0c6e9 *** empty log message ***
claus
parents: 88
diff changeset
   628
      "
d22739a0c6e9 *** empty log message ***
claus
parents: 88
diff changeset
   629
       |num|
d22739a0c6e9 *** empty log message ***
claus
parents: 88
diff changeset
   630
d22739a0c6e9 *** empty log message ***
claus
parents: 88
diff changeset
   631
       num := 0.
d22739a0c6e9 *** empty log message ***
claus
parents: 88
diff changeset
   632
       Number divisionByZeroSignal handle:[:ex |
159
514c749165c3 *** empty log message ***
claus
parents: 145
diff changeset
   633
	  'oops' printNL.
514c749165c3 *** empty log message ***
claus
parents: 145
diff changeset
   634
	  ex return
95
d22739a0c6e9 *** empty log message ***
claus
parents: 88
diff changeset
   635
       ] do:[
159
514c749165c3 *** empty log message ***
claus
parents: 145
diff changeset
   636
	  123 / num   
95
d22739a0c6e9 *** empty log message ***
claus
parents: 88
diff changeset
   637
       ]
d22739a0c6e9 *** empty log message ***
claus
parents: 88
diff changeset
   638
      "
44
b262907c93ea *** empty log message ***
claus
parents: 27
diff changeset
   639
!
b262907c93ea *** empty log message ***
claus
parents: 27
diff changeset
   640
362
claus
parents: 345
diff changeset
   641
handle:handleBlock from:anObject do:aBlock
claus
parents: 345
diff changeset
   642
    "evaluate the argument, aBlock.
claus
parents: 345
diff changeset
   643
     If the receiver-signal is raised during evaluation,
claus
parents: 345
diff changeset
   644
     and the exception originated from anObject,
claus
parents: 345
diff changeset
   645
     evaluate the handleBlock passing it an Exception argument.
claus
parents: 345
diff changeset
   646
     The handler may decide how to react to the signal by sending
claus
parents: 345
diff changeset
   647
     a corresponding message to the exception (see there).
claus
parents: 345
diff changeset
   648
     If the signal is not raised, return the value of evaluating
claus
parents: 345
diff changeset
   649
     aBlock."
claus
parents: 345
diff changeset
   650
claus
parents: 345
diff changeset
   651
     ^ aBlock value  "the real logic is in raise/Exception"
claus
parents: 345
diff changeset
   652
claus
parents: 345
diff changeset
   653
      "
claus
parents: 345
diff changeset
   654
       the first open will be cought; the second not:
claus
parents: 345
diff changeset
   655
claus
parents: 345
diff changeset
   656
       |o1 o2|
claus
parents: 345
diff changeset
   657
claus
parents: 345
diff changeset
   658
       o1 := 123.
claus
parents: 345
diff changeset
   659
       o2 := nil.
claus
parents: 345
diff changeset
   660
       Object messageNotUnderstoodSignal 
claus
parents: 345
diff changeset
   661
	   handle:
claus
parents: 345
diff changeset
   662
		[:ex |
claus
parents: 345
diff changeset
   663
		    'oops' printNL.
claus
parents: 345
diff changeset
   664
		    ex proceed
claus
parents: 345
diff changeset
   665
		] 
claus
parents: 345
diff changeset
   666
	   from:o1
claus
parents: 345
diff changeset
   667
	   do:
claus
parents: 345
diff changeset
   668
		[
claus
parents: 345
diff changeset
   669
		    o1 open.
claus
parents: 345
diff changeset
   670
		    o2 open
claus
parents: 345
diff changeset
   671
		]
claus
parents: 345
diff changeset
   672
      "
claus
parents: 345
diff changeset
   673
!
claus
parents: 345
diff changeset
   674
419
62f39bdfe99d *** empty log message ***
claus
parents: 406
diff changeset
   675
ignoreIn:aBlock
159
514c749165c3 *** empty log message ***
claus
parents: 145
diff changeset
   676
     "evaluate the argument, aBlock.
514c749165c3 *** empty log message ***
claus
parents: 145
diff changeset
   677
      Ignore the receiver-signal during evaluation - i.e. simply
419
62f39bdfe99d *** empty log message ***
claus
parents: 406
diff changeset
   678
      continue. 
62f39bdfe99d *** empty log message ***
claus
parents: 406
diff changeset
   679
      This makes only sense for some signals, such as UserInterrupt
62f39bdfe99d *** empty log message ***
claus
parents: 406
diff changeset
   680
      or AbortSignal, because continuing after an exception without any cleanup
62f39bdfe99d *** empty log message ***
claus
parents: 406
diff changeset
   681
      often leads to followup-errors."
159
514c749165c3 *** empty log message ***
claus
parents: 145
diff changeset
   682
514c749165c3 *** empty log message ***
claus
parents: 145
diff changeset
   683
      ^ self handle:[:ex | ex proceed] do:aBlock.
514c749165c3 *** empty log message ***
claus
parents: 145
diff changeset
   684
514c749165c3 *** empty log message ***
claus
parents: 145
diff changeset
   685
      "
419
62f39bdfe99d *** empty log message ***
claus
parents: 406
diff changeset
   686
       Object messageNotUnderstoodSignal ignoreIn:[
159
514c749165c3 *** empty log message ***
claus
parents: 145
diff changeset
   687
	  123 size open   
61
claus
parents: 44
diff changeset
   688
       ]
claus
parents: 44
diff changeset
   689
      "
1
a27a279701f8 Initial revision
claus
parents:
diff changeset
   690
! !
a27a279701f8 Initial revision
claus
parents:
diff changeset
   691
1608
440faca45e37 comment
Claus Gittinger <cg@exept.de>
parents: 1362
diff changeset
   692
!Signal  class methodsFor:'documentation'!
1249
2d5d0edd3359 commentary
Claus Gittinger <cg@exept.de>
parents: 854
diff changeset
   693
2d5d0edd3359 commentary
Claus Gittinger <cg@exept.de>
parents: 854
diff changeset
   694
version
1610
2c076ee64e11 added #raiseErrorString:in:
Claus Gittinger <cg@exept.de>
parents: 1608
diff changeset
   695
    ^ '$Header: /cvs/stx/stx/libbasic/Signal.st,v 1.38 1996-07-26 14:44:57 cg Exp $'
1249
2d5d0edd3359 commentary
Claus Gittinger <cg@exept.de>
parents: 854
diff changeset
   696
! !
622
a17084b7ac06 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 530
diff changeset
   697
Signal initialize!