alien.libraries: add remove-library word, fix dlclose and dll-valid? VM primitives
parent
15c7499ef5
commit
baff251d1e
|
@ -0,0 +1,10 @@
|
|||
IN: alien.libraries.tests
|
||||
USING: alien.libraries alien.syntax tools.test kernel ;
|
||||
|
||||
[ f ] [ DLL" fadfasdfsada" dll-valid? ] unit-test
|
||||
|
||||
[ f ] [ "does not exist" DLL" fadsfasfdsaf" dlsym ] unit-test
|
||||
|
||||
[ ] [ "doesnotexist" dlopen dlclose ] unit-test
|
||||
|
||||
[ "fdasfsf" dll-valid? drop ] must-fail
|
|
@ -71,10 +71,6 @@ cell 8 = [
|
|||
|
||||
[ "( displaced alien )" ] [ 0 B{ 1 2 3 } <displaced-alien> unparse ] unit-test
|
||||
|
||||
[ f ] [ DLL" fadfasdfsada" dll-valid? ] unit-test
|
||||
|
||||
[ f ] [ "does not exist" DLL" fadsfasfdsaf" dlsym ] unit-test
|
||||
|
||||
SYMBOL: initialize-test
|
||||
|
||||
f initialize-test set-global
|
||||
|
|
11
vm/alien.cpp
11
vm/alien.cpp
|
@ -134,20 +134,21 @@ PRIMITIVE(dlsym)
|
|||
box_alien(ffi_dlsym(NULL,sym));
|
||||
else
|
||||
{
|
||||
tagged<dll> d = library.as<dll>();
|
||||
d.untag_check();
|
||||
dll *d = untag_check<dll>(library.value());
|
||||
|
||||
if(d->dll == NULL)
|
||||
dpush(F);
|
||||
else
|
||||
box_alien(ffi_dlsym(d.untagged(),sym));
|
||||
box_alien(ffi_dlsym(d,sym));
|
||||
}
|
||||
}
|
||||
|
||||
/* close a native library handle */
|
||||
PRIMITIVE(dlclose)
|
||||
{
|
||||
ffi_dlclose(untag_check<dll>(dpop()));
|
||||
dll *d = untag_check<dll>(dpop());
|
||||
if(d->dll != NULL)
|
||||
ffi_dlclose(d);
|
||||
}
|
||||
|
||||
PRIMITIVE(dll_validp)
|
||||
|
@ -156,7 +157,7 @@ PRIMITIVE(dll_validp)
|
|||
if(library == F)
|
||||
dpush(T);
|
||||
else
|
||||
dpush(tagged<dll>(library)->dll == NULL ? F : T);
|
||||
dpush(untag_check<dll>(library)->dll == NULL ? F : T);
|
||||
}
|
||||
|
||||
/* gets the address of an object representing a C pointer */
|
||||
|
|
Loading…
Reference in New Issue