]> gitweb.factorcode.org Git - factor.git/commitdiff
more I/O docs; added missing files from twb's patch
authorSlava Pestov <slava@factorcode.org>
Thu, 19 Jan 2006 08:03:32 +0000 (08:03 +0000)
committerSlava Pestov <slava@factorcode.org>
Thu, 19 Jan 2006 08:03:32 +0000 (08:03 +0000)
contrib/cairo/load.factor [new file with mode: 0644]
contrib/load.factor [new file with mode: 0644]
contrib/parser-combinators/load.factor [new file with mode: 0644]
contrib/sqlite/load.factor [new file with mode: 0644]
contrib/sqlite/test.txt [new file with mode: 0644]
doc/handbook/handbook.facts
doc/handbook/streams.facts
library/bootstrap/boot-stage1.factor
library/compiler/compiler.factor
library/io/files.facts

diff --git a/contrib/cairo/load.factor b/contrib/cairo/load.factor
new file mode 100644 (file)
index 0000000..05f8309
--- /dev/null
@@ -0,0 +1,13 @@
+IN: scratchpad
+USING: alien kernel parser compiler words sequences ;
+
+{ { "cairo" "libcairo" }
+  { "sdl-gfx" "libSDL_gfx" }
+  { "sdl" "libSDL" } }
+[ first2 add-simple-library ] each
+
+{ "cairo" "cairo_sdl" }
+[ "contrib/cairo/" swap ".factor" append3 run-file ] each
+
+{ "cairo" "cairo-sdl" }
+[ words [ try-compile ] each ] each
diff --git a/contrib/load.factor b/contrib/load.factor
new file mode 100644 (file)
index 0000000..bfb635a
--- /dev/null
@@ -0,0 +1,31 @@
+! Load all contrib libs, compile them, and save a new image.
+IN: scratchpad
+USING: alien kernel words sequences parser compiler memory ;
+
+! digraph dependencies {
+!   // run-file libs in the correct order to avoid repeated run-filing
+!   aim -> crypto
+!   concurrency -> dlists
+!   concurrency -> math
+!   cont-responder -> httpd
+!   crypto -> math
+!   factor -> x11
+!   space-invaders -> parser-combinators
+!   cont-responder -> parser-combinators
+! }
+
+: add-simple-library ( name file -- ) 
+    win32? ".dll" ".so" ? append
+    win32? "stdcall" "cdecl" ? add-library ;
+
+{ "coroutines" "dlists" "splay-trees" }
+[ dup
+  "contrib/" swap ".factor" append3 run-file
+   words [ try-compile ] each ] each
+
+{ "cairo" "math" "concurrency" "crypto" "aim" "httpd" "units" "sqlite" "win32"
+  "x11" ! "factory" has a C component, ick.
+  "postgresql" "parser-combinators" "cont-responder" "space-invaders"
+} [ "contrib/" swap "/load.factor" append3 run-file ] each
+
+compile-all
diff --git a/contrib/parser-combinators/load.factor b/contrib/parser-combinators/load.factor
new file mode 100644 (file)
index 0000000..1cc873d
--- /dev/null
@@ -0,0 +1,8 @@
+IN: scratchpad
+USING: kernel parser sequences words compiler ;
+
+{ "lazy" "parser-combinators" "lazy-examples" "tests" }
+[ "contrib/parser-combinators/" swap ".factor" append3 run-file ] each
+
+{ "lazy" "lazy-examples" "parser-combinators" }
+[ words [ try-compile ] each ] each
diff --git a/contrib/sqlite/load.factor b/contrib/sqlite/load.factor
new file mode 100644 (file)
index 0000000..ee2f961
--- /dev/null
@@ -0,0 +1,9 @@
+IN: scratchpad
+USING: kernel alien parser compiler words sequences ;
+"sqllite" "libsqlite3" add-simple-library
+
+{ "sqlite" "tuple-db" "test" "tuple-db-tests" }
+[ "contrib/sqlite/" swap ".factor" append3 run-file ] each
+
+{ "sqlite" "tuple-db" }
+[ words [ try-compile ] each ] each
diff --git a/contrib/sqlite/test.txt b/contrib/sqlite/test.txt
new file mode 100644 (file)
index 0000000..5c7ae2b
--- /dev/null
@@ -0,0 +1,3 @@
+create table test (name varchar(30), address varchar(30));
+insert into test values('John', 'America');
+insert into test values('Jane', 'New Zealand');
index e97d192ed94a01ef5d12569e5de860ac42631965..923f764f1898c7c9c0f12d24189eaa9e3cb1286b 100644 (file)
@@ -14,6 +14,7 @@ $terpri
 { $subsection "objects" }
 { $subsection "math" }
 { $subsection "collections" }
+{ $subsection "streams" }
 { $subsection "parser" } ;
 
 ARTICLE: "presentation-intro" "The presentation-based UI"
index 4dba28d226fc9428f56fae69e3498973a2503277..7ee5b70eb70104ce0f251a63963accbdeae9236e 100644 (file)
@@ -1,19 +1,27 @@
-USING: help io ;
+USING:
+help
+io
+styles ;
 
 GLOSSARY: "stream" "an endpoint for input/output operations, supporting the " { $link "stream-protocol" } ;
 
 ARTICLE: "streams" "Streams"
 "Input and output centers on the concept of a " { $emphasis "stream" } ", which is a source or sink of characters. Streams also support formatted output, which may be used to present styled text in a manner independent of output medium."
+$terpri
+"Stream words are in the " { $snippet "io" } " vocabulary."
 { $subsection "stream-protocol" }
-{ $subsection "stream-utilities" }
+{ $subsection "stream-utils" }
 { $subsection "stdio" }
+{ $subsection "styles" }
+{ $subsection "stream-binary" }
+{ $subsection "stream-impls" }
 ;
 
 GLOSSARY: "input stream" "an object responding to the input words of the " { $link "stream-protocol" } ;
 
 GLOSSARY: "output stream" "an object responding to the output words of the " { $link "stream-protocol" } ;
 
-GLOSSARY: "bidirectional stream" "an object that is both an input and output stream" ;
+GLOSSARY: "bidirectional stream" "an object that is both an input and output stream" ;
 
 ARTICLE: "stream-protocol" "Stream protocol"
 "The stream protocol consits of a large number of generic words, many of which are optional."
@@ -67,4 +75,124 @@ ARTICLE: "stdio" "The default stream"
 { $subsection with-stream }
 { $subsection with-stream* } ;
 
+ARTICLE: "styles" "Formatted output"
+"The " { $link stream-format } " and " { $link with-nested-stream } " words take a hashtable of style attributes. The former acts on character styles, and the latter acts on paragraph styles. Output stream implementations are free to ignore style information."
+$terpri
+"Style hashtables are keyed by symbols from the " { $snippet "styles" } " vocabulary."
+{ $subsection "character-styles" }
+{ $subsection "paragraph-styles" }
+{ $subsection "style-stack" }
+{ $subsection "presentations" } ;
+
+ARTICLE: "character-styles" "Character styles"
+"Character styles for " { $link stream-format } ":"
+{ $subsection foreground }
+{ $subsection background }
+{ $subsection foreground }
+{ $subsection background }
+{ $subsection font }
+{ $subsection font-size }
+{ $subsection font-style }
+{ $subsection presented }
+{ $subsection file }
+{ $subsection word-break } ;
+
+ARTICLE: "paragraph-styles" "Paragraph styles"
+"Paragraph styles for " { $link with-nested-stream } ":"
+{ $subsection page-color }
+{ $subsection border-color }
+{ $subsection border-width }
+{ $subsection wrap-margin }
+{ $subsection outline }
+{ $subsection presented } ;
+
+ARTICLE: "style-stack" "The style stack"
+"The style stack provides a convenient facility for implementing logical nesting of character and paragraph styles."
+$terpri
+"A combinator pushes a style onto the style stack and calls a quotaiton:"
+{ $subsection with-style }
+"The contents of the style stack can be combined to form one style hashtable:"
+{ $subsection current-style }
+"A pair of words corresponding to " { $link format } " and " { $link with-nesting } ", but taking the current style from the style stack:"
+{ $subsection format* }
+{ $subsection with-nesting* } ;
+
+ARTICLE: "presentations" "Presentations and outliners"
+"The " { $link presented } " and " { $link outline } " styles can be used to build sophisticated user interfaces in the Factor UI."
+$terpri
+"Associating the " { $link presented } " character style with a run of text displayed in a pane makes it a clickable presentation of an object. Two useful utility words wrap presentation output:"
+{ $subsection write-object }
+{ $subsection simple-object }
+"Associating the " { $link outline } " paragraph style with a nested block displays it as an expandable outliner gadget, whose contents are lazily generated by a quotation. Two useful utility words wrap outliner output:"
+{ $subsection write-outliner }
+{ $subsection simple-outliner } ;
+
+GLOSSARY: "big endian" "a representation of an integer as a sequence of bytes, ordered from most significant to least significant. This is the native byte ordering for PowerPC processors" ;
+
+GLOSSARY: "little endian" "a representation of an integer as a sequence of bytes, ordered from least significant to most significant. This is the native byte ordering for x86 and AMD64 processors" ;
+
+ARTICLE: "stream-binary" "Working with binary data"
+"The core stream words read and write strings. Packed binary integers can be read and written by converting to and from sequences of bytes. Floating point numbers can be read and written by converting them into a their bitwise integer representation (" { $link "floats" } ")."
+$terpri
+"There are two ways to order the bytes making up an integer; " { $emphasis "little endian" } " byte order outputs the least significant byte first, and the most significant byte last, whereas " { $emphasis "big endian" } " is the other way around."
+$terpri
+"Consider the hexadecimal integer "{ $snippet "HEX: cafebabe" } ". Big endian byte order yields the following sequence of bytes:"
+{ $code
+    "Byte:   1  2  3  4"
+    "Value: be ba fe ca"
+}
+"Compare this with little endian byte order:"
+{ $code
+    "Byte:   1  2  3  4"
+    "Value: ca fe ba be"                    
+}                                                             
+"Two words convert a sequence of bytes into an integer:"
+{ $subsection be> }
+{ $subsection le> }
+"Two words convert an integer into a sequence of bytes:"
+{ $subsection >be }
+{ $subsection >le } ;
+
+ARTICLE: "stream-impls" "Stream implementations"
+"External resource streams communicate with the outside world:"
+{ $subsection "file-streams" }
+{ $subsection "network-streams" }
+"Virtual streams serve as glue:"
+{ $subsection "string-streams" }
+"Wrapper streams convert partial implementations of the stream protocol into full-fledged streams:"
+{ $subsection <line-reader> }
+{ $subsection <plain-writer> }
+"A utility to combine a complementary input and output stream pair into a single stream:"
+{ $subsection <duplex-stream> }
+"As a final note, the " { $link f } " object implements the stream protocol, by yielding end-of-file on input and discarding all output." ;
+
+ARTICLE: "file-streams" "Reading and writing files"
+{ $subsection <file-reader> }
+{ $subsection <file-writer> }
+"File system meta-data:"
+{ $subsection exists? }
+{ $subsection directory? }
+{ $subsection file-length }
+{ $subsection stat } ;
+
+GLOSSARY: "server stream" "a stream listening on a TCP/IP socket" ;
+
+GLOSSARY: "client stream" "a bidirectional stream for an to end-point of a TCP/IP connection" ;
+
+ARTICLE: "network-streams" "TCP/IP networking"
+"Client connections are bidirectional streams opened with this word:"
+{ $subsection <client> }
+"Network servers are implemented by first opening a server socket, then waiting for connections:"
+{ $subsection <server> }
+{ $subsection accept }
+"Some information can be obtained about incoming client connections:"
+{ $subsection client-stream-host }
+{ $subsection client-stream-port } ;
 
+ARTICLE: "string-streams" "String streams"
+"Streams:"
+{ $subsection <string-reader> }
+{ $subsection <string-writer> }
+"Utility combinators:"
+{ $subsection string-in }
+{ $subsection string-out } ;
index 44d0d5f719151d500708b6124bedc1f799ed96ff..85c1da696c6e2320ad6cb1bfb9e7998c4bc57ae1 100644 (file)
@@ -57,8 +57,8 @@ vectors words ;
         "/library/vocabularies.factor"
         "/library/continuations.factor"
         "/library/errors.factor"
-        "/library/styles.factor"
-
+        
+        "/library/io/styles.factor"
         "/library/io/stream.factor"
         "/library/io/duplex-stream.factor"
         "/library/io/stdio.factor"
@@ -240,6 +240,7 @@ vectors words ;
         "/library/io/stdio.facts"
         "/library/io/stream.facts"
         "/library/io/string-streams.facts"
+        "/library/io/styles.facts"
         "/library/math/arc-trig-hyp.facts"
         "/library/math/complex.facts"
         "/library/math/constants.facts"
@@ -266,6 +267,7 @@ vectors words ;
         "/doc/handbook/objects.facts"
         "/doc/handbook/parser.facts"
         "/doc/handbook/sequences.facts"
+        "/doc/handbook/streams.facts"
         "/doc/handbook/syntax.facts"
         "/doc/handbook/tutorial.facts"
         "/doc/handbook/words.facts"
index 5b78f878d66bd4d68cbcd3cf74c88afff082c635..e3e8b9571d59e8bbbac2b3392b39c94e2bff7a10 100644 (file)
@@ -4,7 +4,7 @@ USING: compiler-backend compiler-frontend errors hashtables
 inference io kernel lists math namespaces optimizer prettyprint
 sequences words ;
 
-: (compile) ( word -- basic-blocks )
+: (compile) ( word -- )
     #! Should be called inside the with-compiler scope.
     dup word-def dataflow optimize linearize
     [ split-blocks simplify generate ] hash-each ;
index b25ecb0c710c0bdd50313dcaa25e8de8a0897b15..455a59ae871e4541467a6ae8ae0ee5ec7ce99f6e 100644 (file)
@@ -1,5 +1,17 @@
 USING: help io ;
 
+HELP: stat "( path -- list )"
+{ $values { "path" "a pathname string" } { "list" "a new list" } }
+{ $description
+    "Outputs a list of file system attributes, or " { $link f } " if the file does not exist. The elements of the list are precisely the following:"
+    { $list
+        "boolean indicating if the file is a directory"
+        "the length in bytes as an integer"
+        "a Unix permission bitmap, or 0 if not supported"
+        "the last modification time, as milliseconds since midnight, January 1st 1970 GMT"
+    }
+} ;
+
 HELP: path+ "( str1 str2 -- str )"
 { $values { "str1" "a string" } { "str2" "a string" } { "str" "a string" } }
 { $description "Concatenates two path names." } ;