gtk-rs / gir

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

Spice-gtk will not generate #805

Closed bepvte closed 5 years ago

bepvte commented 5 years ago

On using it with SpiceClientGLib-2.0.gir, I get this error and the generation fails. I dont understand introspection too well, so if I'm leaving out details you need let me know.

GirXml: /usr/share/gir-1.0/SpiceClientGLib-2.0.gir at line 1550:8: <type> element is missing a name attribute
EPashkin commented 5 years ago

Seems you need fix .gir file before processing: type element must have name attribute, Ex.

<type name="guint" c:type="guint"/>
bepvte commented 5 years ago

The problem was that the type had the attribute "introspectable=0", which it doesnt look like this respects.

EPashkin commented 5 years ago

Strange, I thought that type element can't have introspectable attribute. Can you show part of file here or link full file from somewhere?

bepvte commented 5 years ago
    <record name="CursorShape"
            c:type="SpiceCursorShape"
            glib:type-name="SpiceCursorShape"
            glib:get-type="spice_cursor_shape_get_type"
            c:symbol-prefix="cursor_shape">
      <doc xml:space="preserve"
           filename="channel-cursor.h"
           line="41">The #SpiceCursorShape structure defines the remote cursor's shape.</doc>
      <source-position filename="channel-cursor.h" line="61"/>
      <field name="type" introspectable="0" writable="1">
        <doc xml:space="preserve"
             filename="channel-cursor.h"
             line="43">a #SpiceCursorType of @data</doc>
        <type c:type="SpiceCursorType"/>
      </field>
      <field name="width" writable="1">
        <doc xml:space="preserve"
             filename="channel-cursor.h"
             line="44">a width of the remote cursor</doc>
        <type name="guint16" c:type="guint16"/>
      </field>

my apologies, the introspectable attribute was on the "field"

EPashkin commented 5 years ago

Strange, SpiceCursorType not found more in this file, so I propose just remove field completely.

bepvte commented 5 years ago

will do, thanks!

bepvte commented 5 years ago

While that made it progress farther, I still get some errors, starting with the "vreader" virtual smartcard features I dont use:

thread 'main' panicked at 'Incomplete library, unresolved: ["SpiceClientGLib.VReader"]', src/library_postprocessing.rs:62:13

But adding this to the ignore array did not work, so I instead deleted all smartcard features from the GIR xml. Then I am getting vague and similar errors about the "URL" class, which I do need for my project. How should I debug these?

EPashkin commented 5 years ago

Sorry "glib::boxed" type currently not supported, so VReader can be only ignored.

    <glib:boxed glib:name="VReader"
                c:symbol-prefix="smartcard_reader"
                glib:type-name="VReader"
                glib:get-type="spice_smartcard_reader_get_type">
    </glib:boxed>

I don't see any URL class in my version of SpiceClientGLib-2.0.gir (from https://packages.ubuntu.com/eoan/libspice-client-glib-2.0-dev), can you link repo with your file and Gir.toml?

bepvte commented 5 years ago

I managed to fix the problem by more carefully removing the smartcard related components in an editor with collapsing xml. The problem was most likely incorrect XML syntax that was my fault. The class I was talking about (which is fixed now) is the URI class, sorry for misspelling it. Thank you for your patience and this very useful software.

yshui commented 2 years ago

Can gir ignore introspectable=0 elements instead of requiring the user to manually remove them?

sdroege commented 2 years ago

No because many of those are actually used by gir

bilelmoussaoui commented 2 years ago

You don't have to remove them, just mark them as ignored on the Gir.toml btw