]> gitweb.factorcode.org Git - factor.git/commitdiff
document remainder of byte-arrays
authorDoug Coleman <doug.coleman@gmail.com>
Fri, 5 Sep 2008 21:04:23 +0000 (16:04 -0500)
committerDoug Coleman <doug.coleman@gmail.com>
Fri, 5 Sep 2008 21:04:23 +0000 (16:04 -0500)
core/byte-arrays/byte-arrays-docs.factor
core/byte-arrays/byte-arrays.factor

index 8a51f4c66323c1dd3e15dc6467f261e18371c7c2..25bff0fce5a743f4bf24b6775a9690ef52eb0b6d 100755 (executable)
@@ -1,4 +1,4 @@
-USING: help.markup help.syntax ;
+USING: kernel help.markup help.syntax ;
 IN: byte-arrays
 
 ARTICLE: "byte-arrays" "Byte arrays"
@@ -13,7 +13,13 @@ $nl
 { $subsection byte-array? }
 "There are several ways to construct byte arrays."
 { $subsection >byte-array }
-{ $subsection <byte-array> } ;
+{ $subsection <byte-array> }
+{ $subsection 1byte-array }
+{ $subsection 2byte-array }
+{ $subsection 3byte-array }
+{ $subsection 4byte-array }
+"Resizing byte-arrays:"
+{ $subsection resize-byte-array } ;
 
 ABOUT: "byte-arrays"
 
@@ -29,3 +35,34 @@ HELP: >byte-array
 { $description
   "Outputs a freshly-allocated byte array whose elements have the same signed byte values as a given sequence." }
 { $errors "Throws an error if the sequence contains elements other than integers." } ;
+
+HELP: 1byte-array
+{ $values
+     { "x" object }
+     { "byte-array" byte-array } }
+{ $description "Creates a new byte-array with one element." } ;
+
+HELP: 2byte-array
+{ $values
+     { "x" object } { "y" object }
+     { "byte-array" byte-array } }
+{ $description "Creates a new byte-array with two elements." } ;
+
+HELP: 3byte-array
+{ $values
+     { "x" object } { "y" object } { "z" object }
+     { "byte-array" byte-array } }
+{ $description "Creates a new byte-array with three element." } ;
+
+HELP: 4byte-array
+{ $values
+     { "w" object } { "x" object } { "y" object } { "z" object }
+     { "byte-array" byte-array } }
+{ $description "Creates a new byte-array with four elements." } ;
+
+{ 1byte-array 2byte-array 3byte-array 4byte-array } related-words
+
+HELP: resize-byte-array ( n byte-array -- newbyte-array )
+{ $values { "n" "a non-negative integer" } { "byte-array" byte-array }
+        { "newbyte-array" byte-array } }
+{ $description "Creates a new byte-array of n elements.  The contents of the existing byte-array are copied into the new byte-array; if the new byte-array is shorter, only an initial segment is copied, and if the new byte-array is longer the remaining space is filled in with 0." } ;
index 0bcea2651a8628d3cf84fc20e18b9e1ae011a5f6..50ea4b32ba3cf9f106c45eb5b88adbaa7fe3b2c1 100755 (executable)
@@ -20,10 +20,10 @@ M: byte-array resize
 
 INSTANCE: byte-array sequence
 
-: 1byte-array ( x -- array ) 1 <byte-array> [ set-first ] keep ; inline
+: 1byte-array ( x -- byte-array ) 1 <byte-array> [ set-first ] keep ; inline
 
-: 2byte-array ( x y -- array ) B{ } 2sequence ; inline
+: 2byte-array ( x y -- byte-array ) B{ } 2sequence ; inline
 
-: 3byte-array ( x y z -- array ) B{ } 3sequence ; inline
+: 3byte-array ( x y z -- byte-array ) B{ } 3sequence ; inline
 
-: 4byte-array ( w x y z -- array ) B{ } 4sequence ; inline
+: 4byte-array ( w x y z -- byte-array ) B{ } 4sequence ; inline