] [ drop ] 2bi
<direct-A> ; inline
-M: A byte-length length \ T heap-size * ; inline
+M: A element-size drop \ T heap-size ; inline
M: A direct-array-syntax drop \ A@ ;
;FUNCTOR
-GENERIC: (underlying-type) ( c-type -- c-type' )
+GENERIC: underlying-type ( c-type -- c-type' )
-M: string (underlying-type) c-types get at ;
-M: word (underlying-type) "c-type" word-prop ;
-
-: underlying-type ( c-type -- c-type' )
- dup (underlying-type) {
+M: c-type-word underlying-type
+ dup "c-type" word-prop {
{ [ dup not ] [ drop no-c-type ] }
- { [ dup c-type-name? ] [ nip underlying-type ] }
+ { [ dup pointer? ] [ 2drop void* ] }
+ { [ dup c-type-word? ] [ nip underlying-type ] }
[ drop ]
} cond ;
+M: pointer underlying-type
+ drop void* ;
+
: specialized-array-vocab ( c-type -- vocab )
[
"specialized-arrays.instances." %
[ specialized-array-vocab ] [ '[ _ define-array ] ] bi
generate-vocab ;
-M: c-type-name require-c-array define-array-vocab drop ;
-
ERROR: specialized-array-vocab-not-loaded c-type ;
-M: c-type-name c-array-constructor
+M: c-type-word c-array-constructor
underlying-type
dup [ name>> "<" "-array>" surround ] [ specialized-array-vocab ] bi lookup
[ ] [ specialized-array-vocab-not-loaded ] ?if ; foldable
-M: c-type-name c-(array)-constructor
+M: pointer c-array-constructor drop void* c-array-constructor ;
+
+M: c-type-word c-(array)-constructor
underlying-type
dup [ name>> "(" "-array)" surround ] [ specialized-array-vocab ] bi lookup
[ ] [ specialized-array-vocab-not-loaded ] ?if ; foldable
-M: c-type-name c-direct-array-constructor
+M: pointer c-(array)-constructor drop void* c-(array)-constructor ;
+
+M: c-type-word c-direct-array-constructor
underlying-type
dup [ name>> "<direct-" "-array>" surround ] [ specialized-array-vocab ] bi lookup
[ ] [ specialized-array-vocab-not-loaded ] ?if ; foldable
+M: pointer c-direct-array-constructor drop void* c-direct-array-constructor ;
+
SYNTAX: SPECIALIZED-ARRAYS:
";" parse-tokens [ parse-c-type define-array-vocab use-vocab ] each ;