]> gitweb.factorcode.org Git - factor.git/commitdiff
fix circular dependency in UI
authorSlava Pestov <slava@factorcode.org>
Sat, 19 Feb 2005 00:02:06 +0000 (00:02 +0000)
committerSlava Pestov <slava@factorcode.org>
Sat, 19 Feb 2005 00:02:06 +0000 (00:02 +0000)
library/test/tuple.factor
library/tools/heap-stats.factor
library/ui/hand.factor
native/scan.c

index eea3af872ebe6e90bbd0539247074827d8da06de..7a44b3d636575df95185519d2bfa5ea2548f97f8 100644 (file)
@@ -51,3 +51,8 @@ C: quuux-tuple-2
     
     point-x
 ] unit-test
+
+! Ensure we have a fresh word.
+DEFER: losing-eq FORGET: losing-eq
+[ t ] [ DEFER: losing-eq \ losing-eq TUPLE: losing-eq x y ; \ losing-eq eq? ]
+unit-test
index 26273599c9c2361407af6318516e17c598751be1..90dd574d54725611ebc8573a3e8d5f4a3e98a04b 100644 (file)
@@ -4,6 +4,8 @@ IN: memory
 USING: errors generic kernel lists math namespaces prettyprint
 stdio unparser vectors words ;
 
+! Printing an overview of heap usage.
+
 : kb. 1024 /i unparse write " KB" write ;
 
 : (room.) ( free total -- )
@@ -17,18 +19,7 @@ stdio unparser vectors words ;
     "Data space: " write (room.)
     "Code space: " write (room.) ;
 
-: heap-stat. ( type instances bytes -- )
-    dup 0 = [
-        3drop
-    ] [
-        rot builtin-type word-name write ": " write
-        unparse write " bytes, " write
-        unparse write " instances" print
-    ] ifte ;
-
-: heap-stats. ( -- )
-    #! Print heap allocation breakdown.
-    0 heap-stats [ dupd uncons heap-stat. 1 + ] each drop ;
+! Some words for iterating through the heap.
 
 : (each-object) ( quot -- )
     next-object dup [
@@ -47,9 +38,22 @@ stdio unparser vectors words ;
 
 : instances ( class -- list )
     #! Return a list of all instances of a built-in or tuple
-    #! class.
+    #! class in the image.
     [
         [
             dup class pick = [ , ] [ drop ] ifte
         ] each-object drop
     ] make-list ;
+
+: heap-stat. ( type instances bytes -- )
+    dup 0 = [
+        3drop
+    ] [
+        rot builtin-type word-name write ": " write
+        unparse write " bytes, " write
+        unparse write " instances" print
+    ] ifte ;
+
+: heap-stats. ( -- )
+    #! Print heap allocation breakdown.
+    0 heap-stats [ dupd uncons heap-stat. 1 + ] each drop ;
index b8887cdb7e618f02c740fa50d5d0a23eda1d4bbe..c4dddb7bec757d69c712284621dc15b1c8c489ab 100644 (file)
@@ -38,8 +38,6 @@ DEFER: pick-up
     #! exposed facade issue.
     tuck pick-up* dup t = [ drop ] [ nip ] ifte ;
 
-DEFER: world
-
 ! The hand is a special gadget that holds mouse position and
 ! mouse button click state. The hand's parent is the world, but
 ! it is special in that the world does not list it as part of
@@ -47,11 +45,15 @@ DEFER: world
 ! - hand-gadget is the gadget under the mouse position
 ! - hand-clicked is the most recently clicked gadget
 ! - hand-focus is the gadget holding keyboard focus
-TUPLE: hand click-pos clicked buttons gadget focus delegate ;
+TUPLE: hand
+    world
+    click-pos clicked buttons
+    gadget focus delegate ;
 
 C: hand ( world -- hand )
     0 0 0 0 <rectangle> <gadget>
     over set-hand-delegate
+    [ set-hand-world ] 2keep
     [ set-gadget-parent ] 2keep
     [ set-hand-gadget ] keep ;
 
@@ -71,7 +73,7 @@ C: hand ( world -- hand )
 
 : update-hand-gadget ( hand -- )
     #! The hand gadget is the gadget under the hand right now.
-    dup world get pick-up swap set-hand-gadget ;
+    dup dup hand-world pick-up swap set-hand-gadget ;
 
 : fire-motion ( hand -- )
     [ motion ] swap hand-gadget handle-gesture drop ;
index 517a694c76d828f99bf4637326f5261e1961959b..94581f5726c4f86fc7b0e9fba1f11cb18ae18974 100644 (file)
@@ -2,6 +2,7 @@
 
 void primitive_begin_scan(void)
 {
+       primitive_gc();
        heap_scan_ptr = active.base;
        heap_scan_end = active.here;
        heap_scan = true;