[vala/wip/attributes: 8/8] codegen: Add CCodeBaseModule.get_ccode_lower_case_name



commit c785e2d0c51afba8f0c45b5291fca365ab083b29
Author: Luca Bruno <lucabru src gnome org>
Date:   Sun Jun 26 14:16:16 2011 +0200

    codegen: Add CCodeBaseModule.get_ccode_lower_case_name

 codegen/valaccodebasemodule.vala           |   60 ++++++++++++++++++++------
 codegen/valaccodememberaccessmodule.vala   |    8 ++--
 codegen/valaccodemethodcallmodule.vala     |    6 +-
 codegen/valaccodemethodmodule.vala         |    4 +-
 codegen/valaccodestructmodule.vala         |    2 +-
 codegen/valaclassregisterfunction.vala     |   32 +++++++-------
 codegen/valagdbusclientmodule.vala         |    6 +-
 codegen/valagdbusmodule.vala               |    8 ++--
 codegen/valagdbusservermodule.vala         |    4 +-
 codegen/valagerrormodule.vala              |    4 +-
 codegen/valagobjectmodule.vala             |   28 ++++++------
 codegen/valagsignalmodule.vala             |    4 +-
 codegen/valagtypemodule.vala               |   62 ++++++++++++++--------------
 codegen/valagvariantmodule.vala            |   12 +++---
 codegen/valainterfaceregisterfunction.vala |    4 +-
 codegen/valatyperegisterfunction.vala      |   10 ++--
 16 files changed, 143 insertions(+), 111 deletions(-)
---
diff --git a/codegen/valaccodebasemodule.vala b/codegen/valaccodebasemodule.vala
index c4d1851..a08014a 100644
--- a/codegen/valaccodebasemodule.vala
+++ b/codegen/valaccodebasemodule.vala
@@ -700,10 +700,10 @@ public abstract class Vala.CCodeBaseModule : CodeGenerator {
 
 		decl_space.add_type_declaration (new CCodeNewline ());
 
-		var macro = "(%s_get_type ())".printf (en.get_lower_case_cname (null));
+		var macro = "(%s_get_type ())".printf (get_ccode_lower_case_name (en, null));
 		decl_space.add_type_declaration (new CCodeMacroReplacement (en.get_type_id (), macro));
 
-		var fun_name = "%s_get_type".printf (en.get_lower_case_cname (null));
+		var fun_name = "%s_get_type".printf (get_ccode_lower_case_name (en, null));
 		var regfun = new CCodeFunction (fun_name, "GType");
 		regfun.attributes = "G_GNUC_CONST";
 
@@ -753,7 +753,7 @@ public abstract class Vala.CCodeBaseModule : CodeGenerator {
 				get_class_private_call.add_argument (new CCodeIdentifier ("klass"));
 				l = new CCodeMemberAccess.pointer (get_class_private_call, get_symbol_lock_name (m.name));
 			} else {
-				l = new CCodeIdentifier (get_symbol_lock_name ("%s_%s".printf(m.parent_symbol.get_lower_case_cname (), m.name)));
+				l = new CCodeIdentifier (get_symbol_lock_name ("%s_%s".printf(get_ccode_lower_case_name (m.parent_symbol), m.name)));
 			}
 
 			push_context (init_context);
@@ -1521,9 +1521,9 @@ public abstract class Vala.CCodeBaseModule : CodeGenerator {
 			string cname;
 			if (is_virtual) {
 				if (acc.readable) {
-					cname = "%s_real_get_%s".printf (t.get_lower_case_cname (null), prop.name);
+					cname = "%s_real_get_%s".printf (get_ccode_lower_case_name (t, null), prop.name);
 				} else {
-					cname = "%s_real_set_%s".printf (t.get_lower_case_cname (null), prop.name);
+					cname = "%s_real_set_%s".printf (get_ccode_lower_case_name (t, null), prop.name);
 				}
 			} else {
 				cname = get_ccode_name (acc);
@@ -3353,7 +3353,7 @@ public abstract class Vala.CCodeBaseModule : CodeGenerator {
 			get_class_private_call.add_argument (klass);
 			l = new CCodeMemberAccess.pointer (get_class_private_call, get_symbol_lock_name (resource.symbol_reference.name));
 		} else {
-			string lock_name = "%s_%s".printf(parent.get_lower_case_cname (), resource.symbol_reference.name);
+			string lock_name = "%s_%s".printf(get_ccode_lower_case_name (parent), resource.symbol_reference.name);
 			l = new CCodeIdentifier (get_symbol_lock_name (lock_name));
 		}
 		return l;
@@ -4900,7 +4900,7 @@ public abstract class Vala.CCodeBaseModule : CodeGenerator {
 	}
 
 	string generate_array_contains_wrapper (ArrayType array_type) {
-		string array_contains_func = "_vala_%s_array_contains".printf (array_type.element_type.get_lower_case_cname ());
+		string array_contains_func = "_vala_%s_array_contains".printf (get_ccode_lower_case_name (array_type.element_type));
 
 		if (!add_wrapper (array_contains_func)) {
 			return array_contains_func;
@@ -5291,7 +5291,7 @@ public abstract class Vala.CCodeBaseModule : CodeGenerator {
 			if (prop.base_property != null) {
 				var base_class = (Class) prop.base_property.parent_symbol;
 				var vcast = new CCodeFunctionCall (new CCodeIdentifier ("%s_CLASS".printf (base_class.get_upper_case_cname (null))));
-				vcast.add_argument (new CCodeIdentifier ("%s_parent_class".printf (current_class.get_lower_case_cname (null))));
+				vcast.add_argument (new CCodeIdentifier ("%s_parent_class".printf (get_ccode_lower_case_name (current_class, null))));
 				
 				var ccall = new CCodeFunctionCall (new CCodeMemberAccess.pointer (vcast, "set_%s".printf (prop.name)));
 				ccall.add_argument ((CCodeExpression) get_ccodenode (instance));
@@ -5300,7 +5300,7 @@ public abstract class Vala.CCodeBaseModule : CodeGenerator {
 				ccode.add_expression (ccall);
 			} else if (prop.base_interface_property != null) {
 				var base_iface = (Interface) prop.base_interface_property.parent_symbol;
-				string parent_iface_var = "%s_%s_parent_iface".printf (current_class.get_lower_case_cname (null), base_iface.get_lower_case_cname (null));
+				string parent_iface_var = "%s_%s_parent_iface".printf (get_ccode_lower_case_name (current_class), get_ccode_lower_case_name (base_iface));
 
 				var ccall = new CCodeFunctionCall (new CCodeMemberAccess.pointer (new CCodeIdentifier (parent_iface_var), "set_%s".printf (prop.name)));
 				ccall.add_argument ((CCodeExpression) get_ccodenode (instance));
@@ -5574,6 +5574,38 @@ public abstract class Vala.CCodeBaseModule : CodeGenerator {
 		return get_ccode_attribute(iface).type_name;
 	}
 
+	public static string get_ccode_lower_case_name (CodeNode node, string? infix = null) {
+		var sym = node as Symbol;
+		if (sym != null) {
+			if (infix == null) {
+				infix = "";
+			}
+			if (sym is Delegate) {
+				return "%s%s%s".printf (get_ccode_lower_case_prefix (sym.parent_symbol), infix, Symbol.camel_case_to_lower_case (sym.name));
+			} else if (sym is ErrorCode) {
+				return get_ccode_name (sym).down ();
+			} else {
+				return "%s%s%s".printf (get_ccode_lower_case_prefix (sym.parent_symbol), infix, get_ccode_lower_case_suffix (sym));
+			}
+		} else if (node is ErrorType) {
+			var type = (ErrorType) node;
+			if (type.error_domain == null) {
+				if (infix == null) {
+					return "g_error";
+				} else {
+					return "g_%s_error".printf (infix);
+				}
+			} else if (type.error_code == null) {
+				return get_ccode_lower_case_name (type.error_domain, infix);
+			} else {
+				return get_ccode_lower_case_name (type.error_code, infix);
+			}
+		} else {
+			var type = (DataType) node;
+			return get_ccode_lower_case_name (type.data_type, infix);
+		}
+	}
+
 	public static List<string> get_ccode_header_filenames (Symbol sym) {
 		return get_ccode_attribute(sym).header_filenames;
 	}
@@ -5990,7 +6022,7 @@ public class Vala.CCodeAttribute : AttributeCache {
 		}
 	}
 
-	public string get_lower_case_prefix {
+	public string lower_case_prefix {
 		get {
 			if (_lower_case_prefix == null) {
 				_lower_case_prefix = get_default_lower_case_prefix ();
@@ -5999,7 +6031,7 @@ public class Vala.CCodeAttribute : AttributeCache {
 		}
 	}
 
-	public string get_lower_case_suffix {
+	public string lower_case_suffix {
 		get {
 			if (_lower_case_suffix == null) {
 				_lower_case_suffix = get_default_lower_case_suffix ();
@@ -6090,7 +6122,7 @@ public class Vala.CCodeAttribute : AttributeCache {
 			} else if (sym is Signal) {
 				return Symbol.camel_case_to_lower_case (sym.name);
 			} else {
-				return "%s%s".printf (get_ccode_prefix (sym.parent_symbol), sym.name);
+				return "%s%s".printf (CCodeBaseModule.get_ccode_prefix (sym.parent_symbol), sym.name);
 			}
 		} else if (node is ObjectType) {
 			var type = (ObjectType) node;
@@ -6208,7 +6240,7 @@ public class Vala.CCodeAttribute : AttributeCache {
 		return "";
 	}
 
-	private string get_lower_case_prefix () {
+	private string get_default_lower_case_prefix () {
 		if (sym is Namespace) {
 			if (sym.name == null) {
 				return "";
@@ -6216,7 +6248,7 @@ public class Vala.CCodeAttribute : AttributeCache {
 				return "%s%s_".printf (CCodeBaseModule.get_ccode_lower_case_prefix (sym.parent_symbol), Symbol.camel_case_to_lower_case (sym.name));
 			}
 		} else {
-			return "%s_".printf (sym.get_lower_case_cname (null));
+			return "%s_".printf (CCodeBaseModule.get_ccode_lower_case_name (sym));
 		}
 	}
 
diff --git a/codegen/valaccodememberaccessmodule.vala b/codegen/valaccodememberaccessmodule.vala
index 03faf35..01109ae 100644
--- a/codegen/valaccodememberaccessmodule.vala
+++ b/codegen/valaccodememberaccessmodule.vala
@@ -52,13 +52,13 @@ public abstract class Vala.CCodeMemberAccessModule : CCodeControlFlowModule {
 				if (m.base_method != null) {
 					var base_class = (Class) m.base_method.parent_symbol;
 					var vcast = new CCodeFunctionCall (new CCodeIdentifier ("%s_CLASS".printf (base_class.get_upper_case_cname (null))));
-					vcast.add_argument (new CCodeIdentifier ("%s_parent_class".printf (current_class.get_lower_case_cname (null))));
+					vcast.add_argument (new CCodeIdentifier ("%s_parent_class".printf (get_ccode_lower_case_name (current_class, null))));
 					
 					set_cvalue (expr, new CCodeMemberAccess.pointer (vcast, m.vfunc_name));
 					return;
 				} else if (m.base_interface_method != null) {
 					var base_iface = (Interface) m.base_interface_method.parent_symbol;
-					string parent_iface_var = "%s_%s_parent_iface".printf (current_class.get_lower_case_cname (null), base_iface.get_lower_case_cname (null));
+					string parent_iface_var = "%s_%s_parent_iface".printf (get_ccode_lower_case_name (current_class), get_ccode_lower_case_name (base_iface));
 
 					set_cvalue (expr, new CCodeMemberAccess.pointer (new CCodeIdentifier (parent_iface_var), m.vfunc_name));
 					return;
@@ -180,7 +180,7 @@ public abstract class Vala.CCodeMemberAccessModule : CCodeControlFlowModule {
 				if (prop.base_property != null) {
 					var base_class = (Class) prop.base_property.parent_symbol;
 					var vcast = new CCodeFunctionCall (new CCodeIdentifier ("%s_CLASS".printf (base_class.get_upper_case_cname (null))));
-					vcast.add_argument (new CCodeIdentifier ("%s_parent_class".printf (current_class.get_lower_case_cname (null))));
+					vcast.add_argument (new CCodeIdentifier ("%s_parent_class".printf (get_ccode_lower_case_name (current_class, null))));
 					
 					var ccall = new CCodeFunctionCall (new CCodeMemberAccess.pointer (vcast, "get_%s".printf (prop.name)));
 					ccall.add_argument (get_cvalue (expr.inner));
@@ -188,7 +188,7 @@ public abstract class Vala.CCodeMemberAccessModule : CCodeControlFlowModule {
 					return;
 				} else if (prop.base_interface_property != null) {
 					var base_iface = (Interface) prop.base_interface_property.parent_symbol;
-					string parent_iface_var = "%s_%s_parent_iface".printf (current_class.get_lower_case_cname (null), base_iface.get_lower_case_cname (null));
+					string parent_iface_var = "%s_%s_parent_iface".printf (get_ccode_lower_case_name (current_class), get_ccode_lower_case_name (base_iface));
 
 					var ccall = new CCodeFunctionCall (new CCodeMemberAccess.pointer (new CCodeIdentifier (parent_iface_var), "get_%s".printf (prop.name)));
 					ccall.add_argument (get_cvalue (expr.inner));
diff --git a/codegen/valaccodemethodcallmodule.vala b/codegen/valaccodemethodcallmodule.vala
index 9f5e985..8b09fb3 100644
--- a/codegen/valaccodemethodcallmodule.vala
+++ b/codegen/valaccodemethodcallmodule.vala
@@ -84,13 +84,13 @@ public class Vala.CCodeMethodCallModule : CCodeAssignmentModule {
 				if (m.base_method != null) {
 					var base_class = (Class) m.base_method.parent_symbol;
 					var vcast = new CCodeFunctionCall (new CCodeIdentifier ("%s_CLASS".printf (base_class.get_upper_case_cname (null))));
-					vcast.add_argument (new CCodeIdentifier ("%s_parent_class".printf (current_class.get_lower_case_cname (null))));
+					vcast.add_argument (new CCodeIdentifier ("%s_parent_class".printf (get_ccode_lower_case_name (current_class, null))));
 
 					async_call.call = new CCodeMemberAccess.pointer (vcast, m.vfunc_name);
 					finish_call.call = new CCodeMemberAccess.pointer (vcast, m.get_finish_vfunc_name ());
 				} else if (m.base_interface_method != null) {
 					var base_iface = (Interface) m.base_interface_method.parent_symbol;
-					string parent_iface_var = "%s_%s_parent_iface".printf (current_class.get_lower_case_cname (null), base_iface.get_lower_case_cname (null));
+					string parent_iface_var = "%s_%s_parent_iface".printf (get_ccode_lower_case_name (current_class), get_ccode_lower_case_name (base_iface));
 
 					async_call.call = new CCodeMemberAccess.pointer (new CCodeIdentifier (parent_iface_var), m.vfunc_name);
 					finish_call.call = new CCodeMemberAccess.pointer (new CCodeIdentifier (parent_iface_var), m.get_finish_vfunc_name ());
@@ -785,7 +785,7 @@ public class Vala.CCodeMethodCallModule : CCodeAssignmentModule {
 	}
 
 	private string generate_enum_tostring_function (Enum en) {
-		var to_string_func = "_%s_to_string".printf (en.get_lower_case_cname ());
+		var to_string_func = "_%s_to_string".printf (get_ccode_lower_case_name (en));
 
 		if (!add_wrapper (to_string_func)) {
 			// wrapper already defined
diff --git a/codegen/valaccodemethodmodule.vala b/codegen/valaccodemethodmodule.vala
index 1beb3d5..a79fcbb 100644
--- a/codegen/valaccodemethodmodule.vala
+++ b/codegen/valaccodemethodmodule.vala
@@ -248,7 +248,7 @@ public abstract class Vala.CCodeMethodModule : CCodeStructModule {
 			}
 		}
 
-		var register_call = new CCodeFunctionCall (new CCodeIdentifier ("%s_register_type".printf (type_symbol.get_lower_case_cname (null))));
+		var register_call = new CCodeFunctionCall (new CCodeIdentifier ("%s_register_type".printf (get_ccode_lower_case_name (type_symbol, null))));
 		register_call.add_argument (new CCodeIdentifier (module_init_param_name));
 		ccode.add_expression (register_call);
 	}
@@ -532,7 +532,7 @@ public abstract class Vala.CCodeMethodModule : CCodeStructModule {
 
 						if (cl.base_class == null) {
 							// derived compact classes do not have fields
-							var cinitcall = new CCodeFunctionCall (new CCodeIdentifier ("%s_instance_init".printf (cl.get_lower_case_cname (null))));
+							var cinitcall = new CCodeFunctionCall (new CCodeIdentifier ("%s_instance_init".printf (get_ccode_lower_case_name (cl, null))));
 							cinitcall.add_argument (new CCodeIdentifier ("self"));
 							ccode.add_expression (cinitcall);
 						}
diff --git a/codegen/valaccodestructmodule.vala b/codegen/valaccodestructmodule.vala
index a6bb108..13254c8 100644
--- a/codegen/valaccodestructmodule.vala
+++ b/codegen/valaccodestructmodule.vala
@@ -49,7 +49,7 @@ public abstract class Vala.CCodeStructModule : CCodeBaseModule {
 		if (context.profile == Profile.GOBJECT) {
 			if (st.has_type_id) {
 				decl_space.add_type_declaration (new CCodeNewline ());
-				var macro = "(%s_get_type ())".printf (st.get_lower_case_cname (null));
+				var macro = "(%s_get_type ())".printf (get_ccode_lower_case_name (st, null));
 				decl_space.add_type_declaration (new CCodeMacroReplacement (st.get_type_id (), macro));
 
 				var type_fun = new StructRegisterFunction (st, context);
diff --git a/codegen/valaclassregisterfunction.vala b/codegen/valaclassregisterfunction.vala
index 73660c3..274661f 100644
--- a/codegen/valaclassregisterfunction.vala
+++ b/codegen/valaclassregisterfunction.vala
@@ -52,7 +52,7 @@ public class Vala.ClassRegisterFunction : TypeRegisterFunction {
 
 	public override string get_base_init_func_name () {
 		if (class_reference.class_constructor != null || (!context.require_glib_version (2, 24) && class_reference.has_class_private_fields)) {
-			return "%s_base_init".printf (class_reference.get_lower_case_cname (null));
+			return "%s_base_init".printf (CCodeBaseModule.get_ccode_lower_case_name (class_reference, null));
 		} else {
 			return "NULL";
 		}
@@ -60,7 +60,7 @@ public class Vala.ClassRegisterFunction : TypeRegisterFunction {
 
 	public override string get_class_finalize_func_name () {
 		if (class_reference.static_destructor != null) {
-			return "%s_class_finalize".printf (class_reference.get_lower_case_cname (null));
+			return "%s_class_finalize".printf (CCodeBaseModule.get_ccode_lower_case_name (class_reference, null));
 		} else {
 			return "NULL";
 		}
@@ -68,14 +68,14 @@ public class Vala.ClassRegisterFunction : TypeRegisterFunction {
 
 	public override string get_base_finalize_func_name () {
 		if (class_reference.class_destructor != null || (!context.require_glib_version (2, 24) && class_reference.has_class_private_fields)) {
-			return "%s_base_finalize".printf (class_reference.get_lower_case_cname (null));
+			return "%s_base_finalize".printf (CCodeBaseModule.get_ccode_lower_case_name (class_reference, null));
 		} else {
 			return "NULL";
 		}
 	}
 
 	public override string get_class_init_func_name () {
-		return "%s_class_init".printf (class_reference.get_lower_case_cname (null));
+		return "%s_class_init".printf (CCodeBaseModule.get_ccode_lower_case_name (class_reference, null));
 	}
 	
 	public override string get_instance_struct_size () {
@@ -83,7 +83,7 @@ public class Vala.ClassRegisterFunction : TypeRegisterFunction {
 	}
 	
 	public override string get_instance_init_func_name () {
-		return "%s_instance_init".printf (class_reference.get_lower_case_cname (null));
+		return "%s_instance_init".printf (CCodeBaseModule.get_ccode_lower_case_name (class_reference, null));
 	}
 	
 	public override string get_parent_type_name () {
@@ -105,7 +105,7 @@ public class Vala.ClassRegisterFunction : TypeRegisterFunction {
 	public override string? get_gtype_value_table_init_function_name () {
 		bool is_fundamental = !class_reference.is_compact && class_reference.base_class == null;
 		if ( is_fundamental )
-			return "%s_init".printf (class_reference.get_lower_case_cname ("value_"));
+			return "%s_init".printf (CCodeBaseModule.get_ccode_lower_case_name (class_reference, "value_"));
 
 		return null;
 	}
@@ -113,7 +113,7 @@ public class Vala.ClassRegisterFunction : TypeRegisterFunction {
 	public override string? get_gtype_value_table_free_function_name () {
 		bool is_fundamental = !class_reference.is_compact && class_reference.base_class == null;
 		if ( is_fundamental )
-			return "%s_free_value".printf (class_reference.get_lower_case_cname ("value_"));
+			return "%s_free_value".printf (CCodeBaseModule.get_ccode_lower_case_name (class_reference, "value_"));
 
 		return null;
 	}
@@ -121,7 +121,7 @@ public class Vala.ClassRegisterFunction : TypeRegisterFunction {
 	public override string? get_gtype_value_table_copy_function_name () {
 		bool is_fundamental = !class_reference.is_compact && class_reference.base_class == null;
 		if ( is_fundamental )
-			return "%s_copy_value".printf (class_reference.get_lower_case_cname ("value_"));
+			return "%s_copy_value".printf (CCodeBaseModule.get_ccode_lower_case_name (class_reference, "value_"));
 
 		return null;
 	}
@@ -129,7 +129,7 @@ public class Vala.ClassRegisterFunction : TypeRegisterFunction {
 	public override string? get_gtype_value_table_peek_pointer_function_name () {
 		bool is_fundamental = !class_reference.is_compact && class_reference.base_class == null;
 		if ( is_fundamental )
-			return "%s_peek_pointer".printf (class_reference.get_lower_case_cname ("value_"));
+			return "%s_peek_pointer".printf (CCodeBaseModule.get_ccode_lower_case_name (class_reference, "value_"));
 
 		return null;
 	}
@@ -137,7 +137,7 @@ public class Vala.ClassRegisterFunction : TypeRegisterFunction {
 	public override string? get_gtype_value_table_collect_value_function_name () {
 		bool is_fundamental = !class_reference.is_compact && class_reference.base_class == null;
 		if ( is_fundamental )
-			return "%s_collect_value".printf (class_reference.get_lower_case_cname ("value_"));
+			return "%s_collect_value".printf (CCodeBaseModule.get_ccode_lower_case_name (class_reference, "value_"));
 
 		return null;
 	}
@@ -145,7 +145,7 @@ public class Vala.ClassRegisterFunction : TypeRegisterFunction {
 	public override string? get_gtype_value_table_lcopy_value_function_name () {
 		bool is_fundamental = !class_reference.is_compact && class_reference.base_class == null;
 		if ( is_fundamental )
-			return "%s_lcopy_value".printf (class_reference.get_lower_case_cname ("value_"));
+			return "%s_lcopy_value".printf (CCodeBaseModule.get_ccode_lower_case_name (class_reference, "value_"));
 
 		return null;
 	}
@@ -160,11 +160,11 @@ public class Vala.ClassRegisterFunction : TypeRegisterFunction {
 			
 			var iface = (Interface) base_type.data_type;
 			
-			var iface_info_name = "%s_info".printf (iface.get_lower_case_cname (null));
+			var iface_info_name = "%s_info".printf (CCodeBaseModule.get_ccode_lower_case_name (iface, null));
 			
 			var ctypedecl = new CCodeDeclaration ("const GInterfaceInfo");
 			ctypedecl.modifiers = CCodeModifiers.STATIC;
-			ctypedecl.add_declarator (new CCodeVariableDeclarator (iface_info_name, new CCodeConstant ("{ (GInterfaceInitFunc) %s_%s_interface_init, (GInterfaceFinalizeFunc) NULL, NULL}".printf (class_reference.get_lower_case_cname (null), iface.get_lower_case_cname (null)))));
+			ctypedecl.add_declarator (new CCodeVariableDeclarator (iface_info_name, new CCodeConstant ("{ (GInterfaceInitFunc) %s_%s_interface_init, (GInterfaceFinalizeFunc) NULL, NULL}".printf (CCodeBaseModule.get_ccode_lower_case_name (class_reference), CCodeBaseModule.get_ccode_lower_case_name (iface)))));
 			frag.append (ctypedecl);
 		}
 		
@@ -179,17 +179,17 @@ public class Vala.ClassRegisterFunction : TypeRegisterFunction {
 			
 			var iface = (Interface) base_type.data_type;
 			
-			var iface_info_name = "%s_info".printf (iface.get_lower_case_cname (null));
+			var iface_info_name = "%s_info".printf (CCodeBaseModule.get_ccode_lower_case_name (iface, null));
 			if (!plugin) {
 				var reg_call = new CCodeFunctionCall (new CCodeIdentifier ("g_type_add_interface_static"));
-				reg_call.add_argument (new CCodeIdentifier ("%s_type_id".printf (class_reference.get_lower_case_cname (null))));
+				reg_call.add_argument (new CCodeIdentifier ("%s_type_id".printf (CCodeBaseModule.get_ccode_lower_case_name (class_reference, null))));
 				reg_call.add_argument (new CCodeIdentifier (iface.get_type_id ()));
 				reg_call.add_argument (new CCodeIdentifier ("&%s".printf (iface_info_name)));
 				block.add_statement (new CCodeExpressionStatement (reg_call));
 			} else {
 				var reg_call = new CCodeFunctionCall (new CCodeIdentifier ("g_type_module_add_interface"));
 				reg_call.add_argument (new CCodeIdentifier ("module"));
-				reg_call.add_argument (new CCodeIdentifier ("%s_type_id".printf (class_reference.get_lower_case_cname (null))));
+				reg_call.add_argument (new CCodeIdentifier ("%s_type_id".printf (CCodeBaseModule.get_ccode_lower_case_name (class_reference, null))));
 				reg_call.add_argument (new CCodeIdentifier (iface.get_type_id ()));
 				reg_call.add_argument (new CCodeIdentifier ("&%s".printf (iface_info_name)));
 				block.add_statement (new CCodeExpressionStatement (reg_call));
diff --git a/codegen/valagdbusclientmodule.vala b/codegen/valagdbusclientmodule.vala
index 2551276..1a23d7e 100644
--- a/codegen/valagdbusclientmodule.vala
+++ b/codegen/valagdbusclientmodule.vala
@@ -383,7 +383,7 @@ public class Vala.GDBusClientModule : GDBusModule {
 	}
 
 	string generate_dbus_signal_handler (Signal sig, ObjectTypeSymbol sym) {
-		string wrapper_name = "_dbus_handle_%s_%s".printf (sym.get_lower_case_cname (), get_ccode_name (sig));
+		string wrapper_name = "_dbus_handle_%s_%s".printf (get_ccode_lower_case_name (sym), get_ccode_name (sig));
 
 		var function = new CCodeFunction (wrapper_name);
 		function.modifiers = CCodeModifiers.STATIC;
@@ -1106,7 +1106,7 @@ public class Vala.GDBusClientModule : GDBusModule {
 		var proxy_type = new CCodeIdentifier (get_ccode_lower_case_prefix (sym) + "proxy_get_type");
 
 		var set_qdata = new CCodeFunctionCall (new CCodeIdentifier ("g_type_set_qdata"));
-		set_qdata.add_argument (new CCodeIdentifier ("%s_type_id".printf (sym.get_lower_case_cname (null))));
+		set_qdata.add_argument (new CCodeIdentifier ("%s_type_id".printf (get_ccode_lower_case_name (sym, null))));
 		set_qdata.add_argument (quark);
 		set_qdata.add_argument (new CCodeCastExpression (proxy_type, "void*"));
 
@@ -1116,7 +1116,7 @@ public class Vala.GDBusClientModule : GDBusModule {
 		quark.add_argument (new CCodeConstant ("\"vala-dbus-interface-name\""));
 
 		set_qdata = new CCodeFunctionCall (new CCodeIdentifier ("g_type_set_qdata"));
-		set_qdata.add_argument (new CCodeIdentifier ("%s_type_id".printf (sym.get_lower_case_cname (null))));
+		set_qdata.add_argument (new CCodeIdentifier ("%s_type_id".printf (get_ccode_lower_case_name (sym, null))));
 		set_qdata.add_argument (quark);
 		set_qdata.add_argument (new CCodeConstant ("\"%s\"".printf (dbus_iface_name)));
 
diff --git a/codegen/valagdbusmodule.vala b/codegen/valagdbusmodule.vala
index cabef3b..095340d 100644
--- a/codegen/valagdbusmodule.vala
+++ b/codegen/valagdbusmodule.vala
@@ -80,7 +80,7 @@ public class Vala.GDBusModule : GVariantModule {
 		}
 
 		var cdecl = new CCodeDeclaration ("const GDBusErrorEntry");
-		cdecl.add_declarator (new CCodeVariableDeclarator (edomain.get_lower_case_cname () + "_entries[]", error_entries));
+		cdecl.add_declarator (new CCodeVariableDeclarator (get_ccode_lower_case_name (edomain) + "_entries[]", error_entries));
 		cdecl.modifiers = CCodeModifiers.STATIC;
 		cfile.add_constant_declaration (cdecl);
 
@@ -94,11 +94,11 @@ public class Vala.GDBusModule : GVariantModule {
 		ccode.add_declaration ("gsize", new CCodeVariableDeclarator (quark_name, new CCodeConstant ("0")), CCodeModifiers.STATIC | CCodeModifiers.VOLATILE);
 
 		var register_call = new CCodeFunctionCall (new CCodeIdentifier ("g_dbus_error_register_error_domain"));
-		register_call.add_argument (new CCodeConstant ("\"" + edomain.get_lower_case_cname () + "-quark\""));
+		register_call.add_argument (new CCodeConstant ("\"" + get_ccode_lower_case_name (edomain) + "-quark\""));
 		register_call.add_argument (new CCodeUnaryExpression (CCodeUnaryOperator.ADDRESS_OF, new CCodeIdentifier (quark_name)));
-		register_call.add_argument (new CCodeIdentifier (edomain.get_lower_case_cname () + "_entries"));
+		register_call.add_argument (new CCodeIdentifier (get_ccode_lower_case_name (edomain) + "_entries"));
 		var nentries = new CCodeFunctionCall (new CCodeIdentifier ("G_N_ELEMENTS"));
-		nentries.add_argument (new CCodeIdentifier (edomain.get_lower_case_cname () + "_entries"));
+		nentries.add_argument (new CCodeIdentifier (get_ccode_lower_case_name (edomain) + "_entries"));
 		register_call.add_argument (nentries);
 		ccode.add_expression (register_call);
 
diff --git a/codegen/valagdbusservermodule.vala b/codegen/valagdbusservermodule.vala
index 7ceb7a1..ce9279e 100644
--- a/codegen/valagdbusservermodule.vala
+++ b/codegen/valagdbusservermodule.vala
@@ -418,7 +418,7 @@ public class Vala.GDBusServerModule : GDBusClientModule {
 	}
 
 	string generate_dbus_signal_wrapper (Signal sig, ObjectTypeSymbol sym, string dbus_iface_name) {
-		string wrapper_name = "_dbus_%s_%s".printf (sym.get_lower_case_cname (), get_ccode_name (sig));
+		string wrapper_name = "_dbus_%s_%s".printf (get_ccode_lower_case_name (sym), get_ccode_name (sig));
 
 		var function = new CCodeFunction (wrapper_name, "void");
 		function.modifiers = CCodeModifiers.STATIC;
@@ -1310,7 +1310,7 @@ public class Vala.GDBusServerModule : GDBusClientModule {
 		quark.add_argument (new CCodeConstant ("\"vala-dbus-register-object\""));
 
 		var set_qdata = new CCodeFunctionCall (new CCodeIdentifier ("g_type_set_qdata"));
-		set_qdata.add_argument (new CCodeIdentifier ("%s_type_id".printf (sym.get_lower_case_cname (null))));
+		set_qdata.add_argument (new CCodeIdentifier ("%s_type_id".printf (get_ccode_lower_case_name (sym, null))));
 		set_qdata.add_argument (quark);
 		set_qdata.add_argument (new CCodeCastExpression (new CCodeIdentifier (get_ccode_lower_case_prefix (sym) + "register_object"), "void*"));
 
diff --git a/codegen/valagerrormodule.vala b/codegen/valagerrormodule.vala
index 85d4804..cbad76a 100644
--- a/codegen/valagerrormodule.vala
+++ b/codegen/valagerrormodule.vala
@@ -76,7 +76,7 @@ public class Vala.GErrorModule : CCodeDelegateModule {
 		push_function (cquark_fun);
 
 		var cquark_call = new CCodeFunctionCall (new CCodeIdentifier ("g_quark_from_static_string"));
-		cquark_call.add_argument (new CCodeConstant ("\"" + edomain.get_lower_case_cname () + "-quark\""));
+		cquark_call.add_argument (new CCodeConstant ("\"" + get_ccode_lower_case_name (edomain) + "-quark\""));
 
 		ccode.add_return (cquark_call);
 
@@ -304,7 +304,7 @@ public class Vala.GErrorModule : CCodeDelegateModule {
 		is_in_catch = true;
 
 		foreach (CatchClause clause in stmt.get_catch_clauses ()) {
-			clause.clabel_name = "__catch%d_%s".printf (this_try_id, clause.error_type.get_lower_case_cname ());
+			clause.clabel_name = "__catch%d_%s".printf (this_try_id, get_ccode_lower_case_name (clause.error_type));
 		}
 
 		is_in_catch = false;
diff --git a/codegen/valagobjectmodule.vala b/codegen/valagobjectmodule.vala
index 8ce9c7d..5960378 100644
--- a/codegen/valagobjectmodule.vala
+++ b/codegen/valagobjectmodule.vala
@@ -51,24 +51,24 @@ public class Vala.GObjectModule : GTypeModule {
 		var ccall = new CCodeFunctionCall (new CCodeIdentifier ("G_OBJECT_CLASS"));
 		ccall.add_argument (new CCodeIdentifier ("klass"));
 		if (class_has_readable_properties (cl) || cl.get_type_parameters ().size > 0) {
-			ccode.add_assignment (new CCodeMemberAccess.pointer (ccall, "get_property"), new CCodeIdentifier ("_vala_%s_get_property".printf (cl.get_lower_case_cname (null))));
+			ccode.add_assignment (new CCodeMemberAccess.pointer (ccall, "get_property"), new CCodeIdentifier ("_vala_%s_get_property".printf (get_ccode_lower_case_name (cl, null))));
 		}
 		if (class_has_writable_properties (cl) || cl.get_type_parameters ().size > 0) {
-			ccode.add_assignment (new CCodeMemberAccess.pointer (ccall, "set_property"), new CCodeIdentifier ("_vala_%s_set_property".printf (cl.get_lower_case_cname (null))));
+			ccode.add_assignment (new CCodeMemberAccess.pointer (ccall, "set_property"), new CCodeIdentifier ("_vala_%s_set_property".printf (get_ccode_lower_case_name (cl, null))));
 		}
 	
 		/* set constructor */
 		if (cl.constructor != null) {
 			var ccast = new CCodeFunctionCall (new CCodeIdentifier ("G_OBJECT_CLASS"));
 			ccast.add_argument (new CCodeIdentifier ("klass"));
-			ccode.add_assignment (new CCodeMemberAccess.pointer (ccast, "constructor"), new CCodeIdentifier ("%s_constructor".printf (cl.get_lower_case_cname (null))));
+			ccode.add_assignment (new CCodeMemberAccess.pointer (ccast, "constructor"), new CCodeIdentifier ("%s_constructor".printf (get_ccode_lower_case_name (cl, null))));
 		}
 
 		/* set finalize function */
 		if (cl.get_fields ().size > 0 || cl.destructor != null) {
 			var ccast = new CCodeFunctionCall (new CCodeIdentifier ("G_OBJECT_CLASS"));
 			ccast.add_argument (new CCodeIdentifier ("klass"));
-			ccode.add_assignment (new CCodeMemberAccess.pointer (ccast, "finalize"), new CCodeIdentifier ("%s_finalize".printf (cl.get_lower_case_cname (null))));
+			ccode.add_assignment (new CCodeMemberAccess.pointer (ccast, "finalize"), new CCodeIdentifier ("%s_finalize".printf (get_ccode_lower_case_name (cl, null))));
 		}
 
 		/* create type, dup_func, and destroy_func properties for generic types */
@@ -79,7 +79,7 @@ public class Vala.GObjectModule : GTypeModule {
 
 			func_name = "%s_type".printf (type_param.name.down ());
 			func_name_constant = new CCodeConstant ("\"%s-type\"".printf (type_param.name.down ()));
-			enum_value = "%s_%s".printf (cl.get_lower_case_cname (null), func_name).up ();
+			enum_value = "%s_%s".printf (get_ccode_lower_case_name (cl, null), func_name).up ();
 			cinst = new CCodeFunctionCall (new CCodeIdentifier ("g_object_class_install_property"));
 			cinst.add_argument (ccall);
 			cinst.add_argument (new CCodeConstant (enum_value));
@@ -96,7 +96,7 @@ public class Vala.GObjectModule : GTypeModule {
 
 			func_name = "%s_dup_func".printf (type_param.name.down ());
 			func_name_constant = new CCodeConstant ("\"%s-dup-func\"".printf (type_param.name.down ()));
-			enum_value = "%s_%s".printf (cl.get_lower_case_cname (null), func_name).up ();
+			enum_value = "%s_%s".printf (get_ccode_lower_case_name (cl, null), func_name).up ();
 			cinst = new CCodeFunctionCall (new CCodeIdentifier ("g_object_class_install_property"));
 			cinst.add_argument (ccall);
 			cinst.add_argument (new CCodeConstant (enum_value));
@@ -112,7 +112,7 @@ public class Vala.GObjectModule : GTypeModule {
 
 			func_name = "%s_destroy_func".printf (type_param.name.down ());
 			func_name_constant = new CCodeConstant ("\"%s-destroy-func\"".printf (type_param.name.down ()));
-			enum_value = "%s_%s".printf (cl.get_lower_case_cname (null), func_name).up ();
+			enum_value = "%s_%s".printf (get_ccode_lower_case_name (cl, null), func_name).up ();
 			cinst = new CCodeFunctionCall (new CCodeIdentifier ("g_object_class_install_property"));
 			cinst.add_argument (ccall);
 			cinst.add_argument (new CCodeConstant (enum_value));
@@ -174,7 +174,7 @@ public class Vala.GObjectModule : GTypeModule {
 	}
 
 	private void add_get_property_function (Class cl) {
-		var get_prop = new CCodeFunction ("_vala_%s_get_property".printf (cl.get_lower_case_cname (null)), "void");
+		var get_prop = new CCodeFunction ("_vala_%s_get_property".printf (get_ccode_lower_case_name (cl, null)), "void");
 		get_prop.modifiers = CCodeModifiers.STATIC;
 		get_prop.add_parameter (new CCodeParameter ("object", "GObject *"));
 		get_prop.add_parameter (new CCodeParameter ("property_id", "guint"));
@@ -274,7 +274,7 @@ public class Vala.GObjectModule : GTypeModule {
 	}
 	
 	private void add_set_property_function (Class cl) {
-		var set_prop = new CCodeFunction ("_vala_%s_set_property".printf (cl.get_lower_case_cname (null)), "void");
+		var set_prop = new CCodeFunction ("_vala_%s_set_property".printf (get_ccode_lower_case_name (cl, null)), "void");
 		set_prop.modifiers = CCodeModifiers.STATIC;
 		set_prop.add_parameter (new CCodeParameter ("object", "GObject *"));
 		set_prop.add_parameter (new CCodeParameter ("property_id", "guint"));
@@ -350,7 +350,7 @@ public class Vala.GObjectModule : GTypeModule {
 			CCodeFunctionCall cgetcall;
 
 			func_name = "%s_type".printf (type_param.name.down ());
-			enum_value = "%s_%s".printf (cl.get_lower_case_cname (null), func_name).up ();
+			enum_value = "%s_%s".printf (get_ccode_lower_case_name (cl, null), func_name).up ();
 			ccode.add_case (new CCodeIdentifier (enum_value));
 			cfield = new CCodeMemberAccess.pointer (new CCodeMemberAccess.pointer (new CCodeIdentifier ("self"), "priv"), func_name);
 			cgetcall = new CCodeFunctionCall (new CCodeIdentifier ("g_value_get_gtype"));
@@ -359,7 +359,7 @@ public class Vala.GObjectModule : GTypeModule {
 			ccode.add_break ();
 
 			func_name = "%s_dup_func".printf (type_param.name.down ());
-			enum_value = "%s_%s".printf (cl.get_lower_case_cname (null), func_name).up ();
+			enum_value = "%s_%s".printf (get_ccode_lower_case_name (cl, null), func_name).up ();
 			ccode.add_case (new CCodeIdentifier (enum_value));
 			cfield = new CCodeMemberAccess.pointer (new CCodeMemberAccess.pointer (new CCodeIdentifier ("self"), "priv"), func_name);
 			cgetcall = new CCodeFunctionCall (new CCodeIdentifier ("g_value_get_pointer"));
@@ -368,7 +368,7 @@ public class Vala.GObjectModule : GTypeModule {
 			ccode.add_break ();
 
 			func_name = "%s_destroy_func".printf (type_param.name.down ());
-			enum_value = "%s_%s".printf (cl.get_lower_case_cname (null), func_name).up ();
+			enum_value = "%s_%s".printf (get_ccode_lower_case_name (cl, null), func_name).up ();
 			ccode.add_case (new CCodeIdentifier (enum_value));
 			cfield = new CCodeMemberAccess.pointer (new CCodeMemberAccess.pointer (new CCodeIdentifier ("self"), "priv"), func_name);
 			cgetcall = new CCodeFunctionCall (new CCodeIdentifier ("g_value_get_pointer"));
@@ -415,7 +415,7 @@ public class Vala.GObjectModule : GTypeModule {
 
 			push_context (new EmitContext (c));
 
-			var function = new CCodeFunction ("%s_constructor".printf (cl.get_lower_case_cname (null)), "GObject *");
+			var function = new CCodeFunction ("%s_constructor".printf (get_ccode_lower_case_name (cl, null)), "GObject *");
 			function.modifiers = CCodeModifiers.STATIC;
 		
 			function.add_parameter (new CCodeParameter ("type", "GType"));
@@ -430,7 +430,7 @@ public class Vala.GObjectModule : GTypeModule {
 			ccode.add_declaration ("GObjectClass *", new CCodeVariableDeclarator ("parent_class"));
 
 			var ccast = new CCodeFunctionCall (new CCodeIdentifier ("G_OBJECT_CLASS"));
-			ccast.add_argument (new CCodeIdentifier ("%s_parent_class".printf (cl.get_lower_case_cname (null))));
+			ccast.add_argument (new CCodeIdentifier ("%s_parent_class".printf (get_ccode_lower_case_name (cl, null))));
 			ccode.add_assignment (new CCodeIdentifier ("parent_class"), ccast);
 
 			var ccall = new CCodeFunctionCall (new CCodeMemberAccess.pointer (new CCodeIdentifier ("parent_class"), "constructor"));
diff --git a/codegen/valagsignalmodule.vala b/codegen/valagsignalmodule.vala
index dfadc76..d5496b6 100644
--- a/codegen/valagsignalmodule.vala
+++ b/codegen/valagsignalmodule.vala
@@ -502,14 +502,14 @@ public class Vala.GSignalModule : GObjectModule {
 				var m = sig.default_handler;
 				var base_class = (Class) m.parent_symbol;
 				var vcast = new CCodeFunctionCall (new CCodeIdentifier ("%s_CLASS".printf (base_class.get_upper_case_cname (null))));
-				vcast.add_argument (new CCodeIdentifier ("%s_parent_class".printf (current_class.get_lower_case_cname (null))));
+				vcast.add_argument (new CCodeIdentifier ("%s_parent_class".printf (get_ccode_lower_case_name (current_class))));
 				
 				set_cvalue (expr, new CCodeMemberAccess.pointer (vcast, m.name));
 				return;
 			}
 
 			if (sig.has_emitter) {
-				var ccall = new CCodeFunctionCall (new CCodeIdentifier ("%s_%s".printf (cl.get_lower_case_cname (null), sig.name)));
+				var ccall = new CCodeFunctionCall (new CCodeIdentifier ("%s_%s".printf (get_ccode_lower_case_name (cl), sig.name)));
 
 				ccall.add_argument (pub_inst);
 				set_cvalue (expr, ccall);
diff --git a/codegen/valagtypemodule.vala b/codegen/valagtypemodule.vala
index 5c5f27a..515169a 100644
--- a/codegen/valagtypemodule.vala
+++ b/codegen/valagtypemodule.vala
@@ -63,7 +63,7 @@ public class Vala.GTypeModule : GErrorModule {
 
 		if (is_gtypeinstance) {
 			decl_space.add_type_declaration (new CCodeNewline ());
-			var macro = "(%s_get_type ())".printf (cl.get_lower_case_cname (null));
+			var macro = "(%s_get_type ())".printf (get_ccode_lower_case_name (cl, null));
 			decl_space.add_type_declaration (new CCodeMacroReplacement (cl.get_type_id (), macro));
 
 			macro = "(G_TYPE_CHECK_INSTANCE_CAST ((obj), %s, %s))".printf (cl.get_type_id (), get_ccode_name (cl));
@@ -104,7 +104,7 @@ public class Vala.GTypeModule : GErrorModule {
 			decl_space.add_function_declaration (unref_fun);
 
 			// GParamSpec and GValue functions
-			string function_name = cl.get_lower_case_cname ("param_spec_");
+			string function_name = get_ccode_lower_case_name (cl, "param_spec_");
 
 			var function = new CCodeFunction (function_name, "GParamSpec*");
 			function.add_parameter (new CCodeParameter ("name", "const gchar*"));
@@ -491,7 +491,7 @@ public class Vala.GTypeModule : GErrorModule {
 				decl_space.add_type_declaration (new CCodeTypeDefinition ("struct %s".printf (type_priv_struct.name), new CCodeVariableDeclarator ("%sClassPrivate".printf (get_ccode_name (cl)))));
 				if (!context.require_glib_version (2, 24)) {
 					var cdecl = new CCodeDeclaration ("GQuark");
-					cdecl.add_declarator (new CCodeVariableDeclarator ("_vala_%s_class_private_quark".printf (cl.get_lower_case_cname ()), new CCodeConstant ("0")));
+					cdecl.add_declarator (new CCodeVariableDeclarator ("_vala_%s_class_private_quark".printf (get_ccode_lower_case_name (cl)), new CCodeConstant ("0")));
 					cdecl.modifiers = CCodeModifiers.STATIC;
 					decl_space.add_type_declaration (cdecl);
 				}
@@ -511,7 +511,7 @@ public class Vala.GTypeModule : GErrorModule {
 				if (context.require_glib_version (2, 24)) {
 					macro = "(G_TYPE_CLASS_GET_PRIVATE (klass, %s, %sClassPrivate))".printf (cl.get_type_id (), get_ccode_name (cl));
 				} else {
-					macro = "((%sClassPrivate *) g_type_get_qdata (G_TYPE_FROM_CLASS (klass), _vala_%s_class_private_quark))".printf (get_ccode_name (cl), cl.get_lower_case_cname ());
+					macro = "((%sClassPrivate *) g_type_get_qdata (G_TYPE_FROM_CLASS (klass), _vala_%s_class_private_quark))".printf (get_ccode_name (cl), get_ccode_lower_case_name (cl));
 				}
 				decl_space.add_type_member_declaration (new CCodeMacroReplacement ("%s_GET_CLASS_PRIVATE(klass)".printf (cl.get_upper_case_cname (null)), macro));
 			}
@@ -715,7 +715,7 @@ public class Vala.GTypeModule : GErrorModule {
 	}
 
 	private void add_type_value_table_init_function (Class cl) {
-		var function = new CCodeFunction ("%s_init".printf (cl.get_lower_case_cname ("value_")), "void");
+		var function = new CCodeFunction ("%s_init".printf (get_ccode_lower_case_name (cl, "value_")), "void");
 		function.add_parameter (new CCodeParameter ("value", "GValue*"));
 		function.modifiers = CCodeModifiers.STATIC;
 
@@ -726,7 +726,7 @@ public class Vala.GTypeModule : GErrorModule {
 	}
 
 	private void add_type_value_table_free_function (Class cl) {
-		var function = new CCodeFunction ("%s_free_value".printf (cl.get_lower_case_cname ("value_")), "void");
+		var function = new CCodeFunction ("%s_free_value".printf (get_ccode_lower_case_name (cl, "value_")), "void");
 		function.add_parameter (new CCodeParameter ("value", "GValue*"));
 		function.modifiers = CCodeModifiers.STATIC;
 
@@ -745,7 +745,7 @@ public class Vala.GTypeModule : GErrorModule {
 	}
 
 	private void add_type_value_table_copy_function (Class cl) {
-		var function = new CCodeFunction ("%s_copy_value".printf (cl.get_lower_case_cname ("value_")), "void");
+		var function = new CCodeFunction ("%s_copy_value".printf (get_ccode_lower_case_name (cl, "value_")), "void");
 		function.add_parameter (new CCodeParameter ("src_value", "const GValue*"));
 		function.add_parameter (new CCodeParameter ("dest_value", "GValue*"));
 		function.modifiers = CCodeModifiers.STATIC;
@@ -769,7 +769,7 @@ public class Vala.GTypeModule : GErrorModule {
 	}
 
 	private void add_type_value_table_peek_pointer_function (Class cl) {
-		var function = new CCodeFunction ("%s_peek_pointer".printf (cl.get_lower_case_cname ("value_")), "gpointer");
+		var function = new CCodeFunction ("%s_peek_pointer".printf (get_ccode_lower_case_name (cl, "value_")), "gpointer");
 		function.add_parameter (new CCodeParameter ("value", "const GValue*"));
 		function.modifiers = CCodeModifiers.STATIC;
 
@@ -783,7 +783,7 @@ public class Vala.GTypeModule : GErrorModule {
 	}
 
 	private void add_type_value_table_lcopy_value_function ( Class cl ) {
-		var function = new CCodeFunction ("%s_lcopy_value".printf (cl.get_lower_case_cname ("value_")), "gchar*");
+		var function = new CCodeFunction ("%s_lcopy_value".printf (get_ccode_lower_case_name (cl, "value_")), "gchar*");
 		function.add_parameter (new CCodeParameter ("value", "const GValue*"));
 		function.add_parameter (new CCodeParameter ("n_collect_values", "guint"));
 		function.add_parameter (new CCodeParameter ("collect_values", "GTypeCValue*"));
@@ -827,7 +827,7 @@ public class Vala.GTypeModule : GErrorModule {
 	}
 
 	private void add_type_value_table_collect_value_function (Class cl) {
-		var function = new CCodeFunction ("%s_collect_value".printf (cl.get_lower_case_cname ("value_")), "gchar*");
+		var function = new CCodeFunction ("%s_collect_value".printf (get_ccode_lower_case_name (cl, "value_")), "gchar*");
 		function.add_parameter (new CCodeParameter ("value", "GValue*"));
 		function.add_parameter (new CCodeParameter ("n_collect_values", "guint"));
 		function.add_parameter (new CCodeParameter ("collect_values", "GTypeCValue*"));
@@ -894,7 +894,7 @@ public class Vala.GTypeModule : GErrorModule {
 	}
 
 	private void add_g_param_spec_type_function (Class cl) {
-		string function_name = cl.get_lower_case_cname ("param_spec_");
+		string function_name = get_ccode_lower_case_name (cl, "param_spec_");
 
 		var function = new CCodeFunction (function_name, "GParamSpec*");
 		function.add_parameter (new CCodeParameter ("name", "const gchar*"));
@@ -1102,7 +1102,7 @@ public class Vala.GTypeModule : GErrorModule {
 	private void begin_base_init_function (Class cl) {
 		push_context (base_init_context);
 
-		var base_init = new CCodeFunction ("%s_base_init".printf (cl.get_lower_case_cname (null)), "void");
+		var base_init = new CCodeFunction ("%s_base_init".printf (get_ccode_lower_case_name (cl, null)), "void");
 		base_init.add_parameter (new CCodeParameter ("klass", "%sClass *".printf (get_ccode_name (cl))));
 		base_init.modifiers = CCodeModifiers.STATIC;
 
@@ -1145,7 +1145,7 @@ public class Vala.GTypeModule : GErrorModule {
 			ccall2 = new CCodeFunctionCall (new CCodeIdentifier ("G_TYPE_FROM_CLASS"));
 			ccall2.add_argument (new CCodeIdentifier ("klass"));
 			ccall.add_argument (ccall2);
-			ccall.add_argument (new CCodeIdentifier ("_vala_%s_class_private_quark".printf (cl.get_lower_case_cname ())));
+			ccall.add_argument (new CCodeIdentifier ("_vala_%s_class_private_quark".printf (get_ccode_lower_case_name (cl))));
 			ccall.add_argument (new CCodeIdentifier ("priv"));
 			ccode.add_expression (ccall);
 		}
@@ -1163,7 +1163,7 @@ public class Vala.GTypeModule : GErrorModule {
 	private void begin_class_init_function (Class cl) {
 		push_context (class_init_context);
 
-		var func = new CCodeFunction ("%s_class_init".printf (cl.get_lower_case_cname (null)));
+		var func = new CCodeFunction ("%s_class_init".printf (get_ccode_lower_case_name (cl, null)));
 		func.add_parameter (new CCodeParameter ("klass", "%sClass *".printf (get_ccode_name (cl))));
 		func.modifiers = CCodeModifiers.STATIC;
 
@@ -1171,7 +1171,7 @@ public class Vala.GTypeModule : GErrorModule {
 		
 		/* save pointer to parent class */
 		var parent_decl = new CCodeDeclaration ("gpointer");
-		var parent_var_decl = new CCodeVariableDeclarator ("%s_parent_class".printf (cl.get_lower_case_cname (null)));
+		var parent_var_decl = new CCodeVariableDeclarator ("%s_parent_class".printf (get_ccode_lower_case_name (cl, null)));
 		parent_var_decl.initializer = new CCodeConstant ("NULL");
 		parent_decl.add_declarator (parent_var_decl);
 		parent_decl.modifiers = CCodeModifiers.STATIC;
@@ -1181,7 +1181,7 @@ public class Vala.GTypeModule : GErrorModule {
 
 		ccall = new CCodeFunctionCall (new CCodeIdentifier ("g_type_class_peek_parent"));
 		ccall.add_argument (new CCodeIdentifier ("klass"));
-		var parent_assignment = new CCodeAssignment (new CCodeIdentifier ("%s_parent_class".printf (cl.get_lower_case_cname (null))), ccall);
+		var parent_assignment = new CCodeAssignment (new CCodeIdentifier ("%s_parent_class".printf (get_ccode_lower_case_name (cl, null))), ccall);
 		ccode.add_expression (parent_assignment);
 		
 
@@ -1247,11 +1247,11 @@ public class Vala.GTypeModule : GErrorModule {
 			ccast.add_argument (new CCodeIdentifier ("klass"));
 
 			if (prop.get_accessor != null) {
-				string cname = "%s_real_get_%s".printf (cl.get_lower_case_cname (null), prop.name);
+				string cname = "%s_real_get_%s".printf (get_ccode_lower_case_name (cl, null), prop.name);
 				ccode.add_assignment (new CCodeMemberAccess.pointer (ccast, "get_%s".printf (prop.name)), new CCodeIdentifier (cname));
 			}
 			if (prop.set_accessor != null) {
-				string cname = "%s_real_set_%s".printf (cl.get_lower_case_cname (null), prop.name);
+				string cname = "%s_real_set_%s".printf (get_ccode_lower_case_name (cl, null), prop.name);
 				ccode.add_assignment (new CCodeMemberAccess.pointer (ccast, "set_%s".printf (prop.name)), new CCodeIdentifier (cname));
 			}
 		}
@@ -1276,7 +1276,7 @@ public class Vala.GTypeModule : GErrorModule {
 	}
 	
 	private void add_interface_init_function (Class cl, Interface iface) {
-		var iface_init = new CCodeFunction ("%s_%s_interface_init".printf (cl.get_lower_case_cname (null), iface.get_lower_case_cname (null)), "void");
+		var iface_init = new CCodeFunction ("%s_%s_interface_init".printf (get_ccode_lower_case_name (cl), get_ccode_lower_case_name (iface)), "void");
 		iface_init.add_parameter (new CCodeParameter ("iface", "%s *".printf (iface.get_type_cname ())));
 		iface_init.modifiers = CCodeModifiers.STATIC;
 
@@ -1285,7 +1285,7 @@ public class Vala.GTypeModule : GErrorModule {
 		CCodeFunctionCall ccall;
 		
 		/* save pointer to parent vtable */
-		string parent_iface_var = "%s_%s_parent_iface".printf (cl.get_lower_case_cname (null), iface.get_lower_case_cname (null));
+		string parent_iface_var = "%s_%s_parent_iface".printf (get_ccode_lower_case_name (cl), get_ccode_lower_case_name (iface));
 		var parent_decl = new CCodeDeclaration (iface.get_type_cname () + "*");
 		var parent_var_decl = new CCodeVariableDeclarator (parent_iface_var);
 		parent_var_decl.initializer = new CCodeConstant ("NULL");
@@ -1368,9 +1368,9 @@ public class Vala.GTypeModule : GErrorModule {
 			var ciface = new CCodeIdentifier ("iface");
 
 			if (prop.get_accessor != null) {
-				string cname = "%s_real_get_%s".printf (cl.get_lower_case_cname (null), prop.name);
+				string cname = "%s_real_get_%s".printf (get_ccode_lower_case_name (cl, null), prop.name);
 				if (prop.is_abstract || prop.is_virtual) {
-					cname = "%s_get_%s".printf (cl.get_lower_case_cname (null), prop.name);
+					cname = "%s_get_%s".printf (get_ccode_lower_case_name (cl, null), prop.name);
 				}
 
 				CCodeExpression cfunc = new CCodeIdentifier (cname);
@@ -1380,9 +1380,9 @@ public class Vala.GTypeModule : GErrorModule {
 				ccode.add_assignment (new CCodeMemberAccess.pointer (ciface, "get_%s".printf (prop.name)), cfunc);
 			}
 			if (prop.set_accessor != null) {
-				string cname = "%s_real_set_%s".printf (cl.get_lower_case_cname (null), prop.name);
+				string cname = "%s_real_set_%s".printf (get_ccode_lower_case_name (cl, null), prop.name);
 				if (prop.is_abstract || prop.is_virtual) {
-					cname = "%s_set_%s".printf (cl.get_lower_case_cname (null), prop.name);
+					cname = "%s_set_%s".printf (get_ccode_lower_case_name (cl, null), prop.name);
 				}
 
 				CCodeExpression cfunc = new CCodeIdentifier (cname);
@@ -1488,7 +1488,7 @@ public class Vala.GTypeModule : GErrorModule {
 	private void begin_instance_init_function (Class cl) {
 		push_context (instance_init_context);
 
-		var func = new CCodeFunction ("%s_instance_init".printf (cl.get_lower_case_cname (null)));
+		var func = new CCodeFunction ("%s_instance_init".printf (get_ccode_lower_case_name (cl, null)));
 		func.add_parameter (new CCodeParameter ("self", "%s *".printf (get_ccode_name (cl))));
 		func.modifiers = CCodeModifiers.STATIC;
 
@@ -1516,7 +1516,7 @@ public class Vala.GTypeModule : GErrorModule {
 	private void begin_class_finalize_function (Class cl) {
 		push_context (class_finalize_context);
 
-		var function = new CCodeFunction ("%s_class_finalize".printf (cl.get_lower_case_cname (null)), "void");
+		var function = new CCodeFunction ("%s_class_finalize".printf (get_ccode_lower_case_name (cl, null)), "void");
 		function.modifiers = CCodeModifiers.STATIC;
 
 		function.add_parameter (new CCodeParameter ("klass", get_ccode_name (cl) + "Class *"));
@@ -1538,7 +1538,7 @@ public class Vala.GTypeModule : GErrorModule {
 	private void begin_base_finalize_function (Class cl) {
 		push_context (base_finalize_context);
 
-		var function = new CCodeFunction ("%s_base_finalize".printf (cl.get_lower_case_cname (null)), "void");
+		var function = new CCodeFunction ("%s_base_finalize".printf (get_ccode_lower_case_name (cl, null)), "void");
 		function.modifiers = CCodeModifiers.STATIC;
 
 		function.add_parameter (new CCodeParameter ("klass", get_ccode_name (cl) + "Class *"));
@@ -1589,7 +1589,7 @@ public class Vala.GTypeModule : GErrorModule {
 				fundamental_class = fundamental_class.base_class;
 			}
 
-			var func = new CCodeFunction ("%s_finalize".printf (cl.get_lower_case_cname (null)));
+			var func = new CCodeFunction ("%s_finalize".printf (get_ccode_lower_case_name (cl, null)));
 			func.add_parameter (new CCodeParameter ("obj", get_ccode_name (fundamental_class) + "*"));
 			func.modifiers = CCodeModifiers.STATIC;
 
@@ -1636,7 +1636,7 @@ public class Vala.GTypeModule : GErrorModule {
 			// chain up to finalize function of the base class
 			if (cl.base_class != null) {
 				var ccast = new CCodeFunctionCall (new CCodeIdentifier ("%s_CLASS".printf (fundamental_class.get_upper_case_cname ())));
-				ccast.add_argument (new CCodeIdentifier ("%s_parent_class".printf (cl.get_lower_case_cname (null))));
+				ccast.add_argument (new CCodeIdentifier ("%s_parent_class".printf (get_ccode_lower_case_name (cl, null))));
 				var ccall = new CCodeFunctionCall (new CCodeMemberAccess.pointer (ccast, "finalize"));
 				ccall.add_argument (new CCodeIdentifier ("obj"));
 				instance_finalize_context.ccode.add_expression (ccall);
@@ -1851,7 +1851,7 @@ public class Vala.GTypeModule : GErrorModule {
 		var type_struct = new CCodeStruct ("_%s".printf (iface.get_type_cname ()));
 		
 		decl_space.add_type_declaration (new CCodeNewline ());
-		var macro = "(%s_get_type ())".printf (iface.get_lower_case_cname (null));
+		var macro = "(%s_get_type ())".printf (get_ccode_lower_case_name (iface, null));
 		decl_space.add_type_declaration (new CCodeMacroReplacement (iface.get_type_id (), macro));
 
 		macro = "(G_TYPE_CHECK_INSTANCE_CAST ((obj), %s, %s))".printf (iface.get_type_id (), get_ccode_name (iface));
@@ -1982,7 +1982,7 @@ public class Vala.GTypeModule : GErrorModule {
 	private void add_interface_base_init_function (Interface iface) {
 		push_context (new EmitContext (iface));
 
-		var base_init = new CCodeFunction ("%s_base_init".printf (iface.get_lower_case_cname (null)), "void");
+		var base_init = new CCodeFunction ("%s_base_init".printf (get_ccode_lower_case_name (iface, null)), "void");
 		base_init.add_parameter (new CCodeParameter ("iface", "%sIface *".printf (get_ccode_name (iface))));
 		base_init.modifiers = CCodeModifiers.STATIC;
 
diff --git a/codegen/valagvariantmodule.vala b/codegen/valagvariantmodule.vala
index 1d12dc9..859d49d 100644
--- a/codegen/valagvariantmodule.vala
+++ b/codegen/valagvariantmodule.vala
@@ -201,7 +201,7 @@ public class Vala.GVariantModule : GAsyncModule {
 
 	CCodeExpression? generate_enum_value_from_string (EnumValueType type, CCodeExpression? expr, CCodeExpression? error_expr) {
 		var en = type.type_symbol as Enum;
-		var from_string_name = "%s_from_string".printf (en.get_lower_case_cname (null));
+		var from_string_name = "%s_from_string".printf (get_ccode_lower_case_name (en, null));
 
 		var from_string_call = new CCodeFunctionCall (new CCodeIdentifier (from_string_name));
 		from_string_call.add_argument (expr);
@@ -211,7 +211,7 @@ public class Vala.GVariantModule : GAsyncModule {
 	}
 
 	public CCodeFunction generate_enum_from_string_function_declaration (Enum en) {
-		var from_string_name = "%s_from_string".printf (en.get_lower_case_cname (null));
+		var from_string_name = "%s_from_string".printf (get_ccode_lower_case_name (en, null));
 
 		var from_string_func = new CCodeFunction (from_string_name, get_ccode_name (en));
 		from_string_func.add_parameter (new CCodeParameter ("str", "const char*"));
@@ -221,7 +221,7 @@ public class Vala.GVariantModule : GAsyncModule {
 	}
 
 	public CCodeFunction generate_enum_from_string_function (Enum en) {
-		var from_string_name = "%s_from_string".printf (en.get_lower_case_cname (null));
+		var from_string_name = "%s_from_string".printf (get_ccode_lower_case_name (en, null));
 
 		var from_string_func = new CCodeFunction (from_string_name, get_ccode_name (en));
 		from_string_func.add_parameter (new CCodeParameter ("str", "const char*"));
@@ -528,7 +528,7 @@ public class Vala.GVariantModule : GAsyncModule {
 
 	CCodeExpression? generate_enum_value_to_string (EnumValueType type, CCodeExpression? expr) {
 		var en = type.type_symbol as Enum;
-		var to_string_name = "%s_to_string".printf (en.get_lower_case_cname (null));
+		var to_string_name = "%s_to_string".printf (get_ccode_lower_case_name (en, null));
 
 		var to_string_call = new CCodeFunctionCall (new CCodeIdentifier (to_string_name));
 		to_string_call.add_argument (expr);
@@ -537,7 +537,7 @@ public class Vala.GVariantModule : GAsyncModule {
 	}
 
 	public CCodeFunction generate_enum_to_string_function_declaration (Enum en) {
-		var to_string_name = "%s_to_string".printf (en.get_lower_case_cname (null));
+		var to_string_name = "%s_to_string".printf (get_ccode_lower_case_name (en, null));
 
 		var to_string_func = new CCodeFunction (to_string_name, "const char*");
 		to_string_func.add_parameter (new CCodeParameter ("value", get_ccode_name (en)));
@@ -546,7 +546,7 @@ public class Vala.GVariantModule : GAsyncModule {
 	}
 
 	public CCodeFunction generate_enum_to_string_function (Enum en) {
-		var to_string_name = "%s_to_string".printf (en.get_lower_case_cname (null));
+		var to_string_name = "%s_to_string".printf (get_ccode_lower_case_name (en, null));
 
 		var to_string_func = new CCodeFunction (to_string_name, "const char*");
 		to_string_func.add_parameter (new CCodeParameter ("value", get_ccode_name (en)));
diff --git a/codegen/valainterfaceregisterfunction.vala b/codegen/valainterfaceregisterfunction.vala
index cec7cbd..d52af3f 100644
--- a/codegen/valainterfaceregisterfunction.vala
+++ b/codegen/valainterfaceregisterfunction.vala
@@ -47,7 +47,7 @@ public class Vala.InterfaceRegisterFunction : TypeRegisterFunction {
 	}
 
 	public override string get_base_init_func_name () {
-		return "%s_base_init".printf (interface_reference.get_lower_case_cname (null));
+		return "%s_base_init".printf (CCodeBaseModule.get_ccode_lower_case_name (interface_reference));
 	}
 
 	public override string get_class_finalize_func_name () {
@@ -84,7 +84,7 @@ public class Vala.InterfaceRegisterFunction : TypeRegisterFunction {
 			var prereq = prereq_ref.data_type;
 			
 			var func = new CCodeFunctionCall (new CCodeIdentifier ("g_type_interface_add_prerequisite"));
-			func.add_argument (new CCodeIdentifier ("%s_type_id".printf (interface_reference.get_lower_case_cname (null))));
+			func.add_argument (new CCodeIdentifier ("%s_type_id".printf (CCodeBaseModule.get_ccode_lower_case_name (interface_reference))));
 			func.add_argument (new CCodeIdentifier (prereq.get_type_id()));
 			
 			block.add_statement (new CCodeExpressionStatement (func));
diff --git a/codegen/valatyperegisterfunction.vala b/codegen/valatyperegisterfunction.vala
index f6d2b55..a4d449a 100644
--- a/codegen/valatyperegisterfunction.vala
+++ b/codegen/valatyperegisterfunction.vala
@@ -44,7 +44,7 @@ public abstract class Vala.TypeRegisterFunction {
 			fundamental = true;
 		}
 
-		string type_id_name = "%s_type_id".printf (get_type_declaration ().get_lower_case_cname (null));
+		string type_id_name = "%s_type_id".printf (CCodeBaseModule.get_ccode_lower_case_name (get_type_declaration ()));
 
 		var type_block = new CCodeBlock ();
 		CCodeDeclaration cdecl;
@@ -67,7 +67,7 @@ public abstract class Vala.TypeRegisterFunction {
 
 		CCodeFunction fun;
 		if (!plugin) {
-			fun = new CCodeFunction ("%s_get_type".printf (get_type_declaration ().get_lower_case_cname (null)), "GType");
+			fun = new CCodeFunction ("%s_get_type".printf (CCodeBaseModule.get_ccode_lower_case_name (get_type_declaration ())), "GType");
 			fun.attributes = "G_GNUC_CONST";
 
 			/* Function will not be prototyped anyway */
@@ -77,10 +77,10 @@ public abstract class Vala.TypeRegisterFunction {
 				fun.attributes += " G_GNUC_UNUSED";
 			}
 		} else {
-			fun = new CCodeFunction ("%s_register_type".printf (get_type_declaration ().get_lower_case_cname (null)), "GType");
+			fun = new CCodeFunction ("%s_register_type".printf (CCodeBaseModule.get_ccode_lower_case_name (get_type_declaration ())), "GType");
 			fun.add_parameter (new CCodeParameter ("module", "GTypeModule *"));
 
-			var get_fun = new CCodeFunction ("%s_get_type".printf (get_type_declaration ().get_lower_case_cname (null)), "GType");
+			var get_fun = new CCodeFunction ("%s_get_type".printf (CCodeBaseModule.get_ccode_lower_case_name (get_type_declaration ())), "GType");
 			get_fun.attributes = "G_GNUC_CONST";
 
 			get_fun.is_declaration = true;
@@ -135,7 +135,7 @@ public abstract class Vala.TypeRegisterFunction {
 
 			quark_reg_call.add_argument (new CCodeConstant ("\"Vala%sClassPrivate\"".printf (CCodeBaseModule.get_ccode_name (get_type_declaration ()))));
 
-			type_init.add_statement (new CCodeExpressionStatement (new CCodeAssignment (new CCodeIdentifier ("_vala_%s_class_private_quark".printf (get_type_declaration ().get_lower_case_cname ())), quark_reg_call)));
+			type_init.add_statement (new CCodeExpressionStatement (new CCodeAssignment (new CCodeIdentifier ("_vala_%s_class_private_quark".printf (CCodeBaseModule.get_ccode_lower_case_name (get_type_declaration ()))), quark_reg_call)));
 		}
 
 		CCodeFunctionCall reg_call;



[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]