models: some cleanup.
parent
b360860ecd
commit
439649e707
|
@ -30,10 +30,10 @@ GENERIC: model-activated ( model -- )
|
||||||
M: model model-activated drop ;
|
M: model model-activated drop ;
|
||||||
|
|
||||||
: ref-model ( model -- n )
|
: ref-model ( model -- n )
|
||||||
[ 1 + ] change-ref ref>> ;
|
[ 1 + dup ] change-ref drop ;
|
||||||
|
|
||||||
: unref-model ( model -- n )
|
: unref-model ( model -- n )
|
||||||
[ 1 - ] change-ref ref>> ;
|
[ 1 - dup ] change-ref drop ;
|
||||||
|
|
||||||
: activate-model ( model -- )
|
: activate-model ( model -- )
|
||||||
dup ref-model 1 = [
|
dup ref-model 1 = [
|
||||||
|
@ -57,17 +57,17 @@ DEFER: remove-connection
|
||||||
GENERIC: model-changed ( model observer -- )
|
GENERIC: model-changed ( model observer -- )
|
||||||
|
|
||||||
: add-connection ( observer model -- )
|
: add-connection ( observer model -- )
|
||||||
dup connections>> empty? [ dup activate-model ] when
|
dup connections>>
|
||||||
connections>> push ;
|
[ empty? [ activate-model ] [ drop ] if ]
|
||||||
|
[ push ] bi ;
|
||||||
|
|
||||||
: remove-connection ( observer model -- )
|
: remove-connection ( observer model -- )
|
||||||
[ connections>> remove! drop ] keep
|
[ connections>> remove! ] keep swap
|
||||||
dup connections>> empty? [ dup deactivate-model ] when
|
empty? [ deactivate-model ] [ drop ] if ;
|
||||||
drop ;
|
|
||||||
|
|
||||||
: with-locked-model ( model quot -- )
|
: with-locked-model ( model quot -- )
|
||||||
[ '[ _ t >>locked? @ ] ]
|
[ '[ _ t >>locked? @ ] ]
|
||||||
[ drop '[ _ f >>locked? drop ] ]
|
[ drop '[ f _ locked?<< ] ]
|
||||||
2bi [ ] cleanup ; inline
|
2bi [ ] cleanup ; inline
|
||||||
|
|
||||||
GENERIC: update-model ( model -- )
|
GENERIC: update-model ( model -- )
|
||||||
|
|
Loading…
Reference in New Issue