]> git.ipfire.org Git - thirdparty/vala.git/commitdiff
Move EnumValue.get_canonical_cconstant to the codegen
authorLuca Bruno <lucabru@src.gnome.org>
Wed, 3 Aug 2011 20:02:12 +0000 (22:02 +0200)
committerLuca Bruno <lucabru@src.gnome.org>
Thu, 4 Aug 2011 07:49:44 +0000 (09:49 +0200)
codegen/valaccodebasemodule.vala
codegen/valatyperegisterfunction.vala
vala/valaenumvalue.vala

index e5c11b1b92981cf048ea3a2bdea4decb5fac828a..5ed6f855b704177112929c457c873d43a9554670 100644 (file)
@@ -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;
        }
index a2266832ae64e3ec5c25db2c8c2819ead05e6733..61e77a80ee28ee55482bf6e404d796e01337d749 100644 (file)
@@ -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);
                        }
 
index 05d4494c32db5c25dec351de87a831947a87747d..b4d27bf06c1b75efaaa239f1980ce50bbf238702 100644 (file)
@@ -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);
        }