[go: up one dir, main page]

Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

generating astal bindings #453

Open
kotontrion opened this issue Oct 3, 2024 · 1 comment
Open

generating astal bindings #453

kotontrion opened this issue Oct 3, 2024 · 1 comment

Comments

@kotontrion
Copy link

I'm currently on the process of generating haskell bindings for astal and its companion libs. Most of them generated fine, but I did come across some issues.

AstalApps:

<property name="app" writable="1" construct="1">
    <type name="GLib.DesktopAppInfo" c:type="GDesktopAppInfo*"/>
</property>

GDesktopAppInfo is part of Gio and not GLib. I couldn't get it to work by changing the type name using overrides. I just removed this property from the bindings for now.

AstalBluetooth

<property name="adapter">
    <type name="GLib.ObjectPath" c:type="char*"/>
</property>

GLib.ObjectPath is a vala thing. renaming the type using overrides works well, but maybe this should be handled in haskell-gi?

AstalNetwork

depends on NetworkManager, which does not have haskell bindings, so they have to be generated first. I tried to generate them, but it has types like 80211ApFlags, which are not valid names in haskell, as they start with a number. They have to be renamed. Do i have to add an override entry for every occurrence in the gir file or is there a better way?

AstalWireplumber

I get this error when trying to build the generated bindings.

GI/AstalWp/Objects/Endpoint.hs:666:42: error:
    • Could not deduce (BoxedEnum AstalWp.Enums.MediaClass)
        arising from a use of ‘B.Properties.getObjectPropertyEnum’
      from the context: (MonadIO m, IsEndpoint o)
        bound by the type signature for:
                   getEndpointMediaClass :: forall (m :: * -> *) o.
                                            (MonadIO m, IsEndpoint o) =>
                                            o -> m AstalWp.Enums.MediaClass
        at GI/AstalWp/Objects/Endpoint.hs:665:1-85
    • In the second argument of ‘($)’, namely
        ‘B.Properties.getObjectPropertyEnum obj "media-class"’
      In the expression:
        liftIO $ B.Properties.getObjectPropertyEnum obj "media-class"
      In an equation for ‘getEndpointMediaClass’:
          getEndpointMediaClass obj
            = liftIO $ B.Properties.getObjectPropertyEnum obj "media-class"
    |
666 | getEndpointMediaClass obj = MIO.liftIO $ B.Properties.getObjectPropertyEnum obj "media-class"
    |                                          ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

The same error is repeated for the AstalWp.Device.device-type and AstalWp.Wp.scale properties, which are enums as well. For now i just removed these properties from the generated bindings. The getter and setter functions for them are still included and it builds fine.
relevant parts of the gir file:

<enumeration name="MediaClass" c:type="AstalWpMediaClass">
    <source-position filename="include/astal/wireplumber/endpoint.h"
        line="23"/>
    <member name="audio_microphone"
        value="0"
        c:identifier="ASTAL_WP_MEDIA_CLASS_AUDIO_MICROPHONE">
    </member>
    <member name="audio_speaker"
        value="1"
        c:identifier="ASTAL_WP_MEDIA_CLASS_AUDIO_SPEAKER">
    </member>
    [...]
</enumeration>

<property name="media-class"
    transfer-ownership="none"
    getter="get_media_class"
    default-value="ASTAL_WP_MEDIA_CLASS_AUDIO_SPEAKER">
    <type name="MediaClass"/>
</property>

I would appreciate any pointers in the right direction.

@brainlessbitch
Copy link

there are also a few typing bugs, like some props that should just take Int want GHC.Int.Int32

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants