]> git.ipfire.org Git - thirdparty/vala.git/commitdiff
support methods throwing exceptions and returning generic type parameter
authorJuerg Billeter <j@bitron.ch>
Fri, 29 Feb 2008 22:23:29 +0000 (22:23 +0000)
committerJürg Billeter <juergbi@src.gnome.org>
Fri, 29 Feb 2008 22:23:29 +0000 (22:23 +0000)
2008-02-29  Juerg Billeter  <j@bitron.ch>

* gobject/valaccodegenerator.vala,
  gobject/valaccodegeneratormethod.vala: support methods throwing
  exceptions and returning generic type parameter

svn path=/trunk/; revision=1070

ChangeLog
gobject/valaccodegenerator.vala
gobject/valaccodegeneratormethod.vala

index c0b8a2e378dfb22dde58485749d5b621caaadd67..3ec905d17ac6c0d25ebfbb2c1a37d4b5a9e2350e 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,9 @@
+2008-02-29  Jürg Billeter  <j@bitron.ch>
+
+       * gobject/valaccodegenerator.vala,
+         gobject/valaccodegeneratormethod.vala: support methods throwing
+         exceptions and returning generic type parameter
+
 2008-02-29  Jürg Billeter  <j@bitron.ch>
 
        * vala/parser.y, vala/valacodecontext.vala, vala/valaenumvalue.vala:
index 4457916c40650ddfb1a8e57a17998732efa1b9ee..e9aa25a69b84ca0bd891a745deaca527ac4222d5 100644 (file)
@@ -1354,10 +1354,10 @@ public class Vala.CCodeGenerator : CodeGenerator {
                        var cerror_block = new CCodeBlock ();
                        cerror_block.add_statement (new CCodeExpressionStatement (cpropagate));
 
-                       if (current_return_type != null && current_return_type.data_type != null) {
-                               cerror_block.add_statement (new CCodeReturnStatement (default_value_for_type (current_return_type)));
-                       } else {
+                       if (current_return_type is VoidType) {
                                cerror_block.add_statement (new CCodeReturnStatement ());
+                       } else {
+                               cerror_block.add_statement (new CCodeReturnStatement (default_value_for_type (current_return_type)));
                        }
 
                        var ccond = new CCodeBinaryExpression (CCodeBinaryOperator.INEQUALITY, new CCodeIdentifier ("inner_error"), new CCodeConstant ("NULL"));
@@ -2111,22 +2111,6 @@ public class Vala.CCodeGenerator : CodeGenerator {
 
                add_simple_check (stmt, cfrag);
 
-               /* free temporary objects */
-               foreach (VariableDeclarator decl in temp_ref_vars) {
-                       var ma = new MemberAccess.simple (decl.name);
-                       ma.symbol_reference = decl;
-                       cfrag.append (new CCodeExpressionStatement (get_unref_expression (new CCodeIdentifier (decl.name), decl.type_reference, ma)));
-               }
-
-               temp_vars.clear ();
-               temp_ref_vars.clear ();
-
-               if (current_return_type != null && current_return_type.data_type != null) {
-                       cfrag.append (new CCodeReturnStatement (default_value_for_type (current_return_type)));
-               } else {
-                       cfrag.append (new CCodeReturnStatement ());
-               }
-
                stmt.ccodenode = cfrag;
        }
 
index 3a60c80448969bdbe4959903d3024772c9acae8f..b31114a7b86f55c6b93e5887191dc168d2db2e44 100644 (file)
@@ -731,6 +731,10 @@ public class Vala.CCodeGenerator {
                        return new CCodeConstant ("NULL");
                } else if (type.data_type != null && type.data_type.get_default_value () != null) {
                        return new CCodeConstant (type.data_type.get_default_value ());
+               } else if (type.type_parameter != null) {
+                       return new CCodeConstant ("NULL");
+               } else if (type is ErrorType) {
+                       return new CCodeConstant ("NULL");
                }
                return null;
        }