[vala] codegen: Remove fallback in delegate target handling
- From: Jürg Billeter <juergbi src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [vala] codegen: Remove fallback in delegate target handling
- Date: Thu, 21 Oct 2010 18:04:16 +0000 (UTC)
commit f261f2e0c3d50675a67d9d5009ae37c30d9ccfa8
Author: Jürg Billeter <j bitron ch>
Date: Sun Oct 17 20:33:54 2010 +0200
codegen: Remove fallback in delegate target handling
codegen/valaccodebasemodule.vala | 1 +
codegen/valaccodedelegatemodule.vala | 12 ++----------
codegen/valaccodememberaccessmodule.vala | 7 +++++++
vala/valamethod.vala | 1 +
4 files changed, 11 insertions(+), 10 deletions(-)
---
diff --git a/codegen/valaccodebasemodule.vala b/codegen/valaccodebasemodule.vala
index 678d139..51a145a 100644
--- a/codegen/valaccodebasemodule.vala
+++ b/codegen/valaccodebasemodule.vala
@@ -3602,6 +3602,7 @@ public class Vala.CCodeBaseModule : CodeGenerator {
}
} else if (delegate_type != null && delegate_type.delegate_symbol.has_target) {
set_delegate_target (expr, new CCodeConstant ("NULL"));
+ set_delegate_target_destroy_notify (expr, new CCodeConstant ("NULL"));
}
}
diff --git a/codegen/valaccodedelegatemodule.vala b/codegen/valaccodedelegatemodule.vala
index 86734f2..8fc1610 100644
--- a/codegen/valaccodedelegatemodule.vala
+++ b/codegen/valaccodedelegatemodule.vala
@@ -129,17 +129,9 @@ public class Vala.CCodeDelegateModule : CCodeArrayModule {
}
public override CCodeExpression get_delegate_target_cexpression (Expression delegate_expr, out CCodeExpression delegate_target_destroy_notify) {
- delegate_target_destroy_notify = new CCodeConstant ("NULL");
+ delegate_target_destroy_notify = get_delegate_target_destroy_notify (delegate_expr);
- if (get_delegate_target_destroy_notify (delegate_expr) != null) {
- delegate_target_destroy_notify = get_delegate_target_destroy_notify (delegate_expr);
- }
- var target_expr = get_delegate_target (delegate_expr);
- if (target_expr == null) {
- return new CCodeConstant ("NULL");
- } else {
- return target_expr;
- }
+ return get_delegate_target (delegate_expr);
}
public override string get_delegate_target_destroy_notify_cname (string delegate_cname) {
diff --git a/codegen/valaccodememberaccessmodule.vala b/codegen/valaccodememberaccessmodule.vala
index c17a6f6..6f57813 100644
--- a/codegen/valaccodememberaccessmodule.vala
+++ b/codegen/valaccodememberaccessmodule.vala
@@ -92,6 +92,7 @@ public class Vala.CCodeMemberAccessModule : CCodeControlFlowModule {
}
if (expr.target_type is DelegateType) {
+ set_delegate_target_destroy_notify (expr, new CCodeConstant ("NULL"));
if (m.binding == MemberBinding.STATIC) {
set_delegate_target (expr, new CCodeConstant ("NULL"));
} else if (m.is_async_callback) {
@@ -203,6 +204,7 @@ public class Vala.CCodeMemberAccessModule : CCodeControlFlowModule {
string target_cname = get_delegate_target_cname (field.get_cname ());
string target_destroy_notify_cname = get_delegate_target_destroy_notify_cname (field.get_cname ());
+ set_delegate_target_destroy_notify (expr, new CCodeConstant ("NULL"));
if (field.no_delegate_target) {
set_delegate_target (expr, new CCodeConstant ("NULL"));
} else {
@@ -271,6 +273,7 @@ public class Vala.CCodeMemberAccessModule : CCodeControlFlowModule {
}
}
} else if (field.variable_type is DelegateType) {
+ set_delegate_target_destroy_notify (expr, new CCodeConstant ("NULL"));
if (field.no_delegate_target) {
set_delegate_target (expr, new CCodeConstant ("NULL"));
} else {
@@ -502,6 +505,8 @@ public class Vala.CCodeMemberAccessModule : CCodeControlFlowModule {
set_delegate_target (expr, new CCodeIdentifier (get_delegate_target_cname (get_variable_cname (local.name))));
if (expr.value_type.value_owned) {
set_delegate_target_destroy_notify (expr, new CCodeIdentifier (get_delegate_target_destroy_notify_cname (get_variable_cname (local.name))));
+ } else {
+ set_delegate_target_destroy_notify (expr, new CCodeConstant ("NULL"));
}
}
}
@@ -594,6 +599,8 @@ public class Vala.CCodeMemberAccessModule : CCodeControlFlowModule {
set_delegate_target (expr, target_expr);
if (expr.value_type.value_owned) {
set_delegate_target_destroy_notify (expr, delegate_target_destroy_notify);
+ } else {
+ set_delegate_target_destroy_notify (expr, new CCodeConstant ("NULL"));
}
}
}
diff --git a/vala/valamethod.vala b/vala/valamethod.vala
index d48d356..6d61d6c 100644
--- a/vala/valamethod.vala
+++ b/vala/valamethod.vala
@@ -1115,6 +1115,7 @@ public class Vala.Method : Symbol {
var callback_param = new FormalParameter ("_callback_", callback_type);
callback_param.initializer = new NullLiteral (source_reference);
+ callback_param.initializer.target_type = callback_type.copy ();
callback_param.cparameter_position = -1;
callback_param.cdelegate_target_parameter_position = -0.9;
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]