make add-library normalize-path, use libfactor-ffi-tests for testing ffi

db4
Doug Coleman 2009-03-25 13:05:34 -05:00
parent f41ee97add
commit 4b275c2861
2 changed files with 22 additions and 6 deletions
basis/compiler/tests
core/alien

View File

@ -6,6 +6,21 @@ continuations effects namespaces.private io io.streams.string
memory system threads tools.test math accessors combinators
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 ;
[ ] [ ffi_test_0 ] unit-test
@ -107,9 +122,9 @@ unit-test
"int" { "int" "int" "int" "int" } "stdcall" alien-indirect
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
: 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 )
"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" }
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 )
"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" }
alien-invoke ;

View File

@ -1,7 +1,7 @@
! Copyright (C) 2004, 2009 Slava Pestov.
! See http://factorcode.org/license.txt for BSD license.
USING: accessors assocs kernel math namespaces sequences system
kernel.private byte-arrays arrays init ;
kernel.private byte-arrays arrays init io.backend ;
IN: alien
! Some predicate classes used by the compiler for optimization
@ -64,6 +64,7 @@ TUPLE: library path abi dll ;
library dup [ dll>> ] when ;
: add-library ( name path abi -- )
[ dup [ normalize-path ] when ] dip
<library> swap libraries get set-at ;
ERROR: alien-callback-error ;
@ -99,4 +100,4 @@ PRIVATE>
: initialize-alien ( symbol quot -- )
swap dup get-global dup recompute-value?
[ drop [ call dup 31337 <alien> expiry-check boa ] dip set-global ]
[ 2nip object>> ] if ; inline
[ 2nip object>> ] if ; inline