[vala] Fix closures in constructors
- From: Jürg Billeter <juergbi src gnome org>
- To: svn-commits-list gnome org
- Cc:
- Subject: [vala] Fix closures in constructors
- Date: Wed, 16 Sep 2009 22:14:53 +0000 (UTC)
commit 659cd2afb73e1d034e454045a9af1bfe1b734488
Author: Jürg Billeter <j bitron ch>
Date: Thu Sep 17 00:11:54 2009 +0200
Fix closures in constructors
codegen/valaccodebasemodule.vala | 4 ++--
codegen/valagobjectmodule.vala | 3 ++-
2 files changed, 4 insertions(+), 3 deletions(-)
---
diff --git a/codegen/valaccodebasemodule.vala b/codegen/valaccodebasemodule.vala
index a6e310e..a93440d 100644
--- a/codegen/valaccodebasemodule.vala
+++ b/codegen/valaccodebasemodule.vala
@@ -1630,7 +1630,7 @@ internal class Vala.CCodeBaseModule : CCodeModule {
var unref_call = new CCodeFunctionCall (new CCodeIdentifier ("block%d_data_unref".printf (parent_block_id)));
unref_call.add_argument (new CCodeMemberAccess.pointer (new CCodeIdentifier ("data"), "_data%d_".printf (parent_block_id)));
free_block.add_statement (new CCodeExpressionStatement (unref_call));
- } else if (current_method.binding == MemberBinding.INSTANCE) {
+ } else if (in_constructor || (current_method != null && current_method.binding == MemberBinding.INSTANCE)) {
data.add_field ("%s *".printf (current_class.get_cname ()), "self");
var ma = new MemberAccess.simple ("this");
@@ -1679,7 +1679,7 @@ internal class Vala.CCodeBaseModule : CCodeModule {
ref_call.add_argument (get_variable_cexpression ("_data%d_".printf (parent_block_id)));
cblock.add_statement (new CCodeExpressionStatement (new CCodeAssignment (new CCodeMemberAccess.pointer (get_variable_cexpression ("_data%d_".printf (block_id)), "_data%d_".printf (parent_block_id)), ref_call)));
- } else if (current_method.binding == MemberBinding.INSTANCE) {
+ } else if (in_constructor || (current_method != null && current_method.binding == MemberBinding.INSTANCE)) {
var ref_call = new CCodeFunctionCall (get_dup_func_expression (new ObjectType (current_class), b.source_reference));
ref_call.add_argument (new CCodeIdentifier ("self"));
diff --git a/codegen/valagobjectmodule.vala b/codegen/valagobjectmodule.vala
index 504474c..467ff19 100644
--- a/codegen/valagobjectmodule.vala
+++ b/codegen/valagobjectmodule.vala
@@ -412,10 +412,11 @@ internal class Vala.GObjectModule : GTypeModule {
public override void visit_constructor (Constructor c) {
bool old_method_inner_error = current_method_inner_error;
current_method_inner_error = false;
- in_constructor = true;
if (c.binding == MemberBinding.CLASS || c.binding == MemberBinding.STATIC) {
in_static_or_class_context = true;
+ } else {
+ in_constructor = true;
}
c.accept_children (codegen);
in_static_or_class_context = false;
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]