From 5ab2bae1fa325bd8692652fbf3b6d78a6954e342 Mon Sep 17 00:00:00 2001 From: Joshua Suskalo Date: Thu, 30 Sep 2021 15:40:55 -0500 Subject: [PATCH] Add a function's address to the metadata of deserialized functions --- CHANGELOG.md | 2 ++ src/clj/coffi/ffi.clj | 16 +++++++++------- 2 files changed, 11 insertions(+), 7 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 53a927d..8f363c2 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -2,6 +2,8 @@ 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] +### Added +- An `::ffi/address` key to deserialized function pointers' metadata ## [0.1.184] - 2021-09-30 ### Fixed diff --git a/src/clj/coffi/ffi.clj b/src/clj/coffi/ffi.clj index c6558a0..fed0b1b 100644 --- a/src/clj/coffi/ffi.clj +++ b/src/clj/coffi/ffi.clj @@ -368,13 +368,15 @@ (defmethod mem/deserialize* ::fn [addr [_fn arg-types ret-type & {:keys [raw-fn?]}]] (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))))) + (vary-meta + (-> 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))) + assoc ::address addr))) ;;; Static memory access