]> git.ipfire.org Git - thirdparty/vala.git/commitdiff
Add Log.FILE, Log.LINE, and Log.METHOD constants as replacements for
authorJürg Billeter <j@bitron.ch>
Sun, 18 Jan 2009 15:18:09 +0000 (15:18 +0000)
committerJürg Billeter <juergbi@src.gnome.org>
Sun, 18 Jan 2009 15:18:09 +0000 (15:18 +0000)
2009-01-18  Jürg Billeter  <j@bitron.ch>

* gobject/valaccodememberaccessmodule.vala:
* vapi/glib-2.0.vapi:

Add Log.FILE, Log.LINE, and Log.METHOD constants as replacements
for __FILE__ and __LINE__ as they are used in C

svn path=/trunk/; revision=2386

ChangeLog
gobject/valaccodememberaccessmodule.vala
vapi/glib-2.0.vapi

index 7e219cfc294ed694b6ca08568df8963c2fc36ec3..b223aabb1cf339d93c2485f076e50e3e7096809b 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,11 @@
+2009-01-18  Jürg Billeter  <j@bitron.ch>
+
+       * gobject/valaccodememberaccessmodule.vala:
+       * vapi/glib-2.0.vapi:
+
+       Add Log.FILE, Log.LINE, and Log.METHOD constants as replacements
+       for __FILE__ and __LINE__ as they are used in C
+
 2009-01-18  Jürg Billeter  <j@bitron.ch>
 
        * vapi/Makefile.am:
index b10b4cbcccf0b71b1d24d24b1f5ae67f84424729..169a585fe65525ebd0045d1b22e25246aa99afef 100644 (file)
@@ -148,7 +148,23 @@ public class Vala.CCodeMemberAccessModule : CCodeControlFlowModule {
                        }
                } else if (expr.symbol_reference is Constant) {
                        var c = (Constant) expr.symbol_reference;
-                       expr.ccodenode = new CCodeIdentifier (c.get_cname ());
+
+                       string fn = c.get_full_name ();
+                       if (fn == "GLib.Log.FILE") {
+                               string s = Path.get_basename (expr.source_reference.file.filename);
+                               expr.ccodenode = new CCodeConstant ("\"%s\"".printf (s));
+                       } else if (fn == "GLib.Log.LINE") {
+                               int i = expr.source_reference.first_line;
+                               expr.ccodenode = new CCodeConstant ("%d".printf (i));
+                       } else if (fn == "GLib.Log.METHOD") {
+                               string s = "";
+                               if (current_method != null) {
+                                       s = current_method.get_full_name ();
+                               }
+                               expr.ccodenode = new CCodeConstant ("\"%s\"".printf (s));
+                       } else {
+                               expr.ccodenode = new CCodeIdentifier (c.get_cname ());
+                       }
                } else if (expr.symbol_reference is Property) {
                        var prop = (Property) expr.symbol_reference;
 
index 967601ce19c4c4e50a3ab3a2912cbf0355667c18..db7b3ac53760f1da627852c7da96642ba24a5cf9 100644 (file)
@@ -1499,6 +1499,10 @@ namespace GLib {
        namespace Log {
                public static uint set_handler (string? log_domain, LogLevelFlags log_levels, LogFunc log_func);
                public static void set_default_handler (LogFunc log_func);
+
+               public const string FILE;
+               public const int LINE;
+               public const string METHOD;
        }
 
        /* String Utility Functions */