add an X-sequence mixin class for each specialized array type to span X-array, X-vector, and direct-X-array
parent
e2b444c8bd
commit
8baae18cdc
|
@ -8,6 +8,7 @@ IN: specialized-arrays.direct.functor
|
|||
FUNCTOR: define-direct-array ( T -- )
|
||||
|
||||
A' IS ${T}-array
|
||||
S IS ${T}-sequence
|
||||
>A' IS >${T}-array
|
||||
<A'> IS <${A'}>
|
||||
A'{ IS ${A'}{
|
||||
|
@ -24,6 +25,8 @@ TUPLE: A
|
|||
{ underlying c-ptr read-only }
|
||||
{ length fixnum read-only } ;
|
||||
|
||||
INSTANCE: A S
|
||||
|
||||
: <A> ( alien len -- direct-array ) A boa ; inline
|
||||
M: A length length>> ;
|
||||
M: A nth-unsafe underlying>> NTH call ;
|
||||
|
|
|
@ -16,6 +16,7 @@ M: bad-byte-array-length summary
|
|||
FUNCTOR: define-array ( T -- )
|
||||
|
||||
A DEFINES-CLASS ${T}-array
|
||||
S DEFINES-CLASS ${T}-sequence
|
||||
<A> DEFINES <${A}>
|
||||
(A) DEFINES (${A})
|
||||
>A DEFINES >${A}
|
||||
|
@ -27,10 +28,14 @@ SET-NTH [ T dup c-setter array-accessor ]
|
|||
|
||||
WHERE
|
||||
|
||||
MIXIN: S
|
||||
|
||||
TUPLE: A
|
||||
{ length array-capacity read-only }
|
||||
{ underlying byte-array read-only } ;
|
||||
|
||||
INSTANCE: A S
|
||||
|
||||
: <A> ( n -- specialized-array ) dup T <c-array> A boa ; inline
|
||||
|
||||
: (A) ( n -- specialized-array ) dup T (c-array) A boa ; inline
|
||||
|
|
|
@ -10,6 +10,7 @@ FUNCTOR: define-vector ( T -- )
|
|||
V DEFINES-CLASS ${T}-vector
|
||||
|
||||
A IS ${T}-array
|
||||
S IS ${T}-sequence
|
||||
<A> IS <${A}>
|
||||
|
||||
>V DEFERS >${V}
|
||||
|
@ -19,6 +20,8 @@ WHERE
|
|||
|
||||
V A <A> vectors.functor:define-vector
|
||||
|
||||
INSTANCE: V S
|
||||
|
||||
M: V contract 2drop ;
|
||||
|
||||
M: V byte-length underlying>> byte-length ;
|
||||
|
|
Loading…
Reference in New Issue