vocabs: change vocabs-changed to be vocab-changed and take a vocab argument.
parent
0d9c7df8e2
commit
33c4e19ff9
|
@ -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
|
||||
|
|
|
@ -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 ;
|
||||
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -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 ;
|
||||
|
||||
|
|
Loading…
Reference in New Issue