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
// Copyright (c) 2025 Nobuharu Shimazu
//
// Permission is hereby granted, free of charge, to any person obtaining a copy
// of this software and associated documentation files (the "Software"), to deal
// in the Software without restriction, including without limitation the rights
// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
// copies of the Software, and to permit persons to whom the Software is
// furnished to do so, subject to the following conditions:
//
// The above copyright notice and this permission notice shall be included in all
// copies or substantial portions of the Software.
//
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
// SOFTWARE.
//! Library for generating C code
//!
//! This library provides an API for generating C source code.
//! It allows structured generation of C code using Rust, ensuring proper formatting and
//! structure while maintaining readability.
//!
//! Notable capabilities include a recursive type model with a real declarator
//! algorithm (so pointers, arrays, and function pointers nest correctly),
//! precedence-aware expression printing that inserts only the parentheses a given
//! grouping requires, and translation-unit splitting into a matching header and
//! source pair via [`Module`].
//!
//! ## Modules
//! - `function`: Defines and formats C functions.
//! - `preprocessor`: Manages preprocessor directives like `#include`, `#define`, and `#pragma`.
//! - `variable`: Handles variable declarations.
//! - `types`: Defines C types and type qualifiers.
//! - `storage`: TODO
//! - `structs`: Supports defining and managing C struct types.
//! - `union`: Provides utilities for defining and formatting C unions.
//! - `typedef`: Facilitates creating `typedef` aliases for types in C.
//! - `loops`: Constructs and formats C loop structures (`for`, `while`, `do-while`).
//! - `conditional`: Handles conditional statements like `if`, `switch`.
//! - `formatter`: Provides utilities for formatting generated C code.
//! - `scope`: Defines scope management for C code generation.
//! - `module`: Splits a translation unit into a matching header (`.h`) and source (`.c`) pair.
//! - `ident`: Identifier hygiene — sanitizing names, C keyword checks, and fresh-name generation.
//! - `attribute`: GNU/C23 attributes (`packed`, `noreturn`, `aligned`, ...) for items.
//! - `static_assert`: `_Static_assert`/`static_assert` compile-time assertions.
//! - `block`: Manages blocks of code within functions and control structures.
//! - `comment`: Supports adding inline and documentation comments.
//! - `expr`: Handles C expressions and operations.
//! - `enums`: Supports enumeration (`enum`) type definitions.
//!
//! ## Example Usage
//! ```rust
//! use tamago::{BaseType, Block, FunctionBuilder, ParameterBuilder, Type};
//!
//! let func = FunctionBuilder::new_with_str("my_function", Type::new(BaseType::Int).build())
//! .param(
//! ParameterBuilder::new_with_str(
//! "param1",
//! Type::new(BaseType::Float).build(),
//! )
//! .build(),
//! )
//! .body(Block::new().build())
//! .build();
//!
//! println!("{}", func);
//! ```
//!
//! This will generate the following C function:
//! ```c
//! int my_function(float param1) {
//! }
//! ```
//!
pub use ;
pub use ;
pub use ;
pub use ;
pub use ;
pub use ;
pub use ;
pub use ;
pub use ;
pub use ;
pub use ;
pub use ;
pub use ;
pub use StaticAssert;
pub use StorageClass;
pub use ;
pub use ;
pub use ;
pub use ;
pub use ;