return new CCodeConstant (str.str);
}
+ public static CCodeConstant get_enum_value_canonical_cconstant (EnumValue ev) {
+ var str = new StringBuilder ("\"");
+
+ string i = ev.name;
+
+ while (i.length > 0) {
+ unichar c = i.get_char ();
+ if (c == '_') {
+ str.append_c ('-');
+ } else {
+ str.append_unichar (c.tolower ());
+ }
+
+ i = i.next_char ();
+ }
+
+ str.append_c ('"');
+
+ return new CCodeConstant (str.str);
+ }
+
public bool get_signal_has_emitter (Signal sig) {
return sig.get_attribute ("HasEmitter") != null;
}
clist_ev = new CCodeInitializerList ();
clist_ev.append (new CCodeConstant (CCodeBaseModule.get_ccode_name (ev)));
clist_ev.append (new CCodeIdentifier ("\"%s\"".printf (CCodeBaseModule.get_ccode_name (ev))));
- clist_ev.append (ev.get_canonical_cconstant ());
+ clist_ev.append (CCodeBaseModule.get_enum_value_canonical_cconstant (ev));
clist.append (clist_ev);
}
base (name, null, value, source_reference, comment);
}
- /**
- * Returns the string literal of this signal to be used in C code.
- * (FIXME: from vlaasignal.vala)
- *
- * @return string literal to be used in C code
- */
- public CCodeConstant get_canonical_cconstant () {
- var str = new StringBuilder ("\"");
-
- string i = name;
-
- while (i.length > 0) {
- unichar c = i.get_char ();
- if (c == '_') {
- str.append_c ('-');
- } else {
- str.append_unichar (c.tolower ());
- }
-
- i = i.next_char ();
- }
-
- str.append_c ('"');
-
- return new CCodeConstant (str.str);
- }
-
public override void accept (CodeVisitor visitor) {
visitor.visit_enum_value (this);
}