From 673a6532003672d63c5b27edbfca3efd959aa813 Mon Sep 17 00:00:00 2001 From: Joshua Suskalo Date: Fri, 1 Oct 2021 10:39:32 -0500 Subject: [PATCH] Fix bug with primitive-serializing arguments to downcalls not compiling --- CHANGELOG.md | 1 + src/clj/coffi/ffi.clj | 7 ++++--- 2 files changed, 5 insertions(+), 3 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 07295f6..717ee20 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -3,6 +3,7 @@ All notable changes to this project will be documented in this file. This change ## [Unreleased] ### Fixed +- Primitive-serializing types fail to compile as arguments to downcall handles - Primitive-serializing types fail to load as arguments to upcall functions - Void return types on upcalls crash the JVM - Invalid implementation of serialize-into for primitive types diff --git a/src/clj/coffi/ffi.clj b/src/clj/coffi/ffi.clj index 66f5772..75c6b6a 100644 --- a/src/clj/coffi/ffi.clj +++ b/src/clj/coffi/ffi.clj @@ -108,9 +108,10 @@ (defn- insn-layout "Gets the type keyword or class for referring to the type in bytecode." [type] - (if (some-> (mem/primitive-type type) (not= ::mem/pointer)) - (keyword (name type)) - (mem/java-layout type))) + (when-some [prim (mem/primitive-type type)] + (if (not= prim ::mem/pointer) + (keyword (name prim)) + (mem/java-layout type)))) (def ^:private unbox-fn-for-type "Map from type name to the name of its unboxing function."