]> gitweb.factorcode.org Git - factor.git/blob - basis/alien/complex/functor/functor.factor
Missed yet more renames
[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: accessors alien alien.c-types classes.struct math
4 math.functions sequences arrays kernel functors vocabs.parser
5 namespaces quotations ;
6 IN: alien.complex.functor
7
8 FUNCTOR: define-complex-type ( N T -- )
9
10 N-type IS ${N}
11
12 T-class DEFINES-CLASS ${T}
13
14 <T> DEFINES <${T}>
15 *T DEFINES *${T}
16
17 WHERE
18
19 STRUCT: T-class { real N-type } { imaginary N-type } ;
20
21 : <T> ( z -- alien )
22     >rect T-class <struct-boa> >c-ptr ;
23
24 : *T ( alien -- z )
25     T-class memory>struct [ real>> ] [ imaginary>> ] bi rect> ; inline
26
27 T-class lookup-c-type
28 <T> 1quotation >>unboxer-quot
29 *T 1quotation >>boxer-quot
30 complex >>boxed-class
31 drop
32
33 ;FUNCTOR