RFR: 7903626: Add struct helper method to reintrepret an array of structs
Maurizio Cimadamore
mcimadamore at openjdk.org
Tue Jan 16 15:30:50 UTC 2024
On Tue, 16 Jan 2024 15:05:41 GMT, Jorn Vernee <jvernee 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.
Marked as reviewed by mcimadamore (Reviewer).
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.
test/TEST.groups line 14:
> 12: jtreg/generator/test8252016/Test8252016.java \
> 13: jtreg/generator/test8252121/Test8252121.java \
> 14: jtreg/generator/reinterpret/TestReinterpret.java \
uhmmm - I did not realized we had to update this manually (for the other PRs...)
test/jtreg/generator/reinterpret/TestReinterpret.java line 67:
> 65: int elementCount = 10;
> 66: MemorySegment addr = makeArray(elementCount);
> 67: MemorySegment array = Point.reinterpret(addr, elementCount, arena, reinterpret_h::freePoint);
nice!
-------------
PR Review: https://git.openjdk.org/jextract/pull/178#pullrequestreview-1823781234
PR Review Comment: https://git.openjdk.org/jextract/pull/178#discussion_r1453586564
PR Review Comment: https://git.openjdk.org/jextract/pull/178#discussion_r1453588713
PR Review Comment: https://git.openjdk.org/jextract/pull/178#discussion_r1453589125
More information about the jextract-dev
mailing list