bevy/crates/bevy_derive/src/lib.rs

58 lines
2.2 KiB
Rust
Raw Normal View History

2020-01-21 03:15:28 -08:00
extern crate proc_macro;
2020-06-03 20:08:20 -07:00
mod app_plugin;
2020-06-15 12:47:35 -07:00
mod as_vertex_buffer_descriptor;
2020-06-03 20:08:20 -07:00
mod bytes;
2020-05-03 17:54:16 -07:00
mod modules;
mod render_resource;
2020-06-15 12:47:35 -07:00
mod render_resources;
mod resource;
mod shader_defs;
2020-05-03 17:54:16 -07:00
2020-01-19 02:02:12 -08:00
use proc_macro::TokenStream;
2020-03-18 16:06:33 -07:00
/// Derives the FromResources trait. Each field must also implement the FromResources trait or this will fail. FromResources is
/// automatically implemented for types that implement Default.
#[proc_macro_derive(FromResources, attributes(as_crate))]
pub fn derive_from_resources(input: TokenStream) -> TokenStream {
resource::derive_from_resources(input)
2020-04-30 13:26:01 -07:00
}
/// Derives the Bytes trait. Each field must also implements Bytes or this will fail.
#[proc_macro_derive(Bytes, attributes(as_crate))]
pub fn derive_bytes(input: TokenStream) -> TokenStream {
bytes::derive_bytes(input)
}
/// Derives the RenderResources trait. Each field must implement RenderResource or this will fail.
/// You can ignore fields using `#[render_resources(ignore)]`.
#[proc_macro_derive(RenderResources, attributes(render_resources, as_crate))]
pub fn derive_render_resources(input: TokenStream) -> TokenStream {
render_resources::derive_render_resources(input)
}
/// Derives the RenderResource trait. The type must also implement `Bytes` or this will fail.
#[proc_macro_derive(RenderResource, attributes(as_crate))]
pub fn derive_render_resource(input: TokenStream) -> TokenStream {
render_resource::derive_render_resource(input)
}
/// Derives the ShaderDefs trait. Each field must implement ShaderDef or this will fail.
/// You can ignore fields using `#[shader_defs(ignore)]`.
#[proc_macro_derive(ShaderDefs, attributes(shader_def, as_crate))]
pub fn derive_shader_defs(input: TokenStream) -> TokenStream {
shader_defs::derive_shader_defs(input)
}
/// Derives the AsVertexBufferDescriptor trait.
#[proc_macro_derive(AsVertexBufferDescriptor, attributes(vertex, as_crate))]
pub fn derive_as_vertex_buffer_descriptor(input: TokenStream) -> TokenStream {
as_vertex_buffer_descriptor::derive_as_vertex_buffer_descriptor(input)
}
/// Generates a dynamic plugin entry point function for the given `Plugin` type.
2020-08-07 20:22:17 -07:00
#[proc_macro_derive(DynamicPlugin)]
pub fn derive_dynamic_plugin(input: TokenStream) -> TokenStream {
2020-08-07 20:22:17 -07:00
app_plugin::derive_dynamic_plugin(input)
2020-06-15 12:47:35 -07:00
}