]> gitweb.factorcode.org Git - factor.git/blob - core/byte-arrays/byte-arrays.factor
core: cleanup USING lists.
[factor.git] / core / byte-arrays / byte-arrays.factor
1 ! Copyright (C) 2007, 2009 Slava Pestov.
2 ! See http://factorcode.org/license.txt for BSD license.
3 USING: accessors alien.accessors kernel math sequences
4 sequences.private ;
5 IN: byte-arrays
6
7 M: byte-array clone (clone) ; inline
8 M: byte-array length length>> ; inline
9 M: byte-array nth-unsafe swap integer>fixnum alien-unsigned-1 ; inline
10 M: byte-array set-nth-unsafe swap integer>fixnum set-alien-unsigned-1 ; inline
11 : >byte-array ( seq -- byte-array ) B{ } clone-like ; inline
12 M: byte-array new-sequence drop (byte-array) ; inline
13
14 M: byte-array equal?
15     over byte-array? [ sequence= ] [ 2drop f ] if ;
16
17 M: byte-array resize
18     resize-byte-array ; inline
19
20 INSTANCE: byte-array sequence
21
22 : 1byte-array ( x -- byte-array ) B{ } 1sequence ; inline
23
24 : 2byte-array ( x y -- byte-array ) B{ } 2sequence ; inline
25
26 : 3byte-array ( x y z -- byte-array ) B{ } 3sequence ; inline
27
28 : 4byte-array ( w x y z -- byte-array ) B{ } 4sequence ; inline