Add GLib List/SList return value copy/free support - #1573
Open
ousnius wants to merge 1 commit into
Open
Conversation
Implement end-to-end handling for GLib.List and GLib.SList return values by loading nested G-IR element types, resolving them into GirModel metadata, and generating managed array conversions for supported element types (strings, classes/interfaces, and typed records) with transfer-aware ownership behavior. Add internal/container list handle types and UTF-8 string helpers for safe conversion/freeing, wire new converters into return-type rendering, and keep unsupported list element cases on container fallback paths. Also add native GirTest list fixtures, binding/unit tests for element-type resolution and transfer semantics, and update the Secret sample to iterate returned collections directly.
1 task
ousnius
marked this pull request as ready for review
July 29, 2026 16:36
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Implement end-to-end handling for GLib.List and GLib.SList return values by loading nested G-IR element types, resolving them into GirModel metadata, and generating managed array conversions for supported element types (strings, classes/interfaces, and typed records) with transfer-aware ownership behavior.
Add internal/container list handle types and UTF-8 string helpers for safe conversion/freeing, wire new converters into return-type rendering, and keep unsupported list element cases on container fallback paths. Also add native GirTest list fixtures, binding/unit tests for element-type resolution and transfer semantics, and update the Secret sample to iterate returned collections directly.
Methods returning a GList/GSList now hand back a typed managed array whose elements are adopted or copied according to the transfer mode, instead of an opaque GLib.List wrapper that leaked its contents. 162 methods across the bound libraries changed shape — for example Gio.AppInfoHelper.GetAll() went from returning GLib.List to Gio.AppInfo[].
Once the elements are copied out into managed objects, the only thing left to free is the container itself, so transfer full and transfer container share one internal handle type (ListContainerHandle), releasing with
g_list_free/g_slist_free); transfer none keeps the existing unowned handle that frees nothing. What differs per transfer mode is the element, decided in ListElement.cs: with transfer full we own each element, so it is adopted by an owned handle or an owning wrapper; with container or none we don't, so each element is copied or referenced.Supported element types are GObject classes and interfaces, UTF-8 strings, and typed and opaque-typed records; anything else (a gpointer list, for instance) still falls back to the old GLib.List wrapper rather than losing the method.