specialized-arrays: direct-slice for byte-arrays

Implement nth-c-ptr and direct-like for byte-arrays so that direct-slice over a byte-array makes a uchar-array{ } over a part of the byte-array
db4
Joe Groff 2011-10-13 15:11:32 -07:00
parent aaec2eb1ac
commit ae6d6ba951
2 changed files with 6 additions and 0 deletions

View File

@ -199,6 +199,7 @@ SPECIALIZED-ARRAY: struct-resize-test
[ int-array{ 4 5 6 7 8 } ] [ int-array{ 1 2 3 4 5 6 7 8 } 3 direct-tail ] unit-test
[ int-array{ 6 7 8 } ] [ int-array{ 1 2 3 4 5 6 7 8 } 3 direct-tail* ] unit-test
[ uchar-array{ 0 1 255 } ] [ 3 6 B{ 1 1 1 0 1 255 2 2 2 } direct-slice ] unit-test
[ int-array{ 1 2 3 4 55555 6 7 8 } ] [
int-array{ 1 2 3 4 5 6 7 8 }

View File

@ -36,6 +36,9 @@ M: pointer underlying-type
GENERIC: nth-c-ptr ( n seq -- displaced-alien )
GENERIC: direct-like ( alien len exemplar -- seq )
M: byte-array nth-c-ptr <displaced-alien> ; inline
M: byte-array direct-like drop uchar <c-direct-array> ; inline
FUNCTOR: define-array ( T -- )
A DEFINES-CLASS ${T}-array
@ -179,3 +182,5 @@ SYNTAX: SPECIALIZED-ARRAY:
{ "specialized-arrays" "prettyprint" } "specialized-arrays.prettyprint" require-when
{ "specialized-arrays" "mirrors" } "specialized-arrays.mirrors" require-when
uchar define-array-vocab drop