[vala/wip/dbusgen] warns on unrecognized nodes



commit d740547473bb6c53201af3fc20b4bf2168170db5
Author: Chris Daley <chebizarro gmail com>
Date:   Fri Nov 24 17:19:22 2017 -0800

    warns on unrecognized nodes

 dbusgen/valadbusgen.vala    |   21 +++++++++++++---
 dbusgen/valadbusparser.vala |   53 ++++++++++++++++++++++++++++++++++++++++--
 2 files changed, 67 insertions(+), 7 deletions(-)
---
diff --git a/dbusgen/valadbusgen.vala b/dbusgen/valadbusgen.vala
index 93cf463..67bd977 100644
--- a/dbusgen/valadbusgen.vala
+++ b/dbusgen/valadbusgen.vala
@@ -110,6 +110,7 @@ public class Vala.DBusGen {
 
                context.add_external_package ("glib-2.0");
                context.add_external_package ("gobject-2.0");
+               context.add_external_package ("gio-2.0");
 
                if (packages != null) {
                        foreach (string package in packages) {
@@ -130,10 +131,22 @@ public class Vala.DBusGen {
                }
 
                foreach (string source in sources) {
-                       if (FileUtils.test (source, FileTest.EXISTS) && source.has_suffix (".xml")) {
-                               var source_file = new SourceFile (context, SourceFileType.SOURCE, source);
-                               source_file.explicit = true;
-                               context.add_source_file (source_file);
+                       if (FileUtils.test (source, FileTest.EXISTS)) {
+                               if (source.has_suffix (".xml")) {
+                                       var source_file = new SourceFile (context, SourceFileType.SOURCE, 
source);
+                                       source_file.explicit = true;
+                                       context.add_source_file (source_file);
+                               } else if (FileUtils.test (source, FileTest.IS_DIR)) {
+                                       GLib.Dir dir = GLib.Dir.open(source);
+                                       string name;
+                                       while ((name = dir.read_name()) != null) {
+                                               if (name.has_suffix(".xml")) {
+                                                       var source_file = new SourceFile (context, 
SourceFileType.SOURCE, Path.build_filename(source, name));
+                                                       source_file.explicit = true;
+                                                       context.add_source_file (source_file);
+                                               }
+                                       }
+                               }
                        } else {
                                Report.error (null, "%s not found".printf (source));
                        }
diff --git a/dbusgen/valadbusparser.vala b/dbusgen/valadbusparser.vala
index 813fc2c..62895ec 100644
--- a/dbusgen/valadbusparser.vala
+++ b/dbusgen/valadbusparser.vala
@@ -200,7 +200,7 @@ public class Vala.DBusParser : CodeVisitor {
                                break;
                        case "org.freedesktop.DBus.GLib.Async":
                                if (current_node is Method) {
-                                       ((Method) current_method).is_async_callback = true;
+                                       ((Method) current_method).coroutine = true;
                                }
                                break;
                        case "org.freedesktop.DBus.GLib.NoReply":
@@ -243,6 +243,7 @@ public class Vala.DBusParser : CodeVisitor {
                current_param_index = 0U;
 
                while (current_token == MarkupTokenType.START_ELEMENT) {
+                                               
                        switch (reader.name) {
                                case "annotation":
                                        parse_annotation ();
@@ -342,6 +343,8 @@ public class Vala.DBusParser : CodeVisitor {
                                parse_annotation ();
                        } else if (reader.name == "doc:doc") {
                                parse_doc ();
+                       } else {
+                               parse_extension ();
                        }
                }
 
@@ -349,7 +352,49 @@ public class Vala.DBusParser : CodeVisitor {
        }
 
        private void parse_extension () {
+
+               Report.warning (get_current_src (), "Element %s is unrecognized".printf (reader.name));
+
+               skip_element ();
+
+               return;
+
+               stdout.printf ("%s\n", reader.name);
+               stdout.flush ();
+               next ();
                next ();
+               return;
+               
+               while (current_token == MarkupTokenType.START_ELEMENT) {
+                       switch (reader.name) {
+                               case "interface":
+                                       parse_interface ();
+                                       break;
+                               case "annotation":
+                                       parse_annotation ();
+                                       break;
+                               case "method":
+                                       parse_method ();
+                                       break;
+                               case "arg":
+                                       parse_arg ();
+                                       break;
+                               case "signal":
+                                       parse_signal ();
+                                       break;
+                               case "property":
+                                       parse_property ();
+                                       break;
+                               case "doc:doc":
+                                       parse_doc ();
+                                       break;
+                               default:
+                                       parse_extension ();
+                                       break;
+                       }
+               }
+
+               
        }
 
        private void parse_doc () {
@@ -363,7 +408,9 @@ public class Vala.DBusParser : CodeVisitor {
                        
                        if (current_token == MarkupTokenType.TEXT) {
                                SourceReference source = get_current_src ();
-                               comment += source.file.get_source_line (source.begin.line).strip ();
+                               foreach (string line in reader.content.split ("\n")) {
+                                       comment += " * %s \n".printf (line.strip ());
+                               }
                        }
                        
                        if (current_token == MarkupTokenType.END_ELEMENT && reader.name == "doc:doc") {
@@ -372,7 +419,7 @@ public class Vala.DBusParser : CodeVisitor {
                }
 
                if (comment.length > 0) {
-                       comment = "*\n * %s\n*".printf (comment);
+                       comment = "*\n%s*".printf (comment);
                        Comment doc = new Comment (comment, start_loc);
                        Symbol node = current_node as Symbol;
                        if (node != null) {


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