Skip to content

Conversation

@jf2048
Copy link
Member

@jf2048 jf2048 commented Nov 30, 2022

Part of gtk-rs/gtk-rs-core#64

  • g_macro__has_attribute___noreturn__ and G_LOG_DOMAIN are used for C macros, should not be in ffi at all
  • G_LOG_LEVEL_MASK is considered unsigned by rust but C defines it as signed

<doc xml:space="preserve">Multiplying the base 2 exponent by this number yields the base 10 exponent.</doc>
<type name="gdouble" c:type="gdouble"/>
</constant>
<constant name="LOG_DOMAIN" value="0" c:type="G_LOG_DOMAIN">
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Instead this can be ignored in the Gir.toml file which will drop it from the ffi tests

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I tried that but couldn't get it to work, let me try again

Copy link
Member

@bilelmoussaoui bilelmoussaoui Nov 30, 2022

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

we do that in gtk for the version constants for example

<doc xml:space="preserve">log level for debug messages, see g_debug()</doc>
</member>
<member name="level_mask" value="-4" c:identifier="G_LOG_LEVEL_MASK">
<member name="level_mask" value="4294967292" c:identifier="G_LOG_LEVEL_MASK">
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

shouldn't this be fixed upstream?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You can add (type uint) annotation for this IIRC

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

And (value 4294967292). That's done in GStreamer in many places. It also confuses the Python bindings if you don't do that, but I guess nobody is using G_LOG_LEVEL_MASK from Python.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think we have this problem with any flags type, we consider them u32 but in C anything in an enum has to be int. Maybe I will just have gir cast them to unsigned

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yeah it looks like those annotations won't work on an enum constant, they only work on a #define

</parameter>
</parameters>
</function-macro>
<constant name="macro__has_attribute___noreturn__" value="0" c:type="g_macro__has_attribute___noreturn__">
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Similar to the other constant

@jf2048
Copy link
Member Author

jf2048 commented Nov 30, 2022

Closing in favor of more stuff in gtk-rs-core/gir#1409

@jf2048 jf2048 closed this Nov 30, 2022
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

Successfully merging this pull request may close these issues.

3 participants