1 ! Copyright (C) 2008, 2009 Slava Pestov.
2 ! See http://factorcode.org/license.txt for BSD license.
3 USING: accessors alien.c-types alien.parser assocs
4 compiler.units functors growable kernel lexer namespaces parser
5 prettyprint.custom sequences specialized-arrays
6 specialized-arrays.private strings vocabs vocabs.parser
7 vocabs.generated fry make ;
8 QUALIFIED: vectors.functor
9 IN: specialized-vectors
13 FUNCTOR: define-vector ( T -- )
15 V DEFINES-CLASS ${T}-vector
26 V A <A> vectors.functor:define-vector
30 M: V byte-length underlying>> byte-length ;
32 M: V pprint-delims drop \ V{ \ } ;
34 M: V >pprint-sequence ;
36 M: V pprint* pprint-object ;
38 SYNTAX: V{ \ } [ >V ] parse-literal ;
45 : specialized-vector-vocab ( c-type -- vocab )
47 "specialized-vectors.instances." %
48 [ vocabulary>> % "." % ]
55 : define-vector-vocab ( type -- vocab )
57 [ specialized-vector-vocab ] [ '[ _ define-vector ] ] bi
60 SYNTAX: SPECIALIZED-VECTORS:
63 [ define-array-vocab use-vocab ]
64 [ define-vector-vocab use-vocab ] bi
67 SYNTAX: SPECIALIZED-VECTOR:
69 [ define-array-vocab use-vocab ]
70 [ define-vector-vocab use-vocab ] bi ;