valadbusparser.vala \
valadbusvariantmodule.vala \
valadbusnamespacestrategy.vala \
+ valadbusgenextension.vala \
$(NULL)
valadbusgen_SOURCES = \
context.set_target_profile (Profile.GOBJECT);
context.vapi_comments = true;
+ context.add_external_package ("gio-2.0");
+
if (packages != null) {
foreach (string package in packages) {
context.add_external_package (package);
}
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.from_commandline = true;
+ context.add_source_file (source_file);
+ } else if (FileUtils.test (source, FileTest.IS_DIR)) {
+ try {
+ 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.from_commandline = true;
+ context.add_source_file (source_file);
+ }
+ }
+ } catch (FileError e) {
+ Report.error (null, e.message);
+ }
+ }
} else {
Report.error (null, "%s not found".printf (source));
}
--- /dev/null
+/* valadbusgenextension.vala
+ *
+ * Copyright (C) 2017 Chris Daley
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2.1 of the License, or (at your option) any later version.
+
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
+ *
+ * Author:
+ * Chris Daley <chebizarro@gmail.com>
+ */
+
+public abstract class Vala.DBusExtension {
+
+ public string prefix { get; set; }
+
+ public abstract void parse_node (string decl, CodeNode node, SourceReference reference);
+
+ public abstract void parse_attribute (CodeNode node, SourceReference reference);
+}
private SourceLocation begin;
private SourceLocation end;
+ private HashMap<string, DBusExtension> extensions = new HashMap<string, DBusExtension> ();
+
public int dbus_timeout { get; set; }
public NamespaceStrategy namespace_strategy { get; set; }
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":
parse_annotation ();
} else if (reader.name == "doc:doc") {
parse_doc ();
+ } else {
+ parse_extension ();
}
}
}
private void parse_extension () {
- next ();
+ string prefix = reader.name.split (":")[0];
+ DBusExtension? ext = extensions.get (prefix);
+
+ if (ext != null) {
+ ext.parse_node (reader.name, current_node, get_current_src ());
+ next ();
+ } else {
+ Report.warning (get_current_src (), "Element %s is unrecognized".printf (reader.name));
+ skip_element ();
+ }
+
+ return;
}
private void parse_doc () {
next ();
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") {
}
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) {