Skip to content

Commit d9996ce

Browse files
🧩 Refactor(Contract): 新增 BranchArm 与 VariadicPinSpec,扩展 NodeDescriptor
- 新增 BranchArm:通用控制流臂模型(PinName/TargetBlockName/IsLoopback), 位于 Contract 层供 Workflow 与 Contract 共享 - 新增 VariadicPinSpec record:声明节点的变长端口增长规则 (BasePinName/StartIndex/PinType),供编辑器泛化"连一个长一个"机制 - NodeDescriptor 新增可选 InputVariadic/OutputVariadic 字段(默认 null=固定)
1 parent 7d256fc commit d9996ce

3 files changed

Lines changed: 56 additions & 2 deletions

File tree

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
namespace KitX.Core.Contract.Workflow;
2+
3+
/// <summary>
4+
/// A single outgoing arm of a control-flow statement (Branch / Loop / ToLoopCond / Switch).
5+
/// Replaces the former fixed <c>TrueBlockName</c>/<c>FalseBlockName</c>/<c>ToLoopCondReturnTo</c>
6+
/// triple, generalising the model to any number of arms so that an N-way <c>Switch</c>
7+
/// (and future control-flow builtins) can be expressed without positional hacks.
8+
/// </summary>
9+
public class BranchArm
10+
{
11+
/// <summary>
12+
/// The output pin name this arm corresponds to on the Blueprint node
13+
/// (e.g. <c>"True"</c>, <c>"False"</c>, <c>"LoopBody"</c>, <c>"LoopEnd"</c>,
14+
/// <c>"Exec"</c>, <c>"Default"</c>, or <c>"0"</c>..<c>"N-1"</c> for Switch).
15+
/// </summary>
16+
public string PinName { get; set; } = string.Empty;
17+
18+
/// <summary>
19+
/// The target block name this arm transfers control to.
20+
/// </summary>
21+
public string TargetBlockName { get; set; } = string.Empty;
22+
23+
/// <summary>
24+
/// Whether this arm is a loopback edge (used by <c>ToLoopCond</c>, which returns
25+
/// to the parent loop's condition block). Drives <c>CFGEdgeType.LoopbackToCondition</c>.
26+
/// </summary>
27+
public bool IsLoopback { get; set; }
28+
}

KitX Core Contracts/KitX.Core.Contract/Workflow/Nodes/NodeDescriptor.cs

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,10 +6,14 @@ namespace KitX.Core.Contract.Workflow;
66
/// Describes a node type's layout and pin configuration.
77
/// Each node subclass provides its own descriptor via GetDescriptor().
88
/// </summary>
9+
/// <param name="InputVariadic">Optional variadic-growth spec for input pins. Null = fixed.</param>
10+
/// <param name="OutputVariadic">Optional variadic-growth spec for output pins. Null = fixed.</param>
911
public record NodeDescriptor(
1012
double Width,
1113
double Height,
1214
IReadOnlyList<PinDescriptor> InputPins,
1315
IReadOnlyList<PinDescriptor> OutputPins,
14-
string DisplayName
15-
);
16+
string DisplayName,
17+
VariadicPinSpec? InputVariadic = null,
18+
VariadicPinSpec? OutputVariadic = null
19+
);
Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
namespace KitX.Core.Contract.Workflow;
2+
3+
/// <summary>
4+
/// Declares a variadic (auto-growing) pin group on a node descriptor.
5+
/// <para>
6+
/// When a node declares <c>InputVariadic</c> or <c>OutputVariadic</c>, the Blueprint editor
7+
/// appends a fresh pin of <see cref="PinType"/> whenever the <em>last</em> pin of that group
8+
/// gets connected — so the user can chain more inputs/outputs without manually adding pins.
9+
/// </para>
10+
/// <para>
11+
/// <see cref="BasePinName"/> is the title prefix for new pins; <see cref="StartIndex"/> is the
12+
/// starting number appended to it. The editor derives each new pin's name from the node's
13+
/// current pin count (not by mutating this record), so every node instance counts independently
14+
/// and survives save/load round-trips.
15+
/// </para>
16+
/// <para>Examples:</para>
17+
/// <list type="bullet">
18+
/// <item>StringConcat input: <c>new("Input ", 3, PinType.String)</c> → "Input 3", "Input 4", ...</item>
19+
/// <item>Switch output: <c>new("", 1, PinType.Execution)</c> → "1", "2", ...</item>
20+
/// </list>
21+
/// </summary>
22+
public record VariadicPinSpec(string BasePinName, int StartIndex, PinType PinType);

0 commit comments

Comments
 (0)