Merge git://factorcode.org/git/factor

db4
Eduardo Cavazos 2008-02-05 19:41:26 -06:00
commit 85938ad81c
30 changed files with 150 additions and 78 deletions

View File

@ -63,8 +63,8 @@ default:
@echo "macosx-ppc"
@echo "solaris-x86-32"
@echo "solaris-x86-64"
@echo "windows-ce-arm"
@echo "windows-nt-x86-32"
@echo "wince-arm"
@echo "winnt-x86-32"
@echo ""
@echo "Additional modifiers:"
@echo ""
@ -122,10 +122,10 @@ solaris-x86-32:
solaris-x86-64:
$(MAKE) $(EXECUTABLE) CONFIG=vm/Config.solaris.x86.64
windows-nt-x86-32:
winnt-x86-32:
$(MAKE) $(EXECUTABLE) CONFIG=vm/Config.windows.nt.x86.32
windows-ce-arm:
wince-arm:
$(MAKE) $(EXECUTABLE) CONFIG=vm/Config.windows.ce.arm
macosx.app: factor

3
core/system/system-docs.factor Normal file → Executable file
View File

@ -51,7 +51,8 @@ HELP: os
"openbsd"
"netbsd"
"solaris"
"windows"
"wince"
"winnt"
}
} ;

2
core/system/system.factor Normal file → Executable file
View File

@ -22,7 +22,7 @@ splitting assocs ;
os "wince" = ; foldable
: winnt? ( -- ? )
os "windows" = ; foldable
os "winnt" = ; foldable
: windows? ( -- ? )
wince? winnt? or ; foldable

View File

@ -124,15 +124,12 @@ HELP: refresh
{ $values { "prefix" string } }
{ $description "Reloads source files and documentation belonging to loaded vocabularies whose names are prefixed by " { $snippet "prefix" } " which have been modified on disk." } ;
HELP: refresh-all-error
{ $values { "vocabs" "a sequence of vocabularies" } }
{ $description "Throws a " { $link require-all-error } "." }
{ $error-description "Thrown by " { $link require-all } " if one or more vocabulary failed to load." } ;
HELP: refresh-all
{ $description "Reloads source files and documentation for all loaded vocabularies which have been modified on disk." } ;
{ refresh refresh-all } related-words
HELP: vocab-file-contents
{ $values { "vocab" "a vocabulary specifier" } { "name" string } { "seq" "a sequence of lines, or " { $link f } } }
{ $description "Outputs the contents of the file named " { $snippet "name" } " from the vocabulary's directory, or " { $link f } " if the file does not exist." } ;
HELP: set-vocab-file-contents
{ $values { "seq" "a sequence of lines" } { "vocab" "a vocabulary specifier" } { "name" string } }
{ $description "Stores a sequence of lines to the file named " { $snippet "name" } " from the vocabulary's directory." } ;

View File

@ -148,16 +148,31 @@ SYMBOL: load-help?
dup update-roots
dup modified-sources swap modified-docs ;
: require-restart { { "Ignore this vocabulary" t } } ;
: load-error. ( vocab error -- )
"While loading " swap dup >vocab-link write-object ":" print
print-error ;
: require-all ( seq -- )
[
TUPLE: require-all-error vocabs ;
: require-all-error ( vocabs -- )
\ require-all-error construct-boa throw ;
M: require-all-error summary
drop "The require-all operation failed" ;
: require-all ( vocabs -- )
dup length 1 = [ first require ] [
[
[ require ]
[ require-restart rethrow-restarts 2drop ]
recover
] each
] with-compiler-errors ;
[
[ [ require ] [ 2array , ] recover ] each
] { } make
dup empty? [ drop ] [
"==== LOAD ERRORS:" print
dup [ nl load-error. ] assoc-each
keys require-all-error
] if
] with-compiler-errors
] if ;
: do-refresh ( modified-sources modified-docs -- )
2dup
@ -190,22 +205,3 @@ load-vocab-hook set-global
M: vocab where vocab-where ;
M: vocab-link where vocab-where ;
: vocab-file-contents ( vocab name -- seq )
vocab-path+ dup [
?resource-path dup exists? [
<file-reader> lines
] [
drop f
] if
] when ;
: set-vocab-file-contents ( seq vocab name -- )
dupd vocab-path+ [
?resource-path
<file-writer> [ [ print ] each ] with-stream
] [
"The " swap vocab-name
" vocabulary was not loaded from the file system"
3append throw
] ?if ;

View File

@ -10,3 +10,5 @@ IN: bootstrap.io
{ [ wince? ] [ "windows.ce" ] }
} cond append require
] when
"vocabs.monitor" require

View File

@ -137,7 +137,7 @@ ARTICLE: "collections" "Collections"
{ $subsection "graphs" }
{ $subsection "buffers" } ;
USING: io.sockets io.launcher io.mmap io.monitor ;
USING: io.sockets io.launcher io.mmap io.monitors ;
ARTICLE: "io" "Input and output"
{ $subsection "streams" }
@ -155,7 +155,7 @@ ARTICLE: "io" "Input and output"
"Advanced features:"
{ $subsection "io.launcher" }
{ $subsection "io.mmap" }
{ $subsection "io.monitor" } ;
{ $subsection "io.monitors" } ;
ARTICLE: "tools" "Developer tools"
{ $subsection "tools.annotations" }

3
extra/help/help.factor Normal file → Executable file
View File

@ -96,6 +96,9 @@ M: word set-article-parent swap "help-parent" set-word-prop ;
article-content print-content nl ;
: about ( vocab -- )
dup vocab [ ] [
"No such vocabulary: " swap append throw
] ?if
dup vocab-help [
help
] [

View File

@ -1,4 +1,4 @@
IN: io.monitor
IN: io.monitors
USING: help.markup help.syntax continuations ;
HELP: <monitor>
@ -9,7 +9,7 @@ $nl
HELP: next-change
{ $values { "monitor" "a monitor" } { "path" "a pathname string" } { "changes" "a change descriptor" } }
{ $description "Waits for file system changes and outputs the pathname of the first changed file. The change descriptor is aq sequence of symbols documented in " { $link "io.monitor.descriptors" } "." } ;
{ $description "Waits for file system changes and outputs the pathname of the first changed file. The change descriptor is aq sequence of symbols documented in " { $link "io.monitors.descriptors" } "." } ;
HELP: with-monitor
{ $values { "path" "a pathname string" } { "recursive?" "a boolean" } { "quot" "a quotation with stack effect " { $snippet "( monitor -- )" } } }
@ -27,7 +27,7 @@ HELP: +modify-file+
HELP: +rename-file+
{ $description "Indicates that file has been renamed." } ;
ARTICLE: "io.monitor.descriptors" "File system change descriptors"
ARTICLE: "io.monitors.descriptors" "File system change descriptors"
"Change descriptors output by " { $link next-change } ":"
{ $subsection +add-file+ }
{ $subsection +remove-file+ }
@ -35,24 +35,24 @@ ARTICLE: "io.monitor.descriptors" "File system change descriptors"
{ $subsection +rename-file+ }
{ $subsection +add-file+ } ;
ARTICLE: "io.monitor" "File system change monitors"
ARTICLE: "io.monitors" "File system change monitors"
"File system change monitors listen for changes to file names, attributes and contents under a specified directory. They can optionally be recursive, in which case subdirectories are also monitored."
$nl
"Creating a file system change monitor and listening for changes:"
{ $subsection <monitor> }
{ $subsection next-change }
{ $subsection "io.monitor.descriptors" }
{ $subsection "io.monitors.descriptors" }
"Monitors are closed by calling " { $link dispose } " or " { $link with-disposal } "."
$nl
"A utility combinator which opens a monitor and cleans it up after:"
{ $subsection with-monitor }
"An example which watches the Factor directory for changes:"
{ $code
"USE: io.monitor"
"USE: io.monitors"
": watch-loop ( monitor -- )"
" dup next-change . . nl nl flush watch-loop ;"
""
"\"\" resource-path f [ watch-loop ] with-monitor"
} ;
ABOUT: "io.monitor"
ABOUT: "io.monitors"

View File

@ -2,7 +2,7 @@
! See http://factorcode.org/license.txt for BSD license.
USING: io.backend kernel continuations namespaces sequences
assocs hashtables sorting arrays ;
IN: io.monitor
IN: io.monitors
<PRIVATE

View File

@ -1,6 +1,6 @@
! Copyright (C) 2008 Slava Pestov.
! See http://factorcode.org/license.txt for BSD license.
USING: kernel io.backend io.monitor io.monitor.private io.files
USING: kernel io.backend io.monitors io.monitors.private io.files
io.buffers io.nonblocking io.unix.backend io.unix.select
io.unix.launcher unix.linux.inotify assocs namespaces threads
continuations init math alien.c-types alien ;

View File

@ -3,9 +3,9 @@
USING: alien.c-types destructors io.windows
io.windows.nt.backend kernel math windows windows.kernel32
windows.types libc assocs alien namespaces continuations
io.monitor io.monitor.private io.nonblocking io.buffers io.files
io.monitors io.monitors.private io.nonblocking io.buffers io.files
io sequences hashtables sorting arrays combinators ;
IN: io.windows.nt.monitor
IN: io.windows.nt.monitors
: open-directory ( path -- handle )
FILE_LIST_DIRECTORY
@ -70,8 +70,7 @@ M: windows-nt-io <monitor> ( path recursive? -- monitor )
FILE_NOTIFY_INFORMATION-FileName
FILE_NOTIFY_INFORMATION-FileNameLength
FILE_NOTIFY_INFORMATION-Action
} get-slots parse-action 1array swap
memory>u16-string ;
} get-slots parse-action 1array -rot memory>u16-string ;
: (changed-files) ( buffer -- )
dup parse-file-notify changed-file

View File

@ -5,7 +5,7 @@ USE: io.windows
USE: io.windows.nt.backend
USE: io.windows.nt.files
USE: io.windows.nt.launcher
USE: io.windows.nt.monitor
USE: io.windows.nt.monitors
USE: io.windows.nt.sockets
USE: io.windows.mmap
USE: io.backend

1
extra/log-viewer/authors.txt Executable file
View File

@ -0,0 +1 @@
Slava Pestov

View File

@ -0,0 +1,14 @@
USING: kernel io io.files io.monitors ;
IN: log-viewer
: read-lines ( stream -- )
dup stream-readln dup
[ print read-lines ] [ 2drop flush ] if ;
: tail-file-loop ( stream monitor -- )
dup next-change 2drop over read-lines tail-file-loop ;
: tail-file ( file -- )
dup <file-reader> dup read-lines
swap parent-directory f <monitor>
tail-file-loop ;

1
extra/log-viewer/summary.txt Executable file
View File

@ -0,0 +1 @@
Simple log file watcher demo using io.monitors

1
extra/log-viewer/tags.txt Executable file
View File

@ -0,0 +1 @@
demos

View File

@ -50,3 +50,6 @@ M: memoized definition "memo-quot" word-prop ;
: memoize-quot ( quot effect -- memo-quot )
gensym swap dupd "declared-effect" set-word-prop
dup rot define-memoized 1quotation ;
: reset-memoized ( word -- )
"memoize" word-prop clear-assoc ;

3
extra/opengl/tags.txt Normal file → Executable file
View File

@ -1,4 +1 @@
opengl.glu
opengl.gl
opengl
bindings

22
extra/tools/browser/browser-docs.factor Normal file → Executable file
View File

@ -2,16 +2,34 @@ USING: help.markup help.syntax io strings ;
IN: tools.browser
ARTICLE: "vocab-index" "Vocabulary index"
{ $tags,authors }
{ $tags }
{ $authors }
{ $describe-vocab "" } ;
ARTICLE: "tools.browser" "Vocabulary browser"
"Getting and setting vocabulary meta-data:"
{ $subsection vocab-file-contents }
{ $subsection set-vocab-file-contents }
{ $subsection vocab-summary }
{ $subsection set-vocab-summary }
{ $subsection vocab-tags }
{ $subsection set-vocab-tags }
{ $subsection add-vocab-tags } ;
{ $subsection add-vocab-tags }
"Global meta-data:"
{ $subsection all-vocabs }
{ $subsection all-vocabs-seq }
{ $subsection all-tags }
{ $subsection all-authors }
"Because loading the above data is expensive, it is cached. The cache is flushed by the " { $vocab-link "vocabs.monitor" } " vocabulary. It can also be flushed manually when file system change monitors are not available:"
{ $subsection reset-cache } ;
HELP: vocab-file-contents
{ $values { "vocab" "a vocabulary specifier" } { "name" string } { "seq" "a sequence of lines, or " { $link f } } }
{ $description "Outputs the contents of the file named " { $snippet "name" } " from the vocabulary's directory, or " { $link f } " if the file does not exist." } ;
HELP: set-vocab-file-contents
{ $values { "seq" "a sequence of lines" } { "vocab" "a vocabulary specifier" } { "name" string } }
{ $description "Stores a sequence of lines to the file named " { $snippet "name" } " from the vocabulary's directory." } ;
HELP: vocab-summary
{ $values { "vocab" "a vocabulary specifier" } { "summary" "a string or " { $link f } } }

View File

@ -1,13 +1,30 @@
! Copyright (C) 2007 Slava Pestov.
! Copyright (C) 2007, 2008 Slava Pestov.
! See http://factorcode.org/license.txt for BSD license.
USING: namespaces splitting sequences io.files kernel assocs
words vocabs vocabs.loader definitions parser continuations
inspector debugger io io.styles io.streams.lines hashtables
sorting prettyprint source-files arrays combinators strings
system math.parser help.markup help.topics help.syntax
help.stylesheet ;
help.stylesheet memoize ;
IN: tools.browser
MEMO: (vocab-file-contents) ( path -- lines )
?resource-path dup exists?
[ <file-reader> lines ] [ drop f ] if ;
: vocab-file-contents ( vocab name -- seq )
vocab-path+ dup [ (vocab-file-contents) ] when ;
: set-vocab-file-contents ( seq vocab name -- )
dupd vocab-path+ [
?resource-path
<file-writer> [ [ print ] each ] with-stream
] [
"The " swap vocab-name
" vocabulary was not loaded from the file system"
3append throw
] ?if ;
: vocab-summary-path ( vocab -- string )
vocab-dir "summary.txt" path+ ;
@ -86,7 +103,7 @@ M: vocab-link summary vocab-summary ;
dup [ "" vocabs-in-dir ] { } make
] { } map>assoc ;
: all-vocabs-seq ( -- seq )
MEMO: all-vocabs-seq ( -- seq )
all-vocabs values concat ;
: dangerous? ( name -- ? )
@ -288,20 +305,20 @@ C: <vocab-author> vocab-author
: $tagged-vocabs ( element -- )
first tagged vocabs. ;
: all-tags ( vocabs -- seq ) [ vocab-tags ] map>set ;
MEMO: all-tags ( -- seq )
all-vocabs-seq [ vocab-tags ] map>set ;
: $authored-vocabs ( element -- )
first authored vocabs. ;
: all-authors ( vocabs -- seq ) [ vocab-authors ] map>set ;
MEMO: all-authors ( -- seq )
all-vocabs-seq [ vocab-authors ] map>set ;
: $tags,authors ( element -- )
drop
all-vocabs-seq
"Tags" $heading
dup all-tags tags.
"Authors" $heading
all-authors authors. ;
: $tags ( element -- )
drop "Tags" $heading all-tags tags. ;
: $authors ( element -- )
drop "Authors" $heading all-authors authors. ;
M: vocab-spec article-title vocab-name " vocabulary" append ;
@ -339,3 +356,9 @@ M: vocab-author article-content
M: vocab-author article-parent drop "vocab-index" ;
M: vocab-author summary article-title ;
: reset-cache ( -- )
\ (vocab-file-contents) reset-memoized
\ all-vocabs-seq reset-memoized
\ all-authors reset-memoized
\ all-tags reset-memoized ;

View File

@ -1,8 +1,8 @@
! Copyright (C) 2007 Slava Pestov.
! Copyright (C) 2007, 2008 Slava Pestov.
! See http://factorcode.org/license.txt for BSD license.
USING: vocabs.loader io.files io kernel sequences assocs
splitting parser prettyprint namespaces math vocabs
hashtables ;
hashtables tools.browser ;
IN: tools.deploy.config
SYMBOL: deploy-name

View File

@ -0,0 +1 @@
Slava Pestov

View File

@ -0,0 +1,14 @@
USING: threads io.files io.monitors init kernel tools.browser ;
IN: vocabs.monitor
! Use file system change monitoring to flush the tags/authors
! cache
: update-thread ( monitor -- )
dup next-change 2drop reset-cache update-thread ;
: start-update-thread
[
"" resource-path t <monitor> update-thread
] in-thread ;
[ start-update-thread ] "tools.browser" add-init-hook

View File

@ -0,0 +1 @@
Use io.monitors to clear tools.browser authors/tags/summary cache

2
extra/xmode/catalog/catalog.factor Normal file → Executable file
View File

@ -99,7 +99,7 @@ SYMBOL: rule-sets
(load-mode) dup finalize-mode ;
: reset-modes ( -- )
\ (load-mode) "memoize" word-prop clear-assoc ;
\ (load-mode) reset-memoized ;
: ?glob-matches ( string glob/f -- ? )
dup [ glob-matches? ] [ 2drop f ] if ;

View File

@ -12,7 +12,7 @@ typedef char F_SYMBOL;
#define unbox_symbol_string unbox_char_string
#define from_symbol_string from_char_string
#define FACTOR_OS_STRING "windows"
#define FACTOR_OS_STRING "winnt"
#define FACTOR_DLL L"factor-nt.dll"
#define FACTOR_DLL_NAME "factor-nt.dll"