diff --git a/CHANGELOG.md b/CHANGELOG.md index 733d9e4..55813bd 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 +- New function to allow getting the backing memory segment of a `coffi.ffi.StaticVariable`, to replace the `Addressable` implementation lost in the migration to JDK 18 ## [0.5.357] - 2022-07-07 ### Removed diff --git a/src/clj/coffi/ffi.clj b/src/clj/coffi/ffi.clj index 5057346..b68e8b0 100644 --- a/src/clj/coffi/ffi.clj +++ b/src/clj/coffi/ffi.clj @@ -19,6 +19,7 @@ FunctionDescriptor MemoryAddress MemoryLayout + MemorySegment NativeSymbol SegmentAllocator))) @@ -594,6 +595,14 @@ [static-var f & args] (freset! static-var (apply f @static-var args))) +(defn static-variable-segment + "Gets the backing [[MemorySegment]] from `static-var`. + + This is primarily useful when you need to pass the static variable's address + to a native function which takes an [[Addressable]]." + ^MemorySegment [static-var] + (.-seg ^StaticVariable static-var)) + (defn static-variable "Constructs a reference to a mutable value stored in `symbol-or-addr`.