diff --git a/CHANGELOG.md b/CHANGELOG.md index 02c4bdb..d111ad0 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,6 +1,10 @@ # Change Log All notable changes to this project will be documented in this file. This change log follows the conventions of [keepachangelog.com](http://keepachangelog.com/). +## [Unreleased] +### Fixed +- Incorrect inline expansion of `make-serde-wrapper` in cases where a function has no arguments + ## [0.1.241] - 2021-10-14 ### Performance - Added an `:inline` function to `make-serde-wrapper` to remove serialization overhead on primitives @@ -55,6 +59,7 @@ All notable changes to this project will be documented in this file. This change - Support for serializing and deserializing arbitrary Clojure functions - Support for serializing and deserializing arbitrary Clojure data structures +[Unreleased]: https://github.com/IGJoshua/coffi/compare/v0.1.241...HEAD [0.1.241]: https://github.com/IGJoshua/coffi/compare/v0.1.220...v0.1.241 [0.1.220]: https://github.com/IGJoshua/coffi/compare/v0.1.205...v0.1.220 [0.1.205]: https://github.com/IGJoshua/coffi/compare/v0.1.192...v0.1.205 diff --git a/src/clj/coffi/ffi.clj b/src/clj/coffi/ffi.clj index ebb8094..f052c7b 100644 --- a/src/clj/coffi/ffi.clj +++ b/src/clj/coffi/ffi.clj @@ -305,10 +305,12 @@ nil)) (list sym `(mem/serialize ~sym ~type ~scope)))) arg-syms arg-types) + wrap-scope (fn [expr] + `(with-open [~scope (mem/stack-scope)] + ~expr)) wrap-serialize (fn [expr] - `(with-open [~scope (mem/stack-scope)] - (let [~@(mapcat identity serialize-args)] - ~expr))) + `(let [~@(mapcat identity serialize-args)] + ~expr)) native-fn (fn [expr] `(fn ~'native-fn [~@arg-syms] ~expr)) @@ -321,6 +323,7 @@ primitive-ret? (-> (cons downcall-sym arg-syms) wrap-serialize + wrap-scope native-fn) :else @@ -336,12 +339,12 @@ const-ret?) (native-fn (if (mem/primitive-type ret-type) prim-call - non-prim-call)) + (wrap-scope non-prim-call))) none-to-serialize? - (if (mem/primitive-type ~ret) - ~(native-fn prim-call) - ~(native-fn non-prim-call)) + `(if (mem/primitive-type ~ret) + ~(native-fn prim-call) + ~(native-fn (wrap-scope non-prim-call))) const-ret? (native-fn (wrap-serialize