alien.libraries, compiler.cfg.builder.alien: include the result of dlerror/GetLastError in the linkage-error for missing symbols

db4
Joe Groff 2011-09-12 12:27:34 -07:00
parent 10845ebfb9
commit b6e0f0180b
5 changed files with 27 additions and 8 deletions

View File

@ -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

View File

@ -0,0 +1,5 @@
USING: alien.c-types alien.syntax io.encodings.utf8 ;
IN: alien.libraries.unix
FUNCTION-ALIAS: (dlerror)
c-string[utf8] dlerror ( ) ;

View File

@ -0,0 +1,5 @@
USING: windows.errors ;
IN: alien.libraries.windows
: (dlerror) ( -- message )
win32-error-string ;

View 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

View 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 ;
ERROR: not-compiled word error ;