GDBEventSubscription.st
author Jan Vrany <jan.vrany@fit.cvut.cz>
Mon, 18 Feb 2019 10:49:02 +0000
changeset 176 e734c17e7c37
parent 145 1256a03213cf
child 244 f0e4ddb50242
permissions -rw-r--r--
Use `View >> pushEvent:` or `ApplicationModel >> enqueueMessage:` to post events ...rather than asking for a window sensor and then talking to it. This allows for more flexibility as the object (subscription receiver) can decide how to handle posting of events.
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
91
472a4841a8b6 License this package under 'GNU Lesser General Public License'
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 78
diff changeset
     1
"
472a4841a8b6 License this package under 'GNU Lesser General Public License'
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 78
diff changeset
     2
jv:libgdbs - GNU Debugger Interface Library
472a4841a8b6 License this package under 'GNU Lesser General Public License'
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 78
diff changeset
     3
Copyright (C) 2015-now Jan Vrany
472a4841a8b6 License this package under 'GNU Lesser General Public License'
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 78
diff changeset
     4
472a4841a8b6 License this package under 'GNU Lesser General Public License'
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 78
diff changeset
     5
This library is free software; you can redistribute it and/or
472a4841a8b6 License this package under 'GNU Lesser General Public License'
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 78
diff changeset
     6
modify it under the terms of the GNU Lesser General Public
472a4841a8b6 License this package under 'GNU Lesser General Public License'
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 78
diff changeset
     7
License as published by the Free Software Foundation; either
472a4841a8b6 License this package under 'GNU Lesser General Public License'
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 78
diff changeset
     8
version 2.1 of the License. 
472a4841a8b6 License this package under 'GNU Lesser General Public License'
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 78
diff changeset
     9
472a4841a8b6 License this package under 'GNU Lesser General Public License'
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 78
diff changeset
    10
This library is distributed in the hope that it will be useful,
472a4841a8b6 License this package under 'GNU Lesser General Public License'
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 78
diff changeset
    11
but WITHOUT ANY WARRANTY; without even the implied warranty of
472a4841a8b6 License this package under 'GNU Lesser General Public License'
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 78
diff changeset
    12
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
472a4841a8b6 License this package under 'GNU Lesser General Public License'
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 78
diff changeset
    13
Lesser General Public License for more details.
472a4841a8b6 License this package under 'GNU Lesser General Public License'
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 78
diff changeset
    14
472a4841a8b6 License this package under 'GNU Lesser General Public License'
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 78
diff changeset
    15
You should have received a copy of the GNU Lesser General Public
472a4841a8b6 License this package under 'GNU Lesser General Public License'
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 78
diff changeset
    16
License along with this library; if not, write to the Free Software
472a4841a8b6 License this package under 'GNU Lesser General Public License'
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 78
diff changeset
    17
Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301  USA
472a4841a8b6 License this package under 'GNU Lesser General Public License'
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 78
diff changeset
    18
"
41
fb48207b6104 Fixes in thread's stack mangement. Dispatch events to applications using their UI event loop.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
    19
"{ Package: 'jv:libgdbs' }"
fb48207b6104 Fixes in thread's stack mangement. Dispatch events to applications using their UI event loop.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
    20
78
c24e7d8bc881 BUpdated build files.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 41
diff changeset
    21
"{ NameSpace: Smalltalk }"
c24e7d8bc881 BUpdated build files.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 41
diff changeset
    22
41
fb48207b6104 Fixes in thread's stack mangement. Dispatch events to applications using their UI event loop.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
    23
StrongSubscription subclass:#GDBEventSubscription
fb48207b6104 Fixes in thread's stack mangement. Dispatch events to applications using their UI event loop.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
    24
	instanceVariableNames:''
fb48207b6104 Fixes in thread's stack mangement. Dispatch events to applications using their UI event loop.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
    25
	classVariableNames:''
fb48207b6104 Fixes in thread's stack mangement. Dispatch events to applications using their UI event loop.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
    26
	poolDictionaries:''
fb48207b6104 Fixes in thread's stack mangement. Dispatch events to applications using their UI event loop.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
    27
	category:'GDB-Private'
fb48207b6104 Fixes in thread's stack mangement. Dispatch events to applications using their UI event loop.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
    28
!
fb48207b6104 Fixes in thread's stack mangement. Dispatch events to applications using their UI event loop.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
    29
91
472a4841a8b6 License this package under 'GNU Lesser General Public License'
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 78
diff changeset
    30
!GDBEventSubscription class methodsFor:'documentation'!
472a4841a8b6 License this package under 'GNU Lesser General Public License'
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 78
diff changeset
    31
472a4841a8b6 License this package under 'GNU Lesser General Public License'
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 78
diff changeset
    32
copyright
472a4841a8b6 License this package under 'GNU Lesser General Public License'
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 78
diff changeset
    33
"
472a4841a8b6 License this package under 'GNU Lesser General Public License'
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 78
diff changeset
    34
jv:libgdbs - GNU Debugger Interface Library
472a4841a8b6 License this package under 'GNU Lesser General Public License'
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 78
diff changeset
    35
Copyright (C) 2015-now Jan Vrany
472a4841a8b6 License this package under 'GNU Lesser General Public License'
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 78
diff changeset
    36
472a4841a8b6 License this package under 'GNU Lesser General Public License'
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 78
diff changeset
    37
This library is free software; you can redistribute it and/or
472a4841a8b6 License this package under 'GNU Lesser General Public License'
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 78
diff changeset
    38
modify it under the terms of the GNU Lesser General Public
472a4841a8b6 License this package under 'GNU Lesser General Public License'
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 78
diff changeset
    39
License as published by the Free Software Foundation; either
472a4841a8b6 License this package under 'GNU Lesser General Public License'
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 78
diff changeset
    40
version 2.1 of the License. 
472a4841a8b6 License this package under 'GNU Lesser General Public License'
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 78
diff changeset
    41
472a4841a8b6 License this package under 'GNU Lesser General Public License'
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 78
diff changeset
    42
This library is distributed in the hope that it will be useful,
472a4841a8b6 License this package under 'GNU Lesser General Public License'
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 78
diff changeset
    43
but WITHOUT ANY WARRANTY; without even the implied warranty of
472a4841a8b6 License this package under 'GNU Lesser General Public License'
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 78
diff changeset
    44
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
472a4841a8b6 License this package under 'GNU Lesser General Public License'
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 78
diff changeset
    45
Lesser General Public License for more details.
472a4841a8b6 License this package under 'GNU Lesser General Public License'
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 78
diff changeset
    46
472a4841a8b6 License this package under 'GNU Lesser General Public License'
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 78
diff changeset
    47
You should have received a copy of the GNU Lesser General Public
472a4841a8b6 License this package under 'GNU Lesser General Public License'
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 78
diff changeset
    48
License along with this library; if not, write to the Free Software
472a4841a8b6 License this package under 'GNU Lesser General Public License'
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 78
diff changeset
    49
Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301  USA
472a4841a8b6 License this package under 'GNU Lesser General Public License'
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 78
diff changeset
    50
"
472a4841a8b6 License this package under 'GNU Lesser General Public License'
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 78
diff changeset
    51
! !
472a4841a8b6 License this package under 'GNU Lesser General Public License'
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 78
diff changeset
    52
41
fb48207b6104 Fixes in thread's stack mangement. Dispatch events to applications using their UI event loop.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
    53
!GDBEventSubscription class methodsFor:'private'!
fb48207b6104 Fixes in thread's stack mangement. Dispatch events to applications using their UI event loop.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
    54
fb48207b6104 Fixes in thread's stack mangement. Dispatch events to applications using their UI event loop.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
    55
blockFor: anObject withSelector: aSelector
fb48207b6104 Fixes in thread's stack mangement. Dispatch events to applications using their UI event loop.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
    56
fb48207b6104 Fixes in thread's stack mangement. Dispatch events to applications using their UI event loop.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
    57
    | args |
fb48207b6104 Fixes in thread's stack mangement. Dispatch events to applications using their UI event loop.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
    58
    args := aSelector numArgs.      
fb48207b6104 Fixes in thread's stack mangement. Dispatch events to applications using their UI event loop.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
    59
fb48207b6104 Fixes in thread's stack mangement. Dispatch events to applications using their UI event loop.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
    60
    anObject isView ifTrue:[ 
176
e734c17e7c37 Use `View >> pushEvent:` or `ApplicationModel >> enqueueMessage:` to post events
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 145
diff changeset
    61
        args = 0 ifTrue: [ ^[ anObject pushEvent: aSelector ] ].
e734c17e7c37 Use `View >> pushEvent:` or `ApplicationModel >> enqueueMessage:` to post events
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 145
diff changeset
    62
        args = 1 ifTrue: [ ^[ :anAnnouncement | anObject pushEvent: aSelector with: anAnnouncement ] ].
e734c17e7c37 Use `View >> pushEvent:` or `ApplicationModel >> enqueueMessage:` to post events
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 145
diff changeset
    63
        args = 2 ifTrue: [ ^[ :anAnnouncement :anAnnouncer | anObject pushEvent: aSelector with: anAnnouncement with: anAnnouncer ] ].
41
fb48207b6104 Fixes in thread's stack mangement. Dispatch events to applications using their UI event loop.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
    64
        self error: 'Couldn''t create block'.        
fb48207b6104 Fixes in thread's stack mangement. Dispatch events to applications using their UI event loop.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
    65
    ].
145
1256a03213cf Fix `GDBEventSubscription` w.r.t. uninitialized / partially initialized applications
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 91
diff changeset
    66
1256a03213cf Fix `GDBEventSubscription` w.r.t. uninitialized / partially initialized applications
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 91
diff changeset
    67
    "/ If the observer (receiver of events) is an application,
1256a03213cf Fix `GDBEventSubscription` w.r.t. uninitialized / partially initialized applications
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 91
diff changeset
    68
    "/ then push the event processing to application's event
1256a03213cf Fix `GDBEventSubscription` w.r.t. uninitialized / partially initialized applications
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 91
diff changeset
    69
    "/ queue. This avoids blocking of event dispatcher and ensures
1256a03213cf Fix `GDBEventSubscription` w.r.t. uninitialized / partially initialized applications
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 91
diff changeset
    70
    "/ that UI is synchronized.
1256a03213cf Fix `GDBEventSubscription` w.r.t. uninitialized / partially initialized applications
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 91
diff changeset
    71
    "/
1256a03213cf Fix `GDBEventSubscription` w.r.t. uninitialized / partially initialized applications
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 91
diff changeset
    72
    "/ However, we must be carefull since application windows may 
1256a03213cf Fix `GDBEventSubscription` w.r.t. uninitialized / partially initialized applications
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 91
diff changeset
    73
    "/ not yet be opened or fully initialized so we have to check
1256a03213cf Fix `GDBEventSubscription` w.r.t. uninitialized / partially initialized applications
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 91
diff changeset
    74
    "/ for existence of sensor. If application/window is not fully 
1256a03213cf Fix `GDBEventSubscription` w.r.t. uninitialized / partially initialized applications
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 91
diff changeset
    75
    "/ initialized, process the event as usual.
1256a03213cf Fix `GDBEventSubscription` w.r.t. uninitialized / partially initialized applications
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 91
diff changeset
    76
    (anObject isKindOf: ApplicationModel) ifTrue:[
176
e734c17e7c37 Use `View >> pushEvent:` or `ApplicationModel >> enqueueMessage:` to post events
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 145
diff changeset
    77
        args = 0 ifTrue: [  ^[ anObject enqueueMessage: aSelector ] ].
e734c17e7c37 Use `View >> pushEvent:` or `ApplicationModel >> enqueueMessage:` to post events
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 145
diff changeset
    78
        args = 1 ifTrue: [  ^[ :anAnnouncement | anObject enqueueMessage: aSelector with: anAnnouncement ] ].
e734c17e7c37 Use `View >> pushEvent:` or `ApplicationModel >> enqueueMessage:` to post events
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 145
diff changeset
    79
        args = 1 ifTrue: [  ^[ :anAnnouncement :anAnnouncer | anObject enqueueMessage: aSelector arguments: (Array with: anAnnouncement with: anAnnouncer) ] ].
41
fb48207b6104 Fixes in thread's stack mangement. Dispatch events to applications using their UI event loop.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
    80
        self error: 'Couldn''t create block'.        
fb48207b6104 Fixes in thread's stack mangement. Dispatch events to applications using their UI event loop.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
    81
    ].
fb48207b6104 Fixes in thread's stack mangement. Dispatch events to applications using their UI event loop.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
    82
    ^ super blockFor: anObject withSelector: aSelector
fb48207b6104 Fixes in thread's stack mangement. Dispatch events to applications using their UI event loop.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
    83
fb48207b6104 Fixes in thread's stack mangement. Dispatch events to applications using their UI event loop.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
    84
    "Created: / 18-09-2014 / 00:10:31 / Jan Vrany <jan.vrany@fit.cvut.cz>"
145
1256a03213cf Fix `GDBEventSubscription` w.r.t. uninitialized / partially initialized applications
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 91
diff changeset
    85
    "Modified: / 01-10-2018 / 17:30:56 / jv"
176
e734c17e7c37 Use `View >> pushEvent:` or `ApplicationModel >> enqueueMessage:` to post events
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 145
diff changeset
    86
    "Modified: / 18-02-2019 / 10:35:18 / Jan Vrany <jan.vrany@fit.cvut.cz>"
41
fb48207b6104 Fixes in thread's stack mangement. Dispatch events to applications using their UI event loop.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
    87
! !
fb48207b6104 Fixes in thread's stack mangement. Dispatch events to applications using their UI event loop.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
    88
145
1256a03213cf Fix `GDBEventSubscription` w.r.t. uninitialized / partially initialized applications
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 91
diff changeset
    89
!GDBEventSubscription class methodsFor:'documentation'!
1256a03213cf Fix `GDBEventSubscription` w.r.t. uninitialized / partially initialized applications
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 91
diff changeset
    90
1256a03213cf Fix `GDBEventSubscription` w.r.t. uninitialized / partially initialized applications
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 91
diff changeset
    91
version_HG
1256a03213cf Fix `GDBEventSubscription` w.r.t. uninitialized / partially initialized applications
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 91
diff changeset
    92
1256a03213cf Fix `GDBEventSubscription` w.r.t. uninitialized / partially initialized applications
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 91
diff changeset
    93
    ^ '$Changeset: <not expanded> $'
1256a03213cf Fix `GDBEventSubscription` w.r.t. uninitialized / partially initialized applications
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 91
diff changeset
    94
! !
1256a03213cf Fix `GDBEventSubscription` w.r.t. uninitialized / partially initialized applications
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 91
diff changeset
    95