]> git.ipfire.org Git - thirdparty/vala.git/commitdiff
girparser: Allow changing the type of constants using metadata
authorRico Tzschichholz <ricotz@ubuntu.com>
Thu, 21 Jun 2018 11:21:51 +0000 (13:21 +0200)
committerRico Tzschichholz <ricotz@ubuntu.com>
Thu, 21 Jun 2018 11:21:51 +0000 (13:21 +0200)
See https://gitlab.gnome.org/GNOME/vala/issues/643

vala/valagirparser.vala

index 95ad5c9d2ed5e9ab5d4c721551203ee4e9e2b4be..31ae069c2c87e23e9cb4793bc50c98084ff0c1cb 100644 (file)
@@ -3502,12 +3502,22 @@ public class Vala.GirParser : CodeVisitor {
 
                var comment = parse_symbol_doc ();
 
-               var type = parse_type ();
+               bool no_array_length;
+               bool array_null_terminated;
+               int array_length_idx;
+               var type = parse_type (null, out array_length_idx, true, out no_array_length, out array_null_terminated);
+               type = element_get_type (type, true, ref no_array_length, ref array_null_terminated);
                var c = new Constant (current.name, type, null, current.source_reference);
                current.symbol = c;
                c.access = SymbolAccessibility.PUBLIC;
                c.comment = comment;
                c.external = true;
+               if (no_array_length || array_null_terminated) {
+                       c.set_attribute_bool ("CCode", "array_length", !no_array_length);
+               }
+               if (array_null_terminated) {
+                       c.set_attribute_bool ("CCode", "array_null_terminated", true);
+               }
 
                pop_node ();
                end_element ("constant");