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
//! Procedural macros shared across the Suon workspace.
//!
//! # Examples
//! ```ignore
//! use suon_macros::Table;
//!
//! #[derive(Table)]
//! struct Inventory {
//! capacity: usize,
//! }
//! ```
use TokenStream;
/// Procedural macro to automatically generate code for the `Table` trait.
///
/// This macro delegates the implementation to the `derive_table` function
/// defined in the `resource` module, passing along the input TokenStream.
///
/// # Usage
/// ```ignore
/// use suon_macros::Table;
///
/// #[derive(Table)]
/// struct MyTable {
/// id: u32,
/// }
/// ```
///
/// The macro expands into the necessary code to implement the `Table` trait
/// for the annotated struct, based on the logic in `resource::derive_table`.
/// Derives `suon_lua::LuaComponent` for a Bevy component that implements
/// `serde::Serialize` and `serde::de::DeserializeOwned`.
///
/// The Lua-visible name defaults to the struct name. Override with
/// `#[lua(name = "CustomName")]`.
///
/// # Usage
/// ```ignore
/// use bevy::prelude::*;
/// use serde::{Deserialize, Serialize};
/// use suon_macros::LuaComponent;
///
/// #[derive(Component, Serialize, Deserialize, LuaComponent)]
/// struct Health { value: i32 }
///
/// // In plugin setup:
/// app.register_lua_component::<Health>();
/// ```
/// Derives `suon_lua::Hook` for a serializable hook payload.
///
/// The Lua-visible hook name defaults to `on{StructName}`. Override with
/// `#[lua(name = "onCustom")]`.
///
/// # Usage
/// ```ignore
/// use serde::Serialize;
/// use suon_macros::LuaHook;
///
/// #[derive(Serialize, LuaHook)]
/// struct Move {
/// from: (i32, i32),
/// to: (i32, i32),
/// }
/// ```