always use VoidType
authorJuerg Billeter <j@bitron.ch>
Wed, 12 Dec 2007 16:15:33 +0000 (16:15 +0000)
committerJürg Billeter <juergbi@src.gnome.org>
Wed, 12 Dec 2007 16:15:33 +0000 (16:15 +0000)
2007-12-12  Juerg Billeter  <j@bitron.ch>

* vala/parser.y, vala/scanner.l, vala/valadatatype.vala,
  vala/valasymbolresolver.vala, vala/valavoidtype.vala: always use
  VoidType

* tests/delegates.exp, tests/delegates.vala: test delegates with void
  return types

svn path=/trunk/; revision=762

ChangeLog
tests/delegates.exp
tests/delegates.vala
vala/parser.y
vala/scanner.l
vala/valadatatype.vala
vala/valasymbolresolver.vala
vala/valavoidtype.vala

index 65bb6f1..fee27f8 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,12 @@
+2007-12-12  Jürg Billeter  <j@bitron.ch>
+
+       * vala/parser.y, vala/scanner.l, vala/valadatatype.vala,
+         vala/valasymbolresolver.vala, vala/valavoidtype.vala: always use
+         VoidType
+
+       * tests/delegates.exp, tests/delegates.vala: test delegates with void
+         return types
+
 2007-12-09  Jürg Billeter  <j@bitron.ch>
 
        * vapi/packages/gdk-2.0/, vapi/packages/gtk+-2.0/, vapi/packages/pango/:
index 4f3a6b4..b613db0 100644 (file)
@@ -1 +1 @@
-Delegate Test: 1 2 3
+Delegate Test: 1 2 3 4 5
index feb1e80..a0b2256 100644 (file)
@@ -1,20 +1,32 @@
 using GLib;
 
+public static delegate void Maman.VoidCallback ();
+
 public static delegate int Maman.ActionCallback ();
 
 class Maman.Bar : Object {
+       static void do_void_action () {
+               stdout.printf (" 2");
+       }
+
        static int do_action () {
-               return 2;
+               return 4;
        }
 
        static int main (string[] args) {
                stdout.printf ("Delegate Test: 1");
                
+               VoidCallback void_cb = do_void_action;
+
+               void_cb ();
+
+               stdout.printf (" 3");
+
                ActionCallback cb = do_action;
                
                stdout.printf (" %d", cb ());
                
-               stdout.printf (" 3\n");
+               stdout.printf (" 5\n");
                
                return 0;
        }
index 0ccf94f..d24ea2a 100644 (file)
@@ -203,6 +203,7 @@ static gboolean check_is_struct (ValaSymbol *symbol, ValaSourceReference *src);
 %token USING "using"
 %token VAR "var"
 %token VIRTUAL "virtual"
+%token VOID "void"
 %token VOLATILE "volatile"
 %token WEAK "weak"
 %token WHILE "while"
@@ -561,6 +562,10 @@ type
                        vala_unresolved_type_set_non_null (VALA_UNRESOLVED_TYPE ($$), TRUE);
                }
          }
+       | VOID
+         {
+               $$ = VALA_DATA_TYPE (vala_void_type_new ());
+         }
        ;
 
 opt_argument_list
@@ -2920,12 +2925,14 @@ method_header
 
                src = src_com(@6, $1);
 
-               if (vala_unresolved_type_get_is_ref (VALA_UNRESOLVED_TYPE ($5)) || vala_unresolved_type_get_is_out (VALA_UNRESOLVED_TYPE ($5))) {
-                       vala_report_error (src, "`ref' and `out' may only be used for parameters.");
-               }
-               if (!vala_unresolved_type_get_is_weak (VALA_UNRESOLVED_TYPE ($5))) {
-                       vala_unresolved_type_set_transfers_ownership (VALA_UNRESOLVED_TYPE ($5), TRUE);
-               }
+               if (VALA_IS_UNRESOLVED_TYPE ($5)) {
+                       if (vala_unresolved_type_get_is_ref (VALA_UNRESOLVED_TYPE ($5)) || vala_unresolved_type_get_is_out (VALA_UNRESOLVED_TYPE ($5))) {
+                               vala_report_error (src, "`ref' and `out' may only be used for parameters.");
+                       }
+                       if (!vala_unresolved_type_get_is_weak (VALA_UNRESOLVED_TYPE ($5))) {
+                               vala_unresolved_type_set_transfers_ownership (VALA_UNRESOLVED_TYPE ($5), TRUE);
+                       }
+               }
 
                $$ = vala_code_context_create_method (context, $6, $5, src);
                g_object_unref (src);
index fdab188..80bafc1 100644 (file)
@@ -180,6 +180,7 @@ literal                             ({integer_literal}|{real_literal}|{character_literal}|{string_literal
 "using"                { uploc; return USING; }
 "var"          { uploc; return VAR; }
 "virtual"      { uploc; return VIRTUAL; }
+"void"         { uploc; return VOID; }
 "volatile"     { uploc; return VOLATILE; }
 "weak"         { uploc; return WEAK; }
 "while"                { uploc; return WHILE; }
index 75bb38a..a4722c1 100644 (file)
@@ -266,7 +266,7 @@ public class Vala.DataType : CodeNode {
         * @param type2 a type reference
         * @return      true if this type reference is stricter or equal
         */
-       public bool stricter (DataType! type2) {
+       public virtual bool stricter (DataType! type2) {
                if (type2.transfers_ownership != transfers_ownership) {
                        return false;
                }
index 590eba8..bb715da 100644 (file)
@@ -192,10 +192,6 @@ public class Vala.SymbolResolver : CodeVisitor {
                        type.add_type_argument (type_arg);
                }
 
-               if (unresolved_type.type_name == null || unresolved_type.type_name == "void") {
-                       return type;
-               }
-               
                if (unresolved_type.namespace_name == null) {
                        Symbol sym = null;
                        Scope scope = current_scope;
index bfe30e3..9398482 100644 (file)
@@ -28,4 +28,8 @@ using GLib;
 public class Vala.VoidType : DataType {
        public VoidType () {
        }
+
+       public override bool stricter (DataType! type2) {
+               return (type2 is VoidType);
+       }
 }