]> git.ipfire.org Git - thirdparty/vala.git/commitdiff
girparser: Actually respect given cprefix metadata for enumerations
authorRico Tzschichholz <ricotz@ubuntu.com>
Wed, 17 Jun 2020 14:58:56 +0000 (16:58 +0200)
committerRico Tzschichholz <ricotz@ubuntu.com>
Mon, 22 Jun 2020 08:25:11 +0000 (10:25 +0200)
vala/valagirparser.vala

index c31c8a344e62d96f1ffc08d749caf210baff7086..541ddbeaca93d191c9c346f562e127977d4d2604 100644 (file)
@@ -2373,7 +2373,12 @@ public class Vala.GirParser : CodeVisitor {
 
                sym.access = SymbolAccessibility.PUBLIC;
 
-               string common_prefix = null;
+               string? common_prefix = null;
+               bool explicit_prefix = false;
+               if (metadata.has_argument (ArgumentType.CPREFIX)) {
+                       sym.set_attribute_string ("CCode", "cprefix", metadata.get_string (ArgumentType.CPREFIX));
+                       explicit_prefix = true;
+               }
                bool has_member = false;
 
                next ();
@@ -2390,9 +2395,10 @@ public class Vala.GirParser : CodeVisitor {
                                has_member = true;
                                if (error_domain) {
                                        parse_error_member ();
-                                       calculate_common_prefix (ref common_prefix, old_current.get_cname ());
                                } else {
                                        parse_enumeration_member ();
+                               }
+                               if (!explicit_prefix) {
                                        calculate_common_prefix (ref common_prefix, old_current.get_cname ());
                                }
                        } else if (reader.name == "function") {