alien.libraries: split update-library and add-library again.

locals-and-roots
John Benediktsson 2016-03-29 06:07:14 -07:00
parent 1589c0b764
commit 98ed2a8ee5
1 changed files with 11 additions and 1 deletions

View File

@ -57,6 +57,16 @@ M: library dispose dll>> [ dispose ] when* ;
: same-library? ( library path abi -- ? )
[ swap path>> = ] [ swap abi>> = ] bi-curry* bi and ;
: add-library? ( name path abi -- ? )
[ lookup-library ] 2dip '[ _ _ same-library? not ] [ t ] if* ;
: add-library ( name path abi -- )
3dup add-library? [
[ 2drop remove-library ]
[ [ nip ] dip make-library ]
[ 2drop libraries get set-at ] 3tri
] [ 3drop ] if ;
: change-dll ( library path abi -- )
swap >>abi
swap >>path
@ -64,7 +74,7 @@ M: library dispose dll>> [ dispose ] when* ;
[ path>> open-dll ]
[ swap >>dlerror swap >>dll drop ] tri ;
: add-library ( name path abi -- )
: update-library ( name path abi -- )
pick lookup-library [
[ 2over same-library? not ] keep swap
[ change-dll drop ] [ 4drop ] if