]> gitweb.factorcode.org Git - factor.git/commitdiff
alien.libraries, compiler.cfg.builder.alien: include the result of dlerror/GetLastErr...
authorJoe Groff <arcata@gmail.com>
Mon, 12 Sep 2011 19:27:34 +0000 (12:27 -0700)
committerJoe Groff <arcata@gmail.com>
Tue, 13 Sep 2011 06:25:59 +0000 (23:25 -0700)
basis/alien/libraries/libraries.factor
basis/alien/libraries/unix/unix.factor [new file with mode: 0644]
basis/alien/libraries/windows/windows.factor [new file with mode: 0644]
basis/compiler/cfg/builder/alien/alien.factor
basis/compiler/errors/errors.factor

index 37ac47307d56a148c8fbbeb7b49c20f639342232..e24105651a7f69f18d62e743d953ba02091374fd 100755 (executable)
@@ -5,12 +5,21 @@ kernel namespaces destructors sequences strings
 system io.pathnames fry ;
 IN: alien.libraries
 
+ERROR: unknown-dlsym-platform ;
+<< {
+    { [ os windows? ] [ "alien.libraries.windows" ] }
+    { [ os unix? ] [ "alien.libraries.unix" ] }
+    [ unknown-dlsym-platform ]
+} cond use-vocab >>
+
 : dlopen ( path -- dll ) native-string>alien (dlopen) ;
 
 : dlsym ( name dll -- alien ) [ string>symbol ] dip (dlsym) ;
 
 : dlsym-raw ( name dll -- alien ) [ string>symbol ] dip (dlsym-raw) ;
 
+: dlerror ( -- message/f ) (dlerror) ;
+
 SYMBOL: libraries
 
 libraries [ H{ } clone ] initialize
diff --git a/basis/alien/libraries/unix/unix.factor b/basis/alien/libraries/unix/unix.factor
new file mode 100644 (file)
index 0000000..8db779d
--- /dev/null
@@ -0,0 +1,5 @@
+USING: alien.c-types alien.syntax io.encodings.utf8 ;
+IN: alien.libraries.unix
+
+FUNCTION-ALIAS: (dlerror)
+    c-string[utf8] dlerror ( ) ;
diff --git a/basis/alien/libraries/windows/windows.factor b/basis/alien/libraries/windows/windows.factor
new file mode 100644 (file)
index 0000000..9a595c8
--- /dev/null
@@ -0,0 +1,5 @@
+USING: windows.errors ;
+IN: alien.libraries.windows
+
+: (dlerror) ( -- message )
+    win32-error-string ;
index d0a4d19723e79e1140670ac21f9c7e74b5e9af4e..114d1deb3e3fb08165d6a82e37bf9b35255e8ee4 100644 (file)
@@ -70,8 +70,8 @@ M: array dlsym-valid? '[ _ dlsym ] any? ;
 : check-dlsym ( symbols dll -- )
     dup dll-valid? [
         dupd dlsym-valid?
-        [ drop ] [ cfg get word>> no-such-symbol ] if
-    ] [ dll-path cfg get word>> no-such-library drop ] if ;
+        [ drop ] [ dlerror cfg get word>> no-such-symbol ] if
+    ] [ dll-path "" cfg get word>> no-such-library drop ] if ;
 
 : decorated-symbol ( params -- symbols )
     [ function>> ] [ parameters>> [ stack-size ] map-sum number>string ] bi
index 3881439fc0ed0d1119506ad70dfaed6db546c281..3c00c5173e4ebb3fd015d93f1fea69ca92158974 100644 (file)
@@ -44,7 +44,7 @@ T{ error-type
 : <linkage-error> ( error word -- linkage-error )
     \ linkage-error <definition-error> ;
 
-: linkage-error ( error word class -- )
+: linkage-error ( name message word class -- )
     '[ _ boa ] dip <linkage-error> dup asset>> linkage-errors get set-at ; inline
 
 T{ error-type
@@ -57,16 +57,16 @@ T{ error-type
    { fatal? f }
 } define-error-type
 
-TUPLE: no-such-library name ;
+TUPLE: no-such-library name message ;
 
 M: no-such-library summary drop "Library not found" ;
 
-: no-such-library ( name word -- ) \ no-such-library linkage-error ;
+: no-such-library ( name message word -- ) \ no-such-library linkage-error ;
 
-TUPLE: no-such-symbol name ;
+TUPLE: no-such-symbol name message ;
 
 M: no-such-symbol summary drop "Symbol not found" ;
 
-: no-such-symbol ( name word -- ) \ no-such-symbol linkage-error ;
+: no-such-symbol ( name message word -- ) \ no-such-symbol linkage-error ;
 
-ERROR: not-compiled word error ;
\ No newline at end of file
+ERROR: not-compiled word error ;