]> gitweb.factorcode.org Git - factor.git/blob - core/byte-arrays/byte-arrays-docs.factor
core: update some help $value types.
[factor.git] / core / byte-arrays / byte-arrays-docs.factor
1 USING: kernel help.markup help.syntax sequences ;
2 IN: byte-arrays
3
4 ARTICLE: "byte-arrays" "Byte arrays"
5 "Byte arrays are fixed-size mutable sequences (" { $link "sequence-protocol" } ") whose elements are integers in the range 0-255, inclusive. Each element only uses one byte of storage, hence the name. The literal syntax is covered in " { $link "syntax-byte-arrays" } "."
6 $nl
7 "Byte array words are in the " { $vocab-link "byte-arrays" } " vocabulary."
8 $nl
9 "Byte arrays play a special role in the C library interface; they can be used to pass binary data back and forth between Factor and C. See " { $link "c-pointers" } "."
10 $nl
11 "Byte arrays form a class of objects."
12 { $subsections
13     byte-array
14     byte-array?
15 }
16 "There are several ways to construct byte arrays."
17 { $subsections
18     >byte-array
19     <byte-array>
20     1byte-array
21     2byte-array
22     3byte-array
23     4byte-array
24 }
25 "Resizing byte arrays:"
26 { $subsections resize-byte-array } ;
27
28 ABOUT: "byte-arrays"
29
30 HELP: byte-array
31 { $description "The class of byte arrays. See " { $link "syntax-byte-arrays" } " for syntax and " { $link "byte-arrays" } " for general information." } ;
32
33 HELP: <byte-array>
34 { $values { "n" "a non-negative integer" } { "byte-array" "a new byte array" } }
35 { $description "Creates a new byte array holding " { $snippet "n" } " bytes." } ;
36
37 HELP: (byte-array)
38 { $values { "n" "a non-negative integer" } { "byte-array" "a new byte array" } }
39 { $description "Creates a new byte array with unspecified contents of length " { $snippet "n" } " bytes." } ;
40
41 HELP: >byte-array
42 { $values { "seq" sequence } { "byte-array" byte-array } }
43 { $description "Outputs a freshly-allocated byte array whose elements have the same signed byte values as a given sequence." }
44 { $errors "Throws an error if the sequence contains elements other than integers." } ;
45
46 HELP: 1byte-array
47 { $values
48      { "x" object }
49      { "byte-array" byte-array } }
50 { $description "Creates a new byte-array with one element." } ;
51
52 HELP: 2byte-array
53 { $values
54      { "x" object } { "y" object }
55      { "byte-array" byte-array } }
56 { $description "Creates a new byte-array with two elements." } ;
57
58 HELP: 3byte-array
59 { $values
60      { "x" object } { "y" object } { "z" object }
61      { "byte-array" byte-array } }
62 { $description "Creates a new byte-array with three element." } ;
63
64 HELP: 4byte-array
65 { $values
66      { "w" object } { "x" object } { "y" object } { "z" object }
67      { "byte-array" byte-array } }
68 { $description "Creates a new byte-array with four elements." } ;
69
70 { 1byte-array 2byte-array 3byte-array 4byte-array } related-words
71
72 HELP: resize-byte-array
73 { $values { "n" "a non-negative integer" } { "byte-array" byte-array } { "new-byte-array" byte-array } }
74 { $description "Resizes the byte array to have a length of " { $snippet "n" } " elements. When making the byte array shorter, this word may either create a new byte array or modify the existing byte array in place. When making the byte array longer, this word always allocates a new byte array, filling remaining space with zeroes." }
75 { $side-effects "byte-array" } ;