]> gitweb.factorcode.org Git - factor.git/blobdiff - basis/io/mmap/mmap-docs.factor
factor: trim using lists
[factor.git] / basis / io / mmap / mmap-docs.factor
index caa2f95dae6a00045f7e14ed5166606ab95df299..f6d21b1d028190c809290e4dbee5f2568db3272e 100644 (file)
@@ -1,6 +1,5 @@
-USING: alien alien.c-types continuations destructors
-help.markup help.syntax kernel math quotations
-specialized-arrays ;
+USING: alien alien.c-types destructors help.markup help.syntax
+quotations specialized-arrays ;
 IN: io.mmap
 
 HELP: mapped-file
@@ -12,19 +11,19 @@ HELP: mapped-file
 } ;
 
 HELP: <mapped-file>
-{ $values { "path" "a pathname string" }  { "mmap" mapped-file } }
+{ $values { "path" "a pathname string" } { "mmap" mapped-file } }
 { $contract "Opens a file and maps its contents into memory. The length is permitted to exceed the length of the file on disk, in which case the remaining space is padded with zero bytes." }
 { $notes "You must call " { $link dispose } " when you are finished working with the returned object, to reclaim resources. The " { $link with-mapped-file } " provides an abstraction which can close the mapped file for you." }
 { $errors "Throws an error if a memory mapping could not be established." } ;
 
 HELP: with-mapped-file
-{ $values { "path" "a pathname string" } { "quot" { $quotation "( mmap -- )" } } }
+{ $values { "path" "a pathname string" } { "quot" { $quotation ( mmap -- ) } } }
 { $contract "Opens a file for read/write access and maps its contents into memory, passing the " { $link mapped-file } " instance to the quotation. The mapped file is disposed of when the quotation returns, or if an error is thrown." }
 { $notes "This is a low-level word, because " { $link mapped-file } " objects simply expose their base address and length. Most applications should use " { $link "io.mmap.arrays" } " instead." }
 { $errors "Throws an error if a memory mapping could not be established." } ;
 
 HELP: with-mapped-file-reader
-{ $values { "path" "a pathname string" } { "quot" { $quotation "( mmap -- )" } } }
+{ $values { "path" "a pathname string" } { "quot" { $quotation ( mmap -- ) } } }
 { $contract "Opens a file for read-only access and maps its contents into memory, passing the " { $link mapped-file } " instance to the quotation. The mapped file is disposed of when the quotation returns, or if an error is thrown." }
 { $notes "This is a low-level word, because " { $link mapped-file } " objects simply expose their base address and length. See " { $link "io.mmap.arrays" } " for a discussion of how to access data in a mapped file." }
 { $errors "Throws an error if a memory mapping could not be established." } ;
@@ -35,7 +34,7 @@ HELP: close-mapped-file
 { $errors "Throws an error if a memory mapping could not be established." } ;
 
 HELP: <mapped-file-reader>
-{ $values { "path" "a pathname string" }  { "mmap" mapped-file } }
+{ $values { "path" "a pathname string" } { "mmap" mapped-file } }
 { $contract "Opens a file for reading only and maps its contents into memory. The length is permitted to exceed the length of the file on disk, in which case the remaining space is padded with zero bytes." }
 { $notes "You must call " { $link dispose } " when you are finished working with the returned object, to reclaim resources. The " { $link with-mapped-file } " provides an abstraction which can close the mapped file for you." }
 { $errors "Throws an error if a memory mapping could not be established." } ;
@@ -44,14 +43,14 @@ HELP: with-mapped-array
 { $values
     { "path" "a pathname string" } { "c-type" c-type } { "quot" quotation }
 }
-{ $description "Memory-maps a file for reading and writing as a mapped-array of the given c-type. The mapped file is disposed of when the quotation returns, or if an error is thrown." }
+{ $description "Memory-maps a file for reading and writing, wrapping it in a specialized array with the given element type. The mapped file is disposed of when the quotation returns, or if an error is thrown." }
 { $examples
     { $unchecked-example
         "USING: alien.c-types io.mmap prettyprint specialized-arrays ;"
         "SPECIALIZED-ARRAY: uint"
-""""resource:license.txt" uint [
+"resource:LICENSE.txt\" uint [
     [ . ] each
-] with-mapped-array"""
+] with-mapped-array"
         ""
     }
 }
@@ -80,18 +79,17 @@ ARTICLE: "io.mmap.examples" "Memory-mapped file examples"
     "SPECIALIZED-ARRAY: char"
     ""
     "\"mydata.dat\" char ["
-    "    4 <sliced-groups>"
-    "    [ reverse-here ] change-each"
+    "    4 <groups>"
+    "    [ reverse! drop ] each"
     "] with-mapped-array"
 }
-"Normalize a file containing packed quadrupes of floats:"
+"Normalize a file containing packed quadruples of floats:"
 { $code
     "USING: kernel io.mmap math.vectors math.vectors.simd" "sequences specialized-arrays ;"
-    "SIMD: float"
     "SPECIALIZED-ARRAY: float-4"
     ""
     "\"mydata.dat\" float-4 ["
-    "    [ normalize ] change-each"
+    "    [ normalize ] map! drop"
     "] with-mapped-array"
 } ;