1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
#![recursion_limit="256"]
extern crate proc_macro;
extern crate proc_macro2;
#[macro_use] extern crate quote;
#[macro_use] extern crate syn;
extern crate rinecs_derive_utils;
extern crate proc_macro_crate;
use proc_macro::TokenStream;
use syn::DeriveInput;
use rinecs_derive_utils::system::{self, SystemType};
#[cfg(not(feature="force_rinecs_cratename"))]
use proc_macro_crate::crate_name;
#[cfg(not(feature="force_rinecs_cratename"))]
use proc_macro2::Span;
use rinecs_derive_utils::system::SystemResourcesTy;
mod filter;
mod debug;
mod component;
mod hierarchical;
mod oneton;
mod hierarchical_oneton;
mod changes;
mod debug_param_fn;
mod onetoone;
#[cfg(not(feature="force_rinecs_cratename"))]
fn rinecs_crate_name() -> syn::Result<syn::Path> {
let crate_name: String = crate_name("rinecs")
.or(crate_name("rin").map(|rin| rin + "::ecs"))
.unwrap_or("rin::ecs".to_string());
syn::parse_str(&crate_name)
}
#[cfg(feature="force_rinecs_cratename")]
fn rinecs_crate_name() -> syn::Result<syn::Path> {
syn::parse_str("rinecs")
}
#[proc_macro_derive(Filter)]
pub fn filter(input: TokenStream) -> TokenStream {
filter::impl_filter(input)
}
#[proc_macro_derive(Component, attributes(storage, debug_as_string, debug_custom, changes, autochanges))]
pub fn component(input: TokenStream) -> TokenStream {
let ast = parse_macro_input!(input as DeriveInput);
let gen = component::impl_component(&ast, false);
TokenStream::from(gen)
}
#[proc_macro_derive(Tag)]
pub fn tag(input: TokenStream) -> TokenStream {
let ast = parse_macro_input!(input as DeriveInput);
let gen = component::impl_tag(&ast);
TokenStream::from(gen)
}
#[proc_macro_derive(NToOneComponent, attributes(storage, debug_as_string, debug_custom, changes, autochanges))]
pub fn ntoone_component(input: TokenStream) -> TokenStream {
let ast = parse_macro_input!(input as DeriveInput);
let gen = component::impl_component(&ast, true);
let gen_ntoone = component::impl_ntoone_component(&ast);
TokenStream::from(gen.into_iter().chain(gen_ntoone.into_iter()).collect::<proc_macro2::TokenStream>())
}
#[proc_macro_derive(OneToOneComponent, attributes(storage, debug_as_string, debug_custom, changes, autochanges))]
pub fn onetoone_component(input: TokenStream) -> TokenStream {
let ast = parse_macro_input!(input as DeriveInput);
let gen = onetoone::impl_one_to_one_component(&ast);
TokenStream::from(gen)
}
#[proc_macro_derive(HierarchicalComponent, attributes(debug_as_string, debug_custom, storage, changes, autochanges))]
pub fn hierarchical_component(input: TokenStream) -> TokenStream {
let ast = parse_macro_input!(input as DeriveInput);
let gen = hierarchical::impl_hierarchical_component(&ast);
TokenStream::from(gen)
}
#[proc_macro_derive(OneToNComponent, attributes(debug_as_string, debug_custom, storage, changes, autochanges))]
pub fn one_to_n_component(input: TokenStream) -> TokenStream {
let ast = parse_macro_input!(input as DeriveInput);
let gen = oneton::impl_one_to_n_component(&ast);
TokenStream::from(gen)
}
#[proc_macro_derive(HierarchicalOneToNComponent, attributes(debug_as_string, debug_custom))]
pub fn hierarchical_one_to_n_component(input: TokenStream) -> TokenStream {
let ast = parse_macro_input!(input as DeriveInput);
let gen = hierarchical_oneton::impl_hierarchical_one_to_n_component(&ast);
TokenStream::from(gen)
}
#[proc_macro_attribute]
pub fn system(args: TokenStream, input: TokenStream) -> TokenStream{
system::impl_any_system(args, input, SystemType::Send, SystemResourcesTy::EntitiesResources)
}
#[proc_macro_attribute]
pub fn system_foreach(args: TokenStream, input: TokenStream) -> TokenStream{
system::impl_any_system(args, input, SystemType::Send, SystemResourcesTy::ForEach)
}
#[proc_macro_attribute]
pub fn system_storages(args: TokenStream, input: TokenStream) -> TokenStream{
system::impl_any_system(args, input, SystemType::Send, SystemResourcesTy::Storages)
}
#[proc_macro_attribute]
pub fn system_once(args: TokenStream, input: TokenStream) -> TokenStream{
system::impl_any_system(args, input, SystemType::SendOnce, SystemResourcesTy::EntitiesResources)
}
#[proc_macro_attribute]
pub fn system_foreach_once(args: TokenStream, input: TokenStream) -> TokenStream{
system::impl_any_system(args, input, SystemType::SendOnce, SystemResourcesTy::ForEach)
}
#[proc_macro_attribute]
pub fn system_foreach_storages(args: TokenStream, input: TokenStream) -> TokenStream{
system::impl_any_system(args, input, SystemType::SendOnce, SystemResourcesTy::Storages)
}
#[proc_macro_attribute]
pub fn system_thread_local(args: TokenStream, input: TokenStream) -> TokenStream{
system::impl_any_system(args, input, SystemType::ThreadLocal, SystemResourcesTy::EntitiesResources)
}
#[proc_macro_attribute]
pub fn system_thread_local_foreach(args: TokenStream, input: TokenStream) -> TokenStream{
system::impl_any_system(args, input, SystemType::ThreadLocal, SystemResourcesTy::ForEach)
}
#[proc_macro_attribute]
pub fn system_thread_local_storages(args: TokenStream, input: TokenStream) -> TokenStream{
system::impl_any_system(args, input, SystemType::ThreadLocal, SystemResourcesTy::Storages)
}
#[proc_macro_attribute]
pub fn system_once_thread_local(args: TokenStream, input: TokenStream) -> TokenStream{
system::impl_any_system(args, input, SystemType::ThreadLocalOnce, SystemResourcesTy::EntitiesResources)
}
#[proc_macro_attribute]
pub fn system_once_thread_local_foreach(args: TokenStream, input: TokenStream) -> TokenStream{
system::impl_any_system(args, input, SystemType::ThreadLocalOnce, SystemResourcesTy::ForEach)
}
#[proc_macro_attribute]
pub fn system_once_thread_local_storages(args: TokenStream, input: TokenStream) -> TokenStream{
system::impl_any_system(args, input, SystemType::ThreadLocalOnce, SystemResourcesTy::Storages)
}
#[proc_macro_attribute]
pub fn creation_system(args: TokenStream, input: TokenStream) -> TokenStream{
system::impl_any_system(args, input, SystemType::Creation, SystemResourcesTy::EntitiesResources)
}
#[proc_macro_attribute]
pub fn creation_system_storages(args: TokenStream, input: TokenStream) -> TokenStream{
system::impl_any_system(args, input, SystemType::Creation, SystemResourcesTy::Storages)
}
#[proc_macro_attribute]
pub fn barrier(args: TokenStream, input: TokenStream) -> TokenStream {
system::impl_barrier(args, input)
}
#[proc_macro_attribute]
pub fn debug_param_fn(args: TokenStream, input: TokenStream) -> TokenStream {
debug_param_fn::impl_debug_param_fn(args, input)
}