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
/// Mark a function as an Ecsact system implementation. A C function will be
/// created for you that will call the marked function with safe context struct
/// from the Ecsact code generator.
///
/// See: https://ecsact.dev/docs/system-impl
///
/// # Example
///
/// Given the following Ecsact file contents:
///
/// ```ecsact
/// package example;
/// component Position { f32 x; f32 y; }
/// system Gravity { readwrite Position; }
/// ```
///
/// A system implementation may be created with the proc macro like so:
///
/// ```rust
/// #[ecsact_macro::system_impl("example.Gravity")]
/// fn gravity(ctx: &mut example::Gravity::Context) {
/// todo!()
/// }
/// ```
/// Mark a function as an Ecsact codegen plugin entry point. Two C functions
/// will be created for you that are required for an Ecsact plugin. One will
/// contain the function you marked as the entry point and be given a "context"
/// object of type `ecsact::CodegenPluginContext`.
///
/// Using the `ecsact_dylib_runtime` crate your entry point will have access to
/// the Ecsact Meta module for the current ecsact file it is processing.
///
/// # Example
///
/// This rust function can use `ctx` to write to a `.txt` file based on the
/// ecsact file.
///
/// ```rust
/// #[ecsact_codegen::plugin_entry("txt")]
/// fn my_plugin(ctx: &mut ecsact::CodegenPluginContext) {
/// let pkg_name = ecsact::meta::package_name(ctx.package_id());
/// writeln!(ctx, "{pkg_name}").unwrap()
/// }
/// ```
///
/// If the ecsact file had a package statement of hello:
///
/// ```ecsact
/// package hello;
/// ```
///
/// The text output file would contain a single line with the packag name.
///
/// ```txt
/// hello
/// ```