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



commit ec23523b80afd5dfa37fe9d7fb3db2a2497168a4
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 efe439981..9a47de56c 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]