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