document remainder of byte-arrays

db4
Doug Coleman 2008-09-05 16:04:23 -05:00
parent 853da3a116
commit 0a7edc8aef
2 changed files with 43 additions and 6 deletions

View File

@ -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." } ;

View File

@ -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