From: Jürg Billeter Date: Sun, 10 Dec 2006 10:11:19 +0000 (+0000) Subject: add message logging functions support enum to int conversions and X-Git-Tag: VALA_0_0_6~24 X-Git-Url: http://git.ipfire.org/gitweb.cgi?a=commitdiff_plain;h=18a2c7fc4f46c787d5dee8a23d0897568b173054;p=thirdparty%2Fvala.git add message logging functions support enum to int conversions and 2006-12-10 Jürg Billeter * 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 --- diff --git a/vala/ChangeLog b/vala/ChangeLog index 1826fbb12..d2ffe6751 100644 --- a/vala/ChangeLog +++ b/vala/ChangeLog @@ -1,3 +1,10 @@ +2006-12-10 Jürg Billeter + + * 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 * vala/valacodegenerator.vala: fix generating switch statements diff --git a/vala/vala/valacodegenerator.vala b/vala/vala/valacodegenerator.vala index 83c654480..0acf6362b 100644 --- a/vala/vala/valacodegenerator.vala +++ b/vala/vala/valacodegenerator.vala @@ -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); diff --git a/vala/vala/valasemanticanalyzer.vala b/vala/vala/valasemanticanalyzer.vala index fb55f7356..ea78ea9dd 100644 --- a/vala/vala/valasemanticanalyzer.vala +++ b/vala/vala/valasemanticanalyzer.vala @@ -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 params, List 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 ()) { diff --git a/vala/vapi/glib-2.0.vala b/vala/vapi/glib-2.0.vala index 1385e38c5..293741414 100644 --- a/vala/vapi/glib-2.0.vala +++ b/vala/vapi/glib-2.0.vala @@ -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 */