gtk-rs-core icon indicating copy to clipboard operation
gtk-rs-core copied to clipboard

Prevent all the copies in FFI translation by having Rust types for GLib arrays, strings, hash table, lists, etc

Open sdroege opened this issue 6 years ago • 2 comments

See above. Those could implement all kinds of conversions to the actual Rust types, e.g. via Iterator::collect() for arrays, but use the GLib allocator for memory management.

These could be used for the "transfer full" return values (and out parameters) everywhere at least.

For "transfer none" we could at least automatically support 'static references. Non-static borrowing requires a lot of knowledge of the API and is better implemented manually.

sdroege avatar Sep 05 '17 14:09 sdroege

It may be good.

EPashkin avatar Sep 05 '17 15:09 EPashkin

For Strings, @philn implemented GString which does exactly that. Now only everything else is missing :)

sdroege avatar Jun 19 '19 12:06 sdroege

Currently have: PtrSlice, Slice, PtrArray, List, SList, GString

Still missing: Array, HashTable

jf2048 avatar Oct 09 '22 06:10 jf2048

Also missing: making use of these from the code generator :)

Still missing: Array, HashTable

These are hard (or impossible) to do right, see https://gitlab.gnome.org/GNOME/gobject-introspection/-/issues/305

sdroege avatar Oct 09 '22 06:10 sdroege

For arrays (including string arrays) and lists there are container types now. As mentioned above, the others are unfortunately hard to deal with and better handled by copying and on a case-by-case basis.

sdroege avatar Jan 21 '23 09:01 sdroege