readComponentOr

This commit is contained in:
2022-07-05 00:14:37 +00:00
parent 1dfa12fb21
commit 697354293d

View File

@@ -23,6 +23,13 @@
// TODO add to the documentation a hint that macros should use fully qualified type paths so macro caller classes don't need to import everything
(tink.Json.parse componentData))))
// Return either the desired component, or def if no such component exists
(defMacro readComponentOr [e componentType def]
(withEvalOnce [e]
(if (hasComponent e ,componentType)
(readComponent e ,componentType)
,def)))
// TODO check not overwriting a component
(defMacro addComponent [archive e componentType c]
`(withWritableEntry ,archive ,e