Make the default for function serdes be to serde the up/downcall
This commit is contained in:
parent
ee34eb6be0
commit
0cc650103c
2 changed files with 8 additions and 8 deletions
|
|
@ -912,24 +912,24 @@
|
|||
(global-scope))))
|
||||
|
||||
(defmethod serialize* ::fn
|
||||
[f [_fn arg-types ret-type & {:keys [wrap-serde?]}] scope]
|
||||
[f [_fn arg-types ret-type & {:keys [raw-fn?]}] scope]
|
||||
(.upcallStub
|
||||
(CLinker/getInstance)
|
||||
(cond-> f
|
||||
wrap-serde? (upcall-serde-wrapper arg-types ret-type)
|
||||
(not raw-fn?) (upcall-serde-wrapper arg-types ret-type)
|
||||
:always (upcall-handle arg-types ret-type))
|
||||
(function-descriptor arg-types ret-type)
|
||||
scope))
|
||||
|
||||
(defmethod deserialize* ::fn
|
||||
[addr [_fn arg-types ret-type & {:keys [wrap-serde?]}]]
|
||||
[addr [_fn arg-types ret-type & {:keys [raw-fn?]}]]
|
||||
(-> addr
|
||||
(downcall-handle
|
||||
(method-type arg-types ret-type)
|
||||
(function-descriptor arg-types ret-type))
|
||||
(downcall-fn arg-types ret-type)
|
||||
(cond->
|
||||
wrap-serde? (make-serde-wrapper arg-types ret-type))))
|
||||
(not raw-fn?) (make-serde-wrapper arg-types ret-type))))
|
||||
|
||||
;;; Static memory access
|
||||
|
||||
|
|
@ -1002,7 +1002,7 @@
|
|||
(make-downcall (:symbol spec)
|
||||
(:function/args spec)
|
||||
(:function/ret spec))
|
||||
(:function/wrap-serde? spec)
|
||||
(not (:function/raw-fn? spec))
|
||||
(make-serde-wrapper
|
||||
(:function/args spec)
|
||||
(:function/ret spec))))
|
||||
|
|
@ -1013,7 +1013,7 @@
|
|||
(make-varargs-factory (:symbol spec)
|
||||
(:function/args spec)
|
||||
(:function/ret spec))
|
||||
(:function/wrap-serde? spec)
|
||||
(not (:function/raw-fn? spec))
|
||||
(make-serde-varargs-wrapper
|
||||
(:function/args spec)
|
||||
(:function/ret spec))))
|
||||
|
|
|
|||
|
|
@ -21,10 +21,10 @@
|
|||
|
||||
(t/deftest can-call-deserialized-fn-pointers
|
||||
(t/is (= "Alternate string"
|
||||
(((sut/cfn "get_downcall" [::sut/int] [::sut/fn [] ::sut/c-string :wrap-serde? true])
|
||||
(((sut/cfn "get_downcall" [::sut/int] [::sut/fn [] ::sut/c-string])
|
||||
1)))))
|
||||
|
||||
(t/deftest can-make-upcall
|
||||
(t/is (= ((sut/cfn "upcall_test" [[::sut/fn [] ::sut/c-string :wrap-serde? true]] ::sut/c-string)
|
||||
(t/is (= ((sut/cfn "upcall_test" [[::sut/fn [] ::sut/c-string]] ::sut/c-string)
|
||||
(fn [] "hello"))
|
||||
"hello")))
|
||||
|
|
|
|||
Loading…
Reference in a new issue