From 4160b1cb6861225c6b7e0d7ec0f45837a793d9ce Mon Sep 17 00:00:00 2001 From: Kristin Rutenkolk Date: Tue, 23 Jul 2024 15:39:58 +0200 Subject: [PATCH] consistently serialize strings to MemorySegment instead of addresses (Longs) and remove ad-hoc upcall-class Long to MemorySegment conversion --- src/clj/coffi/ffi.clj | 4 ---- src/clj/coffi/mem.clj | 2 +- 2 files changed, 1 insertion(+), 5 deletions(-) diff --git a/src/clj/coffi/ffi.clj b/src/clj/coffi/ffi.clj index 3d35d01..365fa10 100644 --- a/src/clj/coffi/ffi.clj +++ b/src/clj/coffi/ffi.clj @@ -499,10 +499,6 @@ inc))) acc)) [:invokeinterface IFn "invoke" (repeat (inc (count arg-types)) Object)] - (if (identical? ::mem/pointer (mem/primitive-type ret-type)) - [[:checkcast Long] - [:invokevirtual Long "longValue" [:long]] - [:invokestatic MemorySegment "ofAddress" [:long MemorySegment] true]]) (to-prim-asm ret-type) [(return-for-type ret-type :areturn)]]}]}) diff --git a/src/clj/coffi/mem.clj b/src/clj/coffi/mem.clj index 972b12d..23139c1 100644 --- a/src/clj/coffi/mem.clj +++ b/src/clj/coffi/mem.clj @@ -1247,7 +1247,7 @@ (defmethod serialize* ::c-string [obj _type ^Arena session] (if obj - (address-of (.allocateFrom session ^String obj)) + (.allocateFrom session ^String obj) (MemorySegment/NULL))) (defmethod deserialize* ::c-string