[vala/wip/attributes: 37/100] codegen: Add get_ccode_vfunc_name



commit 64ce978e57c9106af01b2d9a0d456b1969ea1fe6
Author: Luca Bruno <lucabru src gnome org>
Date:   Tue Jun 28 20:56:57 2011 +0200

    codegen: Add get_ccode_vfunc_name

 codegen/valaccodebasemodule.vala         |   15 +++++++++++++++
 codegen/valaccodememberaccessmodule.vala |    4 ++--
 codegen/valaccodemethodcallmodule.vala   |    4 ++--
 codegen/valaccodemethodmodule.vala       |    2 +-
 codegen/valagasyncmodule.vala            |    2 +-
 codegen/valagdbusclientmodule.vala       |    2 +-
 codegen/valagsignalmodule.vala           |    2 +-
 codegen/valagtypemodule.vala             |   16 ++++++++--------
 8 files changed, 31 insertions(+), 16 deletions(-)
---
diff --git a/codegen/valaccodebasemodule.vala b/codegen/valaccodebasemodule.vala
index 217e898..6f4005d 100644
--- a/codegen/valaccodebasemodule.vala
+++ b/codegen/valaccodebasemodule.vala
@@ -5781,6 +5781,10 @@ public abstract class Vala.CCodeBaseModule : CodeGenerator {
 		return a != null && a.get_bool ("simple_generics");
 	}
 
+	public static string get_ccode_vfunc_name (Method m) {
+		return get_ccode_attribute(m).vfunc_name;
+	}
+
 	public override void visit_class (Class cl) {
 	}
 
@@ -6337,6 +6341,15 @@ public class Vala.CCodeAttribute : AttributeCache {
 		}
 	}
 
+	public string vfunc_name {
+		get {
+			if (_vfunc_name == null) {
+				_vfunc_name = sym.name;
+			}
+			return _vfunc_name;
+		}
+	}
+
 	public bool no_array_length { get; private set; }
 	public string? array_length_type { get; private set; }
 
@@ -6361,6 +6374,7 @@ public class Vala.CCodeAttribute : AttributeCache {
 	private string _param_spec_function;
 	private string _default_value;
 	private double? _pos;
+	private string _vfunc_name;
 
 	public CCodeAttribute (CodeNode node) {
 		this.node = node;
@@ -6406,6 +6420,7 @@ public class Vala.CCodeAttribute : AttributeCache {
 			if (attr.has_argument ("pos")) {
 				_pos = attr.get_double ("pos");
 			}
+			_vfunc_name = attr.get_string ("vfunc_name");
 		}
 	}
 
diff --git a/codegen/valaccodememberaccessmodule.vala b/codegen/valaccodememberaccessmodule.vala
index 92f91d2..6e787e0 100644
--- a/codegen/valaccodememberaccessmodule.vala
+++ b/codegen/valaccodememberaccessmodule.vala
@@ -54,13 +54,13 @@ public abstract class Vala.CCodeMemberAccessModule : CCodeControlFlowModule {
 					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 (get_ccode_lower_case_name (current_class, null))));
 					
-					set_cvalue (expr, new CCodeMemberAccess.pointer (vcast, m.vfunc_name));
+					set_cvalue (expr, new CCodeMemberAccess.pointer (vcast, get_ccode_vfunc_name (m)));
 					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 (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));
+					set_cvalue (expr, new CCodeMemberAccess.pointer (new CCodeIdentifier (parent_iface_var), get_ccode_vfunc_name (m)));
 					return;
 				}
 			}
diff --git a/codegen/valaccodemethodcallmodule.vala b/codegen/valaccodemethodcallmodule.vala
index 58f5b6b..36696c6 100644
--- a/codegen/valaccodemethodcallmodule.vala
+++ b/codegen/valaccodemethodcallmodule.vala
@@ -86,13 +86,13 @@ public class Vala.CCodeMethodCallModule : CCodeAssignmentModule {
 					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 (get_ccode_lower_case_name (current_class, null))));
 
-					async_call.call = new CCodeMemberAccess.pointer (vcast, m.vfunc_name);
+					async_call.call = new CCodeMemberAccess.pointer (vcast, get_ccode_vfunc_name (m));
 					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 (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);
+					async_call.call = new CCodeMemberAccess.pointer (new CCodeIdentifier (parent_iface_var), get_ccode_vfunc_name (m));
 					finish_call.call = new CCodeMemberAccess.pointer (new CCodeIdentifier (parent_iface_var), m.get_finish_vfunc_name ());
 				}
 			}
diff --git a/codegen/valaccodemethodmodule.vala b/codegen/valaccodemethodmodule.vala
index 24bfe5d..e9a68c4 100644
--- a/codegen/valaccodemethodmodule.vala
+++ b/codegen/valaccodemethodmodule.vala
@@ -904,7 +904,7 @@ public abstract class Vala.CCodeMethodModule : CCodeStructModule {
 		}
 		vcast.add_argument (new CCodeIdentifier ("self"));
 	
-		cname = m.vfunc_name;
+		cname = get_ccode_vfunc_name (m);
 		if (suffix == "_finish" && cname.has_suffix ("_async")) {
 			cname = cname.substring (0, cname.length - "_async".length);
 		}
diff --git a/codegen/valagasyncmodule.vala b/codegen/valagasyncmodule.vala
index a9c3822..0d64758 100644
--- a/codegen/valagasyncmodule.vala
+++ b/codegen/valagasyncmodule.vala
@@ -511,7 +511,7 @@ public class Vala.GAsyncModule : GSignalModule {
 		}
 
 		// add vfunc field to the type struct
-		var vdeclarator = new CCodeFunctionDeclarator (m.vfunc_name);
+		var vdeclarator = new CCodeFunctionDeclarator (get_ccode_vfunc_name (m));
 		var cparam_map = new HashMap<int,CCodeParameter> (direct_hash, direct_equal);
 
 		generate_cparameters (m, decl_space, cparam_map, new CCodeFunction ("fake"), vdeclarator, null, null, 1);
diff --git a/codegen/valagdbusclientmodule.vala b/codegen/valagdbusclientmodule.vala
index 16b010a..949d423 100644
--- a/codegen/valagdbusclientmodule.vala
+++ b/codegen/valagdbusclientmodule.vala
@@ -86,7 +86,7 @@ public class Vala.GDBusClientModule : GDBusModule {
 				continue;
 			}
 
-			var vfunc_entry = new CCodeMemberAccess.pointer (new CCodeIdentifier ("iface"), m.vfunc_name);
+			var vfunc_entry = new CCodeMemberAccess.pointer (new CCodeIdentifier ("iface"), get_ccode_vfunc_name (m));
 			if (!m.coroutine) {
 				ccode.add_assignment (vfunc_entry, new CCodeIdentifier (generate_dbus_proxy_method (main_iface, iface, m)));
 			} else {
diff --git a/codegen/valagsignalmodule.vala b/codegen/valagsignalmodule.vala
index 98ea9b4..8f7b223 100644
--- a/codegen/valagsignalmodule.vala
+++ b/codegen/valagsignalmodule.vala
@@ -345,7 +345,7 @@ public class Vala.GSignalModule : GObjectModule {
 				// interface
 				struct_offset.add_argument (new CCodeIdentifier (((Interface) type).get_type_cname ()));
 			}
-			struct_offset.add_argument (new CCodeIdentifier (sig.default_handler.vfunc_name));
+			struct_offset.add_argument (new CCodeIdentifier (get_ccode_vfunc_name (sig.default_handler)));
 			csignew.add_argument (struct_offset);
 		}
 		csignew.add_argument (new CCodeConstant ("NULL"));
diff --git a/codegen/valagtypemodule.vala b/codegen/valagtypemodule.vala
index f0ef83c..7089f4c 100644
--- a/codegen/valagtypemodule.vala
+++ b/codegen/valagtypemodule.vala
@@ -372,7 +372,7 @@ public class Vala.GTypeModule : GErrorModule {
 		}
 
 		// add vfunc field to the type struct
-		var vdeclarator = new CCodeFunctionDeclarator (m.vfunc_name);
+		var vdeclarator = new CCodeFunctionDeclarator (get_ccode_vfunc_name (m));
 		var cparam_map = new HashMap<int,CCodeParameter> (direct_hash, direct_equal);
 
 		generate_cparameters (m, decl_space, cparam_map, new CCodeFunction ("fake"), vdeclarator);
@@ -1218,7 +1218,7 @@ public class Vala.GTypeModule : GErrorModule {
 				var ccast = new CCodeFunctionCall (new CCodeIdentifier ("%s_CLASS".printf (((Class) base_type).get_upper_case_cname (null))));
 				ccast.add_argument (new CCodeIdentifier ("klass"));
 
-				ccode.add_assignment (new CCodeMemberAccess.pointer (ccast, m.base_method.vfunc_name), new CCodeIdentifier (m.get_real_cname ()));
+				ccode.add_assignment (new CCodeMemberAccess.pointer (ccast, get_ccode_vfunc_name (m.base_method)), new CCodeIdentifier (m.get_real_cname ()));
 
 				if (m.coroutine) {
 					ccode.add_assignment (new CCodeMemberAccess.pointer (ccast, m.base_method.get_finish_vfunc_name ()), new CCodeIdentifier (m.get_finish_real_cname ()));
@@ -1233,7 +1233,7 @@ public class Vala.GTypeModule : GErrorModule {
 			}
 			var ccast = new CCodeFunctionCall (new CCodeIdentifier ("%s_CLASS".printf (cl.get_upper_case_cname (null))));
 			ccast.add_argument (new CCodeIdentifier ("klass"));
-			ccode.add_assignment (new CCodeMemberAccess.pointer (ccast, sig.default_handler.vfunc_name), new CCodeIdentifier (sig.default_handler.get_real_cname ()));
+			ccode.add_assignment (new CCodeMemberAccess.pointer (ccast, get_ccode_vfunc_name (sig.default_handler)), new CCodeIdentifier (sig.default_handler.get_real_cname ()));
 		}
 
 		/* connect overridden properties */
@@ -1314,7 +1314,7 @@ public class Vala.GTypeModule : GErrorModule {
 				cfunc = new CCodeIdentifier (m.get_real_cname ());
 			}
 			cfunc = cast_method_pointer (m.base_interface_method, cfunc, iface);
-			ccode.add_assignment (new CCodeMemberAccess.pointer (ciface, m.base_interface_method.vfunc_name), cfunc);
+			ccode.add_assignment (new CCodeMemberAccess.pointer (ciface, get_ccode_vfunc_name (m.base_interface_method)), cfunc);
 
 			if (m.coroutine) {
 				if (m.is_abstract || m.is_virtual) {
@@ -1350,7 +1350,7 @@ public class Vala.GTypeModule : GErrorModule {
 					CCodeExpression cfunc = new CCodeIdentifier (get_ccode_name (base_method));
 					cfunc = cast_method_pointer (base_method, cfunc, iface);
 					var ciface = new CCodeIdentifier ("iface");
-					ccode.add_assignment (new CCodeMemberAccess.pointer (ciface, m.vfunc_name), cfunc);
+					ccode.add_assignment (new CCodeMemberAccess.pointer (ciface, get_ccode_vfunc_name (m)), cfunc);
 				}
 			}
 		}
@@ -1458,7 +1458,7 @@ public class Vala.GTypeModule : GErrorModule {
 		string cast = get_ccode_name (m.return_type) + " (*)";
 		string cast_args = get_ccode_name (base_type) + "*";
 
-		var vdeclarator = new CCodeFunctionDeclarator (m.vfunc_name);
+		var vdeclarator = new CCodeFunctionDeclarator (get_ccode_vfunc_name (m));
 		var cparam_map = new HashMap<int,CCodeParameter> (direct_hash, direct_equal);
 
 		generate_cparameters (m, cfile, cparam_map, new CCodeFunction ("fake"), vdeclarator);
@@ -2024,7 +2024,7 @@ public class Vala.GTypeModule : GErrorModule {
 				continue;
 			}
 			var cname = sig.default_handler.get_real_cname ();
-			ccode.add_assignment (new CCodeMemberAccess.pointer (ciface, sig.default_handler.vfunc_name), new CCodeIdentifier (cname));
+			ccode.add_assignment (new CCodeMemberAccess.pointer (ciface, get_ccode_vfunc_name (sig.default_handler)), new CCodeIdentifier (cname));
 		}
 
 		/* create signals */
@@ -2039,7 +2039,7 @@ public class Vala.GTypeModule : GErrorModule {
 		foreach (Method m in iface.get_methods ()) {
 			if (m.is_virtual) {
 				var cname = m.get_real_cname ();
-				ccode.add_assignment (new CCodeMemberAccess.pointer (ciface, m.vfunc_name), new CCodeIdentifier (cname));
+				ccode.add_assignment (new CCodeMemberAccess.pointer (ciface, get_ccode_vfunc_name (m)), new CCodeIdentifier (cname));
 				if (m.coroutine) {
 					ccode.add_assignment (new CCodeMemberAccess.pointer (ciface, m.get_finish_vfunc_name ()), new CCodeIdentifier (m.get_finish_real_cname ()));
 				}



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