[valadoc] libvaladoc: Move all libvala-related calls to api/driver.vala and api/symbolresolver.vala
- From: Florian Brosch <flobrosch src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [valadoc] libvaladoc: Move all libvala-related calls to api/driver.vala and api/symbolresolver.vala
- Date: Fri, 29 Jul 2011 00:59:08 +0000 (UTC)
commit 6eab9bf749c4613a41289162b67caaa4641848a6
Author: Florian Brosch <flo brosch gmail com>
Date: Wed Jul 20 00:01:00 2011 +0200
libvaladoc: Move all libvala-related calls to api/driver.vala and api/symbolresolver.vala
src/doclets/gtkdoc/commentconverter.vala | 4 +-
src/doclets/gtkdoc/generator.vala | 10 +-
src/libvaladoc/Makefile.am | 12 +-
src/libvaladoc/api/array.vala | 32 +-
src/libvaladoc/api/class.vala | 113 +--
src/libvaladoc/api/constant.vala | 31 +-
src/libvaladoc/api/delegate.vala | 37 +-
src/libvaladoc/api/driver.vala | 977 ++++++++++++++++++++
src/libvaladoc/api/enum.vala | 10 +-
src/libvaladoc/api/enumvalue.vala | 51 +-
src/libvaladoc/api/errorcode.vala | 53 +-
src/libvaladoc/api/errordomain.vala | 20 +-
src/libvaladoc/api/field.vala | 48 +-
src/libvaladoc/api/formalparameter.vala | 705 +--------------
src/libvaladoc/api/formalparametertype.vala | 44 +
src/libvaladoc/api/initializerbuilder.vala | 678 ++++++++++++++
src/libvaladoc/api/interface.vala | 74 +-
src/libvaladoc/api/item.vala | 14 +-
src/libvaladoc/api/member.vala | 9 +-
src/libvaladoc/api/method.vala | 112 +--
src/libvaladoc/api/methodbindingtype.vala | 55 ++
src/libvaladoc/api/namespace.vala | 17 +-
src/libvaladoc/api/node.vala | 95 +--
src/libvaladoc/api/nodebuilder.vala | 280 ------
src/libvaladoc/api/ownership.vala | 47 +
src/libvaladoc/api/package.vala | 67 +--
src/libvaladoc/api/pointer.vala | 33 +-
src/libvaladoc/api/property.vala | 79 +-
src/libvaladoc/api/propertyaccessor.vala | 29 +-
src/libvaladoc/api/propertyaccessortype.vala | 42 +
src/libvaladoc/api/propertybindingtype.vala | 48 +
src/libvaladoc/api/signal.vala | 46 +-
src/libvaladoc/api/sourcecomment.vala | 84 ++
src/libvaladoc/api/sourcefile.vala | 47 +
src/libvaladoc/api/struct.vala | 48 +-
src/libvaladoc/api/symbol.vala | 87 +--
src/libvaladoc/api/symbolaccessibility.vala | 51 +
src/libvaladoc/api/symbolresolver.vala | 310 +++++++
src/libvaladoc/api/tree.vala | 258 +-----
src/libvaladoc/api/typeparameter.vala | 6 +-
src/libvaladoc/api/typereference.vala | 146 +---
src/libvaladoc/api/typesymbol.vala | 22 +-
.../documentation/documentationparser.vala | 7 +-
src/libvaladoc/errorreporter.vala | 18 +-
src/libvaladoc/html/basicdoclet.vala | 4 +-
.../importer/valadocdocumentationimporter.vala | 7 +-
src/libvaladoc/parser/tokentype.vala | 2 +-
src/libvaladoc/settings.vala | 10 +
src/valadoc/valadoc.vala | 71 +-
49 files changed, 2974 insertions(+), 2076 deletions(-)
---
diff --git a/doc/Makefile.am b/doc/Makefile.am
old mode 100644
new mode 100755
diff --git a/src/Makefile.am b/src/Makefile.am
old mode 100644
new mode 100755
diff --git a/src/doclets/Makefile.am b/src/doclets/Makefile.am
old mode 100644
new mode 100755
diff --git a/src/doclets/devhelp/Makefile.am b/src/doclets/devhelp/Makefile.am
old mode 100644
new mode 100755
diff --git a/src/doclets/gtkdoc/Makefile.am b/src/doclets/gtkdoc/Makefile.am
old mode 100644
new mode 100755
diff --git a/src/doclets/gtkdoc/commentconverter.vala b/src/doclets/gtkdoc/commentconverter.vala
index e520983..a0c3372 100755
--- a/src/doclets/gtkdoc/commentconverter.vala
+++ b/src/doclets/gtkdoc/commentconverter.vala
@@ -44,7 +44,7 @@ public class Gtkdoc.CommentConverter : ContentVisitor {
this.reporter = reporter;
}
- public void convert (Comment comment, bool is_dbus = false) {
+ public void convert (Content.Comment comment, bool is_dbus = false) {
this.is_dbus = is_dbus;
comment.accept (this);
@@ -54,7 +54,7 @@ public class Gtkdoc.CommentConverter : ContentVisitor {
}
}
- public override void visit_comment (Comment c) {
+ public override void visit_comment (Content.Comment c) {
c.accept_children (this);
}
diff --git a/src/doclets/gtkdoc/generator.vala b/src/doclets/gtkdoc/generator.vala
index 7b4974e..ed90599 100755
--- a/src/doclets/gtkdoc/generator.vala
+++ b/src/doclets/gtkdoc/generator.vala
@@ -165,7 +165,7 @@ public class Gtkdoc.Generator : Api.Visitor {
return headers;
}
- private void set_section_comment (string filename, string section_name, Comment? comment) {
+ private void set_section_comment (string filename, string section_name, Content.Comment? comment) {
var file_data = get_file_data (filename);
if (file_data.title == null) {
file_data.title = section_name;
@@ -183,7 +183,7 @@ public class Gtkdoc.Generator : Api.Visitor {
file_data.section_comment = gcomment;
}
- private GComment create_gcomment (string symbol, Comment? comment, string[]? returns_annotations = null, bool is_dbus = false) {
+ private GComment create_gcomment (string symbol, Content.Comment? comment, string[]? returns_annotations = null, bool is_dbus = false) {
var converter = new Gtkdoc.CommentConverter (reporter, current_method_or_delegate);
if (comment != null) {
@@ -204,14 +204,14 @@ public class Gtkdoc.Generator : Api.Visitor {
return gcomment;
}
- private GComment add_comment (string filename, string symbol, Comment? comment = null) {
+ private GComment add_comment (string filename, string symbol, Content.Comment? comment = null) {
var file_data = get_file_data (filename);
var gcomment = create_gcomment (symbol, comment);
file_data.comments.add (gcomment);
return gcomment;
}
- private GComment add_symbol (string filename, string cname, Comment? comment = null, string? symbol = null, string[]? returns_annotations = null) {
+ private GComment add_symbol (string filename, string cname, Content.Comment? comment = null, string? symbol = null, string[]? returns_annotations = null) {
var file_data = get_file_data (filename);
file_data.section_lines.add (cname);
@@ -244,7 +244,7 @@ public class Gtkdoc.Generator : Api.Visitor {
return null;
}
- private Header? add_header (string name, Comment? comment, string[]? annotations = null, double pos = double.MAX) {
+ private Header? add_header (string name, Content.Comment? comment, string[]? annotations = null, double pos = double.MAX) {
if (comment == null && annotations == null) {
return null;
}
diff --git a/src/doclets/htm/Makefile.am b/src/doclets/htm/Makefile.am
old mode 100644
new mode 100755
diff --git a/src/libvaladoc/Makefile.am b/src/libvaladoc/Makefile.am
old mode 100644
new mode 100755
index bc69374..da6bf19
--- a/src/libvaladoc/Makefile.am
+++ b/src/libvaladoc/Makefile.am
@@ -42,6 +42,9 @@ libvaladoc_la_VALASOURCES = \
importer/girdocumentationbuilder.vala \
importer/valadocdocumentationimporter.vala \
importer/valadocdocumentationimporterscanner.vala \
+ api/symbolaccessibility.vala \
+ api/symbolresolver.vala \
+ api/sourcecomment.vala \
api/array.vala \
api/class.vala \
api/constant.vala \
@@ -52,19 +55,25 @@ libvaladoc_la_VALASOURCES = \
api/errordomain.vala \
api/field.vala \
api/formalparameter.vala \
+ api/formalparametertype.vala \
api/interface.vala \
+ api/initializerbuilder.vala \
api/item.vala \
api/member.vala \
api/method.vala \
+ api/methodbindingtype.vala \
api/namespace.vala \
api/node.vala \
- api/nodebuilder.vala \
+ api/ownership.vala \
api/package.vala \
api/pointer.vala \
api/property.vala \
api/propertyaccessor.vala \
+ api/propertyaccessortype.vala \
+ api/propertybindingtype.vala \
api/signal.vala \
api/signaturebuilder.vala \
+ api/sourcefile.vala \
api/struct.vala \
api/symbol.vala \
api/tree.vala \
@@ -73,6 +82,7 @@ libvaladoc_la_VALASOURCES = \
api/typesymbol.vala \
api/browsable.vala \
api/visitor.vala \
+ api/driver.vala \
content/block.vala \
content/blockcontent.vala \
content/comment.vala \
diff --git a/src/libvaladoc/api/array.vala b/src/libvaladoc/api/array.vala
index eda6965..ef2a1d4 100755
--- a/src/libvaladoc/api/array.vala
+++ b/src/libvaladoc/api/array.vala
@@ -1,6 +1,6 @@
/* array.vala
*
- * Copyright (C) 2008 Florian Brosch
+ * 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
@@ -28,41 +28,19 @@ using Valadoc.Content;
* Represents an array declaration.
*/
public class Valadoc.Api.Array : Item {
- private Vala.ArrayType vtype;
/**
* The element type.
*/
public Item data_type {
- private set;
+ set;
get;
}
- public Array (Vala.ArrayType vtyperef, Item parent) {
- this.vtype = vtyperef;
- this.parent = parent;
-
- Vala.DataType vntype = vtyperef.element_type;
- if (vntype is Vala.ArrayType) {
- this.data_type = new Array ((Vala.ArrayType) vntype, this);
- } else {
- this.data_type = new TypeReference (vntype, this);
- }
- }
+ public Array (Item parent, void* data) {
+ base (data);
- /**
- * { inheritDoc}
- */
- internal override void resolve_type_references (Tree root) {
- if (this.data_type == null) {
- /*TODO:possible?*/;
- } else if (this.data_type is Array) {
- ((Array)this.data_type).resolve_type_references (root);
- } else if (this.data_type is Pointer) {
- ((Pointer)this.data_type).resolve_type_references (root);
- } else {
- ((TypeReference)this.data_type).resolve_type_references (root);
- }
+ this.parent = parent;
}
/**
diff --git a/src/libvaladoc/api/class.vala b/src/libvaladoc/api/class.vala
index 3b85145..00441d6 100755
--- a/src/libvaladoc/api/class.vala
+++ b/src/libvaladoc/api/class.vala
@@ -1,6 +1,6 @@
/* class.vala
*
- * Copyright (C) 2008 Florian Brosch
+ * Copyright (C) 2008-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
@@ -29,13 +29,38 @@ using Valadoc.Content;
*/
public class Valadoc.Api.Class : TypeSymbol {
private ArrayList<TypeReference> interfaces;
- private Vala.Class vclass;
- public Class (Vala.Class symbol, Node parent) {
- base (symbol, parent);
+ private string? dbus_name;
+ private string? take_value_function_cname;
+ private string? get_value_function_cname;
+ private string? set_value_function_cname;
+ private string? unref_function_name;
+ private string? param_spec_function_name;
+ private string? ref_function_name;
+ private string? type_id;
+ private string? cname;
+
+
+ public Class (Node parent, SourceFile file, string name, SymbolAccessibility accessibility, SourceComment? comment, string? cname, string? dbus_name, string? type_id, string? param_spec_function_name, string? ref_function_name, string? unref_function_name, string? take_value_function_cname, string? get_value_function_cname, string? set_value_function_cname, bool is_fundamental, bool is_abstract, bool is_basic_type, void* data) {
+ base (parent, file, name, accessibility, comment, is_basic_type, data);
+
this.interfaces = new ArrayList<TypeReference> ();
- this.vclass = symbol;
+ this.dbus_name = dbus_name;
+ this.type_id = type_id;
+ this.cname = cname;
+
+ this.param_spec_function_name = param_spec_function_name;
+
+ this.unref_function_name = unref_function_name;
+ this.ref_function_name = ref_function_name;
+
+ this.take_value_function_cname = take_value_function_cname;
+ this.get_value_function_cname = get_value_function_cname;
+ this.set_value_function_cname = set_value_function_cname;
+
+ this.is_fundamental = is_fundamental;
+ this.is_abstract = is_abstract;
if (glib_error == null) {
if (this.get_full_name () == "GLib.Error") {
@@ -48,7 +73,7 @@ public class Valadoc.Api.Class : TypeSymbol {
* Specifies the base class.
*/
public TypeReference? base_type {
- private set;
+ set;
get;
}
@@ -56,14 +81,14 @@ public class Valadoc.Api.Class : TypeSymbol {
* Returns the name of this class as it is used in C.
*/
public string? get_cname () {
- return this.vclass.get_cname ();
+ return cname;
}
/**
* Returns the C symbol representing the runtime type id for this data type.
*/
public string? get_type_id () {
- return this.vclass.get_type_id ();
+ return type_id;
}
/**
@@ -74,7 +99,7 @@ public class Valadoc.Api.Class : TypeSymbol {
* support reference counting
*/
public string? get_ref_function_cname () {
- return this.vclass.get_ref_function ();
+ return ref_function_name;
}
/**
@@ -85,42 +110,42 @@ public class Valadoc.Api.Class : TypeSymbol {
* support reference counting
*/
public string? get_unref_function_cname () {
- return this.vclass.get_unref_function ();
+ return unref_function_name;
}
/**
* Returns the cname of the GValue parameter spec function.
*/
public string? get_param_spec_function_cname () {
- return this.vclass.get_param_spec_function ();
+ return param_spec_function_name;
}
/**
* Returns the cname of the GValue setter function.
*/
public string? get_set_value_function_cname () {
- return this.vclass.get_set_value_function ();
+ return set_value_function_cname;
}
/**
* Returns the cname of the GValue getter function.
*/
public string? get_get_value_function_cname () {
- return this.vclass.get_get_value_function ();
+ return get_value_function_cname;
}
/**
* Returns the cname of the GValue taker function.
*/
public string? get_take_value_function_cname () {
- return this.vclass.get_take_value_function ();
+ return take_value_function_cname;
}
/**
* Returns the dbus-name.
*/
public string? get_dbus_name () {
- return Vala.GDBusModule.get_dbus_name ((Vala.TypeSymbol) symbol);
+ return dbus_name;
}
/**
@@ -152,22 +177,24 @@ public class Valadoc.Api.Class : TypeSymbol {
return _full_implemented_interfaces;
}
+ public void add_interface (TypeReference iface) {
+ interfaces.add (iface);
+ }
+
/**
* Specifies whether this class is abstract.
*/
public bool is_abstract {
- get {
- return this.vclass.is_abstract;
- }
+ private set;
+ get;
}
/**
* Specifies whether this class is fundamental.
*/
public bool is_fundamental {
- get {
- return this.vclass.is_fundamental ();
- }
+ private set;
+ get;
}
/**
@@ -182,23 +209,6 @@ public class Valadoc.Api.Class : TypeSymbol {
visitor.visit_class (this);
}
- private void set_parent_type_references (Tree root, Vala.Collection<Vala.DataType> lst) {
- if (this.interfaces.size != 0) {
- return;
- }
-
- foreach (Vala.DataType vtyperef in lst) {
- var inherited = new TypeReference (vtyperef, this);
- inherited.resolve_type_references (root);
-
- if (inherited.data_type is Class) {
- this.base_type = inherited;
- } else {
- this.interfaces.add (inherited);
- }
- }
- }
-
private Set<Interface> _known_derived_interfaces = new TreeSet<Interface> ();
private Set<Class> _known_child_classes = new TreeSet<Class> ();
@@ -231,33 +241,6 @@ public class Valadoc.Api.Class : TypeSymbol {
/**
* { inheritDoc}
*/
- internal override void resolve_children (Tree root) {
- // base class:
- if (this.base_type != null) {
- ((Class) this.base_type.data_type).register_child_class (this);
- }
-
- // implemented interfaces:
- foreach (var iface in get_full_implemented_interface_list ()) {
- ((Interface) iface.data_type).register_implementation (this);
- }
-
- base.resolve_children (root);
- }
-
- /**
- * { inheritDoc}
- */
- internal override void resolve_type_references (Tree root) {
- var lst = this.vclass.get_base_types ();
- this.set_parent_type_references (root, lst);
-
- base.resolve_type_references (root);
- }
-
- /**
- * { inheritDoc}
- */
protected override Inline build_signature () {
var signature = new SignatureBuilder ();
diff --git a/src/libvaladoc/api/constant.vala b/src/libvaladoc/api/constant.vala
index 9dae9ef..f2d2260 100755
--- a/src/libvaladoc/api/constant.vala
+++ b/src/libvaladoc/api/constant.vala
@@ -1,6 +1,6 @@
/* constant.vala
*
- * Copyright (C) 2008 Florian Brosch
+ * Copyright (C) 2008-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
@@ -27,28 +27,27 @@ using Valadoc.Content;
* Represents a type member with a constant value.
*/
public class Valadoc.Api.Constant : Member {
+ private string? cname;
+
/**
* The data type of this constant.
*/
- public TypeReference type_reference { private set; get; }
+ public TypeReference constant_type {
+ set;
+ get;
+ }
+
+ public Constant (Node parent, SourceFile file, string name, SymbolAccessibility accessibility, SourceComment? comment, string? cname, void* data) {
+ base (parent, file, name, accessibility, comment, data);
- public Constant (Vala.Constant symbol, Node parent) {
- base (symbol, parent);
- type_reference = new TypeReference (symbol.type_reference, this);
+ this.cname = cname;
}
/**
* Returns the name of this constant as it is used in C.
*/
public string get_cname () {
- return ((Vala.Constant) symbol).get_cname ();
- }
-
- /**
- * { inheritDoc}
- */
- internal override void resolve_type_references (Tree root) {
- type_reference.resolve_type_references (root);
+ return cname;
}
/**
@@ -58,7 +57,7 @@ public class Valadoc.Api.Constant : Member {
return new SignatureBuilder ()
.append_keyword (get_accessibility_modifier ())
.append_keyword ("const")
- .append_content (type_reference.signature)
+ .append_content (constant_type.signature)
.append_symbol (this)
.get ();
}
@@ -66,7 +65,9 @@ public class Valadoc.Api.Constant : Member {
/**
* { inheritDoc}
*/
- public override NodeType node_type { get { return NodeType.CONSTANT; } }
+ public override NodeType node_type {
+ get { return NodeType.CONSTANT; }
+ }
/**
* { inheritDoc}
diff --git a/src/libvaladoc/api/delegate.vala b/src/libvaladoc/api/delegate.vala
index cfd4fe2..87753fc 100755
--- a/src/libvaladoc/api/delegate.vala
+++ b/src/libvaladoc/api/delegate.vala
@@ -1,6 +1,6 @@
/* delegate.vala
*
- * Copyright (C) 2008 Florian Brosch
+ * Copyright (C) 2008-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
@@ -28,16 +28,20 @@ using Valadoc.Content;
* Represents a Delegate.
*/
public class Valadoc.Api.Delegate : TypeSymbol {
- public Delegate (Vala.Delegate symbol, Node parent) {
- base (symbol, parent);
- return_type = new TypeReference (symbol.return_type, this);
+ private string? cname;
+
+ public Delegate (Node parent, SourceFile file, string name, SymbolAccessibility accessibility, SourceComment? comment, string? cname, bool is_static, void* data) {
+ base (parent, file, name, accessibility, comment, false, data);
+
+ this.is_static = is_static;
+ this.cname = cname;
}
/**
* Returns the name of this delegate as it is used in C.
*/
public string? get_cname () {
- return ((Vala.Delegate) symbol).get_cname ();
+ return cname;
}
/**
@@ -45,12 +49,17 @@ public class Valadoc.Api.Delegate : TypeSymbol {
*
* @return The return type of this callback or null for void
*/
- public TypeReference? return_type { private set; get; }
+ public TypeReference? return_type {
+ set;
+ get;
+ }
/**
* { inheritDoc}
*/
- public override NodeType node_type { get { return NodeType.DELEGATE; } }
+ public override NodeType node_type {
+ get { return NodeType.DELEGATE; }
+ }
/**
* { inheritDoc}
@@ -63,18 +72,8 @@ public class Valadoc.Api.Delegate : TypeSymbol {
* Specifies whether this delegate is static
*/
public bool is_static {
- get {
- return !((Vala.Delegate) symbol).has_target;
- }
- }
-
- /**
- * { inheritDoc}
- */
- internal override void resolve_type_references (Tree root) {
- return_type.resolve_type_references (root);
-
- base.resolve_type_references (root);
+ private set;
+ get;
}
/**
diff --git a/src/libvaladoc/api/driver.vala b/src/libvaladoc/api/driver.vala
new file mode 100755
index 0000000..c1376b1
--- /dev/null
+++ b/src/libvaladoc/api/driver.vala
@@ -0,0 +1,977 @@
+/* driver.vala
+ *
+ * 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:
+ * Florian Brosch <flo brosch gmail com>
+ */
+
+using Valadoc.Api;
+using Gee;
+
+
+/**
+ * Creates an simpler, minimized, more abstract AST for valacs AST.
+ */
+public class Valadoc.Api.Driver : Vala.CodeVisitor {
+ private ArrayList<PackageMetaData> packages = new ArrayList<PackageMetaData> ();
+ private PackageMetaData source_package;
+
+ private HashMap<Vala.SourceFile, SourceFile> files = new HashMap<Vala.SourceFile, SourceFile> ();
+ private HashMap<Vala.Symbol, Symbol> symbol_map = new HashMap<Vala.Symbol, Symbol> ();
+
+ private ErrorReporter reporter;
+ private Settings settings;
+
+ private Api.Node current_node;
+ private Api.Tree tree;
+
+ private Valadoc.Api.Class glib_error = null;
+
+
+ private class PackageMetaData {
+ public Package package;
+ public HashMap<Vala.Namespace, Namespace> namespaces = new HashMap<Vala.Namespace, Namespace> ();
+ public ArrayList<Vala.SourceFile> files = new ArrayList<Vala.SourceFile> ();
+
+ public PackageMetaData (Package package) {
+ this.package = package;
+ }
+
+ public Namespace get_namespace (Vala.Namespace vns, SourceFile? file) {
+ Namespace? ns = namespaces.get (vns);
+ if (ns != null) {
+ return ns;
+ }
+
+ // find documentation comment if existing:
+ SourceComment? comment = null;
+ if (vns.source_reference != null) {
+ foreach (Vala.Comment c in vns.get_comments()) {
+ if (c.source_reference.file == vns.source_reference.file) {
+ Vala.SourceReference pos = c.source_reference;
+ comment = new SourceComment (c.content, file, pos.first_line, pos.first_column, pos.last_line, pos.last_column);
+ break;
+ }
+ }
+ }
+
+ // find parent if existing
+ var parent_vns = vns.parent_symbol;
+
+ if (parent_vns == null) {
+ ns = new Namespace (package, file, vns.name, comment, vns);
+ package.add_child (ns);
+ } else {
+ Namespace parent_ns = get_namespace ((Vala.Namespace) parent_vns, file);
+ ns = new Namespace (parent_ns, file, vns.name, comment, vns);
+ parent_ns.add_child (ns);
+ }
+
+ namespaces.set (vns, ns);
+ return ns;
+ }
+
+ public void register_source_file (Vala.SourceFile file) {
+ files.add (file);
+ }
+
+ public bool is_package_for_file (Vala.SourceFile source_file) {
+ if (source_file.file_type == Vala.SourceFileType.SOURCE && !package.is_package) {
+ return true;
+ }
+
+ return files.contains (source_file);
+ }
+ }
+
+
+ //
+ // Type constructor translation helpers:
+ //
+
+ private Pointer create_pointer (Vala.PointerType vtyperef, Item parent) {
+ Pointer ptr = new Pointer (parent, vtyperef);
+
+ Vala.DataType vntype = vtyperef.base_type;
+ if (vntype is Vala.PointerType) {
+ ptr.data_type = create_pointer ((Vala.PointerType) vntype, ptr);
+ } else if (vntype is Vala.ArrayType) {
+ ptr.data_type = create_array ((Vala.ArrayType) vntype, ptr);
+ } else {
+ ptr.data_type = create_type_reference (vntype, ptr);
+ }
+
+ return ptr;
+ }
+
+ private Array create_array (Vala.ArrayType vtyperef, Item parent) {
+ Array arr = new Array (parent, vtyperef);
+
+ Vala.DataType vntype = vtyperef.element_type;
+ if (vntype is Vala.ArrayType) {
+ arr.data_type = create_array ((Vala.ArrayType) vntype, arr);
+ } else {
+ arr.data_type = create_type_reference (vntype, arr);
+ }
+
+ return arr;
+ }
+
+ private TypeReference create_type_reference (Vala.DataType? vtyperef, Item parent) {
+ bool is_nullable = vtyperef != null && vtyperef.nullable && !(vtyperef is Vala.GenericType) && !(vtyperef is Vala.PointerType);
+ string? signature = (vtyperef != null && vtyperef.data_type != null)? Vala.GVariantModule.get_dbus_signature (vtyperef.data_type) : null;
+ bool pass_ownership = type_reference_pass_ownership (vtyperef);
+ Ownership ownership = get_type_reference_ownership (vtyperef);
+ bool is_dynamic = vtyperef != null && vtyperef.is_dynamic;
+
+ TypeReference type_ref = new TypeReference (parent, ownership, pass_ownership, is_dynamic, is_nullable, signature, vtyperef);
+
+ if (vtyperef is Vala.PointerType) {
+ type_ref.data_type = create_pointer ((Vala.PointerType) vtyperef, type_ref);
+ } else if (vtyperef is Vala.ArrayType) {
+ type_ref.data_type = create_array ((Vala.ArrayType) vtyperef, type_ref);
+ }
+
+ // type parameters:
+ if (vtyperef != null) {
+ foreach (Vala.DataType vdtype in vtyperef.get_type_arguments ()) {
+ var type_param = create_type_reference (vdtype, type_ref);
+ type_ref.add_type_argument (type_param);
+ }
+ }
+
+ return type_ref;
+ }
+
+
+
+ //
+ // Translation helpers:
+ //
+
+ private SourceComment? create_comment (Vala.Comment? comment) {
+ if (comment != null) {
+ Vala.SourceReference pos = comment.source_reference;
+ SourceFile file = files.get (pos.file);
+ return new SourceComment (comment.content, file, pos.first_line, pos.first_column, pos.last_line, pos.last_column);
+ }
+
+ return null;
+ }
+
+ private string get_method_name (Vala.Method element) {
+ if (element is Vala.CreationMethod) {
+ if (element.name == ".new") {
+ return element.parent_symbol.name;
+ } else {
+ return element.parent_symbol.name + "." + element.name;
+ }
+ }
+
+ return element.name;
+ }
+
+ private PackageMetaData? get_package_meta_data (Package pkg) {
+ foreach (PackageMetaData data in packages) {
+ if (data.package == pkg) {
+ return data;
+ }
+ }
+
+ return null;
+ }
+
+ private PackageMetaData register_package (Package package) {
+ PackageMetaData meta_data = new PackageMetaData (package);
+ tree.add_package (package);
+ packages.add (meta_data);
+ return meta_data;
+ }
+
+ private SourceFile register_source_file (PackageMetaData meta_data, Vala.SourceFile source_file) {
+ SourceFile file = new SourceFile (source_file.get_relative_filename (), source_file.get_csource_filename ());
+ files.set (source_file, file);
+
+ meta_data.register_source_file (source_file);
+ return file;
+ }
+
+ private SourceFile? get_source_file (Vala.Symbol symbol) {
+ Vala.SourceReference source_ref = symbol.source_reference;
+ if (source_ref == null) {
+ return null;
+ }
+
+ SourceFile file = files.get (source_ref.file);
+ assert (file != null);
+ return file;
+ }
+
+ private Package? find_package_for_file (Vala.SourceFile source_file) {
+ foreach (PackageMetaData pkg in this.packages) {
+ if (pkg.is_package_for_file (source_file)) {
+ return pkg.package;
+ }
+ }
+
+ return null;
+ }
+
+
+ private Namespace get_namespace (Package pkg, Vala.Symbol symbol, SourceFile? file) {
+ // Find the closest namespace in our vala-tree
+ Vala.Symbol namespace_symbol = symbol;
+ while (!(namespace_symbol is Vala.Namespace)) {
+ namespace_symbol = namespace_symbol.parent_symbol;
+ }
+
+ PackageMetaData? meta_data = get_package_meta_data (pkg);
+ assert (meta_data != null);
+
+ return meta_data.get_namespace ((Vala.Namespace) namespace_symbol, file);
+ }
+
+ private MethodBindingType get_method_binding_type (Vala.Method element) {
+ if (element.is_inline) {
+ return MethodBindingType.INLINE;
+ } else if (element.is_abstract) {
+ return MethodBindingType.ABSTRACT;
+ } else if (element.is_virtual) {
+ return MethodBindingType.VIRTUAL;
+ } else if (element.overrides) {
+ return MethodBindingType.OVERRIDE;
+ } else if (element.is_inline) {
+ return MethodBindingType.INLINE;
+ } else if (element.binding == Vala.MemberBinding.INSTANCE) {
+ return MethodBindingType.STATIC;
+ }
+ return MethodBindingType.UNMODIFIED;
+ }
+
+
+ private SymbolAccessibility get_access_modifier(Vala.Symbol symbol) {
+ switch (symbol.access) {
+ case Vala.SymbolAccessibility.PROTECTED:
+ return SymbolAccessibility.PROTECTED;
+
+ case Vala.SymbolAccessibility.INTERNAL:
+ return SymbolAccessibility.INTERNAL;
+
+ case Vala.SymbolAccessibility.PRIVATE:
+ return SymbolAccessibility.PRIVATE;
+
+ case Vala.SymbolAccessibility.PUBLIC:
+ return SymbolAccessibility.PUBLIC;
+
+ default:
+ error ("Unknown symbol accessibility modifier found");
+ }
+ }
+
+ private PropertyAccessorType get_property_accessor_type (Vala.PropertyAccessor element) {
+ if (element.construction) {
+ return PropertyAccessorType.CONSTRUCT;
+ } else if (element.writable) {
+ return PropertyAccessorType.SET;
+ } else if (element.readable) {
+ return PropertyAccessorType.GET;
+ }
+
+ error ("Unknown symbol accessibility type");
+ }
+
+ private bool type_reference_pass_ownership (Vala.DataType? element) {
+ if (element == null) {
+ return false;
+ }
+
+ Vala.CodeNode? node = element.parent_node;
+ if (node == null) {
+ return false;
+ }
+ if (node is Vala.Parameter) {
+ return (((Vala.Parameter)node).direction == Vala.ParameterDirection.IN &&
+ ((Vala.Parameter)node).variable_type.value_owned);
+ }
+ if (node is Vala.Property) {
+ return ((Vala.Property)node).property_type.value_owned;
+ }
+
+ return false;
+ }
+
+ private bool is_type_reference_unowned (Vala.DataType? element) {
+ if (element == null) {
+ return false;
+ }
+
+ // non ref counted types are weak, not unowned
+ if (element.data_type is Vala.TypeSymbol && ((Vala.TypeSymbol) element.data_type).is_reference_counting () == true) {
+ return false;
+ }
+
+ // FormalParameters are weak by default
+ return (element.parent_node is Vala.Parameter == false)? element.is_weak () : false;
+ }
+
+ private bool is_type_reference_owned (Vala.DataType? element) {
+ if (element == null) {
+ return false;
+ }
+
+ Vala.CodeNode parent = element.parent_node;
+
+ // parameter:
+ if (parent is Vala.Parameter) {
+ if (((Vala.Parameter)parent).direction != Vala.ParameterDirection.IN) {
+ return false;
+ }
+ return ((Vala.Parameter)parent).variable_type.value_owned;
+ }
+
+ return false;
+ }
+
+ private bool is_type_reference_weak (Vala.DataType? element) {
+ if (element == null) {
+ return false;
+ }
+
+ // non ref counted types are unowned, not weak
+ if (element.data_type is Vala.TypeSymbol && ((Vala.TypeSymbol) element.data_type).is_reference_counting () == false) {
+ return false;
+ }
+
+ // FormalParameters are weak by default
+ return (element.parent_node is Vala.Parameter == false)? element.is_weak () : false;
+ }
+
+ private Ownership get_type_reference_ownership (Vala.DataType? element) {
+ if (is_type_reference_owned (element)) {
+ return Ownership.OWNED;
+ } else if (is_type_reference_weak (element)) {
+ return Ownership.WEAK;
+ } else if (is_type_reference_unowned (element)) {
+ return Ownership.UNOWNED;
+ }
+
+ return Ownership.DEFAULT;
+ }
+
+ private Ownership get_property_ownership (Vala.PropertyAccessor element) {
+ if (element.value_type.value_owned) {
+ return Ownership.OWNED;
+ }
+
+ // the exact type (weak, unowned) does not matter
+ return Ownership.UNOWNED;
+ }
+
+ private PropertyBindingType get_property_binding_type (Vala.Property element) {
+ if (element.is_abstract) {
+ return PropertyBindingType.ABSTRACT;
+ } else if (element.is_virtual) {
+ return PropertyBindingType.VIRTUAL;
+ } else if (element.overrides) {
+ return PropertyBindingType.OVERRIDE;
+ }
+
+ return PropertyBindingType.UNMODIFIED;
+ }
+
+ private FormalParameterType get_formal_parameter_type (Vala.Parameter element) {
+ if (element.direction == Vala.ParameterDirection.OUT) {
+ return FormalParameterType.OUT;
+ } else if (element.direction == Vala.ParameterDirection.REF) {
+ return FormalParameterType.REF;
+ } else if (element.direction == Vala.ParameterDirection.IN) {
+ return FormalParameterType.IN;
+ }
+
+ error ("Unknown formal parameter type");
+ }
+
+
+ //
+ // Vala tree creation:
+ //
+
+ private bool add_package (Vala.CodeContext context, string pkg) {
+ if (context.has_package (pkg)) {
+ // ignore multiple occurences of the same package
+ return true;
+ }
+
+ var package_path = context.get_vapi_path (pkg) ?? context.get_gir_path (pkg);
+ if (package_path == null) {
+ Vala.Report.error (null, "Package `%s' not found in specified Vala API directories or GObject-Introspection GIR directories".printf (pkg));
+ return false;
+ }
+
+ context.add_package (pkg);
+
+ var vfile = new Vala.SourceFile (context, Vala.SourceFileType.PACKAGE, package_path);
+ context.add_source_file (vfile);
+ Package vdpkg = new Package (vfile, 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);
+ return true;
+ }
+
+ private void add_deps (Vala.CodeContext context, string file_path, string pkg_name) {
+ if (FileUtils.test (file_path, FileTest.EXISTS)) {
+ try {
+ string deps_content;
+ ulong deps_len;
+ FileUtils.get_contents (file_path, out deps_content, out deps_len);
+ foreach (string dep in deps_content.split ("\n")) {
+ dep.strip ();
+ if (dep != "") {
+ if (!add_package (context, dep)) {
+ Vala.Report.error (null, "%s, dependency of %s, not found in specified Vala API directories".printf (dep, pkg_name));
+ }
+ }
+ }
+ } catch (FileError e) {
+ Vala.Report.error (null, "Unable to read dependency file: %s".printf (e.message));
+ }
+ }
+ }
+
+ /**
+ * Adds the specified packages to the list of used packages.
+ *
+ * @param context The code context
+ * @param packages a list of package names
+ */
+ private void add_depencies (Vala.CodeContext context, string[] packages) {
+ foreach (string package in packages) {
+ if (!add_package (context, package)) {
+ Vala.Report.error (null, "Package `%s' not found in specified Vala API directories or GObject-Introspection GIR directories".printf (package));
+ }
+ }
+ }
+
+ /**
+ * Add the specified source file to the context. Only .vala, .vapi, .gs,
+ * and .c files are supported.
+ */
+ private void add_documented_files (Vala.CodeContext context, string[] sources) {
+ if (sources == null) {
+ return;
+ }
+
+ foreach (string source in sources) {
+ if (FileUtils.test (source, FileTest.EXISTS)) {
+ var rpath = realpath (source);
+ if (source.has_suffix (".vala") || source.has_suffix (".gs")) {
+ 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));
+ }
+
+ register_source_file (source_package, source_file);
+
+ if (context.profile == Vala.Profile.POSIX) {
+ // import the Posix namespace by default (namespace of backend-specific standard library)
+ var ns_ref = new Vala.UsingDirective (new Vala.UnresolvedSymbol (null, "Posix", null));
+ source_file.add_using_directive (ns_ref);
+ context.root.add_using_directive (ns_ref);
+ } else if (context.profile == Vala.Profile.GOBJECT) {
+ // import the GLib namespace by default (namespace of backend-specific standard library)
+ var ns_ref = new Vala.UsingDirective (new Vala.UnresolvedSymbol (null, "GLib", null));
+ source_file.add_using_directive (ns_ref);
+ context.root.add_using_directive (ns_ref);
+ }
+
+ context.add_source_file (source_file);
+ } else if (source.has_suffix (".vapi")) {
+ string file_name = Path.get_basename (source);
+ 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);
+ context.add_source_file (vfile);
+
+ register_source_file (register_package (vdpkg), vfile);
+
+ add_deps (context, Path.build_filename (Path.get_dirname (source), "%s.deps".printf (file_name)), file_name);
+ } else if (source.has_suffix (".c")) {
+ context.add_c_source_file (rpath);
+ tree.add_external_c_files (rpath);
+ } else {
+ Vala.Report.error (null, "%s is not a supported source file type. Only .vala, .vapi, .gs, and .c files are supported.".printf (source));
+ }
+ } else {
+ Vala.Report.error (null, "%s not found".printf (source));
+ }
+ }
+ }
+
+ private Vala.CodeContext create_valac_tree (Settings settings) {
+ // init context:
+ var context = new Vala.CodeContext ();
+ Vala.CodeContext.push (context);
+
+
+ // settings:
+ context.experimental = settings.experimental;
+ context.experimental_non_null = settings.experimental || settings.experimental_non_null;
+ context.vapi_directories = settings.vapi_directories;
+ context.report.enable_warnings = settings.verbose;
+
+ if (settings.basedir == null) {
+ context.basedir = realpath (".");
+ } else {
+ context.basedir = realpath (settings.basedir);
+ }
+
+ if (settings.directory != null) {
+ context.directory = realpath (settings.directory);
+ } else {
+ context.directory = context.basedir;
+ }
+
+
+ // add default packages:
+ if (settings.profile == "gobject-2.0" || settings.profile == "gobject" || settings.profile == null) {
+ context.profile = Vala.Profile.GOBJECT;
+ context.add_define ("GOBJECT");
+ }
+
+
+ if (settings.defines != null) {
+ foreach (string define in settings.defines) {
+ context.add_define (define);
+ }
+ }
+
+ if (context.profile == Vala.Profile.POSIX) {
+ // default package
+ if (!add_package (context, "posix")) {
+ Vala.Report.error (null, "posix not found in specified Vala API directories");
+ }
+ } else if (context.profile == Vala.Profile.GOBJECT) {
+ int glib_major = 2;
+ int glib_minor = 12;
+
+ context.target_glib_major = glib_major;
+ context.target_glib_minor = glib_minor;
+ if (context.target_glib_major != 2) {
+ Vala.Report.error (null, "This version of valac only supports GLib 2");
+ }
+
+ // default packages
+ if (!this.add_package (context, "glib-2.0")) { //
+ Vala.Report.error (null, "glib-2.0 not found in specified Vala API directories");
+ }
+
+ if (!this.add_package (context, "gobject-2.0")) { //
+ Vala.Report.error (null, "gobject-2.0 not found in specified Vala API directories");
+ }
+ }
+
+
+ // add user defined files:
+ add_depencies (context, settings.packages);
+ if (reporter.errors > 0) {
+ return context;
+ }
+
+ add_documented_files (context, settings.source_files);
+ if (reporter.errors > 0) {
+ return context;
+ }
+
+
+ // parse vala-code:
+ Vala.Parser parser = new Vala.Parser ();
+
+ parser.parse (context);
+ if (context.report.get_errors () > 0) {
+ return context;
+ }
+
+
+ // check context:
+ context.check ();
+ if (context.report.get_errors () > 0) {
+ return context;
+ }
+
+ return context;
+ }
+
+
+
+ //
+ // Valadoc tree creation:
+ //
+
+ private void process_children (Api.Node node, Vala.Symbol element) {
+ Api.Node old_node = current_node;
+ current_node = node;
+ element.accept_children (this);
+ current_node = old_node;
+ }
+
+ private Api.Node get_parent_node_for (Vala.Symbol element) {
+ if (current_node != null) {
+ return current_node;
+ }
+
+ Vala.SourceFile vala_source_file = element.source_reference.file;
+ Package package = find_package_for_file (vala_source_file);
+ SourceFile? source_file = get_source_file (element);
+
+ return get_namespace (package, element, source_file);
+ }
+
+ /**
+ * { inheritDoc}
+ */
+ public override void visit_namespace (Vala.Namespace element) {
+ element.accept_children (this);
+ }
+
+ /**
+ * { inheritDoc}
+ */
+ public override void visit_class (Vala.Class element) {
+ Api.Node parent = get_parent_node_for (element);
+ SourceFile? file = get_source_file (element);
+ SourceComment? comment = create_comment (element.comment);
+
+ bool is_basic_type = element.base_class == null && element.name == "string";
+
+ Class node = new Class (parent, file, element.name, get_access_modifier(element), comment, element.get_cname (), Vala.GDBusModule.get_dbus_name (element), element.get_param_spec_function (), element.get_type_id (), element.get_ref_function (), element.get_unref_function (), element.get_take_value_function (), element.get_get_value_function (), element.get_set_value_function (), element.is_fundamental (), element.is_abstract, is_basic_type, element);
+ symbol_map.set (element, node);
+ parent.add_child (node);
+
+ // relations
+ foreach (Vala.DataType vala_type_ref in element.get_base_types ()) {
+ var type_ref = create_type_reference (vala_type_ref, node);
+
+ if (vala_type_ref.data_type is Vala.Interface) {
+ node.add_interface (type_ref);
+ } else {
+ node.base_type = type_ref;
+ }
+ }
+
+ process_children (node, element);
+
+ // save GLib.Error
+ if (glib_error == null && node.get_full_name () == "GLib.Error") {
+ glib_error = node;
+ }
+ }
+
+ /**
+ * { inheritDoc}
+ */
+ public override void visit_interface (Vala.Interface element) {
+ Api.Node parent = get_parent_node_for (element);
+ SourceFile? file = get_source_file (element);
+ SourceComment? comment = create_comment (element.comment);
+
+ Interface node = new Interface (parent, file, element.name, get_access_modifier(element), comment, element.get_cname (), Vala.GDBusModule.get_dbus_name (element), element);
+ symbol_map.set (element, node);
+ parent.add_child (node);
+
+ // prerequisites:
+ foreach (Vala.DataType vala_type_ref in element.get_prerequisites ()) {
+ TypeReference type_ref = create_type_reference (vala_type_ref, node);
+ if (vala_type_ref.data_type is Vala.Interface) {
+ node.add_interface (type_ref);
+ } else {
+ node.base_type = type_ref;
+ }
+ }
+
+ process_children (node, element);
+ }
+
+ /**
+ * { inheritDoc}
+ */
+ public override void visit_struct (Vala.Struct element) {
+ Api.Node parent = get_parent_node_for (element);
+ SourceFile? file = get_source_file (element);
+ SourceComment? comment = create_comment (element.comment);
+
+ bool is_basic_type = element.base_type == null && (element.is_boolean_type () || element.is_floating_type () || element.is_integer_type ());
+
+ Struct node = new Struct (parent, file, element.name, get_access_modifier(element), comment, element.get_cname(), element.get_dup_function (), element.get_free_function (), is_basic_type, element);
+ symbol_map.set (element, node);
+ parent.add_child (node);
+
+ // parent type:
+ Vala.ValueType? basetype = element.base_type as Vala.ValueType;
+ if (basetype != null) {
+ node.base_type = create_type_reference (basetype, node);
+ }
+
+ process_children (node, element);
+ }
+
+ /**
+ * { inheritDoc}
+ */
+ public override void visit_field (Vala.Field element) {
+ Api.Node parent = get_parent_node_for (element);
+ SourceFile? file = get_source_file (element);
+ SourceComment? comment = create_comment (element.comment);
+
+ Field node = new Field (parent, file, element.name, get_access_modifier(element), comment, element.get_cname (), element.binding == Vala.MemberBinding.STATIC, element.is_volatile, element);
+ node.field_type = create_type_reference (element.variable_type, node);
+ symbol_map.set (element, node);
+ parent.add_child (node);
+
+ process_children (node, element);
+ }
+
+ /**
+ * { inheritDoc}
+ */
+ public override void visit_property (Vala.Property element) {
+ Api.Node parent = get_parent_node_for (element);
+ SourceFile? file = get_source_file (element);
+ SourceComment? comment = create_comment (element.comment);
+
+ Property node = new Property (parent, file, element.name, get_access_modifier(element), comment, element.nick, Vala.GDBusModule.get_dbus_name_for_member (element), Vala.GDBusServerModule.is_dbus_visible (element), get_property_binding_type (element), element);
+ node.property_type = create_type_reference (element.property_type, node);
+ symbol_map.set (element, node);
+ parent.add_child (node);
+
+ // Process property type
+ if (element.get_accessor != null) {
+ var accessor = element.get_accessor;
+ node.getter = new PropertyAccessor (node, file, element.name, get_access_modifier(element), accessor.get_cname(), get_property_accessor_type (accessor), get_property_ownership (accessor), accessor);
+ }
+
+ if (element.set_accessor != null) {
+ var accessor = element.set_accessor;
+ node.setter = new PropertyAccessor (node, file, element.name, get_access_modifier(element), accessor.get_cname(), get_property_accessor_type (accessor), get_property_ownership (accessor), accessor);
+ }
+
+ process_children (node, element);
+ }
+
+ /**
+ * { inheritDoc}
+ */
+ public override void visit_creation_method (Vala.CreationMethod element) {
+ Api.Node parent = get_parent_node_for (element);
+ SourceFile? file = get_source_file (element);
+ SourceComment? comment = create_comment (element.comment);
+
+ Method node = new Method (parent, file, get_method_name (element), get_access_modifier(element), comment, element.get_cname (), Vala.GDBusModule.get_dbus_name_for_member (element), Vala.GDBusServerModule.dbus_result_name (element), (element.coroutine)? element.get_finish_cname () : null, get_method_binding_type (element), element.coroutine, Vala.GDBusServerModule.is_dbus_visible (element), element is Vala.CreationMethod, element);
+ node.return_type = create_type_reference (element.return_type, node);
+ symbol_map.set (element, node);
+ parent.add_child (node);
+
+ process_children (node, element);
+ }
+
+ /**
+ * { inheritDoc}
+ */
+ public override void visit_method (Vala.Method element) {
+ Api.Node parent = get_parent_node_for (element);
+ SourceFile? file = get_source_file (element);
+ SourceComment? comment = create_comment (element.comment);
+
+ Method node = new Method (parent, file, get_method_name (element), get_access_modifier(element), comment, element.get_cname (), Vala.GDBusModule.get_dbus_name_for_member (element), Vala.GDBusServerModule.dbus_result_name (element), (element.coroutine)? element.get_finish_cname () : null, get_method_binding_type (element), element.coroutine, Vala.GDBusServerModule.is_dbus_visible (element), element is Vala.CreationMethod, element);
+ node.return_type = create_type_reference (element.return_type, node);
+ symbol_map.set (element, node);
+ parent.add_child (node);
+
+ process_children (node, element);
+ }
+
+ /**
+ * { inheritDoc}
+ */
+ public override void visit_signal (Vala.Signal element) {
+ Api.Node parent = get_parent_node_for (element);
+ SourceFile? file = get_source_file (element);
+ SourceComment? comment = create_comment (element.comment);
+
+ Signal node = new Api.Signal (parent, file, element.name, get_access_modifier(element), comment, element.get_cname(), Vala.GDBusModule.get_dbus_name_for_member (element), Vala.GDBusServerModule.is_dbus_visible (element), element.is_virtual, element);
+ node.return_type = create_type_reference (element.return_type, node);
+ symbol_map.set (element, node);
+ parent.add_child (node);
+
+ process_children (node, element);
+ }
+
+ /**
+ * { inheritDoc}
+ */
+ public override void visit_delegate (Vala.Delegate element) {
+ Api.Node parent = get_parent_node_for (element);
+ SourceFile? file = get_source_file (element);
+ SourceComment? comment = create_comment (element.comment);
+
+ Delegate node = new Delegate (parent, file, element.name, get_access_modifier(element), comment, element.get_cname (), element.has_target, element);
+ node.return_type = create_type_reference (element.return_type, node);
+ symbol_map.set (element, node);
+ parent.add_child (node);
+
+ process_children (node, element);
+ }
+
+ /**
+ * { inheritDoc}
+ */
+ public override void visit_enum (Vala.Enum element) {
+ Api.Node parent = get_parent_node_for (element);
+ SourceFile? file = get_source_file (element);
+ SourceComment? comment = create_comment (element.comment);
+
+ Symbol node = new Enum (parent, file, element.name, get_access_modifier(element), comment, element.get_cname (), element);
+ symbol_map.set (element, node);
+ parent.add_child (node);
+
+ process_children (node, element);
+ }
+
+ /**
+ * { inheritDoc}
+ */
+ public override void visit_enum_value (Vala.EnumValue element) {
+ Api.Enum parent = (Enum) get_parent_node_for (element);
+ SourceFile? file = get_source_file (element);
+ SourceComment? comment = create_comment (element.comment);
+
+ Symbol node = new Api.EnumValue (parent, file, element.name, comment, element.get_cname (), element);
+ symbol_map.set (element, node);
+ parent.add_child (node);
+
+ process_children (node, element);
+ }
+
+ /**
+ * { inheritDoc}
+ */
+ public override void visit_constant (Vala.Constant element) {
+ Api.Node parent = get_parent_node_for (element);
+ SourceFile? file = get_source_file (element);
+ SourceComment? comment = create_comment (element.comment);
+
+ Constant node = new Constant (parent, file, element.name, get_access_modifier(element), comment, element.get_cname (), element);
+ node.constant_type = create_type_reference (element.type_reference, node);
+ symbol_map.set (element, node);
+ parent.add_child (node);
+
+ process_children (node, element);
+ }
+
+ /**
+ * { inheritDoc}
+ */
+ public override void visit_error_domain (Vala.ErrorDomain element) {
+ Api.Node parent = get_parent_node_for (element);
+ SourceFile? file = get_source_file (element);
+ SourceComment? comment = create_comment (element.comment);
+
+ Symbol node = new ErrorDomain (parent, file, element.name, get_access_modifier(element), comment, element.get_cname(), Vala.GDBusModule.get_dbus_name (element), element);
+ symbol_map.set (element, node);
+ parent.add_child (node);
+
+ process_children (node, element);
+ }
+
+ /**
+ * { inheritDoc}
+ */
+ public override void visit_error_code (Vala.ErrorCode element) {
+ Api.ErrorDomain parent = (ErrorDomain) get_parent_node_for (element);
+ SourceFile? file = get_source_file (element);
+ SourceComment? comment = create_comment (element.comment);
+
+ Symbol node = new Api.ErrorCode (parent, file, element.name, comment, element.get_cname (), Vala.GDBusModule.get_dbus_name_for_member (element), element);
+ symbol_map.set (element, node);
+ parent.add_child (node);
+
+ process_children (node, element);
+ }
+
+ /**
+ * { inheritDoc}
+ */
+ public override void visit_type_parameter (Vala.TypeParameter element) {
+ Api.Node parent = get_parent_node_for (element);
+ SourceFile? file = get_source_file (element);
+
+ Symbol node = new TypeParameter (parent, file, element.name, element);
+ parent.add_child (node);
+
+ process_children (node, element);
+ }
+
+ /**
+ * { inheritDoc}
+ */
+ public override void visit_formal_parameter (Vala.Parameter element) {
+ Api.Node parent = get_parent_node_for (element);
+ SourceFile? file = get_source_file (element);
+
+ FormalParameter node = new FormalParameter (parent, file, element.name, get_access_modifier(element), get_formal_parameter_type (element), element.ellipsis, element);
+ node.parameter_type = create_type_reference (element.variable_type, node);
+ parent.add_child (node);
+
+ process_children (node, element);
+ }
+
+
+ //
+ // startpoint:
+ //
+
+ public Api.Tree? build (Settings settings, ErrorReporter reporter) {
+ this.tree = new Api.Tree (reporter, settings);
+ this.settings = settings;
+ this.reporter = reporter;
+
+ var context = create_valac_tree (settings);
+
+ reporter.warnings_offset = context.report.get_warnings ();
+ reporter.errors_offset = context.report.get_errors ();
+
+ if (context == null) {
+ return null;
+ }
+
+ context.accept(this);
+
+ if (reporter.errors > 0) {
+ return null;
+ }
+
+ SymbolResolver resolver = new SymbolResolver (symbol_map, glib_error);
+ this.tree.accept (resolver);
+
+ return tree;
+ }
+}
+
+
diff --git a/src/libvaladoc/api/enum.vala b/src/libvaladoc/api/enum.vala
index d4b59f4..108f312 100755
--- a/src/libvaladoc/api/enum.vala
+++ b/src/libvaladoc/api/enum.vala
@@ -1,6 +1,6 @@
/* enum.vala
*
- * Copyright (C) 2008 Florian Brosch
+ * Copyright (C) 2008-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
@@ -28,15 +28,17 @@ using Valadoc.Content;
* Represents an enum declaration.
*/
public class Valadoc.Api.Enum : TypeSymbol {
- public Enum (Vala.Enum symbol, Node parent) {
- base (symbol, parent);
+ private string cname;
+
+ public Enum (Node parent, SourceFile file, string name, SymbolAccessibility accessibility, SourceComment? comment, string? cname, void* data) {
+ base (parent, file, name, accessibility, comment, false, data);
}
/**
* Returns the name of this enum as it is used in C.
*/
public string? get_cname () {
- return ((Vala.Enum) symbol).get_cname ();
+ return cname;
}
/**
diff --git a/src/libvaladoc/api/enumvalue.vala b/src/libvaladoc/api/enumvalue.vala
index ef9dead..d63af21 100755
--- a/src/libvaladoc/api/enumvalue.vala
+++ b/src/libvaladoc/api/enumvalue.vala
@@ -1,6 +1,6 @@
/* enumvalue.vala
*
- * Copyright (C) 2008 Florian Brosch
+ * Copyright (C) 2008-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
@@ -28,51 +28,34 @@ using Valadoc.Content;
* Represents an enum member.
*/
public class Valadoc.Api.EnumValue: Symbol {
- public EnumValue (Vala.EnumValue symbol, Node parent) {
- base (symbol, parent);
- }
+ private SourceComment? source_comment;
+ private string? cname;
- /**
- * { inheritDoc}
- */
- public override bool is_public {
- get {
- return ((Enum)parent).is_public;
- }
+ public Content.Run default_value {
+ get;
+ set;
}
/**
- * { inheritDoc}
+ * Specifies whether the parameter has a default value
*/
- public override bool is_protected {
+ public bool has_default_value {
get {
- return ((Enum)parent).is_protected;
+ return default_value != null;
}
}
- /**
- * { inheritDoc}
- */
- public override bool is_internal {
- get {
- return ((Enum)parent).is_internal;
- }
- }
+ public EnumValue (Enum parent, SourceFile file, string name, SourceComment? comment, string? cname, void* data) {
+ base (parent, file, name, parent.accessibility, data);
- /**
- * { inheritDoc}
- */
- public override bool is_private {
- get {
- return ((Enum)parent).is_private;
- }
+ this.source_comment = comment;
+ this.cname = cname;
}
/**
* { inheritDoc}
*/
internal override void process_comments (Settings settings, DocumentationParser parser) {
- var source_comment = ((Vala.EnumValue) symbol).comment;
if (source_comment != null) {
documentation = parser.parse (this, source_comment);
}
@@ -84,7 +67,7 @@ public class Valadoc.Api.EnumValue: Symbol {
* Returns the name of this enum value as it is used in C.
*/
public string get_cname () {
- return ((Vala.EnumValue) symbol).get_cname ();
+ return cname;
}
/**
@@ -106,9 +89,9 @@ public class Valadoc.Api.EnumValue: Symbol {
var builder = new SignatureBuilder ()
.append_symbol (this);
- if (((Vala.EnumValue) symbol).value != null) {
- builder.append ("=")
- .append (((Vala.EnumValue) symbol).value.to_string ());
+ if (has_default_value) {
+ builder.append ("=");
+ builder.append_content (default_value);
}
return builder.get ();
diff --git a/src/libvaladoc/api/errorcode.vala b/src/libvaladoc/api/errorcode.vala
index 7639867..8253c1b 100755
--- a/src/libvaladoc/api/errorcode.vala
+++ b/src/libvaladoc/api/errorcode.vala
@@ -1,6 +1,6 @@
/* errorcode.vala
*
- * Copyright (C) 2008 Florian Brosch
+ * Copyright (C) 2008-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
@@ -27,65 +27,50 @@ using Valadoc.Content;
/**
* Represents an errordomain member in the source code.
*/
-public class Valadoc.Api.ErrorCode : TypeSymbol {
- public ErrorCode (Vala.ErrorCode symbol, Node parent) {
- base (symbol, parent);
- }
+public class Valadoc.Api.ErrorCode : Symbol {
+ private SourceComment? source_comment;
+ private string? dbus_name;
+ private string? cname;
- /**
- * { inheritDoc}
- */
- public override bool is_public {
- get {
- return ((ErrorDomain)parent).is_public;
- }
- }
+ public ErrorCode (ErrorDomain parent, SourceFile file, string name, SourceComment? comment, string? cname, string? dbus_name, void* data) {
+ base (parent, file, name, parent.accessibility, data);
- /**
- * { inheritDoc}
- */
- public override bool is_protected {
- get {
- return ((ErrorDomain)parent).is_protected;
- }
+ this.source_comment = comment;
+ this.dbus_name = dbus_name;
+ this.cname = cname;
}
/**
* { inheritDoc}
*/
- public override bool is_internal {
- get {
- return ((ErrorDomain)parent).is_internal;
+ internal override void process_comments (Settings settings, DocumentationParser parser) {
+ if (source_comment != null) {
+ documentation = parser.parse (this, source_comment);
}
- }
- /**
- * { inheritDoc}
- */
- public override bool is_private {
- get {
- return ((ErrorDomain)parent).is_private;
- }
+ base.process_comments (settings, parser);
}
/**
* Returns the name of this class as it is used in C.
*/
public string get_cname () {
- return ((Vala.ErrorCode) symbol).get_cname ();
+ return cname;
}
/**
* Returns the dbus-name.
*/
public string get_dbus_name () {
- return Vala.GDBusModule.get_dbus_name_for_member (symbol);
+ return dbus_name;
}
/**
* { inheritDoc}
*/
- public override NodeType node_type { get { return NodeType.ERROR_CODE; } }
+ public override NodeType node_type {
+ get { return NodeType.ERROR_CODE; }
+ }
/**
* { inheritDoc}
diff --git a/src/libvaladoc/api/errordomain.vala b/src/libvaladoc/api/errordomain.vala
index 061da44..3076b28 100755
--- a/src/libvaladoc/api/errordomain.vala
+++ b/src/libvaladoc/api/errordomain.vala
@@ -1,6 +1,6 @@
/* errordomain.vala
*
- * Copyright (C) 2008 Florian Brosch
+ * Copyright (C) 2008-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
@@ -28,28 +28,36 @@ using Valadoc.Content;
* Represents an error domain declaration.
*/
public class Valadoc.Api.ErrorDomain : TypeSymbol {
- public ErrorDomain (Vala.ErrorDomain symbol, Node parent) {
- base (symbol, parent);
+ private string? dbus_name;
+ private string? cname;
+
+ public ErrorDomain (Node parent, SourceFile file, string name, SymbolAccessibility accessibility, SourceComment? comment, string? cname, string? dbus_name, void* data) {
+ base (parent, file, name, accessibility, comment, false, data);
+
+ this.dbus_name = dbus_name;
+ this.cname = cname;
}
/**
* Returns the name of this errordomain as it is used in C.
*/
public string? get_cname () {
- return ((Vala.ErrorDomain) symbol).get_cname();
+ return this.cname;
}
/**
* Returns the dbus-name.
*/
public string? get_dbus_name () {
- return Vala.GDBusModule.get_dbus_name ((Vala.TypeSymbol) symbol);
+ return dbus_name;
}
/**
* { inheritDoc}
*/
- public override NodeType node_type { get { return NodeType.ERROR_DOMAIN; } }
+ public override NodeType node_type {
+ get { return NodeType.ERROR_DOMAIN; }
+ }
/**
* { inheritDoc}
diff --git a/src/libvaladoc/api/field.vala b/src/libvaladoc/api/field.vala
index 85b84c8..d33d289 100755
--- a/src/libvaladoc/api/field.vala
+++ b/src/libvaladoc/api/field.vala
@@ -1,6 +1,6 @@
/* field.vala
*
- * Copyright (C) 2008 Florian Brosch
+ * Copyright (C) 2008-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
@@ -28,16 +28,22 @@ using Valadoc.Content;
* Represents a field.
*/
public class Valadoc.Api.Field : Member {
- public Field (Vala.Field symbol, Node parent) {
- base (symbol, parent);
- field_type = new TypeReference (symbol.variable_type, this);
+ private string? cname;
+
+ public Field (Node parent, SourceFile file, string name, SymbolAccessibility accessibility, SourceComment? comment, string? cname, bool is_static, bool is_volatile, void* data) {
+ base (parent, file, name, accessibility, comment, data);
+
+ this.is_static = !(parent is Namespace) && is_static;
+ this.is_volatile = is_volatile;
+
+ this.cname = cname;
}
/**
* Returns the name of this field as it is used in C.
*/
public string? get_cname () {
- return ((Vala.Field) symbol).get_cname();
+ return cname;
}
/**
@@ -45,37 +51,25 @@ public class Valadoc.Api.Field : Member {
*
* @return The field type or null for void
*/
- public TypeReference? field_type { private set; get; }
+ public TypeReference? field_type {
+ set;
+ get;
+ }
/**
* Specifies whether the field is static.
*/
public bool is_static {
- get {
- if (this.parent is Namespace) {
- return false;
- }
-
- return ((Vala.Field) symbol).binding == Vala.MemberBinding.STATIC;
- }
+ private set;
+ get;
}
/**
* Specifies whether the field is volatile.
*/
public bool is_volatile {
- get {
- return ((Vala.Field) symbol).is_volatile;
- }
- }
-
- /**
- * { inheritDoc}
- */
- internal override void resolve_type_references (Tree root) {
- field_type.resolve_type_references (root);
-
- base.resolve_type_references (root);
+ private set;
+ get;
}
/**
@@ -100,7 +94,9 @@ public class Valadoc.Api.Field : Member {
/**
* { inheritDoc}
*/
- public override NodeType node_type { get { return NodeType.FIELD; } }
+ public override NodeType node_type {
+ get { return NodeType.FIELD; }
+ }
/**
* { inheritDoc}
diff --git a/src/libvaladoc/api/formalparameter.vala b/src/libvaladoc/api/formalparameter.vala
index 1ba385f..0a781e3 100755
--- a/src/libvaladoc/api/formalparameter.vala
+++ b/src/libvaladoc/api/formalparameter.vala
@@ -1,6 +1,6 @@
/* formalparameter.vala
*
- * Copyright (C) 2008 Florian Brosch
+ * Copyright (C) 2008-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
@@ -27,9 +27,19 @@ using Valadoc.Content;
* Represents a formal parameter in method, signal and delegate signatures.
*/
public class Valadoc.Api.FormalParameter : Symbol {
- public FormalParameter (Vala.Parameter symbol, Node parent) {
- base (symbol, parent);
- parameter_type = new TypeReference (symbol.variable_type, this);
+ public Content.Run default_value {
+ get;
+ set;
+ }
+
+ private FormalParameterType type;
+
+ public FormalParameter (Node parent, SourceFile file, string? name, SymbolAccessibility accessibility, FormalParameterType type, bool ellipsis, void* data) {
+ base (parent, file, name, accessibility, data);
+ assert ((name == null && ellipsis) || (name != null && !ellipsis));
+
+ this.ellipsis = ellipsis;
+ this.type = type;
}
/**
@@ -37,7 +47,7 @@ public class Valadoc.Api.FormalParameter : Symbol {
*/
public bool is_out {
get {
- return ((Vala.Parameter) symbol).direction == Vala.ParameterDirection.OUT;
+ return type == FormalParameterType.OUT;
}
}
@@ -46,7 +56,7 @@ public class Valadoc.Api.FormalParameter : Symbol {
*/
public bool is_ref {
get {
- return ((Vala.Parameter) symbol).direction == Vala.ParameterDirection.REF;
+ return type == FormalParameterType.REF;
}
}
@@ -55,7 +65,7 @@ public class Valadoc.Api.FormalParameter : Symbol {
*/
public bool has_default_value {
get {
- return ((Vala.Parameter) symbol).initializer != null;
+ return default_value != null;
}
}
@@ -64,21 +74,25 @@ public class Valadoc.Api.FormalParameter : Symbol {
*
* @return The parameter type or null for void
*/
- public TypeReference? parameter_type { private set; get; }
+ public TypeReference? parameter_type {
+ set;
+ get;
+ }
/**
* Specifies whether the methods accepts a variable number of arguments
*/
public bool ellipsis {
- get {
- return ((Vala.Parameter) symbol).ellipsis;
- }
+ private set;
+ get;
}
/**
* { inheritDoc}
*/
- public override NodeType node_type { get { return NodeType.FORMAL_PARAMETER; } }
+ public override NodeType node_type {
+ get { return NodeType.FORMAL_PARAMETER; }
+ }
/**
* { inheritDoc}
@@ -90,669 +104,6 @@ public class Valadoc.Api.FormalParameter : Symbol {
/**
* { inheritDoc}
*/
- internal override void resolve_type_references (Tree root) {
- if (ellipsis) {
- return;
- }
-
- parameter_type.resolve_type_references (root);
-
- base.resolve_type_references (root);
- this.root = root;
- }
-
- private Tree root;
-
- private class InitializerBuilder : Vala.CodeVisitor {
- private SignatureBuilder signature;
- private Tree root;
-
- private void write_node (Vala.Symbol vsymbol) {
- signature.append_symbol (root.search_vala_symbol (vsymbol));
- }
-
- private void write_type (Vala.DataType vsymbol) {
- if (vsymbol.data_type != null) {
- write_node (vsymbol.data_type);
- } else {
- signature.append_literal ("null");
- }
-
- var type_args = vsymbol.get_type_arguments ();
- if (type_args.size > 0) {
- signature.append ("<");
- bool first = true;
- foreach (Vala.DataType type_arg in type_args) {
- if (!first) {
- signature.append (",");
- } else {
- first = false;
- }
- if (!type_arg.value_owned) {
- signature.append_keyword ("weak");
- }
- signature.append (type_arg.to_qualified_string (null));
- }
- signature.append (">");
- }
-
- if (vsymbol.nullable) {
- signature.append ("?");
- }
- }
-
- /**
- * { inheritDoc}
- */
- public override void visit_array_creation_expression (Vala.ArrayCreationExpression expr) {
- signature.append_keyword ("new");
- write_type (expr.element_type);
- signature.append ("[", false);
-
- bool first = true;
- foreach (Vala.Expression size in expr.get_sizes ()) {
- if (!first) {
- signature.append (", ", false);
- }
- size.accept (this);
- first = false;
- }
-
- signature.append ("]", false);
-
- if (expr.initializer_list != null) {
- signature.append (" ", false);
- expr.initializer_list.accept (this);
- }
- }
-
- public InitializerBuilder (SignatureBuilder signature, Tree root) {
- this.signature = signature;
- this.root = root;
- }
-
- /**
- * { inheritDoc}
- */
- public override void visit_binary_expression (Vala.BinaryExpression expr) {
- expr.left.accept (this);
-
- switch (expr.operator) {
- case Vala.BinaryOperator.PLUS:
- signature.append ("+ ");
- break;
-
- case Vala.BinaryOperator.MINUS:
- signature.append ("- ");
- break;
-
- case Vala.BinaryOperator.MUL:
- signature.append ("* ");
- break;
-
- case Vala.BinaryOperator.DIV:
- signature.append ("/ ");
- break;
-
- case Vala.BinaryOperator.MOD:
- signature.append ("% ");
- break;
-
- case Vala.BinaryOperator.SHIFT_LEFT:
- signature.append ("<< ");
- break;
-
- case Vala.BinaryOperator.SHIFT_RIGHT:
- signature.append (">> ");
- break;
-
- case Vala.BinaryOperator.LESS_THAN:
- signature.append ("< ");
- break;
-
- case Vala.BinaryOperator.GREATER_THAN:
- signature.append ("> ");
- break;
-
- case Vala.BinaryOperator.LESS_THAN_OR_EQUAL:
- signature.append ("<= ");
- break;
-
- case Vala.BinaryOperator.GREATER_THAN_OR_EQUAL:
- signature.append (">= ");
- break;
-
- case Vala.BinaryOperator.EQUALITY:
- signature.append ("== ");
- break;
-
- case Vala.BinaryOperator.INEQUALITY:
- signature.append ("!= ");
- break;
-
- case Vala.BinaryOperator.BITWISE_AND:
- signature.append ("& ");
- break;
-
- case Vala.BinaryOperator.BITWISE_OR:
- signature.append ("| ");
- break;
-
- case Vala.BinaryOperator.BITWISE_XOR:
- signature.append ("^ ");
- break;
-
- case Vala.BinaryOperator.AND:
- signature.append ("&& ");
- break;
-
- case Vala.BinaryOperator.OR:
- signature.append ("|| ");
- break;
-
- case Vala.BinaryOperator.IN:
- signature.append_keyword ("in");
- signature.append (" ");
- break;
-
- case Vala.BinaryOperator.COALESCE:
- signature.append ("?? ");
- break;
-
- default:
- assert_not_reached ();
- }
-
- expr.right.accept (this);
- }
-
- /**
- * { inheritDoc}
- */
- public override void visit_unary_expression (Vala.UnaryExpression expr) {
- switch (expr.operator) {
- case Vala.UnaryOperator.PLUS:
- signature.append ("+");
- break;
-
- case Vala.UnaryOperator.MINUS:
- signature.append ("-");
- break;
-
- case Vala.UnaryOperator.LOGICAL_NEGATION:
- signature.append ("!");
- break;
-
- case Vala.UnaryOperator.BITWISE_COMPLEMENT:
- signature.append ("~");
- break;
-
- case Vala.UnaryOperator.INCREMENT:
- signature.append ("++");
- break;
-
- case Vala.UnaryOperator.DECREMENT:
- signature.append ("--");
- break;
-
- case Vala.UnaryOperator.REF:
- signature.append_keyword ("ref");
- break;
-
- case Vala.UnaryOperator.OUT:
- signature.append_keyword ("out");
- break;
-
- default:
- assert_not_reached ();
- }
- expr.inner.accept (this);
- }
-
- /**
- * { inheritDoc}
- */
- public override void visit_assignment (Vala.Assignment a) {
- a.left.accept (this);
-
- switch (a.operator) {
- case Vala.AssignmentOperator.SIMPLE:
- signature.append ("=");
- break;
-
- case Vala.AssignmentOperator.BITWISE_OR:
- signature.append ("|");
- break;
-
- case Vala.AssignmentOperator.BITWISE_AND:
- signature.append ("&");
- break;
-
- case Vala.AssignmentOperator.BITWISE_XOR:
- signature.append ("^");
- break;
-
- case Vala.AssignmentOperator.ADD:
- signature.append ("+");
- break;
-
- case Vala.AssignmentOperator.SUB:
- signature.append ("-");
- break;
-
- case Vala.AssignmentOperator.MUL:
- signature.append ("*");
- break;
-
- case Vala.AssignmentOperator.DIV:
- signature.append ("/");
- break;
-
- case Vala.AssignmentOperator.PERCENT:
- signature.append ("%");
- break;
-
- case Vala.AssignmentOperator.SHIFT_LEFT:
- signature.append ("<<");
- break;
-
- case Vala.AssignmentOperator.SHIFT_RIGHT:
- signature.append (">>");
- break;
-
- default:
- assert_not_reached ();
- }
-
- a.right.accept (this);
- }
-
- /**
- * { inheritDoc}
- */
- public override void visit_cast_expression (Vala.CastExpression expr) {
- if (expr.is_non_null_cast) {
- signature.append ("(!)");
- expr.inner.accept (this);
- return;
- }
-
- if (!expr.is_silent_cast) {
- signature.append ("(", false);
- write_type (expr.type_reference);
- signature.append (")", false);
- }
-
- expr.inner.accept (this);
-
- if (expr.is_silent_cast) {
- signature.append_keyword ("as");
- write_type (expr.type_reference);
- }
- }
-
- /**
- * { inheritDoc}
- */
- public override void visit_initializer_list (Vala.InitializerList list) {
- signature.append ("{", false);
-
- bool first = true;
- foreach (Vala.Expression initializer in list.get_initializers ()) {
- if (!first) {
- signature.append (", ", false);
- }
- first = false;
- initializer.accept (this);
- }
-
- signature.append ("}", false);
- }
-
- /**
- * { inheritDoc}
- */
- public override void visit_member_access (Vala.MemberAccess expr) {
- if (expr.symbol_reference != null) {
- expr.symbol_reference.accept (this);
- } else {
- signature.append (expr.member_name);
- }
- }
-
- /**
- * { inheritDoc}
- */
- public override void visit_element_access (Vala.ElementAccess expr) {
- expr.container.accept (this);
- signature.append ("[", false);
-
- bool first = true;
- foreach (Vala.Expression index in expr.get_indices ()) {
- if (!first) {
- signature.append (", ", false);
- }
- first = false;
-
- index.accept (this);
- }
-
- signature.append ("]", false);
- }
-
- /**
- * { inheritDoc}
- */
- public override void visit_pointer_indirection (Vala.PointerIndirection expr) {
- signature.append ("*", false);
- expr.inner.accept (this);
- }
-
- /**
- * { inheritDoc}
- */
- public override void visit_addressof_expression (Vala.AddressofExpression expr) {
- signature.append ("&", false);
- expr.inner.accept (this);
- }
-
- /**
- * { inheritDoc}
- */
- public override void visit_reference_transfer_expression (Vala.ReferenceTransferExpression expr) {
- signature.append ("(", false).append_keyword ("owned", false).append (")", false);
- expr.inner.accept (this);
- }
-
- /**
- * { inheritDoc}
- */
- public override void visit_type_check (Vala.TypeCheck expr) {
- expr.expression.accept (this);
- signature.append_keyword ("is");
- write_type (expr.type_reference);
- }
-
- /**
- * { inheritDoc}
- */
- public override void visit_method_call (Vala.MethodCall expr) {
- // symbol-name:
- expr.call.symbol_reference.accept (this);
-
- // parameters:
- signature.append (" (", false);
- bool first = true;
- foreach (Vala.Expression literal in expr.get_argument_list ()) {
- if (!first) {
- signature.append (", ", false);
- }
-
- literal.accept (this);
- first = false;
- }
- signature.append (")", false);
- }
-
- /**
- * { inheritDoc}
- */
- public override void visit_slice_expression (Vala.SliceExpression expr) {
- expr.container.accept (this);
- signature.append ("[", false);
- expr.start.accept (this);
- signature.append (":", false);
- expr.stop.accept (this);
- signature.append ("]", false);
- }
-
- /**
- * { inheritDoc}
- */
- public override void visit_base_access (Vala.BaseAccess expr) {
- signature.append_keyword ("base", false);
- }
-
- /**
- * { inheritDoc}
- */
- public override void visit_postfix_expression (Vala.PostfixExpression expr) {
- expr.inner.accept (this);
- if (expr.increment) {
- signature.append ("++", false);
- } else {
- signature.append ("--", false);
- }
- }
-
- /**
- * { inheritDoc}
- */
- public override void visit_object_creation_expression (Vala.ObjectCreationExpression expr) {
- if (!expr.struct_creation) {
- signature.append_keyword ("new");
- }
-
- signature.append_symbol (root.search_vala_symbol (expr.symbol_reference));
-
- signature.append (" (", false);
-
- //TODO: rm conditional space
- bool first = true;
- foreach (Vala.Expression arg in expr.get_argument_list ()) {
- if (!first) {
- signature.append (", ", false);
- }
- arg.accept (this);
- first = false;
- }
-
- signature.append (")", false);
- }
-
- /**
- * { inheritDoc}
- */
- public override void visit_sizeof_expression (Vala.SizeofExpression expr) {
- signature.append_keyword ("sizeof", false).append (" (", false);
- write_type (expr.type_reference);
- signature.append (")", false);
- }
-
- /**
- * { inheritDoc}
- */
- public override void visit_typeof_expression (Vala.TypeofExpression expr) {
- signature.append_keyword ("typeof", false).append (" (", false);
- write_type (expr.type_reference);
- signature.append (")", false);
- }
-
- /**
- * { inheritDoc}
- */
- public override void visit_lambda_expression (Vala.LambdaExpression expr) {
- signature.append ("(", false);
-
- bool first = true;
- foreach (Vala.Parameter param in expr.get_parameters ()) {
- if (!first) {
- signature.append (", ", false);
- }
- signature.append (param.name, false);
- first = false;
- }
-
- var run = new Run (Run.Style.ITALIC);
- run.content.add (new Text (" [...] "));
-
- signature.append (") => {", false);
- signature.append_content (run, false);
- signature.append ("}", false);
- }
-
-
-
- /**
- * { inheritDoc}
- */
- public override void visit_boolean_literal (Vala.BooleanLiteral lit) {
- signature.append_literal (lit.to_string (), false);
- }
-
- /**
- * { inheritDoc}
- */
- public override void visit_character_literal (Vala.CharacterLiteral lit) {
- signature.append_literal (lit.to_string (), false);
- }
-
- /**
- * { inheritDoc}
- */
- public override void visit_integer_literal (Vala.IntegerLiteral lit) {
- signature.append_literal (lit.to_string (), false);
- }
-
- /**
- * { inheritDoc}
- */
- public override void visit_real_literal (Vala.RealLiteral lit) {
- signature.append_literal (lit.to_string (), false);
- }
-
- /**
- * { inheritDoc}
- */
- public override void visit_regex_literal (Vala.RegexLiteral lit) {
- signature.append_literal (lit.to_string (), false);
- }
-
- /**
- * { inheritDoc}
- */
- public override void visit_string_literal (Vala.StringLiteral lit) {
- signature.append_literal (lit.to_string (), false);
- }
-
- /**
- * { inheritDoc}
- */
- public override void visit_list_literal (Vala.ListLiteral lit) {
- signature.append_literal (lit.to_string (), false);
- }
-
- /**
- * { inheritDoc}
- */
- public override void visit_null_literal (Vala.NullLiteral lit) {
- signature.append_literal (lit.to_string (), false);
- }
-
-
-
- /**
- * { inheritDoc}
- */
- public override void visit_field (Vala.Field field) {
- write_node (field);
- }
-
- /**
- * { inheritDoc}
- */
- public override void visit_constant (Vala.Constant constant) {
- write_node (constant);
- }
-
- /**
- * { inheritDoc}
- */
- public override void visit_enum_value (Vala.EnumValue ev) {
- write_node (ev);
- }
-
- /**
- * { inheritDoc}
- */
- public override void visit_error_code (Vala.ErrorCode ec) {
- write_node (ec);
- }
-
- /**
- * { inheritDoc}
- */
- public override void visit_delegate (Vala.Delegate d) {
- write_node (d);
- }
-
- /**
- * { inheritDoc}
- */
- public override void visit_method (Vala.Method m) {
- write_node (m);
- }
-
- /**
- * { inheritDoc}
- */
- public override void visit_creation_method (Vala.CreationMethod m) {
- write_node (m);
- }
-
- /**
- * { inheritDoc}
- */
- public override void visit_signal (Vala.Signal sig) {
- write_node (sig);
- }
-
- /**
- * { inheritDoc}
- */
- public override void visit_class (Vala.Class c) {
- write_node (c);
- }
-
- /**
- * { inheritDoc}
- */
- public override void visit_struct (Vala.Struct s) {
- write_node (s);
- }
-
- /**
- * { inheritDoc}
- */
- public override void visit_interface (Vala.Interface i) {
- write_node (i);
- }
-
- /**
- * { inheritDoc}
- */
- public override void visit_enum (Vala.Enum en) {
- write_node (en);
- }
-
- /**
- * { inheritDoc}
- */
- public override void visit_error_domain (Vala.ErrorDomain ed) {
- write_node (ed);
- }
-
- /**
- * { inheritDoc}
- */
- public override void visit_property (Vala.Property prop) {
- write_node (prop);
- }
- }
-
- /**
- * { inheritDoc}
- */
protected override Inline build_signature () {
var signature = new SignatureBuilder ();
@@ -770,9 +121,7 @@ public class Valadoc.Api.FormalParameter : Symbol {
if (has_default_value) {
signature.append ("=");
-
- var inbuilder = new InitializerBuilder (signature, root);
- ((Vala.Parameter) symbol).initializer.accept (inbuilder);
+ signature.append_content (default_value);
}
}
diff --git a/src/libvaladoc/api/formalparametertype.vala b/src/libvaladoc/api/formalparametertype.vala
new file mode 100644
index 0000000..d95cc0f
--- /dev/null
+++ b/src/libvaladoc/api/formalparametertype.vala
@@ -0,0 +1,44 @@
+/* formalparametertype.vala
+ *
+ * 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:
+ * Florian Brosch <flo brosch gmail com>
+ */
+
+public enum Valadoc.Api.FormalParameterType {
+ IN,
+ OUT,
+ REF;
+
+ public string to_string () {
+ switch (this) {
+ case FormalParameterType.OUT:
+ return "out";
+
+ case FormalParameterType.REF:
+ return "ref";
+
+ case FormalParameterType.IN:
+ return "";
+
+ }
+
+ assert_not_reached ();
+ }
+}
+
diff --git a/src/libvaladoc/api/initializerbuilder.vala b/src/libvaladoc/api/initializerbuilder.vala
new file mode 100644
index 0000000..3f580e1
--- /dev/null
+++ b/src/libvaladoc/api/initializerbuilder.vala
@@ -0,0 +1,678 @@
+/* initializerbuilder.vala
+ *
+ * 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:
+ * Florian Brosch <flo brosch gmail com>
+ */
+
+
+using Valadoc.Content;
+using Gee;
+
+
+private class Valadoc.Api.InitializerBuilder : Vala.CodeVisitor {
+ private HashMap<Vala.Symbol, Symbol> symbol_map;
+ private SignatureBuilder signature;
+
+ private Symbol? resolve (Vala.Symbol symbol) {
+ return symbol_map.get (symbol);
+ }
+
+ private void write_node (Vala.Symbol vsymbol) {
+ signature.append_symbol (resolve (vsymbol));
+ }
+
+ private void write_type (Vala.DataType vsymbol) {
+ if (vsymbol.data_type != null) {
+ write_node (vsymbol.data_type);
+ } else {
+ signature.append_literal ("null");
+ }
+
+ var type_args = vsymbol.get_type_arguments ();
+ if (type_args.size > 0) {
+ signature.append ("<");
+ bool first = true;
+ foreach (Vala.DataType type_arg in type_args) {
+ if (!first) {
+ signature.append (",");
+ } else {
+ first = false;
+ }
+ if (!type_arg.value_owned) {
+ signature.append_keyword ("weak");
+ }
+ signature.append (type_arg.to_qualified_string (null));
+ }
+ signature.append (">");
+ }
+
+ if (vsymbol.nullable) {
+ signature.append ("?");
+ }
+ }
+
+ /**
+ * { inheritDoc}
+ */
+ public override void visit_array_creation_expression (Vala.ArrayCreationExpression expr) {
+ signature.append_keyword ("new");
+ write_type (expr.element_type);
+ signature.append ("[", false);
+
+ bool first = true;
+ foreach (Vala.Expression size in expr.get_sizes ()) {
+ if (!first) {
+ signature.append (", ", false);
+ }
+ size.accept (this);
+ first = false;
+ }
+
+ signature.append ("]", false);
+
+ if (expr.initializer_list != null) {
+ signature.append (" ", false);
+ expr.initializer_list.accept (this);
+ }
+ }
+
+ public InitializerBuilder (SignatureBuilder signature, HashMap<Vala.Symbol, Symbol> symbol_map) {
+ this.symbol_map = symbol_map;
+ this.signature = signature;
+ }
+
+ /**
+ * { inheritDoc}
+ */
+ public override void visit_binary_expression (Vala.BinaryExpression expr) {
+ expr.left.accept (this);
+
+ switch (expr.operator) {
+ case Vala.BinaryOperator.PLUS:
+ signature.append ("+ ");
+ break;
+
+ case Vala.BinaryOperator.MINUS:
+ signature.append ("- ");
+ break;
+
+ case Vala.BinaryOperator.MUL:
+ signature.append ("* ");
+ break;
+
+ case Vala.BinaryOperator.DIV:
+ signature.append ("/ ");
+ break;
+
+ case Vala.BinaryOperator.MOD:
+ signature.append ("% ");
+ break;
+
+ case Vala.BinaryOperator.SHIFT_LEFT:
+ signature.append ("<< ");
+ break;
+
+ case Vala.BinaryOperator.SHIFT_RIGHT:
+ signature.append (">> ");
+ break;
+
+ case Vala.BinaryOperator.LESS_THAN:
+ signature.append ("< ");
+ break;
+
+ case Vala.BinaryOperator.GREATER_THAN:
+ signature.append ("> ");
+ break;
+
+ case Vala.BinaryOperator.LESS_THAN_OR_EQUAL:
+ signature.append ("<= ");
+ break;
+
+ case Vala.BinaryOperator.GREATER_THAN_OR_EQUAL:
+ signature.append (">= ");
+ break;
+
+ case Vala.BinaryOperator.EQUALITY:
+ signature.append ("== ");
+ break;
+
+ case Vala.BinaryOperator.INEQUALITY:
+ signature.append ("!= ");
+ break;
+
+ case Vala.BinaryOperator.BITWISE_AND:
+ signature.append ("& ");
+ break;
+
+ case Vala.BinaryOperator.BITWISE_OR:
+ signature.append ("| ");
+ break;
+
+ case Vala.BinaryOperator.BITWISE_XOR:
+ signature.append ("^ ");
+ break;
+
+ case Vala.BinaryOperator.AND:
+ signature.append ("&& ");
+ break;
+
+ case Vala.BinaryOperator.OR:
+ signature.append ("|| ");
+ break;
+
+ case Vala.BinaryOperator.IN:
+ signature.append_keyword ("in");
+ signature.append (" ");
+ break;
+
+ case Vala.BinaryOperator.COALESCE:
+ signature.append ("?? ");
+ break;
+
+ default:
+ assert_not_reached ();
+ }
+
+ expr.right.accept (this);
+ }
+
+ /**
+ * { inheritDoc}
+ */
+ public override void visit_unary_expression (Vala.UnaryExpression expr) {
+ switch (expr.operator) {
+ case Vala.UnaryOperator.PLUS:
+ signature.append ("+");
+ break;
+
+ case Vala.UnaryOperator.MINUS:
+ signature.append ("-");
+ break;
+
+ case Vala.UnaryOperator.LOGICAL_NEGATION:
+ signature.append ("!");
+ break;
+
+ case Vala.UnaryOperator.BITWISE_COMPLEMENT:
+ signature.append ("~");
+ break;
+
+ case Vala.UnaryOperator.INCREMENT:
+ signature.append ("++");
+ break;
+
+ case Vala.UnaryOperator.DECREMENT:
+ signature.append ("--");
+ break;
+
+ case Vala.UnaryOperator.REF:
+ signature.append_keyword ("ref");
+ break;
+
+ case Vala.UnaryOperator.OUT:
+ signature.append_keyword ("out");
+ break;
+
+ default:
+ assert_not_reached ();
+ }
+ expr.inner.accept (this);
+ }
+
+ /**
+ * { inheritDoc}
+ */
+ public override void visit_assignment (Vala.Assignment a) {
+ a.left.accept (this);
+
+ switch (a.operator) {
+ case Vala.AssignmentOperator.SIMPLE:
+ signature.append ("=");
+ break;
+
+ case Vala.AssignmentOperator.BITWISE_OR:
+ signature.append ("|");
+ break;
+
+ case Vala.AssignmentOperator.BITWISE_AND:
+ signature.append ("&");
+ break;
+
+ case Vala.AssignmentOperator.BITWISE_XOR:
+ signature.append ("^");
+ break;
+
+ case Vala.AssignmentOperator.ADD:
+ signature.append ("+");
+ break;
+
+ case Vala.AssignmentOperator.SUB:
+ signature.append ("-");
+ break;
+
+ case Vala.AssignmentOperator.MUL:
+ signature.append ("*");
+ break;
+
+ case Vala.AssignmentOperator.DIV:
+ signature.append ("/");
+ break;
+
+ case Vala.AssignmentOperator.PERCENT:
+ signature.append ("%");
+ break;
+
+ case Vala.AssignmentOperator.SHIFT_LEFT:
+ signature.append ("<<");
+ break;
+
+ case Vala.AssignmentOperator.SHIFT_RIGHT:
+ signature.append (">>");
+ break;
+
+ default:
+ assert_not_reached ();
+ }
+
+ a.right.accept (this);
+ }
+
+ /**
+ * { inheritDoc}
+ */
+ public override void visit_cast_expression (Vala.CastExpression expr) {
+ if (expr.is_non_null_cast) {
+ signature.append ("(!)");
+ expr.inner.accept (this);
+ return;
+ }
+
+ if (!expr.is_silent_cast) {
+ signature.append ("(", false);
+ write_type (expr.type_reference);
+ signature.append (")", false);
+ }
+
+ expr.inner.accept (this);
+
+ if (expr.is_silent_cast) {
+ signature.append_keyword ("as");
+ write_type (expr.type_reference);
+ }
+ }
+
+ /**
+ * { inheritDoc}
+ */
+ public override void visit_initializer_list (Vala.InitializerList list) {
+ signature.append ("{", false);
+
+ bool first = true;
+ foreach (Vala.Expression initializer in list.get_initializers ()) {
+ if (!first) {
+ signature.append (", ", false);
+ }
+ first = false;
+ initializer.accept (this);
+ }
+
+ signature.append ("}", false);
+ }
+
+ /**
+ * { inheritDoc}
+ */
+ public override void visit_member_access (Vala.MemberAccess expr) {
+ if (expr.symbol_reference != null) {
+ expr.symbol_reference.accept (this);
+ } else {
+ signature.append (expr.member_name);
+ }
+ }
+
+ /**
+ * { inheritDoc}
+ */
+ public override void visit_element_access (Vala.ElementAccess expr) {
+ expr.container.accept (this);
+ signature.append ("[", false);
+
+ bool first = true;
+ foreach (Vala.Expression index in expr.get_indices ()) {
+ if (!first) {
+ signature.append (", ", false);
+ }
+ first = false;
+
+ index.accept (this);
+ }
+
+ signature.append ("]", false);
+ }
+
+ /**
+ * { inheritDoc}
+ */
+ public override void visit_pointer_indirection (Vala.PointerIndirection expr) {
+ signature.append ("*", false);
+ expr.inner.accept (this);
+ }
+
+ /**
+ * { inheritDoc}
+ */
+ public override void visit_addressof_expression (Vala.AddressofExpression expr) {
+ signature.append ("&", false);
+ expr.inner.accept (this);
+ }
+
+ /**
+ * { inheritDoc}
+ */
+ public override void visit_reference_transfer_expression (Vala.ReferenceTransferExpression expr) {
+ signature.append ("(", false).append_keyword ("owned", false).append (")", false);
+ expr.inner.accept (this);
+ }
+
+ /**
+ * { inheritDoc}
+ */
+ public override void visit_type_check (Vala.TypeCheck expr) {
+ expr.expression.accept (this);
+ signature.append_keyword ("is");
+ write_type (expr.type_reference);
+ }
+
+ /**
+ * { inheritDoc}
+ */
+ public override void visit_method_call (Vala.MethodCall expr) {
+ // symbol-name:
+ expr.call.symbol_reference.accept (this);
+
+ // parameters:
+ signature.append (" (", false);
+ bool first = true;
+ foreach (Vala.Expression literal in expr.get_argument_list ()) {
+ if (!first) {
+ signature.append (", ", false);
+ }
+
+ literal.accept (this);
+ first = false;
+ }
+ signature.append (")", false);
+ }
+
+ /**
+ * { inheritDoc}
+ */
+ public override void visit_slice_expression (Vala.SliceExpression expr) {
+ expr.container.accept (this);
+ signature.append ("[", false);
+ expr.start.accept (this);
+ signature.append (":", false);
+ expr.stop.accept (this);
+ signature.append ("]", false);
+ }
+
+ /**
+ * { inheritDoc}
+ */
+ public override void visit_base_access (Vala.BaseAccess expr) {
+ signature.append_keyword ("base", false);
+ }
+
+ /**
+ * { inheritDoc}
+ */
+ public override void visit_postfix_expression (Vala.PostfixExpression expr) {
+ expr.inner.accept (this);
+ if (expr.increment) {
+ signature.append ("++", false);
+ } else {
+ signature.append ("--", false);
+ }
+ }
+
+ /**
+ * { inheritDoc}
+ */
+ public override void visit_object_creation_expression (Vala.ObjectCreationExpression expr) {
+ if (!expr.struct_creation) {
+ signature.append_keyword ("new");
+ }
+
+ signature.append_symbol (resolve (expr.symbol_reference));
+
+ signature.append (" (", false);
+
+ //TODO: rm conditional space
+ bool first = true;
+ foreach (Vala.Expression arg in expr.get_argument_list ()) {
+ if (!first) {
+ signature.append (", ", false);
+ }
+ arg.accept (this);
+ first = false;
+ }
+
+ signature.append (")", false);
+ }
+
+ /**
+ * { inheritDoc}
+ */
+ public override void visit_sizeof_expression (Vala.SizeofExpression expr) {
+ signature.append_keyword ("sizeof", false).append (" (", false);
+ write_type (expr.type_reference);
+ signature.append (")", false);
+ }
+
+ /**
+ * { inheritDoc}
+ */
+ public override void visit_typeof_expression (Vala.TypeofExpression expr) {
+ signature.append_keyword ("typeof", false).append (" (", false);
+ write_type (expr.type_reference);
+ signature.append (")", false);
+ }
+
+ /**
+ * { inheritDoc}
+ */
+ public override void visit_lambda_expression (Vala.LambdaExpression expr) {
+ signature.append ("(", false);
+
+ bool first = true;
+ foreach (Vala.Parameter param in expr.get_parameters ()) {
+ if (!first) {
+ signature.append (", ", false);
+ }
+ signature.append (param.name, false);
+ first = false;
+ }
+
+ var run = new Run (Run.Style.ITALIC);
+ run.content.add (new Text (" [...] "));
+
+ signature.append (") => {", false);
+ signature.append_content (run, false);
+ signature.append ("}", false);
+ }
+
+
+
+ /**
+ * { inheritDoc}
+ */
+ public override void visit_boolean_literal (Vala.BooleanLiteral lit) {
+ signature.append_literal (lit.to_string (), false);
+ }
+
+ /**
+ * { inheritDoc}
+ */
+ public override void visit_character_literal (Vala.CharacterLiteral lit) {
+ signature.append_literal (lit.to_string (), false);
+ }
+
+ /**
+ * { inheritDoc}
+ */
+ public override void visit_integer_literal (Vala.IntegerLiteral lit) {
+ signature.append_literal (lit.to_string (), false);
+ }
+
+ /**
+ * { inheritDoc}
+ */
+ public override void visit_real_literal (Vala.RealLiteral lit) {
+ signature.append_literal (lit.to_string (), false);
+ }
+
+ /**
+ * { inheritDoc}
+ */
+ public override void visit_regex_literal (Vala.RegexLiteral lit) {
+ signature.append_literal (lit.to_string (), false);
+ }
+
+ /**
+ * { inheritDoc}
+ */
+ public override void visit_string_literal (Vala.StringLiteral lit) {
+ signature.append_literal (lit.to_string (), false);
+ }
+
+ /**
+ * { inheritDoc}
+ */
+ public override void visit_list_literal (Vala.ListLiteral lit) {
+ signature.append_literal (lit.to_string (), false);
+ }
+
+ /**
+ * { inheritDoc}
+ */
+ public override void visit_null_literal (Vala.NullLiteral lit) {
+ signature.append_literal (lit.to_string (), false);
+ }
+
+
+
+ /**
+ * { inheritDoc}
+ */
+ public override void visit_field (Vala.Field field) {
+ write_node (field);
+ }
+
+ /**
+ * { inheritDoc}
+ */
+ public override void visit_constant (Vala.Constant constant) {
+ write_node (constant);
+ }
+
+ /**
+ * { inheritDoc}
+ */
+ public override void visit_enum_value (Vala.EnumValue ev) {
+ write_node (ev);
+ }
+
+ /**
+ * { inheritDoc}
+ */
+ public override void visit_error_code (Vala.ErrorCode ec) {
+ write_node (ec);
+ }
+
+ /**
+ * { inheritDoc}
+ */
+ public override void visit_delegate (Vala.Delegate d) {
+ write_node (d);
+ }
+
+ /**
+ * { inheritDoc}
+ */
+ public override void visit_method (Vala.Method m) {
+ write_node (m);
+ }
+
+ /**
+ * { inheritDoc}
+ */
+ public override void visit_creation_method (Vala.CreationMethod m) {
+ write_node (m);
+ }
+
+ /**
+ * { inheritDoc}
+ */
+ public override void visit_signal (Vala.Signal sig) {
+ write_node (sig);
+ }
+
+ /**
+ * { inheritDoc}
+ */
+ public override void visit_class (Vala.Class c) {
+ write_node (c);
+ }
+
+ /**
+ * { inheritDoc}
+ */
+ public override void visit_struct (Vala.Struct s) {
+ write_node (s);
+ }
+
+ /**
+ * { inheritDoc}
+ */
+ public override void visit_interface (Vala.Interface i) {
+ write_node (i);
+ }
+
+ /**
+ * { inheritDoc}
+ */
+ public override void visit_enum (Vala.Enum en) {
+ write_node (en);
+ }
+
+ /**
+ * { inheritDoc}
+ */
+ public override void visit_error_domain (Vala.ErrorDomain ed) {
+ write_node (ed);
+ }
+
+ /**
+ * { inheritDoc}
+ */
+ public override void visit_property (Vala.Property prop) {
+ write_node (prop);
+ }
+}
+
diff --git a/src/libvaladoc/api/interface.vala b/src/libvaladoc/api/interface.vala
index 087ff5c..236b14d 100755
--- a/src/libvaladoc/api/interface.vala
+++ b/src/libvaladoc/api/interface.vala
@@ -1,6 +1,6 @@
/* interface.vala
*
- * Copyright (C) 2008 Florian Brosch
+ * Copyright (C) 2008-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
@@ -29,8 +29,14 @@ using Valadoc.Content;
* Represents a interface declaration in the source code.
*/
public class Valadoc.Api.Interface : TypeSymbol {
- public Interface (Vala.Interface symbol, Node parent) {
- base (symbol, parent);
+ private string? dbus_name;
+ private string? cname;
+
+ public Interface (Node parent, SourceFile file, string name, SymbolAccessibility accessibility, SourceComment? comment, string? cname, string? dbus_name, void* data) {
+ base (parent, file, name, accessibility, comment, false, data);
+
+ this.dbus_name = dbus_name;
+ this.cname = cname;
}
/**
@@ -39,6 +45,13 @@ public class Valadoc.Api.Interface : TypeSymbol {
private ArrayList<TypeReference> interfaces = new ArrayList<TypeReference> ();
/**
+ * Add a newpreconditioned interface to the list
+ */
+ public void add_interface (TypeReference iface) {
+ interfaces.add (iface);
+ }
+
+ /**
* Returns a list of newly preconditioned interfaces
*/
public Collection<TypeReference> get_implemented_interface_list () {
@@ -71,25 +84,30 @@ public class Valadoc.Api.Interface : TypeSymbol {
* Returns the name of this interface as it is used in C.
*/
public string? get_cname () {
- return ((Vala.Interface) symbol).get_cname ();
+ return cname;
}
/**
* Returns the dbus-name.
*/
public string? get_dbus_name () {
- return Vala.GDBusModule.get_dbus_name ((Vala.TypeSymbol) symbol);
+ return dbus_name;
}
/**
* A preconditioned class or null
*/
- public TypeReference? base_type { private set; get; }
+ public TypeReference? base_type {
+ set;
+ get;
+ }
/**
* { inheritDoc}
*/
- public override NodeType node_type { get { return NodeType.INTERFACE; } }
+ public override NodeType node_type {
+ get { return NodeType.INTERFACE; }
+ }
/**
* { inheritDoc}
@@ -98,23 +116,6 @@ public class Valadoc.Api.Interface : TypeSymbol {
visitor.visit_interface (this);
}
- private void set_prerequisites (Tree root, Vala.Collection<Vala.DataType> lst) {
- if (this.interfaces.size != 0) {
- return;
- }
-
- foreach (Vala.DataType vtyperef in lst) {
- var inherited = new TypeReference (vtyperef, this);
- inherited.resolve_type_references (root);
-
- if (inherited.data_type is Class) {
- this.base_type = inherited;
- } else {
- this.interfaces.add (inherited);
- }
- }
- }
-
/**
* A list of all known related (sub-)interfaces
*/
@@ -150,31 +151,6 @@ public class Valadoc.Api.Interface : TypeSymbol {
/**
* { inheritDoc}
*/
- internal override void resolve_children (Tree root) {
- if (base_type != null) {
- ((Class) this.base_type.data_type).register_derived_interface (this);
- }
-
- foreach (var iface in get_all_implemented_interface_list ()) {
- ((Interface) iface.data_type).register_related_interface (this);
- }
-
- base.resolve_children (root);
- }
-
- /**
- * { inheritDoc}
- */
- internal override void resolve_type_references (Tree root) {
- var prerequisites = ((Vala.Interface) symbol).get_prerequisites ();
- this.set_prerequisites (root, prerequisites);
-
- base.resolve_type_references (root);
- }
-
- /**
- * { inheritDoc}
- */
protected override Inline build_signature () {
var signature = new SignatureBuilder ();
diff --git a/src/libvaladoc/api/item.vala b/src/libvaladoc/api/item.vala
index 627d759..1253623 100755
--- a/src/libvaladoc/api/item.vala
+++ b/src/libvaladoc/api/item.vala
@@ -30,15 +30,21 @@ using Gee;
public abstract class Valadoc.Api.Item : Object {
private Inline _signature;
+ public void* data {
+ private set;
+ get;
+ }
+
/**
* The parent of this item.
*/
- public Item parent { protected set; get; }
-
- internal virtual void resolve_type_references (Tree root) {
+ public Item parent {
+ protected set;
+ get;
}
- internal virtual void resolve_children (Tree root) {
+ public Item (void* data) {
+ this.data = data;
}
internal virtual void process_comments (Settings settings, DocumentationParser parser) {
diff --git a/src/libvaladoc/api/member.vala b/src/libvaladoc/api/member.vala
index e15d62f..77df1b7 100755
--- a/src/libvaladoc/api/member.vala
+++ b/src/libvaladoc/api/member.vala
@@ -1,6 +1,7 @@
/* member.vala
*
* Copyright (C) 2008-2009 Florian Brosch, Didier Villevalois
+ * 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
@@ -23,13 +24,15 @@
using Gee;
public abstract class Valadoc.Api.Member : Symbol {
+ private SourceComment? source_comment;
- public Member (Vala.Symbol symbol, Node parent) {
- base (symbol, parent);
+ public Member (Node parent, SourceFile file, string name, SymbolAccessibility accessibility, SourceComment? comment, void* data) {
+ base (parent, file, name, accessibility, data);
+
+ this.source_comment = comment;
}
internal override void process_comments (Settings settings, DocumentationParser parser) {
- var source_comment = symbol.comment;
if (source_comment != null) {
documentation = parser.parse (this, source_comment);
}
diff --git a/src/libvaladoc/api/method.vala b/src/libvaladoc/api/method.vala
index f09230e..c71360c 100755
--- a/src/libvaladoc/api/method.vala
+++ b/src/libvaladoc/api/method.vala
@@ -1,6 +1,6 @@
/* method.vala
*
- * Copyright (C) 2008 Florian Brosch
+ * Copyright (C) 2008-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
@@ -28,55 +28,76 @@ using Valadoc.Content;
* Represents a function or a method.
*/
public class Valadoc.Api.Method : Member {
- public Method (Vala.Method symbol, Node parent) {
- base (symbol, parent);
- return_type = new TypeReference (symbol.return_type, this);
+ private string? finish_function_cname;
+ private string? dbus_result_name;
+ private string? dbus_name;
+ private string? cname;
+
+ private MethodBindingType binding_type;
+
+ public Method (Node parent, SourceFile file, string name, SymbolAccessibility accessibility, SourceComment? comment, string? cname, string? dbus_name, string? dbus_result_name, string? finish_function_cname, MethodBindingType binding_type, bool is_yields, bool is_dbus_visible, bool is_constructor, void* data) {
+ base (parent, file, name, accessibility, comment, data);
+
+ this.finish_function_cname = finish_function_cname;
+ this.dbus_result_name = dbus_result_name;
+ this.dbus_name = dbus_name;
+ this.cname = cname;
+
+ this.binding_type = binding_type;
+ this.is_dbus_visible = is_dbus_visible;
+ this.is_constructor = is_constructor;
+ this.is_yields = is_yields;
}
/**
* Returns the name of this method as it is used in C.
*/
public string? get_cname () {
- return ((Vala.Method) symbol).get_cname ();
+ return cname;
}
/**
* Returns the name of the finish function as it is used in C.
*/
public string? get_finish_function_cname () {
- return ((Vala.Method) symbol).get_finish_cname ();
+ return finish_function_cname;
}
/**
* Returns the dbus-name.
*/
public string get_dbus_name () {
- return Vala.GDBusModule.get_dbus_name_for_member (symbol);
+ return dbus_name;
}
public string get_dbus_result_name () {
- return Vala.GDBusServerModule.dbus_result_name ((Vala.Method) symbol);
+ return dbus_result_name;
}
/**
* Specifies the virtual or abstract method this method overrides.
*/
- public Method? base_method { private set; get; }
+ public Method? base_method {
+ set;
+ get;
+ }
/**
* The return type of this method.
*
* @return The return type of this method or null for void
*/
- public TypeReference? return_type { private set; get; }
+ public TypeReference? return_type {
+ set;
+ get;
+ }
/**
* Specifies whether this method is asynchronous
*/
public bool is_yields {
- get {
- return ((Vala.Method) symbol).coroutine;
- }
+ private set;
+ get;
}
/**
@@ -84,7 +105,7 @@ public class Valadoc.Api.Method : Member {
*/
public bool is_abstract {
get {
- return ((Vala.Method) symbol).is_abstract;
+ return binding_type == MethodBindingType.ABSTRACT;
}
}
@@ -93,7 +114,7 @@ public class Valadoc.Api.Method : Member {
*/
public bool is_virtual {
get {
- return ((Vala.Method) symbol).is_virtual;
+ return binding_type == MethodBindingType.VIRTUAL;
}
}
@@ -102,7 +123,7 @@ public class Valadoc.Api.Method : Member {
*/
public bool is_override {
get {
- return ((Vala.Method) symbol).overrides;
+ return binding_type == MethodBindingType.OVERRIDE;
}
}
@@ -111,10 +132,7 @@ public class Valadoc.Api.Method : Member {
*/
public bool is_static {
get {
- if (is_constructor) {
- return false;
- }
- return ((Vala.Method) symbol).binding == Vala.MemberBinding.STATIC;
+ return !is_constructor && binding_type == MethodBindingType.STATIC;
}
}
@@ -122,9 +140,8 @@ public class Valadoc.Api.Method : Member {
* Specifies whether this method is a creation method
*/
public bool is_constructor {
- get {
- return symbol is Vala.CreationMethod;
- }
+ private set;
+ get;
}
/**
@@ -132,7 +149,7 @@ public class Valadoc.Api.Method : Member {
*/
public bool is_inline {
get {
- return ((Vala.Method) symbol).is_inline;
+ return binding_type == MethodBindingType.INLINE;
}
}
@@ -140,51 +157,8 @@ public class Valadoc.Api.Method : Member {
* Specifies whether this method is visible for dbus
*/
public bool is_dbus_visible {
- get {
- return Vala.GDBusServerModule.is_dbus_visible (symbol);
- }
- }
-
- /**
- * { inheritDoc}
- */
- public override string? name {
- owned get {
- if (this.is_constructor) {
- if (symbol.name == ".new") {
- return ((Node) parent).name;
- } else {
- return ((Node) parent).name + "." + symbol.name;
- }
- }
- else {
- return symbol.name;
- }
- }
- }
-
- /**
- * { inheritDoc}
- */
- internal override void resolve_type_references (Tree root) {
- Vala.Method vala_method = symbol as Vala.Method;
- Vala.Method? base_vala_method = null;
- if (vala_method.base_method != null) {
- base_vala_method = vala_method.base_method;
- } else if (vala_method.base_interface_method != null) {
- base_vala_method = vala_method.base_interface_method;
- }
- if (base_vala_method == vala_method
- && vala_method.base_interface_method != null) {
- base_vala_method = vala_method.base_interface_method;
- }
- if (base_vala_method != null) {
- this.base_method = (Method?) root.search_vala_symbol (base_vala_method);
- }
-
- return_type.resolve_type_references (root);
-
- base.resolve_type_references (root);
+ private set;
+ get;
}
/**
diff --git a/src/libvaladoc/api/methodbindingtype.vala b/src/libvaladoc/api/methodbindingtype.vala
new file mode 100644
index 0000000..c340c30
--- /dev/null
+++ b/src/libvaladoc/api/methodbindingtype.vala
@@ -0,0 +1,55 @@
+/* methodbindingtype.vala
+ *
+ * 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:
+ * Brosch Florian <flo brosch gmail com>
+ */
+
+
+public enum Valadoc.MethodBindingType {
+ UNMODIFIED,
+ OVERRIDE,
+ ABSTRACT,
+ VIRTUAL,
+ INLINE,
+ STATIC;
+
+ public string to_string () {
+ switch (this) {
+ case OVERRIDE:
+ return "override";
+
+ case ABSTRACT:
+ return "abstract";
+
+ case VIRTUAL:
+ return "virtual";
+
+ case INLINE:
+ return "inline";
+
+ case STATIC:
+ return "static";
+
+ case UNMODIFIED:
+ return "";
+ }
+
+ assert_not_reached ();
+ }
+}
diff --git a/src/libvaladoc/api/namespace.vala b/src/libvaladoc/api/namespace.vala
index 0c2389e..0b9b346 100755
--- a/src/libvaladoc/api/namespace.vala
+++ b/src/libvaladoc/api/namespace.vala
@@ -1,6 +1,6 @@
/* namespace.vala
*
- * Copyright (C) 2008 Florian Brosch
+ * Copyright (C) 2008-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
@@ -28,19 +28,12 @@ using Valadoc.Content;
* Represents a namespace declaration.
*/
public class Valadoc.Api.Namespace : Symbol {
- private Vala.Comment source_comment;
+ private SourceComment? source_comment;
- public Namespace (Vala.Namespace symbol, Api.Node parent) {
- base (symbol, parent);
+ public Namespace (Api.Node parent, SourceFile file, string? name, SourceComment? comment, void* data) {
+ base (parent, file, name, SymbolAccessibility.PUBLIC, data);
- if (symbol.source_reference != null) {
- foreach (Vala.Comment c in symbol.get_comments()) {
- if (package.is_package_for_file (c.source_reference.file)) {
- source_comment = c;
- break;
- }
- }
- }
+ this.source_comment = comment;
}
/**
diff --git a/src/libvaladoc/api/node.vala b/src/libvaladoc/api/node.vala
index 0e4b49c..49671bc 100755
--- a/src/libvaladoc/api/node.vala
+++ b/src/libvaladoc/api/node.vala
@@ -1,6 +1,7 @@
/* node.vala
*
* Copyright (C) 2008-2009 Florian Brosch, Didier Villevalois
+ * Copyright (C) 20011 Florian Brosch
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
@@ -54,11 +55,19 @@ public enum Valadoc.Api.NodeType {
*/
public abstract class Valadoc.Api.Node : Item, Browsable, Documentation, Comparable<Node> {
protected bool do_document { private set; get; default = false; }
+ private SourceFile file;
/**
* The name of the node
*/
- public abstract string? name { owned get; }
+ public string? name {
+ private set;
+ get;
+ }
+
+ public SourceFile get_source_file () {
+ return file;
+ }
/**
* Returns the type of this node
@@ -66,15 +75,17 @@ public abstract class Valadoc.Api.Node : Item, Browsable, Documentation, Compara
public abstract NodeType node_type { get; }
private Map<string,Node> per_name_children;
- private Map<Vala.Symbol, Node> per_symbol_children;
private Map<NodeType?, Gee.List<Node>> per_type_children;
- public Node (Node? parent) {
- this.parent = parent;
+ public Node (Node? parent, SourceFile? file, string? name, void* data) {
+ base (data);
per_name_children = new HashMap<string,Node> ();
- per_symbol_children = new HashMap<Vala.Symbol, Node> ();
per_type_children = new HashMap<NodeType?, Gee.List<Node>> (int_hash, int_equal);
+
+ this.parent = parent;
+ this.name = name;
+ this.file = file;
}
/**
@@ -91,9 +102,16 @@ public abstract class Valadoc.Api.Node : Item, Browsable, Documentation, Compara
/**
* The corresponding file name
+ *
+ * @deprecated
*/
- public virtual string? get_filename () {
- return null;
+ //TODO: rm
+ public string? get_filename () {
+ if (file == null) {
+ return null;
+ }
+
+ return file.relative_path;
}
internal void add_child (Symbol child) {
@@ -104,8 +122,6 @@ public abstract class Valadoc.Api.Node : Item, Browsable, Documentation, Compara
per_name_children.set ("", child);
}
- per_symbol_children.set (child.symbol, child);
-
Gee.List<Node> children = per_type_children.get (child.node_type);
if (children == null) {
children = new ArrayList<Node> ();
@@ -118,52 +134,10 @@ public abstract class Valadoc.Api.Node : Item, Browsable, Documentation, Compara
/**
* { inheritDoc}
*/
- internal override void resolve_children (Tree root) {
- var list = per_type_children.get (NodeType.NAMESPACE);
- if (list != null) {
- foreach (Node node in list) {
- node.resolve_children (root);
- }
- }
-
- list = per_type_children.get (NodeType.STRUCT);
- if (list != null) {
- foreach (Node node in list) {
- node.resolve_children (root);
- }
- }
-
- list = per_type_children.get (NodeType.CLASS);
- if (list != null) {
- foreach (Node node in list) {
- node.resolve_children (root);
- }
- }
-
- list = per_type_children.get (NodeType.INTERFACE);
- if (list != null) {
- foreach (Node node in list) {
- node.resolve_children (root);
- }
- }
- }
-
- /**
- * { inheritDoc}
- */
- internal override void resolve_type_references (Tree root) {
- foreach (Node node in per_name_children.values) {
- node.resolve_type_references (root);
- }
- }
-
- /**
- * { inheritDoc}
- */
internal override void process_comments (Settings settings, DocumentationParser parser) {
do_document = true;
- foreach (Node node in per_symbol_children.values) {
+ foreach (Node node in per_name_children.values) {
if (node.is_browsable (settings)) {
node.process_comments (settings, parser);
}
@@ -281,10 +255,6 @@ public abstract class Valadoc.Api.Node : Item, Browsable, Documentation, Compara
return per_name_children.get (name);
}
- public Node? find_by_symbol (Vala.Symbol symbol) {
- return per_symbol_children.get (symbol);
- }
-
private Namespace? _nspace = null;
private Package? _package = null;
private string _full_name = null;
@@ -298,8 +268,9 @@ public abstract class Valadoc.Api.Node : Item, Browsable, Documentation, Compara
Api.Item ast = this;
while (ast is Valadoc.Api.Namespace == false) {
ast = ast.parent;
- if (ast == null)
+ if (ast == null) {
return null;
+ }
}
this._nspace = (Valadoc.Api.Namespace)ast;
}
@@ -316,10 +287,12 @@ public abstract class Valadoc.Api.Node : Item, Browsable, Documentation, Compara
Api.Item ast = this;
while (ast is Valadoc.Api.Package == false) {
ast = ast.parent;
- if (ast == null)
+ if (ast == null) {
return null;
+ }
}
- this._package = (Valadoc.Api.Package)ast; }
+ this._package = (Valadoc.Api.Package)ast;
+ }
return this._package;
}
}
@@ -334,8 +307,9 @@ public abstract class Valadoc.Api.Node : Item, Browsable, Documentation, Compara
*/
public string? get_full_name () {
if (this._full_name == null) {
- if (this.name == null)
+ if (this.name == null) {
return null;
+ }
GLib.StringBuilder full_name = new GLib.StringBuilder (this.name);
@@ -360,3 +334,4 @@ public abstract class Valadoc.Api.Node : Item, Browsable, Documentation, Compara
return strcmp (name, node.name);
}
}
+
diff --git a/src/libvaladoc/api/ownership.vala b/src/libvaladoc/api/ownership.vala
new file mode 100644
index 0000000..eb4f5b0
--- /dev/null
+++ b/src/libvaladoc/api/ownership.vala
@@ -0,0 +1,47 @@
+/* ownership.vala
+ *
+ * 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:
+ * Florian Brosch <flo brosch gmail com>
+ */
+
+
+public enum Valadoc.Api.Ownership {
+ DEFAULT,
+ UNOWNED,
+ OWNED,
+ WEAK;
+
+ public string to_string () {
+ switch (this) {
+ case Ownership.UNOWNED:
+ return "unowned";
+
+ case Ownership.OWNED:
+ return "owned";
+
+ case Ownership.WEAK:
+ return "weak";
+
+ case Ownership.DEFAULT:
+ return "";
+ }
+
+ assert_not_reached ();
+ }
+}
diff --git a/src/libvaladoc/api/package.vala b/src/libvaladoc/api/package.vala
index 8d2c62e..f89e152 100755
--- a/src/libvaladoc/api/package.vala
+++ b/src/libvaladoc/api/package.vala
@@ -1,6 +1,6 @@
/* package.vala
*
- * Copyright (C) 2008 Florian Brosch
+ * Copyright (C) 2008-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
@@ -25,12 +25,6 @@ using Valadoc.Content;
using Valadoc.Importer;
public class Valadoc.Api.Package : Node {
- private ArrayList<Vala.SourceFile> vfiles = new ArrayList<Vala.SourceFile> ();
-
- internal void add_file (Vala.SourceFile vfile) {
- this.vfiles.add (vfile);
- }
-
/**
* Specifies whether this package is a dependency
*/
@@ -70,7 +64,6 @@ public class Valadoc.Api.Package : Node {
return list.read_only_view;
}
- //TODO: rm
public Collection<Package> get_dependency_list () {
if (this._dependencies == null) {
return Collection.empty<Package> ();
@@ -79,31 +72,13 @@ public class Valadoc.Api.Package : Node {
return this._dependencies.read_only_view;
}
- public Package (Vala.SourceFile vfile, string name, bool is_package = false) {
- base (null);
- this.is_package = is_package;
+ public Package (Vala.SourceFile vfile, string name, bool is_package, void* data) {
+ base (null, null, name, data);
- this.package_name = name;
-
- this.vfiles.add (vfile);
+ this.is_package = is_package;
this.parent = null;
}
- private string package_name;
-
- /**
- * { inheritDoc}
- */
- public override string? name {
- owned get {
- return package_name;
- }
- }
-
- internal bool is_package_for_file (Vala.SourceFile source_file) {
- return this.vfiles.contains (source_file);
- }
-
/**
* { inheritDoc}
*/
@@ -114,7 +89,9 @@ public class Valadoc.Api.Package : Node {
/**
* { inheritDoc}
*/
- public override NodeType node_type { get { return NodeType.PACKAGE; } }
+ public override NodeType node_type {
+ get { return NodeType.PACKAGE; }
+ }
/**
* { inheritDoc}
@@ -132,35 +109,5 @@ public class Valadoc.Api.Package : Node {
.append (name)
.get ();
}
-
- internal Namespace get_namespace (Tree root, Vala.Symbol symbol) {
- Vala.Symbol namespace_symbol = symbol;
- while (!(namespace_symbol is Vala.Namespace)) {
- namespace_symbol = namespace_symbol.parent_symbol;
- }
-
- // Try to find it first
- var ns = (Namespace) root.search_vala_symbol_in (namespace_symbol, this);
- if (ns != null) {
- return ns;
- }
-
- // Find parent namespace and use it as parent if existing
- var parent_namespace_symbol = namespace_symbol.parent_symbol;
-
- if (parent_namespace_symbol != null) {
- ns = (Namespace) get_namespace (root, parent_namespace_symbol);
- if (ns != null) {
- var new_namespace = new Namespace ((Vala.Namespace) namespace_symbol, ns);
- ns.add_child (new_namespace);
- return new_namespace;
- }
- }
-
- // Else take this package as parent
- var new_namespace = new Namespace ((Vala.Namespace) namespace_symbol, this);
- add_child (new_namespace);
- return new_namespace;
- }
}
diff --git a/src/libvaladoc/api/pointer.vala b/src/libvaladoc/api/pointer.vala
index 1e4e149..aec541b 100755
--- a/src/libvaladoc/api/pointer.vala
+++ b/src/libvaladoc/api/pointer.vala
@@ -28,44 +28,19 @@ using Valadoc.Content;
* Represents a pointer declaration.
*/
public class Valadoc.Api.Pointer : Item {
- private Vala.PointerType vtype;
/**
* The type the pointer is referring to.
*/
public Item data_type {
- private set;
+ set;
get;
}
- public Pointer (Vala.PointerType vtyperef, Item parent) {
- this.vtype = vtyperef;
- this.parent = parent;
-
- Vala.DataType vntype = vtype.base_type;
- if (vntype is Vala.PointerType) {
- this.data_type = new Pointer ((Vala.PointerType) vntype, this);
- } else if (vntype is Vala.ArrayType) {
- this.data_type = new Array ((Vala.ArrayType) vntype, this);
- } else {
- this.data_type = new TypeReference (vntype, this);
- }
- }
+ public Pointer (Item parent, void* data) {
+ base (data);
- /**
- * { inheritDoc}
- */
- internal override void resolve_type_references (Tree root) {
- Api.Item type = this.data_type;
- if (type == null) {
- ;
- } else if (type is Array) {
- ((Array) type).resolve_type_references (root);
- } else if (type is Pointer) {
- ((Pointer) type ).resolve_type_references (root);
- } else {
- ((TypeReference) type).resolve_type_references (root);
- }
+ this.parent = parent;
}
/**
diff --git a/src/libvaladoc/api/property.vala b/src/libvaladoc/api/property.vala
index 06bebcd..3b6471f 100755
--- a/src/libvaladoc/api/property.vala
+++ b/src/libvaladoc/api/property.vala
@@ -1,6 +1,6 @@
/* property.vala
*
- * Copyright (C) 2008 Florian Brosch
+ * Copyright (C) 2008-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
@@ -28,32 +28,32 @@ using Valadoc.Content;
* Represents a property declaration.
*/
public class Valadoc.Api.Property : Member {
- public Property (Vala.Property symbol, Node parent) {
- base (symbol, parent);
+ private PropertyBindingType binding_type;
+ private string? dbus_name;
+ private string? cname;
- property_type = new TypeReference (symbol.property_type, this);
+ public Property (Node parent, SourceFile file, string name, SymbolAccessibility accessibility, SourceComment? comment, string? cname, string? dbus_name, bool is_dbus_visible, PropertyBindingType binding_type, void* data) {
+ base (parent, file, name, accessibility, comment, data);
- if (symbol.get_accessor != null) {
- this.getter = new PropertyAccessor (symbol.get_accessor, this);
- }
+ this.is_dbus_visible = is_dbus_visible;
+ this.binding_type = binding_type;
- if (symbol.set_accessor != null) {
- this.setter = new PropertyAccessor (symbol.set_accessor, this);
- }
+ this.dbus_name = dbus_name;
+ this.cname = cname;
}
/**
* Returns the name of this method as it is used in C.
*/
public string? get_cname () {
- return ((Vala.Property) symbol).nick;
+ return cname;
}
/**
* Returns the dbus-name.
*/
public string get_dbus_name () {
- return Vala.GDBusModule.get_dbus_name_for_member (symbol);
+ return dbus_name;
}
/**
@@ -61,14 +61,17 @@ public class Valadoc.Api.Property : Member {
*
* @return The property type or null for void
*/
- public TypeReference? property_type { private set; get;}
+ public TypeReference? property_type {
+ set;
+ get;
+ }
/**
* Specifies whether the property is virtual.
*/
public bool is_virtual {
get {
- return ((Vala.Property) symbol).is_virtual;
+ return binding_type == PropertyBindingType.VIRTUAL;
}
}
@@ -77,7 +80,7 @@ public class Valadoc.Api.Property : Member {
*/
public bool is_abstract {
get {
- return ((Vala.Property) symbol).is_abstract;
+ return binding_type == PropertyBindingType.ABSTRACT;
}
}
@@ -86,7 +89,7 @@ public class Valadoc.Api.Property : Member {
*/
public bool is_override {
get {
- return ((Vala.Property) symbol).overrides;
+ return binding_type == PropertyBindingType.OVERRIDE;
}
}
@@ -94,40 +97,26 @@ public class Valadoc.Api.Property : Member {
* Specifies whether the property is visible.
*/
public bool is_dbus_visible {
- get {
- return Vala.GDBusServerModule.is_dbus_visible (symbol);
- }
+ private set;
+ get;
}
- public PropertyAccessor setter { private set; get; }
+ public PropertyAccessor? setter {
+ internal set;
+ get;
+ }
- public PropertyAccessor getter { private set; get; }
+ public PropertyAccessor? getter {
+ internal set;
+ get;
+ }
/**
* Specifies the virtual or abstract property this property overrides.
*/
- public Property base_property { private set; get; }
-
- /**
- * { inheritDoc}
- */
- internal override void resolve_type_references (Tree root) {
- Vala.Property vala_property = symbol as Vala.Property;
- Vala.Property? base_vala_property = null;
- if (vala_property.base_property != null) {
- base_vala_property = vala_property.base_property;
- } else if (vala_property.base_interface_property != null) {
- base_vala_property = vala_property.base_interface_property;
- }
- if (base_vala_property == vala_property
- && vala_property.base_interface_property != null) {
- base_vala_property = vala_property.base_interface_property;
- }
- if (base_vala_property != null) {
- base_property = (Property?) root.search_vala_symbol (base_vala_property);
- }
-
- property_type.resolve_type_references (root);
+ public Property base_property {
+ set;
+ get;
}
/**
@@ -180,7 +169,9 @@ public class Valadoc.Api.Property : Member {
/**
* { inheritDoc}
*/
- public override NodeType node_type { get { return NodeType.PROPERTY; } }
+ public override NodeType node_type {
+ get { return NodeType.PROPERTY; }
+ }
/**
* { inheritDoc}
diff --git a/src/libvaladoc/api/propertyaccessor.vala b/src/libvaladoc/api/propertyaccessor.vala
index 3bdb940..7d41e65 100755
--- a/src/libvaladoc/api/propertyaccessor.vala
+++ b/src/libvaladoc/api/propertyaccessor.vala
@@ -1,6 +1,6 @@
/* propertyaccessor.vala
*
- * Copyright (C) 2008 Florian Brosch
+ * Copyright (C) 2008-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
@@ -28,23 +28,30 @@ using Valadoc.Content;
* Represents a get or set accessor of a property.
*/
public class Valadoc.Api.PropertyAccessor : Symbol {
- private Vala.PropertyAccessor vpropacc;
+ private PropertyAccessorType type;
+ private Ownership ownership;
+ private string? cname;
- public PropertyAccessor (Vala.PropertyAccessor symbol, Property parent) {
- base (symbol, parent);
- this.vpropacc = symbol;
+ public PropertyAccessor (Property parent, SourceFile file, string name, SymbolAccessibility accessibility, string? cname, PropertyAccessorType type, Ownership ownership, void* data) {
+ base (parent, file, name, accessibility, data);
+
+ this.ownership = ownership;
+ this.cname = cname;
+ this.type = type;
}
/**
* { inheritDoc}
*/
- public override NodeType node_type { get { return NodeType.PROPERTY_ACCESSOR; } }
+ public override NodeType node_type {
+ get { return NodeType.PROPERTY_ACCESSOR; }
+ }
/**
* Returns the name of this property accessor as it is used in C.
*/
public string? get_cname () {
- return vpropacc.get_cname ();
+ return cname;
}
/**
@@ -58,7 +65,7 @@ public class Valadoc.Api.PropertyAccessor : Symbol {
*/
public bool is_construct {
get {
- return this.vpropacc.construction;
+ return type == PropertyAccessorType.CONSTRUCT;
}
}
@@ -67,7 +74,7 @@ public class Valadoc.Api.PropertyAccessor : Symbol {
*/
public bool is_set {
get {
- return this.vpropacc.writable;
+ return type == PropertyAccessorType.SET || type == PropertyAccessorType.CONSTRUCT;
}
}
@@ -76,7 +83,7 @@ public class Valadoc.Api.PropertyAccessor : Symbol {
*/
public bool is_get {
get {
- return this.vpropacc.readable;
+ return type == PropertyAccessorType.GET;
}
}
@@ -85,7 +92,7 @@ public class Valadoc.Api.PropertyAccessor : Symbol {
*/
public bool is_owned {
get {
- return this.vpropacc.value_type.value_owned;
+ return ownership == Ownership.OWNED;
}
}
diff --git a/src/libvaladoc/api/propertyaccessortype.vala b/src/libvaladoc/api/propertyaccessortype.vala
new file mode 100644
index 0000000..01529ca
--- /dev/null
+++ b/src/libvaladoc/api/propertyaccessortype.vala
@@ -0,0 +1,42 @@
+/* propertyaccessor.vala
+ *
+ * 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:
+ * Florian Brosch <flo brosch gmail com>
+ */
+
+public enum Valadoc.Api.PropertyAccessorType {
+ CONSTRUCT,
+ SET,
+ GET;
+
+ public string to_string () {
+ switch (this) {
+ case PropertyAccessorType.CONSTRUCT:
+ return "construct";
+
+ case PropertyAccessorType.SET:
+ return "set";
+
+ case PropertyAccessorType.GET:
+ return "get";
+ }
+
+ assert_not_reached ();
+ }
+}
diff --git a/src/libvaladoc/api/propertybindingtype.vala b/src/libvaladoc/api/propertybindingtype.vala
new file mode 100644
index 0000000..a8ce161
--- /dev/null
+++ b/src/libvaladoc/api/propertybindingtype.vala
@@ -0,0 +1,48 @@
+/* propertybindingtype.vala
+ *
+ * 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:
+ * Florian Brosch <flo brosch gmail com>
+ */
+
+
+public enum Valadoc.Api.PropertyBindingType {
+ UNMODIFIED,
+ OVERRIDE,
+ ABSTRACT,
+ VIRTUAL;
+
+ public string to_string () {
+ switch (this) {
+ case OVERRIDE:
+ return "override";
+
+ case ABSTRACT:
+ return "abstract";
+
+ case VIRTUAL:
+ return "virtual";
+
+ case UNMODIFIED:
+ return "";
+ }
+
+ assert_not_reached ();
+ }
+}
+
diff --git a/src/libvaladoc/api/signal.vala b/src/libvaladoc/api/signal.vala
index d281588..7753517 100755
--- a/src/libvaladoc/api/signal.vala
+++ b/src/libvaladoc/api/signal.vala
@@ -1,6 +1,6 @@
/* signal.vala
*
- * Copyright (C) 2008 Florian Brosch
+ * Copyright (C) 2008-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
@@ -28,23 +28,31 @@ using Valadoc.Content;
* Represents an signal.
*/
public class Valadoc.Api.Signal : Member {
- public Signal (Vala.Signal symbol, Node parent) {
- base (symbol, parent);
- return_type = new TypeReference (symbol.return_type, this);
+ private string? dbus_name;
+ private string? cname;
+
+ public Signal (Node parent, SourceFile file, string name, SymbolAccessibility accessibility, SourceComment? comment, string? cname, string? dbus_name, bool is_dbus_visible, bool is_virtual, void* data) {
+ base (parent, file, name, accessibility, comment, data);
+
+ this.dbus_name = dbus_name;
+ this.cname = cname;
+
+ this.is_dbus_visible = is_dbus_visible;
+ this.is_virtual = is_virtual;
}
/**
* Returns the name of this signal as it is used in C.
*/
public string? get_cname () {
- return ((Vala.Signal) symbol).get_cname();
+ return cname;
}
/**
* Returns the dbus-name.
*/
public string get_dbus_name () {
- return Vala.GDBusModule.get_dbus_name_for_member (symbol);
+ return dbus_name;
}
/**
@@ -52,33 +60,25 @@ public class Valadoc.Api.Signal : Member {
*
* @return The return type of this signal or null for void
*/
- public TypeReference? return_type { protected set; get; }
-
- /**
- * { inheritDoc}
- */
- internal override void resolve_type_references (Tree root) {
- return_type.resolve_type_references (root);
-
- base.resolve_type_references (root);
+ public TypeReference? return_type {
+ set;
+ get;
}
/**
* Specifies whether this signal is virtual
*/
public bool is_virtual {
- get {
- return ((Vala.Signal) symbol).is_virtual;
- }
+ private set;
+ get;
}
/**
* Specifies whether this signal is visible for dbus
*/
public bool is_dbus_visible {
- get {
- return Vala.GDBusServerModule.is_dbus_visible (symbol);
- }
+ private set;
+ get;
}
/**
@@ -113,7 +113,9 @@ public class Valadoc.Api.Signal : Member {
/**
* { inheritDoc}
*/
- public override NodeType node_type { get { return NodeType.SIGNAL; } }
+ public override NodeType node_type {
+ get { return NodeType.SIGNAL; }
+ }
/**
* { inheritDoc}
diff --git a/src/libvaladoc/api/sourcecomment.vala b/src/libvaladoc/api/sourcecomment.vala
new file mode 100644
index 0000000..4f5c277
--- /dev/null
+++ b/src/libvaladoc/api/sourcecomment.vala
@@ -0,0 +1,84 @@
+/* sourcecomment.vala
+ *
+ * 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:
+ * Florian Brosch <flo brosch gmail com>
+ */
+
+
+
+/**
+ * A documentation comment used by valadoc
+ */
+public class Valadoc.Api.SourceComment {
+ public SourceFile file {
+ private set;
+ get;
+ }
+
+ /**
+ * The text describing the referenced source code.
+ */
+ public string content {
+ private set;
+ get;
+ }
+
+ /**
+ * The first line number of the referenced source code.
+ */
+ public int first_line {
+ private set;
+ get;
+ }
+
+ /**
+ * The first column number of the referenced source code.
+ */
+ public int first_column {
+ private set;
+ get;
+ }
+
+ /**
+ * The last line number of the referenced source code.
+ */
+ public int last_line {
+ private set;
+ get;
+ }
+
+ /**
+ * The last column number of the referenced source code.
+ */
+ public int last_column {
+ private set;
+ get;
+ }
+
+ public SourceComment (string content, SourceFile file, int first_line, int first_column, int last_line, int last_column) {
+ this.first_column = first_column;
+ this.last_column = last_column;
+ this.first_line = first_line;
+ this.last_line = last_line;
+ this.content = content;
+ this.file = file;
+ }
+}
+
+
diff --git a/src/libvaladoc/api/sourcefile.vala b/src/libvaladoc/api/sourcefile.vala
new file mode 100644
index 0000000..f0e6721
--- /dev/null
+++ b/src/libvaladoc/api/sourcefile.vala
@@ -0,0 +1,47 @@
+/* sourcefile.vala
+ *
+ * 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:
+ * Brosch Florian <flo brosch gmail com>
+ */
+
+/**
+ * Represents a source file
+ */
+public class SourceFile : Object {
+ public string relative_path {
+ private set;
+ get;
+ }
+
+ public string relative_c_path {
+ private set;
+ get;
+ }
+
+ public string get_name () {
+ return Path.get_basename (relative_path);
+ }
+
+ public SourceFile (string relative_path, string relative_c_path) {
+ this.relative_c_path = relative_c_path;
+ this.relative_path = relative_path;
+ }
+}
+
+
diff --git a/src/libvaladoc/api/struct.vala b/src/libvaladoc/api/struct.vala
index 9df0a6f..d0ebe5b 100755
--- a/src/libvaladoc/api/struct.vala
+++ b/src/libvaladoc/api/struct.vala
@@ -1,6 +1,6 @@
/* struct.vala
*
- * Copyright (C) 2008 Florian Brosch
+ * 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
@@ -28,21 +28,33 @@ using Valadoc.Content;
* Represents a struct declaration.
*/
public class Valadoc.Api.Struct : TypeSymbol {
- public Struct (Vala.Struct symbol, Node parent) {
- base (symbol, parent);
+ private string? dup_function_cname;
+ private string? free_function_cname;
+ private string? cname;
+
+ public Struct (Node parent, SourceFile file, string name, SymbolAccessibility accessibility, SourceComment? comment, string? cname, string? dup_function_cname, string? free_function_cname, bool is_basic_type, void* data) {
+ base (parent, file, name, accessibility, comment, is_basic_type, data);
+
+ this.dup_function_cname = dup_function_cname;
+ this.free_function_cname = free_function_cname;
+
+ this.cname = cname;
}
/**
* Specifies the base struct.
*/
- public TypeReference? base_type { private set; get; }
+ public TypeReference? base_type {
+ set;
+ get;
+ }
/**
* Returns the name of this struct as it is used in C.
*/
public string? get_cname () {
- return ((Vala.Struct) symbol).get_cname();
+ return cname;
}
/**
@@ -50,20 +62,22 @@ public class Valadoc.Api.Struct : TypeSymbol {
* type.
*/
public string? get_dup_function_cname () {
- return ((Vala.Struct) symbol).get_dup_function ();
+ return dup_function_cname;
}
/**
* Returns the C function name that frees instances of this data type.
*/
public string? get_free_function_cname () {
- return ((Vala.Struct) symbol).get_free_function ();
+ return free_function_cname;
}
/**
* { inheritDoc}
*/
- public override NodeType node_type { get { return NodeType.STRUCT; } }
+ public override NodeType node_type {
+ get { return NodeType.STRUCT; }
+ }
/**
* { inheritDoc}
@@ -72,24 +86,6 @@ public class Valadoc.Api.Struct : TypeSymbol {
visitor.visit_struct (this);
}
- private void set_parent_references (Tree root) {
- Vala.ValueType? basetype = ((Vala.Struct) symbol).base_type as Vala.ValueType;
- if (basetype == null) {
- return ;
- }
- this.base_type = new TypeReference (basetype, this);
- this.base_type.resolve_type_references (root);
- }
-
- /**
- * { inheritDoc}
- */
- internal override void resolve_type_references (Tree root) {
- this.set_parent_references (root);
-
- base.resolve_type_references (root);
- }
-
/**
* { inheritDoc}
*/
diff --git a/src/libvaladoc/api/symbol.vala b/src/libvaladoc/api/symbol.vala
index 985904d..260a5d3 100755
--- a/src/libvaladoc/api/symbol.vala
+++ b/src/libvaladoc/api/symbol.vala
@@ -1,6 +1,7 @@
/* symbol.vala
*
* Copyright (C) 2008-2009 Florian Brosch, Didier Villevalois
+ * 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
@@ -26,41 +27,11 @@ using Gee;
* Represents a node in the symbol tree.
*/
public abstract class Valadoc.Api.Symbol : Node {
- /**
- * The underlining vala symbol
- */
- internal Vala.Symbol symbol { private set; get; }
-
- /**
- * { inheritDoc}
- */
- public override string? name {
- owned get {
- return symbol.name;
- }
- }
-
- public Symbol (Vala.Symbol symbol, Node parent) {
- base (parent);
- this.symbol = symbol;
- }
-
- /**
- * { inheritDoc}
- */
- public override string? get_filename () {
- Vala.SourceReference? sref = symbol.source_reference;
- if (sref == null) {
- return null;
- }
- Vala.SourceFile? file = sref.file;
- if (file == null) {
- return null;
- }
+ public Symbol (Node parent, SourceFile file, string? name, SymbolAccessibility accessibility, void* data) {
+ base (parent, file, name, data);
- string path = sref.file.filename;
- return GLib.Path.get_basename (path);
+ this.accessibility = accessibility;
}
/**
@@ -79,71 +50,55 @@ public abstract class Valadoc.Api.Symbol : Node {
return true;
}
+ public SymbolAccessibility accessibility {
+ private set;
+ get;
+ }
+
/**
* Specifies whether this symbol is public.
*/
- public virtual bool is_public {
+ public bool is_public {
get {
- return symbol.access == Vala.SymbolAccessibility.PUBLIC;
+ return accessibility == SymbolAccessibility.PUBLIC;
}
}
/**
* Specifies whether this symbol is protected.
*/
- public virtual bool is_protected {
+ public bool is_protected {
get {
- return symbol.access == Vala.SymbolAccessibility.PROTECTED;
+ return accessibility == SymbolAccessibility.PROTECTED;
}
}
/**
* Specifies whether this symbol is internal.
*/
- public virtual bool is_internal {
+ public bool is_internal {
get {
- return symbol.access == Vala.SymbolAccessibility.INTERNAL;
+ return accessibility == SymbolAccessibility.INTERNAL;
}
}
/**
* Specifies whether this symbol is private.
*/
- public virtual bool is_private {
+ public bool is_private {
get {
- return symbol.access == Vala.SymbolAccessibility.PRIVATE;
+ return accessibility == SymbolAccessibility.PRIVATE;
}
}
/**
* Returns the accessibility modifier as string
+ *
+ * @deprecated
*/
+ //TODO: rm
protected string get_accessibility_modifier () {
- if (is_public) {
- return "public";
- } else if (is_protected) {
- return "protected";
- } else if (is_internal) {
- return "internal";
- } else {
- return "private";
- }
- }
-
- /**
- * { inheritDoc}
- */
- internal override void resolve_type_references (Tree root) {
- base.resolve_type_references (root);
-
- foreach (Vala.DataType type in symbol.get_error_types ()) {
- var error_type = type as Vala.ErrorType;
- if (error_type.error_domain == null) {
- add_child (glib_error);
- } else {
- add_child (root.search_vala_symbol (error_type.error_domain));
- }
- }
+ return accessibility.to_string ();
}
}
diff --git a/src/libvaladoc/api/symbolaccessibility.vala b/src/libvaladoc/api/symbolaccessibility.vala
new file mode 100755
index 0000000..9b78aa6
--- /dev/null
+++ b/src/libvaladoc/api/symbolaccessibility.vala
@@ -0,0 +1,51 @@
+/* SymbolAccessibility.vala
+ *
+ * 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:
+ * Florian Brosch <flo brosch gmail com>
+ */
+
+
+/**
+ * The access modifier
+ */
+public enum Valadoc.Api.SymbolAccessibility {
+ PROTECTED,
+ INTERNAL,
+ PRIVATE,
+ PUBLIC;
+
+ public string to_string () {
+ switch (this) {
+ case SymbolAccessibility.PROTECTED:
+ return "protected";
+
+ case SymbolAccessibility.INTERNAL:
+ return "internal";
+
+ case SymbolAccessibility.PRIVATE:
+ return "private";
+
+ case SymbolAccessibility.PUBLIC:
+ return "public";
+
+ default:
+ assert_not_reached ();
+ }
+ }
+}
diff --git a/src/libvaladoc/api/symbolresolver.vala b/src/libvaladoc/api/symbolresolver.vala
new file mode 100644
index 0000000..39d5a77
--- /dev/null
+++ b/src/libvaladoc/api/symbolresolver.vala
@@ -0,0 +1,310 @@
+/* symbolresolver.vala
+ *
+ * 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:
+ * Florian Brosch <flo brosch gmail com>
+ */
+
+using Gee;
+
+
+public class Valadoc.Api.SymbolResolver : Visitor {
+ private HashMap<Vala.Symbol, Symbol> symbol_map;
+ private Valadoc.Api.Class glib_error;
+ private Tree root;
+
+ public SymbolResolver (HashMap<Vala.Symbol, Symbol> symbol_map, Valadoc.Api.Class glib_error) {
+ this.symbol_map = symbol_map;
+ this.glib_error = glib_error;
+ }
+
+ private Symbol? resolve (Vala.Symbol symbol) {
+ return symbol_map.get (symbol);
+ }
+
+ private void resolve_array_type_references (Array ptr) {
+ Api.Item data_type = ptr.data_type;
+ if (data_type == null) {
+ // void
+ } else if (data_type is Array) {
+ resolve_array_type_references ((Array) data_type);
+ } else if (data_type is Pointer) {
+ resolve_pointer_type_references ((Pointer) data_type);
+ } else {
+ resolve_type_reference ((TypeReference) data_type);
+ }
+ }
+
+ private void resolve_pointer_type_references (Pointer ptr) {
+ Api.Item type = ptr.data_type;
+ if (type == null) {
+ // void
+ } else if (type is Array) {
+ resolve_array_type_references ((Array) type);
+ } else if (type is Pointer) {
+ resolve_pointer_type_references ((Pointer) type);
+ } else {
+ resolve_type_reference ((TypeReference) type);
+ }
+ }
+
+ private void resolve_type_reference (TypeReference reference) {
+ Vala.DataType vtyperef = (Vala.DataType) reference.data;
+ if (vtyperef is Vala.GenericType) {
+ reference.data_type = resolve (((Vala.GenericType) vtyperef).type_parameter);
+ } else if (vtyperef is Vala.ErrorType) {
+ Vala.ErrorDomain verrdom = ((Vala.ErrorType) vtyperef).error_domain;
+ if (verrdom != null) {
+ reference.data_type = resolve (verrdom);
+ } else {
+ reference.data_type = glib_error;
+ }
+ } else if (vtyperef is Vala.DelegateType) {
+ reference.data_type = resolve (((Vala.DelegateType) vtyperef).delegate_symbol);
+ } else if (vtyperef.data_type != null) {
+ reference.data_type = resolve (vtyperef.data_type);
+ }
+
+ // Type parameters:
+ foreach (TypeReference type_param_ref in reference.get_type_arguments ()) {
+ resolve_type_reference (type_param_ref);
+ }
+
+ if (reference.data_type is Pointer) {
+ resolve_pointer_type_references ((Pointer)reference.data_type);
+ } else if (reference.data_type is Array) {
+ resolve_array_type_references ((Array)reference.data_type);
+ }
+ }
+
+ /**
+ * { inheritDoc}
+ */
+ public override void visit_tree (Tree item) {
+ this.root = item;
+ item.accept_children (this);
+ this.root = null;
+ }
+
+ /**
+ * { inheritDoc}
+ */
+ public override void visit_package (Package item) {
+ item.accept_all_children (this, false);
+ }
+
+ /**
+ * { inheritDoc}
+ */
+ public override void visit_namespace (Namespace item) {
+ item.accept_all_children (this, false);
+ }
+
+ /**
+ * { inheritDoc}
+ */
+ public override void visit_interface (Interface item) {
+ Collection<TypeReference> interfaces = item.get_implemented_interface_list ();
+ foreach (var type_ref in interfaces) {
+ resolve_type_reference (type_ref);
+ ((Interface) type_ref.data_type).register_related_interface (item);
+ }
+
+
+ if (item.base_type != null) {
+ resolve_type_reference (item.base_type);
+ ((Class) item.base_type.data_type).register_derived_interface (item);
+ }
+
+ item.accept_all_children (this, false);
+ }
+
+ /**
+ * { inheritDoc}
+ */
+ public override void visit_class (Class item) {
+ Collection<TypeReference> interfaces = item.get_implemented_interface_list ();
+ foreach (TypeReference type_ref in interfaces) {
+ resolve_type_reference (type_ref);
+ ((Interface) type_ref.data_type).register_implementation (item);
+ }
+
+ if (item.base_type != null) {
+ resolve_type_reference (item.base_type);
+ ((Class) item.base_type.data_type).register_child_class (item);
+ }
+
+ item.accept_all_children (this, false);
+ }
+
+ /**
+ * { inheritDoc}
+ */
+ public override void visit_struct (Struct item) {
+ if (item.base_type != null) {
+ resolve_type_reference (item.base_type);
+ }
+
+ item.accept_all_children (this, false);
+ }
+
+ /**
+ * { inheritDoc}
+ */
+ public override void visit_property (Property item) {
+ Vala.Property vala_property = item.data as Vala.Property;
+ Vala.Property? base_vala_property = null;
+
+ if (vala_property.base_property != null) {
+ base_vala_property = vala_property.base_property;
+ } else if (vala_property.base_interface_property != null) {
+ base_vala_property = vala_property.base_interface_property;
+ }
+ if (base_vala_property == vala_property && vala_property.base_interface_property != null) {
+ base_vala_property = vala_property.base_interface_property;
+ }
+ if (base_vala_property != null) {
+ item.base_property = (Property?) resolve (base_vala_property);
+ }
+
+ resolve_type_reference (item.property_type);
+
+ item.accept_all_children (this, false);
+ }
+
+ /**
+ * { inheritDoc}
+ */
+ public override void visit_field (Field item) {
+ resolve_type_reference (item.field_type);
+
+ item.accept_all_children (this, false);
+ }
+
+ /**
+ * { inheritDoc}
+ */
+ public override void visit_constant (Constant item) {
+ resolve_type_reference (item.constant_type);
+
+ item.accept_all_children (this, false);
+ }
+
+ /**
+ * { inheritDoc}
+ */
+ public override void visit_delegate (Delegate item) {
+ resolve_type_reference (item.return_type);
+
+ item.accept_all_children (this, false);
+ }
+
+ /**
+ * { inheritDoc}
+ */
+ public override void visit_signal (Signal item) {
+ resolve_type_reference (item.return_type);
+
+ item.accept_all_children (this, false);
+ }
+
+ /**
+ * { inheritDoc}
+ */
+ public override void visit_method (Method item) {
+ Vala.Method vala_method = item.data as Vala.Method;
+ Vala.Method? base_vala_method = null;
+ if (vala_method.base_method != null) {
+ base_vala_method = vala_method.base_method;
+ } else if (vala_method.base_interface_method != null) {
+ base_vala_method = vala_method.base_interface_method;
+ }
+ if (base_vala_method == vala_method && vala_method.base_interface_method != null) {
+ base_vala_method = vala_method.base_interface_method;
+ }
+ if (base_vala_method != null) {
+ item.base_method = (Method?) resolve (base_vala_method);
+ }
+
+ resolve_type_reference (item.return_type);
+
+ item.accept_all_children (this, false);
+ }
+
+ /**
+ * { inheritDoc}
+ */
+ public override void visit_type_parameter (TypeParameter item) {
+ item.accept_all_children (this, false);
+ }
+
+ /**
+ * { inheritDoc}
+ */
+ public override void visit_formal_parameter (FormalParameter item) {
+ if (item.ellipsis) {
+ return;
+ }
+
+ if (((Vala.Parameter) item.data).initializer != null) {
+ SignatureBuilder signature = new SignatureBuilder ();
+ InitializerBuilder ibuilder = new InitializerBuilder (signature, symbol_map);
+ ((Vala.Parameter) item.data).initializer.accept (ibuilder);
+ item.default_value = signature.get ();
+ }
+
+ resolve_type_reference (item.parameter_type);
+ item.accept_all_children (this, false);
+ }
+
+ /**
+ * { inheritDoc}
+ */
+ public override void visit_error_domain (ErrorDomain item) {
+ item.accept_all_children (this, false);
+ }
+
+ /**
+ * { inheritDoc}
+ */
+ public override void visit_error_code (ErrorCode item) {
+ item.accept_all_children (this, false);
+ }
+
+ /**
+ * { inheritDoc}
+ */
+ public override void visit_enum (Enum item) {
+ item.accept_all_children (this, false);
+ }
+
+ /**
+ * { inheritDoc}
+ */
+ public override void visit_enum_value (EnumValue item) {
+
+ if (((Vala.EnumValue) item.data).value != null) {
+ SignatureBuilder signature = new SignatureBuilder ();
+ InitializerBuilder ibuilder = new InitializerBuilder (signature, symbol_map);
+ ((Vala.EnumValue) item.data).value.accept (ibuilder);
+ item.default_value = signature.get ();
+ }
+
+ item.accept_all_children (this, false);
+ }
+}
diff --git a/src/libvaladoc/api/tree.vala b/src/libvaladoc/api/tree.vala
index 4485b3e..8c28e66 100755
--- a/src/libvaladoc/api/tree.vala
+++ b/src/libvaladoc/api/tree.vala
@@ -1,6 +1,6 @@
/* tree.vala
*
- * Copyright (C) 2008 Florian Brosch
+ * Copyright (C) 2008-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
@@ -27,6 +27,7 @@ using Gee;
private Valadoc.Api.Class glib_error = null;
+
/**
* The root of the code tree.
*/
@@ -37,9 +38,13 @@ public class Valadoc.Api.Tree {
private Package source_package = null;
private Settings settings;
private ErrorReporter reporter;
- private Package sourcefiles = null;
private CTypeResolver _cresolver = null;
+ // TODO schÃner machen
+ internal void add_package(Package package) {
+ this.packages.add (package);
+ }
+
internal Vala.CodeContext context {
private set;
get;
@@ -62,6 +67,11 @@ public class Valadoc.Api.Tree {
return external_c_files.read_only_view;
}
+ internal void add_external_c_files (string name) {
+ external_c_files.add (name);
+ }
+
+
/**
* Returns a list of all packages in the tree
*
@@ -181,116 +191,8 @@ public class Valadoc.Api.Tree {
}
public Tree (ErrorReporter reporter, Settings settings) {
- this.context = new Vala.CodeContext ( );
- Vala.CodeContext.push (context);
-
this.settings = settings;
this.reporter = reporter;
-
- reporter.vreporter = this.context.report;
-
- this.context.experimental = settings.experimental;
- this.context.experimental_non_null = settings.experimental || settings.experimental_non_null;
- this.context.vapi_directories = settings.vapi_directories;
-
- if (settings.verbose) {
- context.report.enable_warnings = true;
- } else {
- context.report.enable_warnings = false;
- }
-
- if (settings.basedir == null) {
- context.basedir = realpath (".");
- } else {
- context.basedir = realpath (settings.basedir);
- }
-
- if (settings.directory != null) {
- context.directory = realpath (settings.directory);
- } else {
- context.directory = context.basedir;
- }
-
- if (settings.profile == "gobject-2.0" || settings.profile == "gobject" || settings.profile == null) {
- context.profile = Vala.Profile.GOBJECT;
- context.add_define ("GOBJECT");
- }
-
- if (settings.defines != null) {
- foreach (string define in settings.defines) {
- context.add_define (define);
- }
- }
-
- if (context.profile == Vala.Profile.POSIX) {
- /* default package */
- if (!add_package ("posix")) {
- Vala.Report.error (null, "posix not found in specified Vala API directories");
- }
- } else if (context.profile == Vala.Profile.GOBJECT) {
- int glib_major = 2;
- int glib_minor = 12;
-
-
- context.target_glib_major = glib_major;
- context.target_glib_minor = glib_minor;
- if (context.target_glib_major != 2) {
- Vala.Report.error (null, "This version of valac only supports GLib 2");
- }
-
- /* default packages */
- if (!this.add_package ("glib-2.0")) { //
- Vala.Report.error (null, "glib-2.0 not found in specified Vala API directories");
- }
-
- if (!this.add_package ("gobject-2.0")) { //
- Vala.Report.error (null, "gobject-2.0 not found in specified Vala API directories");
- }
- }
- }
-
- private void add_deps (string file_path, string pkg_name) {
- if (FileUtils.test (file_path, FileTest.EXISTS)) {
- try {
- string deps_content;
- ulong deps_len;
- FileUtils.get_contents (file_path, out deps_content, out deps_len);
- foreach (string dep in deps_content.split ("\n")) {
- dep.strip ();
- if (dep != "") {
- if (!add_package (dep)) {
- Vala.Report.error (null, "%s, dependency of %s, not found in specified Vala API directories".printf (dep, pkg_name));
- }
- }
- }
- } catch (FileError e) {
- Vala.Report.error (null, "Unable to read dependency file: %s".printf (e.message));
- }
- }
- }
-
- private bool add_package (string pkg) {
- if (context.has_package (pkg)) {
- // ignore multiple occurences of the same package
- return true;
- }
-
- var package_path = context.get_vapi_path (pkg) ?? context.get_gir_path (pkg);
- if (package_path == null) {
- Vala.Report.error (null, "Package `%s' not found in specified Vala API directories or GObject-Introspection GIR directories".printf (pkg));
- return false;
- }
-
- context.add_package (pkg);
-
- var vfile = new Vala.SourceFile (context, Vala.SourceFileType.PACKAGE, package_path);
- context.add_source_file (vfile);
-
- Package vdpkg = new Package (vfile, pkg, true);
- this.packages.add (vdpkg);
-
- add_deps (Path.build_filename (Path.get_dirname (package_path), "%s.deps".printf (pkg)), pkg);
- return true;
}
// copied from valacodecontext.vala
@@ -316,117 +218,11 @@ public class Valadoc.Api.Tree {
return null;
}
- /**
- * Adds the specified packages to the list of used packages.
- *
- * @param packages a list of package names
- */
- public void add_depencies (string[] packages) {
- foreach (string package in packages) {
- if (!add_package (package)) {
- Vala.Report.error (null, "Package `%s' not found in specified Vala API directories or GObject-Introspection GIR directories".printf (package));
- }
- }
- }
-
- /**
- * Add the specified source file to the context. Only .vala, .vapi, .gs,
- * and .c files are supported.
- */
- public void add_documented_file (string[] sources) {
- if (sources == null) {
- return;
- }
-
- foreach (string source in sources) {
- if (FileUtils.test (source, FileTest.EXISTS)) {
- var rpath = realpath (source);
- if (source.has_suffix (".vala") || source.has_suffix (".gs")) {
- var source_file = new Vala.SourceFile (context, Vala.SourceFileType.SOURCE, rpath);
-
-
- if (this.sourcefiles == null) {
- this.sourcefiles = new Package (source_file, settings.pkg_name, false);
- this.packages.add (this.sourcefiles);
- } else {
- this.sourcefiles.add_file (source_file);
- }
-
- if (context.profile == Vala.Profile.POSIX) {
- // import the Posix namespace by default (namespace of backend-specific standard library)
- var ns_ref = new Vala.UsingDirective (new Vala.UnresolvedSymbol (null, "Posix", null));
- source_file.add_using_directive (ns_ref);
- context.root.add_using_directive (ns_ref);
- } else if (context.profile == Vala.Profile.GOBJECT) {
- // import the GLib namespace by default (namespace of backend-specific standard library)
- var ns_ref = new Vala.UsingDirective (new Vala.UnresolvedSymbol (null, "GLib", null));
- source_file.add_using_directive (ns_ref);
- context.root.add_using_directive (ns_ref);
- }
-
- context.add_source_file (source_file);
- } else if (source.has_suffix (".vapi")) {
- string file_name = Path.get_basename (source);
- 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);
- context.add_source_file (vfile);
- this.packages.add (vdpkg);
- add_deps (Path.build_filename (Path.get_dirname (source), "%s.deps".printf (file_name)), file_name);
- } else if (source.has_suffix (".c")) {
- context.add_c_source_file (rpath);
- external_c_files.add (rpath);
- } else {
- Vala.Report.error (null, "%s is not a supported source file type. Only .vala, .vapi, .gs, and .c files are supported.".printf (source));
- }
- } else {
- Vala.Report.error (null, "%s not found".printf (source));
- }
- }
- }
-
public bool create_tree ( ) {
- Vala.Parser parser = new Vala.Parser ();
- parser.parse (this.context);
- if (this.context.report.get_errors () > 0) {
- return false;
- }
-
- context.check ();
-
- if (this.context.report.get_errors () > 0) {
- return false;
- }
-
- Api.NodeBuilder builder = new NodeBuilder (this);
- this.context.accept(builder);
- this.resolve_type_references ();
- this.resolve_children ();
this.add_dependencies_to_source_package ();
return true;
}
- private Package? find_package_for_file (Vala.SourceFile vfile) {
- foreach (Package pkg in this.packages) {
- if (pkg.is_package_for_file (vfile))
- return pkg;
- }
- return null;
- }
-
- private void resolve_type_references () {
- foreach (Package pkg in this.packages) {
- pkg.resolve_type_references (this);
- }
- }
-
- private void resolve_children () {
- foreach (Package pkg in packages) {
- pkg.resolve_children (this);
- }
- }
-
private Package? get_source_package () {
foreach (Package pkg in packages) {
if (!pkg.is_package) {
@@ -485,35 +281,5 @@ public class Valadoc.Api.Tree {
}
}
}
-
- internal Symbol? search_vala_symbol (Vala.Symbol symbol) {
- Vala.SourceFile source_file = symbol.source_reference.file;
- Package package = find_package_for_file (source_file);
- return search_vala_symbol_in (symbol, package);
- }
-
- internal Symbol? search_vala_symbol_in (Vala.Symbol symbol, Package package) {
- ArrayList<Vala.Symbol> params = new ArrayList<Vala.Symbol> ();
- for (Vala.Symbol iter = symbol; iter != null; iter = iter.parent_symbol) {
- if (iter is Vala.DataType) {
- params.insert (0, ((Vala.DataType)iter).data_type);
- } else {
- params.insert (0, iter);
- }
- }
-
- if (params.size == 0) {
- return null;
- }
-
- Api.Node? node = package;
- foreach (Vala.Symbol a_symbol in params) {
- node = node.find_by_symbol (a_symbol);
- if (node == null) {
- return null;
- }
- }
- return (Symbol) node;
- }
}
diff --git a/src/libvaladoc/api/typeparameter.vala b/src/libvaladoc/api/typeparameter.vala
index c0f5006..1c925a1 100755
--- a/src/libvaladoc/api/typeparameter.vala
+++ b/src/libvaladoc/api/typeparameter.vala
@@ -1,6 +1,6 @@
/* typeparameter.vala
*
- * Copyright (C) 2008 Florian Brosch
+ * Copyright (C) 2008-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
@@ -29,8 +29,8 @@ using Valadoc.Content;
*/
public class Valadoc.Api.TypeParameter : Symbol {
- public TypeParameter (Vala.TypeParameter symbol, Node parent) {
- base (symbol, parent);
+ public TypeParameter (Node parent, SourceFile file, string name, void* data) {
+ base (parent, file, name, SymbolAccessibility.PUBLIC, data);
}
/**
diff --git a/src/libvaladoc/api/typereference.vala b/src/libvaladoc/api/typereference.vala
index af34864..1759687 100755
--- a/src/libvaladoc/api/typereference.vala
+++ b/src/libvaladoc/api/typereference.vala
@@ -1,6 +1,6 @@
/* typereference.vala
*
- * Copyright (C) 2008 Florian Brosch
+ * Copyright (C) 2008-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
@@ -29,10 +29,17 @@ using Valadoc.Content;
*/
public class Valadoc.Api.TypeReference : Item {
private ArrayList<TypeReference> type_arguments = new ArrayList<TypeReference> ();
- private Vala.DataType? vtyperef;
+ private string? dbus_type_signature;
+ private Ownership ownership;
- public TypeReference (Vala.DataType? vtyperef, Item parent) {
- this.vtyperef = vtyperef;
+ public TypeReference (Item parent, Ownership ownership, bool pass_ownership, bool is_dynamic, bool is_nullable, string? dbus_type_signature, void* data) {
+ base (data);
+
+ this.dbus_type_signature = dbus_type_signature;
+ this.pass_ownership = pass_ownership;
+ this.is_nullable = is_nullable;
+ this.is_dynamic = is_dynamic;
+ this.ownership = ownership;
this.parent = parent;
}
@@ -45,42 +52,21 @@ public class Valadoc.Api.TypeReference : Item {
return this.type_arguments.read_only_view;
}
- private void set_template_argument_list (Tree root, Vala.Collection<Vala.DataType> varguments) {
- foreach (Vala.DataType vdtype in varguments) {
- var dtype = new TypeReference (vdtype, this);
- dtype.resolve_type_references (root);
- this.type_arguments.add (dtype);
- }
+ public void add_type_argument (TypeReference type_ref) {
+ type_arguments.add (type_ref);
}
/**
* The referred data type.
*/
public Item? data_type {
- private set;
+ set;
get;
}
public bool pass_ownership {
- get {
- if (this.vtyperef == null) {
- return false;
- }
-
- Vala.CodeNode? node = this.vtyperef.parent_node;
- if (node == null) {
- return false;
- }
- if (node is Vala.Parameter) {
- return (((Vala.Parameter)node).direction == Vala.ParameterDirection.IN &&
- ((Vala.Parameter)node).variable_type.value_owned);
- }
- if (node is Vala.Property) {
- return ((Vala.Property)node).property_type.value_owned;
- }
-
- return false;
- }
+ private set;
+ get;
}
/**
@@ -88,21 +74,7 @@ public class Valadoc.Api.TypeReference : Item {
*/
public bool is_owned {
get {
- if (this.vtyperef == null) {
- return false;
- }
-
- Vala.CodeNode parent = this.vtyperef.parent_node;
-
- // parameter:
- if (parent is Vala.Parameter) {
- if (((Vala.Parameter)parent).direction != Vala.ParameterDirection.IN) {
- return false;
- }
- return ((Vala.Parameter)parent).variable_type.value_owned;
- }
-
- return false;
+ return ownership == Ownership.OWNED;
}
}
@@ -111,98 +83,38 @@ public class Valadoc.Api.TypeReference : Item {
*/
public bool is_weak {
get {
- if (vtyperef == null) {
- return false;
- }
-
- // non ref counted types are unowned, not weak
- if (vtyperef.data_type is Vala.TypeSymbol && ((Vala.TypeSymbol) vtyperef.data_type).is_reference_counting () == false) {
- return false;
- }
-
- // FormalParameters are weak by default
- return (parent is FormalParameter == false)? vtyperef.is_weak () : false;
+ return ownership == Ownership.WEAK;
}
}
/**
- * Specifies that the expression is dynamic.
+ * Specifies that the expression is unwoned.
*/
- public bool is_dynamic {
+ public bool is_unowned {
get {
- return this.vtyperef != null && this.vtyperef.is_dynamic;
+ return ownership == Ownership.UNOWNED;
}
}
+
/**
- * Specifies that the expression is unwoned.
+ * Specifies that the expression is dynamic.
*/
- public bool is_unowned {
- get {
- if (vtyperef == null) {
- return false;
- }
-
- // non ref counted types are weak, not unowned
- if (vtyperef.data_type is Vala.TypeSymbol && ((Vala.TypeSymbol) vtyperef.data_type).is_reference_counting () == true) {
- return false;
- }
-
- // FormalParameters are weak by default
- return (parent is FormalParameter == false)? vtyperef.is_weak () : false;
- }
+ public bool is_dynamic {
+ private set;
+ get;
}
/**
* Specifies that the expression may be null.
*/
public bool is_nullable {
- get {
- return this.vtyperef != null
- && this.vtyperef.nullable
- && !(this.vtyperef is Vala.GenericType)
- && !(this.vtyperef is Vala.PointerType);
- }
+ private set;
+ get;
}
public string? get_dbus_type_signature () {
- if (vtyperef != null) {
- return Vala.GVariantModule.get_dbus_signature (vtyperef.data_type);
- } else {
- return null;
- }
- }
-
- /**
- * { inheritDoc}
- */
- internal override void resolve_type_references (Tree root) {
- if ( this.vtyperef is Vala.PointerType) {
- this.data_type = new Pointer ((Vala.PointerType) this.vtyperef, this);
- } else if (vtyperef is Vala.ArrayType) {
- this.data_type = new Array ((Vala.ArrayType) this.vtyperef, this);
- } else if (vtyperef is Vala.GenericType) {
- this.data_type = root.search_vala_symbol (((Vala.GenericType) this.vtyperef).type_parameter);
- } else if (vtyperef is Vala.ErrorType) {
- Vala.ErrorDomain verrdom = ((Vala.ErrorType) vtyperef).error_domain;
- if (verrdom != null) {
- this.data_type = root.search_vala_symbol (verrdom);
- } else {
- this.data_type = glib_error;
- }
- } else if (vtyperef is Vala.DelegateType) {
- this.data_type = root.search_vala_symbol (((Vala.DelegateType) vtyperef).delegate_symbol);
- } else if (vtyperef.data_type != null) {
- this.data_type = root.search_vala_symbol (vtyperef.data_type);
- }
-
- this.set_template_argument_list (root, vtyperef.get_type_arguments ());
-
- if (this.data_type is Pointer) {
- ((Pointer)this.data_type).resolve_type_references (root);
- } else if (this.data_type is Array) {
- ((Array)this.data_type).resolve_type_references (root);
- }
+ return dbus_type_signature;
}
/**
diff --git a/src/libvaladoc/api/typesymbol.vala b/src/libvaladoc/api/typesymbol.vala
index ca2ac1a..f829cb1 100755
--- a/src/libvaladoc/api/typesymbol.vala
+++ b/src/libvaladoc/api/typesymbol.vala
@@ -1,6 +1,7 @@
/* typesymbol.vala
*
* Copyright (C) 2008-2009 Florian Brosch, Didier Villevalois
+ * 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
@@ -27,32 +28,27 @@ using Gee;
* Represents a runtime data type.
*/
public abstract class Valadoc.Api.TypeSymbol : Symbol {
+ private SourceComment? source_comment;
- public TypeSymbol (Vala.TypeSymbol symbol, Node parent) {
- base (symbol, parent);
+ public TypeSymbol (Node parent, SourceFile file, string name, SymbolAccessibility accessibility, SourceComment? comment, bool is_basic_type, void* data) {
+ base (parent, file, name, accessibility, data);
+
+ this.is_basic_type = is_basic_type;
+ this.source_comment = comment;
}
/**
* Specifies whether this symbol is a basic type (string, int, char, etc)
*/
public bool is_basic_type {
- get {
- if (symbol is Vala.Struct) {
- var vala_struct = symbol as Vala.Struct;
- return vala_struct.base_type == null && (vala_struct.is_boolean_type () || vala_struct.is_floating_type () || vala_struct.is_integer_type ());
- } else if (symbol is Vala.Class) {
- var vala_class = symbol as Vala.Class;
- return vala_class.base_class == null && vala_class.name == "string";
- }
- return false;
- }
+ private set;
+ get;
}
/**
* { inheritDoc}
*/
internal override void process_comments (Settings settings, DocumentationParser parser) {
- var source_comment = ((Vala.TypeSymbol) symbol).comment;
if (source_comment != null) {
documentation = parser.parse (this, source_comment);
}
diff --git a/src/libvaladoc/documentation/documentationparser.vala b/src/libvaladoc/documentation/documentationparser.vala
index 9de199b..f2b2ae7 100755
--- a/src/libvaladoc/documentation/documentationparser.vala
+++ b/src/libvaladoc/documentation/documentationparser.vala
@@ -1,6 +1,6 @@
/* documentationparser.vala
*
- * Copyright (C) 2008-2009 Florian Brosch, Didier Villevalois
+ * Copyright (C) 2008-2011 Florian Brosch, Didier Villevalois
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
@@ -73,9 +73,8 @@ public class Valadoc.DocumentationParser : Object, ResourceLocator {
private Parser _parser;
private Scanner _scanner;
- public Comment? parse (Api.Node element, Vala.Comment source_comment) {
- var source_ref = source_comment.source_reference;
- return parse_comment_str (element, source_comment.content, source_ref.file.filename, source_ref.first_line, source_ref.first_column);
+ public Comment? parse (Api.Node element, Api.SourceComment comment) {
+ return parse_comment_str (element, comment.content, comment.file.get_name (), comment.first_line, comment.first_column);
}
public Comment? parse_comment_str (Api.Node element, string content, string filename, int first_line, int first_column) {
diff --git a/src/libvaladoc/errorreporter.vala b/src/libvaladoc/errorreporter.vala
index 454d087..48e2a6c 100755
--- a/src/libvaladoc/errorreporter.vala
+++ b/src/libvaladoc/errorreporter.vala
@@ -1,6 +1,6 @@
/* errorreporter.vala
*
- * Copyright (C) 2008-2009 Florian Brosch
+ * Copyright (C) 2008-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
@@ -27,6 +27,16 @@ public class Valadoc.ErrorReporter : Object {
private int _warnings = 0;
private int _errors = 0;
+ public int warnings_offset {
+ get;
+ set;
+ }
+
+ public int errors_offset {
+ get;
+ set;
+ }
+
public unowned GLib.FileStream stream {
get; set;
}
@@ -41,15 +51,13 @@ public class Valadoc.ErrorReporter : Object {
public int errors {
get {
- int verrors = (this.vreporter != null)? this.vreporter.get_errors () : 0;
- return this._errors + verrors;
+ return this._errors + errors_offset;
}
}
public int warnings {
get {
- int vwarnings = (this.vreporter != null)? this.vreporter.get_warnings () : 0;
- return this._warnings + vwarnings;
+ return this._warnings + warnings_offset;
}
}
diff --git a/src/libvaladoc/html/basicdoclet.vala b/src/libvaladoc/html/basicdoclet.vala
index 7afa5c9..d04d39e 100755
--- a/src/libvaladoc/html/basicdoclet.vala
+++ b/src/libvaladoc/html/basicdoclet.vala
@@ -352,7 +352,7 @@ public abstract class Valadoc.Html.BasicDoclet : Api.Visitor, Doclet {
}
private void write_brief_description (Api.Node element , Api.Node? pos) {
- Comment? doctree = element.documentation;
+ Content.Comment? doctree = element.documentation;
if (doctree == null) {
return;
}
@@ -369,7 +369,7 @@ public abstract class Valadoc.Html.BasicDoclet : Api.Visitor, Doclet {
}
private void write_documentation (Api.Node element , Api.Node? pos) {
- Comment? doctree = element.documentation;
+ Content.Comment? doctree = element.documentation;
if (doctree == null) {
return;
}
diff --git a/src/libvaladoc/importer/valadocdocumentationimporter.vala b/src/libvaladoc/importer/valadocdocumentationimporter.vala
index 189acf7..43e83aa 100755
--- a/src/libvaladoc/importer/valadocdocumentationimporter.vala
+++ b/src/libvaladoc/importer/valadocdocumentationimporter.vala
@@ -102,9 +102,10 @@ public class Valadoc.Importer.ValadocDocumentationImporter : DocumentationImport
.set_name ("Documentation");
Rule file = Rule.many ({
- optional_empty_lines,
- documentation,
- optional_empty_lines
+ Rule.one_of ({
+ documentation,
+ optional_empty_lines
+ })
})
.set_name ("ValadocFile");
diff --git a/src/libvaladoc/parser/tokentype.vala b/src/libvaladoc/parser/tokentype.vala
index 9d98b1c..03ecdce 100755
--- a/src/libvaladoc/parser/tokentype.vala
+++ b/src/libvaladoc/parser/tokentype.vala
@@ -256,7 +256,7 @@ public class Valadoc.TokenType : Object {
private TokenType (string string_value, int basic_value, Action? action) {
_string_value = string_value;
_basic_value = basic_value;
- if (_action != null) {
+ if (action != null) {
_action = (token) => { action (token); };
} else {
_action = null;
diff --git a/src/libvaladoc/settings.vala b/src/libvaladoc/settings.vala
index baa8cb4..1a4a4ba 100755
--- a/src/libvaladoc/settings.vala
+++ b/src/libvaladoc/settings.vala
@@ -115,6 +115,16 @@ public class Valadoc.Settings : Object {
* List of directories where to find .vapi files.
*/
public string[] vapi_directories;
+
+ /**
+ * A list of all packages
+ */
+ public string[] packages;
+
+ /**
+ * A list of all source files.
+ */
+ public string[] source_files;
}
diff --git a/src/valadoc/Makefile.am b/src/valadoc/Makefile.am
old mode 100644
new mode 100755
diff --git a/src/valadoc/valadoc.vala b/src/valadoc/valadoc.vala
index b4cb78f..36235c6 100755
--- a/src/valadoc/valadoc.vala
+++ b/src/valadoc/valadoc.vala
@@ -129,30 +129,7 @@ public class ValaDoc : Object {
return this.pkg_name;
}
-
- private int run (ErrorReporter reporter) {
- var settings = new Valadoc.Settings ();
- settings.pkg_name = this.get_pkg_name ();
- settings.pkg_version = this.pkg_version;
- settings.add_inherited = this.add_inherited;
- settings._protected = this._protected;
- settings._internal = this._internal;
- settings.with_deps = this.with_deps;
- settings._private = this._private;
- settings.path = realpath (this.directory);
- settings.verbose = this.verbose;
- settings.wiki_directory = this.wikidirectory;
- settings.pluginargs = this.pluginargs;
-
- settings.experimental = experimental;
- settings.experimental_non_null = experimental_non_null;
- settings.basedir = basedir;
- settings.directory = directory;
- settings.vapi_directories = vapi_directories;
-
- settings.profile = profile;
- settings.defines = defines;
-
+ private ModuleLoader? create_module_loader (ErrorReporter reporter) {
string fulldirpath = "";
if (pluginpath == null) {
fulldirpath = build_filename (Config.plugin_dir, "html");
@@ -175,23 +152,56 @@ public class ValaDoc : Object {
bool tmp = modules.load_doclet (fulldirpath);
if (tmp == false) {
reporter.simple_error ("failed to load plugin");
- return quit (reporter);
+ return null;
}
+ return modules;
+ }
+
+ private int run (ErrorReporter reporter) {
+ // settings:
+ var settings = new Valadoc.Settings ();
+ settings.pkg_name = this.get_pkg_name ();
+ settings.pkg_version = this.pkg_version;
+ settings.add_inherited = this.add_inherited;
+ settings._protected = this._protected;
+ settings._internal = this._internal;
+ settings.with_deps = this.with_deps;
+ settings._private = this._private;
+ settings.path = realpath (this.directory);
+ settings.verbose = this.verbose;
+ settings.wiki_directory = this.wikidirectory;
+ settings.pluginargs = this.pluginargs;
+
+ settings.experimental = experimental;
+ settings.experimental_non_null = experimental_non_null;
+ settings.basedir = basedir;
+ settings.directory = directory;
+ settings.vapi_directories = vapi_directories;
+
+ settings.source_files = tsources;
+ settings.packages = packages;
+
+ settings.profile = profile;
+ settings.defines = defines;
- Valadoc.Api.Tree doctree = new Valadoc.Api.Tree (reporter, settings);
- Valadoc.DocumentationParser docparser = new Valadoc.DocumentationParser (settings, reporter, doctree, modules);
- doctree.add_depencies (packages);
+ // Create tree:
+ Valadoc.Api.Driver driver = new Valadoc.Api.Driver ();
+ Valadoc.Api.Tree doctree = driver.build (settings, reporter);
+
if (reporter.errors > 0) {
return quit (reporter);
}
- doctree.add_documented_file (tsources);
- if (reporter.errors > 0) {
+
+ // process documentation
+ ModuleLoader? modules = create_module_loader (reporter);
+ if (reporter.errors > 0 || modules == null) {
return quit (reporter);
}
+ Valadoc.DocumentationParser docparser = new Valadoc.DocumentationParser (settings, reporter, doctree, modules);
if (!doctree.create_tree()) {
return quit (reporter);
}
@@ -201,7 +211,6 @@ public class ValaDoc : Object {
return quit (reporter);
}
-
DocumentationImporter[] importers = {
new GirDocumentationImporter (doctree, docparser, modules, settings),
new ValadocDocumentationImporter (doctree, docparser, modules, settings, reporter)
diff --git a/src/vapi/config.vapi b/src/vapi/config.vapi
old mode 100644
new mode 100755
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]