Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
bevyengine
GitHub Repository: bevyengine/bevy
Path: blob/main/crates/bevy_material/macros/src/lib.rs
9351 views
1
#![expect(missing_docs, reason = "Not all docs are written yet, see #3492.")]
2
#![cfg_attr(docsrs, feature(doc_cfg))]
3
4
use bevy_macro_utils::{derive_label, BevyManifest};
5
use proc_macro::TokenStream;
6
use quote::format_ident;
7
use syn::{parse_macro_input, DeriveInput};
8
9
pub(crate) fn bevy_material_path() -> syn::Path {
10
BevyManifest::shared(|manifest| manifest.get_path("bevy_material"))
11
}
12
13
#[proc_macro_derive(ShaderLabel)]
14
pub fn derive_shader_label(input: TokenStream) -> TokenStream {
15
let input = parse_macro_input!(input as DeriveInput);
16
let mut trait_path = bevy_material_path();
17
trait_path.segments.push(format_ident!("labels").into());
18
trait_path
19
.segments
20
.push(format_ident!("ShaderLabel").into());
21
derive_label(input, "ShaderLabel", &trait_path)
22
}
23
24
#[proc_macro_derive(DrawFunctionLabel)]
25
pub fn derive_draw_function_label(input: TokenStream) -> TokenStream {
26
let input = parse_macro_input!(input as DeriveInput);
27
let mut trait_path = bevy_material_path();
28
trait_path.segments.push(format_ident!("labels").into());
29
trait_path
30
.segments
31
.push(format_ident!("DrawFunctionLabel").into());
32
derive_label(input, "DrawFunctionLabel", &trait_path)
33
}
34
35