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
use TokenStream;
use parse_macro_input;
/// Marks a struct as a representation of a C-style struct with memory-mapped fields.
///
/// # Supported Attributes:
/// - `size = "<struct size>"` (required)
/// Defines the total memory size of the struct.
///
/// Each field within the struct must be annotated with the `#[field(...)]` attribute.
///
/// # `#[field(...)]` Attributes:
/// - `offset = "<field offset>"` (required)
/// Specifies the memory offset of the field within the struct.
/// This can be either a fixed value (e.g., `0x08`) or a function call (e.g., `get_offset_field_a()`).
/// **Note:** If a function call is used, the function will be executed each time the getter is invoked
/// to determine the field's offset.
///
/// - `getter = "<getter name>"` (optional)
/// Defines a custom name for the field's getter method.
///
/// # Example:
/// ```ignore
/// #[raw_struct(size = 0x10)]
/// struct MyStruct {
/// #[field(offset = 0x00)]
/// pub field_a: u32,
///
/// #[field(offset = 0x04)]
/// pub field_b: u32,
///
/// #[field(offset = 0x08, getter = "get_field_c")]
/// pub field_c: [u8; 0x8],
/// }
/// ```