]> git.ipfire.org Git - thirdparty/vala.git/commitdiff
girparser: Threat non-boxed disguised records as compact classes 507697e0902f21b02356c3237207b935663ef3a5
authorLuca Bruno <lucabru@src.gnome.org>
Sun, 29 May 2011 19:43:37 +0000 (21:43 +0200)
committerLuca Bruno <lucabru@src.gnome.org>
Sun, 29 May 2011 20:01:29 +0000 (22:01 +0200)
Fixes bug 651408.

vala/valagirparser.vala

index 839c1057a9349ea5f1e9f87f26122ff39987cea8..0140f6e189b009c468195051daced5660bd63489 100644 (file)
@@ -1667,10 +1667,14 @@ public class Vala.GirParser : CodeVisitor {
                                parse_callback ();
                        } else if (reader.name == "record") {
                                if (reader.get_attribute ("glib:get-type") != null && !metadata.get_bool (ArgumentType.STRUCT)) {
-                                       parse_boxed ("record");
+                                       parse_compact_class ("record", true);
                                } else {
                                        if (!reader.get_attribute ("name").has_suffix ("Private")) {
-                                               parse_record ();
+                                               if (reader.get_attribute ("disguised") == "1") {
+                                                       parse_compact_class ("record", false);
+                                               } else {
+                                                       parse_record ();
+                                               }
                                        } else {
                                                skip_element ();
                                        }
@@ -1680,7 +1684,7 @@ public class Vala.GirParser : CodeVisitor {
                        } else if (reader.name == "interface") {
                                parse_interface ();
                        } else if (reader.name == "glib:boxed") {
-                               parse_boxed ("glib:boxed");
+                               parse_compact_class ("glib:boxed", true);
                        } else if (reader.name == "union") {
                                parse_union ();
                        } else if (reader.name == "constant") {
@@ -2545,7 +2549,7 @@ public class Vala.GirParser : CodeVisitor {
                parse_function ("glib:signal");
        }
 
-       void parse_boxed (string element_name) {
+       void parse_compact_class (string element_name, bool is_boxed) {
                start_element (element_name);
                string name = reader.get_attribute ("name");
                if (name == null) {
@@ -2565,8 +2569,10 @@ public class Vala.GirParser : CodeVisitor {
                        if (typeid != null) {
                                cl.set_type_id ("%s ()".printf (typeid));
                        }
-                       cl.set_free_function ("g_boxed_free");
-                       cl.set_dup_function ("g_boxed_copy");
+                       if (is_boxed) {
+                               cl.set_free_function ("g_boxed_free");
+                               cl.set_dup_function ("g_boxed_copy");
+                       }
 
                        current.symbol = cl;
                } else {