factor/basis/alien/complex/functor/functor.factor

32 lines
683 B
Factor
Raw Normal View History

! Copyright (C) 2009 Slava Pestov.
! See http://factorcode.org/license.txt for BSD license.
USING: accessors alien alien.c-types classes.struct math
math.functions sequences arrays kernel functors vocabs.parser
namespaces quotations ;
IN: alien.complex.functor
FUNCTOR: define-complex-type ( N T -- )
T-class DEFINES-CLASS ${T}
2009-02-06 20:05:56 -05:00
<T> DEFINES <${T}>
*T DEFINES *${T}
WHERE
STRUCT: T-class { real N } { imaginary N } ;
2009-02-06 20:05:56 -05:00
: <T> ( z -- alien )
2009-08-30 00:18:31 -04:00
>rect T-class <struct-boa> >c-ptr ;
2009-02-06 20:05:56 -05:00
: *T ( alien -- z )
T-class memory>struct [ real>> ] [ imaginary>> ] bi rect> ; inline
T-class c-type
2009-02-09 16:01:41 -05:00
<T> 1quotation >>unboxer-quot
*T 1quotation >>boxer-quot
number >>boxed-class
drop
2009-02-06 20:05:56 -05:00
;FUNCTOR