mirror of
https://github.com/xodio/xod.git
synced 2026-03-06 16:56:52 +01:00
fix(xod-arduino, xod-project): ensure that buses in specializations are converted to links
Closes #1892
This commit is contained in:
@@ -594,8 +594,8 @@ const transformProjectWithImpls = def(
|
||||
R.map(XP.extractBoundInputsToConstNodes(path)),
|
||||
R.chain(XP.flatten(R.__, path)),
|
||||
R.map(XP.expandVariadicNodes(path)),
|
||||
R.chain(XP.autoresolveTypes(path)),
|
||||
R.map(XP.jumperizePatchRecursively(path)),
|
||||
R.chain(XP.autoresolveTypes(path)),
|
||||
R.unless(
|
||||
() => liveness !== LIVENESS.NONE,
|
||||
R.map(XP.removeDebugNodes(path))
|
||||
|
||||
@@ -12,7 +12,7 @@ let getMatchingBusNodes = patch => {
|
||||
let nodes = Patch.listNodes(patch);
|
||||
let toBusNodesByLabel =
|
||||
nodes
|
||||
|. List.keep(n => Node.getType(n) == toBusPatchPath)
|
||||
|. List.keep(n => Node.getType(n) |> PatchPath.isToBus)
|
||||
|. BeltHoles.List.groupByString(Node.getLabel)
|
||||
/* having multiple `to-bus` nodes with the same label is forbidden,
|
||||
so exclude them from type resolution */
|
||||
@@ -22,7 +22,7 @@ let getMatchingBusNodes = patch => {
|
||||
[]; /* short-curcuit for optimization */
|
||||
} else {
|
||||
nodes
|
||||
|. List.keep(n => Node.getType(n) == fromBusPatchPath)
|
||||
|. List.keep(n => Node.getType(n) |> PatchPath.isFromBus)
|
||||
|. BeltHoles.List.groupByString(Node.getLabel)
|
||||
|. Map.String.keep((label, _) =>
|
||||
Map.String.has(toBusNodesByLabel, label)
|
||||
@@ -120,14 +120,14 @@ let splitLinksToBuses:
|
||||
|> Link.getInputNodeId
|
||||
|> Patch.getNodeById(patch)
|
||||
|. Option.mapWithDefault(false, n =>
|
||||
Node.getType(n) == toBusPatchPath
|
||||
Node.getType(n) |> PatchPath.isToBus
|
||||
);
|
||||
let isOutputConnectedToBusNode =
|
||||
link
|
||||
|> Link.getOutputNodeId
|
||||
|> Patch.getNodeById(patch)
|
||||
|. Option.mapWithDefault(false, n =>
|
||||
Node.getType(n) == fromBusPatchPath
|
||||
Node.getType(n) |> PatchPath.isFromBus
|
||||
);
|
||||
! isOutputConnectedToBusNode && ! isInputConnectedToBusNode;
|
||||
});
|
||||
@@ -146,7 +146,7 @@ let splitLinksToBuses:
|
||||
|> Link.getInputNodeId
|
||||
|> Patch.getNodeById(patch)
|
||||
|. Option.flatMap(node =>
|
||||
Node.getType(node) == toBusPatchPath ?
|
||||
Node.getType(node) |> PatchPath.isToBus ?
|
||||
Some(node) : None
|
||||
)
|
||||
|. Option.map(node => (link, node))
|
||||
|
||||
@@ -124,10 +124,10 @@ export const isWatchPatchPath = R.test(/^xod\/(core|debug)\/watch$/);
|
||||
export const isJumperPatchPath = R.equals(CONST.JUMPER_PATCH_PATH);
|
||||
|
||||
// :: String -> Boolean
|
||||
export const isFromBusPatchPath = R.equals(CONST.FROM_BUS_PATH);
|
||||
export const isFromBusPatchPath = R.startsWith(CONST.FROM_BUS_PATH);
|
||||
|
||||
// :: String -> Boolean
|
||||
export const isToBusPatchPath = R.equals(CONST.TO_BUS_PATH);
|
||||
export const isToBusPatchPath = R.startsWith(CONST.TO_BUS_PATH);
|
||||
|
||||
// :: String -> Boolean
|
||||
export const isBusPatchPath = R.either(isFromBusPatchPath, isToBusPatchPath);
|
||||
|
||||
112
workspace/test/test-core/foo(number)/patch.xodp
Normal file
112
workspace/test/test-core/foo(number)/patch.xodp
Normal file
@@ -0,0 +1,112 @@
|
||||
{
|
||||
"comments": [
|
||||
{
|
||||
"content": "for `test-buses-in-specializations`",
|
||||
"id": "H1l3ONIgoH",
|
||||
"position": {
|
||||
"units": "slots",
|
||||
"x": 4,
|
||||
"y": 1
|
||||
},
|
||||
"size": {
|
||||
"height": 1,
|
||||
"units": "slots",
|
||||
"width": 6
|
||||
}
|
||||
}
|
||||
],
|
||||
"links": [
|
||||
{
|
||||
"id": "B1NU_VLlor",
|
||||
"input": {
|
||||
"nodeId": "BJZUd4LxiH",
|
||||
"pinKey": "BJnQUR_BwyZ"
|
||||
},
|
||||
"output": {
|
||||
"nodeId": "ByLdE8giS",
|
||||
"pinKey": "__out__"
|
||||
}
|
||||
},
|
||||
{
|
||||
"id": "H1H8dVIgjH",
|
||||
"input": {
|
||||
"nodeId": "SkMUuEUxjS",
|
||||
"pinKey": "__in__"
|
||||
},
|
||||
"output": {
|
||||
"nodeId": "HklLuELlsB",
|
||||
"pinKey": "__out__"
|
||||
}
|
||||
},
|
||||
{
|
||||
"id": "HJILO4IgiH",
|
||||
"input": {
|
||||
"nodeId": "SyXU_NLejH",
|
||||
"pinKey": "__in__"
|
||||
},
|
||||
"output": {
|
||||
"nodeId": "BJZUd4LxiH",
|
||||
"pinKey": "SyomIRurDJ-"
|
||||
}
|
||||
}
|
||||
],
|
||||
"nodes": [
|
||||
{
|
||||
"boundLiterals": {
|
||||
"HkqmLAOrD1W": "10"
|
||||
},
|
||||
"id": "BJZUd4LxiH",
|
||||
"position": {
|
||||
"units": "slots",
|
||||
"x": 0,
|
||||
"y": 1
|
||||
},
|
||||
"type": "xod/core/add"
|
||||
},
|
||||
{
|
||||
"id": "By2_EUgir",
|
||||
"position": {
|
||||
"units": "slots",
|
||||
"x": 3,
|
||||
"y": 1
|
||||
},
|
||||
"type": "xod/patch-nodes/utility"
|
||||
},
|
||||
{
|
||||
"id": "ByLdE8giS",
|
||||
"position": {
|
||||
"units": "slots",
|
||||
"x": 0,
|
||||
"y": 0
|
||||
},
|
||||
"type": "xod/patch-nodes/input-number"
|
||||
},
|
||||
{
|
||||
"id": "HklLuELlsB",
|
||||
"position": {
|
||||
"units": "slots",
|
||||
"x": 0,
|
||||
"y": 3
|
||||
},
|
||||
"type": "xod/patch-nodes/from-bus"
|
||||
},
|
||||
{
|
||||
"id": "SkMUuEUxjS",
|
||||
"position": {
|
||||
"units": "slots",
|
||||
"x": 0,
|
||||
"y": 4
|
||||
},
|
||||
"type": "xod/patch-nodes/output-number"
|
||||
},
|
||||
{
|
||||
"id": "SyXU_NLejH",
|
||||
"position": {
|
||||
"units": "slots",
|
||||
"x": 0,
|
||||
"y": 2
|
||||
},
|
||||
"type": "xod/patch-nodes/to-bus"
|
||||
}
|
||||
]
|
||||
}
|
||||
56
workspace/test/test-core/foo/patch.xodp
Normal file
56
workspace/test/test-core/foo/patch.xodp
Normal file
@@ -0,0 +1,56 @@
|
||||
{
|
||||
"comments": [
|
||||
{
|
||||
"content": "for `test-buses-in-specializations`",
|
||||
"id": "SyPBNIgsH",
|
||||
"position": {
|
||||
"units": "slots",
|
||||
"x": 3,
|
||||
"y": 1
|
||||
},
|
||||
"size": {
|
||||
"height": 1,
|
||||
"units": "slots",
|
||||
"width": 6
|
||||
}
|
||||
}
|
||||
],
|
||||
"nodes": [
|
||||
{
|
||||
"id": "Bk-aVVUxor",
|
||||
"position": {
|
||||
"units": "slots",
|
||||
"x": 0,
|
||||
"y": 2
|
||||
},
|
||||
"type": "xod/patch-nodes/output-t1"
|
||||
},
|
||||
{
|
||||
"id": "HJe6NEIejB",
|
||||
"position": {
|
||||
"units": "slots",
|
||||
"x": 0,
|
||||
"y": 1
|
||||
},
|
||||
"type": "xod/patch-nodes/abstract"
|
||||
},
|
||||
{
|
||||
"id": "r1MBNLxjB",
|
||||
"position": {
|
||||
"units": "slots",
|
||||
"x": 2,
|
||||
"y": 1
|
||||
},
|
||||
"type": "xod/patch-nodes/utility"
|
||||
},
|
||||
{
|
||||
"id": "rypE48lsS",
|
||||
"position": {
|
||||
"units": "slots",
|
||||
"x": 0,
|
||||
"y": 0
|
||||
},
|
||||
"type": "xod/patch-nodes/input-t1"
|
||||
}
|
||||
]
|
||||
}
|
||||
@@ -0,0 +1,3 @@
|
||||
IN OUT
|
||||
10 20
|
||||
100 110
|
||||
|
@@ -0,0 +1,64 @@
|
||||
{
|
||||
"links": [
|
||||
{
|
||||
"id": "SkcFV8lsH",
|
||||
"input": {
|
||||
"nodeId": "HyeIKEUeiS",
|
||||
"pinKey": "__in__"
|
||||
},
|
||||
"output": {
|
||||
"nodeId": "SkWItNIxoH",
|
||||
"pinKey": "Bk-aVVUxor"
|
||||
}
|
||||
},
|
||||
{
|
||||
"id": "rJsFEIljB",
|
||||
"input": {
|
||||
"nodeId": "SkWItNIxoH",
|
||||
"pinKey": "rypE48lsS"
|
||||
},
|
||||
"output": {
|
||||
"nodeId": "rJMLY4Leor",
|
||||
"pinKey": "__out__"
|
||||
}
|
||||
}
|
||||
],
|
||||
"nodes": [
|
||||
{
|
||||
"id": "HyIKE8eoH",
|
||||
"position": {
|
||||
"units": "slots",
|
||||
"x": 2,
|
||||
"y": 1
|
||||
},
|
||||
"type": "xod/patch-nodes/tabtest"
|
||||
},
|
||||
{
|
||||
"id": "HyeIKEUeiS",
|
||||
"position": {
|
||||
"units": "slots",
|
||||
"x": 0,
|
||||
"y": 2
|
||||
},
|
||||
"type": "xod/patch-nodes/output-number"
|
||||
},
|
||||
{
|
||||
"id": "SkWItNIxoH",
|
||||
"position": {
|
||||
"units": "slots",
|
||||
"x": 0,
|
||||
"y": 1
|
||||
},
|
||||
"type": "@/foo"
|
||||
},
|
||||
{
|
||||
"id": "rJMLY4Leor",
|
||||
"position": {
|
||||
"units": "slots",
|
||||
"x": 0,
|
||||
"y": 0
|
||||
},
|
||||
"type": "xod/patch-nodes/input-number"
|
||||
}
|
||||
]
|
||||
}
|
||||
Reference in New Issue
Block a user