RFR: 7903626: Add struct helper method to reintrepret an array of structs
Maurizio Cimadamore
mcimadamore at openjdk.org
Tue Jan 16 15:30:51 UTC 2024
On Tue, 16 Jan 2024 15:24:04 GMT, Maurizio Cimadamore <mcimadamore at openjdk.org> wrote:
>> This patch renames the existing `ofAddress` method we generate in struct classes to `reinterpret` to reflect the latest naming changes in the FFM API. It also adds another overload that takes an element count, for reinterpreting arrays. Finally, this patch adds the missing cleanup parameter that the underlying reinterpret method accepts.
>
> src/main/java/org/openjdk/jextract/impl/StructBuilder.java line 224:
>
>> 222:
>> 223: public static MemorySegment reinterpret(MemorySegment addr, Arena scope, Consumer<MemorySegment> cleanup) {
>> 224: return addr.reinterpret($LAYOUT().byteSize(), scope, cleanup);
>
> Maybe crazy idea - if we did `reinterpret(Long.MAX_VALUE, ...).asSlice($LAYOUT())` that would check alignment too - not sure if that would be useful or not.
Should the simpler reinterpret method call the array one with length of 1 ?
-------------
PR Review Comment: https://git.openjdk.org/jextract/pull/178#discussion_r1453587676
More information about the jextract-dev
mailing list