Skip to content

Add g_autoqueue

Marco Trevisan requested to merge 3v1n0/glib:more-auto-macros into master

This is based on !413 (merged), so just last commits are relevant.

Add missing g_autoqueue definition, that works as g_auto(s)list work, as per the work in !413 (merged) it can be added in a cleaner way.

Also wondering if it would be the case to just standardize all these types, by creating a g_autocontainer(ContainerType, DataType) so that eventually there are not g_auto[containertype] ways to define things, making this also cleaner to extend.

Then added various g_clear_auto* macros so that it's possible to unref a pointer with the cleaner defined for the type (which takes in account the parent type too) and at the same time to unset its reference, and I find it quite useful for containers and especially lists, where right now we've to use two calls when it comes to free deeply and unset the ref.

As per this last topic, I was also considering adding g_clear_{(s)list,queue}[_full] definitions, which might then be reused here too, simplifying the macro definitions.

One more aspect to be considered, I was thinking to use the definition of _GLIB_AUTOPTR_CLEAR_FUNC_NAME (that could be applied to g_auto's with a _GLIB_AUTO_CLEAR_FUNC_NAME) to basically be able to add functions such as g_foo_bar_new_auto(TypeName) in the way that this for example automatically calls g_foo_bar_new_full(timename_unref).

And basically to be able to avoid passing GDestroyFunc's but having those to be automatically guessed, which might be useful especially for some derived types.

Edited by Marco Trevisan

Merge request reports