]> gitweb.factorcode.org Git - factor.git/commitdiff
make add-library normalize-path, use libfactor-ffi-tests for testing ffi
authorDoug Coleman <erg@jobim.local>
Wed, 25 Mar 2009 18:05:34 +0000 (13:05 -0500)
committerDoug Coleman <erg@jobim.local>
Wed, 25 Mar 2009 18:05:34 +0000 (13:05 -0500)
basis/compiler/tests/alien.factor
core/alien/alien.factor

index f3c2deb2d8d9b341ae72383a1a54bf9fcd74b39f..2aed251676f12ebbf6ac65efea2b8279c720f949 100644 (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 ;
 
index 83665778f1aa416d2d02d8788b634bd9b4936555..8e48ac770c8933bdcd8fcd8035ae7d1a7748dd05 100644 (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
\ No newline at end of file
+    [ 2nip object>> ] if ; inline