]> git.ipfire.org Git - thirdparty/vala.git/commitdiff
vala: Add MarkupReader.has_attribute() helper and use it accordingly
authorRico Tzschichholz <ricotz@ubuntu.com>
Mon, 12 Jun 2023 13:13:15 +0000 (15:13 +0200)
committerRico Tzschichholz <ricotz@ubuntu.com>
Sat, 12 Aug 2023 16:11:38 +0000 (18:11 +0200)
vala/valagirparser.vala
vala/valamarkupreader.vala

index 3703b6f518086d3b363ec8ca4a174f1c33ed0da7..a00042d0bf215353a4d26e366643e76061d92ee2 100644 (file)
@@ -2279,7 +2279,7 @@ public class Vala.GirParser : CodeVisitor {
                                                parse_enumeration ();
                                        }
                                } else {
-                                       if ((reader.get_attribute ("glib:error-quark") != null) || (reader.get_attribute ("glib:error-domain") != null)) {
+                                       if (reader.has_attribute ("glib:error-quark") || reader.has_attribute ("glib:error-domain")) {
                                                parse_error_domain ();
                                        } else {
                                                parse_enumeration ();
@@ -2303,7 +2303,7 @@ public class Vala.GirParser : CodeVisitor {
                                } else if (element_get_type_id () != null) {
                                        parse_boxed ("record");
                                } else if (!reader.get_attribute ("name").has_suffix ("Private")) {
-                                       if (reader.get_attribute ("glib:is-gtype-struct-for") == null && reader.get_attribute ("disguised") == "1") {
+                                       if (!reader.has_attribute ("glib:is-gtype-struct-for") && reader.get_attribute ("disguised") == "1") {
                                                parse_boxed ("record");
                                        } else {
                                                parse_record ();
@@ -2725,12 +2725,12 @@ public class Vala.GirParser : CodeVisitor {
                        var src = get_current_src ();
 
                        if (type_name == null) {
-                               if (reader.get_attribute ("length") != null) {
+                               if (reader.has_attribute ("length")) {
                                        array_length_idx = int.parse (reader.get_attribute ("length"));
                                        no_array_length = false;
                                        array_null_terminated = false;
                                }
-                               if (reader.get_attribute ("fixed-size") != null) {
+                               if (reader.has_attribute ("fixed-size")) {
                                        fixed_length = int.parse (reader.get_attribute ("fixed-size"));
                                        array_null_terminated = false;
                                }
@@ -2738,7 +2738,7 @@ public class Vala.GirParser : CodeVisitor {
                                        no_array_length = true;
                                        array_null_terminated = true;
                                }
-                               if (reader.get_attribute ("zero-terminated") != null) {
+                               if (reader.has_attribute ("zero-terminated")) {
                                        array_null_terminated = int.parse (reader.get_attribute ("zero-terminated")) != 0;
                                }
                                next ();
index e8e85891099c2a21cb0f27c365db8b3edf0f8f9e..3ad25e045e8b9ad22fd4a8789496d935a72164ce 100644 (file)
@@ -73,6 +73,10 @@ public class Vala.MarkupReader {
                column = 1;
        }
 
+       public bool has_attribute (string attr) {
+               return attributes.contains (attr);
+       }
+
        public string? get_attribute (string attr) {
                return attributes[attr];
        }