]> gitweb.factorcode.org Git - factor.git/commitdiff
vocabs: change vocabs-changed to be vocab-changed and take a vocab argument.
authorJohn Benediktsson <mrjbq7@gmail.com>
Mon, 13 Aug 2012 19:05:42 +0000 (12:05 -0700)
committerJohn Benediktsson <mrjbq7@gmail.com>
Mon, 13 Aug 2012 19:05:42 +0000 (12:05 -0700)
basis/vocabs/cache/cache.factor
basis/vocabs/refresh/monitor/monitor.factor
core/vocabs/loader/loader.factor
core/vocabs/vocabs.factor

index 1f62f02ddee23d0924f6231efc06309bf5abf67c..071707462399b9442682c0476745fb12c1a50f26 100644 (file)
@@ -1,11 +1,11 @@
 ! Copyright (C) 2009 Slava Pestov.
 ! See http://factorcode.org/license.txt for BSD license.
-USING: assocs kernel namespaces memoize init vocabs
+USING: assocs kernel namespaces memoize init sequences vocabs
 vocabs.hierarchy vocabs.loader vocabs.metadata vocabs.refresh ;
 IN: vocabs.cache
 
-: reset-cache ( -- )
-    root-cache get-global clear-assoc
+: reset-cache ( vocab -- )
+    vocab-name root-cache get-global delete-at
     \ vocab-file-contents reset-memoized
     \ all-vocabs-recursive reset-memoized
     \ all-authors reset-memoized
@@ -13,7 +13,7 @@ IN: vocabs.cache
 
 SINGLETON: cache-observer
 
-M: cache-observer vocabs-changed drop reset-cache ;
+M: cache-observer vocab-changed drop reset-cache ;
 
 [
     f changed-vocabs set-global
index c6d55b047ead4664adf693706320aa7d0d5163f1..3f15bb951e7ad2acf9b79d2aed00954dcb157179 100644 (file)
@@ -31,7 +31,10 @@ TR: convert-separators "/\\" ".." ;
 : monitor-loop ( monitor -- )
     #! On OS X, monitors give us the full path, so we chop it
     #! off if its there.
-    [ next-change path>> path>vocab changed-vocab reset-cache ]
+    [
+        next-change path>> path>vocab
+        [ changed-vocab ] [ reset-cache ] bi
+    ]
     [ monitor-loop ]
     bi ;
 
index 1c4b07290b2e8f8068caccb63a5b41c0b5b1e7e5..47fe95e747d670b53231629d78ec1fb6dca2e883 100644 (file)
@@ -26,7 +26,6 @@ SYMBOL: add-vocab-root-hook
     [ add-vocab-root-hook get-global call( root -- ) ] bi ;
 
 SYMBOL: root-cache
-
 root-cache [ H{ } clone ] initialize
 
 ERROR: not-found-in-roots path ;
@@ -69,7 +68,6 @@ SYMBOL: load-help?
 
 ! Defined by vocabs.metadata
 SYMBOL: check-vocab-hook
-
 check-vocab-hook [ [ drop ] ] initialize
 
 <PRIVATE
index e2a9b895e7e688e1c640f53f3bbeb67d68f9c1bb..f86dcda135540db2a72f91d4839a73760c6c40f0 100644 (file)
@@ -79,7 +79,7 @@ M: f vocab-main ;
 
 SYMBOL: vocab-observers
 
-GENERIC: vocabs-changed ( obj -- )
+GENERIC: vocab-changed ( vocab obj -- )
 
 : add-vocab-observer ( obj -- )
     vocab-observers get push ;
@@ -87,13 +87,13 @@ GENERIC: vocabs-changed ( obj -- )
 : remove-vocab-observer ( obj -- )
     vocab-observers get remove-eq! drop ;
 
-: notify-vocab-observers ( -- )
-    vocab-observers get [ vocabs-changed ] each ;
+: notify-vocab-observers ( vocab -- )
+    vocab-observers get [ vocab-changed ] with each ;
 
 : create-vocab ( name -- vocab )
     check-vocab-name
     dictionary get [ <vocab> ] cache
-    notify-vocab-observers ;
+    dup notify-vocab-observers ;
 
 ERROR: no-vocab name ;
 
@@ -126,8 +126,8 @@ M: object >vocab-link dup lookup-vocab [ ] [ <vocab-link> ] ?if ;
 
 : forget-vocab ( vocab -- )
     [ words forget-all ]
-    [ vocab-name dictionary get delete-at ] bi
-    notify-vocab-observers ;
+    [ vocab-name dictionary get delete-at ]
+    [ notify-vocab-observers ] tri ;
 
 M: vocab-spec forget* forget-vocab ;