Re: [Vala] Default enum's values' nick



I've read that article, some time ago. Is very useful for some tasks; but I
need some thing more easy when you have lot of enums and want to serialize
them to XML.

I working in a serialization branch in GXml project and added some
convenient functions to get exactly the same result with a simple method
call.

Check the code at:

https://git.gnome.org/browse/gxml/commit/?h=serialization&id=6abcfbb98ed53ada56616181f92b820fff4b685d

These resolve most cases and they could be added to Vala enums by default
to extra functionality. Some one can point me how?

But as you can see in the patch, the automatic generation of EnumClass for
each enum to register it as a valid GLib.Type adds some extra field called
'value_nick', my tests shows up that by default nick is set to lower case
canonical string representation of a given enum's value, then for a:

enum Cat {
BIG_SIZE,
BIGGEST
}

BIG_SIZE's default nick, from EnumClass and its EnumValue, is 'big-size'
while for BIGGEST is 'biggest'.

A call to GXml.Enumeration. get_nick_camelcase() returns 'BigSize' and
'Biggest' respectively.

My problem is when I need some nicks like 'givenTime' for GIVEN_TIME or
'CASTtool' for CAST_TOOL enums values. For them using a simple:

[Description (nick="CASTtool")]
CAST_TOOL

Is better and allow any others to get great control over enums in Vala.
El nov 8, 2013 12:01 a.m., "Donn" <donn ingle gmail com> escribió:

On 08/11/2013 02:43, Daniel Espinosa wrote:

 Do you know how can I change default nick?


I'm not sure - haven't had a chance to try this yet - but have a look at
this link:
http://blog.yorba.org/jim/2011/05/a-few-of-my-favorite-
vala-things-enums.html

\d
_______________________________________________
vala-list mailing list
vala-list gnome org
https://mail.gnome.org/mailman/listinfo/vala-list



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