From: Jürg Billeter Date: Tue, 1 Sep 2009 17:53:17 +0000 (+0200) Subject: GObject: Fix boxed properties X-Git-Tag: 0.7.6~156 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=a6302a90c322bad697cdf5a8c479a9957c5bb5dc;p=thirdparty%2Fvala.git GObject: Fix boxed properties GObject properties that are boxed types were incorrectly being declared as pointer types when the properties were installed. Based on patch by Mark Lee, fixes bug 592493. --- diff --git a/codegen/valagtypemodule.vala b/codegen/valagtypemodule.vala index 229c7bf2a..8e7a245d8 100644 --- a/codegen/valagtypemodule.vala +++ b/codegen/valagtypemodule.vala @@ -108,7 +108,7 @@ internal class Vala.GTypeModule : GErrorModule { decl_space.add_type_member_declaration (unref_fun.copy ()); // GParamSpec and GValue functions - var function_name = cl.get_lower_case_cname ("param_spec_"); + string function_name = cl.get_lower_case_cname ("param_spec_"); var function = new CCodeFunction (function_name, "GParamSpec*"); function.add_parameter (new CCodeFormalParameter ("name", "const gchar*")); @@ -117,8 +117,6 @@ internal class Vala.GTypeModule : GErrorModule { function.add_parameter (new CCodeFormalParameter ("object_type", "GType")); function.add_parameter (new CCodeFormalParameter ("flags", "GParamFlags")); - cl.set_param_spec_function (function_name); - if (cl.access == SymbolAccessibility.PRIVATE) { function.modifiers = CCodeModifiers.STATIC; } @@ -864,7 +862,7 @@ internal class Vala.GTypeModule : GErrorModule { } private void add_g_param_spec_type_function (Class cl) { - var function_name = cl.get_lower_case_cname ("param_spec_"); + string function_name = cl.get_lower_case_cname ("param_spec_"); var function = new CCodeFunction (function_name, "GParamSpec*"); function.add_parameter (new CCodeFormalParameter ("name", "const gchar*")); @@ -873,8 +871,6 @@ internal class Vala.GTypeModule : GErrorModule { function.add_parameter (new CCodeFormalParameter ("object_type", "GType")); function.add_parameter (new CCodeFormalParameter ("flags", "GParamFlags")); - cl.set_param_spec_function ( function_name ); - if (cl.access == SymbolAccessibility.PRIVATE) { function.modifiers = CCodeModifiers.STATIC; } @@ -1498,17 +1494,14 @@ internal class Vala.GTypeModule : GErrorModule { cspec.add_argument (new CCodeConstant ("\"%s\"".printf (prop.blurb))); - if ((prop.property_type.data_type is Class && !(((Class) prop.property_type.data_type).is_compact)) || prop.property_type.data_type is Interface) { + if (prop.property_type.data_type is Class || prop.property_type.data_type is Interface) { string param_spec_name = prop.property_type.data_type.get_param_spec_function (); - if (param_spec_name == null) { - cspec.call = new CCodeIdentifier ("g_param_spec_pointer"); - } else { - cspec.call = new CCodeIdentifier (param_spec_name); + cspec.call = new CCodeIdentifier (param_spec_name); + if (prop.property_type.data_type == string_type.data_type) { + cspec.add_argument (new CCodeConstant ("NULL")); + } else if (prop.property_type.data_type.get_type_id () != "G_TYPE_POINTER") { cspec.add_argument (new CCodeIdentifier (prop.property_type.data_type.get_type_id ())); } - } else if (prop.property_type.data_type == string_type.data_type) { - cspec.call = new CCodeIdentifier ("g_param_spec_string"); - cspec.add_argument (new CCodeConstant ("NULL")); } else if (prop.property_type.data_type is Enum) { var e = prop.property_type.data_type as Enum; if (e.has_type_id) { diff --git a/vala/valaclass.vala b/vala/valaclass.vala index 63b93e147..7bb053249 100644 --- a/vala/valaclass.vala +++ b/vala/valaclass.vala @@ -720,22 +720,24 @@ public class Vala.Class : ObjectTypeSymbol { } public override string? get_param_spec_function () { - if (param_spec_function == null ) { - if (!(is_compact || base_class == null)) { + if (param_spec_function == null) { + if (is_fundamental ()) { + param_spec_function = get_lower_case_cname ("param_spec_"); + } else if (base_class != null) { param_spec_function = base_class.get_param_spec_function (); + } else if (get_type_id () == "G_TYPE_POINTER") { + param_spec_function = "g_param_spec_pointer"; + } else { + param_spec_function = "g_param_spec_boxed"; } } return param_spec_function; } - public void set_param_spec_function ( string name ) { - param_spec_function = name; - } - public override string? get_get_value_function () { if (get_value_function == null) { - if (is_fundamental()) { + if (is_fundamental ()) { get_value_function = get_lower_case_cname ("value_get_"); } else if (base_class != null) { get_value_function = base_class.get_get_value_function (); @@ -751,7 +753,7 @@ public class Vala.Class : ObjectTypeSymbol { public override string? get_set_value_function () { if (set_value_function == null) { - if (is_fundamental()) { + if (is_fundamental ()) { set_value_function = get_lower_case_cname ("value_set_"); } else if (base_class != null) { set_value_function = base_class.get_set_value_function (); diff --git a/vapi/glib-2.0.vapi b/vapi/glib-2.0.vapi index 8713507ce..5ca94b684 100644 --- a/vapi/glib-2.0.vapi +++ b/vapi/glib-2.0.vapi @@ -808,7 +808,7 @@ public enum NormalizeMode { [Compact] [Immutable] -[CCode (cname = "char", const_cname = "const char", copy_function = "g_strdup", free_function = "g_free", cheader_filename = "stdlib.h,string.h,glib.h", type_id = "G_TYPE_STRING", marshaller_type_name = "STRING", get_value_function = "g_value_get_string", set_value_function = "g_value_set_string", type_signature = "s")] +[CCode (cname = "char", const_cname = "const char", copy_function = "g_strdup", free_function = "g_free", cheader_filename = "stdlib.h,string.h,glib.h", type_id = "G_TYPE_STRING", marshaller_type_name = "STRING", param_spec_function = "g_param_spec_string", get_value_function = "g_value_get_string", set_value_function = "g_value_set_string", type_signature = "s")] public class string { [CCode (cname = "strstr")] public weak string? str (string needle);