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

Tracker async functions are not detected #967

Open uzytkownik opened 3 years ago

uzytkownik commented 3 years ago

Sorry if it is more of help request. I'm trying to create bindings for Tracker and it seems not to recognize the callback parameter but I cannot figure out why:

    //pub fn local_new_async<P: IsA<gio::File>, Q: IsA<gio::File>, R: IsA<gio::File>, S: IsA<gio::Cancellable>, T: FnOnce(Result<(), glib::Error>) + 'static>(flags: SparqlConnectionFlags, store: &P, journal: &Q, ontology: &R, cancellable: &S, _callback_: T, _callback__target: /*Unimplemented*/Fundamental: Pointer) {
    //    unsafe { TODO: call tracker_sys:tracker_sparql_connection_local_new_async() }
    //}
        <function name="local_new_async" c:identifier="tracker_sparql_connection_local_new_async">
            <return-value transfer-ownership="none">
                <type name="none" c:type="void" />
            </return-value>
            <parameters>
                <parameter name="flags" transfer-ownership="none">
                    <type name="Tracker.SparqlConnectionFlags" c:type="TrackerSparqlConnectionFlags" />
                </parameter>
                <parameter name="store" transfer-ownership="none">
                    <type name="Gio.File" c:type="GFile*" />
                </parameter>
                <parameter allow-none="1" name="journal" transfer-ownership="none">
                    <type name="Gio.File" c:type="GFile*" />
                </parameter>
                <parameter allow-none="1" name="ontology" transfer-ownership="none">
                    <type name="Gio.File" c:type="GFile*" />
                </parameter>
                <parameter allow-none="1" name="cancellable" transfer-ownership="none">
                    <type name="Gio.Cancellable" c:type="GCancellable*" />
                </parameter>
                <parameter allow-none="1" closure="6" name="_callback_" scope="async" transfer-ownership="none">
                    <type name="Gio.AsyncReadyCallback" c:type="GAsyncReadyCallback" />
                </parameter>
                <parameter allow-none="1" name="_callback__target" transfer-ownership="none">
                    <type name="gpointer" c:type="void*" />
                </parameter>
            </parameters>
        </function>
        <function name="local_new_finish" throws="1" c:identifier="tracker_sparql_connection_local_new_finish">
            <return-value transfer-ownership="full">
                <type name="Tracker.SparqlConnection" c:type="TrackerSparqlConnection*" />
            </return-value>
            <parameters>
                <parameter name="_res_" transfer-ownership="none">
                    <type name="Gio.AsyncResult" c:type="GAsyncResult*" />
                </parameter>
            </parameters>
        </function>
sdroege commented 3 years ago

Yes this looks like it should be generated. Is there anything useful printed about this when you run gir?

uzytkownik commented 3 years ago

@sdroege

[WARN  libgir::library_postprocessing] Field `NotifierClass::padding` missing c:type assumed to be `fixed_array`
[WARN  libgir::config::gobjects] Configured object `Gio.Priority` missing from the library
[ERROR libgir::analysis::record] Missing memory management functions for Tracker.NotifierEvent
[WARN  libgir::analysis::functions] get_async: missing success parameters for async future
[WARN  libgir::analysis::functions] local_new_async: missing success parameters for async future
[WARN  libgir::analysis::functions] query_async: missing success parameters for async future
[WARN  libgir::analysis::functions] load_async: missing success parameters for async future
[WARN  libgir::analysis::functions] statistics_async: missing success parameters for async future
[WARN  libgir::analysis::functions] next_async: missing success parameters for async future
[WARN  libgir::analysis::functions] execute_async: missing success parameters for async future
sdroege commented 3 years ago

[WARN libgir::analysis::functions] local_new_async: missing success parameters for async future

So this is the problem. Unclear why it needs this, returning a pointer and having NULL as failure is not exactly uncommon and I thought we handled that?

@GuillaumeGomez you wrote that code IIRC, any reason you see why this would fail here?

GuillaumeGomez commented 3 years ago

Just a note: the tracker API is deprecated apparently.

uzytkownik commented 3 years ago

@GuillaumeGomez - I tried to look for this information but I could not find any (it wasn't mentioned when I reported problems with GIR: https://gitlab.gnome.org/GNOME/tracker/-/issues/262 or on blog post: https://samthursfield.wordpress.com/2020/01/08/last-month-in-tracker/). Tracker 3 (which is unreleased AFAIK) contains spqrl as well. Can you link to announcement?