Ah, yes, opaque types are indeed unsupported:
https://github.com/openjdk/jextract/blob/master/doc/GUIDE.md#unsupported-features.
As Jorn said there, if the API exposes methods that use opaque types, then
you wouldn't have a problem. Also, if you have the .c file where they are
defined, jextract can handle them. It could be a bit of a hack though.

I wrote a jextract GUI wrapper with JavaFX, which I tested only on Windows
for now. I will try to get the Linux and Mac versions up soon as well. I
find it very helpful compared to the command line and I think it could help
you with the complex headers there.

Note that jextract generates Java 22 compatible code, which is unusable in
JavaFX for now (we comply with Java 21).

On Mon, Apr 22, 2024 at 1:36 AM Thiago Milczarek Sayão <
thiago.sa...@gmail.com> wrote:

> I mailed the jextract list and Jorn Vernee explained that wayland use
> opaque types, which are just defined as such:
>
> struct wl_registry;
>
> I guess you just pass it around and it's defined in the internal .c file.
> Those are not supported by jextract.
>
> I'll find a way to get around it.
>
> But I've been playing with it all day, it seems very good. I was able to
> generate bindings for:
>
> GMain - for the main loop;
> GSettings - for reading settings;
> XDG Portal - for screen capture, screenshot, file dialogs
>
> It looks like this:
>
> 1) To get a setting
>
> try(var a = Arena.ofConfined()) {
>     var mouseSettings = 
> g_settings_new(a.allocateUtf8String("org.gnome.desktop.interface"));
>     int size = g_settings_get_int(mouseSettings, 
> a.allocateUtf8String("cursor-size"));
>     g_object_unref(mouseSettings);
>     return new Size(size, size);
> }
>
>
> 2) Callbacks
>
> @Override
> protected void _invokeLater(Runnable runnable) {
>     MemorySegment call = GSourceFunc.allocate(p -> {
>         runnable.run();
>         return 0;
>     }, Arena.ofAuto());
>
>     g_idle_add(call, MemorySegment.NULL);
> }
>
>
> It looks correct to me, but untested.
>
> -- Thiago.
>
> Em dom., 21 de abr. de 2024 às 18:15, Nir Lisker <nlis...@gmail.com>
> escreveu:
>
>> Can you link to where all the headers are? I found some in
>> https://gitlab.freedesktop.org/wayland/wayland/-/tree/main/src, but I
>> couldn't see where wl_registry is defined. From what I see, wl_XYZ types
>> are structs, which are supported.
>>
>> By the way, there's a new guide for jextract at
>> https://github.com/openjdk/jextract/blob/master/doc/GUIDE.md. When
>> working with complex headers (includes upon includes), it's important to
>> specify the correct target header.
>>
>> On Sun, Apr 21, 2024 at 11:35 PM Thiago Milczarek Sayão <
>> thiago.sa...@gmail.com> wrote:
>>
>>> jextract --output src -t org.freedesktop.wayland.client
>>> --header-class-name WlClient `pkg-config --cflags-only-I wayland-client`
>>> `pkg-config --libs wayland-client`  /usr/include/wayland-client.h
>>>
>>> WARNING: Skipping wl_registry (type Declared(wl_registry) is not
>>> supported)
>>>
>>> I would need this to hook the events with wl_registry_add_listener, but
>>> currently the code generation for this is not working.
>>>
>>>
>>>
>>>
>>>
>>> Em dom., 21 de abr. de 2024 às 16:39, Nir Lisker <nlis...@gmail.com>
>>> escreveu:
>>>
>>>> What are wl_ types? jextract only supports c headers.
>>>>
>>>> On Sun, Apr 21, 2024 at 10:31 PM Thiago Milczarek Sayão <
>>>> thiago.sa...@gmail.com> wrote:
>>>>
>>>>> Hi,
>>>>>
>>>>> I did a small test app to explore Wayland client and portals (for
>>>>> Robot and dialogs such as file open/save).
>>>>>
>>>>> https://github.com/tsayao/wayland-test/blob/main/wayland-test.c
>>>>>
>>>>> It seems it will work as a glass backend, but some walls will be hit
>>>>> on the way :)
>>>>>
>>>>> I have tried to use jextract (from project Panama) to work directly
>>>>> with java, but it seems it does not support wl_ types.
>>>>>
>>>>> -- Thiago.
>>>>>
>>>>

Reply via email to