RFR: Update jextract to reflect latest API changes [v2]
Jorn Vernee
jvernee at openjdk.org
Fri Feb 10 19:07:15 UTC 2023
On Fri, 10 Feb 2023 17:55:46 GMT, Maurizio Cimadamore <mcimadamore at openjdk.org> wrote:
>> This patch refreshes the generated bindings to reflect the latest API changes in https://github.com/openjdk/panama-foreign/pull/787.
>>
>> The changes are straightforward, and mostly consist in removing `.scope()` calls when creating upcalls, and with replacing some `SegmentScope` parameters with `Arena` ones.
>
> Maurizio Cimadamore has updated the pull request with a new target base due to a merge or a rebase. The pull request now contains seven commits:
>
> - Merge branch 'panama' into arena_lump
> - Revert spurious changes
> - Polish test
> - Drop spurious changes
> - Fix test
> - Use target layouts for pointers
> - Add support for latest API changes
src/main/java/org/openjdk/jextract/clang/libclang/RuntimeHelper.java line 82:
> 80:
> 81: static MemorySegment lookupGlobalVariable(String name, MemoryLayout layout) {
> 82: return SYMBOL_LOOKUP.find(name).orElse(null).asUnbounded().asSlice(0, layout.byteSize());
I note that his is different from the template, which returns `null` if the symbol can not be found as well. I'm not sure if that was intentional.
test/jtreg/generator/test8246341/LibTest8246341Test.java line 59:
> 57: assertEquals(argv.getAtIndex(C_POINTER, 1).asUnbounded().getUtf8String(0), "python");
> 58: assertEquals(argv.getAtIndex(C_POINTER, 2).asUnbounded().getUtf8String(0), "javascript");
> 59: assertEquals(argv.getAtIndex(C_POINTER, 3).asUnbounded().getUtf8String(0), "c++");
Is `asUnbounded` really needed here? Looking at the layout of `C_POINTER`, it has an unbounded target layout attached:
final class Constants$root {
...
static final OfAddress C_POINTER$LAYOUT = ADDRESS.withBitAlignment(64).withTargetLayout(MemoryLayout.sequenceLayout(Constants$root.C_CHAR$LAYOUT));
}
test/jtreg/generator/test8246341/LibTest8246341Test.java line 72:
> 70: addr.set(C_POINTER, 0, MemorySegment.NULL);
> 71: fillin(addr);
> 72: assertEquals(addr.get(C_POINTER, 0).asUnbounded().getUtf8String(0), "hello world");
And here?
-------------
PR: https://git.openjdk.org/jextract/pull/102
More information about the jextract-dev
mailing list