From c40c43c1a79000ee28ad2ce3076f7fa07be2ef57 Mon Sep 17 00:00:00 2001 From: Eduardo Cavazos Date: Wed, 5 Dec 2007 19:35:19 -0600 Subject: [PATCH 01/27] Raptor updates --- extra/raptor/cronjobs.factor | 40 ++++++++++++--------------- extra/raptor/raptor.factor | 4 ++- extra/raptor/{readme-0.1.1 => readme} | 8 ++++++ 3 files changed, 29 insertions(+), 23 deletions(-) rename extra/raptor/{readme-0.1.1 => readme} (94%) diff --git a/extra/raptor/cronjobs.factor b/extra/raptor/cronjobs.factor index 91263a31d9..684fecc6b8 100644 --- a/extra/raptor/cronjobs.factor +++ b/extra/raptor/cronjobs.factor @@ -6,33 +6,29 @@ IN: raptor ! !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! -: run-script ( path -- ) 1array [ fork-exec-args-wait ] curry in-thread ; - -! !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! - [ - "/etc/cron.daily/apt" run-script - "/etc/cron.daily/aptitude" run-script - "/etc/cron.daily/bsdmainutils" run-script - "/etc/cron.daily/find.notslocate" run-script - "/etc/cron.daily/logrotate" run-script - "/etc/cron.daily/man-db" run-script - "/etc/cron.daily/ntp-server" run-script - "/etc/cron.daily/slocate" run-script - "/etc/cron.daily/standard" run-script - "/etc/cron.daily/sysklogd" run-script - "/etc/cron.daily/tetex-bin" run-script + "/etc/cron.daily/apt" fork-exec-arg + "/etc/cron.daily/aptitude" fork-exec-arg + "/etc/cron.daily/bsdmainutils" fork-exec-arg + "/etc/cron.daily/find.notslocate" fork-exec-arg + "/etc/cron.daily/logrotate" fork-exec-arg + "/etc/cron.daily/man-db" fork-exec-arg + "/etc/cron.daily/ntp-server" fork-exec-arg + "/etc/cron.daily/slocate" fork-exec-arg + "/etc/cron.daily/standard" fork-exec-arg + "/etc/cron.daily/sysklogd" fork-exec-arg + "/etc/cron.daily/tetex-bin" fork-exec-arg ] cron-jobs-daily set-global [ - "/etc/cron.weekly/cvs" run-script - "/etc/cron.weekly/man-db" run-script - "/etc/cron.weekly/ntp-server" run-script - "/etc/cron.weekly/popularity-contest" run-script - "/etc/cron.weekly/sysklogd" run-script + "/etc/cron.weekly/cvs" fork-exec-arg + "/etc/cron.weekly/man-db" fork-exec-arg + "/etc/cron.weekly/ntp-server" fork-exec-arg + "/etc/cron.weekly/popularity-contest" fork-exec-arg + "/etc/cron.weekly/sysklogd" fork-exec-arg ] cron-jobs-weekly set-global [ - "/etc/cron.monthly/scrollkeeper" run-script - "/etc/cron.monthly/standard" run-script + "/etc/cron.monthly/scrollkeeper" fork-exec-arg + "/etc/cron.monthly/standard" fork-exec-arg ] cron-jobs-monthly set-global \ No newline at end of file diff --git a/extra/raptor/raptor.factor b/extra/raptor/raptor.factor index ef5359c313..d776739d89 100644 --- a/extra/raptor/raptor.factor +++ b/extra/raptor/raptor.factor @@ -1,5 +1,5 @@ -USING: kernel parser namespaces threads sequences unix unix.process +USING: kernel parser namespaces threads arrays sequences unix unix.process combinators.cleave bake ; IN: raptor @@ -24,6 +24,8 @@ SYMBOL: networking-hook : fork-exec-args-wait ( args -- ) [ first ] [ ] bi fork-exec-wait ; +: fork-exec-arg ( arg -- ) 1array [ fork-exec-args-wait ] curry in-thread ; + ! !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! : forever ( quot -- ) [ call ] [ forever ] bi ; diff --git a/extra/raptor/readme-0.1.1 b/extra/raptor/readme similarity index 94% rename from extra/raptor/readme-0.1.1 rename to extra/raptor/readme index bb5d4c0ff8..dfb6890cda 100644 --- a/extra/raptor/readme-0.1.1 +++ b/extra/raptor/readme @@ -32,6 +32,12 @@ another Linux distribution. # cp -v /scratch/factor/factor.image /sbin/init.image +*** Filesystems *** + + # emacs /etc/raptor/config.factor + +Edit the root-device and swap-devices variables. + *** Static IP networking *** If you use a static IP in your network then Factor can take care of @@ -71,6 +77,8 @@ The items in boot-hook correspond to the things in '/etc/rcS.d' and example, I removed the printer services. I also removed other things that I didn't feel were necessary on my system. +Look for the line with the call to 'set-hostname' and edit it appropriately. + *** Grub *** Edit your '/boot/grub/menu.lst'. Basically, copy and paste your From 6edcf9e9e0c53edd4ca632dc8508e23679b416bb Mon Sep 17 00:00:00 2001 From: Eduardo Cavazos Date: Wed, 5 Dec 2007 19:36:00 -0600 Subject: [PATCH 02/27] Add springies meta files --- extra/springies/authors.txt | 1 + extra/springies/summary.txt | 1 + extra/springies/tags.factor | 3 +++ 3 files changed, 5 insertions(+) create mode 100644 extra/springies/authors.txt create mode 100644 extra/springies/summary.txt create mode 100644 extra/springies/tags.factor diff --git a/extra/springies/authors.txt b/extra/springies/authors.txt new file mode 100644 index 0000000000..6cfd5da273 --- /dev/null +++ b/extra/springies/authors.txt @@ -0,0 +1 @@ +Eduardo Cavazos diff --git a/extra/springies/summary.txt b/extra/springies/summary.txt new file mode 100644 index 0000000000..edd2bf3667 --- /dev/null +++ b/extra/springies/summary.txt @@ -0,0 +1 @@ +Mass and spring simulation (inspired by xspringies) diff --git a/extra/springies/tags.factor b/extra/springies/tags.factor new file mode 100644 index 0000000000..375ac57169 --- /dev/null +++ b/extra/springies/tags.factor @@ -0,0 +1,3 @@ +simulation +physics +demos \ No newline at end of file From 73403aa89b610e95f36eb5f5f5b7b8e5b7def871 Mon Sep 17 00:00:00 2001 From: Eduardo Cavazos Date: Wed, 5 Dec 2007 19:39:28 -0600 Subject: [PATCH 03/27] Add bake meta files --- extra/bake/authors.txt | 1 + extra/bake/summary.txt | 1 + 2 files changed, 2 insertions(+) create mode 100644 extra/bake/authors.txt create mode 100644 extra/bake/summary.txt diff --git a/extra/bake/authors.txt b/extra/bake/authors.txt new file mode 100644 index 0000000000..6cfd5da273 --- /dev/null +++ b/extra/bake/authors.txt @@ -0,0 +1 @@ +Eduardo Cavazos diff --git a/extra/bake/summary.txt b/extra/bake/summary.txt new file mode 100644 index 0000000000..cfc944a0b2 --- /dev/null +++ b/extra/bake/summary.txt @@ -0,0 +1 @@ +Bake is similar to make but with additional features From 6efd5260ad0f04e9d033099a70af1430f53103a4 Mon Sep 17 00:00:00 2001 From: Eduardo Cavazos Date: Wed, 5 Dec 2007 19:45:56 -0600 Subject: [PATCH 04/27] Add a bunch of meta files --- extra/cabal/authors.txt | 1 + extra/cabal/summary.txt | 1 + extra/cabal/ui/authors.txt | 2 ++ extra/cabal/ui/summary.txt | 1 + extra/cfdg/summary.txt | 1 + 5 files changed, 6 insertions(+) create mode 100644 extra/cabal/authors.txt create mode 100644 extra/cabal/summary.txt create mode 100644 extra/cabal/ui/authors.txt create mode 100644 extra/cabal/ui/summary.txt create mode 100644 extra/cfdg/summary.txt diff --git a/extra/cabal/authors.txt b/extra/cabal/authors.txt new file mode 100644 index 0000000000..6cfd5da273 --- /dev/null +++ b/extra/cabal/authors.txt @@ -0,0 +1 @@ +Eduardo Cavazos diff --git a/extra/cabal/summary.txt b/extra/cabal/summary.txt new file mode 100644 index 0000000000..881f8367a1 --- /dev/null +++ b/extra/cabal/summary.txt @@ -0,0 +1 @@ +Minimalist chat server diff --git a/extra/cabal/ui/authors.txt b/extra/cabal/ui/authors.txt new file mode 100644 index 0000000000..c7091ca9e6 --- /dev/null +++ b/extra/cabal/ui/authors.txt @@ -0,0 +1,2 @@ +Matthew Willis +Eduardo Cavazos diff --git a/extra/cabal/ui/summary.txt b/extra/cabal/ui/summary.txt new file mode 100644 index 0000000000..12c0170a5d --- /dev/null +++ b/extra/cabal/ui/summary.txt @@ -0,0 +1 @@ +Connects to a cabal server diff --git a/extra/cfdg/summary.txt b/extra/cfdg/summary.txt new file mode 100644 index 0000000000..0b5e92cbfc --- /dev/null +++ b/extra/cfdg/summary.txt @@ -0,0 +1 @@ +Implementation of: http://contextfreeart.org From 6afcf0ba2fb07abcc7f43a4f3a0bdbb5a8fee966 Mon Sep 17 00:00:00 2001 From: Slava Pestov Date: Tue, 11 Dec 2007 15:48:18 -0500 Subject: [PATCH 05/27] Pastebin updates --- extra/webapps/pastebin/annotation.furnace | 6 +++--- extra/webapps/pastebin/paste-list.furnace | 16 +++++++++------- extra/webapps/pastebin/pastebin.factor | 2 +- 3 files changed, 13 insertions(+), 11 deletions(-) diff --git a/extra/webapps/pastebin/annotation.furnace b/extra/webapps/pastebin/annotation.furnace index 791905197e..e59db32484 100755 --- a/extra/webapps/pastebin/annotation.furnace +++ b/extra/webapps/pastebin/annotation.furnace @@ -3,9 +3,9 @@

Annotation: <% "summary" get write %>

- - - + + +
Annotation by:<% "author" get write %>
Channel:<% "channel" get write %>
Created:<% "date" get timestamp>string write %>
Annotation by:<% "author" get write %>
File type:<% "mode" get write %>
Created:<% "date" get timestamp>string write %>
<% "syntax" render-template %> diff --git a/extra/webapps/pastebin/paste-list.furnace b/extra/webapps/pastebin/paste-list.furnace index da2d1add9c..51813ecf97 100644 --- a/extra/webapps/pastebin/paste-list.furnace +++ b/extra/webapps/pastebin/paste-list.furnace @@ -17,13 +17,15 @@ <% "pastes" get [ "paste-summary" render-component ] each %> - -

This pastebin is written in Factor. It is inspired by lisppaste. -

-

It can be used for collaborative development over IRC. You can post code for review, and annotate other people's code. Syntax highlighting for over a hundred file types is supported. -

-

- <% "webapps.pastebin" browse-webapp-source %>

+ +
+

This pastebin is written in Factor. It is inspired by lisppaste. +

+

It can be used for collaborative development over IRC. You can post code for review, and annotate other people's code. Syntax highlighting for over a hundred file types is supported. +

+

+ <% "webapps.pastebin" browse-webapp-source %>

+
diff --git a/extra/webapps/pastebin/pastebin.factor b/extra/webapps/pastebin/pastebin.factor index 7ea98b8ba1..9aefe15bca 100755 --- a/extra/webapps/pastebin/pastebin.factor +++ b/extra/webapps/pastebin/pastebin.factor @@ -58,7 +58,7 @@ C: annotation paste-n number>string [ show-paste ] curry quot-link ; : paste-feed ( -- entries ) - get-pastebin pastebin-pastes [ + get-pastebin pastebin-pastes [ { paste-summary paste-link From c6dea4c49d4a55c517984106cb125cc11d606f47 Mon Sep 17 00:00:00 2001 From: Slava Pestov Date: Tue, 11 Dec 2007 18:44:19 -0500 Subject: [PATCH 06/27] Pastebin fixes --- extra/webapps/pastebin/pastebin.factor | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/extra/webapps/pastebin/pastebin.factor b/extra/webapps/pastebin/pastebin.factor index 9aefe15bca..ca7591afd1 100755 --- a/extra/webapps/pastebin/pastebin.factor +++ b/extra/webapps/pastebin/pastebin.factor @@ -79,6 +79,7 @@ C: annotation pastebin-pastes 2dup length swap set-paste-n push ; : submit-paste ( summary author channel mode contents -- ) + 2dup global [ 2array . flush ] bind [ pastebin store get-persistent add-paste store save-store @@ -100,7 +101,7 @@ C: annotation \ annotate-paste { { "n" v-required v-number } { "summary" "- no summary -" v-default } - { "author" v-required } + { "author" "- no author -" v-default } { "mode" "factor" v-default } { "contents" v-required } } define-action From 5c628517d1be67e6eccb6a71c03a39cd10aec178 Mon Sep 17 00:00:00 2001 From: Slava Pestov Date: Tue, 11 Dec 2007 18:44:26 -0500 Subject: [PATCH 07/27] Source responder fixes --- extra/webapps/file/file.factor | 12 ++---------- extra/webapps/source/source.factor | 31 +++++++++++++++++++++--------- 2 files changed, 24 insertions(+), 19 deletions(-) diff --git a/extra/webapps/file/file.factor b/extra/webapps/file/file.factor index 3a8feddbad..110b90f84a 100755 --- a/extra/webapps/file/file.factor +++ b/extra/webapps/file/file.factor @@ -35,8 +35,9 @@ IN: webapps.file SYMBOL: serve-file-hook [ + dupd file-response - stdio get stream-copy + stdio get stream-copy ] serve-file-hook set-global : serve-static ( filename mime-type -- ) @@ -46,7 +47,6 @@ SYMBOL: serve-file-hook "method" get "head" = [ file-response ] [ - >r dup swap r> serve-file-hook get call ] if ] if ; @@ -118,14 +118,6 @@ SYMBOL: page ] if ; global [ - ! Serve up our own source code - "resources" [ - [ - "" resource-path "doc-root" set - file-responder - ] with-scope - ] add-simple-responder - ! Serves files from a directory stored in the "doc-root" ! variable. You can set the variable in the global ! namespace, or inside the responder. diff --git a/extra/webapps/source/source.factor b/extra/webapps/source/source.factor index efc46c68b7..c414e0ac70 100755 --- a/extra/webapps/source/source.factor +++ b/extra/webapps/source/source.factor @@ -1,20 +1,33 @@ ! Copyright (C) 2007 Slava Pestov. ! See http://factorcode.org/license.txt for BSD license. USING: io.files namespaces webapps.file http.server.responders -xmode.code2html kernel html ; +xmode.code2html kernel html sequences ; IN: webapps.source +! This responder is a potential security problem. Make sure you +! don't have sensitive files stored under vm/, core/, extra/ +! or misc/. + +: check-source-path ( path -- ? ) + { "vm/" "core/" "extra/" "misc/" } + [ head? ] curry* contains? ; + +: source-responder ( path mime-type -- ) + drop + serving-html + [ dup htmlize-stream ] with-html-stream ; + global [ ! Serve up our own source code "source" [ - [ - "" resource-path "doc-root" set + "argument" get check-source-path [ [ - drop - serving-html - [ swap htmlize-stream ] with-html-stream - ] serve-file-hook set - file-responder - ] with-scope + "" resource-path "doc-root" set + [ source-responder ] serve-file-hook set + file-responder + ] with-scope + ] [ + "403 forbidden" httpd-error + ] if ] add-simple-responder ] bind From d7217801c3f94557004f4c7ca529794628c2d258 Mon Sep 17 00:00:00 2001 From: Slava Pestov Date: Tue, 11 Dec 2007 22:36:40 -0500 Subject: [PATCH 08/27] Documentation fixes --- core/bootstrap/image/image-docs.factor | 2 +- core/continuations/continuations-docs.factor | 2 +- core/generator/generator-docs.factor | 3 +- core/generic/math/math-docs.factor | 4 +- core/hashtables/hashtables-docs.factor | 2 +- core/io/files/files-docs.factor | 2 +- core/io/io-docs.factor | 16 ++-- core/kernel/kernel-docs.factor | 2 +- core/libc/libc-docs.factor | 2 +- core/math/math-docs.factor | 10 +-- core/prettyprint/backend/backend-docs.factor | 2 +- extra/channels/remote/remote-docs.factor | 6 +- extra/combinators/lib/lib-docs.factor | 32 +++---- extra/concurrency/concurrency-docs.factor | 6 +- extra/crypto/common/common-docs.factor | 6 +- extra/help/help-docs.factor | 8 +- extra/help/lint/lint-docs.factor | 14 ++- extra/help/lint/lint.factor | 90 +++++++++++-------- extra/lazy-lists/lazy-lists-docs.factor | 2 +- extra/locals/locals-docs.factor | 6 +- extra/math/functions/functions-docs.factor | 10 +-- extra/models/models-docs.factor | 2 +- .../replace/replace-docs.factor | 16 ++-- .../simple/simple-docs.factor | 2 +- extra/peg/peg-docs.factor | 36 +++----- extra/promises/promises-docs.factor | 2 +- extra/serialize/serialize-docs.factor | 10 +-- extra/tools/deploy/config/config-docs.factor | 2 +- extra/tools/test/test.factor | 4 +- extra/tuples/lib/lib-docs.factor | 2 + extra/ui/gadgets/gadgets-docs.factor | 51 ++++++++++- extra/ui/gadgets/worlds/worlds-docs.factor | 2 +- 32 files changed, 214 insertions(+), 142 deletions(-) diff --git a/core/bootstrap/image/image-docs.factor b/core/bootstrap/image/image-docs.factor index 868e49deeb..91aa22b738 100644 --- a/core/bootstrap/image/image-docs.factor +++ b/core/bootstrap/image/image-docs.factor @@ -14,7 +14,7 @@ $nl ABOUT: "bootstrap.image" HELP: make-image -{ $values { "architecture" "a string" } } +{ $values { "arch" "a string" } } { $description "Creates a bootstrap image from sources, where " { $snippet "architecture" } " is one of the following:" { $code "x86.32" "x86.64" "ppc" "arm" } "The new image file is written to the " { $link resource-path } " and is named " { $snippet "boot." { $emphasis "architecture" } ".image" } "." } ; diff --git a/core/continuations/continuations-docs.factor b/core/continuations/continuations-docs.factor index eb6afbf51e..87616d8833 100644 --- a/core/continuations/continuations-docs.factor +++ b/core/continuations/continuations-docs.factor @@ -85,7 +85,7 @@ HELP: continuation { $description "Reifies the current continuation from the point immediately after which the caller returns." } ; HELP: >continuation< -{ $values { "continuation" continuation } { "data" vector } { "retain" vector } { "call" vector } { "name" vector } { "catch" vector } { "c" array } } +{ $values { "continuation" continuation } { "data" vector } { "retain" vector } { "call" vector } { "name" vector } { "catch" vector } } { $description "Takes a continuation apart into its constituents." } ; HELP: ifcc diff --git a/core/generator/generator-docs.factor b/core/generator/generator-docs.factor index a68454f001..655b23e517 100644 --- a/core/generator/generator-docs.factor +++ b/core/generator/generator-docs.factor @@ -48,11 +48,10 @@ HELP: literal-table { $var-description "Holds a vector of literal objects referenced from the currently compiling word. If " { $link compiled-stack-traces? } " is on, " { $link init-generator } " ensures that the first entry is the word being compiled." } ; HELP: init-generator -{ $values { "word" word } } { $description "Prepares to generate machine code for a word." } ; HELP: generate-1 -{ $values { "label" word } { "node" "a dataflow node" } { "quot" "a quotation with stack effect " { $snippet "( node -- )" } } } +{ $values { "word" word } { "label" word } { "node" "a dataflow node" } { "quot" "a quotation with stack effect " { $snippet "( node -- )" } } } { $description "Generates machine code for " { $snippet "label" } " by applying the quotation to the dataflow node." } ; HELP: generate-node diff --git a/core/generic/math/math-docs.factor b/core/generic/math/math-docs.factor index b19b358343..b1148bb34e 100644 --- a/core/generic/math/math-docs.factor +++ b/core/generic/math/math-docs.factor @@ -4,7 +4,7 @@ generic.math ; HELP: math-upgrade { $values { "class1" "a class word" } { "class2" "a class word" } { "quot" "a quotation with stack effect " { $snippet "( n n -- n n )" } } } { $description "Outputs a quotation for upgrading numberical types. It takes two numbers on the stack, an instance of " { $snippet "class1" } ", and an instance of " { $snippet "class2" } ", and converts the one with the lower priority to the higher priority type." } -{ $examples { $example "USE: generic.math" "fixnum bignum math-upgrade ." "[ >r >bignum r> ]" } } ; +{ $examples { $example "USE: generic.math" "fixnum bignum math-upgrade ." "[ [ >bignum ] dip ]" } } ; HELP: no-math-method { $values { "left" "an object" } { "right" "an object" } { "generic" "a generic word" } } @@ -14,7 +14,7 @@ HELP: no-math-method HELP: math-method { $values { "word" "a generic word" } { "class1" "a class word" } { "class2" "a class word" } { "quot" "a quotation" } } { $description "Generates a definition for " { $snippet "word" } " when the two inputs are instances of " { $snippet "class1" } " and " { $snippet "class2" } ", respectively." } -{ $examples { $example "USE: generic.math" "\\ + fixnum float math-method ." "[ >r >float r> float+ ]" } } ; +{ $examples { $example "USE: generic.math" "\\ + fixnum float math-method ." "[ [ >float ] dip float+ ]" } } ; HELP: math-class { $class-description "The class of subtypes of " { $link number } " which are not " { $link null } "." } ; diff --git a/core/hashtables/hashtables-docs.factor b/core/hashtables/hashtables-docs.factor index 5ed8fbbe3a..3719c2f9e0 100644 --- a/core/hashtables/hashtables-docs.factor +++ b/core/hashtables/hashtables-docs.factor @@ -96,7 +96,7 @@ HELP: hash-deleted+ { $side-effects "hash" } ; HELP: (set-hash) -{ $values { "value" "a value" } { "key" "a key to add" } { "hash" hashtable } } +{ $values { "value" "a value" } { "key" "a key to add" } { "hash" hashtable } { "new?" "a boolean" } } { $description "Stores the key/value pair into the hashtable. This word does not grow the hashtable if it exceeds capacity, therefore a hang can result. User code should use " { $link set-at } " instead, which grows the hashtable if necessary." } { $side-effects "hash" } ; diff --git a/core/io/files/files-docs.factor b/core/io/files/files-docs.factor index fba91ded0a..3a23c8f6ef 100755 --- a/core/io/files/files-docs.factor +++ b/core/io/files/files-docs.factor @@ -104,7 +104,7 @@ HELP: file-modified HELP: parent-directory { $values { "path" "a pathname string" } { "parent" "a pathname string" } } { $description "Strips the last component off a pathname." } -{ $examples { $example "USE: io.files" "\"/etc/passwd\" parent-directory print" "/etc" } } ; +{ $examples { $example "USE: io.files" "\"/etc/passwd\" parent-directory print" "/etc/" } } ; HELP: file-name { $values { "path" "a pathname string" } { "string" string } } diff --git a/core/io/io-docs.factor b/core/io/io-docs.factor index d653bc8032..5c71714c64 100644 --- a/core/io/io-docs.factor +++ b/core/io/io-docs.factor @@ -134,12 +134,13 @@ $nl $io-error ; HELP: make-block-stream -{ $values { "quot" "a quotation" } { "style" "a hashtable" } { "stream" "an output stream" } } -{ $contract "Calls the quotation in a new dynamic scope with the " { $link stdio } " stream rebound to a nested paragraph stream, with formatting information applied." +{ $values { "style" "a hashtable" } { "stream" "an output stream" } { "stream'" "an output stream" } } +{ $contract "Creates an output stream which wraps " { $snippet "stream" } " and adds " { $snippet "style" } " on calls to " { $link stream-write } " and " { $link stream-format } "." $nl "Unlike " { $link make-span-stream } ", this creates a new paragraph block in the output." $nl "The " { $snippet "style" } " hashtable holds paragraph style information. See " { $link "paragraph-styles" } "." } +{ $notes "Instead of calling this word directly, use " { $link with-nesting } "." } $io-error ; HELP: stream-write-table @@ -151,16 +152,17 @@ $nl $io-error ; HELP: make-cell-stream -{ $values { "quot" quotation } { "style" hashtable } { "stream" "an output stream" } { "table-cell" object } } -{ $contract "Creates a table cell by calling the quotation in a new scope with a rebound " { $link stdio } " stream. Callers should not make any assumptions about the type of this word's output value; it should be treated like an opaque handle passed to " { $link stream-write-table } "." } +{ $values { "style" hashtable } { "stream" "an output stream" } { "stream'" object } } +{ $contract "Creates an output stream which writes to a table cell object." } { $notes "Instead of calling this word directly, use " { $link tabular-output } "." } $io-error ; HELP: make-span-stream -{ $values { "style" "a hashtable" } { "quot" "a quotation" } { "stream" "an output stream" } } -{ $contract "Calls the quotation in a new dynamic scope where calls to " { $link write } ", " { $link format } " and other stream output words automatically inherit style settings from " { $snippet "style" } "." +{ $values { "style" "a hashtable" } { "stream" "an output stream" } { "stream'" "an output stream" } } +{ $contract "Creates an output stream which wraps " { $snippet "stream" } " and adds " { $snippet "style" } " on calls to " { $link stream-write } " and " { $link stream-format } "." $nl -"Unlike " { $link make-block-stream } ", the quotation's output is inline, and not nested in a paragraph block." } +"Unlike " { $link make-block-stream } ", the stream output is inline, and not nested in a paragraph block." } +{ $notes "Instead of calling this word directly, use " { $link with-style } "." } $io-error ; HELP: stream-print diff --git a/core/kernel/kernel-docs.factor b/core/kernel/kernel-docs.factor index de3c0ead3e..31d28a6ec6 100644 --- a/core/kernel/kernel-docs.factor +++ b/core/kernel/kernel-docs.factor @@ -542,7 +542,7 @@ HELP: 3compose } ; HELP: while -{ $values { "pred" "a quotation with stack effect " { $snippet "( -- ? )" } } { "quot" "a quotation" } { "tail" "a quotation" } } +{ $values { "pred" "a quotation with stack effect " { $snippet "( -- ? )" } } { "body" "a quotation" } { "tail" "a quotation" } } { $description "Repeatedly calls " { $snippet "pred" } ". If it yields " { $link f } ", iteration stops, otherwise " { $snippet "quot" } " is called. After iteration stops, " { $snippet "tail" } " is called." } { $notes "In most cases, tail recursion should be used, because it is simpler both in terms of implementation and conceptually. However in some cases this combinator expresses intent better and should be used." $nl diff --git a/core/libc/libc-docs.factor b/core/libc/libc-docs.factor index ba870560d6..45d6b94326 100644 --- a/core/libc/libc-docs.factor +++ b/core/libc/libc-docs.factor @@ -25,7 +25,7 @@ HELP: memcpy { $warning "As per the BSD C library documentation, the behavior is undefined if the source and destination overlap." } ; HELP: check-ptr -{ $values { "c-ptr" "an alien address, byte array, or " { $link f } } { "checked" "an alien address or byte array with non-zero address" } } +{ $values { "c-ptr" "an alien address, byte array, or " { $link f } } } { $description "Throws an error if the input is " { $link f } ". Otherwise the object remains on the data stack." } ; HELP: free diff --git a/core/math/math-docs.factor b/core/math/math-docs.factor index 60e5310ce4..5a004534ef 100755 --- a/core/math/math-docs.factor +++ b/core/math/math-docs.factor @@ -222,12 +222,12 @@ $nl HELP: bit? { $values { "x" integer } { "n" integer } { "?" "a boolean" } } { $description "Tests if the " { $snippet "n" } "th bit of " { $snippet "x" } " is set." } -{ $examples { $example "BIN: 101 3 bit? ." "t" } } ; +{ $examples { $example "BIN: 101 2 bit? ." "t" } } ; HELP: log2 -{ $values { "n" "a positive integer" } { "b" integer } } -{ $description "Outputs the largest integer " { $snippet "b" } " such that " { $snippet "2^b" } " is less than " { $snippet "n" } "." } -{ $errors "Throws an error if " { $snippet "n" } " is zero or negative." } ; +{ $values { "x" "a positive integer" } { "n" integer } } +{ $description "Outputs the largest integer " { $snippet "n" } " such that " { $snippet "2^n" } " is less than " { $snippet "x" } "." } +{ $errors "Throws an error if " { $snippet "x" } " is zero or negative." } ; HELP: 1+ { $values { "x" number } { "y" number } } @@ -344,7 +344,7 @@ HELP: each-integer { $notes "This word is used to implement " { $link each } "." } ; HELP: all-integers? -{ $values { "n" integer } { "quot" "a quotation with stack effect " { $snippet "( i -- ? )" } } { "i" "an integer or " { $link f } } } +{ $values { "n" integer } { "quot" "a quotation with stack effect " { $snippet "( i -- ? )" } } { "?" "a boolean" } } { $description "Applies the quotation to each integer from 0 up to " { $snippet "n" } ", excluding " { $snippet "n" } ". Iterationi stops when the quotation outputs " { $link f } " or the end is reached. If the quotation yields a false value for some integer, this word outputs " { $link f } ". Otherwise, this word outputs " { $link t } "." } { $notes "This word is used to implement " { $link all? } "." } ; diff --git a/core/prettyprint/backend/backend-docs.factor b/core/prettyprint/backend/backend-docs.factor index bf1c5c2fc2..4605308a95 100644 --- a/core/prettyprint/backend/backend-docs.factor +++ b/core/prettyprint/backend/backend-docs.factor @@ -31,7 +31,7 @@ HELP: do-string-limit { $description "If " { $link string-limit } " is on, trims the string such that it does not exceed the margin, appending \"...\" if trimming took place." } ; HELP: pprint-string -{ $values { "obj" object } { "str" string } { "prefix" "a prefix string" } } +{ $values { "obj" object } { "str" string } { "prefix" string } { "suffix" string } } { $description "Outputs a text section consisting of the prefix, the string, and a final quote (\")." } $prettyprinting-note ; diff --git a/extra/channels/remote/remote-docs.factor b/extra/channels/remote/remote-docs.factor index 3cce6fdc4e..5400f147f4 100644 --- a/extra/channels/remote/remote-docs.factor +++ b/extra/channels/remote/remote-docs.factor @@ -13,7 +13,7 @@ HELP: "returned by " { $link publish } } { $examples - { $example "\"localhost\" 9000 \"ID123456\" \"foo\" over to" } + { $code "\"localhost\" 9000 \"ID123456\" \"foo\" over to" } } { $see-also publish unpublish } ; @@ -24,7 +24,7 @@ HELP: unpublish "accessible by remote nodes." } { $examples - { $example " publish unpublish" } + { $code " publish unpublish" } } { $see-also publish } ; @@ -37,7 +37,7 @@ HELP: publish { $link to } " and " { $link from } " to access the channel." } { $examples - { $example " publish" } + { $code " publish" } } { $see-also unpublish } ; diff --git a/extra/combinators/lib/lib-docs.factor b/extra/combinators/lib/lib-docs.factor index 719af59d9e..ac05160b31 100644 --- a/extra/combinators/lib/lib-docs.factor +++ b/extra/combinators/lib/lib-docs.factor @@ -1,8 +1,9 @@ -USING: help.syntax help.markup kernel prettyprint sequences ; +USING: help.syntax help.markup kernel prettyprint sequences +quotations math ; IN: combinators.lib HELP: generate -{ $values { "generator" "a quotation" } { "predicate" "a quotation" } { "obj" "an object" } } +{ $values { "generator" quotation } { "predicate" quotation } { "obj" object } } { $description "Loop until the generator quotation generates an object that satisfies predicate quotation." } { $unchecked-example "! Generate a random 20-bit prime number congruent to 3 (mod 4)" @@ -12,7 +13,7 @@ HELP: generate } ; HELP: ndip -{ $values { "quot" "a quotation" } { "n" "a number" } } +{ $values { "quot" quotation } { "n" number } } { $description "A generalisation of " { $link dip } " that can work " "for any stack depth. The quotation will be called with a stack that " "has 'n' items removed first. The 'n' items are then put back on the " @@ -25,7 +26,7 @@ HELP: ndip { $see-also dip dipd } ; HELP: nslip -{ $values { "n" "a number" } } +{ $values { "n" number } } { $description "A generalisation of " { $link slip } " that can work " "for any stack depth. The first " { $snippet "n" } " items after the quotation will be " "removed from the stack, the quotation called, and the items restored." @@ -36,7 +37,7 @@ HELP: nslip { $see-also slip nkeep } ; HELP: nkeep -{ $values { "quot" "a quotation" } { "n" "a number" } } +{ $values { "quot" quotation } { "n" number } } { $description "A generalisation of " { $link keep } " that can work " "for any stack depth. The first " { $snippet "n" } " items after the quotation will be " "saved, the quotation called, and the items restored." @@ -47,7 +48,7 @@ HELP: nkeep { $see-also keep nslip } ; HELP: map-withn -{ $values { "seq" "a sequence" } { "quot" "a quotation" } { "n" "a number" } { "newseq" "a sequence" } } +{ $values { "seq" sequence } { "quot" quotation } { "n" number } { "newseq" sequence } } { $description "A generalisation of " { $link map } ". The first " { $snippet "n" } " items after the quotation will be " "passed to the quotation given to map-withn for each element in the sequence." } @@ -57,43 +58,44 @@ HELP: map-withn { $see-also each-withn } ; HELP: each-withn -{ $values { "seq" "a sequence" } { "quot" "a quotation" } { "n" "a number" } } +{ $values { "seq" sequence } { "quot" quotation } { "n" number } } { $description "A generalisation of " { $link each } ". The first " { $snippet "n" } " items after the quotation will be " "passed to the quotation given to each-withn for each element in the sequence." } { $see-also map-withn } ; HELP: sigma -{ $values { "seq" "a sequence" } { "quot" "a quotation" } } +{ $values { "seq" sequence } { "quot" quotation } { "n" number } } { $description "Like map sum, but without creating an intermediate sequence." } { $example "! Find the sum of the squares [0,99]" - "USE: math.ranges" - "100 [1,b] [ sq ] sigma" + "USING: math.ranges combinators.lib ;" + "100 [1,b] [ sq ] sigma ." "338350" } ; HELP: count -{ $values { "seq" "a sequence" } { "quot" "a quotation" } } +{ $values { "seq" sequence } { "quot" quotation } { "n" integer } } { $description "Efficiently returns the number of elements that the predicate quotation matches." } { $example - "USE: math.ranges" + "USING: math.ranges combinators.lib ;" "100 [1,b] [ even? ] count ." "50" } ; HELP: all-unique? -{ $values { "seq" "a sequence" } { "?" "a boolean" } } +{ $values { "seq" sequence } { "?" "a boolean" } } { $description "Tests whether a sequence contains any repeated elements." } { $example + "USE: combinators.lib" "{ 0 1 1 2 3 5 } all-unique? ." "f" } ; HELP: && -{ $values { "quots" "a sequence of quotations with stack effect " { $snippet "( ... -- ... ? )" } } } +{ $values { "quots" "a sequence of quotations with stack effect " { $snippet "( ... -- ... ? )" } } { "?" "a boolean" } } { $description "Calls each quotation in turn; outputs " { $link f } " if one of the quotations output " { $link f } ", otherwise outputs " { $link t } ". As soon as a quotation outputs " { $link f } ", evaluation stops and subsequent quotations are not called." } ; HELP: || -{ $values { "quots" "a sequence of quotations with stack effect " { $snippet "( ... -- ... ? )" } } } +{ $values { "quots" "a sequence of quotations with stack effect " { $snippet "( ... -- ... ? )" } } { "?" "a boolean" } } { $description "Calls each quotation in turn; outputs " { $link t } " if one of the quotations output " { $link t } ", otherwise outputs " { $link f } ". As soon as a quotation outputs " { $link t } ", evaluation stops and subsequent quotations are not called." } ; diff --git a/extra/concurrency/concurrency-docs.factor b/extra/concurrency/concurrency-docs.factor index cf09f3bb57..39e8b277e3 100644 --- a/extra/concurrency/concurrency-docs.factor +++ b/extra/concurrency/concurrency-docs.factor @@ -25,9 +25,8 @@ HELP: mailbox-put HELP: (mailbox-block-unless-pred) { $values { "pred" "a quotation with stack effect " { $snippet "( X -- bool )" } } - { "mailbox" "a mailbox object" } - { "pred2" "same object as 'pred'" } - { "mailbox2" "same object as 'mailbox'" } + { "mailbox" "a mailbox object" } + { "timeout" "a timeout in milliseconds" } } { $description "Block the thread if there are no items in the mailbox that return true when the predicate is called with the item on the stack. The predicate must have stack effect " { $snippet "( X -- bool )" } "." } { $see-also make-mailbox mailbox-empty? mailbox-put mailbox-get mailbox-get-all while-mailbox-empty mailbox-get? } ; @@ -35,6 +34,7 @@ HELP: (mailbox-block-unless-pred) HELP: (mailbox-block-if-empty) { $values { "mailbox" "a mailbox object" } { "mailbox2" "same object as 'mailbox'" } + { "timeout" "a timeout in milliseconds" } } { $description "Block the thread if the mailbox is empty." } { $see-also make-mailbox mailbox-empty? mailbox-put mailbox-get mailbox-get-all while-mailbox-empty mailbox-get? } ; diff --git a/extra/crypto/common/common-docs.factor b/extra/crypto/common/common-docs.factor index 1be85a364b..1292e04777 100644 --- a/extra/crypto/common/common-docs.factor +++ b/extra/crypto/common/common-docs.factor @@ -13,8 +13,8 @@ HELP: bitroll { $values { "x" "an integer (input)" } { "s" "an integer (shift)" } { "w" "an integer (wrap)" } { "y" "an integer" } } { $description "Roll n by s bits to the left, wrapping around after w bits." } { $examples - { $example "1 -1 32 bitroll .b" "10000000000000000000000000000000" } - { $example "HEX: ffff0000 8 32 bitroll .h" "ff0000ff" } + { $example "USE: crypto.common" "1 -1 32 bitroll .b" "10000000000000000000000000000000" } + { $example "USE: crypto.common" "HEX: ffff0000 8 32 bitroll .h" "ff0000ff" } } ; @@ -22,7 +22,7 @@ HELP: hex-string { $values { "seq" "a sequence" } { "str" "a string" } } { $description "Converts a sequence of values from 0-255 to a string of hex numbers from 0-ff." } { $examples - { $example "B{ 1 2 3 4 } hex-string print" "01020304" } + { $example "USE: crypto.common" "B{ 1 2 3 4 } hex-string print" "01020304" } } { $notes "Numbers are zero-padded on the left." } ; diff --git a/extra/help/help-docs.factor b/extra/help/help-docs.factor index 2d53e4e59d..d2d0b9beae 100644 --- a/extra/help/help-docs.factor +++ b/extra/help/help-docs.factor @@ -1,5 +1,5 @@ USING: help.markup help.crossref help.topics help.syntax -definitions io prettyprint inspector ; +definitions io prettyprint inspector help.lint ; IN: help ARTICLE: "printing-elements" "Printing markup elements" @@ -81,7 +81,8 @@ $nl } { $subsection "element-types" } "Related words can be cross-referenced:" -{ $subsection related-words } ; +{ $subsection related-words } +{ $see-also "help.lint" } ; ARTICLE: "help-impl" "Help system implementation" "Help topic protocol:" @@ -108,6 +109,7 @@ ARTICLE: "help" "Help system" "The help system maintains documentation written in a simple markup language, along with cross-referencing and search. Documentation can either exist as free-standing " { $emphasis "articles" } " or be associated with words." { $subsection "browsing-help" } { $subsection "writing-help" } +{ $subsection "help.lint" } { $subsection "help-impl" } ; ABOUT: "help" @@ -143,7 +145,7 @@ HELP: $index { $description "Calls the quotation to generate a sequence of help topics, and outputs a " { $link $subsection } " for each one." } ; HELP: ($index) -{ $values { "seq" "a sequence of help article names and words" } { "quot" "a quotation with stack effect " { $snippet "( topic -- )" } } } +{ $values { "articles" "a sequence of help articles" } } { $description "Writes a list of " { $link $subsection } " elements to the " { $link stdio } " stream." } ; HELP: xref-help diff --git a/extra/help/lint/lint-docs.factor b/extra/help/lint/lint-docs.factor index 6ff0699471..2813391d07 100644 --- a/extra/help/lint/lint-docs.factor +++ b/extra/help/lint/lint-docs.factor @@ -1,8 +1,20 @@ USING: help.markup help.syntax ; IN: help.lint +HELP: check-help +{ $description "Checks all word and article help." } ; + +HELP: check-vocab-help +{ $values { "vocab" "a vocabulary specifier" } } +{ $description "Checks all word help in the given vocabulary." } ; + ARTICLE: "help.lint" "Help lint tool" -"A quick and dirty tool to check documentation in an automated fashion." +"The " { $vocab-link "help.lint" } " vocabulary implements a tool to check documentation in an automated fashion. You should use this tool to check any documentation that you write." +$nl +"To run help lint, use one of the following two words:" +{ $subsection check-help } +{ $subsection check-vocab-help } +"Help lint performs the following checks:" { $list "ensures examples run and produce stated output" { "ensures " { $link $see-also } " elements don't contain duplicate entries" } diff --git a/extra/help/lint/lint.factor b/extra/help/lint/lint.factor index 3621b3c6ad..6496ca21ff 100644 --- a/extra/help/lint/lint.factor +++ b/extra/help/lint/lint.factor @@ -4,7 +4,8 @@ USING: sequences parser kernel help help.markup help.topics words strings classes tools.browser namespaces io io.streams.string prettyprint definitions arrays vectors combinators splitting debugger hashtables sorting effects vocabs -vocabs.loader assocs editors continuations classes.predicate ; +vocabs.loader assocs editors continuations classes.predicate +macros combinators.lib ; IN: help.lint : check-example ( element -- ) @@ -29,7 +30,7 @@ IN: help.lint stack-effect dup effect-in swap effect-out append [ string? ] subset prune natural-sort ; -: check-values ( word element -- ) +: contains-funky-elements? ( element -- ? ) { $shuffle $values-x/y @@ -38,11 +39,20 @@ IN: help.lint $predicate $class-description $error-description - } - over [ elements empty? ] curry all? - pick "declared-effect" word-prop and - [ extract-values >array >r effect-values >array r> assert= ] - [ 2drop ] if ; + } swap [ elements f like ] curry contains? ; + +: check-values ( word element -- ) + { + [ over "declared-effect" word-prop ] + [ dup contains-funky-elements? not ] + [ over macro? not ] + [ + 2dup extract-values >array + >r effect-values >array + r> assert= + t + ] + } && 3drop ; : check-see-also ( word element -- ) nip \ $see-also swap elements [ @@ -61,55 +71,59 @@ IN: help.lint : check-rendering ( word element -- ) [ help ] string-out drop ; -: all-word-help ( -- seq ) - all-words [ word-help ] subset ; +: all-word-help ( words -- seq ) + [ word-help ] subset ; TUPLE: help-error topic ; : ( topic delegate -- error ) { set-help-error-topic set-delegate } help-error construct ; -: fix-help ( error -- ) - dup delegate error. - help-error-topic >link edit - "Press ENTER when done." print flush readln drop - refresh-all ; +M: help-error error. + "In " write dup help-error-topic ($link) nl + delegate error. ; + +: check-something ( obj quot -- ) + over . flush [ , ] recover ; inline : check-word ( word -- ) - dup . flush - [ - dup word-help [ - 2dup check-examples - 2dup check-values - 2dup check-see-also - 2dup check-modules - 2dup drop check-rendering - ] assert-depth 2drop - ] [ - dupd fix-help check-word - ] recover ; + dup word-help [ + [ + dup word-help [ + 2dup check-examples + 2dup check-values + 2dup check-see-also + 2dup check-modules + 2dup drop check-rendering + ] assert-depth 2drop + ] check-something + ] [ drop ] if ; -: check-words ( -- ) - [ - all-vocabs-seq [ vocab-name ] map - "all-vocabs" set - all-word-help [ check-word ] each - ] with-scope ; +: check-words ( words -- ) [ check-word ] each ; : check-article ( article -- ) - dup . flush [ [ dup check-rendering ] assert-depth drop - ] [ - dupd fix-help check-article - ] recover ; + ] check-something ; : check-articles ( -- ) articles get keys [ check-article ] each ; -: check-help ( -- ) check-words check-articles ; +: with-help-lint ( quot -- ) + [ + all-vocabs-seq [ vocab-name ] map "all-vocabs" set + call + ] { } make [ nl error. ] each ; inline -: unlinked-words ( -- seq ) +: check-help ( -- ) + [ all-words check-words check-articles ] with-help-lint ; + +: check-vocab-help ( vocab -- ) + [ + child-vocabs [ words check-words ] each + ] with-help-lint ; + +: unlinked-words ( words -- seq ) all-word-help [ article-parent not ] subset ; : linked-undocumented-words ( -- seq ) diff --git a/extra/lazy-lists/lazy-lists-docs.factor b/extra/lazy-lists/lazy-lists-docs.factor index 5b53b80cba..e8acb397df 100644 --- a/extra/lazy-lists/lazy-lists-docs.factor +++ b/extra/lazy-lists/lazy-lists-docs.factor @@ -181,7 +181,7 @@ HELP: lmerge { $values { "list1" "a list" } { "list2" "a list" } { "result" "lazy list merging list1 and list2" } } { $description "Return the result of merging the two lists in a lazy manner." } { $examples - { $example "{ 1 2 3 } >list { 4 5 6 } >list lmerge list>array ." "{ 1 4 2 5 3 6 }" } + { $example "USE: lazy-lists" "{ 1 2 3 } >list { 4 5 6 } >list lmerge list>array ." "{ 1 4 2 5 3 6 }" } } { $see-also leach lmap lmap-with lconcat ltake lsubset lfrom-by lcartesian-product lcomp } ; diff --git a/extra/locals/locals-docs.factor b/extra/locals/locals-docs.factor index 92d64d5c6f..97f9aa5c65 100644 --- a/extra/locals/locals-docs.factor +++ b/extra/locals/locals-docs.factor @@ -4,7 +4,7 @@ IN: locals search ." "{ 123 \"hello\" 456 }" } +{ $example "USE: parser-combinators" "\"one 123 two 456\" 'integer' search ." "{ 123 456 }" } +{ $example "USE: parser-combinators" "\"one 123 \\\"hello\\\" two 456\" 'integer' 'string' <|> search ." "{ 123 \"hello\" 456 }" } { $see-also search* replace replace* } ; HELP: search* @@ -40,7 +40,7 @@ HELP: search* "parsers in the 'parsers' sequence." } -{ $example "\"one 123 \\\"hello\\\" two 456\" 'integer' 'string' 2array search* ." "{ 123 \"hello\" 456 }" } +{ $example "USE: parser-combinators" "\"one 123 \\\"hello\\\" two 456\" 'integer' 'string' 2array search* ." "{ 123 \"hello\" 456 }" } { $see-also search replace replace* } ; HELP: replace @@ -54,9 +54,9 @@ HELP: replace "successfully parse with the given parser replaced with " "the result of that parser." } -{ $example "\"one 123 two 456\" 'integer' [ 2 * number>string ] <@ replace ." "\"one 246 two 912\"" } -{ $example "\"hello *world* from *factor*\" 'bold' [ \"\" swap \"\" 3append ] <@ replace ." "\"hello world from factor\"" } -{ $example "\"hello *world* from _factor_\"\n 'bold' [ \"\" swap \"\" 3append ] <@\n 'italic' [ \"\" swap \"\" 3append ] <@ <|>\n replace ." "\"hello world from factor\"" } +{ $example "USING: parser-combinators math.parser ;" "\"one 123 two 456\" 'integer' [ 2 * number>string ] <@ replace ." "\"one 246 two 912\"" } +{ $example "USE: parser-combinators" "\"hello *world* from *factor*\" 'bold' [ \"\" swap \"\" 3append ] <@ replace ." "\"hello world from factor\"" } +{ $example "USE: parser-combinators" "\"hello *world* from _factor_\"\n 'bold' [ \"\" swap \"\" 3append ] <@\n 'italic' [ \"\" swap \"\" 3append ] <@ <|>\n replace ." "\"hello world from factor\"" } { $see-also search search* replace* } ; HELP: replace* @@ -71,6 +71,6 @@ HELP: replace* "the result of that parser. Each parser is done in sequence so that " "the parse results of the first parser can be replaced by later parsers." } -{ $example "\"*hello _world_*\"\n 'bold' [ \"\" swap \"\" 3append ] <@\n 'italic' [ \"\" swap \"\" 3append ] <@ 2array\n replace* ." "\"hello world\"" } +{ $example "USE: parser-combinators" "\"*hello _world_*\"\n 'bold' [ \"\" swap \"\" 3append ] <@\n 'italic' [ \"\" swap \"\" 3append ] <@ 2array\n replace* ." "\"hello world\"" } { $see-also search search* replace* } ; diff --git a/extra/parser-combinators/simple/simple-docs.factor b/extra/parser-combinators/simple/simple-docs.factor index 52786aceae..c2cca6e4a0 100755 --- a/extra/parser-combinators/simple/simple-docs.factor +++ b/extra/parser-combinators/simple/simple-docs.factor @@ -60,6 +60,6 @@ HELP: comma-list "'element' should be a parser that can parse the elements. The " "result of the parser is a sequence of the parsed elements." } { $examples -{ $example "USING: lazy-lits parser-combinators ;" "\"1,2,3,4\" 'integer' comma-list parse-1 ." "{ 1 2 3 4 }" } } ; +{ $example "USING: lazy-lists parser-combinators ;" "\"1,2,3,4\" 'integer' comma-list parse-1 ." "{ 1 2 3 4 }" } } ; { $see-also 'digit' 'integer' 'string' 'bold' 'italic' comma-list } related-words diff --git a/extra/peg/peg-docs.factor b/extra/peg/peg-docs.factor index 63b9d44310..41463d85a0 100644 --- a/extra/peg/peg-docs.factor +++ b/extra/peg/peg-docs.factor @@ -4,9 +4,9 @@ USING: help.markup help.syntax peg ; HELP: parse { $values - { "string" "a string" } - { "parse" "a parser" } - { "result" "a or f" } + { "input" "a string" } + { "parser" "a parser" } + { "result" "a parse-result or f" } } { $description "Given the input string, parse it using the given parser. The result is a object if " @@ -37,7 +37,7 @@ HELP: range } { $description "Returns a parser that matches a single character that lies within the range of characters given, inclusive." } -{ $example ": digit ( -- parser ) CHAR: 0 CHAR: 9 range ;" } ; +{ $examples { $code ": digit ( -- parser ) CHAR: 0 CHAR: 9 range ;" } } ; HELP: seq { $values @@ -60,8 +60,7 @@ HELP: choice HELP: repeat0 { $values - { "p1" "a parser" } - { "p2" "a parser" } + { "parser" "a parser" } } { $description "Returns a parser that parses 0 or more instances of the 'p1' parser. The AST produced is " @@ -70,8 +69,7 @@ HELP: repeat0 HELP: repeat1 { $values - { "p1" "a parser" } - { "p2" "a parser" } + { "parser" "a parser" } } { $description "Returns a parser that parses 1 or more instances of the 'p1' parser. The AST produced is " @@ -79,8 +77,7 @@ HELP: repeat1 HELP: optional { $values - { "p1" "a parser" } - { "p2" "a parser" } + { "parser" "a parser" } } { $description "Returns a parser that parses 0 or 1 instances of the 'p1' parser. The AST produced is " @@ -88,29 +85,27 @@ HELP: optional HELP: ensure { $values - { "p1" "a parser" } - { "p2" "a parser" } + { "parser" "a parser" } } { $description "Returns a parser that succeeds if the 'p1' parser succeeds but does not add anything to the " "AST and does not move the location in the input string. This can be used for lookahead and " "disambiguation, along with the " { $link ensure-not } " word." } -{ $example "\"0\" token ensure octal-parser" } ; +{ $examples { $code "\"0\" token ensure octal-parser" } } ; HELP: ensure-not { $values - { "p1" "a parser" } - { "p2" "a parser" } + { "parser" "a parser" } } { $description "Returns a parser that succeeds if the 'p1' parser fails but does not add anything to the " "AST and does not move the location in the input string. This can be used for lookahead and " "disambiguation, along with the " { $link ensure } " word." } -{ $example "\"+\" token \"=\" token ensure-not \"+=\" token 3array seq" } ; +{ $code "\"+\" token \"=\" token ensure-not \"+=\" token 3array seq" } ; HELP: action { $values - { "p1" "a parser" } + { "parser" "a parser" } { "quot" "a quotation with stack effect ( ast -- ast )" } } { $description @@ -118,11 +113,10 @@ HELP: action "from that parse. The result of the quotation is then used as the final AST. This can be used " "for manipulating the parse tree to produce a AST better suited for the task at hand rather than " "the default AST." } -{ $example "CHAR: 0 CHAR: 9 range [ to-digit ] action" } ; +{ $code "CHAR: 0 CHAR: 9 range [ to-digit ] action" } ; HELP: sp { $values - { "p1" "a parser" } { "parser" "a parser" } } { $description @@ -131,17 +125,15 @@ HELP: sp HELP: hide { $values - { "p1" "a parser" } { "parser" "a parser" } } { $description "Returns a parser that succeeds if the original parser succeeds, but does not " "put any result in the AST. Useful for ignoring 'syntax' in the AST." } -{ $example "\"[\" token hide number \"]\" token hide 3array seq" } ; +{ $code "\"[\" token hide number \"]\" token hide 3array seq" } ; HELP: delay { $values - { "quot" "a quotation with stack effect ( -- parser )" } { "parser" "a parser" } } { $description diff --git a/extra/promises/promises-docs.factor b/extra/promises/promises-docs.factor index f9477feaa3..8fe2afd2f2 100644 --- a/extra/promises/promises-docs.factor +++ b/extra/promises/promises-docs.factor @@ -28,6 +28,6 @@ HELP: LAZY: { $values { "word" "a new word to define" } { "definition" "a word definition" } } { $description "Creates a lazy word in the current vocabulary. When executed the word will return a " { $link promise } " that when forced, executes the word definition. Any values on the stack that are required by the word definition are captured along with the promise." } { $examples - { $example "LAZY: my-add ( a b -- c ) + ;\n1 2 my-add force ." "3" } + { $example "IN: promises LAZY: my-add ( a b -- c ) + ;\n1 2 my-add force ." "3" } } { $see-also force promise-with promise-with2 } ; diff --git a/extra/serialize/serialize-docs.factor b/extra/serialize/serialize-docs.factor index fd257c9879..5f21b02ae7 100644 --- a/extra/serialize/serialize-docs.factor +++ b/extra/serialize/serialize-docs.factor @@ -8,7 +8,7 @@ HELP: (serialize) } { $description "Serializes the object to the current output stream. Object references within the structure being serialized are maintained. It must be called from within the scope of a " { $link with-serialized } " call." } { $examples - { $example "USE: serialize" "[\n [ { 1 2 } dup (serialize) (serialize) ] with-serialized\n] string-out\n\n[\n [ (deserialize) (deserialize) ] with-serialized\n] string-in eq? ." "t" } + { $example "USING: serialize io.streams.string ;" "[\n [ { 1 2 } dup (serialize) (serialize) ] with-serialized\n] string-out\n\n[\n [ (deserialize) (deserialize) ] with-serialized\n] string-in eq? ." "t" } } { $see-also deserialize (deserialize) serialize with-serialized } ; @@ -17,7 +17,7 @@ HELP: (deserialize) } { $description "Deserializes an object by reading from the current input stream. Object references within the structure that was originally serialized are maintained. It must be called from within the scope of a " { $link with-serialized } " call." } { $examples - { $example "USE: serialize" "[\n [ { 1 2 } dup serialize serialize ] with-serialized\n] string-out\n\n[\n [ deserialize deserialize ] with-serialized\n] string-in eq? ." "t" } + { $example "USING: serialize io.streams.string ;" "[\n [ { 1 2 } dup (serialize) (serialize) ] with-serialized\n] string-out\n\n[\n [ (deserialize) (deserialize) ] with-serialized\n] string-in eq? ." "t" } } { $see-also (serialize) deserialize serialize with-serialized } ; @@ -26,7 +26,7 @@ HELP: with-serialized } { $description "Creates a scope for serialization and deserialization operations. The quotation is called within this scope. The scope is used for maintaining the structure and object references of serialized objects." } { $examples - { $example "USE: serialize" "[\n [ { 1 2 } dup (serialize) (serialize) ] with-serialized\n] string-out\n\n[\n [ (deserialize) (deserialize) ] with-serialized\n] string-in eq? ." "t" } + { $example "USING: serialize io.streams.string ;" "[\n [ { 1 2 } dup (serialize) (serialize) ] with-serialized\n] string-out\n\n[\n [ (deserialize) (deserialize) ] with-serialized\n] string-in eq? ." "t" } } { $see-also (serialize) (deserialize) serialize deserialize } ; @@ -35,7 +35,7 @@ HELP: serialize } { $description "Serializes the object to the current output stream. Object references within the structure being serialized are maintained." } { $examples - { $example "USE: serialize" "[ { 1 2 } serialize ] ] string-out\n\n[ deserialize ] string-in ." "{ 1 2 }" } + { $example "USING: serialize io.streams.string ;" "[ { 1 2 } serialize ] string-out\n\n[ deserialize ] string-in ." "{ 1 2 }" } } { $see-also deserialize (deserialize) (serialize) with-serialized } ; @@ -44,6 +44,6 @@ HELP: deserialize } { $description "Deserializes an object by reading from the current input stream. Object references within the structure that was originally serialized are maintained." } { $examples - { $example "USE: serialize" "[ { 1 2 } serialize ] ] string-out\n\n[ deserialize ] string-in ." "{ 1 2 }" } + { $example "USING: serialize io.streams.string ;" "[ { 1 2 } serialize ] string-out\n\n[ deserialize ] string-in ." "{ 1 2 }" } } { $see-also (serialize) deserialize (deserialize) with-serialized } ; diff --git a/extra/tools/deploy/config/config-docs.factor b/extra/tools/deploy/config/config-docs.factor index 5b1efce25e..c1b9755cd6 100755 --- a/extra/tools/deploy/config/config-docs.factor +++ b/extra/tools/deploy/config/config-docs.factor @@ -43,7 +43,7 @@ $nl HELP: deploy-word-defs? { $description "Deploy flag. If set, the deploy tool retains word definition quotations for words compiled with the optimizing compiler. Otherwise, word definitions are stripped from words compiled with the optimizing compiler." $nl -"Off by default. During normal execution, the word definition quotation of a word compiled with the optimizing compiler is not used, so disabling this flag can save space. However, some libraries introspect word definitions dynamically (for example, " { $link "inverse" } ") and so programs using these libraries must retain word definition quotations." } ; +"Off by default. During normal execution, the word definition quotation of a word compiled with the optimizing compiler is not used, so disabling this flag can save space. However, some libraries introspect word definitions dynamically (for example, " { $vocab-link "inverse" } ") and so programs using these libraries must retain word definition quotations." } ; HELP: deploy-c-types? { $description "Deploy flag. If set, the deploy tool retains the " { $link c-types } " table, otherwise this table is stripped out, saving space." diff --git a/extra/tools/test/test.factor b/extra/tools/test/test.factor index 88f94a7fd6..1cefce8721 100644 --- a/extra/tools/test/test.factor +++ b/extra/tools/test/test.factor @@ -18,9 +18,7 @@ SYMBOL: this-test : (unit-test) ( what quot -- ) swap dup . flush this-test set [ time ] curry failures get [ - [ - this-test get failures get push - ] recover + [ this-test get failure ] recover ] [ call ] if ; diff --git a/extra/tuples/lib/lib-docs.factor b/extra/tuples/lib/lib-docs.factor index 040ef3576c..0ab709a11f 100644 --- a/extra/tuples/lib/lib-docs.factor +++ b/extra/tuples/lib/lib-docs.factor @@ -5,6 +5,7 @@ HELP: >tuple< { $values { "class" "a tuple class" } } { $description "Explodes the tuple so that tuple slots are on the stack in the order listed in the tuple." } { $example + "USE: tuples.lib" "TUPLE: foo a b c ;" "1 2 3 \\ foo construct-boa \\ foo >tuple< .s" "1\n2\n3" @@ -16,6 +17,7 @@ HELP: >tuple*< { $values { "class" "a tuple class" } } { $description "Explodes the tuple so that tuple slots ending with '*' are on the stack in the order listed in the tuple." } { $example + "USE: tuples.lib" "TUPLE: foo a bb* ccc dddd* ;" "1 2 3 4 \\ foo construct-boa \\ foo >tuple*< .s" "2\n4" diff --git a/extra/ui/gadgets/gadgets-docs.factor b/extra/ui/gadgets/gadgets-docs.factor index faac461888..1132ea8d66 100644 --- a/extra/ui/gadgets/gadgets-docs.factor +++ b/extra/ui/gadgets/gadgets-docs.factor @@ -1,5 +1,5 @@ USING: ui.gadgets help.markup help.syntax opengl kernel strings -tuples classes quotations ; +tuples classes quotations models ; HELP: rect { $class-description "A rectangle with the following slots:" @@ -259,3 +259,52 @@ HELP: g HELP: g-> { $values { "x" object } { "gadget" gadget } } { $description "Duplicates the top of the stack and outputs the gadget being built. Can only be used inside a quotation passed to " { $link build-gadget } "." } ; + +HELP: construct-control +{ $values { "model" model } { "gadget" gadget } { "class" class } { "control" gadget } } +{ $description "Creates a new control linked to the given model. The gadget parameter becomes the control's delegate. The quotation is called when the model value changes." } +{ $examples + "The following example creates a gadget whose fill color is determined by the value of a model:" + { $code + "USING: ui.gadgets ui.gadgets.panes models ;" + ": set-fill-color >r r> set-gadget-interior ;" + "" + "TUPLE: color-gadget ;" + "" + "M: color-gadget model-changed" + " >r model-value r> set-fill-color ;" + "" + ": ( model -- gadget )" + " " + " { 100 100 } over set-rect-dim" + " color-gadget" + " construct-control ;" + "" + "{ 1.0 0.0 0.5 1.0 } " + "gadget." + } + "The " { $vocab-link "color-picker" } " module extends this example into a more elaborate color chooser." +} ; + +{ construct-control control-value set-control-value gadget-model } related-words + +HELP: control-value +{ $values { "control" gadget } { "value" object } } +{ $description "Outputs the value of the control's model." } ; + +HELP: set-control-value +{ $values { "value" object } { "control" gadget } } +{ $description "Sets the value of the control's model." } ; + +ARTICLE: "ui-control-impl" "Implementing controls" +"A " { $emphasis "control" } " is a gadget which is linked to an underlying " { $link model } " by having its " { $link gadget-model } " slot set to a model instance." +$nl +"To implement a new control, simply use this word in your constructor:" +{ $subsection construct-control } +"Some utility words useful in control implementations:" +{ $subsection gadget-model } +{ $subsection control-value } +{ $subsection set-control-value } +{ $see-also "models" } ; + +ABOUT: "ui-control-impl" diff --git a/extra/ui/gadgets/worlds/worlds-docs.factor b/extra/ui/gadgets/worlds/worlds-docs.factor index aedad9e049..34da6da6b3 100644 --- a/extra/ui/gadgets/worlds/worlds-docs.factor +++ b/extra/ui/gadgets/worlds/worlds-docs.factor @@ -55,6 +55,6 @@ HELP: find-world { $description "Finds the " { $link world } " containing the gadget, or outputs " { $link f } " if the gadget is not grafted." } ; HELP: draw-world -{ $values { "rect" "a clipping rectangle" } { "world" world } } +{ $values { "world" world } } { $description "Redraws a world." } { $notes "This word should only be called by the UI backend. To force a gadget to redraw from user code, call " { $link relayout-1 } "." } ; From 9ec1911625089097f8772b70f58d45a1b1da30bf Mon Sep 17 00:00:00 2001 From: Slava Pestov Date: Tue, 11 Dec 2007 22:37:31 -0500 Subject: [PATCH 09/27] Remove debug message --- extra/webapps/pastebin/pastebin.factor | 1 - 1 file changed, 1 deletion(-) diff --git a/extra/webapps/pastebin/pastebin.factor b/extra/webapps/pastebin/pastebin.factor index ca7591afd1..8e4c0a5be9 100755 --- a/extra/webapps/pastebin/pastebin.factor +++ b/extra/webapps/pastebin/pastebin.factor @@ -79,7 +79,6 @@ C: annotation pastebin-pastes 2dup length swap set-paste-n push ; : submit-paste ( summary author channel mode contents -- ) - 2dup global [ 2array . flush ] bind [ pastebin store get-persistent add-paste store save-store From 0670633393105343111bd54aabe4ce4fda78ea8c Mon Sep 17 00:00:00 2001 From: Slava Pestov Date: Wed, 12 Dec 2007 00:32:35 -0500 Subject: [PATCH 10/27] Bootstrap fix --- core/classes/classes-docs.factor | 14 -------------- extra/help/help-docs.factor | 6 +++++- extra/help/help.factor | 12 +++++++++++- 3 files changed, 16 insertions(+), 16 deletions(-) diff --git a/core/classes/classes-docs.factor b/core/classes/classes-docs.factor index e637c47933..130844e797 100644 --- a/core/classes/classes-docs.factor +++ b/core/classes/classes-docs.factor @@ -203,17 +203,3 @@ HELP: define-class { $values { "word" word } { "members" "a sequence of class words" } { "superclass" class } { "metaclass" class } } { $description "Sets a property indicating this word is a class word, thus making it an instance of " { $link class } ", and registers it with " { $link typemap } " and " { $link class Date: Wed, 12 Dec 2007 00:32:43 -0500 Subject: [PATCH 11/27] Clean up --- vm/quotations.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/vm/quotations.c b/vm/quotations.c index 9d98fa7842..649aaf8189 100755 --- a/vm/quotations.c +++ b/vm/quotations.c @@ -191,12 +191,13 @@ XT quot_offset_to_pc(F_QUOTATION *quot, F_FIXNUM offset) DEFINE_PRIMITIVE(curry) { - F_CURRY *curry = allot_object(CURRY_TYPE,sizeof(F_CURRY)); + F_CURRY *curry; switch(type_of(dpeek())) { case QUOTATION_TYPE: case CURRY_TYPE: + curry = allot_object(CURRY_TYPE,sizeof(F_CURRY)); curry->quot = dpop(); curry->obj = dpop(); dpush(tag_object(curry)); From 8815ff96f2142a860a912432c98db361f9a095e2 Mon Sep 17 00:00:00 2001 From: Slava Pestov Date: Wed, 12 Dec 2007 00:32:52 -0500 Subject: [PATCH 12/27] README.txt update for Mac OS X --- README.txt | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/README.txt b/README.txt index d574868892..c5bae96b9c 100644 --- a/README.txt +++ b/README.txt @@ -74,6 +74,10 @@ following command line: ./factor -i=boot..image +Or this command for Mac OS X systems: + +./Factor.app/Contents/MacOS/factor -i=boot..image + Bootstrap can take a while, depending on your system. When the process completes, a 'factor.image' file will be generated. Note that this image is both CPU and OS-specific, so in general cannot be shared between From 8cb2675a70ff68b996829923262d06a0dba7f3ce Mon Sep 17 00:00:00 2001 From: Doug Coleman Date: Wed, 12 Dec 2007 01:29:41 -0600 Subject: [PATCH 13/27] Add error checking to AddVectoredExceptionHandler --- vm/os-windows-nt.c | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/vm/os-windows-nt.c b/vm/os-windows-nt.c index da54b794d1..e425b6b94c 100755 --- a/vm/os-windows-nt.c +++ b/vm/os-windows-nt.c @@ -84,9 +84,11 @@ long exception_handler(PEXCEPTION_POINTERS pe) void c_to_factor_toplevel(CELL quot) { - AddVectoredExceptionHandler(0, (void*)exception_handler); + if(!AddVectoredExceptionHandler(0, (void*)exception_handler)) + fatal_error("AddVectoredExceptionHandler failed", 0); c_to_factor(quot); - RemoveVectoredExceptionHandler((void*)exception_handler); + if(!RemoveVectoredExceptionHandler((void*)exception_handler)) + fatal_error("RemoveVectoredExceptionHandler failed", 0); } void open_console(void) From 68268bff0eabf6c5ed49707cbe36c93155d6b9b9 Mon Sep 17 00:00:00 2001 From: Slava Pestov Date: Wed, 12 Dec 2007 02:34:14 -0500 Subject: [PATCH 14/27] Windows deploy fix --- extra/tools/deploy/windows/windows.factor | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/extra/tools/deploy/windows/windows.factor b/extra/tools/deploy/windows/windows.factor index 0d0241a5e0..34580cf6f9 100755 --- a/extra/tools/deploy/windows/windows.factor +++ b/extra/tools/deploy/windows/windows.factor @@ -1,7 +1,8 @@ ! Copyright (C) 2007 Slava Pestov. ! See http://factorcode.org/license.txt for BSD license. USING: io io.files kernel namespaces sequences system -tools.deploy tools.deploy.config assocs hashtables prettyprint ; +tools.deploy tools.deploy.config assocs hashtables prettyprint +windows.shell32 windows.user32 ; IN: tools.deploy.windows : copy-vm ( executable bundle-name -- vm ) @@ -38,4 +39,5 @@ M: windows-deploy-implementation deploy [ deploy-name get create-exe-dir ] keep [ deploy-name get image-name ] keep namespace + deploy-name get open-in-explorer ] bind deploy* ; From c9daaa8eca044792158139f9e5621b140878817a Mon Sep 17 00:00:00 2001 From: Doug Coleman Date: Wed, 12 Dec 2007 13:01:25 -0600 Subject: [PATCH 15/27] disable RemoveVectoredExceptionHandler error checking it's failing with error 258 - wait operation timed out if c_to_factor(quot) is not called, it still "fails" with error 0 - operation successful perhaps we need to clean up resources like the master io completion port? --- vm/os-windows-nt.c | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/vm/os-windows-nt.c b/vm/os-windows-nt.c index e425b6b94c..2b08d5f394 100755 --- a/vm/os-windows-nt.c +++ b/vm/os-windows-nt.c @@ -87,8 +87,7 @@ void c_to_factor_toplevel(CELL quot) if(!AddVectoredExceptionHandler(0, (void*)exception_handler)) fatal_error("AddVectoredExceptionHandler failed", 0); c_to_factor(quot); - if(!RemoveVectoredExceptionHandler((void*)exception_handler)) - fatal_error("RemoveVectoredExceptionHandler failed", 0); + RemoveVectoredExceptionHandler((void*)exception_handler); } void open_console(void) From 0e20f7eb7e6244cac52b161dd7fc64b020fd4b72 Mon Sep 17 00:00:00 2001 From: Doug Coleman Date: Wed, 12 Dec 2007 16:22:41 -0600 Subject: [PATCH 16/27] Fix compile on 64bit linux --- vm/platform.h | 1 - 1 file changed, 1 deletion(-) diff --git a/vm/platform.h b/vm/platform.h index a3b7350b69..d5687b849d 100644 --- a/vm/platform.h +++ b/vm/platform.h @@ -72,7 +72,6 @@ #elif defined(FACTOR_ARM) #include "os-linux-arm.h" #elif defined(FACTOR_AMD64) - #include "os-unix-ucontext.h" #include "os-linux-x86-64.h" #else #error "Unsupported Linux flavor" From e640f7bf3098e17b43705836df859ae8356af426 Mon Sep 17 00:00:00 2001 From: Slava Pestov Date: Wed, 12 Dec 2007 18:24:42 -0500 Subject: [PATCH 17/27] Updated windows release script --- misc/factor.el.html | 64 ++++++++++++++++++++++++++++++++++++++ misc/macos-release.sh.html | 64 ++++++++++++++++++++++++++++++++++++++ misc/windows-release.sh | 6 ++++ 3 files changed, 134 insertions(+) create mode 100755 misc/factor.el.html create mode 100755 misc/macos-release.sh.html diff --git a/misc/factor.el.html b/misc/factor.el.html new file mode 100755 index 0000000000..1d64f0f0ab --- /dev/null +++ b/misc/factor.el.html @@ -0,0 +1,64 @@ +C:\cygwin\home\Slava\factor/misc/factor.el
;; Eduardo Cavazos - wayo.cavazos@gmail.com

;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;; Add these lines to your .emacs file:

;; (load-file "/scratch/repos/Factor/misc/factor.el")
;; (setq factor-binary "/scratch/repos/Factor/factor")
;; (setq factor-image "/scratch/repos/Factor/factor.image")

;; Of course, you'll have to edit the directory paths for your system
;; accordingly.

;; That's all you have to do to "install" factor.el on your
;; system. Whenever you edit a factor file, Emacs will know to switch
;; to Factor mode.
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;

;; M-x run-factor === Start a Factor listener inside Emacs

;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;

;; BUG: A double quote character on a commented line will break the
;; syntax highlighting for that line.

(defgroup factor nil
"Factor mode"
:group 'languages)

(defvar factor-mode-syntax-table nil
"Syntax table used while in Factor mode.")

(if factor-mode-syntax-table
()
(let ((i 0))
(setq factor-mode-syntax-table (make-syntax-table))

;; Default is atom-constituent
(while (< i 256)
(modify-syntax-entry i "_ " factor-mode-syntax-table)
(setq i (1+ i)))

;; Word components.
(setq i ?0)
(while (<= i ?9)
(modify-syntax-entry i "w " factor-mode-syntax-table)
(setq i (1+ i)))
(setq i ?A)
(while (<= i ?Z)
(modify-syntax-entry i "w " factor-mode-syntax-table)
(setq i (1+ i)))
(setq i ?a)
(while (<= i ?z)
(modify-syntax-entry i "w " factor-mode-syntax-table)
(setq i (1+ i)))

;; Whitespace
(modify-syntax-entry ?\t " " factor-mode-syntax-table)
(modify-syntax-entry ?\n ">" factor-mode-syntax-table)
(modify-syntax-entry ?\f " " factor-mode-syntax-table)
(modify-syntax-entry ?\r " " factor-mode-syntax-table)
(modify-syntax-entry ? " " factor-mode-syntax-table)

(modify-syntax-entry ?\[ "(] " factor-mode-syntax-table)
(modify-syntax-entry ?\] ")[ " factor-mode-syntax-table)
(modify-syntax-entry ?{ "(} " factor-mode-syntax-table)
(modify-syntax-entry ?} "){ " factor-mode-syntax-table)

(modify-syntax-entry ?\( "()" factor-mode-syntax-table)
(modify-syntax-entry ?\) ")(" factor-mode-syntax-table)
(modify-syntax-entry ?\" "\" " factor-mode-syntax-table)))

(defvar factor-mode-map (make-sparse-keymap))

(defcustom factor-mode-hook nil
"Hook run when entering Factor mode."
:type 'hook
:group 'factor)

(defconst factor-font-lock-keywords
'(("#!.*$" . font-lock-comment-face)
("!( .* )" . font-lock-comment-face)
("^!.*$" . font-lock-comment-face)
(" !.*$" . font-lock-comment-face)
("( .* )" . font-lock-comment-face)
"MAIN:"
"IN:" "USING:" "TUPLE:" "^C:" "^M:" "USE:" "REQUIRE:" "PROVIDE:"
"REQUIRES:"
"GENERIC:" "GENERIC#" "SYMBOL:" "PREDICATE:" "VAR:" "VARS:"
"C-STRUCT:"
"C-UNION:" "<PRIVATE" "PRIVATE>" "MACRO:" "MACRO::" "DEFER:" "TYPEDEF:"))

(defun factor-mode ()
"A mode for editing programs written in the Factor programming language."
(interactive)
(kill-all-local-variables)
(use-local-map factor-mode-map)
(setq major-mode 'factor-mode)
(setq mode-name "Factor")
(make-local-variable 'comment-start)
(setq comment-start "! ")
(make-local-variable 'font-lock-defaults)
(setq font-lock-defaults
'(factor-font-lock-keywords nil nil nil nil))
(set-syntax-table factor-mode-syntax-table)
(run-hooks 'factor-mode-hooks))

(add-to-list 'auto-mode-alist '("\\.factor\\'" . factor-mode))

;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;

(require 'comint)

(defvar factor-binary "/scratch/repos/Factor/factor")
(defvar factor-image "/scratch/repos/Factor/factor.image")

(defun factor-telnet-to-port (port)
(interactive "nPort: ")
(switch-to-buffer
(make-comint-in-buffer "factor-telnet" nil (cons "localhost" port))))

(defun factor-telnet ()
(interactive)
(factor-telnet-to-port 9000))

(defun factor-telnet-factory ()
(interactive)
(factor-telnet-to-port 9010))

(defun factor-run-file ()
(interactive)
(comint-send-string "*factor*" (format "\"%s\"" (buffer-file-name)))
(comint-send-string "*factor*" " run-file\n"))

(defun factor-send-region (start end)
(interactive "r")
(comint-send-region "*factor*" start end)
(comint-send-string "*factor*" "\n"))

(defun factor-see ()
(interactive)
(comint-send-string "*factor*" "\\ ")
(comint-send-string "*factor*" (thing-at-point 'sexp))
(comint-send-string "*factor*" " see\n"))

(defun factor-help ()
(interactive)
(comint-send-string "*factor*" "\\ ")
(comint-send-string "*factor*" (thing-at-point 'sexp))
(comint-send-string "*factor*" " help\n"))

(defun factor-edit ()
(interactive)
(comint-send-string "*factor*" "\\ ")
(comint-send-string "*factor*" (thing-at-point 'sexp))
(comint-send-string "*factor*" " edit\n"))

(defun factor-comment-line ()
(interactive)
(beginning-of-line)
(insert "! "))

(define-key factor-mode-map "\C-c\C-f" 'factor-run-file)
(define-key factor-mode-map "\C-c\C-r" 'factor-send-region)
(define-key factor-mode-map "\C-c\C-s" 'factor-see)
(define-key factor-mode-map "\C-ce" 'factor-edit)
(define-key factor-mode-map "\C-c\C-h" 'factor-help)
(define-key factor-mode-map "\C-cc" 'comment-region)
(define-key factor-mode-map [return] 'newline-and-indent)

;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;; factor-listener-mode
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;

(define-derived-mode factor-listener-mode comint-mode "Factor Listener")

(define-key factor-listener-mode-map [f8] 'factor-refresh-all)

(defun run-factor ()
(interactive)
(switch-to-buffer
(make-comint-in-buffer "factor" nil factor-binary nil
(concat "-i=" factor-image)
"-run=listener"))
(factor-listener-mode))

(defun factor-refresh-all ()
(interactive)
(comint-send-string "*factor*" "refresh-all\n"))
\ No newline at end of file diff --git a/misc/macos-release.sh.html b/misc/macos-release.sh.html new file mode 100755 index 0000000000..17091e7bb5 --- /dev/null +++ b/misc/macos-release.sh.html @@ -0,0 +1,64 @@ +C:\cygwin\home\Slava\factor/misc/macos-release.sh
TARGET=$1

if [ "$TARGET" = "x86" ]; then
CPU="x86.32"
else
CPU="ppc"
fi

make macosx-$TARGET
Factor.app/Contents/MacOS/factor -i=boot.$CPU.image -no-user-init

VERSION=0.91
DISK_IMAGE_DIR=Factor-$VERSION
DISK_IMAGE=Factor-$VERSION-$TARGET.dmg

rm -f $DISK_IMAGE
rm -rf $DISK_IMAGE_DIR
mkdir $DISK_IMAGE_DIR
mkdir -p $DISK_IMAGE_DIR/Factor/
cp -R Factor.app $DISK_IMAGE_DIR/Factor/Factor.app
chmod +x cp_dir
cp factor.image license.txt README.txt $DISK_IMAGE_DIR/Factor/
find core extra fonts misc unmaintained -type f \
-exec ./cp_dir {} $DISK_IMAGE_DIR/Factor/{} \;
hdiutil create -srcfolder "$DISK_IMAGE_DIR" -fs HFS+ \
-volname "$DISK_IMAGE_DIR" "$DISK_IMAGE"
\ No newline at end of file diff --git a/misc/windows-release.sh b/misc/windows-release.sh index 052dc396ae..a32292e16a 100644 --- a/misc/windows-release.sh +++ b/misc/windows-release.sh @@ -6,9 +6,15 @@ if [ "$CPU" = "x86" ]; then fi make windows-nt-x86 + +wget http://factorcode.org/dlls/freetype6.dll +wget http://factorcode.org/dlls/zlib1.dll +wget http://factorcode.org/images/$VERSION/boot.x86.32.image + CMD="./factor-nt -i=boot.x86.32.image -no-user-init $FLAGS" echo $CMD $CMD +rm -rf .git/ rm -rf Factor.app/ rm -rf vm/ rm -f Makefile From 9af1c38a69b9f6848fe6f080be82fb0b983800aa Mon Sep 17 00:00:00 2001 From: Slava Pestov Date: Wed, 12 Dec 2007 18:25:03 -0500 Subject: [PATCH 18/27] Remove accidentally added files --- misc/factor.el.html | 64 -------------------------------------- misc/macos-release.sh.html | 64 -------------------------------------- 2 files changed, 128 deletions(-) delete mode 100755 misc/factor.el.html delete mode 100755 misc/macos-release.sh.html diff --git a/misc/factor.el.html b/misc/factor.el.html deleted file mode 100755 index 1d64f0f0ab..0000000000 --- a/misc/factor.el.html +++ /dev/null @@ -1,64 +0,0 @@ -C:\cygwin\home\Slava\factor/misc/factor.el
;; Eduardo Cavazos - wayo.cavazos@gmail.com

;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;; Add these lines to your .emacs file:

;; (load-file "/scratch/repos/Factor/misc/factor.el")
;; (setq factor-binary "/scratch/repos/Factor/factor")
;; (setq factor-image "/scratch/repos/Factor/factor.image")

;; Of course, you'll have to edit the directory paths for your system
;; accordingly.

;; That's all you have to do to "install" factor.el on your
;; system. Whenever you edit a factor file, Emacs will know to switch
;; to Factor mode.
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;

;; M-x run-factor === Start a Factor listener inside Emacs

;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;

;; BUG: A double quote character on a commented line will break the
;; syntax highlighting for that line.

(defgroup factor nil
"Factor mode"
:group 'languages)

(defvar factor-mode-syntax-table nil
"Syntax table used while in Factor mode.")

(if factor-mode-syntax-table
()
(let ((i 0))
(setq factor-mode-syntax-table (make-syntax-table))

;; Default is atom-constituent
(while (< i 256)
(modify-syntax-entry i "_ " factor-mode-syntax-table)
(setq i (1+ i)))

;; Word components.
(setq i ?0)
(while (<= i ?9)
(modify-syntax-entry i "w " factor-mode-syntax-table)
(setq i (1+ i)))
(setq i ?A)
(while (<= i ?Z)
(modify-syntax-entry i "w " factor-mode-syntax-table)
(setq i (1+ i)))
(setq i ?a)
(while (<= i ?z)
(modify-syntax-entry i "w " factor-mode-syntax-table)
(setq i (1+ i)))

;; Whitespace
(modify-syntax-entry ?\t " " factor-mode-syntax-table)
(modify-syntax-entry ?\n ">" factor-mode-syntax-table)
(modify-syntax-entry ?\f " " factor-mode-syntax-table)
(modify-syntax-entry ?\r " " factor-mode-syntax-table)
(modify-syntax-entry ? " " factor-mode-syntax-table)

(modify-syntax-entry ?\[ "(] " factor-mode-syntax-table)
(modify-syntax-entry ?\] ")[ " factor-mode-syntax-table)
(modify-syntax-entry ?{ "(} " factor-mode-syntax-table)
(modify-syntax-entry ?} "){ " factor-mode-syntax-table)

(modify-syntax-entry ?\( "()" factor-mode-syntax-table)
(modify-syntax-entry ?\) ")(" factor-mode-syntax-table)
(modify-syntax-entry ?\" "\" " factor-mode-syntax-table)))

(defvar factor-mode-map (make-sparse-keymap))

(defcustom factor-mode-hook nil
"Hook run when entering Factor mode."
:type 'hook
:group 'factor)

(defconst factor-font-lock-keywords
'(("#!.*$" . font-lock-comment-face)
("!( .* )" . font-lock-comment-face)
("^!.*$" . font-lock-comment-face)
(" !.*$" . font-lock-comment-face)
("( .* )" . font-lock-comment-face)
"MAIN:"
"IN:" "USING:" "TUPLE:" "^C:" "^M:" "USE:" "REQUIRE:" "PROVIDE:"
"REQUIRES:"
"GENERIC:" "GENERIC#" "SYMBOL:" "PREDICATE:" "VAR:" "VARS:"
"C-STRUCT:"
"C-UNION:" "<PRIVATE" "PRIVATE>" "MACRO:" "MACRO::" "DEFER:" "TYPEDEF:"))

(defun factor-mode ()
"A mode for editing programs written in the Factor programming language."
(interactive)
(kill-all-local-variables)
(use-local-map factor-mode-map)
(setq major-mode 'factor-mode)
(setq mode-name "Factor")
(make-local-variable 'comment-start)
(setq comment-start "! ")
(make-local-variable 'font-lock-defaults)
(setq font-lock-defaults
'(factor-font-lock-keywords nil nil nil nil))
(set-syntax-table factor-mode-syntax-table)
(run-hooks 'factor-mode-hooks))

(add-to-list 'auto-mode-alist '("\\.factor\\'" . factor-mode))

;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;

(require 'comint)

(defvar factor-binary "/scratch/repos/Factor/factor")
(defvar factor-image "/scratch/repos/Factor/factor.image")

(defun factor-telnet-to-port (port)
(interactive "nPort: ")
(switch-to-buffer
(make-comint-in-buffer "factor-telnet" nil (cons "localhost" port))))

(defun factor-telnet ()
(interactive)
(factor-telnet-to-port 9000))

(defun factor-telnet-factory ()
(interactive)
(factor-telnet-to-port 9010))

(defun factor-run-file ()
(interactive)
(comint-send-string "*factor*" (format "\"%s\"" (buffer-file-name)))
(comint-send-string "*factor*" " run-file\n"))

(defun factor-send-region (start end)
(interactive "r")
(comint-send-region "*factor*" start end)
(comint-send-string "*factor*" "\n"))

(defun factor-see ()
(interactive)
(comint-send-string "*factor*" "\\ ")
(comint-send-string "*factor*" (thing-at-point 'sexp))
(comint-send-string "*factor*" " see\n"))

(defun factor-help ()
(interactive)
(comint-send-string "*factor*" "\\ ")
(comint-send-string "*factor*" (thing-at-point 'sexp))
(comint-send-string "*factor*" " help\n"))

(defun factor-edit ()
(interactive)
(comint-send-string "*factor*" "\\ ")
(comint-send-string "*factor*" (thing-at-point 'sexp))
(comint-send-string "*factor*" " edit\n"))

(defun factor-comment-line ()
(interactive)
(beginning-of-line)
(insert "! "))

(define-key factor-mode-map "\C-c\C-f" 'factor-run-file)
(define-key factor-mode-map "\C-c\C-r" 'factor-send-region)
(define-key factor-mode-map "\C-c\C-s" 'factor-see)
(define-key factor-mode-map "\C-ce" 'factor-edit)
(define-key factor-mode-map "\C-c\C-h" 'factor-help)
(define-key factor-mode-map "\C-cc" 'comment-region)
(define-key factor-mode-map [return] 'newline-and-indent)

;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;; factor-listener-mode
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;

(define-derived-mode factor-listener-mode comint-mode "Factor Listener")

(define-key factor-listener-mode-map [f8] 'factor-refresh-all)

(defun run-factor ()
(interactive)
(switch-to-buffer
(make-comint-in-buffer "factor" nil factor-binary nil
(concat "-i=" factor-image)
"-run=listener"))
(factor-listener-mode))

(defun factor-refresh-all ()
(interactive)
(comint-send-string "*factor*" "refresh-all\n"))
\ No newline at end of file diff --git a/misc/macos-release.sh.html b/misc/macos-release.sh.html deleted file mode 100755 index 17091e7bb5..0000000000 --- a/misc/macos-release.sh.html +++ /dev/null @@ -1,64 +0,0 @@ -C:\cygwin\home\Slava\factor/misc/macos-release.sh
TARGET=$1

if [ "$TARGET" = "x86" ]; then
CPU="x86.32"
else
CPU="ppc"
fi

make macosx-$TARGET
Factor.app/Contents/MacOS/factor -i=boot.$CPU.image -no-user-init

VERSION=0.91
DISK_IMAGE_DIR=Factor-$VERSION
DISK_IMAGE=Factor-$VERSION-$TARGET.dmg

rm -f $DISK_IMAGE
rm -rf $DISK_IMAGE_DIR
mkdir $DISK_IMAGE_DIR
mkdir -p $DISK_IMAGE_DIR/Factor/
cp -R Factor.app $DISK_IMAGE_DIR/Factor/Factor.app
chmod +x cp_dir
cp factor.image license.txt README.txt $DISK_IMAGE_DIR/Factor/
find core extra fonts misc unmaintained -type f \
-exec ./cp_dir {} $DISK_IMAGE_DIR/Factor/{} \;
hdiutil create -srcfolder "$DISK_IMAGE_DIR" -fs HFS+ \
-volname "$DISK_IMAGE_DIR" "$DISK_IMAGE"
\ No newline at end of file From 530c05226ee2b54f50e967b2fbdb74a448d93c11 Mon Sep 17 00:00:00 2001 From: Slava Pestov Date: Wed, 12 Dec 2007 18:35:46 -0500 Subject: [PATCH 19/27] Update release scripts --- misc/macos-release.sh | 12 ++++++++---- misc/source-release.sh | 4 ++++ misc/version.sh | 1 + misc/windows-release.sh | 3 ++- 4 files changed, 15 insertions(+), 5 deletions(-) create mode 100644 misc/source-release.sh create mode 100644 misc/version.sh diff --git a/misc/macos-release.sh b/misc/macos-release.sh index 6a25ba2012..4f62501a1b 100644 --- a/misc/macos-release.sh +++ b/misc/macos-release.sh @@ -1,15 +1,19 @@ +source misc/version.sh + TARGET=$1 if [ "$TARGET" = "x86" ]; then CPU="x86.32" else - CPU="ppc" + CPU="macosx-ppc" fi -make macosx-$TARGET -Factor.app/Contents/MacOS/factor -i=boot.$CPU.image -no-user-init +BOOT_IMAGE=boot.$CPU.image +wget http://factorcode.org/images/$VERSION/$BOOT_IMAGE + +make macosx-$TARGET +Factor.app/Contents/MacOS/factor -i=$BOOT_IMAGE -no-user-init -VERSION=0.91 DISK_IMAGE_DIR=Factor-$VERSION DISK_IMAGE=Factor-$VERSION-$TARGET.dmg diff --git a/misc/source-release.sh b/misc/source-release.sh new file mode 100644 index 0000000000..647bd49760 --- /dev/null +++ b/misc/source-release.sh @@ -0,0 +1,4 @@ +source misc/version.sh +rm -rf .git +cd .. +tar cfz Factor-$VERSION.tgz factor/ diff --git a/misc/version.sh b/misc/version.sh new file mode 100644 index 0000000000..0bc37f62df --- /dev/null +++ b/misc/version.sh @@ -0,0 +1 @@ +export VERSION=0.91 diff --git a/misc/windows-release.sh b/misc/windows-release.sh index a32292e16a..1f947ff3f4 100644 --- a/misc/windows-release.sh +++ b/misc/windows-release.sh @@ -1,5 +1,6 @@ +source misc/version.sh + CPU=$1 -VERSION=0.91 if [ "$CPU" = "x86" ]; then FLAGS="-no-sse2" From 3f22d61a0482bb5f6b60d0252e28598bbc5b0fba Mon Sep 17 00:00:00 2001 From: Slava Pestov Date: Wed, 12 Dec 2007 18:57:22 -0500 Subject: [PATCH 20/27] Update build scripts --- misc/macos-release.sh | 3 +++ misc/source-release.sh | 3 +++ 2 files changed, 6 insertions(+) diff --git a/misc/macos-release.sh b/misc/macos-release.sh index 4f62501a1b..57ac2b2255 100644 --- a/misc/macos-release.sh +++ b/misc/macos-release.sh @@ -28,3 +28,6 @@ find core extra fonts misc unmaintained -type f \ -exec ./cp_dir {} $DISK_IMAGE_DIR/Factor/{} \; hdiutil create -srcfolder "$DISK_IMAGE_DIR" -fs HFS+ \ -volname "$DISK_IMAGE_DIR" "$DISK_IMAGE" + +ssh mkdir -p linode:w/downloads/$VERSION/ +scp $DISK_IMAGE linode:w/downloads/$VERSION/ diff --git a/misc/source-release.sh b/misc/source-release.sh index 647bd49760..78a6fe2826 100644 --- a/misc/source-release.sh +++ b/misc/source-release.sh @@ -2,3 +2,6 @@ source misc/version.sh rm -rf .git cd .. tar cfz Factor-$VERSION.tgz factor/ + +ssh mkdir -p linode:w/downloads/$VERSION/ +scp Factor-$VERSION.tgz linode:w/downloads/$VERSION/ From 257736bd6aa167fb94f32052574f8074e793328c Mon Sep 17 00:00:00 2001 From: Slava Pestov Date: Thu, 13 Dec 2007 14:16:55 -0500 Subject: [PATCH 21/27] Update script again --- misc/macos-release.sh | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/misc/macos-release.sh b/misc/macos-release.sh index 57ac2b2255..c265b8a80f 100644 --- a/misc/macos-release.sh +++ b/misc/macos-release.sh @@ -2,16 +2,18 @@ source misc/version.sh TARGET=$1 -if [ "$TARGET" = "x86" ]; then +if [ "$1" = "x86" ]; then CPU="x86.32" + TARGET=macosx-x86-32 else CPU="macosx-ppc" + TARGET=macosx-ppc fi BOOT_IMAGE=boot.$CPU.image wget http://factorcode.org/images/$VERSION/$BOOT_IMAGE -make macosx-$TARGET +make $TARGET Factor.app/Contents/MacOS/factor -i=$BOOT_IMAGE -no-user-init DISK_IMAGE_DIR=Factor-$VERSION From b2b1f2cfa8c2031441c8e6a7d5de2d535140e739 Mon Sep 17 00:00:00 2001 From: Slava Pestov Date: Thu, 13 Dec 2007 14:21:04 -0500 Subject: [PATCH 22/27] Fix the script (again??) --- misc/macos-release.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/misc/macos-release.sh b/misc/macos-release.sh index c265b8a80f..3a080e0ae6 100644 --- a/misc/macos-release.sh +++ b/misc/macos-release.sh @@ -31,5 +31,5 @@ find core extra fonts misc unmaintained -type f \ hdiutil create -srcfolder "$DISK_IMAGE_DIR" -fs HFS+ \ -volname "$DISK_IMAGE_DIR" "$DISK_IMAGE" -ssh mkdir -p linode:w/downloads/$VERSION/ +ssh linode mkdir -p w/downloads/$VERSION/ scp $DISK_IMAGE linode:w/downloads/$VERSION/ From 9766faca6d45dfe3079ea944531748b664c0f509 Mon Sep 17 00:00:00 2001 From: Slava Pestov Date: Thu, 13 Dec 2007 14:22:02 -0500 Subject: [PATCH 23/27] More script fixes --- misc/source-release.sh | 6 +++--- misc/windows-release.sh | 7 ++++++- 2 files changed, 9 insertions(+), 4 deletions(-) diff --git a/misc/source-release.sh b/misc/source-release.sh index 78a6fe2826..37aa98e1e3 100644 --- a/misc/source-release.sh +++ b/misc/source-release.sh @@ -1,7 +1,7 @@ source misc/version.sh rm -rf .git cd .. -tar cfz Factor-$VERSION.tgz factor/ +tar cfz Factor-$VERSION.tar.gz factor/ -ssh mkdir -p linode:w/downloads/$VERSION/ -scp Factor-$VERSION.tgz linode:w/downloads/$VERSION/ +ssh linode mkdir -p w/downloads/$VERSION/ +scp Factor-$VERSION.tar.gz linode:w/downloads/$VERSION/ diff --git a/misc/windows-release.sh b/misc/windows-release.sh index 1f947ff3f4..91c5935f81 100644 --- a/misc/windows-release.sh +++ b/misc/windows-release.sh @@ -22,5 +22,10 @@ rm -f Makefile rm -f cp_dir rm -f boot.*.image +FILE=Factor-$VERSION-win32-$CPU.zip + cd .. -zip -r Factor-$VERSION-win32-$CPU.zip Factor/ +zip -r $FILE Factor/ + +ssh linode mkdir -p w/downloads/$VERSION/ +scp $FILE linode:w/downloads/$VERSION/ From fda9958ab40de4e397d26f71c1e3e6e75e94cf5c Mon Sep 17 00:00:00 2001 From: Slava Pestov Date: Thu, 13 Dec 2007 15:15:54 -0500 Subject: [PATCH 24/27] Starting 0.92 --- core/kernel/kernel.factor | 2 +- misc/version.sh | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/core/kernel/kernel.factor b/core/kernel/kernel.factor index 88ca0a64f7..6fe0a9588c 100644 --- a/core/kernel/kernel.factor +++ b/core/kernel/kernel.factor @@ -3,7 +3,7 @@ USING: kernel.private ; IN: kernel -: version ( -- str ) "0.91" ; foldable +: version ( -- str ) "0.92" ; foldable ! Stack stuff : roll ( x y z t -- y z t x ) >r rot r> swap ; inline diff --git a/misc/version.sh b/misc/version.sh index 0bc37f62df..9c5d02d463 100644 --- a/misc/version.sh +++ b/misc/version.sh @@ -1 +1 @@ -export VERSION=0.91 +export VERSION=0.92 From 114ee74041d20aa7b9ccdb57a4b8f8023119392d Mon Sep 17 00:00:00 2001 From: Slava Pestov Date: Thu, 13 Dec 2007 16:34:36 -0500 Subject: [PATCH 25/27] Fix one-word-elt --- extra/documents/documents.factor | 4 ++-- extra/springies/models/2x2snake/deploy.factor | 13 +++++++++++++ extra/ui/gadgets/editors/editors-tests.factor | 10 ++++++++++ extra/ui/gadgets/editors/editors.factor | 10 +++++----- 4 files changed, 30 insertions(+), 7 deletions(-) create mode 100644 extra/springies/models/2x2snake/deploy.factor diff --git a/extra/documents/documents.factor b/extra/documents/documents.factor index 01034e0e3f..97433d247f 100755 --- a/extra/documents/documents.factor +++ b/extra/documents/documents.factor @@ -195,11 +195,11 @@ TUPLE: one-word-elt ; M: one-word-elt prev-elt drop - [ [ f -rot >r 1- r> (prev-word) ] (word-elt) ] (prev-char) ; + [ f -rot >r 1- r> (prev-word) ] (word-elt) ; M: one-word-elt next-elt drop - [ [ f -rot (next-word) ] (word-elt) ] (next-char) ; + [ f -rot (next-word) ] (word-elt) ; TUPLE: word-elt ; diff --git a/extra/springies/models/2x2snake/deploy.factor b/extra/springies/models/2x2snake/deploy.factor new file mode 100644 index 0000000000..1ad6cfe172 --- /dev/null +++ b/extra/springies/models/2x2snake/deploy.factor @@ -0,0 +1,13 @@ +USING: tools.deploy.config ; +H{ + { deploy-compiler? t } + { deploy-word-props? f } + { deploy-ui? t } + { deploy-reflection 1 } + { deploy-name "springies.models.2x2snake" } + { deploy-c-types? f } + { deploy-word-defs? f } + { "stop-after-last-window?" t } + { deploy-math? t } + { deploy-io 1 } +} diff --git a/extra/ui/gadgets/editors/editors-tests.factor b/extra/ui/gadgets/editors/editors-tests.factor index 6be0423e95..cbccb37111 100755 --- a/extra/ui/gadgets/editors/editors-tests.factor +++ b/extra/ui/gadgets/editors/editors-tests.factor @@ -30,6 +30,16 @@ tools.test.inference tools.test.ui models ; ] with-grafted-gadget ] unit-test +[ "bar" ] [ + "editor" set + "editor" get [ + "bar\nbaz quux" "editor" get set-editor-string + { 0 3 } "editor" get editor-caret set-model + "editor" get select-word + "editor" get gadget-selection + ] with-grafted-gadget +] unit-test + { 0 1 } [ ] unit-test-effect "hello" "field" set diff --git a/extra/ui/gadgets/editors/editors.factor b/extra/ui/gadgets/editors/editors.factor index 84cc01cdb6..eb1d5daf26 100755 --- a/extra/ui/gadgets/editors/editors.factor +++ b/extra/ui/gadgets/editors/editors.factor @@ -320,11 +320,6 @@ M: editor gadget-text* editor-string % ; : end-of-document ( editor -- ) T{ doc-elt } editor-next ; -: selected-word ( editor -- string ) - dup gadget-selection? [ - dup T{ one-word-elt } select-elt - ] unless gadget-selection ; - : position-caret ( editor -- ) mouse-elt dup T{ one-char-elt } = [ drop dup extend-selection dup editor-mark click-loc ] @@ -408,6 +403,11 @@ editor "caret-motion" f { : select-word T{ one-word-elt } select-elt ; +: selected-word ( editor -- string ) + dup gadget-selection? + [ dup select-word ] unless + gadget-selection ; + : select-previous-character T{ char-elt } editor-select-prev ; : select-next-character T{ char-elt } editor-select-next ; From 52bb787631a910b47e72b3a4d7e5b8f9f9cb534a Mon Sep 17 00:00:00 2001 From: Slava Pestov Date: Fri, 14 Dec 2007 01:16:47 -0500 Subject: [PATCH 26/27] Fix Enter key in deploy tool --- extra/ui/gadgets/editors/editors.factor | 28 ++++++++++++++------- extra/ui/tools/deploy/deploy.factor | 2 +- extra/ui/tools/interactor/interactor.factor | 5 ++-- extra/ui/tools/search/search.factor | 3 ++- 4 files changed, 24 insertions(+), 14 deletions(-) diff --git a/extra/ui/gadgets/editors/editors.factor b/extra/ui/gadgets/editors/editors.factor index eb1d5daf26..2d447db1e9 100755 --- a/extra/ui/gadgets/editors/editors.factor +++ b/extra/ui/gadgets/editors/editors.factor @@ -34,14 +34,10 @@ focused? ; : field-theme ( gadget -- ) gray swap set-gadget-boundary ; -: construct-editor ( class -- tuple ) - >r { set-gadget-delegate } r> construct +: construct-editor ( object class -- tuple ) + >r { set-gadget-delegate } r> construct dup dup set-editor-self ; inline -TUPLE: source-editor ; - -: source-editor construct-editor ; - : activate-editor-model ( editor model -- ) 2dup add-connection dup activate-model @@ -340,9 +336,6 @@ M: editor gadget-text* editor-string % ; : delete-to-end-of-line T{ one-line-elt } editor-backspace ; editor "general" f { - { T{ key-down f f "RET" } insert-newline } - { T{ key-down f { S+ } "RET" } insert-newline } - { T{ key-down f f "ENTER" } insert-newline } { T{ key-down f f "DELETE" } delete-next-character } { T{ key-down f { S+ } "DELETE" } delete-next-character } { T{ key-down f f "BACKSPACE" } delete-previous-character } @@ -448,6 +441,23 @@ editor "selection" f { { T{ key-down f { S+ C+ } "END" } select-end-of-document } } define-command-map +! Multi-line editors +TUPLE: multiline-editor ; + +: ( -- editor ) + multiline-editor construct-editor ; + +multiline-editor "general" f { + { T{ key-down f f "RET" } insert-newline } + { T{ key-down f { S+ } "RET" } insert-newline } + { T{ key-down f f "ENTER" } insert-newline } +} define-command-map + +TUPLE: source-editor ; + +: ( -- editor ) + source-editor construct-editor ; + ! Fields are like editors except they edit an external model TUPLE: field model editor ; diff --git a/extra/ui/tools/deploy/deploy.factor b/extra/ui/tools/deploy/deploy.factor index e7d9161079..7b20c4591f 100755 --- a/extra/ui/tools/deploy/deploy.factor +++ b/extra/ui/tools/deploy/deploy.factor @@ -95,7 +95,7 @@ deploy-gadget "toolbar" f { { f com-help } { f com-revert } { f com-save } - { T{ key-down f f "RETURN" } com-deploy } + { T{ key-down f f "RET" } com-deploy } } define-command-map : buttons, diff --git a/extra/ui/tools/interactor/interactor.factor b/extra/ui/tools/interactor/interactor.factor index b603cc5eea..45494124c8 100755 --- a/extra/ui/tools/interactor/interactor.factor +++ b/extra/ui/tools/interactor/interactor.factor @@ -33,9 +33,8 @@ help ; : ( output -- gadget ) - { set-interactor-output set-gadget-delegate } - interactor construct - dup dup set-editor-self + interactor construct-editor + tuck set-interactor-output dup init-interactor-history dup init-caret-help ; diff --git a/extra/ui/tools/search/search.factor b/extra/ui/tools/search/search.factor index 157e8473ef..f77cf59fad 100755 --- a/extra/ui/tools/search/search.factor +++ b/extra/ui/tools/search/search.factor @@ -33,7 +33,8 @@ M: live-search handle-gesture* ( gadget gesture delegate -- ? ) TUPLE: search-field ; -: ( -- gadget ) search-field construct-editor ; +: ( -- gadget ) + search-field construct-editor ; search-field H{ { T{ key-down f f "UP" } [ find-search-list select-previous ] } From c726962a7a106eb4474875d9edb3084028958e2f Mon Sep 17 00:00:00 2001 From: Daniel Ehrenberg Date: Sat, 15 Dec 2007 16:20:32 -0500 Subject: [PATCH 27/27] Fixing insufficient safety in flip and M: column virtual@ --- core/sequences/sequences.factor | 14 ++++++++------ 1 file changed, 8 insertions(+), 6 deletions(-) diff --git a/core/sequences/sequences.factor b/core/sequences/sequences.factor index de10e5c2e4..c580bbe118 100755 --- a/core/sequences/sequences.factor +++ b/core/sequences/sequences.factor @@ -221,7 +221,8 @@ TUPLE: column seq col ; C: column M: column virtual-seq column-seq ; -M: column virtual@ dup column-col -rot column-seq nth ; +M: column virtual@ + dup column-col -rot column-seq nth bounds-check ; M: column length column-seq length ; INSTANCE: column virtual-sequence @@ -546,11 +547,6 @@ M: sequence <=> : all-eq? ( seq -- ? ) [ eq? ] monotonic? ; -: flip ( matrix -- newmatrix ) - dup empty? [ - dup first length [ dup like ] curry* map - ] unless ; - : exchange ( m n seq -- ) pick over bounds-check 2drop 2dup bounds-check 2drop exchange-unsafe ; @@ -667,6 +663,12 @@ PRIVATE> : infimum ( seq -- n ) dup first [ min ] reduce ; : supremum ( seq -- n ) dup first [ max ] reduce ; +: flip ( matrix -- newmatrix ) + dup empty? [ + dup [ length ] map infimum + [ dup like ] curry* map + ] unless ; + : sequence-hashcode ( n seq -- x ) 0 -rot [ hashcode* >fixnum swap 31 fixnum*fast fixnum+fast