From 6801c7735e9d643e85ad38542cae1f3ec4fb448b Mon Sep 17 00:00:00 2001 From: Joshua Suskalo Date: Thu, 16 Sep 2021 14:10:28 -0500 Subject: [PATCH] Implement the macro in terms of `invokeWithArguments` --- src/coffi/ffi.clj | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) diff --git a/src/coffi/ffi.clj b/src/coffi/ffi.clj index d1500bd..026c2cb 100644 --- a/src/coffi/ffi.clj +++ b/src/coffi/ffi.clj @@ -467,10 +467,16 @@ (find-symbol ~(name (:symbol args))) (method-type args-types# ret-type#) (function-descriptor args-types# ret-type#)) - ~(:name args) (fn [& args#] + ~(:name args) (fn [~@arg-syms] (with-open [~scope (stack-scope)] - (let [[~@arg-syms] (map #(serialize ))] - (.invoke downcall# ~@arg-syms)))) + (let [args# (map #(serialize %1 %2 ~scope) + [~@arg-syms] + args-types#)] + ;; TODO(Joshua): Rewrite this to use jgpc42/insn + ;; to generate bytecode for a proper invoke for + ;; an instant performance boost + (deserialize (.invokeWithArguments downcall# (object-array args#)) + ret-type#)))) fun# ~(if (:fn-tail args) `(fn ~(-> args :fn-tail :arglist) ~@(-> args :fn-tail :body))