]> git.ipfire.org Git - thirdparty/vala.git/commitdiff
libvaladoc: drop dependency on libvala
authorFlorian Brosch <flo.brosch@gmail.com>
Thu, 21 Jul 2011 18:04:32 +0000 (20:04 +0200)
committerFlorian Brosch <flo.brosch@gmail.com>
Fri, 29 Jul 2011 00:45:25 +0000 (02:45 +0200)
17 files changed:
src/driver/0.13.x/treebuilder.vala
src/libvaladoc/Makefile.am
src/libvaladoc/api/package.vala
src/libvaladoc/api/sourcefile.vala
src/libvaladoc/api/tree.vala
src/libvaladoc/documentation/documentationparser.vala
src/libvaladoc/errorreporter.vala
src/libvaladoc/filehelper.vala
src/libvaladoc/importer/gircomment.vala [new file with mode: 0755]
src/libvaladoc/importer/girdocumentationbuilder.vala [changed mode: 0755->0644]
src/libvaladoc/importer/girdocumentationimporter.vala
src/libvaladoc/markupreader.vala [new file with mode: 0644]
src/libvaladoc/markupsourcelocation.vala [new file with mode: 0644]
src/libvaladoc/markuptokentype.vala [new file with mode: 0644]
src/libvaladoc/valadoc-1.0.deps.in
src/libvaladoc/valadoc-1.0.pc.in
src/valadoc/valadoc.vala

index a4a05ec9be75a71365d9612688dcbec7cae447b5..9a10c1b76c795a52c8910145ac4b5152d52ea5d4 100644 (file)
@@ -445,7 +445,7 @@ public class Valadoc.Drivers.TreeBuilder : Vala.CodeVisitor {
 
                var vfile = new Vala.SourceFile (context, Vala.SourceFileType.PACKAGE, package_path);
                context.add_source_file (vfile);
-               Package vdpkg = new Package (vfile, pkg, true, null);
+               Package vdpkg = new Package (pkg, true, null);
                register_source_file (register_package (vdpkg), vfile);
 
                add_deps (context, Path.build_filename (Path.get_dirname (package_path), "%s.deps".printf (pkg)), pkg);
@@ -502,7 +502,7 @@ public class Valadoc.Drivers.TreeBuilder : Vala.CodeVisitor {
                                        var source_file = new Vala.SourceFile (context, Vala.SourceFileType.SOURCE, rpath);
 
                                        if (source_package == null) {
-                                               source_package = register_package (new Package (source_file, settings.pkg_name, false, null));
+                                               source_package = register_package (new Package (settings.pkg_name, false, null));
                                        }
 
                                        register_source_file (source_package, source_file);
@@ -525,7 +525,7 @@ public class Valadoc.Drivers.TreeBuilder : Vala.CodeVisitor {
                                        file_name = file_name.substring (0, file_name.length - ".vapi".length);
 
                                        var vfile = new Vala.SourceFile (context, Vala.SourceFileType.PACKAGE, rpath);
-                                       Package vdpkg = new Package (vfile, file_name, true, null);
+                                       Package vdpkg = new Package (file_name, true, null);
                                        context.add_source_file (vfile);
 
                                        register_source_file (register_package (vdpkg), vfile);
index 64c277bca5236b1f21653689f1bebce079749579..affc2e69070aeb0086871eb865eb90ebb909c752 100755 (executable)
@@ -9,7 +9,6 @@ AM_CFLAGS = \
        $(LIBGVC_CFLAGS) \
        $(GLIB_CFLAGS) \
        $(LIBGEE_CFLAGS) \
-       $(LIBVALA_CFLAGS) \
        $(GMODULE_CFLAGS) \
        $(NULL)
 
@@ -31,6 +30,9 @@ libvaladoc_la_VALASOURCES = \
        markupwriter.vala \
        devhelp-markupwriter.vala \
        ctyperesolver.vala \
+       markupsourcelocation.vala \
+       markuptokentype.vala \
+       markupreader.vala \
        documentation/girdocumentationscanner.vala \
        documentation/commentscanner.vala \
        documentation/documentation.vala \
@@ -39,7 +41,7 @@ libvaladoc_la_VALASOURCES = \
        documentation/wikiscanner.vala \
        importer/girdocumentationimporter.vala \
        importer/documentationimporter.vala \
-       importer/girdocumentationbuilder.vala \
+       importer/gircomment.vala \
        importer/valadocdocumentationimporter.vala \
        importer/valadocdocumentationimporterscanner.vala \
        api/symbolaccessibility.vala \
@@ -158,7 +160,7 @@ libvaladocincludedir = $(includedir)/
 
 
 libvaladoc.vala.stamp: $(libvaladoc_la_VALASOURCES)
-       $(VALAC) $(VALAFLAGS) -C -H valadoc-1.0.h --pkg gee-1.0 --pkg $(VALA_PACKAGE) --pkg libgvc --pkg gmodule-2.0 --pkg libgvc --vapidir $(top_srcdir)/src/vapi --pkg config --library valadoc-1.0 --basedir $(top_srcdir)/src/libvaladoc/ --save-temps $^
+       $(VALAC) $(VALAFLAGS) -C -H valadoc-1.0.h --pkg gee-1.0 --pkg libgvc --pkg gmodule-2.0 --pkg libgvc --vapidir $(top_srcdir)/src/vapi --pkg config --library valadoc-1.0 --basedir $(top_srcdir)/src/libvaladoc/ --save-temps $^
        touch $@
 
 
@@ -169,7 +171,6 @@ libvaladoc_la_LIBADD = \
        $(LIBGVC_LIBS)     \
        $(LIBGEE_LIBS)     \
        $(GLIB_LIBS)       \
-       $(LIBVALA_LIBS)    \
        $(GMODULE_LIBS)    \
        $(NULL)
 
@@ -192,9 +193,6 @@ MAINTAINERCLEANFILES =                        \
 pkgconfigdir = $(libdir)/pkgconfig
 pkgconfig_DATA = valadoc-1.0.pc
 
-valadoc-1.0.deps: valadoc-1.0.deps.in
-       cat $^ > $@
-       echo $(VALA_PACKAGE) >> $@
 
 vapidir = $(datadir)/vala/vapi
 vapi_DATA =     \
index f89e152f0027c4d1ff90d6d60ec52550be3a9bcc..6656b4810d0ecf89ceda9b61ddd9e8e9f2432088 100755 (executable)
@@ -72,7 +72,7 @@ public class Valadoc.Api.Package : Node {
                return this._dependencies.read_only_view;
        }
 
-       public Package (Vala.SourceFile vfile, string name, bool is_package, void* data) {
+       public Package (string name, bool is_package, void* data) {
                base (null, null, name, data);
 
                this.is_package = is_package;
index f0e67214c63ac5fbfe963133c6cad8a676a72551..6ac6720365f37ba4354e8f27747c97d97e32e09c 100644 (file)
 /**
  * Represents a source file
  */
-public class SourceFile : Object {
+public class Valadoc.Api.SourceFile : Object {
        public string relative_path {
                private set;
                get;
        }
 
-       public string relative_c_path {
+       public string? relative_c_path {
                private set;
                get;
        }
@@ -38,7 +38,7 @@ public class SourceFile : Object {
                return Path.get_basename (relative_path);
        }
 
-       public SourceFile (string relative_path, string relative_c_path) {
+       public SourceFile (string relative_path, string? relative_c_path) {
                this.relative_c_path = relative_c_path;
                this.relative_path = relative_path;
        }
index c662058345b368b3ecfa34d28e2d4f5e100141b7..bddb1bfb9f78b2d333b3b886f036d13213d073ea 100755 (executable)
@@ -44,11 +44,6 @@ public class Valadoc.Api.Tree {
                this.packages.add (package);
        }
 
-       internal Vala.CodeContext context {
-               private set;
-               get;
-       }
-
        /**
         * The root of the wiki tree.
         */
@@ -276,7 +271,7 @@ public class Valadoc.Api.Tree {
                        }
 
                        if (imported == false) {
-                               Vala.Report.error (null, "%s not found in specified import directories".printf (pkg_name));
+                               reporter.simple_error ("%s not found in specified import directories", pkg_name);
                        }
                }
        }
index f2b2ae7544cbf422cd5a07e86075db5441c02d79..eee9f01a9988059b316cb11ef4832e4277065391 100755 (executable)
@@ -87,14 +87,14 @@ public class Valadoc.DocumentationParser : Object, ResourceLocator {
                }
        }
 
-       public Comment? parse_gir_comment (Api.Node element, GirDocumentationBuilder doc) {
+       public Comment? parse_gir_comment (Api.Node element, GirComment doc) {
                try {
                        _stack.clear ();
 
                        if (doc.content != null) {
                                _parser = _gir_parser;
                                _scanner = _gir_scanner;
-                               _gir_parser.parse (doc.content, doc.source_reference.file.filename, doc.source_reference.first_line, doc.source_reference.first_column);
+                               _gir_parser.parse (doc.content, doc.file.get_name (), doc.first_line, doc.first_column);
                        } else {
                                push (_factory.create_comment ());
                        }
@@ -105,7 +105,7 @@ public class Valadoc.DocumentationParser : Object, ResourceLocator {
 
                        if (doc.return_value != null && !(element is Api.Method && ((Api.Method) element).is_constructor)) {
                                push (_factory.create_taglet ("return"));
-                               _gir_taglet_parser.parse (doc.return_value.content, doc.return_value.source_reference.file.filename, doc.return_value.source_reference.first_line, doc.return_value.source_reference.first_column);
+                               _gir_taglet_parser.parse (doc.return_value.content, doc.return_value.file.get_name (), doc.return_value.first_line, doc.return_value.first_column);
                        }
 
                        var iter = doc.parameters.map_iterator ();
@@ -116,7 +116,7 @@ public class Valadoc.DocumentationParser : Object, ResourceLocator {
                                        var param = _factory.create_taglet ("param") as Taglets.Param;
                                        param.parameter_name = key;
                                        push (param);
-                                       _gir_taglet_parser.parse (val.content, val.source_reference.file.filename, val.source_reference.first_line, val.source_reference.first_column);
+                                       _gir_taglet_parser.parse (val.content, val.file.get_name (), val.first_line, val.first_column);
                                }
                        }
 
index 48e2a6c44b2ee668447faaa7a3359b206820972f..0ff49237361b3576c11d3bf8a7f810d14ed57c57 100755 (executable)
@@ -38,11 +38,8 @@ public class Valadoc.ErrorReporter : Object {
        }
 
        public unowned GLib.FileStream stream {
-               get; set;
-       }
-
-       public Vala.Report? vreporter {
-               get; set;
+               get;
+               set;
        }
 
        public ErrorReporter () {
@@ -112,14 +109,12 @@ public class Valadoc.ErrorReporter : Object {
                this._errors++;
        }
 
-       //TODO
        public void error (string file, long line, long startpos, long endpos, string errline, string msg_format, ...) {
                var args = va_list();
                this.msg (ErrorType.ERROR, file, line, startpos, endpos, errline, msg_format, args);
                this._errors++;
        }
 
-       //TODO
        public void warning (string file, long line, long startpos, long endpos, string errline, string msg_format, ...) {
                var args = va_list();
                this.msg (ErrorType.WARNING, file, line, startpos, endpos, errline, msg_format, args);
index d8b2ef621553c5b1af01b2b340cac505cc457803..137aff1cd8d30c2d19c8d32177e9836bc94d5384 100755 (executable)
@@ -108,14 +108,87 @@ namespace Valadoc {
                return true;
        }
 
+
+       private inline bool ends_with_dir_separator (string s) {
+               // --- ported from libvala ---
+               return Path.is_dir_separator (s.get_char (s.length - 1));
+       }
+
        /**
         * Returns canonicalized absolute pathname
         *
         * @param basedir the path being checked
         * @return a canonicalized absolute pathname
         */
-       public string realpath (string basedir) {
-               return Vala.CodeContext.realpath (basedir);
+       public string realpath (string name) {
+               // --- ported from libvala ---
+
+               string rpath;
+
+               // start of path component
+               weak string start;
+               // end of path component
+               weak string end;
+
+               if (!Path.is_absolute (name)) {
+                       // relative path
+                       rpath = Environment.get_current_dir ();
+
+                       start = end = name;
+               } else {
+                       // set start after root
+                       start = end = Path.skip_root (name);
+
+                       // extract root
+                       rpath = name.substring (0, (int) ((char*) start - (char*) name));
+               }
+
+               long root_len = (long) ((char*) Path.skip_root (rpath) - (char*) rpath);
+
+               for (; start.get_char () != 0; start = end) {
+                       // skip sequence of multiple path-separators
+                       while (Path.is_dir_separator (start.get_char ())) {
+                               start = start.next_char ();
+                       }
+
+                       // find end of path component
+                       long len = 0;
+                       for (end = start; end.get_char () != 0 && !Path.is_dir_separator (end.get_char ()); end = end.next_char ()) {
+                               len++;
+                       }
+
+                       if (len == 0) {
+                               break;
+                       } else if (len == 1 && start.get_char () == '.') {
+                               // do nothing
+                       } else if (len == 2 && start.has_prefix ("..")) {
+                               // back up to previous component, ignore if at root already
+                               if (rpath.length > root_len) {
+                                       do {
+                                               rpath = rpath.substring (0, rpath.length - 1);
+                                       } while (!ends_with_dir_separator (rpath));
+                               }
+                       } else {
+                               if (!ends_with_dir_separator (rpath)) {
+                                       rpath += Path.DIR_SEPARATOR_S;
+                               }
+
+                               rpath += start.substring (0, len);
+                       }
+               }
+
+               if (rpath.length > root_len && ends_with_dir_separator (rpath)) {
+                       rpath = rpath.substring (0, rpath.length - 1);
+               }
+
+               if (Path.DIR_SEPARATOR != '/') {
+                       // don't use backslashes internally,
+                       // to avoid problems in #include directives
+                       string[] components = rpath.split ("\\");
+                       rpath = string.joinv ("/", components);
+               }
+
+               return rpath;
        }
 }
 
diff --git a/src/libvaladoc/importer/gircomment.vala b/src/libvaladoc/importer/gircomment.vala
new file mode 100755 (executable)
index 0000000..7caa679
--- /dev/null
@@ -0,0 +1,56 @@
+/* DocumentationBuilderimporter.vala
+ *
+ * Copyright (C) 2010-2011 Florian Brosch
+ *
+ * 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:
+ *     Florian Brosch <flo.brosch@gmail.com>
+ */
+
+
+using Valadoc;
+using Gee;
+
+
+/**
+ * A documentation comment used by valadoc
+ */
+public class Valadoc.Importer.GirComment : Valadoc.Api.SourceComment {
+       private HashMap<string, Api.SourceComment> _parameters = new HashMap<string, Api.SourceComment> ();
+
+       public Map<string, Api.SourceComment> parameters {
+               owned get { return _parameters.read_only_view; }
+       }
+
+       public Api.SourceComment? return_value {
+               internal set;
+               get;
+       }
+
+       public GirComment (string content, Api.SourceFile file, int first_line, int first_column, int last_line, int last_column) {
+               base (content, file, first_line, first_column, last_line, last_column);
+               return_value = null;
+       }
+
+       internal void add_parameter (string name, Api.SourceComment comment) {
+               _parameters.set (name, comment);
+       }
+
+       public bool is_empty () {
+               return return_value == null && (content == null || content == "") && parameters.is_empty;
+       }
+}
+
old mode 100755 (executable)
new mode 100644 (file)
index d502cf3..7c4bc0f
@@ -28,24 +28,31 @@ using Gee;
 /**
  * A documentation comment used by valadoc
  */
-public class Valadoc.Importer.GirDocumentationBuilder : Vala.Comment {
-       private HashMap<string, Vala.Comment> _parameters = new HashMap<string, Vala.Comment> ();
+public class Valadoc.Importer.GirComment : Valadoc.Api.Comment {
+       private HashMap<string, Api.Comment> _parameters = new HashMap<string, APi.Comment> ();
 
-       public Map<string, Vala.Comment> parameters { owned get { return _parameters.read_only_view; } }
+       public Map<string, Api.Comment> parameters {
+               owned get { return _parameters.read_only_view; }
+       }
 
-       public Vala.Comment? return_value { get; internal set; }
+       public Api.Comment? return_value {
+               internal set;
+               get;
+       }
        
-       public GirDocumentationBuilder.empty (Vala.SourceReference _source_reference) {
+       //TODO
+       public GirComment.empty (Api.SourceReference _source_reference) {
                base ("", _source_reference);
                return_value = null;
        }
 
-       public GirDocumentationBuilder (Vala.Comment comment) {
+       //TODO
+       public GirComment (Api.Comment comment) {
                base (comment.content, comment.source_reference);
                return_value = null;
        }
 
-       internal void add_parameter (string name, Vala.Comment comment) {
+       internal void add_parameter (string name, Api.Comment comment) {
                _parameters.set (name, comment);
        }
 
index 19c59993f32c5f2e9432ac1dac87d293ee825d86..d83bc2d7d474d8a1abf456e1027daddffb9d3b82 100755 (executable)
@@ -1,6 +1,6 @@
 /* DocumentationBuilderimporter.vala
  *
- * Copyright (C) 2010 Florian Brosch
+ * Copyright (C) 2010-2011 Florian Brosch
  *
  * This library is free software; you can redistribute it and/or
  * modify it under the terms of the GNU Lesser General Public
@@ -26,25 +26,52 @@ using Gee;
 
 public class Valadoc.Importer.GirDocumentationImporter : DocumentationImporter {
        DocumentationParser docparser;
-       Vala.MarkupReader reader;
+       MarkupReader reader;
 
-       Vala.SourceFile current_source_file;
-       Vala.SourceLocation begin;
-       Vala.SourceLocation end;
-       Vala.MarkupTokenType current_token;
+       ErrorReporter reporter;
 
-       Vala.DataType dummy_type;
+       Api.SourceFile current_source_file;
+       MarkupSourceLocation begin;
+       MarkupSourceLocation end;
+       MarkupTokenType current_token;
 
        LinkedList<string> type_cname_stack = new LinkedList<string> ();
 
        int anonymous_param_count = 0;
 
-       public override string file_extension { get { return "gir"; } }
+       public override string file_extension {
+               get { return "gir"; }
+       }
+
+       private GirComment create_empty_gir_comment () {
+               return new GirComment ("", current_source_file, begin.line, begin.column, end.line, end.column);
+       }
+
+       private GirComment create_gir_comment (Api.SourceComment sc) {
+               return new GirComment (sc.content, sc.file, sc.first_line, sc.first_column, sc.last_line, sc.last_column);
+       }
+
+       private void error (string msg_format, ...) {
+               va_list args = va_list();
+               string msg = msg_format.vprintf (args);
+
+               string code_line = null;
 
-       public GirDocumentationImporter (Api.Tree tree, DocumentationParser docparser, ModuleLoader modules, Settings settings) {
+               unowned string start_src_line = ((string) begin.pos).utf8_offset (-begin.column);
+               int offset = start_src_line.index_of_char ('\n');
+               if (offset == -1) {
+                       code_line = start_src_line;
+               } else {
+                       code_line = start_src_line.substring (0, offset);
+               }
+
+               reporter.error (current_source_file.get_name (), begin.line, begin.column, end.column, code_line, msg);
+       }
+
+       public GirDocumentationImporter (Api.Tree tree, DocumentationParser docparser, ModuleLoader modules, Settings settings, ErrorReporter reporter) {
                base (tree, modules, settings);
-               this.dummy_type = new Vala.StructValueType (new Vala.Struct ("Dummy"));
                this.docparser = docparser;
+               this.reporter = reporter;
        }
 
        public override void process (string filename) {
@@ -52,8 +79,8 @@ public class Valadoc.Importer.GirDocumentationImporter : DocumentationImporter {
        }
 
        void parse_file (string gir_file) {
-               reader = new Vala.MarkupReader (gir_file);
-               this.current_source_file = new Vala.SourceFile (tree.context, Vala.SourceFileType.PACKAGE, GLib.Path.get_basename (gir_file));
+               this.current_source_file = new Api.SourceFile (gir_file, null);
+               reader = new MarkupReader (gir_file, reporter);
 
                // xml prolog
                next ();
@@ -64,14 +91,14 @@ public class Valadoc.Importer.GirDocumentationImporter : DocumentationImporter {
                this.current_source_file = null;
        }
 
-       Vala.Comment? parse_doc () {
+       Api.SourceComment? parse_doc () {
                start_element ("doc");
 
-               Vala.Comment comment = null;
+               Api.SourceComment comment = null;
                next ();
 
-               if (current_token == Vala.MarkupTokenType.TEXT) {
-                       comment = new Vala.Comment (reader.content, get_current_src ());
+               if (current_token == MarkupTokenType.TEXT) {
+                       comment = new Api.SourceComment (reader.content, current_source_file, begin.line, begin.column, end.line, end.column);
                        next ();
                }
 
@@ -84,28 +111,22 @@ public class Valadoc.Importer.GirDocumentationImporter : DocumentationImporter {
        }
 
        void start_element (string name) {
-               if (current_token != Vala.MarkupTokenType.START_ELEMENT || reader.name != name) {
-                       // error
-                       Vala.Report.error (get_current_src (), "expected start element of `%s' instead of `%s'".printf (name, reader.name));
+               if (current_token != MarkupTokenType.START_ELEMENT || reader.name != name) {
+                       error ("expected start element of `%s' instead of `%s'", name, reader.name);
                }
        }
 
        void end_element (string name) {
-               if (current_token != Vala.MarkupTokenType.END_ELEMENT || reader.name != name) {
-                       // error
-                       Vala.Report.error (get_current_src (), "expected end element of `%s' instead of `%s'".printf (name, reader.name));
+               if (current_token != MarkupTokenType.END_ELEMENT || reader.name != name) {
+                       error ("expected end element of `%s' instead of `%s'", name, reader.name);
                }
                next ();
        }
 
-       Vala.SourceReference get_current_src () {
-               return new Vala.SourceReference (this.current_source_file, begin.line, begin.column, end.line, end.column);
-       }
-
        void parse_repository () {
                start_element ("repository");
                next ();
-               while (current_token == Vala.MarkupTokenType.START_ELEMENT) {
+               while (current_token == MarkupTokenType.START_ELEMENT) {
                        if (reader.name == "namespace") {
                                parse_namespace ();
                        } else if (reader.name == "include") {
@@ -115,8 +136,7 @@ public class Valadoc.Importer.GirDocumentationImporter : DocumentationImporter {
                        } else if (reader.name == "c:include") {
                                parse_c_include ();
                        } else {
-                               // error
-                               Vala.Report.error (get_current_src (), "unknown child element `%s' in `repository'".printf (reader.name));
+                               error ("unknown child element `%s' in `repository'", reader.name);
                                break;
                        }
                }
@@ -146,12 +166,12 @@ public class Valadoc.Importer.GirDocumentationImporter : DocumentationImporter {
 
                int level = 1;
                while (level > 0) {
-                       if (current_token == Vala.MarkupTokenType.START_ELEMENT) {
+                       if (current_token == MarkupTokenType.START_ELEMENT) {
                                level++;
-                       } else if (current_token == Vala.MarkupTokenType.END_ELEMENT) {
+                       } else if (current_token == MarkupTokenType.END_ELEMENT) {
                                level--;
-                       } else if (current_token == Vala.MarkupTokenType.EOF) {
-                               Vala.Report.error (get_current_src (), "unexpected end of file");
+                       } else if (current_token == MarkupTokenType.EOF) {
+                               error ("unexpected end of file");
                                break;
                        }
                        next ();
@@ -162,7 +182,7 @@ public class Valadoc.Importer.GirDocumentationImporter : DocumentationImporter {
                start_element ("namespace");
                next ();
 
-               while (current_token == Vala.MarkupTokenType.START_ELEMENT) {
+               while (current_token == MarkupTokenType.START_ELEMENT) {
                        if (reader.get_attribute ("introspectable") == "0") {
                                skip_element ();
                                continue;
@@ -195,8 +215,7 @@ public class Valadoc.Importer.GirDocumentationImporter : DocumentationImporter {
                        } else if (reader.name == "constant") {
                                parse_constant ();
                        } else {
-                               // error
-                               Vala.Report.error (get_current_src (), "unknown child element `%s' in `namespace'".printf (reader.name));
+                               error ("unknown child element `%s' in `namespace'", reader.name);
                                break;
                        }
                }
@@ -206,6 +225,13 @@ public class Valadoc.Importer.GirDocumentationImporter : DocumentationImporter {
        void parse_alias () {
                start_element ("alias");
                next ();
+
+               while (current_token == MarkupTokenType.START_ELEMENT) {
+                       if (reader.name != "alias") {
+                               skip_element ();
+                       }
+               }
+
                end_element ("alias");
        }
 
@@ -215,11 +241,11 @@ public class Valadoc.Importer.GirDocumentationImporter : DocumentationImporter {
                type_cname_stack.add (cname);
                next ();
 
-               if (current_token == Vala.MarkupTokenType.START_ELEMENT && reader.name == "doc") {
-                       process_documentation (cname, new GirDocumentationBuilder (parse_doc ()));
+               if (current_token == MarkupTokenType.START_ELEMENT && reader.name == "doc") {
+                       process_documentation (cname, create_gir_comment (parse_doc ()));
                }
 
-               while (current_token == Vala.MarkupTokenType.START_ELEMENT) {
+               while (current_token == MarkupTokenType.START_ELEMENT) {
                        if (reader.get_attribute ("introspectable") == "0") {
                                skip_element ();
                                continue;
@@ -243,11 +269,11 @@ public class Valadoc.Importer.GirDocumentationImporter : DocumentationImporter {
                type_cname_stack.add (cname);
                next ();
 
-               if (current_token == Vala.MarkupTokenType.START_ELEMENT && reader.name == "doc") {
-                       process_documentation (cname, new GirDocumentationBuilder (parse_doc ()));
+               if (current_token == MarkupTokenType.START_ELEMENT && reader.name == "doc") {
+                       process_documentation (cname, create_gir_comment (parse_doc ()));
                }
 
-               while (current_token == Vala.MarkupTokenType.START_ELEMENT) {
+               while (current_token == MarkupTokenType.START_ELEMENT) {
                        if (reader.get_attribute ("introspectable") == "0") {
                                skip_element ();
                                continue;
@@ -270,18 +296,18 @@ public class Valadoc.Importer.GirDocumentationImporter : DocumentationImporter {
                string cname = reader.get_attribute ("c:identifier");
                next ();
 
-               if (current_token == Vala.MarkupTokenType.START_ELEMENT && reader.name == "doc") {
-                       process_documentation (cname, new GirDocumentationBuilder (parse_doc ()));
+               if (current_token == MarkupTokenType.START_ELEMENT && reader.name == "doc") {
+                       process_documentation (cname, create_gir_comment (parse_doc ()));
                }
 
                end_element ("member");
        }
 
-       void parse_return_value (GirDocumentationBuilder doc) {
+       void parse_return_value (GirComment doc) {
                start_element ("return-value");
                next ();
 
-               if (current_token == Vala.MarkupTokenType.START_ELEMENT && reader.name == "doc") {
+               if (current_token == MarkupTokenType.START_ELEMENT && reader.name == "doc") {
                        doc.return_value = parse_doc ();
                }
 
@@ -290,7 +316,7 @@ public class Valadoc.Importer.GirDocumentationImporter : DocumentationImporter {
                end_element ("return-value");
        }
 
-       void parse_parameter (GirDocumentationBuilder doc) {
+       void parse_parameter (GirComment doc) {
                start_element ("parameter");
                string name = reader.get_attribute ("name");
 
@@ -301,7 +327,7 @@ public class Valadoc.Importer.GirDocumentationImporter : DocumentationImporter {
 
                next ();
 
-               if (current_token == Vala.MarkupTokenType.START_ELEMENT && reader.name == "doc") {
+               if (current_token == MarkupTokenType.START_ELEMENT && reader.name == "doc") {
                        doc.add_parameter (name, parse_doc ());
                }
 
@@ -329,11 +355,11 @@ public class Valadoc.Importer.GirDocumentationImporter : DocumentationImporter {
                type_cname_stack.add (cname);
                next ();
 
-               if (current_token == Vala.MarkupTokenType.START_ELEMENT && reader.name == "doc") {
-                       process_documentation (cname, new GirDocumentationBuilder (parse_doc ()));
+               if (current_token == MarkupTokenType.START_ELEMENT && reader.name == "doc") {
+                       process_documentation (cname, create_gir_comment (parse_doc ()));
                }
 
-               while (current_token == Vala.MarkupTokenType.START_ELEMENT) {
+               while (current_token == MarkupTokenType.START_ELEMENT) {
                        if (reader.get_attribute ("introspectable") == "0") {
                                skip_element ();
                                continue;
@@ -354,8 +380,7 @@ public class Valadoc.Importer.GirDocumentationImporter : DocumentationImporter {
                        } else if (reader.name == "union") {
                                parse_union ();
                        } else {
-                               // error
-                               Vala.Report.error (get_current_src (), "unknown child element `%s' in `record'".printf (reader.name));
+                               error ("unknown child element `%s' in `record'", reader.name);
                                break;
                        }
                }
@@ -370,11 +395,11 @@ public class Valadoc.Importer.GirDocumentationImporter : DocumentationImporter {
                type_cname_stack.add (cname);
                next ();
 
-               if (current_token == Vala.MarkupTokenType.START_ELEMENT && reader.name == "doc") {
-                       process_documentation (cname, new GirDocumentationBuilder (parse_doc ()));
+               if (current_token == MarkupTokenType.START_ELEMENT && reader.name == "doc") {
+                       process_documentation (cname, create_gir_comment (parse_doc ()));
                }
 
-               while (current_token == Vala.MarkupTokenType.START_ELEMENT) {
+               while (current_token == MarkupTokenType.START_ELEMENT) {
                        if (reader.get_attribute ("introspectable") == "0") {
                                skip_element ();
                                continue;
@@ -403,8 +428,7 @@ public class Valadoc.Importer.GirDocumentationImporter : DocumentationImporter {
                        } else if (reader.name == "glib:signal") {
                                parse_signal ();
                        } else {
-                               // error
-                               Vala.Report.error (get_current_src (), "unknown child element `%s' in `class'".printf (reader.name));
+                               error ("unknown child element `%s' in `class'", reader.name);
                                break;
                        }
                }
@@ -419,11 +443,11 @@ public class Valadoc.Importer.GirDocumentationImporter : DocumentationImporter {
                type_cname_stack.add (cname);
                next ();
 
-               if (current_token == Vala.MarkupTokenType.START_ELEMENT && reader.name == "doc") {
-                       process_documentation (cname, new GirDocumentationBuilder (parse_doc ()));
+               if (current_token == MarkupTokenType.START_ELEMENT && reader.name == "doc") {
+                       process_documentation (cname, create_gir_comment (parse_doc ()));
                }
 
-               while (current_token == Vala.MarkupTokenType.START_ELEMENT) {
+               while (current_token == MarkupTokenType.START_ELEMENT) {
                        if (reader.get_attribute ("introspectable") == "0") {
                                skip_element ();
                                continue;
@@ -446,8 +470,7 @@ public class Valadoc.Importer.GirDocumentationImporter : DocumentationImporter {
                        } else if (reader.name == "glib:signal") {
                                parse_signal ();
                        } else {
-                               // error
-                               Vala.Report.error (get_current_src (), "unknown child element `%s' in `interface'".printf (reader.name));
+                               error ("unknown child element `%s' in `interface'", reader.name);
                                break;
                        }
                }
@@ -461,10 +484,10 @@ public class Valadoc.Importer.GirDocumentationImporter : DocumentationImporter {
                string cname = reader.get_attribute ("name");
                next ();
 
-               if (current_token == Vala.MarkupTokenType.START_ELEMENT && reader.name == "doc" && cname != null) {
+               if (current_token == MarkupTokenType.START_ELEMENT && reader.name == "doc" && cname != null) {
                        string real_cname = type_cname_stack.peek();
                        real_cname = (real_cname == null)? cname : real_cname+"."+cname;
-                       process_documentation (real_cname, new GirDocumentationBuilder (parse_doc ()));
+                       process_documentation (real_cname, create_gir_comment (parse_doc ()));
                }
 
                parse_type ();
@@ -477,8 +500,8 @@ public class Valadoc.Importer.GirDocumentationImporter : DocumentationImporter {
                string cname = reader.get_attribute ("name");
                next ();
 
-               if (current_token == Vala.MarkupTokenType.START_ELEMENT && reader.name == "doc" && cname != null) {
-                       process_documentation (type_cname_stack.peek()+":"+cname, new GirDocumentationBuilder (parse_doc ()));
+               if (current_token == MarkupTokenType.START_ELEMENT && reader.name == "doc" && cname != null) {
+                       process_documentation (type_cname_stack.peek()+":"+cname, create_gir_comment (parse_doc ()));
                }
 
                parse_type ();
@@ -495,20 +518,20 @@ public class Valadoc.Importer.GirDocumentationImporter : DocumentationImporter {
                string cname = reader.get_attribute ("c:identifier");
                next ();
 
-               GirDocumentationBuilder doc;
+               GirComment doc;
 
-               if (current_token == Vala.MarkupTokenType.START_ELEMENT && reader.name == "doc") {
-                       doc = new GirDocumentationBuilder (parse_doc ());
+               if (current_token == MarkupTokenType.START_ELEMENT && reader.name == "doc") {
+                       doc = create_gir_comment (parse_doc ());
                } else {
-                       doc = new GirDocumentationBuilder.empty (get_current_src ());
+                       doc = create_empty_gir_comment ();
                }
 
                parse_return_value (doc);
 
-               if (current_token == Vala.MarkupTokenType.START_ELEMENT && reader.name == "parameters") {
+               if (current_token == MarkupTokenType.START_ELEMENT && reader.name == "parameters") {
                        start_element ("parameters");
                        next ();
-                       while (current_token == Vala.MarkupTokenType.START_ELEMENT) {
+                       while (current_token == MarkupTokenType.START_ELEMENT) {
                                parse_parameter (doc);
                        }
                        end_element ("parameters");
@@ -526,23 +549,23 @@ public class Valadoc.Importer.GirDocumentationImporter : DocumentationImporter {
                string cname = reader.get_attribute ("c:identifier");
                next ();
 
-               GirDocumentationBuilder doc;
+               GirComment doc;
 
-               if (current_token == Vala.MarkupTokenType.START_ELEMENT && reader.name == "doc") {
-                       doc = new GirDocumentationBuilder (parse_doc ());
+               if (current_token == MarkupTokenType.START_ELEMENT && reader.name == "doc") {
+                       doc = create_gir_comment (parse_doc ());
                } else {
-                       doc = new GirDocumentationBuilder.empty (get_current_src ());
+                       doc = create_empty_gir_comment ();
                }
 
-               if (current_token == Vala.MarkupTokenType.START_ELEMENT && reader.name == "return-value") {
+               if (current_token == MarkupTokenType.START_ELEMENT && reader.name == "return-value") {
                        parse_return_value (doc);
                }
 
-               if (current_token == Vala.MarkupTokenType.START_ELEMENT && reader.name == "parameters") {
+               if (current_token == MarkupTokenType.START_ELEMENT && reader.name == "parameters") {
                        start_element ("parameters");
                        next ();
 
-                       while (current_token == Vala.MarkupTokenType.START_ELEMENT) {
+                       while (current_token == MarkupTokenType.START_ELEMENT) {
                                parse_parameter (doc);
                        }
 
@@ -565,22 +588,22 @@ public class Valadoc.Importer.GirDocumentationImporter : DocumentationImporter {
                string cname = reader.get_attribute ("name");
                next ();
 
-               GirDocumentationBuilder doc;
+               GirComment doc;
 
-               if (current_token == Vala.MarkupTokenType.START_ELEMENT && reader.name == "doc") {
-                       doc = new GirDocumentationBuilder (parse_doc ());
+               if (current_token == MarkupTokenType.START_ELEMENT && reader.name == "doc") {
+                       doc = create_gir_comment (parse_doc ());
                } else {
-                       doc = new GirDocumentationBuilder.empty (get_current_src ());
+                       doc = create_empty_gir_comment ();
                }
 
-               if (current_token == Vala.MarkupTokenType.START_ELEMENT && reader.name == "return-value") {
+               if (current_token == MarkupTokenType.START_ELEMENT && reader.name == "return-value") {
                        parse_return_value (doc);
                }
 
-               if (current_token == Vala.MarkupTokenType.START_ELEMENT && reader.name == "parameters") {
+               if (current_token == MarkupTokenType.START_ELEMENT && reader.name == "parameters") {
                        start_element ("parameters");
                        next ();
-                       while (current_token == Vala.MarkupTokenType.START_ELEMENT) {
+                       while (current_token == MarkupTokenType.START_ELEMENT) {
                                parse_parameter (doc);
                        }
                        end_element ("parameters");
@@ -595,11 +618,11 @@ public class Valadoc.Importer.GirDocumentationImporter : DocumentationImporter {
                string cname = reader.get_attribute ("c:type");
                next ();
 
-               if (current_token == Vala.MarkupTokenType.START_ELEMENT && reader.name == "doc") {
-                       process_documentation (cname, new GirDocumentationBuilder (parse_doc ()));
+               if (current_token == MarkupTokenType.START_ELEMENT && reader.name == "doc") {
+                       process_documentation (cname, create_gir_comment (parse_doc ()));
                }
 
-               while (current_token == Vala.MarkupTokenType.START_ELEMENT) {
+               while (current_token == MarkupTokenType.START_ELEMENT) {
                        if (reader.get_attribute ("introspectable") == "0") {
                                skip_element ();
                                continue;
@@ -614,15 +637,13 @@ public class Valadoc.Importer.GirDocumentationImporter : DocumentationImporter {
                        } else if (reader.name == "method") {
                                parse_method ("method");
                        } else {
-                               // error
-                               Vala.Report.error (get_current_src (), "unknown child element `%s' in `class'".printf (reader.name));
+                               error ("unknown child element `%s' in `class'", reader.name);
                                break;
                        }
                }
 
-               if (current_token != Vala.MarkupTokenType.END_ELEMENT) {
-                       // error
-                       Vala.Report.error (get_current_src (), "expected end element");
+               if (current_token != MarkupTokenType.END_ELEMENT) {
+                       error ("expected end element");
                }
                next ();
        }
@@ -633,11 +654,11 @@ public class Valadoc.Importer.GirDocumentationImporter : DocumentationImporter {
                type_cname_stack.add (cname);
                next ();
 
-               if (current_token == Vala.MarkupTokenType.START_ELEMENT && reader.name == "doc") {
-                       process_documentation (cname, new GirDocumentationBuilder (parse_doc ()));
+               if (current_token == MarkupTokenType.START_ELEMENT && reader.name == "doc") {
+                       process_documentation (cname, create_gir_comment (parse_doc ()));
                }
 
-               while (current_token == Vala.MarkupTokenType.START_ELEMENT) {
+               while (current_token == MarkupTokenType.START_ELEMENT) {
                        if (reader.get_attribute ("introspectable") == "0") {
                                skip_element ();
                                continue;
@@ -663,8 +684,8 @@ public class Valadoc.Importer.GirDocumentationImporter : DocumentationImporter {
                string name = reader.get_attribute ("name");
                next ();
 
-               if (current_token == Vala.MarkupTokenType.START_ELEMENT && reader.name == "doc") {
-                       process_documentation (name, new GirDocumentationBuilder (parse_doc ()));
+               if (current_token == MarkupTokenType.START_ELEMENT && reader.name == "doc") {
+                       process_documentation (name, create_gir_comment (parse_doc ()));
                }
 
                parse_type ();
@@ -672,7 +693,7 @@ public class Valadoc.Importer.GirDocumentationImporter : DocumentationImporter {
                end_element ("constant");
        }
 
-       void process_documentation (string? cname, GirDocumentationBuilder? doc) {
+       void process_documentation (string? cname, GirComment? doc) {
                if (cname == null || doc == null) {
                        return;
                }
diff --git a/src/libvaladoc/markupreader.vala b/src/libvaladoc/markupreader.vala
new file mode 100644 (file)
index 0000000..d6ea9d9
--- /dev/null
@@ -0,0 +1,306 @@
+/* markupreader.vala
+ *
+ * Copyright (C) 2008-2009  Jürg Billeter
+ * Copyright (C) 2011       Florian Brosch
+ *
+ * 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:
+ *     Jürg Billeter <j@bitron.ch>
+ */
+
+using GLib;
+using Gee;
+
+
+/**
+ * Simple reader for a subset of XML.
+ */
+public class Valadoc.MarkupReader : Object {
+       public string filename {
+               private set;
+               get;
+       }
+
+       public string name {
+               private set;
+               get;
+       }
+
+       public string content {
+               private set;
+               get;
+       }
+
+       private MappedFile mapped_file;
+
+       private char* begin;
+       private char* current;
+       private char* end;
+
+       private int line;
+       private int column;
+
+       private Map<string, string> attributes = new HashMap<string, string> (str_hash, str_equal);
+       private bool empty_element;
+
+       private ErrorReporter reporter;
+
+       public MarkupReader (string filename, ErrorReporter reporter) {
+               this.filename = filename;
+               this.reporter = reporter;
+
+               try {
+                       mapped_file = new MappedFile (filename, false);
+                       begin = mapped_file.get_contents ();
+                       end = begin + mapped_file.get_length ();
+
+                       current = begin;
+
+                       line = 1;
+                       column = 1;
+               } catch (FileError e) {
+                       reporter.simple_error ("Unable to map file `%s': %s", filename, e.message);
+               }
+       }
+
+       public string? get_attribute (string attr) {
+               return attributes[attr];
+       }
+
+       /*
+        * Returns a copy of the current attributes.
+        *
+        * @return map of current attributes
+        */
+       public Map<string,string> get_attributes () {
+               var result = new HashMap<string,string> (str_hash, str_equal);
+               foreach (var key in attributes.keys) {
+                       result.set (key, attributes.get (key));
+               }
+               return result;
+       }
+
+       private string read_name () {
+               char* begin = current;
+               while (current < end) {
+                       if (current[0] == ' ' || current[0] == '\t' || current[0] == '>'
+                           || current[0] == '/' || current[0] == '=' || current[0] == '\n') {
+                               break;
+                       }
+                       unichar u = ((string) current).get_char_validated ((long) (end - current));
+                       if (u != (unichar) (-1)) {
+                               current += u.to_utf8 (null);
+                       } else {
+                               reporter.simple_error ("invalid UTF-8 character");
+                       }
+               }
+               if (current == begin) {
+                       // syntax error: invalid name
+               }
+               return ((string) begin).substring (0, (int) (current - begin));
+       }
+
+       public MarkupTokenType read_token (out MarkupSourceLocation token_begin, out MarkupSourceLocation token_end) {
+               attributes.clear ();
+
+               if (empty_element) {
+                       empty_element = false;
+                       return MarkupTokenType.END_ELEMENT;
+               }
+
+               space ();
+
+               MarkupTokenType type = MarkupTokenType.NONE;
+               char* begin = current;
+               token_begin.pos = begin;
+               token_begin.line = line;
+               token_begin.column = column;
+
+               if (current >= end) {
+                       type = MarkupTokenType.EOF;
+               } else if (current[0] == '<') {
+                       current++;
+                       if (current >= end) {
+                               // error
+                       } else if (current[0] == '?') {
+                               // processing instruction
+                       } else if (current[0] == '!') {
+                               // comment or doctype
+                               current++;
+                               if (current < end - 1 && current[0] == '-' && current[1] == '-') {
+                                       // comment
+                                       current += 2;
+                                       while (current < end - 2) {
+                                               if (current[0] == '-' && current[1] == '-' && current[2] == '>') {
+                                                       // end of comment
+                                                       current += 3;
+                                                       break;
+                                               } else if (current[0] == '\n') {
+                                                       line++;
+                                                       column = 0;
+                                               }
+                                               current++;
+                                       }
+
+                                       // ignore comment, read next token
+                                       return read_token (out token_begin, out token_end);
+                               }
+                       } else if (current[0] == '/') {
+                               type = MarkupTokenType.END_ELEMENT;
+                               current++;
+                               name = read_name ();
+                               if (current >= end || current[0] != '>') {
+                                       // error
+                               }
+                               current++;
+                       } else {
+                               type = MarkupTokenType.START_ELEMENT;
+                               name = read_name ();
+                               space ();
+                               while (current < end && current[0] != '>' && current[0] != '/') {
+                                       string attr_name = read_name ();
+                                       if (current >= end || current[0] != '=') {
+                                               // error
+                                       }
+                                       current++;
+                                       // FIXME allow single quotes
+                                       if (current >= end || current[0] != '"') {
+                                               // error
+                                       }
+                                       current++;
+
+                                       string attr_value = text ('"', false);
+
+                                       if (current >= end || current[0] != '"') {
+                                               // error
+                                       }
+                                       current++;
+                                       attributes.set (attr_name, attr_value);
+                                       space ();
+                               }
+                               if (current[0] == '/') {
+                                       empty_element = true;
+                                       current++;
+                                       space ();
+                               } else {
+                                       empty_element = false;
+                               }
+                               if (current >= end || current[0] != '>') {
+                                       // error
+                               }
+                               current++;
+                       }
+               } else {
+                       space ();
+
+                       if (current[0] != '<') {
+                               content = text ('<', true);
+                       } else {
+                               // no text
+                               // read next token
+                               return read_token (out token_begin, out token_end);
+                       }
+
+                       type = MarkupTokenType.TEXT;
+               }
+
+               token_end.pos = current;
+               token_end.line = line;
+               token_end.column = column - 1;
+
+               return type;
+       }
+
+       private string text (char end_char, bool rm_trailing_whitespace) {
+               StringBuilder content = new StringBuilder ();
+               char* text_begin = current;
+               char* last_linebreak = current;
+
+               while (current < end && current[0] != end_char) {
+                       unichar u = ((string) current).get_char_validated ((long) (end - current));
+                       if (u == (unichar) (-1)) {
+                               reporter.simple_error ("invalid UTF-8 character");
+                       } else if (u == '&') {
+                               char* next_pos = current + u.to_utf8 (null);
+                               if (((string) next_pos).has_prefix ("amp;")) {
+                                       content.append (((string) text_begin).substring (0, (int) (current - text_begin)));
+                                       content.append_c ('&');
+                                       current += 5;
+                                       text_begin = current;
+                               } else if (((string) next_pos).has_prefix ("quot;")) {
+                                       content.append (((string) text_begin).substring (0, (int) (current - text_begin)));
+                                       content.append_c ('"');
+                                       current += 6;
+                                       text_begin = current;
+                               } else if (((string) next_pos).has_prefix ("apos;")) {
+                                       content.append (((string) text_begin).substring (0, (int) (current - text_begin)));
+                                       content.append_c ('\'');
+                                       current += 6;
+                                       text_begin = current;
+                               } else if (((string) next_pos).has_prefix ("lt;")) {
+                                       content.append (((string) text_begin).substring (0, (int) (current - text_begin)));
+                                       content.append_c ('<');
+                                       current += 4;
+                                       text_begin = current;
+                               } else if (((string) next_pos).has_prefix ("gt;")) {
+                                       content.append (((string) text_begin).substring (0, (int) (current - text_begin)));
+                                       content.append_c ('>');
+                                       current += 4;
+                                       text_begin = current;
+                               } else {
+                                       current += u.to_utf8 (null);
+                               }
+                       } else {
+                               if (u == '\n') {
+                                       line++;
+                                       column = 0;
+                                       last_linebreak = current;
+                               }
+
+                               current += u.to_utf8 (null);
+                               column++;
+                       }
+               }
+
+               if (text_begin != current) {
+                       content.append (((string) text_begin).substring (0, (int) (current - text_begin)));
+               }
+
+               column += (int) (current - last_linebreak);
+
+               // Removes trailing whitespace
+               if (rm_trailing_whitespace) {
+                       char* str_pos = ((char*)content.str) + content.len;
+                       for (str_pos--; str_pos > ((char*)content.str) && str_pos[0].isspace(); str_pos--);
+                       content.erase ((ssize_t) (str_pos-((char*) content.str) + 1), -1);
+               }
+
+               return content.str;
+       }
+
+       private void space () {
+               while (current < end && current[0].isspace ()) {
+                       if (current[0] == '\n') {
+                               line++;
+                               column = 0;
+                       }
+                       current++;
+                       column++;
+               }
+       }
+}
+
+
diff --git a/src/libvaladoc/markupsourcelocation.vala b/src/libvaladoc/markupsourcelocation.vala
new file mode 100644 (file)
index 0000000..af7dff1
--- /dev/null
@@ -0,0 +1,39 @@
+/* valasourcelocation.vala
+ *
+ * Copyright (C) 2008  Jürg Billeter
+ *
+ * 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:
+ *     Jürg Billeter <j@bitron.ch>
+ */
+
+using GLib;
+
+/**
+ * Represents a position in a source file.
+ */
+public struct Valadoc.MarkupSourceLocation {
+       public char* pos;
+       public int line;
+       public int column;
+
+       public MarkupSourceLocation (char* _pos, int _line, int _column) {
+               pos = _pos;
+               line = _line;
+               column = _column;
+       }
+}
+
diff --git a/src/libvaladoc/markuptokentype.vala b/src/libvaladoc/markuptokentype.vala
new file mode 100644 (file)
index 0000000..5bd86d9
--- /dev/null
@@ -0,0 +1,50 @@
+/* markuptokentype.vala
+ *
+ * Copyright (C) 2008-2009  Jürg Billeter
+ *
+ * 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:
+ *     Jürg Billeter <j@bitron.ch>
+ */
+
+
+public enum Valadoc.MarkupTokenType {
+       NONE,
+       START_ELEMENT,
+       END_ELEMENT,
+       TEXT,
+       EOF;
+
+       public string to_string () {
+               switch (this) {
+               case START_ELEMENT:
+                       return "start element";
+
+               case END_ELEMENT:
+                       return "end element";
+
+               case TEXT:
+                       return "text";
+
+               case EOF:
+                       return "end of file";
+
+               default:
+                       return "unknown token type";
+               }
+       }
+}
+
index 447458f32450b4ba200a330ba21e37cb8dfc0f4a..2e4a8477c6df743b1a164e6f2d0d9dd4fc55c4c9 100755 (executable)
@@ -1,4 +1,3 @@
 libgvc
 gee-1.0
 gmodule-2.0
-@VALA_PACKAGE@
index 70bfc23f7fd0903955be6d2e32865d41a78e2aad..b16036f359dc8ae9b25dbd3bd61ff6397b7f3594 100755 (executable)
@@ -9,6 +9,6 @@ vapidir=@datadir@/vala/vapi
 Name: Valadoc
 Description: The Vala documentation compiler library
 Version: @VERSION@
-Requires: @VALA_PACKAGE@ libgvc gee-1.0 gmodule-2.0
+Requires: libgvc gee-1.0 gmodule-2.0
 Libs: -L${libdir} -lvaladoc
 Cflags: -I${includedir}/valadoc-1.0
index 02684b3e27136724c02af7ec8523dead755df222..67cffe0421412924f487375c4d9860e853da6524 100755 (executable)
@@ -239,7 +239,7 @@ public class ValaDoc : Object {
                }
 
                DocumentationImporter[] importers = {
-                       new GirDocumentationImporter (doctree, docparser, modules, settings),
+                       new GirDocumentationImporter (doctree, docparser, modules, settings, reporter),
                        new ValadocDocumentationImporter (doctree, docparser, modules, settings, reporter)
                };