[Vala] Property set increment error



Jurg,

       I don't know if incrementing a property is considered valid C#, but the following code is considered valid and compiles in vala, but results in an incompilable C file.  

using GLib;

namespace Error6 {

        private class CountMe {

                private int _count = 0;
                public int Count {
                        get { return _count; }
                        set { _count = value; }
                }
        }

        public static int main(string[] args) {

                var t = new CountMe();

               // This works
                t.Count = t.Count + 1;

               // This results in a C compiler error.
                t.Count++;

                stdout.printf("count = %d", t.Count);
        }
}


Resulting C code (abridged) :

int error6_main (int args_length1, char** args)
{
        Error6CountMe* t = g_object_new (ERROR6_TYPE_COUNT_ME, NULL);
        error6_count_me_set_Count (t, error6_count_me_get_Count (t) + 1);
        /* C compiler error here */
        error6_count_me_get_Count (t)++;
        fprintf (stdout, "count = %d", error6_count_me_get_Count (t), NULL);
        (t == NULL ? NULL : (t = (g_object_unref (t), NULL)));
}

Cayle,
Missouri


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]