2009-02-04 06:13:12 -05:00
|
|
|
! Copyright (C) 2007, 2009 Slava Pestov.
|
2007-09-20 18:09:08 -04:00
|
|
|
! See http://factorcode.org/license.txt for BSD license.
|
2009-07-28 12:20:28 -04:00
|
|
|
USING: accessors kernel kernel.private alien.accessors sequences
|
|
|
|
sequences.private math ;
|
2007-09-20 18:09:08 -04:00
|
|
|
IN: byte-arrays
|
|
|
|
|
2009-08-17 23:32:21 -04:00
|
|
|
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
|
2009-08-17 23:32:21 -04:00
|
|
|
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
|
2009-08-17 23:32:21 -04:00
|
|
|
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
|
|
|
|
2009-02-04 06:13:12 -05: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
|