====== PXAML Pipeline ======
The PXAML pipeline transforms declarative UI markup into executable user interfaces.
===== Overview =====
PXAML (Markup) → Parser → IR (JSON) → Renderer → GUI/TUI/Web
===== Pipeline Phases =====
==== Phase 1: Parsing ====
The PXAML parser reads XML markup and produces an Abstract Syntax Tree (AST).
**Parser tasks:**
* XML validation
* Namespace resolution
* Element recognition
* Attribute parsing
* Event binding detection
==== Phase 2: IR Generation ====
The AST is transformed into an Intermediate Representation (IR) - a JSON-based intermediate format.
{
"type": "Window",
"properties": {
"Title": { "value": "Demo", "type": "string" },
"Width": { "value": 400, "type": "number" }
},
"children": [
{
"type": "Button",
"properties": {
"Content": { "value": "Click me", "type": "string" }
},
"events": {
"Click": { "handler": "OnClick" }
}
}
]
}
**IR properties:**
* Platform-independent
* Serializable (JSON)
* Diff-capable for hot reload
* Type information preserved
==== Phase 3: Binding Resolution ====
Data bindings are analyzed and converted into executable structures.
{
"type": "TextBox",
"properties": {
"Text": {
"type": "binding",
"path": "UserName",
"mode": "TwoWay"
}
}
}
==== Phase 4: Rendering ====
The IR is translated by the target-specific renderer into native UI elements.
^ Renderer ^ Output ^ Technology ^
| GUI | Native Controls | LCL/WinAPI |
| TUI | Terminal characters | ANSI/VT100 |
| Web | DOM Elements | HTML/CSS |
===== Components =====
==== TWvdSPxamlParser ====
type
TWvdSPxamlParser = class
public
function Parse(const ASource: string): TWvdSIRNode;
function ParseFile(const APath: string): TWvdSIRNode;
end;
==== TWvdSIRNode ====
type
TWvdSIRNode = class
NodeType: string;
Properties: TWvdSPropertyMap;
Children: TWvdSIRNodeList;
Events: TWvdSEventMap;
Bindings: TWvdSBindingList;
end;
==== TWvdSRenderer (Abstract) ====
type
TWvdSRenderer = class abstract
public
procedure Render(ARoot: TWvdSIRNode); virtual; abstract;
procedure Update(AOldRoot, ANewRoot: TWvdSIRNode); virtual; abstract;
end;
===== Hot Reload =====
The pipeline supports hot reload through IR differentiation:
1. New PXAML → Parser → New IR
2. Diff(Old IR, New IR) → Patch List
3. Renderer.ApplyPatches(Patch List)
**Benefits:**
* Only changed elements are updated
* State is preserved
* Fast iteration during development
===== Error Handling =====
^ Error Type ^ Phase ^ Handling ^
| XML syntax error | Parsing | Position + message |
| Unknown element | Parsing | Warning + fallback |
| Invalid property type | IR | Type coercion + warning |
| Binding error | Binding | Fallback value |
===== See Also =====
* [[.:architektur|Architecture Overview]]
* [[.:targets|Build Targets]]
* [[..:p:designer|UI Designer]]