use handle_macro::lua_wrap_handle_impl; use lua_macro::wrap_lua_struct_impl; use quote::quote; use syn::{parse_macro_input, Token}; mod mat_wrapper; mod vec_wrapper; use vec_wrapper::VecWrapper; mod lua_macro; mod handle_macro; pub(crate) const FN_NAME_INTERNAL_REFLECT_TYPE: &str = "__lyra_internal_reflect_type"; pub(crate) const FN_NAME_INTERNAL_REFLECT: &str = "__lyra_internal_reflect"; #[proc_macro] pub fn wrap_lua_struct(input: proc_macro::TokenStream) -> proc_macro::TokenStream { wrap_lua_struct_impl(input) } #[proc_macro] pub fn lua_wrap_handle(input: proc_macro::TokenStream) -> proc_macro::TokenStream { lua_wrap_handle_impl(input) } pub(crate) struct VecExtensionInputs { #[allow(dead_code)] pub type_path: syn::Path, pub wrapper_ident: syn::Ident, } impl syn::parse::Parse for VecExtensionInputs { fn parse(input: syn::parse::ParseStream) -> syn::Result { let type_path: syn::Path = input.parse()?; let _comma: Token![,] = input.parse()?; let wrapper_ident: syn::Ident = input.parse()?; Ok(Self { type_path, wrapper_ident }) } } #[proc_macro] pub fn lua_vec_wrap_extension(input: proc_macro::TokenStream) -> proc_macro::TokenStream { let input = parse_macro_input!(input as VecExtensionInputs); let wrapper = VecWrapper; let method_tokens = wrapper.to_method_tokens(&input.wrapper_ident); quote! { #method_tokens }.into() }