factor/core/byte-arrays/byte-arrays.factor

29 lines
938 B
Factor
Raw Normal View History

! Copyright (C) 2007, 2009 Slava Pestov.
2007-09-20 18:09:08 -04:00
! See http://factorcode.org/license.txt for BSD license.
USING: accessors kernel kernel.private alien.accessors sequences
sequences.private math ;
2007-09-20 18:09:08 -04:00
IN: byte-arrays
M: byte-array clone (clone) ; inline
M: byte-array length length>> ; inline
M: byte-array nth-unsafe swap >fixnum alien-unsigned-1 ; inline
M: byte-array set-nth-unsafe swap >fixnum set-alien-unsigned-1 ; inline
2007-09-20 18:09:08 -04:00
: >byte-array ( seq -- byte-array ) B{ } clone-like ; inline
M: byte-array new-sequence drop (byte-array) ; inline
2007-09-20 18:09:08 -04:00
M: byte-array equal?
over byte-array? [ sequence= ] [ 2drop f ] if ;
2008-01-28 19:15:21 -05:00
M: byte-array resize
resize-byte-array ; inline
2008-01-28 19:15:21 -05:00
2007-09-20 18:09:08 -04:00
INSTANCE: byte-array sequence
2008-09-01 19:26:10 -04:00
: 1byte-array ( x -- byte-array ) B{ } 1sequence ; inline
2008-09-01 19:26:10 -04:00
2008-09-05 17:04:23 -04:00
: 2byte-array ( x y -- byte-array ) B{ } 2sequence ; inline
2008-09-01 19:26:10 -04:00
2008-09-05 17:04:23 -04:00
: 3byte-array ( x y z -- byte-array ) B{ } 3sequence ; inline
2008-09-01 19:26:10 -04:00
2008-09-05 17:04:23 -04:00
: 4byte-array ( w x y z -- byte-array ) B{ } 4sequence ; inline