Fix incorrect serdes around upcalls

This commit is contained in:
Joshua Suskalo 2021-09-23 12:26:57 -05:00
parent 284b76255a
commit 3f6203b5d3

View file

@ -907,12 +907,22 @@
[_type]
::pointer)
(defn- upcall-serde-wrapper
"Creates a function that wraps `f` which deserializes the arguments and
serializes the return type in the [[global-scope]]."
[f arg-types ret-type]
(fn [& args]
(serialize
(apply f (map deserialize args arg-types))
ret-type
(global-scope))))
(defmethod serialize* ::fn
[f [_fn arg-types ret-type & {:keys [wrap-serde?]}] scope]
(.upcallStub
(CLinker/getInstance)
(cond-> f
wrap-serde? (make-serde-wrapper arg-types ret-type)
wrap-serde? (upcall-serde-wrapper arg-types ret-type)
:always (upcall-handle arg-types ret-type))
(function-descriptor arg-types ret-type)
scope))