make add-library normalize-path, use libfactor-ffi-tests for testing ffi
parent
f41ee97add
commit
4b275c2861
|
@ -6,6 +6,21 @@ continuations effects namespaces.private io io.streams.string
|
||||||
memory system threads tools.test math accessors combinators
|
memory system threads tools.test math accessors combinators
|
||||||
specialized-arrays.float ;
|
specialized-arrays.float ;
|
||||||
|
|
||||||
|
<<
|
||||||
|
: libfactor-ffi-tests-path ( -- string )
|
||||||
|
{
|
||||||
|
{ [ os winnt? ] [ "resource:libfactor-ffi-test.dll" ] }
|
||||||
|
{ [ os macosx? ] [ "resource:libfactor-ffi-test.dylib" ] }
|
||||||
|
{ [ os unix? ] [ "resource:libfactor-ffi-test.so" ] }
|
||||||
|
} cond ;
|
||||||
|
|
||||||
|
"f-cdecl" libfactor-ffi-tests-path "cdecl" add-library
|
||||||
|
|
||||||
|
"f-stdcall" libfactor-ffi-tests-path "stdcall" add-library
|
||||||
|
>>
|
||||||
|
|
||||||
|
LIBRARY: f-cdecl
|
||||||
|
|
||||||
FUNCTION: void ffi_test_0 ;
|
FUNCTION: void ffi_test_0 ;
|
||||||
[ ] [ ffi_test_0 ] unit-test
|
[ ] [ ffi_test_0 ] unit-test
|
||||||
|
|
||||||
|
@ -107,9 +122,9 @@ unit-test
|
||||||
"int" { "int" "int" "int" "int" } "stdcall" alien-indirect
|
"int" { "int" "int" "int" "int" } "stdcall" alien-indirect
|
||||||
gc ;
|
gc ;
|
||||||
|
|
||||||
<< "f-stdcall" f "stdcall" add-library >>
|
LIBRARY: f-stdcall
|
||||||
|
|
||||||
[ f ] [ "f-stdcall" load-library ] unit-test
|
[ f ] [ "f-stdcall" load-library f = ] unit-test
|
||||||
[ "stdcall" ] [ "f-stdcall" library abi>> ] unit-test
|
[ "stdcall" ] [ "f-stdcall" library abi>> ] unit-test
|
||||||
|
|
||||||
: ffi_test_18 ( w x y z -- int )
|
: ffi_test_18 ( w x y z -- int )
|
||||||
|
@ -149,7 +164,7 @@ FUNCTION: void ffi_test_20 double x1, double x2, double x3,
|
||||||
|
|
||||||
: ffi_test_31 ( a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a -- result y )
|
: ffi_test_31 ( a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a -- result y )
|
||||||
"int"
|
"int"
|
||||||
f "ffi_test_31"
|
"f-stdcall" "ffi_test_31"
|
||||||
{ "int" "int" "int" "int" "int" "int" "int" "int" "int" "int" "int" "int" "int" "int" "int" "int" "int" "int" "int" "int" "int" "int" "int" "int" "int" "int" "int" "int" "int" "int" "int" "int" "int" "int" "int" "int" "int" "int" "int" "int" "int" "int" }
|
{ "int" "int" "int" "int" "int" "int" "int" "int" "int" "int" "int" "int" "int" "int" "int" "int" "int" "int" "int" "int" "int" "int" "int" "int" "int" "int" "int" "int" "int" "int" "int" "int" "int" "int" "int" "int" "int" "int" "int" "int" "int" "int" }
|
||||||
alien-invoke gc 3 ;
|
alien-invoke gc 3 ;
|
||||||
|
|
||||||
|
@ -157,7 +172,7 @@ FUNCTION: void ffi_test_20 double x1, double x2, double x3,
|
||||||
|
|
||||||
: ffi_test_31_point_5 ( a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a -- result )
|
: ffi_test_31_point_5 ( a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a -- result )
|
||||||
"float"
|
"float"
|
||||||
f "ffi_test_31_point_5"
|
"f-stdcall" "ffi_test_31_point_5"
|
||||||
{ "float" "float" "float" "float" "float" "float" "float" "float" "float" "float" "float" "float" "float" "float" "float" "float" "float" "float" "float" "float" "float" "float" "float" "float" "float" "float" "float" "float" "float" "float" "float" "float" "float" "float" "float" "float" "float" "float" "float" "float" "float" "float" }
|
{ "float" "float" "float" "float" "float" "float" "float" "float" "float" "float" "float" "float" "float" "float" "float" "float" "float" "float" "float" "float" "float" "float" "float" "float" "float" "float" "float" "float" "float" "float" "float" "float" "float" "float" "float" "float" "float" "float" "float" "float" "float" "float" }
|
||||||
alien-invoke ;
|
alien-invoke ;
|
||||||
|
|
||||||
|
|
|
@ -1,7 +1,7 @@
|
||||||
! Copyright (C) 2004, 2009 Slava Pestov.
|
! Copyright (C) 2004, 2009 Slava Pestov.
|
||||||
! See http://factorcode.org/license.txt for BSD license.
|
! See http://factorcode.org/license.txt for BSD license.
|
||||||
USING: accessors assocs kernel math namespaces sequences system
|
USING: accessors assocs kernel math namespaces sequences system
|
||||||
kernel.private byte-arrays arrays init ;
|
kernel.private byte-arrays arrays init io.backend ;
|
||||||
IN: alien
|
IN: alien
|
||||||
|
|
||||||
! Some predicate classes used by the compiler for optimization
|
! Some predicate classes used by the compiler for optimization
|
||||||
|
@ -64,6 +64,7 @@ TUPLE: library path abi dll ;
|
||||||
library dup [ dll>> ] when ;
|
library dup [ dll>> ] when ;
|
||||||
|
|
||||||
: add-library ( name path abi -- )
|
: add-library ( name path abi -- )
|
||||||
|
[ dup [ normalize-path ] when ] dip
|
||||||
<library> swap libraries get set-at ;
|
<library> swap libraries get set-at ;
|
||||||
|
|
||||||
ERROR: alien-callback-error ;
|
ERROR: alien-callback-error ;
|
||||||
|
|
Loading…
Reference in New Issue