[vala/wip/gtk4: 2/4] girparser: Avoid fatal handling of nameless unions



commit 31f053178efc7419debf6b75df1af6e297140d37
Author: Rico Tzschichholz <ricotz ubuntu com>
Date:   Sun Jan 31 22:25:16 2016 +0100

    girparser: Avoid fatal handling of nameless unions

 vala/valagirparser.vala |   28 +++++++++++++++++++++++++++-
 1 files changed, 27 insertions(+), 1 deletions(-)
---
diff --git a/vala/valagirparser.vala b/vala/valagirparser.vala
index 2e6fa4d..73273f3 100644
--- a/vala/valagirparser.vala
+++ b/vala/valagirparser.vala
@@ -3318,7 +3318,33 @@ public class Vala.GirParser : CodeVisitor {
 
        void parse_union () {
                start_element ("union");
-               push_node (element_get_name (), true);
+
+               string? element_name = element_get_name ();
+               if (element_name == null) {
+                       next ();
+
+                       while (current_token == MarkupTokenType.START_ELEMENT) {
+                               if (!push_metadata ()) {
+                                       skip_element ();
+                                       continue;
+                               }
+
+                               if (reader.name == "field") {
+                                       parse_field ();
+                               } else {
+                                       // error
+                                       Report.error (get_current_src (), "unknown child element `%s' in 
`transparent union'".printf (reader.name));
+                                       skip_element ();
+                               }
+
+                               pop_metadata ();
+                       }
+
+                       end_element ("union");
+                       return;
+               }
+
+               push_node (element_name, true);
 
                Struct st;
                if (current.new_symbol) {


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]