Commit 18a2c7fc authored by Jürg Billeter's avatar Jürg Billeter Committed by Jürg Billeter

add message logging functions support enum to int conversions and

2006-12-10  Jürg Billeter  <j@bitron.ch>

	* vapi/glib-2.0.vala: add message logging functions
	* vala/valasemanticanalyzer.vala: support enum to int conversions and
	  diagnostic methods
	* vala/valacodegenerator.vala: support do statements

svn path=/trunk/; revision=183
parent 591615af
2006-12-10 Jürg Billeter <j@bitron.ch>
* vapi/glib-2.0.vala: add message logging functions
* vala/valasemanticanalyzer.vala: support enum to int conversions and
diagnostic methods
* vala/valacodegenerator.vala: support do statements
2006-11-24 Jürg Billeter <j@bitron.ch>
* vala/valacodegenerator.vala: fix generating switch statements
......
......@@ -2164,6 +2164,12 @@ public class Vala.CodeGenerator : CodeVisitor {
create_temp_decl (stmt, stmt.condition.temp_vars);
}
public override void visit_do_statement (DoStatement! stmt) {
stmt.ccodenode = new CCodeDoStatement ((CCodeStatement) stmt.body.ccodenode, (CCodeExpression) stmt.condition.ccodenode);
create_temp_decl (stmt, stmt.condition.temp_vars);
}
public override void visit_for_statement (ForStatement! stmt) {
var cfor = new CCodeForStatement ((CCodeExpression) stmt.condition.ccodenode, (CCodeStatement) stmt.body.ccodenode);
......
......@@ -853,6 +853,10 @@ public class Vala.SemanticAnalyzer : CodeVisitor {
return false;
}
if (expression_type.data_type is Enum && expected_type.data_type == int_type.data_type) {
return true;
}
if (expression_type.data_type == expected_type.data_type) {
return true;
}
......@@ -928,8 +932,11 @@ public class Vala.SemanticAnalyzer : CodeVisitor {
}
private bool check_arguments (Expression! expr, Symbol! msym, List<FormalParameter> params, List<Expression> args) {
List prev_arg_it = null;
List arg_it = args;
bool diag = (msym.node.get_attribute ("Diagnostics") != null);
bool ellipsis = false;
int i = 0;
foreach (FormalParameter param in params) {
......@@ -959,6 +966,7 @@ public class Vala.SemanticAnalyzer : CodeVisitor {
return false;
}
prev_arg_it = arg_it;
arg_it = arg_it.next;
i++;
......@@ -971,6 +979,14 @@ public class Vala.SemanticAnalyzer : CodeVisitor {
return false;
}
if (diag && prev_arg_it != null) {
var format_arg = (Expression) prev_arg_it.data;
if (format_arg is LiteralExpression) {
var format_lit = (StringLiteral) ((LiteralExpression) format_arg).literal;
format_lit.value = "\"%s:%d: %s".printf (expr.source_reference.file.filename, expr.source_reference.first_line, format_lit.value.offset (1));
}
}
return true;
}
......@@ -1097,6 +1113,8 @@ public class Vala.SemanticAnalyzer : CodeVisitor {
foreach (TypeReference type_arg in type_args) {
expr.type_reference.add_type_argument (type_arg);
}
} else {
type = expr.type_reference.data_type;
}
if (!type.is_reference_type ()) {
......
......@@ -150,6 +150,8 @@ public struct unichar {
public bool isalnum ();
[CCode (cname = "g_unichar_isdigit")]
public bool isdigit ();
[CCode (cname = "g_unichar_isspace")]
public bool isspace ();
[CCode (cname = "g_unichar_isupper")]
public bool isupper ();
[CCode (cname = "g_unichar_isxdigit")]
......@@ -606,6 +608,39 @@ namespace GLib {
public static void return_if_fail (bool expr);
public static void assert (bool expr);
public static void assert_not_reached ();
/* Message Logging */
[CCode (cprefix = "G_LOG_")]
public enum LogLevelFlags {
/* log flags */
FLAG_RECURSION,
FLAG_FATAL,
/* GLib log levels */
LEVEL_ERROR,
LEVEL_CRITICAL,
LEVEL_WARNING,
LEVEL_MESSAGE,
LEVEL_INFO,
LEVEL_DEBUG,
LEVEL_MASK
}
[Diagnostics ()]
public void log (string log_domain, LogLevelFlags log_level, string format, ...);
[Diagnostics ()]
public void message (string format, ...);
[Diagnostics ()]
public void warning (string format, ...);
[Diagnostics ()]
public void critical (string format, ...);
[Diagnostics ()]
public void error (string format, ...);
[Diagnostics ()]
public void debug (string format, ...);
/* Character Set Conversions */
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment