Pango library seems to be really hard for gobject-introspection?

classic Classic list List threaded Threaded
5 messages Options
Reply | Threaded
Open this post in threaded view
|

Pango library seems to be really hard for gobject-introspection?

Stefan Salewski-2
First I noticed that for pango_font_description_from_string()

From /usr/share/gir-1.0/Pango-1.0.gir we know that transfer-
ownership="full" so we have to free it in our language bindings.

But how to guess the function for freeing?

For gobject there is generally a plain g_object_unref() necessary, and
there is even g_object_info_get_unref_function () available.

Well PangoFontDescription is Boxed type, does that help?

For all the data types with transfer-ownership="full" there seems to
exist in /usr/share/gir-1.0/Pango-1.0.gir: pango_attribute_destroy(),
pango_attr_list_unref(), pango_attr_iterator_destroy(),
pango_color_free() and more.

Well, my current guess would be to parse all methods of the pango data
types and use the one which contains free or destroy or unref in its
name? But that sounds a bit strange.


_______________________________________________
gtk-list mailing list
[hidden email]
https://mail.gnome.org/mailman/listinfo/gtk-list
Reply | Threaded
Open this post in threaded view
|

Re: Pango library seems to be really hard for gobject-introspection?

Emmanuele Bassi
Boxed types use g_boxed_free() to release resources, and g_boxed_copy() to copy them:

Ciao,
 Emmanuele.

On Sat, 9 Sep 2017 at 21:29, Stefan Salewski <[hidden email]> wrote:
First I noticed that for pango_font_description_from_string()

From /usr/share/gir-1.0/Pango-1.0.gir we know that transfer-
ownership="full" so we have to free it in our language bindings.

But how to guess the function for freeing?

For gobject there is generally a plain g_object_unref() necessary, and
there is even g_object_info_get_unref_function () available.

Well PangoFontDescription is Boxed type, does that help?

For all the data types with transfer-ownership="full" there seems to
exist in /usr/share/gir-1.0/Pango-1.0.gir: pango_attribute_destroy(),
pango_attr_list_unref(), pango_attr_iterator_destroy(),
pango_color_free() and more.

Well, my current guess would be to parse all methods of the pango data
types and use the one which contains free or destroy or unref in its
name? But that sounds a bit strange.


_______________________________________________
gtk-list mailing list
[hidden email]
https://mail.gnome.org/mailman/listinfo/gtk-list
--

_______________________________________________
gtk-list mailing list
[hidden email]
https://mail.gnome.org/mailman/listinfo/gtk-list
Reply | Threaded
Open this post in threaded view
|

Re: Pango library seems to be really hard for gobject-introspection?

Stefan Salewski-2
On Sat, 2017-09-09 at 21:46 +0000, Emmanuele Bassi wrote:
> Boxed types use g_boxed_free() to release resources, and
> g_boxed_copy() to copy them:
> https://developer.gnome.org/gobject/stable/gobject-Boxed-Types.html
>
> Ciao,
>  Emmanuele.

Yes I know :-)

But from

https://developer.gnome.org/pango/stable/pango-Fonts.html#pango-font-description-new

PangoFontDescription is a boxed type (from Object Hierarchy), and we
shall use pango_font_description_free() for freeing.

Do you suggest just using g_boxed_free() instead?

I don't think that is right?

What I found out in the last few hours at least: Pango data types which
needs a ...destroy() function for freeing seems to be mostly marked
with introspectable="0". So my current impression is, that for all the
data types which I "see" from gobject introspection with transfer-
ownership="full", I have to use ...free() for freeing.

For other data types, which needs ...destroy() I have to manually
create the glue code, when they should be needed at all.

But there are also data types like PangoFontMetrics which may need an
unref instead -- maybe that ones are used internally only.

But pango is really hard to understand. For example

https://developer.gnome.org/pango/stable/pango-Layout-Objects.html#pango-layout-get-line

For that we have transfer == none, but we can modify the result, and we
can ref and unref the result. To make it even more complicated there is
also pango_layout_get_line_readonly()


_______________________________________________
gtk-list mailing list
[hidden email]
https://mail.gnome.org/mailman/listinfo/gtk-list
Reply | Threaded
Open this post in threaded view
|

Re: Pango library seems to be really hard for gobject-introspection?

Emmanuele Bassi

On Sun, 10 Sep 2017 at 00:29, Stefan Salewski <[hidden email]> wrote:
On Sat, 2017-09-09 at 21:46 +0000, Emmanuele Bassi wrote:
> Boxed types use g_boxed_free() to release resources, and
> g_boxed_copy() to copy them:
> https://developer.gnome.org/gobject/stable/gobject-Boxed-Types.html
>
> Ciao,
>  Emmanuele.

Yes I know :-)

But from

https://developer.gnome.org/pango/stable/pango-Fonts.html#pango-font-description-new

PangoFontDescription is a boxed type (from Object Hierarchy), and we
shall use pango_font_description_free() for freeing.

Do you suggest just using g_boxed_free() instead?

If you're writing a language binding, you should use the GBoxed API for all boxed types, as that defers to the correct function without having to make up an annotation for copy and free functions.

As for Pango: introspection annotations may be missing or wrong; Pango is not heavily used on its own, and most definitely only a subset of its API is heavily exercised outside of GTK. In case of uncertainty, file bugs.

Ciao,
 Emmanuele.
--

_______________________________________________
gtk-list mailing list
[hidden email]
https://mail.gnome.org/mailman/listinfo/gtk-list
Reply | Threaded
Open this post in threaded view
|

Re: Pango library seems to be really hard for gobject-introspection?

Stefan Salewski-2
On Mon, 2017-09-11 at 07:25 +0000, Emmanuele Bassi wrote:
> If you're writing a language binding, you should use the GBoxed API
> for all boxed types, as that defers to the correct function without
> having to make up an annotation for copy and free functions.

That is interesting, thanks. I will read the docu.
_______________________________________________
gtk-list mailing list
[hidden email]
https://mail.gnome.org/mailman/listinfo/gtk-list