1 ! Copyright (C) 2009 Slava Pestov.
2 ! See http://factorcode.org/license.txt for BSD license.
3 USING: alien.structs alien.structs.fields alien.c-types
4 math math.functions sequences arrays kernel functors
5 vocabs.parser namespaces accessors quotations ;
6 IN: alien.complex.functor
8 TUPLE: complex-c-type < struct-type
12 direct-array-constructor
13 sequence-mixin-class ;
14 INSTANCE: complex-c-type array-c-type
16 FUNCTOR: define-complex-type ( N T -- )
18 T-real DEFINES ${T}-real
19 T-imaginary DEFINES ${T}-imaginary
20 set-T-real DEFINES set-${T}-real
21 set-T-imaginary DEFINES set-${T}-imaginary
29 >rect T <c-object> [ set-T-imaginary ] [ set-T-real ] [ ] tri ; inline
32 [ T-real ] [ T-imaginary ] bi rect> ; inline
34 T N c-type-align [ 2 * ] [ ] bi
35 T current-vocab N "real" <field-spec>
36 T current-vocab N "imaginary" <field-spec> N c-type-align >>offset
37 2array complex-c-type (define-struct)
40 <T> 1quotation >>unboxer-quot
41 *T 1quotation >>boxer-quot