77
88pub struct {{ "ScriptingPlugin" | prefix_cratename | convert_case(case="upper_camel")}};
99
10+ {% for item in items %}
11+ #[script_bindings(
12+ remote,
13+ name = "{{ item.ident | convert_case(case="snake") }}",
14+ )]
15+ impl {{item.import_path}} {
16+ {%- for function in item.functions -%}
17+
18+ fn {{ function.ident }} (
19+ {%- for arg in function.args -%}
20+ {%- if arg.proxy_ty is matching("Mut.*")-%}
21+ mut {% endif -%}
22+ {{- arg.ident | to_arg_pattern() -}}
23+ : {{- arg.proxy_ty -}},
24+ {%- endfor -%}
25+ ) {
26+ let output: {{ function.output.proxy_ty }} =
27+ {%- if function.from_trait_path -%}
28+ {{- function_call_expression(type=item.import_path, trait=function.from_trait_path, function=function.ident) -}}
29+ {%- else -%}
30+ {{- function_call_expression(type=item.import_path, function=function.ident) -}}
31+ {%- endif -%}
32+ (
33+ {%- for arg in function.args -%}
34+ {%- if arg.proxy_ty is matching("Ref.*")-%}
35+ &{% endif -%}
36+ {%- if arg.proxy_ty is matching ("Mut.*")-%}
37+ &mut {% endif -%}
38+ {{- arg.ident | to_arg_pattern() -}}
39+ {%- if arg.proxy_ty is matching("Val.*")-%}
40+ .into_inner()
41+ {%- endif -%},
42+ {%- endfor -%}
43+ ).into();
44+ output
45+ }
46+ {%- endfor -%};
47+ }
48+ {% endfor %}
49+
1050impl ::bevy::app::Plugin for {{ "ScriptingPlugin" | prefix_cratename | convert_case(case="upper_camel")}} {
1151 fn build(&self, app: &mut ::bevy::prelude::App) {
1252 let mut world = app.world_mut();
1353
1454 {% for item in items %}
15- NamespaceBuilder::<::{{ item.import_path }}>::new(world)
16- {%- for function in item.functions -%}
17- .register("{{ function.ident }}", |
18- {%- for arg in function.args -%}
19- {%- if arg.proxy_ty is matching("Mut.*")-%}
20- mut {% endif -%}
21- {{- arg.ident | to_arg_pattern() -}}
22- : {{- arg.proxy_ty -}},
23- {%- endfor -%}
24- | {
25- let output: {{ function.output.proxy_ty }} =
26- {%- if function.from_trait_path -%}
27- {{- function_call_expression(type=item.import_path, trait=function.from_trait_path, function=function.ident) -}}
28- {%- else -%}
29- {{- function_call_expression(type=item.import_path, function=function.ident) -}}
30- {%- endif -%}
31- (
32- {%- for arg in function.args -%}
33- {%- if arg.proxy_ty is matching("Ref.*")-%}
34- &{% endif -%}
35- {%- if arg.proxy_ty is matching ("Mut.*")-%}
36- &mut {% endif -%}
37- {{- arg.ident | to_arg_pattern() -}}
38- {%- if arg.proxy_ty is matching("Val.*")-%}
39- .into_inner()
40- {%- endif -%},
41- {%- endfor -%}
42- ).into();
43- output
44- })
45- {%- endfor -%};
55+ register_{{ item.ident | convert_case(case="snake") }}(&mut world);
4656 {% endfor %}
4757 }
4858}
0 commit comments