alien.libraries, compiler.cfg.builder.alien: include the result of dlerror/GetLastError in the linkage-error for missing symbols
parent
10845ebfb9
commit
b6e0f0180b
|
@ -5,12 +5,21 @@ kernel namespaces destructors sequences strings
|
||||||
system io.pathnames fry ;
|
system io.pathnames fry ;
|
||||||
IN: alien.libraries
|
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) ;
|
: dlopen ( path -- dll ) native-string>alien (dlopen) ;
|
||||||
|
|
||||||
: dlsym ( name dll -- alien ) [ string>symbol ] dip (dlsym) ;
|
: dlsym ( name dll -- alien ) [ string>symbol ] dip (dlsym) ;
|
||||||
|
|
||||||
: dlsym-raw ( name dll -- alien ) [ string>symbol ] dip (dlsym-raw) ;
|
: dlsym-raw ( name dll -- alien ) [ string>symbol ] dip (dlsym-raw) ;
|
||||||
|
|
||||||
|
: dlerror ( -- message/f ) (dlerror) ;
|
||||||
|
|
||||||
SYMBOL: libraries
|
SYMBOL: libraries
|
||||||
|
|
||||||
libraries [ H{ } clone ] initialize
|
libraries [ H{ } clone ] initialize
|
||||||
|
|
|
@ -0,0 +1,5 @@
|
||||||
|
USING: alien.c-types alien.syntax io.encodings.utf8 ;
|
||||||
|
IN: alien.libraries.unix
|
||||||
|
|
||||||
|
FUNCTION-ALIAS: (dlerror)
|
||||||
|
c-string[utf8] dlerror ( ) ;
|
|
@ -0,0 +1,5 @@
|
||||||
|
USING: windows.errors ;
|
||||||
|
IN: alien.libraries.windows
|
||||||
|
|
||||||
|
: (dlerror) ( -- message )
|
||||||
|
win32-error-string ;
|
|
@ -70,8 +70,8 @@ M: array dlsym-valid? '[ _ dlsym ] any? ;
|
||||||
: check-dlsym ( symbols dll -- )
|
: check-dlsym ( symbols dll -- )
|
||||||
dup dll-valid? [
|
dup dll-valid? [
|
||||||
dupd dlsym-valid?
|
dupd dlsym-valid?
|
||||||
[ drop ] [ cfg get word>> no-such-symbol ] if
|
[ drop ] [ dlerror cfg get word>> no-such-symbol ] if
|
||||||
] [ dll-path cfg get word>> no-such-library drop ] if ;
|
] [ dll-path "" cfg get word>> no-such-library drop ] if ;
|
||||||
|
|
||||||
: decorated-symbol ( params -- symbols )
|
: decorated-symbol ( params -- symbols )
|
||||||
[ function>> ] [ parameters>> [ stack-size ] map-sum number>string ] bi
|
[ function>> ] [ parameters>> [ stack-size ] map-sum number>string ] bi
|
||||||
|
|
|
@ -44,7 +44,7 @@ T{ error-type
|
||||||
: <linkage-error> ( error word -- linkage-error )
|
: <linkage-error> ( error word -- linkage-error )
|
||||||
\ linkage-error <definition-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
|
'[ _ boa ] dip <linkage-error> dup asset>> linkage-errors get set-at ; inline
|
||||||
|
|
||||||
T{ error-type
|
T{ error-type
|
||||||
|
@ -57,16 +57,16 @@ T{ error-type
|
||||||
{ fatal? f }
|
{ fatal? f }
|
||||||
} define-error-type
|
} define-error-type
|
||||||
|
|
||||||
TUPLE: no-such-library name ;
|
TUPLE: no-such-library name message ;
|
||||||
|
|
||||||
M: no-such-library summary drop "Library not found" ;
|
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" ;
|
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 ;
|
Loading…
Reference in New Issue