RFR: 7903947: Access to function pointers in structs could be streamlined
Nizar Benalla
nbenalla at openjdk.org
Wed Jul 23 12:44:03 UTC 2025
Please review this patch to add a new option where you can generate an direct invoker methods. This feature is intended to be used on structs that are just a collection of functions we had like to call.
If this feature is used, we remove the getter to avoid name collisions as we assume this is similar to an interface.
Changes to `GUIDE.md` have been intentionally left out from this initial patch to make reviews easier.
struct Foo {
struct Bar (*a)(void);
struct Bar (*b)(int);
};
Before
var foo = alloc_callback_h.foo();
var barA = Foo.a.invoke(Foo.a(foo), arena);
var barB = Foo.b.invoke(Foo.b(foo), arena, 100);
After
var foo = alloc_callback_h.foo();
var barA = Foo.a(foo, arena);
var barB = Foo.b(foo, arena, 100);
-------------
Commit messages:
- add functional dispatch feature
Changes: https://git.openjdk.org/jextract/pull/287/files
Webrev: https://webrevs.openjdk.org/?repo=jextract&pr=287&range=00
Issue: https://bugs.openjdk.org/browse/CODETOOLS-7903947
Stats: 294 lines in 8 files changed: 263 ins; 6 del; 25 mod
Patch: https://git.openjdk.org/jextract/pull/287.diff
Fetch: git fetch https://git.openjdk.org/jextract.git pull/287/head:pull/287
PR: https://git.openjdk.org/jextract/pull/287
More information about the jextract-dev
mailing list