alien.libraries: word>dlsym was a stupid idea that didn't work
The def>> attribute is stripped when deploying. So return dlsym? and use that.char-rename
parent
bfd40f0215
commit
a9ac763912
|
@ -44,6 +44,14 @@ HELP: dlsym
|
|||
{ $values { "name" "a C symbol name" } { "dll" "a DLL handle" } { "alien" { $maybe alien } } }
|
||||
{ $description "Looks up a symbol in a native library. If " { $snippet "dll" } " is " { $link f } " looks for the symbol in the runtime executable. If the symbol was not found, outputs " { $link f } "." } ;
|
||||
|
||||
HELP: dlsym?
|
||||
{ $values
|
||||
{ "function" string }
|
||||
{ "library" string }
|
||||
{ "alien/f" { $maybe alien } }
|
||||
}
|
||||
{ $description "Outputs the alien dynamically loaded with the given name in the given library. If no symbol is loaded, output f." } ;
|
||||
|
||||
HELP: make-library
|
||||
{ $values
|
||||
{ "path" "a pathname string" } { "abi" "the ABI used by the library, either " { $link cdecl } " or " { $link stdcall } }
|
||||
|
@ -72,10 +80,6 @@ HELP: remove-library
|
|||
{ $values { "name" string } }
|
||||
{ $description "Unloads a library and removes it from the internal list of libraries. The " { $snippet "name" } " parameter should be a name that was previously passed to " { $link add-library } ". If no library with that name exists, this word does nothing." } ;
|
||||
|
||||
HELP: word>dlsym
|
||||
{ $values { "word" word } { "alien/f" maybe{ alien } } }
|
||||
{ $description "Takes a word which calls a C library function and outputs the address of the symbol it points to as an alien. If the symbol isn't loaded, outputs f." } ;
|
||||
|
||||
ARTICLE: "loading-libs" "Loading native libraries"
|
||||
"Before calling a C library, you must associate its path name on disk with a logical name which Factor uses to identify the library:"
|
||||
{ $subsections
|
||||
|
|
|
@ -1,5 +1,4 @@
|
|||
USING: accessors alien alien.libraries alien.syntax kernel libc
|
||||
tools.test ;
|
||||
USING: accessors alien alien.libraries alien.syntax kernel tools.test ;
|
||||
IN: alien.libraries.tests
|
||||
|
||||
{ f } [ DLL" fadfasdfsada" dll-valid? ] unit-test
|
||||
|
@ -32,7 +31,7 @@ IN: alien.libraries.tests
|
|||
"blah" cdecl make-library [ path>> ] [ dll>> dll-valid? ] bi
|
||||
] unit-test
|
||||
|
||||
! word>dlsym
|
||||
! dlsym?
|
||||
{ t } [
|
||||
\ errno word>dlsym alien?
|
||||
"errno" "libc" dlsym? alien?
|
||||
] unit-test
|
||||
|
|
|
@ -29,10 +29,6 @@ C: <library> library
|
|||
|
||||
: lookup-library ( name -- library/f ) libraries get at ;
|
||||
|
||||
: word>dlsym ( word -- alien/f )
|
||||
def>> [ third ] [ second dup [ lookup-library dll>> ] when ] bi
|
||||
dlsym ;
|
||||
|
||||
: open-dll ( path -- dll dll-error/f )
|
||||
[ dlopen dup dll-valid? [ f ] [ dlerror ] if ]
|
||||
[ f f ] if* ;
|
||||
|
@ -46,6 +42,9 @@ C: <library> library
|
|||
: load-library ( name -- dll )
|
||||
lookup-library library-dll ;
|
||||
|
||||
: dlsym? ( function library -- alien/f )
|
||||
load-library dlsym ;
|
||||
|
||||
M: dll dispose dlclose ;
|
||||
|
||||
M: library dispose dll>> [ dispose ] when* ;
|
||||
|
|
|
@ -10,7 +10,7 @@ SPECIALIZED-ARRAY: uchar
|
|||
SINGLETON: gtk-image
|
||||
|
||||
[
|
||||
os linux? \ g_type_init word>dlsym and [
|
||||
os linux? "g_type_init" "gobject" dlsym? and [
|
||||
! Explicit type initialization needed for glib < 2.36.
|
||||
g_type_init
|
||||
{ "png" "tif" "tiff" "gif" "jpg" "jpeg" "bmp" "ico" }
|
||||
|
|
|
@ -23,9 +23,9 @@ ERROR: no-tls-supported ;
|
|||
|
||||
MEMO: best-tls-method ( -- class )
|
||||
{
|
||||
{ [ \ TLSv1_2_method word>dlsym ] [ TLSv1.2 ] }
|
||||
{ [ \ TLSv1_1_method word>dlsym ] [ TLSv1.1 ] }
|
||||
{ [ \ TLSv1_method word>dlsym ] [ TLSv1 ] }
|
||||
{ [ "TLSv1_2_method" "libssl" dlsym? ] [ TLSv1.2 ] }
|
||||
{ [ "TLSv1_1_method" "libssl" dlsym? ] [ TLSv1.1 ] }
|
||||
{ [ "TLSv1_method" "libssl" dlsym? ] [ TLSv1 ] }
|
||||
[ no-tls-supported ]
|
||||
} cond ;
|
||||
|
||||
|
|
Loading…
Reference in New Issue