Update usages of global ... change-at to use the new change-global combinator
parent
59bec433f4
commit
9bb70c2c4d
|
@ -71,7 +71,7 @@ ERROR: bad-alarm-frequency frequency ;
|
|||
] when* ;
|
||||
|
||||
: init-alarms ( -- )
|
||||
alarms global [ cancel-alarms <min-heap> ] change-at
|
||||
alarms [ cancel-alarms <min-heap> ] change-global
|
||||
[ alarm-thread-loop t ] "Alarms" spawn-server
|
||||
alarm-thread set-global ;
|
||||
|
||||
|
|
|
@ -7,7 +7,7 @@ compiler.units lexer init ;
|
|||
IN: cocoa
|
||||
|
||||
: (remember-send) ( selector variable -- )
|
||||
global [ dupd ?set-at ] change-at ;
|
||||
[ dupd ?set-at ] change-global ;
|
||||
|
||||
SYMBOL: sent-messages
|
||||
|
||||
|
|
|
@ -151,8 +151,8 @@ SYMBOL: event-stream-callbacks
|
|||
\ event-stream-counter counter ;
|
||||
|
||||
[
|
||||
event-stream-callbacks global
|
||||
[ [ drop expired? not ] assoc-filter H{ } assoc-like ] change-at
|
||||
event-stream-callbacks
|
||||
[ [ drop expired? not ] assoc-filter H{ } assoc-like ] change-global
|
||||
] "core-foundation" add-init-hook
|
||||
|
||||
: add-event-source-callback ( quot -- id )
|
||||
|
|
|
@ -7,7 +7,7 @@ IN: ui.tools.common
|
|||
|
||||
SYMBOL: tool-dims
|
||||
|
||||
tool-dims global [ H{ } clone or ] change-at
|
||||
tool-dims [ H{ } clone ] initialize
|
||||
|
||||
TUPLE: tool < track ;
|
||||
|
||||
|
|
|
@ -28,7 +28,7 @@ SYMBOL: windows
|
|||
[ [ length 1- dup 1- ] keep exchange ] [ drop ] if ;
|
||||
|
||||
: unregister-window ( handle -- )
|
||||
windows global [ [ first = not ] with filter ] change-at ;
|
||||
windows [ [ first = not ] with filter ] change-global ;
|
||||
|
||||
: raised-window ( world -- )
|
||||
windows get-global
|
||||
|
|
|
@ -842,7 +842,7 @@ SYMBOLS:
|
|||
[ define-constants ] "windows.dinput.constants" add-init-hook
|
||||
|
||||
: uninitialize ( variable quot -- )
|
||||
[ global ] dip '[ _ when* f ] change-at ; inline
|
||||
'[ _ when* f ] change-global ; inline
|
||||
|
||||
: free-dinput-constants ( -- )
|
||||
{
|
||||
|
|
|
@ -14,7 +14,8 @@ ARTICLE: "namespaces-change" "Changing variable values"
|
|||
{ $subsection off }
|
||||
{ $subsection inc }
|
||||
{ $subsection dec }
|
||||
{ $subsection change } ;
|
||||
{ $subsection change }
|
||||
{ $subsection change-global } ;
|
||||
|
||||
ARTICLE: "namespaces-global" "Global variables"
|
||||
{ $subsection namespace }
|
||||
|
@ -73,6 +74,11 @@ HELP: change
|
|||
{ $description "Applies the quotation to the old value of the variable, and assigns the resulting value to the variable." }
|
||||
{ $side-effects "variable" } ;
|
||||
|
||||
HELP: change-global
|
||||
{ $values { "variable" "a variable, by convention a symbol" } { "quot" { $quotation "( old -- new )" } } }
|
||||
{ $description "Applies the quotation to the old value of the global variable, and assigns the resulting value to the global variable." }
|
||||
{ $side-effects "variable" } ;
|
||||
|
||||
HELP: +@
|
||||
{ $values { "n" "a number" } { "variable" "a variable, by convention a symbol" } }
|
||||
{ $description "Adds " { $snippet "n" } " to the value of the variable. A variable value of " { $link f } " is interpreted as being zero." }
|
||||
|
|
|
@ -24,13 +24,13 @@ PRIVATE>
|
|||
: get-global ( variable -- value ) global at ;
|
||||
: set-global ( value variable -- ) global set-at ;
|
||||
: change ( variable quot -- ) [ [ get ] keep ] dip dip set ; inline
|
||||
: change-global ( var quot -- ) [ [ get-global ] keep ] dip dip set-global ; inline
|
||||
: change-global ( variable quot -- ) [ global ] dip change-at ; inline
|
||||
: +@ ( n variable -- ) [ 0 or + ] change ;
|
||||
: inc ( variable -- ) 1 swap +@ ; inline
|
||||
: dec ( variable -- ) -1 swap +@ ; inline
|
||||
: bind ( ns quot -- ) swap >n call ndrop ; inline
|
||||
: counter ( variable -- n ) global [ 0 or 1+ dup ] change-at ;
|
||||
: counter ( variable -- n ) [ 0 or 1+ dup ] change-global ;
|
||||
: make-assoc ( quot exemplar -- hash ) 20 swap new-assoc [ swap bind ] keep ; inline
|
||||
: with-scope ( quot -- ) 5 <hashtable> swap bind ; inline
|
||||
: with-variable ( value key quot -- ) [ associate ] dip bind ; inline
|
||||
: initialize ( variable quot -- ) [ global ] dip [ unless* ] curry change-at ; inline
|
||||
: initialize ( variable quot -- ) [ unless* ] curry change-global ; inline
|
|
@ -22,7 +22,7 @@ SYMBOLS: +dinput+ +keyboard-device+ +keyboard-state+
|
|||
+dinput+ set-global ;
|
||||
|
||||
: delete-dinput ( -- )
|
||||
+dinput+ global [ com-release f ] change-at ;
|
||||
+dinput+ [ com-release f ] change-global ;
|
||||
|
||||
: device-for-guid ( guid -- device )
|
||||
+dinput+ get swap f <void*>
|
||||
|
@ -172,10 +172,8 @@ TUPLE: window-rect < rect window-loc ;
|
|||
[ +device-change-window+ set-global ] bi ;
|
||||
|
||||
: close-device-change-window ( -- )
|
||||
+device-change-handle+ global
|
||||
[ UnregisterDeviceNotification drop f ] change-at
|
||||
+device-change-window+ global
|
||||
[ DestroyWindow win32-error=0/f f ] change-at ;
|
||||
+device-change-handle+ [ UnregisterDeviceNotification drop f ] change-global
|
||||
+device-change-window+ [ DestroyWindow win32-error=0/f f ] change-global ;
|
||||
|
||||
: add-wm-devicechange ( -- )
|
||||
[ 4dup handle-wm-devicechange DefWindowProc ]
|
||||
|
@ -185,14 +183,11 @@ TUPLE: window-rect < rect window-loc ;
|
|||
WM_DEVICECHANGE wm-handlers get-global delete-at ;
|
||||
|
||||
: release-controllers ( -- )
|
||||
+controller-devices+ global [
|
||||
[ drop com-release ] assoc-each f
|
||||
] change-at
|
||||
+controller-devices+ [ [ drop com-release ] assoc-each f ] change-global
|
||||
f +controller-guids+ set-global ;
|
||||
|
||||
: release-keyboard ( -- )
|
||||
+keyboard-device+ global
|
||||
[ com-release f ] change-at
|
||||
+keyboard-device+ [ com-release f ] change-global
|
||||
f +keyboard-state+ set-global ;
|
||||
|
||||
M: dinput-game-input-backend (open-game-input)
|
||||
|
|
|
@ -239,7 +239,7 @@ M: iokit-game-input-backend (reset-game-input)
|
|||
|
||||
M: iokit-game-input-backend (close-game-input)
|
||||
+hid-manager+ get-global [
|
||||
+hid-manager+ global [
|
||||
+hid-manager+ [
|
||||
[
|
||||
CFRunLoopGetMain CFRunLoopDefaultMode
|
||||
IOHIDManagerUnscheduleFromRunLoop
|
||||
|
@ -247,7 +247,7 @@ M: iokit-game-input-backend (close-game-input)
|
|||
[ 0 IOHIDManagerClose drop ]
|
||||
[ CFRelease ] tri
|
||||
f
|
||||
] change-at
|
||||
] change-global
|
||||
f +keyboard-state+ set-global
|
||||
f +controller-states+ set-global
|
||||
] when ;
|
||||
|
|
|
@ -56,9 +56,6 @@ SYMBOL: *calling*
|
|||
: subtract-overhead ( {oldtime,n} overhead -- {newtime,n} )
|
||||
[ first2 ] dip
|
||||
swap [ * - ] keep 2array ;
|
||||
|
||||
: change-global ( variable quot -- )
|
||||
global swap change-at ; inline
|
||||
|
||||
: (correct-for-timing-overhead) ( timingshash -- timingshash )
|
||||
time-dummy-word [ subtract-overhead ] curry assoc-map ;
|
||||
|
|
Loading…
Reference in New Issue