[vala/wip/attributes: 7/13] codegen: Add get_ccode_lower_case_prefix



commit 65d73116150c208a3b2ed2ecd7c3dbe99f8acc15
Author: Luca Bruno <lucabru src gnome org>
Date:   Sun Jun 26 13:43:30 2011 +0200

    codegen: Add get_ccode_lower_case_prefix

 codegen/valaccodebasemodule.vala     |   53 +++++++++++++++++-----
 codegen/valaccodedelegatemodule.vala |    2 +-
 codegen/valagdbusclientmodule.vala   |   26 +++++-----
 codegen/valagdbusmodule.vala         |    4 +-
 codegen/valagdbusservermodule.vala   |   82 +++++++++++++++++-----------------
 codegen/valagerrormodule.vala        |    4 +-
 codegen/valagtypemodule.vala         |   18 ++++----
 7 files changed, 110 insertions(+), 79 deletions(-)
---
diff --git a/codegen/valaccodebasemodule.vala b/codegen/valaccodebasemodule.vala
index 91fc19e..b87220a 100644
--- a/codegen/valaccodebasemodule.vala
+++ b/codegen/valaccodebasemodule.vala
@@ -2337,7 +2337,7 @@ public abstract class Vala.CCodeBaseModule : CodeGenerator {
 	}
 
 	private string generate_struct_equal_function (Struct st) {
-		string equal_func = "_%sequal".printf (st.get_lower_case_cprefix ());
+		string equal_func = "_%sequal".printf (get_ccode_lower_case_prefix (st));
 
 		if (!add_wrapper (equal_func)) {
 			// wrapper already defined
@@ -2426,7 +2426,7 @@ public abstract class Vala.CCodeBaseModule : CodeGenerator {
 	}
 
 	private string generate_numeric_equal_function (TypeSymbol sym) {
-		string equal_func = "_%sequal".printf (sym.get_lower_case_cprefix ());
+		string equal_func = "_%sequal".printf (get_ccode_lower_case_prefix (sym));
 
 		if (!add_wrapper (equal_func)) {
 			// wrapper already defined
@@ -2475,7 +2475,7 @@ public abstract class Vala.CCodeBaseModule : CodeGenerator {
 	}
 
 	private string generate_struct_dup_wrapper (ValueType value_type) {
-		string dup_func = "_%sdup".printf (value_type.type_symbol.get_lower_case_cprefix ());
+		string dup_func = "_%sdup".printf (get_ccode_lower_case_prefix (value_type.type_symbol));
 
 		if (!add_wrapper (dup_func)) {
 			// wrapper already defined
@@ -5580,6 +5580,10 @@ public abstract class Vala.CCodeBaseModule : CodeGenerator {
 		return get_ccode_attribute(sym).prefix;
 	}
 
+	public static string get_ccode_lower_case_prefix (Symbol sym) {
+		return get_ccode_attribute(sym).lower_case_prefix;
+	}
+
 	public override void visit_class (Class cl) {
 	}
 
@@ -5979,11 +5983,21 @@ public class Vala.CCodeAttribute : AttributeCache {
 		}
 	}
 
+	public string get_lower_case_prefix {
+		get {
+			if (_lower_case_prefix == null) {
+				_lower_case_prefix = get_default_lower_case_prefix ();
+			}
+			return _lower_case_prefix;
+		}
+	}
+
 	private string _name;
 	private string _const_name;
 	private string _type_name;
 	private List<string> _header_filenames;
 	private string _prefix;
+	private string _lower_case_prefix;
 
 	public CCodeAttribute (CodeNode node) {
 		this.node = node;
@@ -6002,6 +6016,11 @@ public class Vala.CCodeAttribute : AttributeCache {
 				}
 			}
 			_prefix = attr.get_string ("cprefix");
+			_lower_case_prefix = attr.get_string ("lower_case_cprefix");
+			if (_lower_case_prefix == null && (sym is ObjectTypeSymbol || sym is Struct)) {
+				_lower_case_prefix = _prefix;
+			}
+			_lower_case_suffix = attr.get_string ("lower_case_csuffix");
 		}
 	}
 
@@ -6009,10 +6028,10 @@ public class Vala.CCodeAttribute : AttributeCache {
 		var sym = node as Symbol;
 		if (sym != null) {
 			if (sym is Constant && !(sym is EnumValue)) {
-				return "%s%s".printf (sym.parent_symbol.get_lower_case_cprefix ().up (), sym.name);
+				return "%s%s".printf (CCodeBaseModule.get_ccode_lower_case_prefix (sym.parent_symbol).up (), sym.name);
 			} else if (sym is Field) {
 				if (((Field) sym).binding == MemberBinding.STATIC) {
-					return "%s%s".printf (sym.parent_symbol.get_lower_case_cprefix (), sym.name);
+					return "%s%s".printf (CCodeBaseModule.get_ccode_lower_case_prefix (sym.parent_symbol), sym.name);
 				} else {
 					return sym.name;
 				}
@@ -6025,9 +6044,9 @@ public class Vala.CCodeAttribute : AttributeCache {
 					infix = "new";
 				}
 				if (m.name == ".new") {
-					return "%s%s".printf (m.parent_symbol.get_lower_case_cprefix (), infix);
+					return "%s%s".printf (CCodeBaseModule.get_ccode_lower_case_prefix (m.parent_symbol), infix);
 				} else {
-					return "%s%s_%s".printf (m.parent_symbol.get_lower_case_cprefix (), infix, m.name);
+					return "%s%s_%s".printf (CCodeBaseModule.get_ccode_lower_case_prefix (m.parent_symbol), infix, m.name);
 				}
 			} else if (sym is Method) {
 				var m = (Method) sym;
@@ -6038,18 +6057,18 @@ public class Vala.CCodeAttribute : AttributeCache {
 					// avoid conflict with generated main function
 					return "_vala_main";
 				} else if (sym.name.has_prefix ("_")) {
-					return "_%s%s".printf (sym.parent_symbol.get_lower_case_cprefix (), sym.name.substring (1));
+					return "_%s%s".printf (CCodeBaseModule.get_ccode_lower_case_prefix (sym.parent_symbol), sym.name.substring (1));
 				} else {
-					return "%s%s".printf (sym.parent_symbol.get_lower_case_cprefix (), sym.name);
+					return "%s%s".printf (CCodeBaseModule.get_ccode_lower_case_prefix (sym.parent_symbol), sym.name);
 				}
 			} else if (sym is PropertyAccessor) {
 				var acc = (PropertyAccessor) sym;
 				var t = (TypeSymbol) acc.prop.parent_symbol;
 
 				if (acc.readable) {
-					return "%sget_%s".printf (t.get_lower_case_cprefix (), acc.prop.name);
+					return "%sget_%s".printf (CCodeBaseModule.get_ccode_lower_case_prefix (t), acc.prop.name);
 				} else {
-					return "%sset_%s".printf (t.get_lower_case_cprefix (), acc.prop.name);
+					return "%sset_%s".printf (CCodeBaseModule.get_ccode_lower_case_prefix (t), acc.prop.name);
 				}
 			} else if (sym is Signal) {
 				return Symbol.camel_case_to_lower_case (sym.name);
@@ -6171,4 +6190,16 @@ public class Vala.CCodeAttribute : AttributeCache {
 		}
 		return "";
 	}
+
+	private string get_lower_case_prefix () {
+		if (sym is Namespace) {
+			if (sym.name == null) {
+				return "";
+			} else {
+				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));
+		}
+	}
 }
diff --git a/codegen/valaccodedelegatemodule.vala b/codegen/valaccodedelegatemodule.vala
index 3b25684..aa41536 100644
--- a/codegen/valaccodedelegatemodule.vala
+++ b/codegen/valaccodedelegatemodule.vala
@@ -181,7 +181,7 @@ public class Vala.CCodeDelegateModule : CCodeArrayModule {
 		if (dynamic_sig != null) {
 			delegate_name = get_dynamic_signal_cname (dynamic_sig);
 		} else if (sig != null) {
-			delegate_name = sig.parent_symbol.get_lower_case_cprefix () + get_ccode_name (sig);
+			delegate_name = get_ccode_lower_case_prefix (sig.parent_symbol) + get_ccode_name (sig);
 		} else {
 			delegate_name = Symbol.camel_case_to_lower_case (get_ccode_name (d));
 		}
diff --git a/codegen/valagdbusclientmodule.vala b/codegen/valagdbusclientmodule.vala
index 5f9a3f9..2551276 100644
--- a/codegen/valagdbusclientmodule.vala
+++ b/codegen/valagdbusclientmodule.vala
@@ -74,9 +74,9 @@ public class Vala.GDBusClientModule : GDBusModule {
 			}
 		}
 
-		string lower_cname = main_iface.get_lower_case_cprefix () + "proxy";
+		string lower_cname = get_ccode_lower_case_prefix (main_iface) + "proxy";
 
-		var proxy_iface_init = new CCodeFunction (lower_cname + "_" + iface.get_lower_case_cprefix () + "interface_init", "void");
+		var proxy_iface_init = new CCodeFunction (lower_cname + "_" + get_ccode_lower_case_prefix (iface) + "interface_init", "void");
 		proxy_iface_init.add_parameter (new CCodeParameter ("iface", get_ccode_name (iface) + "Iface*"));
 
 		push_function (proxy_iface_init);
@@ -129,8 +129,8 @@ public class Vala.GDBusClientModule : GDBusModule {
 
 		result += "G_IMPLEMENT_INTERFACE (%s, %sproxy_%sinterface_init) ".printf (
 			iface.get_upper_case_cname ("TYPE_"),
-			main_iface.get_lower_case_cprefix (),
-			iface.get_lower_case_cprefix ());
+			get_ccode_lower_case_prefix (main_iface),
+			get_ccode_lower_case_prefix (iface));
 		return result;
 	}
 
@@ -142,7 +142,7 @@ public class Vala.GDBusClientModule : GDBusModule {
 			return;
 		}
 
-		string get_type_name = "%sproxy_get_type".printf (iface.get_lower_case_cprefix ());
+		string get_type_name = "%sproxy_get_type".printf (get_ccode_lower_case_prefix (iface));
 
 		if (add_symbol_declaration (decl_space, iface, get_type_name)) {
 			return;
@@ -170,7 +170,7 @@ public class Vala.GDBusClientModule : GDBusModule {
 
 		// create proxy class
 		string cname = get_ccode_name (iface) + "Proxy";
-		string lower_cname = iface.get_lower_case_cprefix () + "proxy";
+		string lower_cname = get_ccode_lower_case_prefix (iface) + "proxy";
 
 		cfile.add_type_declaration (new CCodeTypeDefinition ("GDBusProxy", new CCodeVariableDeclarator (cname)));
 		cfile.add_type_declaration (new CCodeTypeDefinition ("GDBusProxyClass", new CCodeVariableDeclarator (cname + "Class")));
@@ -453,7 +453,7 @@ public class Vala.GDBusClientModule : GDBusModule {
 	}
 
 	void generate_signal_handler_function (ObjectTypeSymbol sym) {
-		var cfunc = new CCodeFunction (sym.get_lower_case_cprefix () + "proxy_g_signal", "void");
+		var cfunc = new CCodeFunction (get_ccode_lower_case_prefix (sym) + "proxy_g_signal", "void");
 		cfunc.add_parameter (new CCodeParameter ("proxy", "GDBusProxy*"));
 		cfunc.add_parameter (new CCodeParameter ("sender_name", "const gchar*"));
 		cfunc.add_parameter (new CCodeParameter ("signal_name", "const gchar*"));
@@ -794,7 +794,7 @@ public class Vala.GDBusClientModule : GDBusModule {
 	}
 
 	string generate_dbus_proxy_method (Interface main_iface, Interface iface, Method m) {
-		string proxy_name = "%sproxy_%s".printf (main_iface.get_lower_case_cprefix (), m.name);
+		string proxy_name = "%sproxy_%s".printf (get_ccode_lower_case_prefix (main_iface), m.name);
 
 		string dbus_iface_name = get_dbus_name (iface);
 
@@ -820,7 +820,7 @@ public class Vala.GDBusClientModule : GDBusModule {
 	}
 
 	string generate_async_dbus_proxy_method (Interface main_iface, Interface iface, Method m) {
-		string proxy_name = "%sproxy_%s_async".printf (main_iface.get_lower_case_cprefix (), m.name);
+		string proxy_name = "%sproxy_%s_async".printf (get_ccode_lower_case_prefix (main_iface), m.name);
 
 		string dbus_iface_name = get_dbus_name (iface);
 
@@ -847,7 +847,7 @@ public class Vala.GDBusClientModule : GDBusModule {
 	}
 
 	string generate_finish_dbus_proxy_method (Interface main_iface, Interface iface, Method m) {
-		string proxy_name = "%sproxy_%s_finish".printf (main_iface.get_lower_case_cprefix (), m.name);
+		string proxy_name = "%sproxy_%s_finish".printf (get_ccode_lower_case_prefix (main_iface), m.name);
 
 		var function = new CCodeFunction (proxy_name);
 		function.modifiers = CCodeModifiers.STATIC;
@@ -871,7 +871,7 @@ public class Vala.GDBusClientModule : GDBusModule {
 	}
 
 	string generate_dbus_proxy_property_get (Interface main_iface, Interface iface, Property prop) {
-		string proxy_name = "%sdbus_proxy_get_%s".printf (main_iface.get_lower_case_cprefix (), prop.name);
+		string proxy_name = "%sdbus_proxy_get_%s".printf (get_ccode_lower_case_prefix (main_iface), prop.name);
 
 		string dbus_iface_name = get_dbus_name (iface);
 
@@ -1002,7 +1002,7 @@ public class Vala.GDBusClientModule : GDBusModule {
 	}
 
 	string generate_dbus_proxy_property_set (Interface main_iface, Interface iface, Property prop) {
-		string proxy_name = "%sdbus_proxy_set_%s".printf (main_iface.get_lower_case_cprefix (), prop.name);
+		string proxy_name = "%sdbus_proxy_set_%s".printf (get_ccode_lower_case_prefix (main_iface), prop.name);
 
 		string dbus_iface_name = get_dbus_name (iface);
 
@@ -1103,7 +1103,7 @@ public class Vala.GDBusClientModule : GDBusModule {
 		var quark = new CCodeFunctionCall (new CCodeIdentifier ("g_quark_from_static_string"));
 		quark.add_argument (new CCodeConstant ("\"vala-dbus-proxy-type\""));
 
-		var proxy_type = new CCodeIdentifier (sym.get_lower_case_cprefix () + "proxy_get_type");
+		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))));
diff --git a/codegen/valagdbusmodule.vala b/codegen/valagdbusmodule.vala
index ce23ca2..cabef3b 100644
--- a/codegen/valagdbusmodule.vala
+++ b/codegen/valagdbusmodule.vala
@@ -84,12 +84,12 @@ public class Vala.GDBusModule : GVariantModule {
 		cdecl.modifiers = CCodeModifiers.STATIC;
 		cfile.add_constant_declaration (cdecl);
 
-		string quark_fun_name = edomain.get_lower_case_cprefix () + "quark";
+		string quark_fun_name = get_ccode_lower_case_prefix (edomain) + "quark";
 
 		var cquark_fun = new CCodeFunction (quark_fun_name, get_ccode_name (gquark_type.data_type));
 		push_function (cquark_fun);
 
-		string quark_name = "%squark_volatile".printf (edomain.get_lower_case_cprefix ());
+		string quark_name = "%squark_volatile".printf (get_ccode_lower_case_prefix (edomain));
 
 		ccode.add_declaration ("gsize", new CCodeVariableDeclarator (quark_name, new CCodeConstant ("0")), CCodeModifiers.STATIC | CCodeModifiers.VOLATILE);
 
diff --git a/codegen/valagdbusservermodule.vala b/codegen/valagdbusservermodule.vala
index 44b4c2d..7ceb7a1 100644
--- a/codegen/valagdbusservermodule.vala
+++ b/codegen/valagdbusservermodule.vala
@@ -613,7 +613,7 @@ public class Vala.GDBusServerModule : GDBusClientModule {
 	}
 
 	void generate_interface_method_call_function (ObjectTypeSymbol sym) {
-		var cfunc = new CCodeFunction (sym.get_lower_case_cprefix () + "dbus_interface_method_call", "void");
+		var cfunc = new CCodeFunction (get_ccode_lower_case_prefix (sym) + "dbus_interface_method_call", "void");
 		cfunc.add_parameter (new CCodeParameter ("connection", "GDBusConnection*"));
 		cfunc.add_parameter (new CCodeParameter ("sender", "const gchar*"));
 		cfunc.add_parameter (new CCodeParameter ("object_path", "const gchar*"));
@@ -680,7 +680,7 @@ public class Vala.GDBusServerModule : GDBusClientModule {
 	}
 
 	void generate_interface_get_property_function (ObjectTypeSymbol sym) {
-		var cfunc = new CCodeFunction (sym.get_lower_case_cprefix () + "dbus_interface_get_property", "GVariant*");
+		var cfunc = new CCodeFunction (get_ccode_lower_case_prefix (sym) + "dbus_interface_get_property", "GVariant*");
 		cfunc.add_parameter (new CCodeParameter ("connection", "GDBusConnection*"));
 		cfunc.add_parameter (new CCodeParameter ("sender", "const gchar*"));
 		cfunc.add_parameter (new CCodeParameter ("object_path", "const gchar*"));
@@ -743,7 +743,7 @@ public class Vala.GDBusServerModule : GDBusClientModule {
 	}
 
 	void generate_interface_set_property_function (ObjectTypeSymbol sym) {
-		var cfunc = new CCodeFunction (sym.get_lower_case_cprefix () + "dbus_interface_set_property", "gboolean");
+		var cfunc = new CCodeFunction (get_ccode_lower_case_prefix (sym) + "dbus_interface_set_property", "gboolean");
 		cfunc.add_parameter (new CCodeParameter ("connection", "GDBusConnection*"));
 		cfunc.add_parameter (new CCodeParameter ("sender", "const gchar*"));
 		cfunc.add_parameter (new CCodeParameter ("object_path", "const gchar*"));
@@ -836,14 +836,14 @@ public class Vala.GDBusServerModule : GDBusClientModule {
 				info.append (new CCodeConstant ("\"%s\"".printf (get_type_signature (param.variable_type, param))));
 
 				var cdecl = new CCodeDeclaration ("const GDBusArgInfo");
-				cdecl.add_declarator (new CCodeVariableDeclarator ("_" + sym.get_lower_case_cprefix () + "dbus_arg_info_" + m.name + "_" + param.name, info));
+				cdecl.add_declarator (new CCodeVariableDeclarator ("_" + get_ccode_lower_case_prefix (sym) + "dbus_arg_info_" + m.name + "_" + param.name, info));
 				cdecl.modifiers = CCodeModifiers.STATIC;
 				cfile.add_constant_declaration (cdecl);
 
 				if (param.direction == ParameterDirection.IN) {
-					in_args_info.append (new CCodeUnaryExpression (CCodeUnaryOperator.ADDRESS_OF, new CCodeIdentifier ("_" + sym.get_lower_case_cprefix () + "dbus_arg_info_" + m.name + "_" + param.name)));
+					in_args_info.append (new CCodeUnaryExpression (CCodeUnaryOperator.ADDRESS_OF, new CCodeIdentifier ("_" + get_ccode_lower_case_prefix (sym) + "dbus_arg_info_" + m.name + "_" + param.name)));
 				} else {
-					out_args_info.append (new CCodeUnaryExpression (CCodeUnaryOperator.ADDRESS_OF, new CCodeIdentifier ("_" + sym.get_lower_case_cprefix () + "dbus_arg_info_" + m.name + "_" + param.name)));
+					out_args_info.append (new CCodeUnaryExpression (CCodeUnaryOperator.ADDRESS_OF, new CCodeIdentifier ("_" + get_ccode_lower_case_prefix (sym) + "dbus_arg_info_" + m.name + "_" + param.name)));
 				}
 			}
 
@@ -854,48 +854,48 @@ public class Vala.GDBusServerModule : GDBusClientModule {
 				info.append (new CCodeConstant ("\"%s\"".printf (get_type_signature (m.return_type, m))));
 
 				var cdecl = new CCodeDeclaration ("const GDBusArgInfo");
-				cdecl.add_declarator (new CCodeVariableDeclarator ("_" + sym.get_lower_case_cprefix () + "dbus_arg_info_" + m.name + "_result", info));
+				cdecl.add_declarator (new CCodeVariableDeclarator ("_" + get_ccode_lower_case_prefix (sym) + "dbus_arg_info_" + m.name + "_result", info));
 				cdecl.modifiers = CCodeModifiers.STATIC;
 				cfile.add_constant_declaration (cdecl);
 
-				out_args_info.append (new CCodeUnaryExpression (CCodeUnaryOperator.ADDRESS_OF, new CCodeIdentifier ("_" + sym.get_lower_case_cprefix () + "dbus_arg_info_" + m.name + "_result")));
+				out_args_info.append (new CCodeUnaryExpression (CCodeUnaryOperator.ADDRESS_OF, new CCodeIdentifier ("_" + get_ccode_lower_case_prefix (sym) + "dbus_arg_info_" + m.name + "_result")));
 			}
 
 			in_args_info.append (new CCodeConstant ("NULL"));
 			out_args_info.append (new CCodeConstant ("NULL"));
 
 			var cdecl = new CCodeDeclaration ("const GDBusArgInfo * const");
-			cdecl.add_declarator (new CCodeVariableDeclarator ("_" + sym.get_lower_case_cprefix () + "dbus_arg_info_" + m.name + "_in[]", in_args_info));
+			cdecl.add_declarator (new CCodeVariableDeclarator ("_" + get_ccode_lower_case_prefix (sym) + "dbus_arg_info_" + m.name + "_in[]", in_args_info));
 			cdecl.modifiers = CCodeModifiers.STATIC;
 			cfile.add_constant_declaration (cdecl);
 
 			cdecl = new CCodeDeclaration ("const GDBusArgInfo * const");
-			cdecl.add_declarator (new CCodeVariableDeclarator ("_" + sym.get_lower_case_cprefix () + "dbus_arg_info_" + m.name + "_out[]", out_args_info));
+			cdecl.add_declarator (new CCodeVariableDeclarator ("_" + get_ccode_lower_case_prefix (sym) + "dbus_arg_info_" + m.name + "_out[]", out_args_info));
 			cdecl.modifiers = CCodeModifiers.STATIC;
 			cfile.add_constant_declaration (cdecl);
 
 			var info = new CCodeInitializerList ();
 			info.append (new CCodeConstant ("-1"));
 			info.append (new CCodeConstant ("\"%s\"".printf (get_dbus_name_for_member (m))));
-			info.append (new CCodeCastExpression (new CCodeUnaryExpression (CCodeUnaryOperator.ADDRESS_OF, new CCodeIdentifier ("_" + sym.get_lower_case_cprefix () + "dbus_arg_info_" + m.name + "_in")), "GDBusArgInfo **"));
-			info.append (new CCodeCastExpression (new CCodeUnaryExpression (CCodeUnaryOperator.ADDRESS_OF, new CCodeIdentifier ("_" + sym.get_lower_case_cprefix () + "dbus_arg_info_" + m.name + "_out")), "GDBusArgInfo **"));
+			info.append (new CCodeCastExpression (new CCodeUnaryExpression (CCodeUnaryOperator.ADDRESS_OF, new CCodeIdentifier ("_" + get_ccode_lower_case_prefix (sym) + "dbus_arg_info_" + m.name + "_in")), "GDBusArgInfo **"));
+			info.append (new CCodeCastExpression (new CCodeUnaryExpression (CCodeUnaryOperator.ADDRESS_OF, new CCodeIdentifier ("_" + get_ccode_lower_case_prefix (sym) + "dbus_arg_info_" + m.name + "_out")), "GDBusArgInfo **"));
 
 			cdecl = new CCodeDeclaration ("const GDBusMethodInfo");
-			cdecl.add_declarator (new CCodeVariableDeclarator ("_" + sym.get_lower_case_cprefix () + "dbus_method_info_" + m.name, info));
+			cdecl.add_declarator (new CCodeVariableDeclarator ("_" + get_ccode_lower_case_prefix (sym) + "dbus_method_info_" + m.name, info));
 			cdecl.modifiers = CCodeModifiers.STATIC;
 			cfile.add_constant_declaration (cdecl);
 
-			infos.append (new CCodeUnaryExpression (CCodeUnaryOperator.ADDRESS_OF, new CCodeIdentifier ("_" + sym.get_lower_case_cprefix () + "dbus_method_info_" + m.name)));
+			infos.append (new CCodeUnaryExpression (CCodeUnaryOperator.ADDRESS_OF, new CCodeIdentifier ("_" + get_ccode_lower_case_prefix (sym) + "dbus_method_info_" + m.name)));
 		}
 
 		infos.append (new CCodeConstant ("NULL"));
 
 		var cdecl = new CCodeDeclaration ("const GDBusMethodInfo * const");
-		cdecl.add_declarator (new CCodeVariableDeclarator ("_" + sym.get_lower_case_cprefix () + "dbus_method_info[]", infos));
+		cdecl.add_declarator (new CCodeVariableDeclarator ("_" + get_ccode_lower_case_prefix (sym) + "dbus_method_info[]", infos));
 		cdecl.modifiers = CCodeModifiers.STATIC;
 		cfile.add_constant_declaration (cdecl);
 
-		return new CCodeIdentifier ("_" + sym.get_lower_case_cprefix () + "dbus_method_info");
+		return new CCodeIdentifier ("_" + get_ccode_lower_case_prefix (sym) + "dbus_method_info");
 	}
 
 	CCodeExpression get_signal_info (ObjectTypeSymbol sym) {
@@ -918,41 +918,41 @@ public class Vala.GDBusServerModule : GDBusClientModule {
 				info.append (new CCodeConstant ("\"%s\"".printf (get_type_signature (param.variable_type, param))));
 
 				var cdecl = new CCodeDeclaration ("const GDBusArgInfo");
-				cdecl.add_declarator (new CCodeVariableDeclarator ("_" + sym.get_lower_case_cprefix () + "dbus_arg_info_" + get_ccode_name (sig) + "_" + param.name, info));
+				cdecl.add_declarator (new CCodeVariableDeclarator ("_" + get_ccode_lower_case_prefix (sym) + "dbus_arg_info_" + get_ccode_name (sig) + "_" + param.name, info));
 				cdecl.modifiers = CCodeModifiers.STATIC;
 				cfile.add_constant_declaration (cdecl);
 
-				args_info.append (new CCodeUnaryExpression (CCodeUnaryOperator.ADDRESS_OF, new CCodeIdentifier ("_" + sym.get_lower_case_cprefix () + "dbus_arg_info_" + get_ccode_name (sig) + "_" + param.name)));
+				args_info.append (new CCodeUnaryExpression (CCodeUnaryOperator.ADDRESS_OF, new CCodeIdentifier ("_" + get_ccode_lower_case_prefix (sym) + "dbus_arg_info_" + get_ccode_name (sig) + "_" + param.name)));
 			}
 
 			args_info.append (new CCodeConstant ("NULL"));
 
 			var cdecl = new CCodeDeclaration ("const GDBusArgInfo * const");
-			cdecl.add_declarator (new CCodeVariableDeclarator ("_" + sym.get_lower_case_cprefix () + "dbus_arg_info_" + get_ccode_name (sig) + "[]", args_info));
+			cdecl.add_declarator (new CCodeVariableDeclarator ("_" + get_ccode_lower_case_prefix (sym) + "dbus_arg_info_" + get_ccode_name (sig) + "[]", args_info));
 			cdecl.modifiers = CCodeModifiers.STATIC;
 			cfile.add_constant_declaration (cdecl);
 
 			var info = new CCodeInitializerList ();
 			info.append (new CCodeConstant ("-1"));
 			info.append (new CCodeConstant ("\"%s\"".printf (get_dbus_name_for_member (sig))));
-			info.append (new CCodeCastExpression (new CCodeUnaryExpression (CCodeUnaryOperator.ADDRESS_OF, new CCodeIdentifier ("_" + sym.get_lower_case_cprefix () + "dbus_arg_info_" + get_ccode_name (sig))), "GDBusArgInfo **"));
+			info.append (new CCodeCastExpression (new CCodeUnaryExpression (CCodeUnaryOperator.ADDRESS_OF, new CCodeIdentifier ("_" + get_ccode_lower_case_prefix (sym) + "dbus_arg_info_" + get_ccode_name (sig))), "GDBusArgInfo **"));
 
 			cdecl = new CCodeDeclaration ("const GDBusSignalInfo");
-			cdecl.add_declarator (new CCodeVariableDeclarator ("_" + sym.get_lower_case_cprefix () + "dbus_signal_info_" + get_ccode_name (sig), info));
+			cdecl.add_declarator (new CCodeVariableDeclarator ("_" + get_ccode_lower_case_prefix (sym) + "dbus_signal_info_" + get_ccode_name (sig), info));
 			cdecl.modifiers = CCodeModifiers.STATIC;
 			cfile.add_constant_declaration (cdecl);
 
-			infos.append (new CCodeUnaryExpression (CCodeUnaryOperator.ADDRESS_OF, new CCodeIdentifier ("_" + sym.get_lower_case_cprefix () + "dbus_signal_info_" + get_ccode_name (sig))));
+			infos.append (new CCodeUnaryExpression (CCodeUnaryOperator.ADDRESS_OF, new CCodeIdentifier ("_" + get_ccode_lower_case_prefix (sym) + "dbus_signal_info_" + get_ccode_name (sig))));
 		}
 
 		infos.append (new CCodeConstant ("NULL"));
 
 		var cdecl = new CCodeDeclaration ("const GDBusSignalInfo * const");
-		cdecl.add_declarator (new CCodeVariableDeclarator ("_" + sym.get_lower_case_cprefix () + "dbus_signal_info[]", infos));
+		cdecl.add_declarator (new CCodeVariableDeclarator ("_" + get_ccode_lower_case_prefix (sym) + "dbus_signal_info[]", infos));
 		cdecl.modifiers = CCodeModifiers.STATIC;
 		cfile.add_constant_declaration (cdecl);
 
-		return new CCodeIdentifier ("_" + sym.get_lower_case_cprefix () + "dbus_signal_info");
+		return new CCodeIdentifier ("_" + get_ccode_lower_case_prefix (sym) + "dbus_signal_info");
 	}
 
 	CCodeExpression get_property_info (ObjectTypeSymbol sym) {
@@ -982,21 +982,21 @@ public class Vala.GDBusServerModule : GDBusClientModule {
 			}
 
 			var cdecl = new CCodeDeclaration ("const GDBusPropertyInfo");
-			cdecl.add_declarator (new CCodeVariableDeclarator ("_" + sym.get_lower_case_cprefix () + "dbus_property_info_" + prop.name, info));
+			cdecl.add_declarator (new CCodeVariableDeclarator ("_" + get_ccode_lower_case_prefix (sym) + "dbus_property_info_" + prop.name, info));
 			cdecl.modifiers = CCodeModifiers.STATIC;
 			cfile.add_constant_declaration (cdecl);
 
-			infos.append (new CCodeUnaryExpression (CCodeUnaryOperator.ADDRESS_OF, new CCodeIdentifier ("_" + sym.get_lower_case_cprefix () + "dbus_property_info_" + prop.name)));
+			infos.append (new CCodeUnaryExpression (CCodeUnaryOperator.ADDRESS_OF, new CCodeIdentifier ("_" + get_ccode_lower_case_prefix (sym) + "dbus_property_info_" + prop.name)));
 		}
 
 		infos.append (new CCodeConstant ("NULL"));
 
 		var cdecl = new CCodeDeclaration ("const GDBusPropertyInfo * const");
-		cdecl.add_declarator (new CCodeVariableDeclarator ("_" + sym.get_lower_case_cprefix () + "dbus_property_info[]", infos));
+		cdecl.add_declarator (new CCodeVariableDeclarator ("_" + get_ccode_lower_case_prefix (sym) + "dbus_property_info[]", infos));
 		cdecl.modifiers = CCodeModifiers.STATIC;
 		cfile.add_constant_declaration (cdecl);
 
-		return new CCodeIdentifier ("_" + sym.get_lower_case_cprefix () + "dbus_property_info");
+		return new CCodeIdentifier ("_" + get_ccode_lower_case_prefix (sym) + "dbus_property_info");
 	}
 
 	CCodeExpression get_interface_info (ObjectTypeSymbol sym) {
@@ -1008,29 +1008,29 @@ public class Vala.GDBusServerModule : GDBusClientModule {
 		info.append (new CCodeCastExpression (new CCodeUnaryExpression (CCodeUnaryOperator.ADDRESS_OF, get_property_info (sym)), "GDBusPropertyInfo **"));
 
 		var cdecl = new CCodeDeclaration ("const GDBusInterfaceInfo");
-		cdecl.add_declarator (new CCodeVariableDeclarator ("_" + sym.get_lower_case_cprefix () + "dbus_interface_info", info));
+		cdecl.add_declarator (new CCodeVariableDeclarator ("_" + get_ccode_lower_case_prefix (sym) + "dbus_interface_info", info));
 		cdecl.modifiers = CCodeModifiers.STATIC;
 		cfile.add_constant_declaration (cdecl);
 
-		return new CCodeIdentifier ("_" + sym.get_lower_case_cprefix () + "dbus_interface_info");
+		return new CCodeIdentifier ("_" + get_ccode_lower_case_prefix (sym) + "dbus_interface_info");
 	}
 
 	CCodeExpression get_interface_vtable (ObjectTypeSymbol sym) {
 		var vtable = new CCodeInitializerList ();
-		vtable.append (new CCodeIdentifier (sym.get_lower_case_cprefix () + "dbus_interface_method_call"));
-		vtable.append (new CCodeIdentifier (sym.get_lower_case_cprefix () + "dbus_interface_get_property"));
-		vtable.append (new CCodeIdentifier (sym.get_lower_case_cprefix () + "dbus_interface_set_property"));
+		vtable.append (new CCodeIdentifier (get_ccode_lower_case_prefix (sym) + "dbus_interface_method_call"));
+		vtable.append (new CCodeIdentifier (get_ccode_lower_case_prefix (sym) + "dbus_interface_get_property"));
+		vtable.append (new CCodeIdentifier (get_ccode_lower_case_prefix (sym) + "dbus_interface_set_property"));
 
 		generate_interface_method_call_function (sym);
 		generate_interface_get_property_function (sym);
 		generate_interface_set_property_function (sym);
 
 		var cdecl = new CCodeDeclaration ("const GDBusInterfaceVTable");
-		cdecl.add_declarator (new CCodeVariableDeclarator ("_" + sym.get_lower_case_cprefix () + "dbus_interface_vtable", vtable));
+		cdecl.add_declarator (new CCodeVariableDeclarator ("_" + get_ccode_lower_case_prefix (sym) + "dbus_interface_vtable", vtable));
 		cdecl.modifiers = CCodeModifiers.STATIC;
 		cfile.add_constant_declaration (cdecl);
 
-		return new CCodeIdentifier ("_" + sym.get_lower_case_cprefix () + "dbus_interface_vtable");
+		return new CCodeIdentifier ("_" + get_ccode_lower_case_prefix (sym) + "dbus_interface_vtable");
 	}
 
 	string generate_register_object_function () {
@@ -1113,7 +1113,7 @@ public class Vala.GDBusServerModule : GDBusClientModule {
 				return;
 			}
 
-			cregister = new CCodeFunctionCall (new CCodeIdentifier ("%sregister_object".printf (object_type.type_symbol.get_lower_case_cprefix ())));
+			cregister = new CCodeFunctionCall (new CCodeIdentifier ("%sregister_object".printf (get_ccode_lower_case_prefix (object_type.type_symbol))));
 		} else {
 			// use runtime type information for generic methods
 			cregister = new CCodeFunctionCall (new CCodeIdentifier (generate_register_object_function ()));
@@ -1175,7 +1175,7 @@ public class Vala.GDBusServerModule : GDBusClientModule {
 			return;
 		}
 
-		string register_object_name = "%sregister_object".printf (sym.get_lower_case_cprefix ());
+		string register_object_name = "%sregister_object".printf (get_ccode_lower_case_prefix (sym));
 
 		if (add_symbol_declaration (decl_space, sym, register_object_name)) {
 			return;
@@ -1203,7 +1203,7 @@ public class Vala.GDBusServerModule : GDBusClientModule {
 
 		cfile.add_include ("gio/gio.h");
 
-		var cfunc = new CCodeFunction (sym.get_lower_case_cprefix () + "register_object", "guint");
+		var cfunc = new CCodeFunction (get_ccode_lower_case_prefix (sym) + "register_object", "guint");
 		cfunc.add_parameter (new CCodeParameter ("object", "gpointer"));
 		cfunc.add_parameter (new CCodeParameter ("connection", "GDBusConnection*"));
 		cfunc.add_parameter (new CCodeParameter ("path", "const gchar*"));
@@ -1252,7 +1252,7 @@ public class Vala.GDBusServerModule : GDBusClientModule {
 		cregister.add_argument (new CCodeUnaryExpression (CCodeUnaryOperator.ADDRESS_OF, get_interface_vtable (sym)));
 
 		cregister.add_argument (new CCodeIdentifier ("data"));
-		cregister.add_argument (new CCodeIdentifier ("_" + sym.get_lower_case_cprefix () + "unregister_object"));
+		cregister.add_argument (new CCodeIdentifier ("_" + get_ccode_lower_case_prefix (sym) + "unregister_object"));
 		cregister.add_argument (new CCodeIdentifier ("error"));
 
 		ccode.add_assignment (new CCodeIdentifier ("result"), cregister);
@@ -1269,7 +1269,7 @@ public class Vala.GDBusServerModule : GDBusClientModule {
 		cfile.add_function (cfunc);
 
 
-		cfunc = new CCodeFunction ("_" + sym.get_lower_case_cprefix () + "unregister_object");
+		cfunc = new CCodeFunction ("_" + get_ccode_lower_case_prefix (sym) + "unregister_object");
 		cfunc.add_parameter (new CCodeParameter ("user_data", "gpointer"));
 		cfunc.modifiers |= CCodeModifiers.STATIC;
 
@@ -1312,7 +1312,7 @@ public class Vala.GDBusServerModule : GDBusClientModule {
 		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 (quark);
-		set_qdata.add_argument (new CCodeCastExpression (new CCodeIdentifier (sym.get_lower_case_cprefix () + "register_object"), "void*"));
+		set_qdata.add_argument (new CCodeCastExpression (new CCodeIdentifier (get_ccode_lower_case_prefix (sym) + "register_object"), "void*"));
 
 		block.add_statement (new CCodeExpressionStatement (set_qdata));
 	}
diff --git a/codegen/valagerrormodule.vala b/codegen/valagerrormodule.vala
index cf717fe..85d4804 100644
--- a/codegen/valagerrormodule.vala
+++ b/codegen/valagerrormodule.vala
@@ -46,7 +46,7 @@ public class Vala.GErrorModule : CCodeDelegateModule {
 
 		decl_space.add_type_definition (cenum);
 
-		string quark_fun_name = edomain.get_lower_case_cprefix () + "quark";
+		string quark_fun_name = get_ccode_lower_case_prefix (edomain) + "quark";
 
 		var error_domain_define = new CCodeMacroReplacement (edomain.get_upper_case_cname (), quark_fun_name + " ()");
 		decl_space.add_type_definition (error_domain_define);
@@ -70,7 +70,7 @@ public class Vala.GErrorModule : CCodeDelegateModule {
 			generate_error_domain_declaration (edomain, internal_header_file);
 		}
 
-		string quark_fun_name = edomain.get_lower_case_cprefix () + "quark";
+		string quark_fun_name = get_ccode_lower_case_prefix (edomain) + "quark";
 
 		var cquark_fun = new CCodeFunction (quark_fun_name, get_ccode_name (gquark_type.data_type));
 		push_function (cquark_fun);
diff --git a/codegen/valagtypemodule.vala b/codegen/valagtypemodule.vala
index e2b0cd8..5c5f27a 100644
--- a/codegen/valagtypemodule.vala
+++ b/codegen/valagtypemodule.vala
@@ -90,8 +90,8 @@ public class Vala.GTypeModule : GErrorModule {
 		}
 
 		if (is_fundamental) {
-			var ref_fun = new CCodeFunction (cl.get_lower_case_cprefix () + "ref", "gpointer");
-			var unref_fun = new CCodeFunction (cl.get_lower_case_cprefix () + "unref", "void");
+			var ref_fun = new CCodeFunction (get_ccode_lower_case_prefix (cl) + "ref", "gpointer");
+			var unref_fun = new CCodeFunction (get_ccode_lower_case_prefix (cl) + "unref", "void");
 			if (cl.access == SymbolAccessibility.PRIVATE) {
 				ref_fun.modifiers = CCodeModifiers.STATIC;
 				unref_fun.modifiers = CCodeModifiers.STATIC;
@@ -157,7 +157,7 @@ public class Vala.GTypeModule : GErrorModule {
 			decl_space.add_function_declaration (function);
 		} else if (!is_gtypeinstance) {
 			if (cl.base_class == null) {
-				var function = new CCodeFunction (cl.get_lower_case_cprefix () + "free", "void");
+				var function = new CCodeFunction (get_ccode_lower_case_prefix (cl) + "free", "void");
 				if (cl.access == SymbolAccessibility.PRIVATE) {
 					function.modifiers = CCodeModifiers.STATIC;
 				}
@@ -646,7 +646,7 @@ public class Vala.GTypeModule : GErrorModule {
 				var ref_count = new CCodeMemberAccess.pointer (new CCodeIdentifier ("self"), "ref_count");
 
 				// ref function
-				var ref_fun = new CCodeFunction (cl.get_lower_case_cprefix () + "ref", "gpointer");
+				var ref_fun = new CCodeFunction (get_ccode_lower_case_prefix (cl) + "ref", "gpointer");
 				ref_fun.add_parameter (new CCodeParameter ("instance", "gpointer"));
 				if (cl.access == SymbolAccessibility.PRIVATE) {
 					ref_fun.modifiers = CCodeModifiers.STATIC;
@@ -663,7 +663,7 @@ public class Vala.GTypeModule : GErrorModule {
 				cfile.add_function (ref_fun);
 
 				// unref function
-				var unref_fun = new CCodeFunction (cl.get_lower_case_cprefix () + "unref", "void");
+				var unref_fun = new CCodeFunction (get_ccode_lower_case_prefix (cl) + "unref", "void");
 				unref_fun.add_parameter (new CCodeParameter ("instance", "gpointer"));
 				if (cl.access == SymbolAccessibility.PRIVATE) {
 					unref_fun.modifiers = CCodeModifiers.STATIC;
@@ -733,7 +733,7 @@ public class Vala.GTypeModule : GErrorModule {
 		push_function (function);
 		
 		var vpointer = new CCodeMemberAccess(new CCodeMemberAccess.pointer (new CCodeIdentifier ("value"), "data[0]"),"v_pointer");
-		var ccall = new CCodeFunctionCall (new CCodeIdentifier (cl.get_lower_case_cprefix () + "unref"));
+		var ccall = new CCodeFunctionCall (new CCodeIdentifier (get_ccode_lower_case_prefix (cl) + "unref"));
 		ccall.add_argument (vpointer);
 
 		ccode.open_if (vpointer);
@@ -755,7 +755,7 @@ public class Vala.GTypeModule : GErrorModule {
 		var dest_vpointer = new CCodeMemberAccess (new CCodeMemberAccess.pointer (new CCodeIdentifier ("dest_value"), "data[0]"), "v_pointer");
 		var src_vpointer = new CCodeMemberAccess (new CCodeMemberAccess.pointer (new CCodeIdentifier ("src_value"), "data[0]"), "v_pointer");
 
-		var ref_ccall = new CCodeFunctionCall (new CCodeIdentifier (cl.get_lower_case_cprefix () + "ref"));
+		var ref_ccall = new CCodeFunctionCall (new CCodeIdentifier (get_ccode_lower_case_prefix (cl) + "ref"));
 		ref_ccall.add_argument ( src_vpointer );
 
 		ccode.open_if (src_vpointer);
@@ -1194,7 +1194,7 @@ public class Vala.GTypeModule : GErrorModule {
 
 			ccall = new CCodeFunctionCall (new CCodeIdentifier ("%s_CLASS".printf (fundamental_class.get_upper_case_cname (null))));
 			ccall.add_argument (new CCodeIdentifier ("klass"));
-			var finalize_assignment = new CCodeAssignment (new CCodeMemberAccess.pointer (ccall, "finalize"), new CCodeIdentifier (cl.get_lower_case_cprefix () + "finalize"));
+			var finalize_assignment = new CCodeAssignment (new CCodeMemberAccess.pointer (ccall, "finalize"), new CCodeIdentifier (get_ccode_lower_case_prefix (cl) + "finalize"));
 			ccode.add_expression (finalize_assignment);
 		}
 
@@ -1600,7 +1600,7 @@ public class Vala.GTypeModule : GErrorModule {
 			ccode.add_declaration ("%s *".printf (get_ccode_name (cl)), new CCodeVariableDeclarator ("self"));
 			ccode.add_assignment (new CCodeIdentifier ("self"), ccall);
 		} else {
-			var function = new CCodeFunction (cl.get_lower_case_cprefix () + "free", "void");
+			var function = new CCodeFunction (get_ccode_lower_case_prefix (cl) + "free", "void");
 			if (cl.access == SymbolAccessibility.PRIVATE) {
 				function.modifiers = CCodeModifiers.STATIC;
 			}



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