gtk-rs / gir

Tool to generate rust bindings and user API for glib-based libraries
https://gtk-rs.org/gir/book/
MIT License
230 stars 102 forks source link

No bindings generated for Vala async methods #1470

Open kawadakk opened 1 year ago

kawadakk commented 1 year ago
public abstract interface Foo.Bar : Object {
    public virtual async void hoge_async(Cancellable? cancellable = null) throws Error {}
}

Vala produces the following GIR for this method:

<virtual-method name="hoge_async" invoker="hoge_async">
  <return-value transfer-ownership="none">
    <type name="none" c:type="void"/>
  </return-value>
  <parameters>
    <instance-parameter name="self" transfer-ownership="none">
      <type name="Foo.Bar" c:type="FooBar*"/>
    </instance-parameter>
    <parameter name="cancellable" transfer-ownership="none" nullable="1">
      <type name="Gio.Cancellable" c:type="GCancellable*"/>
    </parameter>
    <parameter name="_callback_" transfer-ownership="none" nullable="1" closure="2" scope="async">
      <type name="Gio.AsyncReadyCallback" c:type="GAsyncReadyCallback"/>
    </parameter>
    <parameter name="_callback__target" transfer-ownership="none" nullable="1">
      <type name="gpointer" c:type="void*"/>
    </parameter>
  </parameters>
</virtual-method>

GIR does not seem to recognize the callback parameter, resulting in a missing binding:

https://github.com/gtk-rs/gir/blob/72e0c437340147cbb7f513e4ae00defee1ca2f7a/src/analysis/bounds.rs#L108

    //#[doc(alias = "foo_bar_hoge_async")]
    //fn hoge_async(&self, cancellable: Option<&impl IsA<gio::Cancellable>>, _callback_: AsyncReadyCallback) {
    //    unsafe { TODO: call ffi:foo_bar_hoge_async() }
    //}