vala r1896 - in trunk: . gobject vala



Author: juergbi
Date: Fri Oct 24 14:31:28 2008
New Revision: 1896
URL: http://svn.gnome.org/viewvc/vala?rev=1896&view=rev

Log:
2008-10-24  JÃrg Billeter  <j bitron ch>

	* vala/Makefile.am:
	* vala/valacodebinding.vala:
	* vala/valacodegenerator.vala:
	* vala/valacodenode.vala:
	* vala/valadynamicsignal.vala:
	* gobject/Makefile.am:
	* gobject/valaccodeassignmentmodule.vala:
	* gobject/valaccodebinding.vala:
	* gobject/valaccodedynamicsignalmodule.vala:
	* gobject/valaccodegenerator.vala:
	* gobject/valaccodemodule.vala:

	Add CCodeDynamicSignalModule, remove CodeBinding and CCodeBinding


Added:
   trunk/gobject/valaccodedynamicsignalmodule.vala   (contents, props changed)
      - copied, changed from r1880, /trunk/gobject/valaccodedynamicsignalbinding.vala
Removed:
   trunk/gobject/valaccodebinding.vala
   trunk/gobject/valaccodedynamicsignalbinding.vala
   trunk/vala/valacodebinding.vala
Modified:
   trunk/ChangeLog
   trunk/gobject/Makefile.am
   trunk/gobject/valaccodeassignmentmodule.vala
   trunk/gobject/valaccodegenerator.vala
   trunk/gobject/valaccodemodule.vala
   trunk/vala/Makefile.am
   trunk/vala/valacodegenerator.vala
   trunk/vala/valacodenode.vala
   trunk/vala/valadynamicsignal.vala

Modified: trunk/gobject/Makefile.am
==============================================================================
--- trunk/gobject/Makefile.am	(original)
+++ trunk/gobject/Makefile.am	Fri Oct 24 14:31:28 2008
@@ -15,10 +15,9 @@
 	valaccodearraymodule.vala \
 	valaccodeassignmentmodule.vala \
 	valaccodebasemodule.vala \
-	valaccodebinding.vala \
 	valaccodecompiler.vala \
 	valaccodedynamicpropertymodule.vala \
-	valaccodedynamicsignalbinding.vala \
+	valaccodedynamicsignalmodule.vala \
 	valaccodeelementaccessmodule.vala \
 	valaccodegenerator.vala \
 	valaccodegeneratorsignal.vala \

Modified: trunk/gobject/valaccodeassignmentmodule.vala
==============================================================================
--- trunk/gobject/valaccodeassignmentmodule.vala	(original)
+++ trunk/gobject/valaccodeassignmentmodule.vala	Fri Oct 24 14:31:28 2008
@@ -99,7 +99,7 @@
 
 		if (assignment.operator == AssignmentOperator.ADD) {
 			if (sig is DynamicSignal) {
-				connect_func = codegen.dynamic_signal_binding ((DynamicSignal) sig).get_connect_wrapper_name ();
+				connect_func = head.get_dynamic_signal_connect_wrapper_name ((DynamicSignal) sig);
 			} else {
 				connect_func = "g_signal_connect_object";
 				if (m.binding != MemberBinding.INSTANCE) {
@@ -108,7 +108,7 @@
 			}
 		} else if (assignment.operator == AssignmentOperator.SUB) {
 			if (sig is DynamicSignal) {
-				connect_func = codegen.dynamic_signal_binding ((DynamicSignal) sig).get_disconnect_wrapper_name ();
+				connect_func = head.get_dynamic_signal_disconnect_wrapper_name ((DynamicSignal) sig);
 			} else {
 				connect_func = "g_signal_handlers_disconnect_matched";
 			}

Copied: trunk/gobject/valaccodedynamicsignalmodule.vala (from r1880, /trunk/gobject/valaccodedynamicsignalbinding.vala)
==============================================================================
--- /trunk/gobject/valaccodedynamicsignalbinding.vala	(original)
+++ trunk/gobject/valaccodedynamicsignalmodule.vala	Fri Oct 24 14:31:28 2008
@@ -1,4 +1,4 @@
-/* valaccodedynamicsignalbinding.vala
+/* valaccodedynamicsignalmodule.vala
  *
  * Copyright (C) 2007-2008  JÃrg Billeter
  *
@@ -26,86 +26,71 @@
 /**
  * The link between a dynamic signal and generated code.
  */
-public class Vala.CCodeDynamicSignalBinding : CCodeBinding {
-	public Signal node { get; set; }
-
-	public CCodeDynamicSignalBinding (CCodeGenerator codegen, DynamicSignal node) {
-		this.node = node;
-		this.codegen = codegen;
+public class Vala.CCodeDynamicSignalModule : CCodeModule {
+	public CCodeDynamicSignalModule (CCodeGenerator codegen, CCodeModule? next) {
+		base (codegen, next);
 	}
 
-	string? connect_wrapper_name;
-	string? disconnect_wrapper_name;
-
-	string? dynamic_cname;
-
-	private static int signal_wrapper_id;
+	int signal_wrapper_id;
 
-	public string get_dynamic_cname () {
-		if (dynamic_cname == null) {
-			dynamic_cname = "dynamic_%s%d_".printf (node.name, signal_wrapper_id++);
-		}
-		return dynamic_cname;
+	public override string get_dynamic_signal_cname (DynamicSignal node) {
+		return "dynamic_%s%d_".printf (node.name, signal_wrapper_id++);
 	}
 
-	public string get_connect_wrapper_name () {
+	public override string get_dynamic_signal_connect_wrapper_name (DynamicSignal node) {
 		var dynamic_signal = (DynamicSignal) node;
 
-		if (connect_wrapper_name == null) {
-			connect_wrapper_name = "_%sconnect".printf (get_dynamic_cname ());
-			var func = new CCodeFunction (connect_wrapper_name, "void");
-			func.add_parameter (new CCodeFormalParameter ("obj", "gpointer"));
-			func.add_parameter (new CCodeFormalParameter ("signal_name", "const char *"));
-			func.add_parameter (new CCodeFormalParameter ("handler", "GCallback"));
-			func.add_parameter (new CCodeFormalParameter ("data", "gpointer"));
-			var block = new CCodeBlock ();
-			if (dynamic_signal.dynamic_type.data_type == codegen.dbus_object_type) {
-				generate_dbus_connect_wrapper (block);
-			} else if (dynamic_signal.dynamic_type.data_type != null
-			           && dynamic_signal.dynamic_type.data_type.is_subtype_of (codegen.gobject_type)) {
-				generate_gobject_connect_wrapper (block);
-			} else {
-				Report.error (node.source_reference, "dynamic signals are not supported for `%s'".printf (dynamic_signal.dynamic_type.to_string ()));
-			}
+		string connect_wrapper_name = "_%sconnect".printf (get_dynamic_signal_cname (node));
+		var func = new CCodeFunction (connect_wrapper_name, "void");
+		func.add_parameter (new CCodeFormalParameter ("obj", "gpointer"));
+		func.add_parameter (new CCodeFormalParameter ("signal_name", "const char *"));
+		func.add_parameter (new CCodeFormalParameter ("handler", "GCallback"));
+		func.add_parameter (new CCodeFormalParameter ("data", "gpointer"));
+		var block = new CCodeBlock ();
+		if (dynamic_signal.dynamic_type.data_type == codegen.dbus_object_type) {
+			generate_dbus_connect_wrapper (node, block);
+		} else if (dynamic_signal.dynamic_type.data_type != null
+		           && dynamic_signal.dynamic_type.data_type.is_subtype_of (codegen.gobject_type)) {
+			generate_gobject_connect_wrapper (node, block);
+		} else {
+			Report.error (node.source_reference, "dynamic signals are not supported for `%s'".printf (dynamic_signal.dynamic_type.to_string ()));
+		}
 
-			// append to C source file
-			codegen.source_type_member_declaration.append (func.copy ());
+		// append to C source file
+		codegen.source_type_member_declaration.append (func.copy ());
 
-			func.block = block;
-			codegen.source_type_member_definition.append (func);
-		}
+		func.block = block;
+		codegen.source_type_member_definition.append (func);
 
 		return connect_wrapper_name;
 	}
 
-	public string get_disconnect_wrapper_name () {
+	public override string get_dynamic_signal_disconnect_wrapper_name (DynamicSignal node) {
 		var dynamic_signal = (DynamicSignal) node;
 
-		if (disconnect_wrapper_name == null) {
-			disconnect_wrapper_name = "_%sdisconnect".printf (get_dynamic_cname ());
-			var func = new CCodeFunction (disconnect_wrapper_name, "void");
-			func.add_parameter (new CCodeFormalParameter ("obj", "gpointer"));
-			func.add_parameter (new CCodeFormalParameter ("signal_name", "const char *"));
-			func.add_parameter (new CCodeFormalParameter ("handler", "GCallback"));
-			func.add_parameter (new CCodeFormalParameter ("data", "gpointer"));
-			var block = new CCodeBlock ();
-			if (dynamic_signal.dynamic_type.data_type == codegen.dbus_object_type) {
-				generate_dbus_disconnect_wrapper (block);
-			} else {
-				Report.error (node.source_reference, "dynamic signals are not supported for `%s'".printf (dynamic_signal.dynamic_type.to_string ()));
-			}
+		string disconnect_wrapper_name = "_%sdisconnect".printf (get_dynamic_signal_cname (node));
+		var func = new CCodeFunction (disconnect_wrapper_name, "void");
+		func.add_parameter (new CCodeFormalParameter ("obj", "gpointer"));
+		func.add_parameter (new CCodeFormalParameter ("signal_name", "const char *"));
+		func.add_parameter (new CCodeFormalParameter ("handler", "GCallback"));
+		func.add_parameter (new CCodeFormalParameter ("data", "gpointer"));
+		var block = new CCodeBlock ();
+		if (dynamic_signal.dynamic_type.data_type == codegen.dbus_object_type) {
+			generate_dbus_disconnect_wrapper (node, block);
+		} else {
+			Report.error (node.source_reference, "dynamic signals are not supported for `%s'".printf (dynamic_signal.dynamic_type.to_string ()));
+		}
 
-			// append to C source file
-			codegen.source_type_member_declaration.append (func.copy ());
+		// append to C source file
+		codegen.source_type_member_declaration.append (func.copy ());
 
-			func.block = block;
-			codegen.source_type_member_definition.append (func);
-		}
+		func.block = block;
+		codegen.source_type_member_definition.append (func);
 
 		return disconnect_wrapper_name;
 	}
 
-	void generate_gobject_connect_wrapper (CCodeBlock block) {
+	void generate_gobject_connect_wrapper (DynamicSignal node, CCodeBlock block) {
 		var dynamic_signal = (DynamicSignal) node;
 
 		var m = (Method) dynamic_signal.handler.symbol_reference;
@@ -130,7 +115,7 @@
 		block.add_statement (new CCodeExpressionStatement (call));
 	}
 
-	void generate_dbus_connect_wrapper (CCodeBlock block) {
+	void generate_dbus_connect_wrapper (DynamicSignal node, CCodeBlock block) {
 		var dynamic_signal = (DynamicSignal) node;
 
 		var m = (Method) dynamic_signal.handler.symbol_reference;
@@ -197,7 +182,7 @@
 		block.add_statement (new CCodeExpressionStatement (call));
 	}
 
-	void generate_dbus_disconnect_wrapper (CCodeBlock block) {
+	void generate_dbus_disconnect_wrapper (DynamicSignal node, CCodeBlock block) {
 		var dynamic_signal = (DynamicSignal) node;
 
 		var call = new CCodeFunctionCall (new CCodeIdentifier ("dbus_g_proxy_disconnect_signal"));

Modified: trunk/gobject/valaccodegenerator.vala
==============================================================================
--- trunk/gobject/valaccodegenerator.vala	(original)
+++ trunk/gobject/valaccodegenerator.vala	Fri Oct 24 14:31:28 2008
@@ -3973,7 +3973,7 @@
 		var sig = d.parent_symbol as Signal;
 		var dynamic_sig = sig as DynamicSignal;
 		if (dynamic_sig != null) {
-			delegate_name = dynamic_signal_binding (dynamic_sig).get_dynamic_cname ();
+			delegate_name = head.get_dynamic_signal_cname (dynamic_sig);
 		} else if (sig != null) {
 			delegate_name = sig.parent_symbol.get_lower_case_cprefix () + sig.get_cname ();
 		} else {
@@ -4367,16 +4367,4 @@
 		}
 		return node.ccodenode;
 	}
-
-	public override CodeBinding? create_dynamic_signal_binding (DynamicSignal node) {
-		return new CCodeDynamicSignalBinding (this, node);
-	}
-
-	public CCodeBinding? code_binding (CodeNode node) {
-		return (CCodeBinding) node.get_code_binding (this);
-	}
-
-	public CCodeDynamicSignalBinding dynamic_signal_binding (DynamicSignal node) {
-		return (CCodeDynamicSignalBinding) node.get_code_binding (this);
-	}
 }

Modified: trunk/gobject/valaccodemodule.vala
==============================================================================
--- trunk/gobject/valaccodemodule.vala	(original)
+++ trunk/gobject/valaccodemodule.vala	Fri Oct 24 14:31:28 2008
@@ -131,4 +131,16 @@
 	public virtual string get_dynamic_property_setter_cname (DynamicProperty node) {
 		return next.get_dynamic_property_setter_cname (node);
 	}
+
+	public virtual string get_dynamic_signal_cname (DynamicSignal node) {
+		return next.get_dynamic_signal_cname (node);
+	}
+
+	public virtual string get_dynamic_signal_connect_wrapper_name (DynamicSignal node) {
+		return next.get_dynamic_signal_connect_wrapper_name (node);
+	}
+
+	public virtual string get_dynamic_signal_disconnect_wrapper_name (DynamicSignal node) {
+		return next.get_dynamic_signal_disconnect_wrapper_name (node);
+	}
 }

Modified: trunk/vala/Makefile.am
==============================================================================
--- trunk/vala/Makefile.am	(original)
+++ trunk/vala/Makefile.am	Fri Oct 24 14:31:28 2008
@@ -35,7 +35,6 @@
 	valacharacterliteral.vala \
 	valaclass.vala \
 	valaclasstype.vala \
-	valacodebinding.vala \
 	valacodecontext.vala \
 	valacodegenerator.vala \
 	valacodenode.vala \

Modified: trunk/vala/valacodegenerator.vala
==============================================================================
--- trunk/vala/valacodegenerator.vala	(original)
+++ trunk/vala/valacodegenerator.vala	Fri Oct 24 14:31:28 2008
@@ -33,8 +33,4 @@
 	 */
 	public virtual void emit (CodeContext context) {
 	}
-
-	public virtual CodeBinding? create_dynamic_signal_binding (DynamicSignal node) {
-		return null;
-	}
 }

Modified: trunk/vala/valacodenode.vala
==============================================================================
--- trunk/vala/valacodenode.vala	(original)
+++ trunk/vala/valacodenode.vala	Fri Oct 24 14:31:28 2008
@@ -153,7 +153,6 @@
 		return null;
 	}
 
-	private CodeBinding? code_binding;
 	private CCodeNode? _ccodenode;
 
 	/**
@@ -172,23 +171,4 @@
 
 		return str.append (" */").str;
 	}
-
-	/**
-	 * Returns the binding to the generated code.
-	 *
-	 * @return code binding
-	 */
-	public CodeBinding? get_code_binding (CodeGenerator codegen) {
-		if (code_binding == null) {
-			code_binding = create_code_binding (codegen);
-		}
-		return code_binding;
-	}
-
-	/**
-	 * Creates the binding to the generated code.
-	 */
-	public virtual CodeBinding? create_code_binding (CodeGenerator codegen) {
-		return null;
-	}
 }

Modified: trunk/vala/valadynamicsignal.vala
==============================================================================
--- trunk/vala/valadynamicsignal.vala	(original)
+++ trunk/vala/valadynamicsignal.vala	Fri Oct 24 14:31:28 2008
@@ -37,8 +37,4 @@
 		this.return_type = return_type;
 		this.source_reference = source_reference;
 	}
-
-	public override CodeBinding? create_code_binding (CodeGenerator codegen) {
-		return codegen.create_dynamic_signal_binding (this);
-	}
 }



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