]> gitweb.factorcode.org Git - factor.git/commitdiff
alien.libraries: word>dlsym was a stupid idea that didn't work
authorBjörn Lindqvist <bjourne@gmail.com>
Wed, 30 Nov 2016 15:34:53 +0000 (16:34 +0100)
committerBjörn Lindqvist <bjourne@gmail.com>
Wed, 30 Nov 2016 15:36:24 +0000 (16:36 +0100)
The def>> attribute is stripped when deploying. So return dlsym? and use
that.

basis/alien/libraries/libraries-docs.factor
basis/alien/libraries/libraries-tests.factor
basis/alien/libraries/libraries.factor
basis/images/loader/gtk/gtk.factor
basis/io/sockets/secure/secure.factor

index 262ff71e32139f171e697367b343a3243bce6987..741a5be60c802be38ffd7cf018ea0c6a97463dad 100644 (file)
@@ -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
index 33bdeaf2dbd2d783a9da2bca14fdab5a0211d751..66793bf745eaccf9684a3c0a702465983cc743a4 100755 (executable)
@@ -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
index 0eb4dad7ab602823f48ce6c1c320f5299d18f76a..0f95141e2d58e64d4a05e6a4ae5eae280de06af9 100755 (executable)
@@ -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* ;
index 2fd251018522807e1a74c66c5b5d079edc36c989..88071da3f0226192107534316bbc3384c7a8b4bd 100644 (file)
@@ -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" }
index 8a80c59bf9da00a49b31cdf851c79b449540b76c..b0f896f722f7b7800a7d0465a1746d882c2df1ef 100644 (file)
@@ -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 ;