Skip to content

Instantly share code, notes, and snippets.

@ikrima
Created Jul 23, 2020
Embed
What would you like to do?
meander nested capture
(m/rewrite
a_opmirDefOpgraph
{:opnname (m/some ?opnname)
:name (m/some (m/app name ?prmname))
:ctype (m/some {:ctuid {:ctypeName ?prmtypename}})}
[:litStructBlk
"GrphPortDatabind_t"
[[:litFld "prtId" (m/app str* ["GraphDataGetId(\"" ?opnname "." ?prmname "\")"])]
[:litFld "prtName" (m/app str* ["\"" ?prmname "\""])]
[:litFld "prtType" "EGraphPinType::CompParm"]]]
;; Node
{:nodename (m/some ?opnname)
:prmins (m/some [!prmin ...])
:prmouts (m/some [!prmout ...])}
[[:litStructBlk
"GrphNodeDatabind_t"
[[:litFld "nodeId" (m/app str* ["GraphDataGetId(\"" ?opnname "\")"])]
[:litFld "nodeName" (m/app str* ["\"" ?opnname "\""])]
[:litFld "nodeVizTID" "EOpnodeVizTID::OpNode"]
[:litFld "inPorts"
[:litBlk
[(m/cata (m/app (fn [prmblk] (assoc prmblk :opnname ?opnname)) !prmin)) ...]
...]]
[:litFld "outPorts"
[:litBlk
[(m/cata (m/app (fn [prmblk] (assoc prmblk :opnname ?opnname)) !prmout)) ...]
...]]]]]
;; Link
{:src (m/some ?lnkSrc)
:dst (m/some ?lnkDst)}
[:litStructBlk
"GrphLinkDatabind_t"
[[:litFld "linkId" (m/app str* ["GraphDataGetId(\"" ?lnkSrc "->" ?lnkDst "\")"])]
[:litFld "srcPrtId" (m/app str* ["GraphDataGetId(\"" ?lnkSrc "\")"])]
[:litFld "dstPrtId" (m/app str* ["GraphDataGetId(\"" ?lnkDst "\")"])]
[:litFld "linkType" "EGraphEdgeType::Data"]]]
;; NodeGraphDbc
{:nodeBindings (m/some [!nodeBind ...])
:linkBindings (m/some [!lnkBind ...])}
[:litStructBlk "NodeGraph_dbc"
[[:litFld "nodeBindings"
[:litBlk
[(m/cata !nodeBind) ...]]]
[:litFld "linkBindings"
[:litBlk [(m/cata !lnkBind) ...]]]]]
{:opnodes (m/some [{:opnodename !opnodename
:opdef {:oprmblkdef {:inputs !prmins
:outputs !prmouts}}}
...])}
(m/cata
{:nodeBindings [{:nodename (m/app name !opnodename)
:prmins !prmins
:prmouts !prmouts} ...]
:linkBindings [{:src "mynodeA.argout0"
:dst "mynodeB.argin0"}]}))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment