]> git.ipfire.org Git - thirdparty/vala.git/commitdiff
gobject-2.0: Add constructor to GLib.Object class
authorJürg Billeter <j@bitron.ch>
Mon, 31 Aug 2009 18:40:01 +0000 (20:40 +0200)
committerJürg Billeter <j@bitron.ch>
Mon, 31 Aug 2009 18:40:01 +0000 (20:40 +0200)
compiler/valacompiler.vala
vala/valaclass.vala
vala/valacodewriter.vala
vala/valacreationmethod.vala
vala/valastruct.vala
vapi/gobject-2.0.vapi

index 3ea847bc3c85b5dcb368f20d1d01cad1b5cd493b..75a46f8e66daa82c6f8d0ff2cb634a248615e6e4 100644 (file)
@@ -212,6 +212,7 @@ class Vala.Compiler {
                        // default profile
                        context.profile = Profile.GOBJECT;
                        context.add_define ("GOBJECT");
+                       context.add_define ("VALA_0_7_6_NEW_METHODS");
                } else {
                        Report.error (null, "Unknown profile %s".printf (profile));
                }
index 68862a7842ad486896a38765acedb928369a8198..63b93e147789cbbcdc087b6306e191e2b66c148f 100644 (file)
@@ -343,7 +343,7 @@ public class Vala.Class : ObjectTypeSymbol {
                if (m is CreationMethod) {
                        if (m.name == null) {
                                default_construction_method = m;
-                               m.name = "new";
+                               m.name = ".new";
                        }
 
                        var cm = (CreationMethod) m;
index 55dd513849b193ab089ce255fa59705861dfd02c..7d082bf15bc7cb9ecb28d09945bc18feeab35bf8 100644 (file)
@@ -890,7 +890,7 @@ public class Vala.CodeWriter : CodeVisitor {
                if (m is CreationMethod) {
                        var datatype = (TypeSymbol) m.parent_symbol;
                        write_identifier (datatype.name);
-                       if (m.name != "new") {
+                       if (m.name != ".new") {
                                write_string (".");
                                write_identifier (m.name);
                        }
index 6a57805d242456dd96d5e6df491b067a1f6913bb..06f66109d8aab5a400590ac9de35944b51161cc8 100644 (file)
@@ -93,7 +93,7 @@ public class Vala.CreationMethod : Method {
                        infix = "init";
                }
 
-               if (name == "new") {
+               if (name == ".new") {
                        return "%s%s".printf (parent.get_lower_case_cprefix (), infix);
                } else {
                        return "%s%s_%s".printf (parent.get_lower_case_cprefix (), infix, name);
@@ -109,7 +109,7 @@ public class Vala.CreationMethod : Method {
 
                string infix = "construct";
 
-               if (name == "new") {
+               if (name == ".new") {
                        return "%s%s".printf (parent.get_lower_case_cprefix (), infix);
                } else {
                        return "%s%s_%s".printf (parent.get_lower_case_cprefix (), infix, name);
index 33956d7a41ab928ec4494deaaae2cdf19814cab2..15c84a2de24be6c267daca2a49b15c8b76a968e1 100644 (file)
@@ -182,7 +182,7 @@ public class Vala.Struct : TypeSymbol {
                if (m is CreationMethod) {
                        if (m.name == null) {
                                default_construction_method = m;
-                               m.name = "new";
+                               m.name = ".new";
                        }
 
                        var cm = (CreationMethod) m;
index 09b0e9694c1ca9fa1b9b49ce5df185796ef6b55f..f1cd4874384ff7a2b335b0d0e7b7cee19df39bc7 100644 (file)
@@ -175,7 +175,12 @@ namespace GLib {
        public class Object {
                public uint ref_count;
 
+               [CCode (has_construct_function = false)]
+               public Object (Type type = typeof (Object), ...);
+
+#if VALA_0_7_6_NEW_METHODS
                public static Object @new (Type type, ...);
+#endif
 
                [CCode (cname = "G_TYPE_FROM_INSTANCE")]
                public Type get_type ();