bevy_render_macros/
lib.rs#![allow(missing_docs)]
#![cfg_attr(docsrs, feature(doc_auto_cfg))]
mod as_bind_group;
mod extract_component;
mod extract_resource;
use bevy_macro_utils::{derive_label, BevyManifest};
use proc_macro::TokenStream;
use quote::format_ident;
use syn::{parse_macro_input, DeriveInput};
pub(crate) fn bevy_render_path() -> syn::Path {
BevyManifest::default()
.maybe_get_path("bevy_render")
.unwrap_or_else(|| BevyManifest::parse_str("crate"))
}
#[proc_macro_derive(ExtractResource)]
pub fn derive_extract_resource(input: TokenStream) -> TokenStream {
extract_resource::derive_extract_resource(input)
}
#[proc_macro_derive(ExtractComponent, attributes(extract_component_filter))]
pub fn derive_extract_component(input: TokenStream) -> TokenStream {
extract_component::derive_extract_component(input)
}
#[proc_macro_derive(
AsBindGroup,
attributes(uniform, storage_texture, texture, sampler, bind_group_data, storage)
)]
pub fn derive_as_bind_group(input: TokenStream) -> TokenStream {
let input = parse_macro_input!(input as DeriveInput);
as_bind_group::derive_as_bind_group(input).unwrap_or_else(|err| err.to_compile_error().into())
}
#[proc_macro_derive(RenderLabel)]
pub fn derive_render_label(input: TokenStream) -> TokenStream {
let input = parse_macro_input!(input as DeriveInput);
let mut trait_path = bevy_render_path();
trait_path
.segments
.push(format_ident!("render_graph").into());
let mut dyn_eq_path = trait_path.clone();
trait_path
.segments
.push(format_ident!("RenderLabel").into());
dyn_eq_path.segments.push(format_ident!("DynEq").into());
derive_label(input, "RenderLabel", &trait_path, &dyn_eq_path)
}
#[proc_macro_derive(RenderSubGraph)]
pub fn derive_render_sub_graph(input: TokenStream) -> TokenStream {
let input = parse_macro_input!(input as DeriveInput);
let mut trait_path = bevy_render_path();
trait_path
.segments
.push(format_ident!("render_graph").into());
let mut dyn_eq_path = trait_path.clone();
trait_path
.segments
.push(format_ident!("RenderSubGraph").into());
dyn_eq_path.segments.push(format_ident!("DynEq").into());
derive_label(input, "RenderSubGraph", &trait_path, &dyn_eq_path)
}