]> git.ipfire.org Git - thirdparty/vala.git/commitdiff
default cname should be _init instead of _new for creation methods in
authorJuerg Billeter <j@bitron.ch>
Wed, 30 Jan 2008 10:29:19 +0000 (10:29 +0000)
committerJürg Billeter <juergbi@src.gnome.org>
Wed, 30 Jan 2008 10:29:19 +0000 (10:29 +0000)
2008-01-30  Juerg Billeter  <j@bitron.ch>

* vala/valacreationmethod.vala: default cname should be _init instead
  of _new for creation methods in structs

svn path=/trunk/; revision=927

ChangeLog
vala/valacreationmethod.vala

index 7d3b0399d3eeda11f0d3d32b8793f49900b0d371..8032f29fc5e173010018a467738716a91cb6ea35 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,8 @@
+2008-01-30  Jürg Billeter  <j@bitron.ch>
+
+       * vala/valacreationmethod.vala: default cname should be _init instead
+         of _new for creation methods in structs
+
 2008-01-30  Jürg Billeter  <j@bitron.ch>
 
        * vala/valainterfacewriter.vala: don't output overridden properties
index b703fc13888a1e883b67b72790287aa5f64ad143..2e81ed738cbab65b5047165a38dfcdf9952e6e42 100644 (file)
@@ -1,6 +1,6 @@
 /* valacreationmethod.vala
  *
- * Copyright (C) 2007  Raffaele Sandrini, Jürg Billeter
+ * Copyright (C) 2007-2008  Raffaele Sandrini, Jürg Billeter
  *
  * This library is free software; you can redistribute it and/or
  * modify it under the terms of the GNU Lesser General Public
@@ -67,12 +67,17 @@ public class Vala.CreationMethod : Method {
        }
 
        public override string! get_default_cname () {
-               var parent = parent_symbol;
-               assert (parent is Typesymbol);
+               var parent = parent_symbol as Typesymbol;
+
+               string infix = "new";
+               if (parent is Struct) {
+                       infix = "init";
+               }
+
                if (name.len () == ".new".len ()) {
-                       return "%snew".printf (((Typesymbol) parent).get_lower_case_cprefix ());
+                       return "%s%s".printf (parent.get_lower_case_cprefix (), infix);
                } else {
-                       return "%snew_%s".printf (((Typesymbol) parent).get_lower_case_cprefix (), name.offset (".new.".len ()));
+                       return "%s%s_%s".printf (parent.get_lower_case_cprefix (), infix, name.offset (".new.".len ()));
                }
        }
 }