From: Juerg Billeter Date: Sun, 2 Mar 2008 22:10:37 +0000 (+0000) Subject: don't free arguments of ref and out parameters X-Git-Tag: VALA_0_2_0~90 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=251284b98b7aca863bf706c8ebb01210767488b5;p=platform%2Fupstream%2Fvala.git don't free arguments of ref and out parameters 2008-03-02 Juerg Billeter * gobject/valaccodegenerator.vala: don't free arguments of ref and out parameters * tests/classes-methods.vala: test ref parameter svn path=/trunk/; revision=1096 --- diff --git a/ChangeLog b/ChangeLog index abe06af..47d4aa6 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,5 +1,12 @@ 2008-03-02 Jürg Billeter + * gobject/valaccodegenerator.vala: don't free arguments of ref and + out parameters + + * tests/classes-methods.vala: test ref parameter + +2008-03-02 Jürg Billeter + * tests/testrunner.sh: make sure we detect failed test cases 2008-03-02 Jürg Billeter diff --git a/gobject/valaccodegenerator.vala b/gobject/valaccodegenerator.vala index ab5013e..e3499e5 100644 --- a/gobject/valaccodegenerator.vala +++ b/gobject/valaccodegenerator.vala @@ -916,7 +916,7 @@ public class Vala.CCodeGenerator : CodeGenerator { if (b.parent_symbol is Method) { var m = (Method) b.parent_symbol; foreach (FormalParameter param in m.get_parameters ()) { - if (param.type_reference.data_type != null && param.type_reference.data_type.is_reference_type () && param.type_reference.takes_ownership) { + if (param.type_reference.data_type != null && param.type_reference.data_type.is_reference_type () && param.type_reference.takes_ownership && !param.type_reference.is_ref && !param.type_reference.is_out) { var ma = new MemberAccess.simple (param.name); ma.symbol_reference = param; cblock.add_statement (new CCodeExpressionStatement (get_unref_expression (new CCodeIdentifier (get_variable_cname (param.name)), param.type_reference, ma))); @@ -1936,7 +1936,7 @@ public class Vala.CCodeGenerator : CodeGenerator { private void append_param_free (Method m, CCodeFragment cfrag) { foreach (FormalParameter param in m.get_parameters ()) { - if (param.type_reference.data_type != null && param.type_reference.data_type.is_reference_type () && param.type_reference.takes_ownership) { + if (param.type_reference.data_type != null && param.type_reference.data_type.is_reference_type () && param.type_reference.takes_ownership && !param.type_reference.is_ref && !param.type_reference.is_out) { var ma = new MemberAccess.simple (param.name); ma.symbol_reference = param; cfrag.append (new CCodeExpressionStatement (get_unref_expression (new CCodeIdentifier (get_variable_cname (param.name)), param.type_reference, ma))); @@ -1981,7 +1981,7 @@ public class Vala.CCodeGenerator : CodeGenerator { bool found = false; foreach (FormalParameter param in m.get_parameters ()) { - if (param.type_reference.data_type != null && param.type_reference.data_type.is_reference_type () && param.type_reference.takes_ownership) { + if (param.type_reference.data_type != null && param.type_reference.data_type.is_reference_type () && param.type_reference.takes_ownership && !param.type_reference.is_ref && !param.type_reference.is_out) { found = true; var ma = new MemberAccess.simple (param.name); ma.symbol_reference = param; diff --git a/tests/classes-methods.vala b/tests/classes-methods.vala index 3d1dc7c..1637908 100644 --- a/tests/classes-methods.vala +++ b/tests/classes-methods.vala @@ -19,6 +19,14 @@ class Maman.SubBar : Bar { stdout.printf (" 2"); } + static void accept_ref_string (ref string str) { + } + + static void test_classes_methods_ref_parameters () { + string str = "hello"; + accept_ref_string (ref str); + } + static int main (string[] args) { stdout.printf ("Inheritance Test: 1"); @@ -48,6 +56,8 @@ class Maman.SubBar : Bar { stdout.printf (" 3\n"); + test_classes_methods_ref_parameters (); + return 0; } }