Re: element-type for ints cast to pointer



Speaking from a language binding perspective, and from a C developer perspective, exposing this kind of API is a bad idea to begin with, regardless of introspection annotations.

You're already giving up any sort of type safety by using direct pointer keys, there's no amount of papering over with annotations that will make this kind of data type safe.

You should create your own boxed type that contains a (private) GHashTable, and with proper public API that takes integer keys and stores them into the hash table.

Ciao,
 Emmanuele.

On Thu, 4 Oct 2018 at 15:10, Tony Houghton <h realh co uk> wrote:
If I'm using ints cast to pointers with GINT_TO_POINTER as a GHashTable key with g_direct_hash(), what should I use as the element-type in the annotations? If I used "int" that would imply that the pointer is a valid pointer to int, which isn't actually the case.

--
TH

_______________________________________________
gir-devel-list mailing list
gir-devel-list gnome org
https://mail.gnome.org/mailman/listinfo/gir-devel-list


--
https://www.bassi.io
[@] ebassi [@gmail.com]


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]