From 1420ef2b035432ce8e171b859eb0aaa37c2877e6 Mon Sep 17 00:00:00 2001 From: Juerg Billeter Date: Sat, 26 Apr 2008 07:39:28 +0000 Subject: [PATCH] Support catch clauses without error variable, fixes bug 529539 2008-04-26 Juerg Billeter * vala/valacatchclause.vala: * gobject/valaccodegenerator.vala: Support catch clauses without error variable, fixes bug 529539 svn path=/trunk/; revision=1316 --- ChangeLog | 7 +++++++ gobject/valaccodegenerator.vala | 7 ++++++- vala/valacatchclause.vala | 4 ++-- 3 files changed, 15 insertions(+), 3 deletions(-) diff --git a/ChangeLog b/ChangeLog index f9ee415..1ef4902 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,5 +1,12 @@ 2008-04-26 Jürg Billeter + * vala/valacatchclause.vala: + * gobject/valaccodegenerator.vala: + + Support catch clauses without error variable, fixes bug 529539 + +2008-04-26 Jürg Billeter + * vala/valanamespace.vala: * vala/valaparser.vala: diff --git a/gobject/valaccodegenerator.vala b/gobject/valaccodegenerator.vala index 75ecbb0..3dc3797 100644 --- a/gobject/valaccodegenerator.vala +++ b/gobject/valaccodegenerator.vala @@ -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")))); diff --git a/vala/valacatchclause.vala b/vala/valacatchclause.vala index 301527a..ec43c9f 100644 --- a/vala/valacatchclause.vala +++ b/vala/valacatchclause.vala @@ -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; -- 2.7.4