On Wed, 2010-06-09 at 01:23 +0200, Jan Niklas Hasse wrote: > On Tue, Jun 8, 2010 at 10:35 PM, Evan Nemerson <[email protected]> wrote: > > With the improvements made to GPtrArray in GLib 2.22 (reference counting > > and the ability to specify a free function), it would be very useful to > > have a generic implementation available from Vala. > > > > In order to preserve backwards compatibility, we would like to keep > > GLib.PtrArray as it is and implement a generic version with a different > > name in Vala. Unfortunately, we haven't been able to decide on a name we > > like. Right now it seems like the two best choices are: > > > > * GLib.GenericArray > > Not the shortest name, but fairly descriptive of what it does. > > * GLib.ArrayList > > Short and consistent with the gee naming scheme. The problem is > > projects using Gee would always have to type Gee.ArrayList or > > GLib.ArrayList to disambiguate their choice. > > > > Does anyone have any good ideas? Or a preference between these two? > > Do Gee.ArrayList and GLib.ArrayList work different? If so I would > prefer the first choice.
Yes. Gee.ArrayList looks like this: http://valadoc.org/gee-1.0/Gee.ArrayList.html and this new thing would look something like this (untested): [CCode (cname = "GPtrArray", cprefix = "g_ptr_array_", ref_function = "g_ptr_array_ref", unref_function = "g_ptr_array_unref", type_id = "G_TYPE_PTR_ARRAY")] public class GenericArray<T> { public GenericArray<T> (); public GenericArray<T>.with_free_func (GLib.DestroyNotify? element_free_func); [CCode (cname = "g_ptr_array_sized_new")] public GenericArray.sized (uint reserved_size); public void add (owned T data); [CCode (cname = "g_ptr_array_index")] public unowned T index(uint index); public bool remove (T data); public void remove_index (uint index); public bool remove_fast (T data); public void remove_range (uint index, uint length); public void set_free_func (GLib.DestroyNotify? element_free_function); public void sort (GLib.CompareFunc compare_func); public void sort_with_data (GLib.CompareDataFunc compare_func); public void set_size (uint length); [CCode (array_length_cname = "len", array_length_type = "uint")] public T[] pdata; } _______________________________________________ vala-list mailing list [email protected] http://mail.gnome.org/mailman/listinfo/vala-list
