From: Luca Bruno Date: Wed, 3 Aug 2011 20:02:12 +0000 (+0200) Subject: Move EnumValue.get_canonical_cconstant to the codegen X-Git-Tag: 0.13.2~33 X-Git-Url: http://git.ipfire.org/gitweb.cgi?a=commitdiff_plain;h=5a4cf3022f57292becf5b5b2c2e71e019914a47e;p=thirdparty%2Fvala.git Move EnumValue.get_canonical_cconstant to the codegen --- diff --git a/codegen/valaccodebasemodule.vala b/codegen/valaccodebasemodule.vala index e5c11b1b9..5ed6f855b 100644 --- a/codegen/valaccodebasemodule.vala +++ b/codegen/valaccodebasemodule.vala @@ -5840,6 +5840,27 @@ public abstract class Vala.CCodeBaseModule : CodeGenerator { 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; } diff --git a/codegen/valatyperegisterfunction.vala b/codegen/valatyperegisterfunction.vala index a2266832a..61e77a80e 100644 --- a/codegen/valatyperegisterfunction.vala +++ b/codegen/valatyperegisterfunction.vala @@ -173,7 +173,7 @@ public abstract class Vala.TypeRegisterFunction { 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); } diff --git a/vala/valaenumvalue.vala b/vala/valaenumvalue.vala index 05d4494c3..b4d27bf06 100644 --- a/vala/valaenumvalue.vala +++ b/vala/valaenumvalue.vala @@ -37,33 +37,6 @@ public class Vala.EnumValue : Constant { 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); }