From e47f7409e75fa3075d365e25250842e19671d242 Mon Sep 17 00:00:00 2001 From: William Venner Date: Sun, 19 Sep 2021 22:44:35 +0100 Subject: [PATCH] better macro hygiene --- gmod/src/lib.rs | 46 +++++++++++++++++++++++----------------------- 1 file changed, 23 insertions(+), 23 deletions(-) diff --git a/gmod/src/lib.rs b/gmod/src/lib.rs index ba44000..6b3fc9c 100644 --- a/gmod/src/lib.rs +++ b/gmod/src/lib.rs @@ -40,7 +40,7 @@ pub fn is_x86_64() -> bool { #[macro_export] macro_rules! open_library_raw { ($($path:literal),+) => { - ::gmod::libloading::Library::new(concat!($($path),+)).map(|lib| (lib, concat!($($path),+))) + $crate::libloading::Library::new(concat!($($path),+)).map(|lib| (lib, concat!($($path),+))) } } @@ -61,24 +61,24 @@ macro_rules! open_library_srv { } #[cfg(all(target_os = "windows", target_pointer_width = "64"))] { - ::gmod::open_library_raw!("bin/win64/", $name, ".dll") + $crate::open_library_raw!("bin/win64/", $name, ".dll") } #[cfg(all(target_os = "windows", target_pointer_width = "32"))] { - ::gmod::open_library_raw!("bin/", $name, ".dll") - .or_else(|_| ::gmod::open_library_raw!("garrysmod/bin/", $name, ".dll")) + $crate::open_library_raw!("bin/", $name, ".dll") + .or_else(|_| $crate::open_library_raw!("garrysmod/bin/", $name, ".dll")) } #[cfg(all(target_os = "linux", target_pointer_width = "64"))] { - ::gmod::open_library_raw!("bin/linux64/", $name, ".so") - .or_else(|_| ::gmod::open_library_raw!("bin/linux64/lib", $name, ".so")) + $crate::open_library_raw!("bin/linux64/", $name, ".so") + .or_else(|_| $crate::open_library_raw!("bin/linux64/lib", $name, ".so")) } #[cfg(all(target_os = "linux", target_pointer_width = "32"))] { - ::gmod::open_library_raw!("bin/linux32/", $name, ".so") - .or_else(|_| ::gmod::open_library_raw!("bin/linux32/lib", $name, ".so")) - .or_else(|_| ::gmod::open_library_raw!("bin/", $name, "_srv.so")) - .or_else(|_| ::gmod::open_library_raw!("bin/lib", $name, "_srv.so")) - .or_else(|_| ::gmod::open_library_raw!("bin/", $name, ".so")) - .or_else(|_| ::gmod::open_library_raw!("bin/lib", $name, ".so")) + $crate::open_library_raw!("bin/linux32/", $name, ".so") + .or_else(|_| $crate::open_library_raw!("bin/linux32/lib", $name, ".so")) + .or_else(|_| $crate::open_library_raw!("bin/", $name, "_srv.so")) + .or_else(|_| $crate::open_library_raw!("bin/lib", $name, "_srv.so")) + .or_else(|_| $crate::open_library_raw!("bin/", $name, ".so")) + .or_else(|_| $crate::open_library_raw!("bin/lib", $name, ".so")) } }}; } @@ -100,24 +100,24 @@ macro_rules! open_library { } #[cfg(all(target_os = "windows", target_pointer_width = "64"))] { - ::gmod::open_library_raw!("bin/win64/", $name, ".dll") + $crate::open_library_raw!("bin/win64/", $name, ".dll") } #[cfg(all(target_os = "windows", target_pointer_width = "32"))] { - ::gmod::open_library_raw!("bin/", $name, ".dll") - .or_else(|_| ::gmod::open_library_raw!("garrysmod/bin/", $name, ".dll")) + $crate::open_library_raw!("bin/", $name, ".dll") + .or_else(|_| $crate::open_library_raw!("garrysmod/bin/", $name, ".dll")) } #[cfg(all(target_os = "linux", target_pointer_width = "64"))] { - ::gmod::open_library_raw!("bin/linux64/", $name, ".so") - .or_else(|_| ::gmod::open_library_raw!("bin/linux64/lib", $name, ".so")) + $crate::open_library_raw!("bin/linux64/", $name, ".so") + .or_else(|_| $crate::open_library_raw!("bin/linux64/lib", $name, ".so")) } #[cfg(all(target_os = "linux", target_pointer_width = "32"))] { - ::gmod::open_library_raw!("bin/linux32/", $name, ".so") - .or_else(|_| ::gmod::open_library_raw!("bin/linux32/lib", $name, ".so")) - .or_else(|_| ::gmod::open_library_raw!("bin/", $name, ".so")) - .or_else(|_| ::gmod::open_library_raw!("bin/lib", $name, ".so")) - .or_else(|_| ::gmod::open_library_raw!("bin/", $name, "_srv.so")) - .or_else(|_| ::gmod::open_library_raw!("bin/lib", $name, "_srv.so")) + $crate::open_library_raw!("bin/linux32/", $name, ".so") + .or_else(|_| $crate::open_library_raw!("bin/linux32/lib", $name, ".so")) + .or_else(|_| $crate::open_library_raw!("bin/", $name, ".so")) + .or_else(|_| $crate::open_library_raw!("bin/lib", $name, ".so")) + .or_else(|_| $crate::open_library_raw!("bin/", $name, "_srv.so")) + .or_else(|_| $crate::open_library_raw!("bin/lib", $name, "_srv.so")) } }}; } \ No newline at end of file