Merge branch 'master' of git://factorcode.org/git/factor
commit
e1d540803a
|
|
@ -31,7 +31,7 @@ M: #branch remove-dead-code*
|
||||||
pad-with-bottom >>phi-in-d drop ;
|
pad-with-bottom >>phi-in-d drop ;
|
||||||
|
|
||||||
: live-value-indices ( values -- indices )
|
: live-value-indices ( values -- indices )
|
||||||
[ length ] keep live-values get
|
[ length iota ] keep live-values get
|
||||||
'[ _ nth _ key? ] filter ; inline
|
'[ _ nth _ key? ] filter ; inline
|
||||||
|
|
||||||
: drop-indexed-values ( values indices -- node )
|
: drop-indexed-values ( values indices -- node )
|
||||||
|
|
|
||||||
|
|
@ -5,7 +5,7 @@ io.files io.pathnames io.buffers io.ports io.timeouts
|
||||||
io.backend.unix io.encodings.utf8 unix.linux.inotify assocs
|
io.backend.unix io.encodings.utf8 unix.linux.inotify assocs
|
||||||
namespaces make threads continuations init math math.bitwise
|
namespaces make threads continuations init math math.bitwise
|
||||||
sets alien alien.strings alien.c-types vocabs.loader accessors
|
sets alien alien.strings alien.c-types vocabs.loader accessors
|
||||||
system hashtables destructors unix ;
|
system hashtables destructors unix classes.struct ;
|
||||||
IN: io.monitors.linux
|
IN: io.monitors.linux
|
||||||
|
|
||||||
SYMBOL: watches
|
SYMBOL: watches
|
||||||
|
|
@ -82,30 +82,30 @@ M: linux-monitor dispose* ( monitor -- )
|
||||||
] { } make prune ;
|
] { } make prune ;
|
||||||
|
|
||||||
: parse-event-name ( event -- name )
|
: parse-event-name ( event -- name )
|
||||||
dup inotify-event-len zero?
|
dup len>> zero?
|
||||||
[ drop "" ] [ inotify-event-name utf8 alien>string ] if ;
|
[ drop "" ] [ name>> utf8 alien>string ] if ;
|
||||||
|
|
||||||
: parse-file-notify ( buffer -- path changed )
|
: parse-file-notify ( buffer -- path changed )
|
||||||
dup inotify-event-mask ignore-flags? [
|
dup mask>> ignore-flags? [
|
||||||
drop f f
|
drop f f
|
||||||
] [
|
] [
|
||||||
[ parse-event-name ] [ inotify-event-mask parse-action ] bi
|
[ parse-event-name ] [ mask>> parse-action ] bi
|
||||||
] if ;
|
] if ;
|
||||||
|
|
||||||
: events-exhausted? ( i buffer -- ? )
|
: events-exhausted? ( i buffer -- ? )
|
||||||
fill>> >= ;
|
fill>> >= ;
|
||||||
|
|
||||||
: inotify-event@ ( i buffer -- alien )
|
: inotify-event@ ( i buffer -- inotify-event )
|
||||||
ptr>> <displaced-alien> ;
|
ptr>> <displaced-alien> inotify-event memory>struct ;
|
||||||
|
|
||||||
: next-event ( i buffer -- i buffer )
|
: next-event ( i buffer -- i buffer )
|
||||||
2dup inotify-event@
|
2dup inotify-event@
|
||||||
inotify-event-len "inotify-event" heap-size +
|
len>> inotify-event heap-size +
|
||||||
swap [ + ] dip ;
|
swap [ + ] dip ;
|
||||||
|
|
||||||
: parse-file-notifications ( i buffer -- )
|
: parse-file-notifications ( i buffer -- )
|
||||||
2dup events-exhausted? [ 2drop ] [
|
2dup events-exhausted? [ 2drop ] [
|
||||||
2dup inotify-event@ dup inotify-event-wd wd>monitor
|
2dup inotify-event@ dup wd>> wd>monitor
|
||||||
[ parse-file-notify ] dip queue-change
|
[ parse-file-notify ] dip queue-change
|
||||||
next-event parse-file-notifications
|
next-event parse-file-notifications
|
||||||
] if ;
|
] if ;
|
||||||
|
|
|
||||||
|
|
@ -10,3 +10,4 @@ USING: math.primes.factors sequences tools.test ;
|
||||||
{ { 13 4253 15823 32472893749823741 } } [ 28408516453955558205925627 factors ] unit-test
|
{ { 13 4253 15823 32472893749823741 } } [ 28408516453955558205925627 factors ] unit-test
|
||||||
{ { 1 2 3 4 6 8 12 24 } } [ 24 divisors ] unit-test
|
{ { 1 2 3 4 6 8 12 24 } } [ 24 divisors ] unit-test
|
||||||
{ 24 } [ 360 divisors length ] unit-test
|
{ 24 } [ 360 divisors length ] unit-test
|
||||||
|
{ { 1 } } [ 1 divisors ] unit-test
|
||||||
|
|
|
||||||
|
|
@ -43,5 +43,9 @@ PRIVATE>
|
||||||
} cond ; foldable
|
} cond ; foldable
|
||||||
|
|
||||||
: divisors ( n -- seq )
|
: divisors ( n -- seq )
|
||||||
|
dup 1 = [
|
||||||
|
1array
|
||||||
|
] [
|
||||||
group-factors [ first2 [0,b] [ ^ ] with map ] map
|
group-factors [ first2 [0,b] [ ^ ] with map ] map
|
||||||
[ product ] product-map natural-sort ;
|
[ product ] product-map natural-sort
|
||||||
|
] if ;
|
||||||
|
|
|
||||||
|
|
@ -69,12 +69,16 @@ H{
|
||||||
{ vtruncate { +vector+ -> +vector+ } }
|
{ vtruncate { +vector+ -> +vector+ } }
|
||||||
}
|
}
|
||||||
|
|
||||||
SYMBOL: specializations
|
PREDICATE: vector-word < word vector-words key? ;
|
||||||
|
|
||||||
specializations [ vector-words keys [ V{ } clone ] H{ } map>assoc ] initialize
|
: specializations ( word -- assoc )
|
||||||
|
dup "specializations" word-prop
|
||||||
|
[ ] [ V{ } clone [ "specializations" set-word-prop ] keep ] ?if ;
|
||||||
|
|
||||||
|
M: vector-word subwords specializations values ;
|
||||||
|
|
||||||
: add-specialization ( new-word signature word -- )
|
: add-specialization ( new-word signature word -- )
|
||||||
specializations get at set-at ;
|
specializations set-at ;
|
||||||
|
|
||||||
: word-schema ( word -- schema ) vector-words at ;
|
: word-schema ( word -- schema ) vector-words at ;
|
||||||
|
|
||||||
|
|
@ -98,7 +102,7 @@ specializations [ vector-words keys [ V{ } clone ] H{ } map>assoc ] initialize
|
||||||
] each ;
|
] each ;
|
||||||
|
|
||||||
: find-specialization ( classes word -- word/f )
|
: find-specialization ( classes word -- word/f )
|
||||||
specializations get at
|
specializations
|
||||||
[ first [ class<= ] 2all? ] with find
|
[ first [ class<= ] 2all? ] with find
|
||||||
swap [ second ] when ;
|
swap [ second ] when ;
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -45,7 +45,7 @@ T{ error-type
|
||||||
SYMBOL: file
|
SYMBOL: file
|
||||||
|
|
||||||
: file-failure ( error -- )
|
: file-failure ( error -- )
|
||||||
f file get f failure ;
|
[ f file get ] keep error-line failure ;
|
||||||
|
|
||||||
:: (unit-test) ( output input -- error ? )
|
:: (unit-test) ( output input -- error ? )
|
||||||
[ { } input with-datastack output assert-sequence= f f ] [ t ] recover ;
|
[ { } input with-datastack output assert-sequence= f f ] [ t ] recover ;
|
||||||
|
|
|
||||||
|
|
@ -97,7 +97,7 @@ M: error-renderer column-titles
|
||||||
M: error-renderer column-alignment drop { 0 1 0 0 } ;
|
M: error-renderer column-alignment drop { 0 1 0 0 } ;
|
||||||
|
|
||||||
: sort-errors ( seq -- seq' )
|
: sort-errors ( seq -- seq' )
|
||||||
[ [ [ line#>> ] [ asset>> unparse-short ] bi 2array ] keep ] { } map>assoc
|
[ [ [ line#>> 0 or ] [ asset>> unparse-short ] bi 2array ] keep ] { } map>assoc
|
||||||
sort-keys values ;
|
sort-keys values ;
|
||||||
|
|
||||||
: file-matches? ( error pathname/f -- ? )
|
: file-matches? ( error pathname/f -- ? )
|
||||||
|
|
|
||||||
|
|
@ -1,15 +1,14 @@
|
||||||
! Copyright (C) 2008 Slava Pestov.
|
! Copyright (C) 2008 Slava Pestov.
|
||||||
! See http://factorcode.org/license.txt for BSD license.
|
! See http://factorcode.org/license.txt for BSD license.
|
||||||
USING: alien.syntax math math.bitwise ;
|
USING: alien.syntax math math.bitwise classes.struct ;
|
||||||
IN: unix.linux.inotify
|
IN: unix.linux.inotify
|
||||||
|
|
||||||
C-STRUCT: inotify-event
|
STRUCT: inotify-event
|
||||||
{ "int" "wd" } ! watch descriptor
|
{ wd int }
|
||||||
{ "uint" "mask" } ! watch mask
|
{ mask uint }
|
||||||
{ "uint" "cookie" } ! cookie to synchronize two events
|
{ cookie uint }
|
||||||
{ "uint" "len" } ! length (including nulls) of name
|
{ len uint }
|
||||||
{ "char[0]" "name" } ! stub for possible name
|
{ name char[0] } ;
|
||||||
;
|
|
||||||
|
|
||||||
CONSTANT: IN_ACCESS HEX: 1 ! File was accessed
|
CONSTANT: IN_ACCESS HEX: 1 ! File was accessed
|
||||||
CONSTANT: IN_MODIFY HEX: 2 ! File was modified
|
CONSTANT: IN_MODIFY HEX: 2 ! File was modified
|
||||||
|
|
@ -28,8 +27,8 @@ CONSTANT: IN_UNMOUNT HEX: 2000 ! Backing fs was unmounted
|
||||||
CONSTANT: IN_Q_OVERFLOW HEX: 4000 ! Event queued overflowed
|
CONSTANT: IN_Q_OVERFLOW HEX: 4000 ! Event queued overflowed
|
||||||
CONSTANT: IN_IGNORED HEX: 8000 ! File was ignored
|
CONSTANT: IN_IGNORED HEX: 8000 ! File was ignored
|
||||||
|
|
||||||
: IN_CLOSE ( -- n ) IN_CLOSE_WRITE IN_CLOSE_NOWRITE bitor ; inline ! close
|
: IN_CLOSE ( -- n ) { IN_CLOSE_WRITE IN_CLOSE_NOWRITE } flags ; foldable ! close
|
||||||
: IN_MOVE ( -- n ) IN_MOVED_FROM IN_MOVED_TO bitor ; inline ! moves
|
: IN_MOVE ( -- n ) { IN_MOVED_FROM IN_MOVED_TO } flags ; foldable ! moves
|
||||||
|
|
||||||
CONSTANT: IN_ONLYDIR HEX: 1000000 ! only watch the path if it is a directory
|
CONSTANT: IN_ONLYDIR HEX: 1000000 ! only watch the path if it is a directory
|
||||||
CONSTANT: IN_DONT_FOLLOW HEX: 2000000 ! don't follow a sym link
|
CONSTANT: IN_DONT_FOLLOW HEX: 2000000 ! don't follow a sym link
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue