# Generated code

All files in one `aura_add_ui` produce `aura_gen/aura_ui.h` and one `.cpp` per file in the build directory. `aurac` only rewrites files that have changed. Every element is annotated with a `file:line:column` comment in the generated code.

```cpp
namespace views {
struct CartLine {
	std::string description{};
	double quantity{};
	...
};
aura::ui::Value toValue(const CartLine& r);     // dynamic mode
aura::ui::Value toValue(const std::vector<CartLine>& list);

struct ShoppingCartArgs {
	std::vector<CartLine> lines{};
	std::string total{};
	bool canOrder{};
};
struct ShoppingCart {
	aura::ui::RectNode* root = nullptr;
	std::vector<CartLine> lines{};
	void setLines(const std::vector<CartLine>& v);  // state
	...
	std::weak_ptr<aura::Bindings> bindings;
	aura::ui::ScrollNode* list = nullptr;            // IDs
	std::vector<std::shared_ptr<CartRow>> row;      // inside a repeat
	std::function<void()> more;                     // signals
	std::function<void(double)> edit;
	static std::shared_ptr<ShoppingCart> build(aura::ui::RectNode& frame,
		const aura::ui::BasicContext<>& ctx, const ShoppingCartArgs& args = {});
};
}
```

- **Dialogs and screens** have `static size()` (dialogs only) and `static build()`; **components** have a `NameArgs` and `build<Name>(parent, ctx, args, instance)`. `instance` receives the root after the component's own properties and before its children, just like instance properties.
- **Fields:** state (with setters), IDs (node pointers, `std::shared_ptr<Component>` for components, vectors inside repeats), and signals (`std::function`).
- **Lifetime:** the struct is attached to its root node (`Node::attach`: the frame or component root) and lives as long as that node. The application does not need to retain it.
- **Signals** are read only when emitted and can therefore be assigned after `build()`.
- **Dynamic mode:** `build()` first asks the loader (arguments as `aura::ui::Value`, records via `toValue()`). If the loader has loaded the file, `load<Name>()` fills the struct: IDs, component instance structs (once per instance, including nested ones), signals, and IDs again after every block rebuild. Otherwise the compiled construction path runs.
