Support catch clauses without error variable, fixes bug 529539
authorJuerg Billeter <j@bitron.ch>
Sat, 26 Apr 2008 07:39:28 +0000 (07:39 +0000)
committerJürg Billeter <juergbi@src.gnome.org>
Sat, 26 Apr 2008 07:39:28 +0000 (07:39 +0000)
2008-04-26  Juerg Billeter  <j@bitron.ch>

* vala/valacatchclause.vala:
* gobject/valaccodegenerator.vala:

Support catch clauses without error variable, fixes bug 529539

svn path=/trunk/; revision=1316

ChangeLog
gobject/valaccodegenerator.vala
vala/valacatchclause.vala

index f9ee415..1ef4902 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,5 +1,12 @@
 2008-04-26  Jürg Billeter  <j@bitron.ch>
 
+       * vala/valacatchclause.vala:
+       * gobject/valaccodegenerator.vala:
+
+       Support catch clauses without error variable, fixes bug 529539
+
+2008-04-26  Jürg Billeter  <j@bitron.ch>
+
        * vala/valanamespace.vala:
        * vala/valaparser.vala:
 
index 75ecbb0..3dc3797 100644 (file)
@@ -2297,8 +2297,13 @@ public class Vala.CCodeGenerator : CodeGenerator {
 
                var cblock = new CCodeBlock ();
 
+               string variable_name = clause.variable_name;
+               if (variable_name == null) {
+                       variable_name = "__err";
+               }
+
                var cdecl = new CCodeDeclaration ("GError *");
-               cdecl.add_declarator (new CCodeVariableDeclarator.with_initializer (clause.variable_name, new CCodeIdentifier ("inner_error")));
+               cdecl.add_declarator (new CCodeVariableDeclarator.with_initializer (variable_name, new CCodeIdentifier ("inner_error")));
                cblock.add_statement (cdecl);
                cblock.add_statement (new CCodeExpressionStatement (new CCodeAssignment (new CCodeIdentifier ("inner_error"), new CCodeConstant ("NULL"))));
 
index 301527a..ec43c9f 100644 (file)
@@ -42,7 +42,7 @@ public class Vala.CatchClause : CodeNode {
        /**
         * Specifies the error variable name.
         */
-       public string variable_name { get; set; }
+       public string? variable_name { get; set; }
        
        /**
         * Specifies the error handler body.
@@ -65,7 +65,7 @@ public class Vala.CatchClause : CodeNode {
         * @param source_reference reference to source code
         * @return                 newly created catch clause
         */
-       public CatchClause (DataType? error_type, string variable_name, Block body, SourceReference? source_reference = null) {
+       public CatchClause (DataType? error_type, string? variable_name, Block body, SourceReference? source_reference = null) {
                this.error_type = error_type;
                this.variable_name = variable_name;
                this.body = body;