El 31/08/16 a las 17:20, Al Thomas escribió: > ----- Original Message ----- > >> From: Evan Nemerson <e...@coeus-group.com> >> Sent: Tuesday, 30 August 2016, 17:11 >> Subject: Re: [Vala] Array as big as an enum >> >> On Mon, 2016-08-29 at 23:47 +0200, rastersoft wrote: >>> Sorry, I found how to do that: >>> >>> int[] blah = new int[LAST_ELEMENT]; >> If you want to avoid having a LAST_ELEMENT value, something like this >> will also work: >> >> ((GLib.EnumClass) typeof(Foo).class_ref ()).n_values >> >> I'm not necessarily advocating it, but if you really want to keep your >> API clean it's an option. >> > > This gets the GType of Foo, instantiates it by increasing the ref count, > casts it to EnumClass and then uses the n_values field. > > If someone was to add syntax support for this for both EnumClass and > FlagsClass, what would be the best way for this to look? > > a) Explicit instantiation of the Foo EnumClass: > > var a = new Foo (); > print ("%i", a.n_values); > > b) Implicit access to EnumClass methods and fields: > print ("%i", Foo.v_values); >
The B one sounds better, I think. Even more: it would be great to be able to access to the enums as strings too. -- Nos leemos RASTER (Linux user #228804) ras...@rastersoft.com http://www.rastersoft.com _______________________________________________ vala-list mailing list vala-list@gnome.org https://mail.gnome.org/mailman/listinfo/vala-list