This repository was archived by the owner on Nov 12, 2025. It is now read-only.
File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -11,5 +11,5 @@ edition = "2018"
1111# Remember to make your output module a cdylib.
1212
1313[dependencies ]
14- dlopen = " 0.1.8 "
14+ libloading = " 0.7.0 "
1515once_cell = " 1.7.2"
Original file line number Diff line number Diff line change @@ -62,6 +62,3 @@ pub extern fn gmod13_close(_state: LuaState) -> i32 {
6262## Acknowledgements
6363### [ garrysmod_common] ( https://github.com/danielga/garrysmod_common )
6464This is heavily based off of garrysmod_common, in how we export the lua_shared functions and trying to replicate everything from the Lua C Api.
65-
66- ### [ rust-dlopen] ( https://github.com/szymonwieloch/rust-dlopen )
67- Thanks to this library we're able to make rglua cross platform.
Original file line number Diff line number Diff line change 11#![ allow( unused) ]
22#![ macro_export]
33
4- use dlopen :: raw :: Library ;
4+ use libloading :: Library ;
55
66// Keep separate in case needed by crates.
77pub static GMOD_DIR : Lazy < PathBuf > = Lazy :: new ( || {
@@ -43,15 +43,19 @@ pub static LUA_SHARED_PATH: Lazy<Option<PathBuf>> = Lazy::new(|| {
4343macro_rules! expose_symbol {
4444 ( $name: ident, $ret: ty, $( $args: tt) * ) => {
4545 pub const $name: Lazy <extern fn $( $args) * -> $ret> = Lazy :: new( || {
46- unsafe { LUA_SHARED_RAW . symbol( stringify!( $name) ) } . unwrap( )
46+ unsafe {
47+ let lib = & * LUA_SHARED_RAW ;
48+ let v: libloading:: Symbol <extern fn $( $args) * -> $ret> = lib. get( stringify!( $name) . as_bytes( ) ) . unwrap( ) ;
49+ std:: mem:: transmute( v)
50+ }
4751 } ) ;
4852 } ;
4953}
5054
5155// dlopen raw lua_shared.dll library. Don't use this unless you know what you're doing.
5256pub const LUA_SHARED_RAW : Lazy < Library > = Lazy :: new ( || {
5357 let path = LUA_SHARED_PATH . as_ref ( ) . expect ( "Couldn't find lua_shared.dll!" ) ;
54- Library :: open ( path) . expect ( "Could not open library" )
58+ unsafe { Library :: new ( path) . expect ( "Could not open library" ) }
5559} ) ;
5660
5761use std:: path:: PathBuf ;
You can’t perform that action at this time.
0 commit comments