]> gitweb.factorcode.org Git - factor.git/commitdiff
alien.libraries.finder: Make find-library return the string passed in instead of...
authorDoug Coleman <doug.coleman@gmail.com>
Sun, 8 Jun 2014 03:48:09 +0000 (20:48 -0700)
committerDoug Coleman <doug.coleman@gmail.com>
Sun, 8 Jun 2014 03:58:14 +0000 (20:58 -0700)
basis/alien/libraries/finder/finder.factor
basis/alien/libraries/finder/linux/linux.factor
basis/alien/libraries/finder/macosx/macosx.factor
basis/alien/libraries/finder/windows/windows.factor
basis/alien/libraries/libraries.factor
basis/debugger/debugger.factor

index 574e00ad4bbae7d5be7d35afbb7156fc5490c236..681c605d3240d8db8d3459a8a11fdc31ce9cfb47 100644 (file)
@@ -1,9 +1,11 @@
 
-USING: combinators system vocabs ;
-
+USING: combinators kernel system vocabs alien.libraries ;
 IN: alien.libraries.finder
 
-HOOK: find-library os ( name -- path/f )
+HOOK: find-library* os ( name -- path/f )
+
+: find-library ( name -- path/library-not-found )
+    dup find-library* [ nip ] when* ;
 
 {
     { [ os macosx?  ] [ "alien.libraries.finder.macosx"  ] }
index 2785e31603437f5cd510adf7bd769a516c39ee51..482a55cf032276c408d916dd35c446c5b450d1f5 100644 (file)
@@ -35,7 +35,7 @@ CONSTANT: mach-map {
 
 PRIVATE>
 
-M: linux find-library
+M: linux find-library*
     "lib" ".so" surround ldconfig-find-soname [
         { [ exists? ] [ file-info regular-file? ] } 1&&
     ] map-find nip ;
index 63da9a3ff008a2a642615846abaa6f51aed239b5..c6d260b6d91c5fb720d6e137fe7b85d321421b15 100644 (file)
@@ -128,7 +128,7 @@ PRIVATE>
         ] if* file-name append-path dyld-find
     ] if* ;
 
-M: macosx find-library
+M: macosx find-library*
     [ "lib" ".dylib" surround ]
     [ ".dylib" append ]
     [ ".framework/" over 3append ] tri 3array
index 1ebfa6ed34cb1fe7cff9ffcaf1efd78898978bdd..d23f2e8d7ed837092378b97c894e6c9ba35b85d5 100644 (file)
@@ -26,7 +26,7 @@ IN: alien.libraries.finder.windows
 
 PRIVATE>
 
-M: windows find-library
+M: windows find-library*
     candidate-paths [
         { [ exists? ] [ file-info regular-file? ] } 1&&
     ] map-find nip ;
index 17f75a670f3a070cc6888316f49ac79abda17e08..5a06b01a84e9379f06e43b91c462238f21a3924d 100755 (executable)
@@ -23,8 +23,6 @@ C: <library> library
 
 ERROR: no-library name ;
 
-ERROR: library-path-is-f name path abi ;
-
 : lookup-library ( name -- library ) libraries get at ;
 
 : open-dll ( path -- dll dll-error/f )
@@ -34,10 +32,6 @@ ERROR: library-path-is-f name path abi ;
 : make-library ( path abi -- library )
     [ dup open-dll ] dip <library> ;
 
-: try-make-library ( name path abi -- library )
-    over [ [ nip ] dip ] [ library-path-is-f ] if
-    make-library ;
-
 : library-dll ( library -- dll )
     dup [ dll>> ] when ;
 
@@ -58,7 +52,7 @@ M: library dispose dll>> [ dispose ] when* ;
 : add-library ( name path abi -- )
     3dup add-library? [
         [ 2drop remove-library ]
-        [ try-make-library ]
+        [ [ nip ] dip make-library ]
         [ 2drop libraries get set-at ] 3tri
     ] [ 3drop ] if ;
 
index 1076d34acaa63eb4d57ae56775062fe4526834e7..cc98a168b69a4fc46a0b3c09ca60cb7c9e381bdd 100755 (executable)
@@ -2,14 +2,14 @@
 ! See http://factorcode.org/license.txt for BSD license.
 USING: accessors alien.strings arrays assocs classes
 classes.builtin classes.mixin classes.tuple classes.tuple.parser
-combinators combinators.short-circuit compiler.units
-continuations definitions destructors effects.parser generic
-generic.math generic.parser generic.single grouping io
-io.encodings io.styles kernel kernel.private lexer make math
-math.order math.parser namespaces parser prettyprint sequences
-sequences.private slots source-files.errors strings
-strings.parser summary system vocabs vocabs.loader
-vocabs.parser words ;
+combinators combinators.short-circuit compiler.errors
+compiler.units continuations definitions destructors
+effects.parser fry generic generic.math generic.parser
+generic.single grouping io io.encodings io.styles kernel
+kernel.private lexer make math math.order math.parser namespaces
+parser prettyprint sequences sequences.private slots
+source-files.errors strings strings.parser summary system vocabs
+vocabs.loader vocabs.parser words ;
 FROM: namespaces => change-global ;
 IN: debugger
 
@@ -110,11 +110,17 @@ HOOK: signal-error. os ( obj -- )
 : ffi-error. ( obj -- )
     "FFI error" print drop ;
 
+: find-ffi-error ( string -- error )
+    [ linkage-errors get ] dip
+    '[ nip asset>> name>> _ = ] assoc-find drop nip
+    [ error>> message>> ] [ "none" ] if* ;
+
 : undefined-symbol-error. ( obj -- )
     "Cannot resolve C library function" print
-    "Symbol: " write dup third symbol>string print
-    "Library: " write fourth .
-    "You are probably missing a library or the library path is wrong." print
+    "Library: " write dup fourth .
+    third symbol>string
+    [ "Symbol: " write print ]
+    [ "DlError: " write find-ffi-error print ] bi
     "See http://concatenative.org/wiki/view/Factor/Requirements" print ;
 
 : stack-underflow. ( obj name -- )