diff --git a/Makefile b/Makefile index 4c6eb2f4e6..4228a6f8ad 100644 --- a/Makefile +++ b/Makefile @@ -57,12 +57,12 @@ default: @echo "openbsd-x86-32" @echo "openbsd-x86-64" @echo "macosx-x86-32" + @echo "macosx-x86-64" @echo "macosx-ppc" @echo "solaris-x86-32" @echo "solaris-x86-64" @echo "windows-ce-arm" @echo "windows-nt-x86-32" - @echo "windows-nt-x86-64" @echo "" @echo "Additional modifiers:" @echo "" @@ -93,6 +93,9 @@ macosx-ppc: macosx-freetype macosx-x86-32: macosx-freetype $(MAKE) $(EXECUTABLE) macosx.app CONFIG=vm/Config.macosx.x86.32 +macosx-x86-64: macosx-freetype + $(MAKE) $(EXECUTABLE) macosx.app CONFIG=vm/Config.macosx.x86.64 + linux-x86-32: $(MAKE) $(EXECUTABLE) CONFIG=vm/Config.linux.x86.32 @@ -114,9 +117,6 @@ solaris-x86-64: windows-nt-x86-32: $(MAKE) $(EXECUTABLE) CONFIG=vm/Config.windows.nt.x86.32 -windows-nt-x86-64: - $(MAKE) $(EXECUTABLE) CONFIG=vm/Config.windows.nt.x86.64 - windows-ce-arm: $(MAKE) $(EXECUTABLE) CONFIG=vm/Config.windows.ce.arm @@ -142,7 +142,7 @@ clean: rm -f vm/*.o vm/resources.o: - $(WINDRES) vm/factor.rs vm/resources.o + windres vm/factor.rs vm/resources.o .c.o: $(CC) -c $(CFLAGS) -o $@ $< 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 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/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 classcontinuation< -{ $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..fdfa7ddd7b 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 arrays math ; 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 @@ -154,3 +156,7 @@ HELP: sort-articles { $description "Sorts a sequence of help topics." } ; { article-children article-parent xref-help } related-words + +HELP: $predicate +{ $values { "element" "a markup element of the form " { $snippet "{ word }" } } } +{ $description "Prints the boilerplate description of a class membership predicate word such as " { $link array? } " or " { $link integer? } "." } ; diff --git a/extra/help/help.factor b/extra/help/help.factor index 975ed73dc8..87bc0a4b7f 100644 --- a/extra/help/help.factor +++ b/extra/help/help.factor @@ -4,7 +4,7 @@ USING: arrays io kernel namespaces parser prettyprint sequences words assocs definitions generic quotations effects slots continuations tuples debugger combinators vocabs help.stylesheet help.topics help.crossref help.markup -sorting ; +sorting classes ; IN: help GENERIC: word-help* ( word -- content ) @@ -15,12 +15,22 @@ GENERIC: word-help* ( word -- content ) [ swap 2array 1array ] [ 2drop f ] if ] ?if ; +: $predicate ( element -- ) + { { "object" object } { "?" "a boolean" } } $values + [ + "Tests if the object is an instance of the " , + first "predicating" word-prop \ $link swap 2array , + " class." , + ] { } make $description ; + M: word word-help* drop f ; M: slot-reader word-help* drop \ $slot-reader ; M: slot-writer word-help* drop \ $slot-writer ; +M: predicate word-help* drop \ $predicate ; + : all-articles ( -- seq ) articles get keys all-words [ word-help ] subset append ; 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 " } +{ $description "This forms a multiline string literal ending in \">. Unlike the " { $link POSTPONE: STRING: } " form, you can end it in the middle of a line. This construct is non-nesting. In the example above, the string would be parsed as \"text\"." } ; + +{ POSTPONE: <" POSTPONE: STRING: } related-words + +HELP: parse-here +{ $values { "str" "a string" } } +{ $description "Parses a multiline string literal, as used by " { $link POSTPONE: STRING: } "." } ; + +HELP: parse-multiline-string +{ $values { "end-text" "a string delineating the end" } { "str" "the parsed string" } } +{ $description "Parses a multiline string literal, as used by " { $link POSTPONE: <" } ". The end-text is the delimiter for the end." } ; + +{ parse-here parse-multiline-string } related-words diff --git a/extra/multiline/multiline-tests.factor b/extra/multiline/multiline-tests.factor new file mode 100644 index 0000000000..a9b9ee2322 --- /dev/null +++ b/extra/multiline/multiline-tests.factor @@ -0,0 +1,12 @@ +USING: multiline tools.test ; + +STRING: test-it +foo +bar + +; + +[ "foo\nbar\n" ] [ test-it ] unit-test +[ "foo\nbar\n" ] [ <" foo +bar + "> ] unit-test diff --git a/extra/multiline/multiline.factor b/extra/multiline/multiline.factor new file mode 100644 index 0000000000..89a6e06053 --- /dev/null +++ b/extra/multiline/multiline.factor @@ -0,0 +1,35 @@ +! Copyright (C) 2007 Daniel Ehrenberg +! See http://factorcode.org/license.txt for BSD license. +USING: namespaces parser kernel sequences words quotations math ; +IN: multiline + +: next-line-text ( -- str ) + lexer get dup next-line line-text ; + +: (parse-here) ( -- ) + next-line-text dup ";" = + [ drop lexer get next-line ] [ % "\n" % (parse-here) ] if ; + +: parse-here ( -- str ) + [ (parse-here) ] "" make 1 head* + lexer get next-line ; + +: STRING: + CREATE dup reset-generic + parse-here 1quotation define-compound ; parsing + +: (parse-multiline-string) ( start-index end-text -- end-index ) + lexer get line-text 2dup start + [ rot dupd >r >r swap subseq % r> r> length + ] [ + rot tail % "\n" % 0 + lexer get next-line swap (parse-multiline-string) + ] if* ; + +: parse-multiline-string ( end-text -- str ) + [ + lexer get lexer-column swap (parse-multiline-string) + lexer get set-lexer-column + ] "" make 1 tail 1 head* ; + +: <" + "\">" parse-multiline-string parsed ; parsing diff --git a/extra/multiline/summary.txt b/extra/multiline/summary.txt new file mode 100644 index 0000000000..9d9c3ea73f --- /dev/null +++ b/extra/multiline/summary.txt @@ -0,0 +1 @@ +Multiline string literals diff --git a/extra/parser-combinators/replace/replace-docs.factor b/extra/parser-combinators/replace/replace-docs.factor index e0d75b38a7..fe73f5d3c2 100644 --- a/extra/parser-combinators/replace/replace-docs.factor +++ b/extra/parser-combinators/replace/replace-docs.factor @@ -10,7 +10,7 @@ HELP: tree-write "Write the object to the standard output stream, unless " "it is an array, in which case recurse through the array " "writing each object to the stream." } -{ $example "[ { 65 \"bc\" { 68 \"ef\" } } tree-write ] string-out ." "\"AbcDef\"" } ; +{ $example "USE: parser-combinators" "{ 65 \"bc\" { 68 \"ef\" } } tree-write" "AbcDef" } ; HELP: search { $values @@ -24,8 +24,8 @@ HELP: search "parser." } -{ $example "\"one 123 two 456\" 'integer' search ." "{ 123 456 }" } -{ $example "\"one 123 \\\"hello\\\" two 456\" 'integer' 'string' <|> 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/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* ; 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 } "." } ; 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 diff --git a/vm/Config.macosx.x86.64 b/vm/Config.macosx.x86.64 new file mode 100644 index 0000000000..e2063c4a75 --- /dev/null +++ b/vm/Config.macosx.x86.64 @@ -0,0 +1,3 @@ +include vm/Config.macosx +include vm/Config.x86.64 +CFLAGS += -arch x86_64 diff --git a/vm/os-macosx-x86.64.h b/vm/os-macosx-x86.64.h new file mode 100644 index 0000000000..d2bb48c3fe --- /dev/null +++ b/vm/os-macosx-x86.64.h @@ -0,0 +1,35 @@ +/* Fault handler information. MacOSX version. +Copyright (C) 1993-1999, 2002-2003 Bruno Haible +Copyright (C) 2003 Paolo Bonzini + +Used under BSD license with permission from Paolo Bonzini and Bruno Haible, +2005-03-10: + +http://sourceforge.net/mailarchive/message.php?msg_name=200503102200.32002.bruno%40clisp.org + +Modified for Factor by Slava Pestov and Daniel Ehrenberg */ +#define MACH_EXC_STATE_TYPE x86_exception_state64_t +#define MACH_EXC_STATE_FLAVOR x86_EXCEPTION_STATE64 +#define MACH_EXC_STATE_COUNT x86_EXCEPTION_STATE64_COUNT +#define MACH_THREAD_STATE_TYPE x86_thread_state64_t +#define MACH_THREAD_STATE_FLAVOR x86_THREAD_STATE64 +#define MACH_THREAD_STATE_COUNT MACHINE_THREAD_STATE_COUNT + +#if __DARWIN_UNIX03 + #define MACH_EXC_STATE_FAULT(exc_state) (exc_state)->__faultvaddr + #define MACH_STACK_POINTER(thr_state) (thr_state)->__rsp + #define MACH_PROGRAM_COUNTER(thr_state) (thr_state)->__rip + #define UAP_PROGRAM_COUNTER(ucontext) \ + MACH_PROGRAM_COUNTER(&(((ucontext_t *)(ucontext))->uc_mcontext->__ss)) +#else + #define MACH_EXC_STATE_FAULT(exc_state) (exc_state)->faultvaddr + #define MACH_STACK_POINTER(thr_state) (thr_state)->rsp + #define MACH_PROGRAM_COUNTER(thr_state) (thr_state)->rip + #define UAP_PROGRAM_COUNTER(ucontext) \ + MACH_PROGRAM_COUNTER(&(((ucontext_t *)(ucontext))->uc_mcontext->ss)) +#endif + +INLINE CELL fix_stack_pointer(CELL sp) +{ + return ((sp + 8) & ~15) - 8; +} 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) diff --git a/vm/platform.h b/vm/platform.h index 75228726a9..a3b7350b69 100644 --- a/vm/platform.h +++ b/vm/platform.h @@ -30,6 +30,8 @@ #include "os-macosx-x86.32.h" #elif defined(FACTOR_PPC) #include "os-macosx-ppc.h" + #elif defined(FACTOR_AMD64) + #include "os-macosx-x86.64.h" #else #error "Unsupported Mac OS X flavor" #endif @@ -70,6 +72,7 @@ #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" 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));