2009-02-06 05:38:31 -05:00
|
|
|
! Copyright (C) 2009 Slava Pestov.
|
|
|
|
|
! See http://factorcode.org/license.txt for BSD license.
|
2017-12-03 11:52:03 -05:00
|
|
|
USING: functors2 ;
|
2009-02-06 05:38:31 -05:00
|
|
|
IN: alien.complex.functor
|
|
|
|
|
|
2017-12-03 11:52:03 -05:00
|
|
|
FUNCTOR: define-complex-type ( N: name T: name -- ) [[
|
2009-02-06 05:38:31 -05:00
|
|
|
|
2017-12-03 11:52:03 -05:00
|
|
|
STRUCT: ${T}-class { real ${N}-type } { imaginary ${N}-type } ;
|
2010-02-21 13:28:42 -05:00
|
|
|
|
2017-12-03 11:52:03 -05:00
|
|
|
: <${T}> ( z -- alien )
|
|
|
|
|
>rect ${T}-class <struct-boa> >c-ptr ;
|
2009-02-06 05:38:31 -05:00
|
|
|
|
2017-12-03 11:52:03 -05:00
|
|
|
: *${T} ( alien -- z )
|
2009-08-29 21:20:25 -04:00
|
|
|
T-class memory>struct [ real>> ] [ imaginary>> ] bi rect> ; inline
|
2009-02-06 05:38:31 -05:00
|
|
|
|
2017-12-03 11:52:03 -05:00
|
|
|
${T}-class lookup-c-type
|
|
|
|
|
<${T}> 1quotation >>unboxer-quot
|
|
|
|
|
*${T} 1quotation >>boxer-quot
|
2009-09-24 07:58:33 -04:00
|
|
|
complex >>boxed-class
|
2009-02-06 05:38:31 -05:00
|
|
|
drop
|
|
|
|
|
|
2017-12-03 11:52:03 -05:00
|
|
|
]]
|