Add function to get the segment from a static variable

This commit is contained in:
Joshua Suskalo 2022-07-07 13:05:39 -05:00
parent 3794ab7d5f
commit 20956f2549
No known key found for this signature in database
GPG key ID: 9B6BA586EFF1B9F0
2 changed files with 11 additions and 0 deletions

View file

@ -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

View file

@ -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`.