Minor cleanups and documentation fixes
parent
5e5cbd50d4
commit
56bb99fa56
|
@ -51,6 +51,7 @@
|
|||
- variable width word wrap
|
||||
- fix top level window positioning
|
||||
- changing window titles
|
||||
- remove distinction between a word and a link to a word
|
||||
|
||||
+ compiler/ffi:
|
||||
|
||||
|
|
|
@ -35,13 +35,11 @@ ARTICLE: "alien-invoke" "Calling C from Factor"
|
|||
$terpri
|
||||
"The above parsing words create word definitions which call a lower-level word; you can use it directly, too:"
|
||||
{ $subsection alien-invoke }
|
||||
$terpri
|
||||
"There are some details concerning the conversion of Factor objects to C values, and vice versa. See " { $link "c-types" } "." ;
|
||||
|
||||
ARTICLE: "alien-callback" "Calling Factor from C"
|
||||
"Callbacks can be defined and passed to C code as function pointers; the C code can then invoke the callback and run Factor code:"
|
||||
{ $subsection alien-callback }
|
||||
$terpri
|
||||
"There are some details concerning the conversion of Factor objects to C values, and vice versa. See " { $link "c-types" } "." ;
|
||||
|
||||
ARTICLE: "c-types" "C types"
|
||||
|
@ -262,6 +260,7 @@ $terpri
|
|||
{ $subsection malloc }
|
||||
{ $subsection calloc }
|
||||
{ $subsection realloc }
|
||||
{ $subsection check-ptr }
|
||||
"You must always free pointers returned by any of the above words:"
|
||||
{ $subsection free } ;
|
||||
|
||||
|
|
|
@ -56,21 +56,21 @@ HELP: alien>string "( c-ptr -- string )"
|
|||
HELP: <malloc-array> "( n type -- alien )"
|
||||
{ $values { "n" "a non-negative integer" } { "type" "a string" } { "alien" "an alien address" } }
|
||||
{ $description "Allocates an unmanaged memory block large enough to hold " { $snippet "n" } " values of a C type." }
|
||||
{ $warning "Don't forget to deallocate the memory with a call to " { $link free } "." }
|
||||
{ $warning "Don't forget to deallocate the memory with a call to " { $link free } "." }
|
||||
{ $errors "Throws an error if the type does not exist, if the requested size is negative, or if memory allocation fails." }
|
||||
{ $see-also <c-array> } ;
|
||||
|
||||
HELP: <malloc-object> "( type -- alien )"
|
||||
{ $values { "type" "a string" } { "alien" "an alien address" } }
|
||||
{ $description "Allocates an unmanaged memory block large enough to hold a value of a C type." }
|
||||
{ $warning "Don't forget to deallocate the memory with a call to " { $link free } "." }
|
||||
{ $warning "Don't forget to deallocate the memory with a call to " { $link free } "." }
|
||||
{ $errors "Throws an error if the type does not exist or if memory allocation fails." }
|
||||
{ $see-also <c-object> } ;
|
||||
|
||||
HELP: <malloc-string> "( string -- alien )"
|
||||
{ $values { "string" "a string" } { "alien" "an alien address" } }
|
||||
{ $description "Copies a string to an unmanaged memory block large enough to hold a copy of the string in 8-bit ASCII encoding, with a trailing null byte." }
|
||||
{ $warning "Don't forget to deallocate the memory with a call to " { $link free } "." }
|
||||
{ $warning "Don't forget to deallocate the memory with a call to " { $link free } "." }
|
||||
{ $errors "Throws an error if memory allocation fails." }
|
||||
{ $see-also string>alien } ;
|
||||
|
||||
|
|
|
@ -6,21 +6,21 @@ HELP: malloc "( size -- alien )"
|
|||
{ $description "Allocates a block of " { $snippet "size" } " bytes from the operating system. The contents of the block are undefined."
|
||||
$terpri
|
||||
"Outputs " { $link f } " if memory allocation failed, so calls to this word should be followed by a call to " { $link check-ptr } "." }
|
||||
{ $warning "Don't forget to deallocate the memory with a call to " { $link free } "." } ;
|
||||
{ $warning "Don't forget to deallocate the memory with a call to " { $link free } "." } ;
|
||||
|
||||
HELP: calloc "( count size -- alien )"
|
||||
{ $values { "count" "a non-negative integer" } { "size" "a non-negative integer" } { "alien" "an alien address" } }
|
||||
{ $description "Allocates a block of " { $snippet "count * size" } " bytes from the operating system. The contents of the block are initially zero."
|
||||
$terpri
|
||||
"Outputs " { $link f } " if memory allocation failed, so calls to this word should be followed by a call to " { $link check-ptr } "." }
|
||||
{ $warning "Don't forget to deallocate the memory with a call to " { $link free } "." } ;
|
||||
{ $warning "Don't forget to deallocate the memory with a call to " { $link free } "." } ;
|
||||
|
||||
HELP: realloc "( alien size -- newalien )"
|
||||
{ $values { "alien" "an alien address" } { "size" "a non-negative integer" } { "newalien" "an alien address" } }
|
||||
{ $description "Allocates a new block of " { $snippet "size" } " bytes from the operating system. The contents of " { $snippet "alien" } ", which itself must be a block previously returned by " { $link malloc } " or " { $link realloc } ", are copied into the new block, and the old block is freed."
|
||||
$terpri
|
||||
"Outputs " { $link f } " if memory allocation failed, so calls to this word should be followed by a call to " { $link check-ptr } "." }
|
||||
{ $warning "Don't forget to deallocate the memory with a call to " { $link free } "." } ;
|
||||
{ $warning "Don't forget to deallocate the memory with a call to " { $link free } "." } ;
|
||||
|
||||
HELP: memcpy "( dst src size -- newalien )"
|
||||
{ $values { "dst" "an alien address" } { "src" "an alien address" } { "size" "a non-negative integer" } }
|
||||
|
|
|
@ -7,8 +7,6 @@ strings styles words ;
|
|||
! Markup
|
||||
GENERIC: print-element
|
||||
|
||||
GENERIC: article-name
|
||||
|
||||
! Help articles
|
||||
SYMBOL: articles
|
||||
|
||||
|
@ -21,15 +19,10 @@ TUPLE: article title content ;
|
|||
|
||||
M: string article-title article article-title ;
|
||||
|
||||
M: string article-name article article-name ;
|
||||
|
||||
M: string article-content article article-content ;
|
||||
|
||||
M: article article-name article-title ;
|
||||
|
||||
! Special case: f help
|
||||
M: f article-title drop \ f article-title ;
|
||||
M: f article-name drop \ f article-name ;
|
||||
M: f article-content drop \ f article-content ;
|
||||
|
||||
! Glossary of terms
|
||||
|
@ -39,8 +32,6 @@ TUPLE: term entry ;
|
|||
|
||||
M: term article-title term-entry ;
|
||||
|
||||
M: term article-name term-entry ;
|
||||
|
||||
M: term article-content
|
||||
term-entry terms get hash
|
||||
[ "No such glossary entry" ] unless* ;
|
||||
|
|
|
@ -116,8 +116,6 @@ TUPLE: link name ;
|
|||
|
||||
M: link article-title link-name article-title ;
|
||||
|
||||
M: link article-name link-name article-name ;
|
||||
|
||||
M: link article-content link-name article-content ;
|
||||
|
||||
DEFER: help
|
||||
|
@ -136,7 +134,7 @@ DEFER: help
|
|||
pprint
|
||||
] [
|
||||
link-style [
|
||||
dup article-name swap <link> simple-object
|
||||
dup article-title swap <link> simple-object
|
||||
] with-style
|
||||
] if ;
|
||||
|
||||
|
|
|
@ -1,15 +1,9 @@
|
|||
! Copyright (C) 2005, 2006 Slava Pestov.
|
||||
! See http://factorcode.org/license.txt for BSD license.
|
||||
IN: help
|
||||
USING: arrays generic kernel namespaces prettyprint sequences
|
||||
words ;
|
||||
USING: arrays kernel namespaces prettyprint sequences words ;
|
||||
|
||||
M: word article-title
|
||||
[
|
||||
"The " % dup word-name % class? " class" " word" ? %
|
||||
] "" make ;
|
||||
|
||||
M: word article-name word-name ;
|
||||
M: word article-title word-name ;
|
||||
|
||||
: word-article ( word -- article ) "help" word-prop ;
|
||||
|
||||
|
|
|
@ -5,11 +5,12 @@ USE: compiler
|
|||
USE: compiler-frontend
|
||||
USE: inference
|
||||
USE: words
|
||||
USE: sequences
|
||||
|
||||
: fie [ ] [ ] if ;
|
||||
|
||||
[ ] [ \ fie dup word-def dataflow linearize drop ] unit-test
|
||||
|
||||
: foo [ drop ] each-word ;
|
||||
: foo all-words [ drop ] each ;
|
||||
|
||||
[ ] [ \ foo dup word-def dataflow linearize drop ] unit-test
|
||||
|
|
|
@ -22,8 +22,6 @@ SYMBOL: vocabularies
|
|||
|
||||
: all-words ( -- list ) vocabs [ words ] map concat ;
|
||||
|
||||
: each-word ( quot -- ) all-words swap each ; inline
|
||||
|
||||
: word-subset ( pred -- list )
|
||||
all-words swap subset ; inline
|
||||
|
||||
|
@ -31,7 +29,7 @@ SYMBOL: vocabularies
|
|||
all-words swap subset-with ; inline
|
||||
|
||||
: recrossref ( -- )
|
||||
crossref get clear-hash [ add-crossref ] each-word ;
|
||||
crossref get clear-hash all-words [ add-crossref ] each ;
|
||||
|
||||
: lookup ( name vocab -- word ) vocab ?hash ;
|
||||
|
||||
|
|
Loading…
Reference in New Issue