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