Potentially fix some macro hygiene

This commit is contained in:
William Venner 2021-12-09 18:23:19 +00:00
parent 1f6e947223
commit a1f4f9cbac
4 changed files with 10 additions and 10 deletions

10
Cargo.lock generated
View File

@ -126,7 +126,7 @@ dependencies = [
"fn_abi", "fn_abi",
"fn_has_this", "fn_has_this",
"fn_type_alias", "fn_type_alias",
"gmod-macros 1.0.0 (registry+https://github.com/rust-lang/crates.io-index)", "gmod-macros 1.0.0",
"lazy_static", "lazy_static",
"libloading", "libloading",
"null_fn", "null_fn",
@ -144,7 +144,7 @@ dependencies = [
"fn_abi", "fn_abi",
"fn_has_this", "fn_has_this",
"fn_type_alias", "fn_type_alias",
"gmod-macros 1.0.0", "gmod-macros 1.0.1",
"gmserverplugin", "gmserverplugin",
"lazy_static", "lazy_static",
"libloading", "libloading",
@ -155,6 +155,8 @@ dependencies = [
[[package]] [[package]]
name = "gmod-macros" name = "gmod-macros"
version = "1.0.0" version = "1.0.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "b791745998b09a16260e803bb0cca1a641e9b70e2aae94d7a485d34259b29279"
dependencies = [ dependencies = [
"proc-macro2", "proc-macro2",
"quote", "quote",
@ -163,9 +165,7 @@ dependencies = [
[[package]] [[package]]
name = "gmod-macros" name = "gmod-macros"
version = "1.0.0" version = "1.0.1"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "b791745998b09a16260e803bb0cca1a641e9b70e2aae94d7a485d34259b29279"
dependencies = [ dependencies = [
"proc-macro2", "proc-macro2",
"quote", "quote",

View File

@ -1,6 +1,6 @@
[package] [package]
name = "gmod-macros" name = "gmod-macros"
version = "1.0.0" version = "1.0.1"
authors = ["William Venner <william@venner.io>"] authors = ["William Venner <william@venner.io>"]
edition = "2018" edition = "2018"
license = "MIT" license = "MIT"

View File

@ -22,19 +22,19 @@ pub fn gmod13_open(_attr: TokenStream, tokens: TokenStream) -> TokenStream {
let mut input = parse_macro_input!(tokens as ItemFn); let mut input = parse_macro_input!(tokens as ItemFn);
check_lua_function(&mut input); check_lua_function(&mut input);
input.block.stmts.insert(0, syn::parse2(quote!(#[allow(unused_unsafe)] unsafe { ::gmod::lua::load() })).unwrap()); input.block.stmts.insert(0, syn::parse2(quote!(#[allow(unused_unsafe)] unsafe { ::gmod::lua::load() })).unwrap());
TokenStream::from(quote!(#[no_mangle] #input)) input.into_token_stream().into()
} }
#[proc_macro_attribute] #[proc_macro_attribute]
pub fn gmod13_close(_attr: TokenStream, tokens: TokenStream) -> TokenStream { pub fn gmod13_close(_attr: TokenStream, tokens: TokenStream) -> TokenStream {
let mut input = parse_macro_input!(tokens as ItemFn); let mut input = parse_macro_input!(tokens as ItemFn);
check_lua_function(&mut input); check_lua_function(&mut input);
TokenStream::from(quote!(#[no_mangle] #input)) input.into_token_stream().into()
} }
#[proc_macro_attribute] #[proc_macro_attribute]
pub fn lua_function(_attr: TokenStream, tokens: TokenStream) -> TokenStream { pub fn lua_function(_attr: TokenStream, tokens: TokenStream) -> TokenStream {
let mut input = parse_macro_input!(tokens as ItemFn); let mut input = parse_macro_input!(tokens as ItemFn);
check_lua_function(&mut input); check_lua_function(&mut input);
TokenStream::from(quote!(#input)) input.into_token_stream().into()
} }

View File

@ -15,7 +15,7 @@ hax = ["ctor", "skidscan", "detour", "fn_type_alias", "fn_abi", "cfg_table", "nu
server-plugin = ["gmserverplugin"] server-plugin = ["gmserverplugin"]
[dependencies] [dependencies]
gmod-macros = { version = "1.0.0", path = "../gmod-macros" } gmod-macros = { version = "1.0.1", path = "../gmod-macros" }
gmserverplugin = { version = "1", optional = true } gmserverplugin = { version = "1", optional = true }
libloading = "0" libloading = "0"