alien.libraries: add-library won't close and re-open the library if nothing changed. This fixes a crash on Windows when reloading the windows vocab
parent
ee1520f683
commit
b03a16ef4d
|
@ -1,4 +1,4 @@
|
||||||
USING: alien.libraries alien.syntax tools.test kernel ;
|
USING: alien alien.libraries alien.syntax tools.test kernel ;
|
||||||
IN: alien.libraries.tests
|
IN: alien.libraries.tests
|
||||||
|
|
||||||
[ f ] [ DLL" fadfasdfsada" dll-valid? ] unit-test
|
[ f ] [ DLL" fadfasdfsada" dll-valid? ] unit-test
|
||||||
|
@ -8,3 +8,21 @@ IN: alien.libraries.tests
|
||||||
[ ] [ "doesnotexist" dlopen dlclose ] unit-test
|
[ ] [ "doesnotexist" dlopen dlclose ] unit-test
|
||||||
|
|
||||||
[ "fdasfsf" dll-valid? drop ] must-fail
|
[ "fdasfsf" dll-valid? drop ] must-fail
|
||||||
|
|
||||||
|
[ t ] [
|
||||||
|
"test-library" "blah" cdecl add-library
|
||||||
|
"test-library" "BLAH" cdecl add-library?
|
||||||
|
"blah" remove-library
|
||||||
|
] unit-test
|
||||||
|
|
||||||
|
[ t ] [
|
||||||
|
"test-library" "blah" cdecl add-library
|
||||||
|
"test-library" "blah" stdcall add-library?
|
||||||
|
"blah" remove-library
|
||||||
|
] unit-test
|
||||||
|
|
||||||
|
[ f ] [
|
||||||
|
"test-library" "blah" cdecl add-library
|
||||||
|
"test-library" "blah" cdecl add-library?
|
||||||
|
"blah" remove-library
|
||||||
|
] unit-test
|
||||||
|
|
|
@ -2,7 +2,7 @@
|
||||||
! See http://factorcode.org/license.txt for BSD license.
|
! See http://factorcode.org/license.txt for BSD license.
|
||||||
USING: accessors alien alien.strings assocs io.backend
|
USING: accessors alien alien.strings assocs io.backend
|
||||||
kernel namespaces destructors sequences strings
|
kernel namespaces destructors sequences strings
|
||||||
system io.pathnames ;
|
system io.pathnames fry ;
|
||||||
IN: alien.libraries
|
IN: alien.libraries
|
||||||
|
|
||||||
: dlopen ( path -- dll ) native-string>alien (dlopen) ;
|
: dlopen ( path -- dll ) native-string>alien (dlopen) ;
|
||||||
|
@ -32,9 +32,15 @@ M: library dispose dll>> [ dispose ] when* ;
|
||||||
: remove-library ( name -- )
|
: remove-library ( name -- )
|
||||||
libraries get delete-at* [ dispose ] [ drop ] if ;
|
libraries get delete-at* [ dispose ] [ drop ] if ;
|
||||||
|
|
||||||
|
: add-library? ( name path abi -- ? )
|
||||||
|
[ library ] 2dip
|
||||||
|
'[ [ path>> _ = ] [ abi>> _ = ] bi and not ] [ t ] if* ;
|
||||||
|
|
||||||
: add-library ( name path abi -- )
|
: add-library ( name path abi -- )
|
||||||
[ 2drop remove-library ]
|
3dup add-library? [
|
||||||
[ <library> swap libraries get set-at ] 3bi ;
|
[ 2drop remove-library ]
|
||||||
|
[ <library> swap libraries get set-at ] 3bi
|
||||||
|
] [ 3drop ] if ;
|
||||||
|
|
||||||
: library-abi ( library -- abi )
|
: library-abi ( library -- abi )
|
||||||
library [ abi>> ] [ cdecl ] if* ;
|
library [ abi>> ] [ cdecl ] if* ;
|
||||||
|
|
Loading…
Reference in New Issue