]> gitweb.factorcode.org Git - factor.git/commitdiff
Update usages of global ... change-at to use the new change-global combinator
authorSlava Pestov <slava@slava-pestovs-macbook-pro.local>
Fri, 1 May 2009 02:38:14 +0000 (21:38 -0500)
committerSlava Pestov <slava@slava-pestovs-macbook-pro.local>
Fri, 1 May 2009 02:38:14 +0000 (21:38 -0500)
basis/alarms/alarms.factor
basis/cocoa/cocoa.factor
basis/core-foundation/fsevents/fsevents.factor
basis/ui/tools/common/common.factor
basis/ui/ui.factor
basis/windows/dinput/constants/constants.factor
core/namespaces/namespaces-docs.factor
core/namespaces/namespaces.factor
extra/game-input/dinput/dinput.factor
extra/game-input/iokit/iokit.factor
extra/wordtimer/wordtimer.factor

index 9cc05b41591cd8974def94d2f10646a3f7598e8a..f9fdce806f5f606bd1ef5532e19ab42f8ac3694c 100644 (file)
@@ -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 ;
 
index 69d698f9b10c1943a4170eebe2f92d64ddd59cf8..3e933e66430a231cf6794b5c9374af1a21180d4c 100644 (file)
@@ -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
 
index 46f6639ab8f4b6b57693659944b1ec591dc9c092..1956cd9c20d4d6761d978fa8afa4ff765652a3f0 100644 (file)
@@ -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 )
index e581e72e24856a6cfd468756e6f4ea92e33fdcaf..95af20ec72e0ea519a75e9a708b7676ae036f1be 100644 (file)
@@ -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 ;
 
index 8be486cb1a32fc646f35aa7183d002dfb0974102..09403cb2d2784b9f619799d4dd711e263a8e7e6f 100644 (file)
@@ -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
index 0f95c6d6839560737d9f0d560f86768cfee5d8f7..74238abed2aa7681f0638906447c01c8846a7eae 100755 (executable)
@@ -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 ( -- )
     {
index 74d7c58963807d4c8552a6612c6b693b48a3a90e..de4737e7b029d956a5808d75676cec46285f13ce 100644 (file)
@@ -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." }
index 977e5a296167b815c91a30c67f4d6fe2c2404f2b..310816cbf757b226113fb31763ee5e51f6963151 100644 (file)
@@ -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
\ No newline at end of file
+: initialize ( variable quot -- ) [ unless* ] curry change-global ; inline
\ No newline at end of file
index ce87c1223786a2611e1ff4578dde6020cb3a8caa..20815859ab341a624d087363630270a3f5536221 100755 (executable)
@@ -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)
index 254ed61ab0516543c9abe32ee88a5ac409cd6516..2ded2638996402ff893906d1ec5f1a2c387a39ea 100755 (executable)
@@ -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 ;
index 11a1e325c3f857961c350fadae02c20c6e98c0b3..e02701b6909674772ca6b92b514c929f25f18ffb 100644 (file)
@@ -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 ;