]> git.ipfire.org Git - thirdparty/vala.git/commitdiff
add message logging functions support enum to int conversions and
authorJürg Billeter <j@bitron.ch>
Sun, 10 Dec 2006 10:11:19 +0000 (10:11 +0000)
committerJürg Billeter <juergbi@src.gnome.org>
Sun, 10 Dec 2006 10:11:19 +0000 (10:11 +0000)
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

vala/ChangeLog
vala/vala/valacodegenerator.vala
vala/vala/valasemanticanalyzer.vala
vala/vapi/glib-2.0.vala

index 1826fbb12c6bcfc21ddddf7056bd159bd3ff11f4..d2ffe67511c2c15a241bcb0136723372607db3bb 100644 (file)
@@ -1,3 +1,10 @@
+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
index 83c65448006b599cae81863091fe888bccddb335..0acf6362b4127cbb2fc96717ec6eef984bc52267 100644 (file)
@@ -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);
                
index fb55f73563de0e7103a23b74506d8f9e0fd97be7..ea78ea9ddc273ecd3d4bb34eace6a036e156dc2b 100644 (file)
@@ -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 ()) {
index 1385e38c54107c0e224d7f290909e3e10ac6301f..2937414147462e016909a5c14cf6b9c89b500592 100644 (file)
@@ -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 */