[vala/0.40] girparser: Add required copy/free attributes for gtype-boxed structs



commit 1129a01eb30a36e73aa7d6e459b8216ba0426af8
Author: Rico Tzschichholz <ricotz ubuntu com>
Date:   Tue Oct 8 14:04:35 2019 +0200

    girparser: Add required copy/free attributes for gtype-boxed structs
    
    See https://gitlab.gnome.org/GNOME/vala/issues/863

 vala/valagirparser.vala | 8 ++++++++
 1 file changed, 8 insertions(+)
---
diff --git a/vala/valagirparser.vala b/vala/valagirparser.vala
index 369010e73..6b00b6da1 100644
--- a/vala/valagirparser.vala
+++ b/vala/valagirparser.vala
@@ -2784,6 +2784,7 @@ public class Vala.GirParser : CodeVisitor {
                push_node (element_get_name (), true);
 
                Struct st;
+               bool require_copy_free = false;
                if (current.new_symbol) {
                        st = new Struct (element_get_name (), current.source_reference);
                        current.symbol = st;
@@ -2792,6 +2793,7 @@ public class Vala.GirParser : CodeVisitor {
                }
 
                set_type_id_ccode (st);
+               require_copy_free = st.has_attribute_argument ("CCode", "type_id");
 
                st.external = true;
                st.access = SymbolAccessibility.PUBLIC;
@@ -2842,6 +2844,12 @@ public class Vala.GirParser : CodeVisitor {
                        pop_metadata ();
                }
 
+               // Add default g_boxed_copy/free ccode-attributes
+               if (require_copy_free) {
+                       st.set_attribute_string ("CCode", "copy_function", "g_boxed_copy");
+                       st.set_attribute_string ("CCode", "free_function", "g_boxed_free");
+               }
+
                pop_node ();
                end_element ("record");
        }


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]