Post-release version bump. remove g_object_unref call to fix crash in
authorJürg Billeter <j@bitron.ch>
Sun, 16 Jul 2006 21:27:45 +0000 (21:27 +0000)
committerJürg Billeter <juergbi@src.gnome.org>
Sun, 16 Jul 2006 21:27:45 +0000 (21:27 +0000)
2006-07-16  Jürg Billeter  <j@bitron.ch>

* configure.ac: Post-release version bump.
* vala/parser.y: remove g_object_unref call to fix crash in parsing
  array declarations
* vala/valasemanticanalyzer.vala, vala/valacodegenerator.vala: support
  creating structs
* vapi/glib-2.0.vala: GString enhancements
* vapi/Makefile.am: dist gtk+-2.0.vala and pango.vala

svn path=/trunk/; revision=80

vala/ChangeLog
vala/configure.ac
vala/vala/parser.y
vala/vala/valacodegenerator.vala
vala/vala/valasemanticanalyzer.vala
vala/vapi/Makefile.am
vala/vapi/glib-2.0.vala

index b59106f..3362b3e 100644 (file)
@@ -1,3 +1,13 @@
+2006-07-16  Jürg Billeter  <j@bitron.ch>
+
+       * configure.ac: Post-release version bump.
+       * vala/parser.y: remove g_object_unref call to fix crash in parsing
+         array declarations
+       * vala/valasemanticanalyzer.vala, vala/valacodegenerator.vala: support
+         creating structs
+       * vapi/glib-2.0.vala: GString enhancements
+       * vapi/Makefile.am: dist gtk+-2.0.vala and pango.vala
+
 2006-07-15  Jürg Billeter  <j@bitron.ch>
 
        * NEWS: update for 0.0.1 release
index a539f35..d13e3b9 100644 (file)
@@ -1,4 +1,4 @@
-AC_INIT([vala], [0.0.1], [j@bitron.ch], [vala])
+AC_INIT([vala], [0.0.2], [j@bitron.ch], [vala])
 AC_CONFIG_SRCDIR([Makefile.am])
 AC_CONFIG_HEADERS(config.h)
 AM_INIT_AUTOMAKE([dist-bzip2])
index 35f3215..d562044 100644 (file)
@@ -1166,7 +1166,6 @@ local_variable_type
          {
                $$ = $1;
                vala_type_reference_set_array ($$, TRUE);
-               g_object_unref ($1);
          }
        ;
 
index 53f3329..ab9361e 100644 (file)
@@ -842,7 +842,7 @@ public class Vala.CodeGenerator : CodeVisitor {
                                ccheck.add_argument (new CCodeConstant (name = "NULL"));
                        } else if (ret_type.name == "bool") {
                                ccheck.add_argument (new CCodeConstant (name = "FALSE"));
-                       } else if (ret_type.name == "int" || ret_type is Enum || ret_type is Flags) {
+                       } else if (ret_type.name == "int" || ret_type.name == "long" || ret_type.name == "double" || ret_type.name == "float" || ret_type is Enum || ret_type is Flags) {
                                ccheck.add_argument (new CCodeConstant (name = "0"));
                        } else {
                                Report.error (method_node.source_reference, "not supported return type for runtime type checks");
@@ -1934,18 +1934,28 @@ public class Vala.CodeGenerator : CodeVisitor {
        }
 
        public override void visit_object_creation_expression (ObjectCreationExpression! expr) {
-               var ccall = new CCodeFunctionCall (call = new CCodeIdentifier (name = "g_object_new"));
-               
-               ccall.add_argument (new CCodeConstant (name = expr.type_reference.get_upper_case_cname ("TYPE_")));
+               if (expr.type_reference.type is Class) {
+                       var ccall = new CCodeFunctionCall (call = new CCodeIdentifier (name = "g_object_new"));
+                       
+                       ccall.add_argument (new CCodeConstant (name = expr.type_reference.get_upper_case_cname ("TYPE_")));
 
-               foreach (NamedArgument arg in expr.named_argument_list) {
-                       ccall.add_argument (new CCodeConstant (name = "\"%s\"".printf (arg.name)));
-                       ccall.add_argument ((CCodeExpression) arg.argument.ccodenode);
+                       foreach (NamedArgument arg in expr.named_argument_list) {
+                               ccall.add_argument (new CCodeConstant (name = "\"%s\"".printf (arg.name)));
+                               ccall.add_argument ((CCodeExpression) arg.argument.ccodenode);
+                       }
+                       ccall.add_argument (new CCodeConstant (name = "NULL"));
+                       
+                       expr.ccodenode = ccall;
+               } else {
+                       var ccall = new CCodeFunctionCall (call = new CCodeIdentifier (name = "g_new0"));
+                       
+                       ccall.add_argument (new CCodeConstant (name = expr.type_reference.type.get_cname ()));
+                       
+                       ccall.add_argument (new CCodeConstant (name = "1"));
+                       
+                       expr.ccodenode = ccall;
                }
-               ccall.add_argument (new CCodeConstant (name = "NULL"));
-               
-               expr.ccodenode = ccall;
-               
+                       
                visit_expression (expr);
        }
 
index 18d888c..abb7da1 100644 (file)
@@ -823,20 +823,41 @@ public class Vala.SemanticAnalyzer : CodeVisitor {
                        /* if type resolving didn't succeed, skip this check */
                        return;
                }
+               
+               if (!expr.type_reference.type.is_reference_type ()) {
+                       expr.error = true;
+                       Report.error (expr.source_reference, "Can't create instance of value type `%s'".printf (expr.type_reference.to_string ()));
+                       return;
+               }
        
                current_source_file.add_symbol_dependency (expr.type_reference.type.symbol, SourceFileDependencyType.SOURCE);
 
                expr.static_type = expr.type_reference.copy ();
                expr.static_type.is_ref = true;
                
-               var cl = (Class) expr.type_reference.type;
-               while (cl != null) {
-                       if (cl == initially_unowned_type) {
-                               expr.static_type.floating_reference = true;
-                               break;
+               if (expr.type_reference.type is Class) {
+                       var cl = (Class) expr.type_reference.type;
+                       
+                       if (cl.is_abstract) {
+                               expr.static_type = null;
+                               expr.error = true;
+                               Report.error (expr.source_reference, "Can't create instance of abstract class `%s'".printf (expr.type_reference.to_string ()));
+                               return;
                        }
-               
-                       cl = cl.base_class;
+                       
+                       while (cl != null) {
+                               if (cl == initially_unowned_type) {
+                                       expr.static_type.floating_reference = true;
+                                       break;
+                               }
+                       
+                               cl = cl.base_class;
+                       }
+               } else if (expr.named_argument_list.length () != 0) {
+                       expr.static_type = null;
+                       expr.error = true;
+                       Report.error (expr.source_reference, "No arguments allowed when constructing struct `%s'".printf (expr.type_reference.to_string ()));
+                       return;
                }
        }
 
index 83e63da..a87b958 100644 (file)
@@ -5,4 +5,6 @@ vapidir = $(pkgdatadir)/vapi
 dist_vapi_DATA = \
        glib-2.0.vala \
        libxml-2.0.vala \
+       gtk+-2.0.vala \
+       pango.vala \
        $(NULL)
index 0db6a1b..a306d10 100644 (file)
@@ -489,6 +489,10 @@ namespace GLib {
                public String append_c (char c);
                public String append_unichar (unichar wc);
                public String append_len (string! val, long len);
+               public String prepend (string! val);
+               public String prepend_c (char c);
+               public String prepend_unichar (unichar wc);
+               public String prepend_len (string! val, long len);
                public String insert (long pos, string! val);
                public String erase (long pos, long len);