return new CCodeConstant ("\"%s%s\"".printf (get_ccode_name (sig), (detail != null ? "::%s".printf (detail) : "")));
}
- public static CCodeConstant get_enum_value_canonical_cconstant (EnumValue ev) {
- return new CCodeConstant ("\"%s\"".printf (ev.name.down ().replace ("_", "-")));
- }
-
public bool get_signal_has_emitter (Signal sig) {
return sig.get_attribute ("HasEmitter") != null;
}
foreach (EnumValue ev in en.get_values ()) {
clist_ev = new CCodeInitializerList ();
clist_ev.append (new CCodeConstant (get_ccode_name (ev)));
- clist_ev.append (new CCodeIdentifier ("\"%s\"".printf (get_ccode_name (ev))));
- clist_ev.append (CCodeBaseModule.get_enum_value_canonical_cconstant (ev));
+ clist_ev.append (new CCodeConstant ("\"%s\"".printf (get_ccode_name (ev))));
+ clist_ev.append (new CCodeConstant ("\"%s\"".printf (ev.nick)));
clist.append (clist_ev);
}
public int foo { get; set; }
}
+enum Bar {
+ [Description (nick = "foo's nick")]
+ FOO
+}
+
void main () {
var foo = new Foo ();
(unowned ParamSpec)[] properties = foo.get_class ().list_properties ();
assert (p.get_nick () == "foo's nick");
assert (p.get_blurb () == "foo's blurb");
}
+
+ assert (((EnumClass) typeof (Bar).class_ref ()).get_value_by_name (Bar.FOO.to_string ()).value_nick == "foo's nick");
}
* Represents an enum member in the source code.
*/
public class Vala.EnumValue : Constant {
+ /**
+ * The nick of this enum-value
+ */
+ public string nick {
+ get {
+ if (_nick == null) {
+ _nick = get_attribute_string ("Description", "nick");
+ if (_nick == null) {
+ _nick = name.down ().replace ("_", "-");
+ }
+ }
+ return _nick;
+ }
+ }
+
+ private string? _nick = null;
+
/**
* Creates a new enum value with the specified numerical representation.
*