RFR: 7903947: Access to function pointers in structs could be streamlined
Nizar Benalla
nbenalla at openjdk.org
Tue Sep 9 08:45:11 UTC 2025
On Wed, 23 Jul 2025 12:37:47 GMT, Nizar Benalla <nbenalla at openjdk.org> wrote:
> 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);
Keep Alive
-------------
PR Comment: https://git.openjdk.org/jextract/pull/287#issuecomment-3269564444
More information about the jextract-dev
mailing list