Skip to content

Commit

Permalink
feat: Implement luac summons into base crate instead of requiring eve…
Browse files Browse the repository at this point in the history
…ry mod to do it. (#9)
  • Loading branch information
notnotmelon authored Aug 20, 2024
1 parent d5060bb commit edbb332
Show file tree
Hide file tree
Showing 5 changed files with 516 additions and 3 deletions.
8 changes: 5 additions & 3 deletions rivets-macros/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,8 @@ macro_rules! derive_error {

macro_rules! check_finalized {
() => {
// this check causes issues with rust-analyer. disable during debug builds.
#[cfg(not(debug_assertions))]
if IS_FINALIZED.load(std::sync::atomic::Ordering::Relaxed) {
panic!("The rivets library has already been finalized!");
}
Expand Down Expand Up @@ -243,8 +245,7 @@ pub fn import(attr: TokenStream, item: TokenStream) -> TokenStream {
let attr = quote! { #(#attr)* };

let name = &input.sig.ident;
let function_type =
quote! { #attr #vis unsafe #calling_convention fn(#(#arg_types),*) #return_type };
let function_type = quote! { unsafe #calling_convention fn(#(#arg_types),*) #return_type };

CPP_IMPORTS
.lock()
Expand All @@ -255,7 +256,8 @@ pub fn import(attr: TokenStream, item: TokenStream) -> TokenStream {

quote! {
#[allow(non_upper_case_globals)]
static mut #name: rivets::UnsafeSummonedFunction<#function_type> = rivets::UnsafeSummonedFunction::Uninitialized;
#[allow(missing_docs)]
#attr #vis static mut #name: rivets::UnsafeSummonedFunction<#function_type> = rivets::UnsafeSummonedFunction::Uninitialized;
}.into()
}

Expand Down
1 change: 1 addition & 0 deletions src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
#![warn(missing_docs)]

pub mod defines;
pub mod lua;

extern crate rivets_macros;
pub use rivets_macros::*;
Expand Down
6 changes: 6 additions & 0 deletions src/lua/luac_interface.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
use crate as rivets;
use crate::lua::luastate;
use rivets_macros::import;

#[import(lua_gettop)]
pub extern "C" fn get_top(lua_state: *mut luastate::lua_State) -> i64 {}
Loading

0 comments on commit edbb332

Please sign in to comment.