vala r1064 - in trunk: . gobject tests
- From: juergbi svn gnome org
- To: svn-commits-list gnome org
- Subject: vala r1064 - in trunk: . gobject tests
- Date: Fri, 29 Feb 2008 20:39:19 +0000 (GMT)
Author: juergbi
Date: Fri Feb 29 20:39:19 2008
New Revision: 1064
URL: http://svn.gnome.org/viewvc/vala?rev=1064&view=rev
Log:
2008-02-29 Juerg Billeter <j bitron ch>
* gobject/valaccodegenerator.vala: support throw statements in try
statements
* tests/exceptions.vala: test throw statement in try statement with
generic catch clause
Modified:
trunk/ChangeLog
trunk/gobject/valaccodegenerator.vala
trunk/tests/exceptions.vala
Modified: trunk/gobject/valaccodegenerator.vala
==============================================================================
--- trunk/gobject/valaccodegenerator.vala (original)
+++ trunk/gobject/valaccodegenerator.vala Fri Feb 29 20:39:19 2008
@@ -122,7 +122,6 @@
private bool requires_array_free;
private bool requires_array_move;
private bool requires_strcmp0;
- private bool inside_throws_statement;
private Set<string> wrappers;
@@ -2096,16 +2095,19 @@
}
public override void visit_throw_statement (ThrowStatement! stmt) {
- inside_throws_statement = true;
stmt.accept_children (this);
- inside_throws_statement = false;
var cfrag = new CCodeFragment ();
/* declare temporary objects */
append_temp_decl (cfrag, temp_vars);
- cfrag.append (new CCodeExpressionStatement ((CCodeExpression) stmt.error_expression.ccodenode));
+ // method will fail
+ current_method_inner_error = true;
+ var cassign = new CCodeAssignment (new CCodeIdentifier ("inner_error"), (CCodeExpression) stmt.error_expression.ccodenode);
+ cfrag.append (new CCodeExpressionStatement (cassign));
+
+ add_simple_check (stmt, cfrag);
/* free temporary objects */
foreach (VariableDeclarator decl in temp_ref_vars) {
@@ -2824,12 +2826,7 @@
var ecode = (ErrorCode) expr.symbol_reference;
var edomain = (ErrorDomain) ecode.parent_symbol;
- if (inside_throws_statement) {
- creation_call = new CCodeFunctionCall (new CCodeIdentifier ("g_set_error"));
- creation_call.add_argument (new CCodeIdentifier ("error"));
- } else {
- creation_call = new CCodeFunctionCall (new CCodeIdentifier ("g_error_new"));
- }
+ creation_call = new CCodeFunctionCall (new CCodeIdentifier ("g_error_new"));
creation_call.add_argument (new CCodeIdentifier (edomain.get_upper_case_cname ()));
creation_call.add_argument (new CCodeIdentifier (ecode.get_cname ()));
Modified: trunk/tests/exceptions.vala
==============================================================================
--- trunk/tests/exceptions.vala (original)
+++ trunk/tests/exceptions.vala Fri Feb 29 20:39:19 2008
@@ -88,6 +88,16 @@
stdout.printf (" 14");
}
+ static void test_generic_catch () {
+ try {
+ throw new BarError.FOO ("error message");
+ } catch (Error e) {
+ return;
+ }
+
+ assert_not_reached ();
+ }
+
static int main (string[] args) {
stdout.printf ("Exception Test: 1");
@@ -95,7 +105,9 @@
bar.run ();
stdout.printf (" 15\n");
-
+
+ test_generic_catch ();
+
return 0;
}
}
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]