From: Jürg Billeter Date: Mon, 31 Aug 2009 18:40:01 +0000 (+0200) Subject: gobject-2.0: Add constructor to GLib.Object class X-Git-Tag: 0.7.6~167 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=d6dfe51542d920e714be7d9f29a070d04a3ed79e;p=thirdparty%2Fvala.git gobject-2.0: Add constructor to GLib.Object class --- diff --git a/compiler/valacompiler.vala b/compiler/valacompiler.vala index 3ea847bc3..75a46f8e6 100644 --- a/compiler/valacompiler.vala +++ b/compiler/valacompiler.vala @@ -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)); } diff --git a/vala/valaclass.vala b/vala/valaclass.vala index 68862a784..63b93e147 100644 --- a/vala/valaclass.vala +++ b/vala/valaclass.vala @@ -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; diff --git a/vala/valacodewriter.vala b/vala/valacodewriter.vala index 55dd51384..7d082bf15 100644 --- a/vala/valacodewriter.vala +++ b/vala/valacodewriter.vala @@ -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); } diff --git a/vala/valacreationmethod.vala b/vala/valacreationmethod.vala index 6a57805d2..06f66109d 100644 --- a/vala/valacreationmethod.vala +++ b/vala/valacreationmethod.vala @@ -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); diff --git a/vala/valastruct.vala b/vala/valastruct.vala index 33956d7a4..15c84a2de 100644 --- a/vala/valastruct.vala +++ b/vala/valastruct.vala @@ -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; diff --git a/vapi/gobject-2.0.vapi b/vapi/gobject-2.0.vapi index 09b0e9694..f1cd48743 100644 --- a/vapi/gobject-2.0.vapi +++ b/vapi/gobject-2.0.vapi @@ -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 ();