+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:
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"));
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;
}
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;
}