]> gitweb.factorcode.org Git - factor.git/blob - basis/alien/complex/functor/functor.factor
Fix conflict
[factor.git] / basis / alien / complex / functor / functor.factor
1 ! Copyright (C) 2009 Slava Pestov.
2 ! See http://factorcode.org/license.txt for BSD license.
3 USING: alien.structs alien.c-types math math.functions sequences
4 arrays kernel functors vocabs.parser namespaces accessors
5 quotations ;
6 IN: alien.complex.functor
7
8 FUNCTOR: define-complex-type ( N T -- )
9
10 T-real DEFINES ${T}-real
11 T-imaginary DEFINES ${T}-imaginary
12 set-T-real DEFINES set-${T}-real
13 set-T-imaginary DEFINES set-${T}-imaginary
14
15 <T> DEFINES <${T}>
16 *T DEFINES *${T}
17
18 WHERE
19
20 : <T> ( z -- alien )
21     >rect T <c-object> [ set-T-imaginary ] [ set-T-real ] [ ] tri ; inline
22
23 : *T ( alien -- z )
24     [ T-real ] [ T-imaginary ] bi rect> ; inline
25
26 T current-vocab
27 { { N "real" } { N "imaginary" } }
28 define-struct
29
30 T c-type
31 <T> 1quotation >>unboxer-quot
32 *T 1quotation >>boxer-quot
33 drop
34
35 ;FUNCTOR