summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorLuca Bruno <lucabru@src.gnome.org>2011-08-03 22:02:12 +0200
committerLuca Bruno <lucabru@src.gnome.org>2011-08-04 09:49:44 +0200
commit5a4cf3022f57292becf5b5b2c2e71e019914a47e (patch)
tree4cbdf1c00549051ac50107630c344adde050fd1b
parent573bc05e672e8ec8ca5e2da358650df2c9703e14 (diff)
downloadvala-5a4cf3022f57292becf5b5b2c2e71e019914a47e.tar.gz
Move EnumValue.get_canonical_cconstant to the codegen
-rw-r--r--codegen/valaccodebasemodule.vala21
-rw-r--r--codegen/valatyperegisterfunction.vala2
-rw-r--r--vala/valaenumvalue.vala27
3 files changed, 22 insertions, 28 deletions
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);
}