Web lists-archives.com

Re: One more Gobject Introspection issue

On 14 September 2017 at 21:12, Stefan Salewski <mail@xxxxxxxxxxxx> wrote:
> GtkIconSize type is reported as plain gint, but it is an enum.

It's an "extensible" enumeration, like GtkResponseType for GtkDialog:
the API accepts an integer, because app and library developers can
register their own icon sizes, but GTK+ provides default icon sizes
out of the box.

It's a relatively unused functionality, these days.

> But here, again see last line of code segment:

>           <parameter name="size" transfer-ownership="none">
>             <doc xml:space="preserve">a stock icon size (#GtkIconSize)</doc>
>             <type name="gint" c:type="GtkIconSize"/>

All API that takes a GtkIconSize should have a `type int` annotation.
How you handle the translation between an enumeration value and an
integer is entirely up to your language binding; the Perl bindings,
for instance, have additional code that allows transforming strings
(and array of strings, for bitmasks) into integer values, whereas the
Python bindings simply turn enumeration names into integers after
resolving their name from "Namespace.TypeName.VALUE" to
"NAMESPACE_TYPENAME_VALUE". In both cases, integers are passed through
as they are, given that enumeration values in C are by definition


[@] ebassi [@gmail.com]
gtk-list mailing list