]> gitweb.factorcode.org Git - factor.git/blobdiff - basis/alien/complex/functor/functor.factor
factor: trim using lists
[factor.git] / basis / alien / complex / functor / functor.factor
index 1d12bb0ff4da7c70aa99bf55b747ac99f36ee1ef..a28002b8debb1c4d1fa5ab7841cff220304b19a3 100644 (file)
@@ -1,35 +1,32 @@
 ! Copyright (C) 2009 Slava Pestov.
 ! See http://factorcode.org/license.txt for BSD license.
-USING: alien.structs alien.c-types math math.functions sequences
-arrays kernel functors vocabs.parser namespaces accessors
-quotations ;
+USING: accessors alien alien.c-types classes.struct functors
+kernel math quotations ;
 IN: alien.complex.functor
 
-FUNCTOR: define-complex-type ( N T -- )
+<FUNCTOR: define-complex-type ( N T -- )
 
-T-real DEFINES ${T}-real
-T-imaginary DEFINES ${T}-imaginary
-set-T-real DEFINES set-${T}-real
-set-T-imaginary DEFINES set-${T}-imaginary
+N-type IS ${N}
 
->T DEFINES >${T}
-T> DEFINES ${T}>
+T-class DEFINES-CLASS ${T}
+
+<T> DEFINES <${T}>
+*T DEFINES *${T}
 
 WHERE
 
-: >T ( z -- alien )
-    >rect T <c-object> [ set-T-imaginary ] [ set-T-real ] [ ] tri ; inline
+STRUCT: T-class { real N-type } { imaginary N-type } ;
 
-: T> ( alien -- z )
-    [ T-real ] [ T-imaginary ] bi rect> ; inline
+: <T> ( z -- alien )
+    >rect T-class boa >c-ptr ;
 
-T in get
-{ { N "real" } { N "imaginary" } }
-define-struct
+: *T ( alien -- z )
+    T-class memory>struct [ real>> ] [ imaginary>> ] bi rect> ; inline
 
-T c-type
-T> 1quotation >>boxer-quot
->T 1quotation >>unboxer-quot
+T-class lookup-c-type
+<T> 1quotation >>unboxer-quot
+*T 1quotation >>boxer-quot
+complex >>boxed-class
 drop
 
-;FUNCTOR
\ No newline at end of file
+;FUNCTOR>