]> git.ipfire.org Git - thirdparty/vala.git/commitdiff
GObject: Fix boxed properties
authorJürg Billeter <j@bitron.ch>
Tue, 1 Sep 2009 17:53:17 +0000 (19:53 +0200)
committerJürg Billeter <j@bitron.ch>
Tue, 1 Sep 2009 17:53:17 +0000 (19:53 +0200)
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.

codegen/valagtypemodule.vala
vala/valaclass.vala
vapi/glib-2.0.vapi

index 229c7bf2acfded2206091bb88c9120d7b0e1b885..8e7a245d8b5a3dfcd34802b5ab4714ed1396d99c 100644 (file)
@@ -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) {
index 63b93e147789cbbcdc087b6306e191e2b66c148f..7bb05324922f2af794da927f6c0c4fc702f07fc0 100644 (file)
@@ -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 ();
index 8713507cea6977b3216164a8a9996beedd3c1252..5ca94b684cd5f192ba0603196f0dc8c84e982d8c 100644 (file)
@@ -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);