report warning when using deprecated syntax for property default values
authorJuerg Billeter <j@bitron.ch>
Sun, 13 Apr 2008 15:06:51 +0000 (15:06 +0000)
committerJürg Billeter <juergbi@src.gnome.org>
Sun, 13 Apr 2008 15:06:51 +0000 (15:06 +0000)
2008-04-13  Juerg Billeter  <j@bitron.ch>

* vala/valaparser.vala: report warning when using deprecated syntax
  for property default values

* vala/valaconstructor.vala, vala/valaenum.vala: port to new syntax

svn path=/trunk/; revision=1207

ChangeLog
vala/valaconstructor.vala
vala/valaenum.vala
vala/valaparser.vala

index 7589286..71c75ac 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,10 @@
+2008-04-13  Jürg Billeter  <j@bitron.ch>
+
+       * vala/valaparser.vala: report warning when using deprecated syntax
+         for property default values
+
+       * vala/valaconstructor.vala, vala/valaenum.vala: port to new syntax
+
 2008-04-13  Marc-Andre Lureau  <marcandre.lureau@gmail.com>
 
        * vapi/glib-2.0.vapi (Value): add init, register_transform, and
index 1627175..a01e14e 100644 (file)
@@ -39,7 +39,7 @@ public class Vala.Constructor : Symbol {
        /**
         * Specifies whether this is an instance or a class constructor.
         */
-       public bool instance { get; set; default (true); }
+       public bool instance { get; set; default = true; }
        
        /**
         * Creates a new constructor.
index 7365c90..0c0e76c 100644 (file)
@@ -35,7 +35,7 @@ public class Vala.Enum : Typesymbol {
        /**
         * Specifies whether this enum has a registered GType.
         */
-       public bool has_type_id { get; set; default (true); }
+       public bool has_type_id { get; set; default = true; }
 
        private Gee.List<EnumValue> values = new ArrayList<EnumValue> ();
        private Gee.List<Method> methods = new ArrayList<Method> ();
index aa84ccc..da1c44a 100644 (file)
@@ -149,6 +149,16 @@ public class Vala.Parser : CodeVisitor {
                return src;
        }
 
+       SourceReference get_current_src () {
+               return new SourceReference (scanner.source_file, tokens[index].begin.line, tokens[index].begin.column, tokens[index].end.line, tokens[index].end.column);
+       }
+
+       SourceReference get_last_src () {
+               int last_index = (index + BUFFER_SIZE - 1) % BUFFER_SIZE;
+
+               return new SourceReference (scanner.source_file, tokens[last_index].begin.line, tokens[last_index].begin.column, tokens[last_index].end.line, tokens[last_index].end.column);
+       }
+
        void rollback (SourceLocation location) {
                while (tokens[index].begin.pos != location.pos) {
                        prev ();
@@ -1199,7 +1209,7 @@ public class Vala.Parser : CodeVisitor {
                        }
                }
                if (!accept (TokenType.CLOSE_BRACE)) {
-                       Report.error (new SourceReference (scanner.source_file, tokens[index].begin.line, tokens[index].begin.column, tokens[index].end.line, tokens[index].end.column), "expected `}'");
+                       Report.error (get_current_src (), "expected `}'");
                }
 
                return block;
@@ -1626,7 +1636,7 @@ public class Vala.Parser : CodeVisitor {
                }
                if (!root) {
                        if (!accept (TokenType.CLOSE_BRACE)) {
-                               Report.error (new SourceReference (scanner.source_file, tokens[index].begin.line, tokens[index].begin.column, tokens[index].end.line, tokens[index].end.column), "expected `}'");
+                               Report.error (get_current_src (), "expected `}'");
                        }
                }
        }
@@ -2054,7 +2064,7 @@ public class Vala.Parser : CodeVisitor {
                                        throw new ParseError.SYNTAX (get_error ("property default value already defined"));
                                }
                                if (accept (TokenType.OPEN_PARENS)) {
-                                       // deprecated
+                                       Report.warning (get_last_src (), "deprecated syntax, use `default = value;`");
                                        prop.default_expression = parse_expression ();
                                        expect (TokenType.CLOSE_PARENS);
                                } else {