-USING: alien alien.c-types alien.syntax compiler kernel namespaces
-sequences stack-checker stack-checker.errors words arrays parser
-quotations continuations effects namespaces.private io
-io.streams.string memory system threads tools.test math accessors
-combinators specialized-arrays.float alien.libraries io.pathnames
-io.backend ;
+USING: accessors alien alien.c-types alien.libraries
+alien.syntax arrays classes.c-types classes.struct combinators
+compiler continuations effects io io.backend io.pathnames
+io.streams.string kernel math memory namespaces
+namespaces.private parser quotations sequences
+specialized-arrays.float stack-checker stack-checker.errors
+system threads tools.test words ;
 IN: compiler.tests.alien
+FROM: classes.c-types => short ;
 
 <<
 : libfactor-ffi-tests-path ( -- string )


[ 1.0 2.0 ] [
    1.0 2.0 callback-10 callback-10-test
    [ test_struct_14-x1 ] [ test_struct_14-x2 ] bi
] unit-test

FUNCTION: test-struct-12 ffi_test_41 ( int a, double x ) ;

[ 1 2.0 ] [
    1 2.0 ffi_test_41
    [ test-struct-12-a ] [ test-struct-12-x ] bi
] unit-test

: callback-11 ( -- callback )
    "test-struct-12" { "int" "double" } "cdecl"
    [
        "test-struct-12" <c-object>
        [ set-test-struct-12-x ] keep
        [ set-test-struct-12-a ] keep
    ] alien-callback ;

: callback-11-test ( x1 x2 callback -- result )


[ 1 2.0 ] [
    1 2.0 callback-11 callback-11-test
    [ a>> ] [ x>> ] bi
] unit-test

STRUCT: test_struct_15
    { x single-float }
    { y single-float } ;

FUNCTION: test_struct_15 ffi_test_42 ( float x, float y ) ;

[ 1.0 2.0 ] [ 1.0 2.0 ffi_test_42 [ x>> ] [ y>> ] bi ] unit-test

: callback-12 ( -- callback )
    "test_struct_15" { "float" "float" } "cdecl"
    [
        test_struct_15 <struct>
            swap >>y
            swap >>x
    ] alien-callback ;

: callback-12-test ( x1 x2 callback -- result )
    "test_struct_15" { "float" "float" } "cdecl" alien-indirect ;

[ 1.0 2.0 ] [
    1.0 2.0 callback-12 callback-12-test [ x>> ] [ y>> ] bi
] unit-test

STRUCT: test_struct_16
    { x single-float }
    { a int } ;

FUNCTION: test_struct_16 ffi_test_43 ( float x, int a ) ;

[ 1.0 2 ] [ 1.0 2 ffi_test_43 [ x>> ] [ a>> ] bi ] unit-test

: callback-13 ( -- callback )
    "test_struct_16" { "float" "int" } "cdecl"
    [
        test_struct_16 <struct>
            swap >>a
            swap >>x
    ] alien-callback ;

: callback-13-test ( x1 x2 callback -- result )
