]> git.ipfire.org Git - thirdparty/vala.git/commitdiff
girparser: Add support for "ref_/ref_sink_/unref_function" metadata for classes
authorRico Tzschichholz <ricotz@ubuntu.com>
Tue, 5 Oct 2021 13:14:27 +0000 (15:14 +0200)
committerRico Tzschichholz <ricotz@ubuntu.com>
Thu, 14 Oct 2021 10:23:23 +0000 (12:23 +0200)
Fixes https://gitlab.gnome.org/GNOME/vala/issues/1233

vala/valagirparser.vala

index a005efdb06da6c0371dfff30a8ecbf226397f38e..31b8ad4c619fe4b4d5242c93ac995b8a8590b9bc 100644 (file)
@@ -88,6 +88,9 @@ public class Vala.GirParser : CodeVisitor {
                FLOATING,
                TYPE_ID,
                TYPE_GET_FUNCTION,
+               REF_FUNCTION,
+               REF_SINK_FUNCTION,
+               UNREF_FUNCTION,
                RETURN_VOID,
                RETURNS_MODIFIED_POINTER,
                DELEGATE_TARGET_CNAME,
@@ -2998,6 +3001,16 @@ public class Vala.GirParser : CodeVisitor {
 
                cl.access = SymbolAccessibility.PUBLIC;
 
+               if (metadata.has_argument (ArgumentType.REF_FUNCTION)) {
+                       cl.set_attribute_string ("CCode", "ref_function", metadata.get_string (ArgumentType.REF_FUNCTION));
+               }
+               if (metadata.has_argument (ArgumentType.REF_SINK_FUNCTION)) {
+                       cl.set_attribute_string ("CCode", "ref_sink_function", metadata.get_string (ArgumentType.REF_SINK_FUNCTION));
+               }
+               if (metadata.has_argument (ArgumentType.UNREF_FUNCTION)) {
+                       cl.set_attribute_string ("CCode", "unref_function", metadata.get_string (ArgumentType.UNREF_FUNCTION));
+               }
+
                next ();
 
                cl.comment = parse_symbol_doc ();
@@ -3583,6 +3596,15 @@ public class Vala.GirParser : CodeVisitor {
                if (metadata.has_argument (ArgumentType.BASE_TYPE)) {
                        cl.add_base_type (parse_type_from_string (metadata.get_string (ArgumentType.BASE_TYPE), true, metadata.get_source_reference (ArgumentType.BASE_TYPE)));
                }
+               if (metadata.has_argument (ArgumentType.REF_FUNCTION)) {
+                       cl.set_attribute_string ("CCode", "ref_function", metadata.get_string (ArgumentType.REF_FUNCTION));
+               }
+               if (metadata.has_argument (ArgumentType.REF_SINK_FUNCTION)) {
+                       cl.set_attribute_string ("CCode", "ref_sink_function", metadata.get_string (ArgumentType.REF_SINK_FUNCTION));
+               }
+               if (metadata.has_argument (ArgumentType.UNREF_FUNCTION)) {
+                       cl.set_attribute_string ("CCode", "unref_function", metadata.get_string (ArgumentType.UNREF_FUNCTION));
+               }
 
                next ();