From: Juerg Billeter Date: Wed, 16 Apr 2008 16:15:53 +0000 (+0000) Subject: Fix generated C code when calling struct methods X-Git-Tag: VALA_0_3_1~57 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=5e24e1ea87a7042bcaa0987fcf6e0ed9fa5945f5;p=platform%2Fupstream%2Fvala.git Fix generated C code when calling struct methods 2008-04-16 Juerg Billeter * gobject/valaccodegeneratorinvocationexpression.vala: Fix generated C code when calling struct methods svn path=/trunk/; revision=1245 --- diff --git a/ChangeLog b/ChangeLog index b29fe31..29d9e15 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,5 +1,11 @@ 2008-04-16 Jürg Billeter + * gobject/valaccodegeneratorinvocationexpression.vala: + + Fix generated C code when calling struct methods + +2008-04-16 Jürg Billeter + * gobject/valaccodegenerator.vala, gobject/valaccodegeneratorinvocationexpression.vala: diff --git a/gobject/valaccodegeneratorinvocationexpression.vala b/gobject/valaccodegeneratorinvocationexpression.vala index 3528550..3b20b3d 100644 --- a/gobject/valaccodegeneratorinvocationexpression.vala +++ b/gobject/valaccodegeneratorinvocationexpression.vala @@ -82,7 +82,20 @@ public class Vala.CCodeGenerator { } if (instance_expression_type.data_type is Struct && !((Struct) instance_expression_type.data_type).is_simple_type () && instance_expression_type.data_type != current_type_symbol) { - instance = new CCodeUnaryExpression (CCodeUnaryOperator.ADDRESS_OF, instance); + if (instance is CCodeIdentifier) { + instance = new CCodeUnaryExpression (CCodeUnaryOperator.ADDRESS_OF, instance); + } else { + // if instance is e.g. a function call, we can't take the address of the expression + // (tmp = expr, &tmp) + var ccomma = new CCodeCommaExpression (); + + var temp_var = get_temp_variable (instance_expression_type); + temp_vars.insert (0, temp_var); + ccomma.append_expression (new CCodeAssignment (new CCodeIdentifier (temp_var.name), instance)); + ccomma.append_expression (new CCodeUnaryExpression (CCodeUnaryOperator.ADDRESS_OF, new CCodeIdentifier (temp_var.name))); + + instance = ccomma; + } } // parent_symbol may be null for late bound methods