[vala] More delegate fixes



commit 804d578aaa2a2425f2da31c7441be93111be98dc
Author: Jürg Billeter <j bitron ch>
Date:   Sat Sep 19 13:26:42 2009 +0200

    More delegate fixes

 codegen/valaccodebasemodule.vala   |   15 +++++++++++++++
 codegen/valaccodestructmodule.vala |    3 +++
 2 files changed, 18 insertions(+), 0 deletions(-)
---
diff --git a/codegen/valaccodebasemodule.vala b/codegen/valaccodebasemodule.vala
index 1c16854..1a71181 100644
--- a/codegen/valaccodebasemodule.vala
+++ b/codegen/valaccodebasemodule.vala
@@ -2696,6 +2696,7 @@ internal class Vala.CCodeBaseModule : CCodeModule {
 		foreach (LocalVariable local in temp_ref_vars) {
 			var ma = new MemberAccess.simple (local.name);
 			ma.symbol_reference = local;
+			ma.value_type = local.variable_type.copy ();
 			cfrag.append (new CCodeExpressionStatement (get_unref_expression (get_variable_cexpression (local.name), local.variable_type, ma)));
 		}
 		
@@ -4196,6 +4197,20 @@ internal class Vala.CCodeBaseModule : CCodeModule {
 					}
 					ccomma.append_expression (get_variable_cexpression (decl.name));
 					cexpr = ccomma;
+				} else if (expression_type is DelegateType && expr != null) {
+					var ccomma = new CCodeCommaExpression ();
+					ccomma.append_expression (cexpr);
+
+					var target_decl = new LocalVariable (new PointerType (new VoidType ()), get_delegate_target_cname (decl.name));
+					temp_vars.insert (0, target_decl);
+					var target_destroy_notify_decl = new LocalVariable (new DelegateType ((Delegate) context.root.scope.lookup ("GLib").scope.lookup ("DestroyNotify")), get_delegate_target_destroy_notify_cname (decl.name));
+					temp_vars.insert (0, target_destroy_notify_decl);
+					CCodeExpression target_destroy_notify;
+					ccomma.append_expression (new CCodeAssignment (get_variable_cexpression (target_decl.name), get_delegate_target_cexpression (expr, out target_destroy_notify)));
+					ccomma.append_expression (new CCodeAssignment (get_variable_cexpression (target_destroy_notify_decl.name), target_destroy_notify));
+
+					ccomma.append_expression (get_variable_cexpression (decl.name));
+					cexpr = ccomma;
 				}
 			}
 		}
diff --git a/codegen/valaccodestructmodule.vala b/codegen/valaccodestructmodule.vala
index c1d9f4a..6c2dabf 100644
--- a/codegen/valaccodestructmodule.vala
+++ b/codegen/valaccodestructmodule.vala
@@ -94,6 +94,9 @@ internal class Vala.CCodeStructModule : CCodeBaseModule {
 					if (delegate_type.delegate_symbol.has_target) {
 						// create field to store delegate target
 						instance_struct.add_field ("gpointer", get_delegate_target_cname (f.name));
+						if (delegate_type.value_owned) {
+							instance_struct.add_field ("GDestroyNotify", get_delegate_target_destroy_notify_cname (f.name));
+						}
 					}
 				}
 			}



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