catch bad NAT command implementations at runtime
This commit is contained in:
@@ -142,8 +142,14 @@
|
||||
[]
|
||||
&mut lastCollector
|
||||
(lambda []
|
||||
(set lastChangeSet (the ChangeSet (Reflect.callMethod null command.handler collectedArgs)))
|
||||
(when lastChangeSet (ui.handleChanges archive lastChangeSet)))]
|
||||
(let [result (Reflect.callMethod null command.handler collectedArgs)]
|
||||
(assert !(Prelude.isNull result) "Command implementation forgot to return a ChangeSet")
|
||||
(set lastChangeSet (the ChangeSet result))
|
||||
|
||||
(when lastChangeSet
|
||||
(doFor e lastChangeSet
|
||||
(assert (and e (isEntry e)) "Lib function forgot to return the Entry that was modified"))
|
||||
(ui.handleChanges archive lastChangeSet))))]
|
||||
// To facilitate asynchronous arg input via UI, we need to construct an insanely complicated nested callback to give the UI
|
||||
(doFor arg (reverse command.args)
|
||||
(set lastCollector (_composeArgCollector collectedArgs arg stream lastCollector)))
|
||||
|
@@ -136,9 +136,16 @@
|
||||
(if (hasComponent e Connections)
|
||||
(withWritableComponents archive e [conn Connections]
|
||||
(doFor e2 entriesToConnect (dictSet conn e2.id 1)))
|
||||
(addComponent archive e Connections (for e2 entriesToConnect =>e2.id 1))))
|
||||
(addComponent archive e Connections (for e2 entriesToConnect =>e2.id 1)))
|
||||
)
|
||||
|
||||
(function removeConnections [:nat.Archive archive :nat.Entry e :Array<Entry> entriesToRemove]
|
||||
(when (hasComponent e Connections)
|
||||
(withWritableComponents archive e [conn Connections]
|
||||
(doFor e2 entriesToRemove (conn.remove e2.id)))))
|
||||
(doFor e2 entriesToRemove (conn.remove e2.id))))
|
||||
e)
|
||||
|
||||
(function isEntry [o]
|
||||
(let [fields (Reflect.fields o)]
|
||||
(and (= fields.length 3)
|
||||
(apply and (for f ["id" "components" "files"] (contains fields f))))))
|
Reference in New Issue
Block a user