use crate::modules::{get_modules, get_path};
use proc_macro::TokenStream;
use quote::{format_ident, quote};
use syn::{
parse::ParseStream, parse_macro_input, Data, DataStruct, DeriveInput, Field, Fields, Path,
};
#[derive(Default)]
struct RenderResourceFieldAttributes {
pub ignore: bool,
pub buffer: bool,
}
#[derive(Default)]
struct RenderResourceAttributes {
pub from_self: bool,
}
static RENDER_RESOURCE_ATTRIBUTE_NAME: &str = "render_resources";
pub fn derive_render_resources(input: TokenStream) -> TokenStream {
let ast = parse_macro_input!(input as DeriveInput);
let modules = get_modules(&ast.attrs);
let bevy_render_path: Path = get_path(&modules.bevy_render);
let attributes = ast
.attrs
.iter()
.find(|a| *a.path.get_ident().as_ref().unwrap() == RENDER_RESOURCE_ATTRIBUTE_NAME)
.map_or_else(RenderResourceAttributes::default, |a| {
syn::custom_keyword!(from_self);
let mut attributes = RenderResourceAttributes::default();
a.parse_args_with(|input: ParseStream| {
if input.parse::