diff --git a/CHANGELOG.md b/CHANGELOG.md index ccc7bac..53a927d 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -3,6 +3,12 @@ All notable changes to this project will be documented in this file. This change ## [Unreleased] +## [0.1.184] - 2021-09-30 +### Fixed +- Deserializing nullpointers as functions threw an exception +- Upcall stubs with non-primitive arguments failed to compile +- Upcall stubs had incorrect types + ## [0.1.176] - 2021-09-29 ### Fixed - Usage of `defcfn` without a docstring produced an invalid `def` form @@ -17,6 +23,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.176...HEAD +[Unreleased]: https://github.com/IGJoshua/coffi/compare/v0.1.184...HEAD +[0.1.184]: https://github.com/IGJoshua/coffi/compare/v0.1.176...v0.1.184 [0.1.176]: https://github.com/IGJoshua/coffi/compare/v0.1.169...v0.1.176 [0.1.169]: https://github.com/IGJoshua/coffi/compare/16f56bc31d69142ec4d2fb61b15b069d78b127ca...v0.1.169 diff --git a/README.md b/README.md index a900d1b..5bcbb00 100644 --- a/README.md +++ b/README.md @@ -17,8 +17,8 @@ This library is available on Clojars. Add one of the following entries to the `:deps` key of your `deps.edn`: ```clojure -org.suskalo/coffi {:mvn/version "0.1.176"} -io.github.IGJoshua/coffi {:git/tag "v0.1.176" :git/sha "2a90bdb"} +org.suskalo/coffi {:mvn/version "0.1.184"} +io.github.IGJoshua/coffi {:git/tag "v0.1.184" :git/sha "ea53cfb"} ``` If you use this library as a git dependency, you will need to prepare the diff --git a/src/clj/coffi/ffi.clj b/src/clj/coffi/ffi.clj index 4c966e6..c6558a0 100644 --- a/src/clj/coffi/ffi.clj +++ b/src/clj/coffi/ffi.clj @@ -314,13 +314,13 @@ [:return]]} {:name :upcall :flags #{:public} - :desc (conj (mapv mem/java-layout arg-types) - (mem/java-layout ret-type)) + :desc (conj (mapv insn-layout arg-types) + (insn-layout ret-type)) :emit [[:aload 0] [:getfield :this "upcall_ifn" IFn] (map-indexed (fn [idx arg] - [[(load-instructions arg) (inc idx)] + [[(load-instructions arg :aload) (inc idx)] (to-object-asm arg)]) arg-types) [:invokeinterface IFn "invoke" (repeat (inc (count arg-types)) Object)] @@ -367,13 +367,14 @@ (defmethod mem/deserialize* ::fn [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-> - (not raw-fn?) (make-serde-wrapper arg-types ret-type)))) + (when-not (mem/null? addr) + (-> addr + (downcall-handle + (method-type arg-types ret-type) + (function-descriptor arg-types ret-type)) + (downcall-fn arg-types ret-type) + (cond-> + (not raw-fn?) (make-serde-wrapper arg-types ret-type))))) ;;; Static memory access