Inhaltsverzeichnis
PXAML-Pipeline
PXAML-Pipeline transformira deklarativni UI-markup u izvršna korisnička sučelja.
Pregled
PXAML (Markup) → Parser → IR (JSON) → Renderer → GUI/TUI/Web
Faze Pipelinea
Faza 1: Parsing
PXAML-Parser čita XML-markup i generira Abstract Syntax Tree (AST).
<!-- Input: PXAML --> <Window Title="Demo" Width="400"> <Button Content="Klikni me" Click="OnClick"/> </Window>
Zadaci Parsera:
- XML-validacija
- Razlučivanje Namespace-a
- Prepoznavanje elemenata
- Parsiranje atributa
- Prepoznavanje Event-Bindinga
Faza 2: IR-Generiranje
AST se transformira u Intermediate Representation (IR) - JSON-bazirani međuformat.
{
"type": "Window",
"properties": {
"Title": { "value": "Demo", "type": "string" },
"Width": { "value": 400, "type": "number" }
},
"children": [
{
"type": "Button",
"properties": {
"Content": { "value": "Klikni me", "type": "string" }
},
"events": {
"Click": { "handler": "OnClick" }
}
}
]
}
IR-Svojstva:
- Platformno neovisno
- Serijalizirajuće (JSON)
- Diff-sposobno za Hot Reload
- Informacije o tipovima sačuvane
Faza 3: Binding-Razlučivanje
Data-Bindingi se analiziraju i pretvaraju u izvršne strukture.
<!-- PXAML s Bindingom --> <TextBox Text="{Binding Path=UserName, Mode=TwoWay}"/>
{
"type": "TextBox",
"properties": {
"Text": {
"type": "binding",
"path": "UserName",
"mode": "TwoWay"
}
}
}
Faza 4: Rendering
IR se prevodi od strane target-specifičnog Renderera u native UI-elemente.
| Renderer | Izlaz | Tehnologija |
|---|---|---|
| GUI | Native Controls | LCL/WinAPI |
| TUI | Terminal-znakovi | ANSI/VT100 |
| Web | DOM-elementi | HTML/CSS |
Komponente
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 (Apstraktno)
type TWvdSRenderer = class abstract public procedure Render(ARoot: TWvdSIRNode); virtual; abstract; procedure Update(AOldRoot, ANewRoot: TWvdSIRNode); virtual; abstract; end;
Hot Reload
Pipeline podržava Hot Reload putem IR-diferenciranja:
1. Novi PXAML → Parser → Nova IR 2. Diff(Stara IR, Nova IR) → Patch-Lista 3. Renderer.ApplyPatches(Patch-Lista)
Prednosti:
- Samo promijenjeni elementi se ažuriraju
- Stanje ostaje sačuvano
- Brza iteracija tijekom razvoja
Obrada grešaka
| Tip greške | Faza | Obrada |
|---|---|---|
| XML-sintaksna greška | Parsing | Pozicija + Poruka |
| Nepoznati element | Parsing | Upozorenje + Fallback |
| Nevaljani Property-tip | IR | Type Coercion + Upozorenje |
| Binding-greška | Binding | Fallback-vrijednost |
Vidi također
Zuletzt geändert: 29.01.2026. u 22:29