[valadoc] - valac 4.7.5
- From: Florian Brosch <flobrosch src gnome org>
- To: svn-commits-list gnome org
- Subject: [valadoc] - valac 4.7.5
- Date: Sat, 4 Jul 2009 12:09:17 +0000 (UTC)
commit 56eddfb529b976479709b7b865e797c7c3b178e9
Author: Florian Brosch <flo brosch gmail com>
Date: Sat Jul 4 14:05:04 2009 +0200
- valac 4.7.5
- initial valadoc.org doclet changes for the new webside
src/doclets/valadoc.org/doclet/template.vala | 1831 ++++++--------------------
src/libvaladoc/apitree.vala | 21 +-
src/libvaladoc/parser.vala | 12 +-
3 files changed, 417 insertions(+), 1447 deletions(-)
---
diff --git a/src/doclets/valadoc.org/doclet/template.vala b/src/doclets/valadoc.org/doclet/template.vala
index 4b7a4d6..f472962 100644
--- a/src/doclets/valadoc.org/doclet/template.vala
+++ b/src/doclets/valadoc.org/doclet/template.vala
@@ -24,1703 +24,658 @@ using Gee;
+public class Valadoc.HtmlDoclet : Valadoc.Doclet {
+ private Settings settings;
+ private FileStream file;
+ private bool run;
-
-
-public class Valadoc.ValadocOrgLanglet : Valadoc.Langlet {
- private const string css_optional_parameter = "";
- private const string css_basic_type = "";
- private const string css_other_type = "";
- private const string css_keyword = "";
-
- public Valadoc.Settings settings {
- construct set;
- protected get;
- }
-
- public ValadocOrgLanglet ( Settings settings ) {
+ public override void initialisation (Settings settings, Tree tree) {
this.settings = settings;
- }
+ this.run = true;
- private Basic position = null;
+ DirUtils.create (this.settings.path, 0777);
- protected string get_link ( Basic type, Basic position ) {
- return "";
- }
-
- private inline bool is_basic_type ( string name ) {
- string[] basic_types = new string[] { "bool", "char", "uchar", "int", "uint", "short", "ushort",
- "long", "ulong", "size_t", "ssize_t", "int8", "uint8", "int16", "uint16", "int32",
- "uint32", "int64", "uint64", "float", "double", "time_t", "unichar", "string"
- };
- foreach ( string str in basic_types ) {
- if ( str == name )
- return true;
- }
- return false;
- }
-
- private void write_type_name ( DataType? datatype, GLib.StringBuilder stream ) {
- if ( datatype == null ) {
- stream.append ( "<font class=\"" );
- stream.append ( css_keyword );
- stream.append ( "\">void</font>" );
- return ;
- }
+ foreach (Package pkg in tree.get_package_list ()) {
+ pkg.visit (this);
- string typename = datatype.full_name ();
- if ( ((DocumentedElement)datatype.parent).name == null && (datatype is Class || datatype is Struct) ) {
- if ( this.is_basic_type ( typename ) ) {
- string link = this.get_link(datatype, this.position );
- if ( link == null ) {
- stream.append ( "<span class=\"" );
- stream.append ( css_basic_type );
- stream.append ( "\">" );
- stream.append ( typename );
- stream.append ( "</span>" );
- }
- else {
- stream.append ( "<a class=\"" );
- stream.append ( css_basic_type );
- stream.append ( "\" href=\"" );
- stream.append ( link );
- stream.append ( "\">" );
- stream.append ( typename );
- stream.append ( "</a>" );
- }
- return ;
+ if (this.run == false) {
+ break;
}
}
-
- string link = this.get_link(datatype, this.position);
- if ( link == null ) {
- stream.append ( "<span class=\"" );
- stream.append ( css_other_type );
- stream.append ( "\">" );
- stream.append ( typename );
- stream.append ( "</span>" );
- }
- else {
- stream.append ( "<a class=\"" );
- stream.append ( css_other_type );
- stream.append ( "\" href=\"" );
- stream.append ( link );
- stream.append ( "\">" );
- stream.append ( typename );
- stream.append ( "</a>" );
- }
}
- private void write_type_reference_name ( TypeReference type_reference, GLib.StringBuilder stream ) {
- if ( type_reference.type_name == "void" ) {
- stream.append ( "<font class=\"" );
- stream.append ( css_keyword );
- stream.append ( "\">void</font>" );
- }
- else {
- if ( type_reference.data_type == null ) {
- stream.append ( "<font class=\"" );
- stream.append ( css_other_type );
- stream.append ( "\">" );
- stream.append ( type_reference.type_name );
- stream.append ( "</font>" );
- }
- else {
- this.write_type_name ( type_reference.data_type, stream );
- }
- }
+ // get_type_path()
+ private void write_insert_into_valadoc_element_str (string name, string pkgname, string fullname) {
+ string fullname2 = (pkgname == fullname)? pkgname : pkgname+"/"+fullname;
+ this.file.printf ("INSERT INTO `ValadocElement` (`name`, `fullname`) VALUES ('%s', '%s');\n", name, fullname2);
}
- private void write_type_reference_template_arguments ( Valadoc.TypeReference type_reference, GLib.StringBuilder stream ) {
- Gee.Collection<TypeReference> arglst = type_reference.get_type_arguments ( );
- int size = arglst.size;
- if ( size == 0 )
- return ;
-
- stream.append ( "<" );
- int i = 0;
-
- foreach ( TypeReference arg in arglst ) {
- i++;
+ // get_type_path()
+ private void write_insert_into_valadoc_element (DocumentedElement element) {
+ string name = element.name;
+ string fullname;
- this.write_nested_type_referene ( arg, stream );
- if ( i != size )
- stream.append ( ", " );
+ if (name == null) {
+ name = element.package.name;
+ fullname = name;
+ }
+ else {
+ fullname = element.full_name();
}
- stream.append ( ">" );
+ this.write_insert_into_valadoc_element_str(name, element.package.name, fullname);
}
- private void write_nested_type_referene ( Valadoc.TypeReference type_reference, GLib.StringBuilder stream ) {
- if ( type_reference.type_name == null )
- return ;
-
-
- GLib.StringBuilder modifiers = new GLib.StringBuilder ();
-
- if ( type_reference.is_dynamic )
- modifiers.append ( "dynamic " );
-
- if ( type_reference.is_weak )
- modifiers.append ( "weak " );
- else if ( type_reference.is_unowned )
- modifiers.append ( "unowned " );
- else if ( type_reference.is_owned )
- modifiers.append ( "owned " );
-
- if ( modifiers.len > 0 ) {
- stream.append ( "<font class=\"" );
- stream.append ( css_keyword );
- stream.append ( "\">" );
- stream.append ( modifiers.str );
- stream.append ( "</font> ");
- }
+ private void write_insert_into_valadoc_package (Package pkg) {
+ this.file.printf ("INSERT INTO `ValadocPackage` (`id`) VALUES ((SELECT `id` FROM `ValadocElement` WHERE `fullname`='%s' LIMIT 1));\n", pkg.name);
+ }
+ // get_type_path()
+ private void write_insert_into_code_element_str (string fullname, string pkgname, string valaapi, string parentnodepkgname, string parentnodefullname) {
+ string parentnodetypepath = (parentnodepkgname == parentnodefullname)? parentnodepkgname : parentnodepkgname+"/"+parentnodefullname;
+ string typepath = pkgname+"/"+fullname;
+ this.file.printf ("INSERT INTO `ValadocCodeElement` (`id`, `parent`, `valaapi`) VALUES ((SELECT `id` FROM `ValadocElement` WHERE BINARY `fullname`='%s' LIMIT 1), (SELECT `id` FROM `ValadocElement` WHERE BINARY `fullname`='%s' LIMIT 1), '%s');\n", typepath, parentnodetypepath, valaapi);
+ }
- this.write_type_reference_name ( type_reference, stream );
- this.write_type_reference_template_arguments ( type_reference, stream );
+ // get_type_path()
+ private void write_insert_into_code_element (DocumentedElement element) {
+ string api = "foo bar foobaro";
+ string parentnodepkgname;
+ string parentnodename;
+ string typename;
+ string cname;
- if ( type_reference.is_array ) {
- stream.append_unichar ( '[' );
- stream.append ( string.nfill ( type_reference.array_rank-1, ',') );
- stream.append_unichar ( ']' );
+ Basic parent = element.parent;
+ if (parent is DocumentedElement) {
+ parentnodepkgname = ((DocumentedElement)parent).package.name;
+ parentnodename = ((DocumentedElement)parent).full_name();
+ if (parentnodename == null) {
+ parentnodename = parentnodepkgname;
+ }
}
-
- if ( type_reference.is_nullable ) {
- stream.append_unichar ( '?' );
+ else {
+ parentnodepkgname = ((Package)parent).name;
+ parentnodename = parentnodepkgname;
}
- stream.append ( string.nfill ( type_reference.pointer_rank, '*') );
+ this.write_insert_into_code_element_str(element.full_name(), element.package.name, api, parentnodepkgname, parentnodename);
}
- public override void write_type_reference ( Valadoc.TypeReference type_reference, void* ptr ) {
- weak GLib.StringBuilder stream = (GLib.StringBuilder)ptr;
- if ( type_reference == null )
+ public override void visit_package (Package pkg) {
+ string path = Path.build_filename(this.settings.path, pkg.name);
+ if (GLib.DirUtils.create (path, 0777) == -1) {
+ this.run = false;
return ;
-
- this.write_nested_type_referene ( type_reference, stream );
- stream.append_unichar ( ' ' );
-
- /*
- if ( type_reference.is_weak ) {
- file.printf ( "<font class=\"%s\">weak</font> ", css_keyword );
}
- this.write_type_name ( type_reference.data_type, file );
-
- if ( type_reference.is_array ) {
- string str = string.nfill ( type_reference.array_rank-1, ',');
- file.printf ( "[%s]", str );
+ path = Path.build_filename(path, "dump.sql");
+ this.file = FileStream.open (path , "w");
+ if (this.file == null) {
+ this.run = false;
+ return ;
}
- if ( type_reference.pass_ownership ) {
- file.putc ( '#' );
+ this.write_insert_into_valadoc_element_str (pkg.name, pkg.name, pkg.name);
+ if ( this.run == false ) {
+ return ;
}
- if ( type_reference.is_nullable ) {
- file.putc ( '?' );
+ this.write_insert_into_valadoc_package (pkg);
+ if ( this.run == false ) {
+ return ;
}
- string str = string.nfill ( type_reference.pointer_rank, '*' );
- file.puts ( str );
- */
- }
+ foreach (Namespace ns in pkg.get_namespace_list()) {
+ ns.visit(this);
- private void write_formal_parameter ( FormalParameter param, GLib.StringBuilder stream ) {
- if ( param.ellipsis ) {
- stream.append ( " ..." );
- }
- else {
- if ( param.is_out ) {
- stream.append ( "<span class=\"" );
- stream.append ( css_keyword );
- stream.append ( "\">out</span> " );
- }
- else if ( param.is_ref ) {
- stream.append ( "<span class=\"" );
- stream.append ( css_keyword );
- stream.append ( "\">ref</span> " );
+ if (this.run == false) {
+ return ;
}
-
- this.write_type_reference ( param.type_reference, stream );
- stream.append_unichar ( ' ' );
- stream.append ( param.name );
}
}
- public override void write_parameter_list ( ParameterListHandler thandler, void* ptr ) {
- weak GLib.StringBuilder stream = (GLib.StringBuilder)ptr;
- bool open_bracket = false;
-
- Gee.ArrayList<FormalParameter> params = thandler.param_list;
- int size = params.size;
- int i = 0;
-
- stream.append_unichar ( '(' );
-
- foreach ( FormalParameter param in params ) {
- i++;
-
- if ( param.has_default_value == true && open_bracket == false ) {
- stream.append ( "<span class=\"" );
- stream.append ( css_optional_parameter );
- stream.append ( "\">[" );
- open_bracket = true;
+ public override void visit_namespace (Namespace ns) {
+ if (ns.name != null) {
+ this.write_insert_into_valadoc_element (ns);
+ if (this.run == false) {
+ return ;
}
- this.write_formal_parameter ( param, stream );
- if ( i != size ) {
- stream.append ( ", " );
- }
- else if ( open_bracket == true ) {
- stream.append ( "]</span>" );
+ this.write_insert_into_code_element (ns);
+ if (this.run == false) {
+ return ;
}
}
- stream.append_unichar ( ')' );
- }
-
- private void write_exception_list ( ExceptionHandler exception_handler, GLib.StringBuilder stream ) {
- Gee.ReadOnlyCollection<DataType> error_domains = exception_handler.get_error_domains ();
- int size = error_domains.size;
- int i = 1;
+ foreach (Namespace sns in ns.get_namespace_list()) {
+ sns.visit(this);
- if ( size == 0 )
- return ;
-
- stream.append ( " <span class=\"" );
- stream.append ( css_keyword );
- stream.append ( "\">throws</span> " );
-
-
- foreach ( DataType type in error_domains ) {
- this.write_type_name ( type, stream );
- if ( error_domains.size > i ) {
- stream.append ( ", " );
- }
- i++;
+ if (this.run == false) {
+ return ;
+ }
}
- }
- public override void write_method ( void* ptr, Valadoc.Method m, Valadoc.MethodHandler parent ) {
- GLib.StringBuilder modifiers = new GLib.StringBuilder ( "" );
- weak GLib.StringBuilder stream = (GLib.StringBuilder)ptr;
- this.position = m;
+ foreach (Interface iface in ns.get_interface_list()) {
+ iface.visit(this);
- this.write_accessor ( m, stream );
-
- if ( m.is_abstract )
- modifiers.append ( " abstract" );
- else if ( m.is_virtual )
- modifiers.append ( " virtual" );
- else if ( m.is_override )
- modifiers.append ( " override" );
- if ( m.is_static )
- modifiers.append ( " static" );
- if ( m.is_inline )
- modifiers.append ( " inline" );
-
- if ( modifiers.len > 0 ) {
- stream.append ( " <span class=\"" );
- stream.append ( css_keyword );
- stream.append ( "\">" );
- stream.append ( modifiers.str );
- stream.append ( "</span>" );
+ if (this.run == false) {
+ return ;
+ }
}
- this.write_type_reference ( m.type_reference, stream );
- stream.append ( m.name );
- stream.append_unichar ( ' ' );
- this.write_parameter_list ( m, stream );
+ foreach (Class cl in ns.get_class_list()) {
+ cl.visit(this);
- if ( m.is_yields ) {
- stream.append ( " <span class=\"" );
- stream.append ( css_keyword );
- stream.append ( "\">yields</span> " );
+ if (this.run == false) {
+ return ;
+ }
}
- this.write_exception_list ( m, stream );
- }
-
- public override void write_type_parameter ( TypeParameter param, void* ptr ) {
- weak GLib.StringBuilder stream = (GLib.StringBuilder)ptr;
- stream.append ( param.name );
- }
-
- public override void write_template_parameters ( TemplateParameterListHandler thandler, void* ptr ) {
- weak GLib.StringBuilder stream = (GLib.StringBuilder)ptr;
- int i = 1;
+ foreach (Struct stru in ns.get_struct_list()) {
+ stru.visit(this);
- var lst = thandler.get_template_param_list( );
- if ( lst.size == 0 )
- return ;
-
- stream.append ( "<" ); // <
-
- foreach ( TypeParameter param in lst ) {
- param.write ( this, stream );
- if ( lst.size > i )
- stream.append ( ", " );
-
- i++;
+ if (this.run == false) {
+ return ;
+ }
}
- stream.append ( ">" ); // >
- }
-
- public override void write_field ( Valadoc.Field field, Valadoc.FieldHandler parent, void* ptr ) {
- weak GLib.StringBuilder stream = (GLib.StringBuilder)ptr;
- this.position = field;
- this.write_accessor ( field, stream );
+ foreach (Enum en in ns.get_enum_list()) {
+ en.visit(this);
- if ( field.is_volatile ) {
- stream.append ( " <span class=\"" );
- stream.append ( css_keyword );
- stream.append ( "\">volatile</span>" );
+ if (this.run == false) {
+ return ;
+ }
}
- this.write_type_reference ( field.type_reference, stream );
-
- stream.append_unichar ( ' ' );
- stream.append ( field.name );
- }
-
- public override void write_constant ( Constant constant, ConstantHandler parent, void* ptr ) {
- weak GLib.StringBuilder stream = (GLib.StringBuilder)ptr;
- this.position = constant;
-
- this.write_accessor ( constant, stream );
- stream.append ( " <span class=\"" );
- stream.append ( css_keyword );
- stream.append ( "\"> const </span>" );
-
- this.write_type_reference ( constant.type_reference, stream );
-
- stream.append_unichar ( ' ' );
- stream.append ( constant.name );
- }
+ foreach (ErrorDomain err in ns.get_error_domain_list()) {
+ err.visit(this);
- public override void write_property_accessor ( Valadoc.PropertyAccessor propac, void* ptr ) {
- weak GLib.StringBuilder stream = (GLib.StringBuilder)ptr;
- Property prop = (Property)propac.parent;
-
- stream.append ( "<span class=\"" );
- stream.append ( css_keyword );
- stream.append ( "\">" );
-
- if ( !(prop.is_public == propac.is_public && prop.is_private == propac.is_private && prop.is_protected == propac.is_protected) ) {
- // FIXME: PropertyAccessor isn't a SymbolAccessibility.
- if ( propac.is_public )
- stream.append ( "public " );
- else if ( propac.is_protected )
- stream.append ( "protected " );
- else if ( propac.is_private )
- stream.append ( "private " );
+ if (this.run == false) {
+ return ;
+ }
}
- if ( propac.is_owned )
- stream.append ( "owned " );
-
- if ( propac.is_get )
- stream.append ( "get" );
- else if ( propac.is_set )
- stream.append ( "set" );
-
- stream.append ( "</span>; " );
- }
-
- public override void write_property ( Valadoc.Property prop, void* ptr ) {
- GLib.StringBuilder modifiers = new GLib.StringBuilder ( "" );
- weak GLib.StringBuilder stream = (GLib.StringBuilder)ptr;
- this.position = prop;
+ foreach (Delegate del in ns.get_delegate_list()) {
+ del.visit(this);
-
- this.write_accessor ( prop, stream );
-
- if ( prop.is_virtual ) {
- modifiers.append ( " virtual " );
- }
- else if ( prop.is_abstract ) {
- modifiers.append ( " abstract " );
- }
- else if ( prop.is_override ) {
- modifiers.append ( " override " );
- }
-
- if ( modifiers.len > 0 ) {
- stream.append ( " <span class=\"" );
- stream.append ( css_keyword );
- stream.append ( "\">" );
- stream.append ( modifiers.str );
- stream.append ( "</span> " );
+ if (this.run == false) {
+ return ;
+ }
}
- this.write_type_reference ( prop.type_reference, stream );
- stream.append_unichar ( ' ' );
- stream.append ( prop.name );
- stream.append ( " { " );
-
- if ( prop.setter != null )
- this.write_property_accessor ( prop.setter, stream );
-
-
- stream.append_unichar ( ' ' );
-
- if ( prop.getter != null )
- this.write_property_accessor ( prop.getter, stream );
-
- stream.append ( " }" );
- }
-
- public override void write_signal ( Valadoc.Signal sig, void* ptr ) {
- weak GLib.StringBuilder stream = (GLib.StringBuilder)ptr;
- this.position = sig;
+ foreach (Method m in ns.get_method_list()) {
+ m.visit(this, ns);
- this.write_accessor ( sig, stream );
-
- stream.append ( " <span class=\"" );
- stream.append ( css_keyword );
- stream.append ( "\">" );
-
- if ( sig.is_virtual == true )
- stream.append ( "virtual " );
-
- stream.append ( "signal</span> " );
-
- this.write_type_reference ( sig.type_reference, stream );
- stream.append_unichar ( ' ' );
- stream.append ( sig.name );
- stream.append_unichar ( ' ' );
- this.write_parameter_list ( sig, stream );
- }
-
- public override void write_enum_value ( Valadoc.EnumValue enval, void* ptr ) {
- }
-
- public override void write_error_code ( Valadoc.ErrorCode errcode, void* ptr ) {
- }
-
- public override void write_delegate ( Valadoc.Delegate del, void* ptr ) {
- weak GLib.StringBuilder stream = (GLib.StringBuilder)ptr;
- this.position = del;
-
- this.write_accessor ( del, stream );
-
- stream.append ( " <span class=\"" );
- stream.append ( css_keyword );
- stream.append ( "\">delegate</span> " );
-
- this.write_type_reference ( del.type_reference, stream );
-
- stream.append_unichar ( ' ' );
- stream.append ( del.name );
- stream.append_unichar ( ' ' );
- this.write_parameter_list ( del, stream );
- this.write_exception_list ( del, stream );
- }
-
- public override void write_enum ( Valadoc.Enum en, void* ptr ) {
- }
-
- public override void write_error_domain ( Valadoc.ErrorDomain errdom, void* ptr ) {
- }
-
- private void write_accessor ( Valadoc.SymbolAccessibility element, GLib.StringBuilder stream ) {
- stream.append ( "<span class=\"%s\">public</span> " );
- stream.append ( css_keyword );
- stream.append ( "\">" );
-
- if ( element.is_public )
- stream.append ( "public" );
- else if ( element.is_protected )
- stream.append ( "protected" );
- else if ( element.is_private )
- stream.append ( "private" );
-
- stream.append ( "</span> " );
- }
-
- public override void write_struct ( Valadoc.Struct stru, void* ptr ) {
- weak GLib.StringBuilder stream = (GLib.StringBuilder)ptr;
- this.position = stru;
-
- this.write_accessor ( stru, stream );
- stream.append ( "<span class=\"" );
- stream.append ( css_keyword );
- stream.append ( "\">struct</span> " );
- stream.append ( stru.name );
-
- this.write_template_parameters ( stru, stream );
- this.write_inheritance_list ( stru, stream );
- }
-
- private void write_inheritance_list ( Valadoc.ContainerDataType dtype, GLib.StringBuilder stream ) {
- Gee.Collection<DataType> lst = dtype.get_parent_types ( );
- int size = lst.size;
- int i = 1;
-
- if ( size == 0 )
- return ;
-
- stream.append ( " : " );
-
- foreach ( DataType cntype in lst ) {
- this.write_type_name ( cntype, stream );
- if ( size > i )
- stream.append ( ", " );
-
- i++;
+ if (this.run == false) {
+ return ;
+ }
}
- stream.append_unichar ( ' ' );
- }
-
- public override void write_class ( Valadoc.Class cl, void* ptr ) {
- weak GLib.StringBuilder stream = (GLib.StringBuilder)ptr;
- this.position = cl;
-
- this.write_accessor ( cl, stream );
-
- stream.append ( "<span class=\"" );
- stream.append ( css_keyword );
- stream.append ( "\">" );
+ foreach (Field f in ns.get_field_list()) {
+ f.visit(this, ns);
- if ( cl.is_abstract )
- stream.append ( "abstract " );
-
- stream.append ( " class</span> " );
- stream.append ( cl.name );
-
- this.write_template_parameters ( cl, stream );
- this.write_inheritance_list ( cl, stream );
- }
-
- public override void write_interface ( Valadoc.Interface iface, void* ptr ) {
- weak GLib.StringBuilder stream = (GLib.StringBuilder)ptr;
- this.position = iface;
-
- this.write_accessor ( iface, stream );
-
- stream.append ( "<span class=\"" );
- stream.append ( css_keyword );
- stream.append ( "\">interface</span> " );
- stream.append ( iface.name );
+ if (this.run == false) {
+ return ;
+ }
+ }
- this.write_template_parameters ( iface, stream );
- this.write_inheritance_list ( iface, stream );
- }
+ foreach (Constant c in ns.get_constant_list()) {
+ c.visit(this, ns);
- public override void write_namespace ( Valadoc.Namespace ns, void* ptr ) {
- }
+ if (this.run == false) {
+ return ;
+ }
+ }
- public override void write_file ( Valadoc.Package file, void* ptr ) {
+ this.file.printf ("INSERT INTO `ValadocNamespaces` (`id`) VALUES ((SELECT `id` FROM `ValadocElement` WHERE BINARY `fullname`='%s' LIMIT 1));\n", this.get_type_path(ns));
}
-}
-
-
-
-
-
-
-
-
-public class Valadoc.HtmlDoclet : Valadoc.Doclet {
- private Gee.HashMap<Object, ulong> ids = new Gee.HashMap<Object, ulong> ();
- private GLib.List<Package> exist = new GLib.List<Package> ();
- private Valadoc.ValadocOrgLanglet langlet;
- private Settings settings;
- private bool run = true;
- private Database mysql;
- private int level;
-
- private Namespace? get_global_namespace ( Package pkg ) {
- foreach ( Namespace ns in pkg.get_namespace_list() ) {
- if ( ns.name == null ) {
- return ns;
- }
+ public override void visit_interface ( Interface iface ) {
+ this.write_insert_into_valadoc_element (iface);
+ if (this.run == false) {
+ return ;
}
- return null;
- }
- private ulong get_package_id ( Package element ) {
- if ( this.ids.contains ( element ) == true ) {
- return this.ids.get ( element );
+ this.write_insert_into_code_element (iface);
+ if (this.run == false) {
+ return ;
}
- string query = "SELECT `id` FROM `Element` NATURAL JOIN `PackageElement` WHERE `name`='" + element.name + "' LIMIT 1";
- if ( mysql.query ( query ) != 0 ) {
- stderr.printf ("ERROR: '%s'\n", mysql.error ());
- return 0;
- }
+ foreach (Delegate del in iface.get_delegate_list()) {
+ del.visit(this);
- Result? res = mysql.store_result ();
- if ( res == null ) {
- return 0;
+ if (this.run == false) {
+ return ;
+ }
}
- weak string[]? row = res.fetch_row ();
- if ( row == null ) {
- return 0;
- }
+ foreach (Struct stru in iface.get_struct_list()) {
+ stru.visit(this);
- ulong id = row[0].to_ulong ();
- Namespace? ns = this.get_global_namespace ( element );
- if ( ns != null ) {
- this.ids.set ( ns, id );
+ if (this.run == false) {
+ return ;
+ }
}
- this.ids.set ( element, id );
- return id;
- }
+ foreach (Method m in iface.get_method_list()) {
+ m.visit(this, iface);
- private ulong get_type_id ( DocumentedElement element ) {
- if ( this.ids.contains ( element ) == true ) {
- return this.ids.get ( element );
+ if (this.run == false) {
+ return ;
+ }
}
+ foreach (Field f in iface.get_field_list()) {
+ f.visit(this, iface);
- GLib.Queue<DocumentedElement> stack = new Queue<DocumentedElement> ();
-
- for ( DocumentedElement pos = element; pos != null ; pos = (DocumentedElement)pos.parent ) {
- stack.push_head ( pos );
+ if (this.run == false) {
+ return ;
+ }
}
- Package pkg = (Package)stack.pop_head ( );
- ulong lastid = this.get_package_id ( pkg );
-
- foreach ( DocumentedElement pos in stack.head ) {
- if ( this.ids.contains ( pos ) ) {
- lastid = this.ids.get ( pos );
- continue ;
- }
-
- string query = "SELECT `id` FROM `ChildElement` NATURAL JOIN `Element` WHERE `name`='%s' AND `parentelement`='%lu' LIMIT 1".printf ( pos.name, lastid );
- bool tmp = mysql.query ( query ) == 0;
- if ( tmp == false ) {
- stderr.printf ("ERROR: '%s'\n", mysql.error ());
- return 0;
- }
-
- Result? res = mysql.store_result ();
- if ( res == null ) {
- stderr.printf ("ERROR: '%s'\n", mysql.error ());
- return 0;
- }
-
- weak string[]? row = res.fetch_row ();
- if ( row == null ) {
- return 0;
- }
-
- lastid = row[0].to_ulong ();
+ foreach (Enum en in iface.get_enum_list()) {
+ en.visit(this);
- if ( lastid == 0 ) {
- return 0;
- }
-
- this.ids.set ( pos, lastid );
+ if (this.run == false) {
+ return ;
+ }
}
- return lastid;
- }
+ foreach (Class cl in iface.get_class_list()) {
+ cl.visit(this);
- private ulong db_create_element ( DocumentedElement element ) {
- string name = element.name;
- if ( name == null ) {
- // err msg
- return 0;
+ if (this.run == false) {
+ return ;
+ }
}
- GLib.StringBuilder query = new GLib.StringBuilder ( "INSERT INTO `Element` (`name`,`fullname`,`txtid`) VALUES ( '");
- query.append ( name );
- query.append ( "', '" );
- query.append ( element.full_name () );
- query.append ( "', '" );
+ foreach (Property prop in iface.get_property_list()) {
+ prop.visit(this);
- if ( element is Package == false ) {
- query.append ( element.package.name );
- query.append_unichar ( '/' );
+ if (this.run == false) {
+ return ;
+ }
}
- query.append ( element.full_name () );
- query.append ( "');" );
- bool tmp = mysql.query ( query.str ) == 0;
- if ( tmp == false ) {
- // err msg
- return 0;
+ foreach (Signal sig in iface.get_signal_list()) {
+ sig.visit(this);
+
+ if (this.run == false) {
+ return ;
+ }
}
- ulong id = this.mysql.insert_id ();
- this.ids.set ( element, id );
- return id;
+ this.file.printf ("INSERT INTO `ValadocInterfaces` (`id`) VALUES ((SELECT `id` FROM `ValadocElement` WHERE BINARY `fullname`='%s' LIMIT 1));\n", this.get_type_path(iface));
}
- private ulong db_create_property ( Property element ) {
- ulong id = db_create_element ( element );
- if ( id == 0 ) {
- return 0;
+ public override void visit_class ( Class cl ) {
+ this.write_insert_into_valadoc_element (cl);
+ if (this.run == false) {
+ return ;
}
- GLib.StringBuilder query = new GLib.StringBuilder ( "INSERT INTO `PropertyElement` (`id`,`abstract`,`virtual`,`override`) VALUES ('" );
- query.append ( id.to_string() );
- query.append ( "', '" );
- query.append ( this.db_boolean ( element.is_abstract ) );
- query.append ( "', '" );
- query.append ( this.db_boolean ( element.is_virtual ) );
- query.append ( "', '" );
- query.append ( this.db_boolean ( element.is_override ) );
- query.append ( "');" );
-
- bool tmp = mysql.query ( query.str ) == 0;
- if ( tmp == false ) {
- stderr.printf ("ERROR: '%s'\n", mysql.error ());
- return 0;
+ this.write_insert_into_code_element (cl);
+ if (this.run == false) {
+ return ;
}
- ulong tmp2 = this.db_create_accessibility ( element );
- if ( tmp2 == 0 )
- return 0;
-
- tmp = this.db_create_with_api_element ( element );
- if ( tmp == false )
- return 0;
-
- tmp = this.db_add_child_element ( element );
- if ( tmp == false )
- return 0;
+ foreach (Delegate del in cl.get_delegate_list()) {
+ del.visit(this);
- return id;
- }
-
- private ulong db_create_field ( Field element ) {
- ulong id = db_create_element ( element );
- if ( id == 0 )
- return 0;
-
- bool tmp = mysql.query ( "INSERT INTO `FieldElement` (`id`,`volatile`) VALUES ('%lu','%s');".printf ( id, this.db_boolean ( element.is_volatile ) ) ) == 0;
- if ( tmp == false ) {
- stderr.printf ("ERROR: '%s'\n", mysql.error ());
- return 0;
+ if (this.run == false) {
+ return ;
+ }
}
- ulong tmp2 = this.db_create_accessibility ( element );
- if ( tmp2 == 0 )
- return 0;
+ foreach (Struct stru in cl.get_struct_list()) {
+ stru.visit(this);
- tmp = this.db_create_with_api_element ( element );
- if ( tmp == false )
- return 0;
-
- tmp = this.db_add_child_element ( element );
- if ( tmp == false )
- return 0;
-
- return id;
- }
-
- private ulong db_create_constant ( Constant element ) {
- ulong id = db_create_element ( element );
- if ( id == 0 )
- return 0;
-
- bool tmp = mysql.query ( "INSERT INTO `ConstantElement` (`id`) VALUES ('%lu');".printf ( id ) ) == 0;
- if ( tmp == false ) {
- stderr.printf ("ERROR: '%s'\n", mysql.error ());
- return 0;
+ if (this.run == false) {
+ return ;
+ }
}
- ulong tmp2 = this.db_create_accessibility ( element );
- if ( tmp2 == 0 )
- return 0;
-
- tmp = this.db_create_with_api_element ( element );
- if ( tmp == false )
- return 0;
-
- tmp = this.db_add_child_element ( element );
- if ( tmp == false )
- return 0;
-
- return id;
- }
+ foreach (Method m in cl.get_method_list()) {
+ m.visit(this, cl);
- private bool db_add_child_element ( Basic element ) {
- bool tmp = mysql.query ( "INSERT INTO `ChildElement` (`id`, `parentelement`) VALUES ('%lu', '%lu');".printf ( this.ids.get ( element ), this.ids.get ( element.parent ) ) ) == 0;
- if ( tmp == false ) {
- stderr.printf ("ERROR: '%s'\n", mysql.error ());
- return false;
+ if (this.run == false) {
+ return ;
+ }
}
- return true;
- }
- private ulong db_create_package ( Package element ) {
- ulong id = db_create_element ( element );
- if ( id == 0 )
- return 0;
+ foreach (Field f in cl.get_field_list()) {
+ f.visit(this, cl);
- bool tmp = mysql.query ( "INSERT INTO `PackageElement` (`id`) VALUES ('%lu');".printf ( id ) ) == 0;
- if ( tmp == false ) {
- stderr.printf ("ERROR: '%s'\n", mysql.error ());
- return 0;
+ if (this.run == false) {
+ return ;
+ }
}
- return id;
- }
+ foreach (Enum en in cl.get_enum_list()) {
+ en.visit(this);
- private ulong db_create_namespace ( Namespace element ) {
- if ( element.name == null ) {
- ulong id = this.get_type_id ( element.package );
- this.ids.set ( element, id );
- return id;
+ if (this.run == false) {
+ return ;
+ }
}
- ulong id = db_create_element ( element );
- if ( id == 0 )
- return 0;
-
+ foreach (Class scl in cl.get_class_list()) {
+ scl.visit(this);
- bool tmp = mysql.query ( "INSERT INTO `NamespaceElement` (`id`) VALUES ('%lu');".printf ( id ) ) == 0;
- if ( tmp == false ) {
- stderr.printf ("ERROR: '%s'\n", mysql.error ());
- return 0;
+ if (this.run == false) {
+ return ;
+ }
}
- tmp = this.db_add_child_element ( element );
- if ( tmp == false )
- return 0;
+ foreach (Property prop in cl.get_property_list()) {
+ prop.visit(this);
- return id;
- }
-
- private ulong db_create_type ( DocumentedElement element ) {
- ulong id = db_create_element ( element );
- if ( id == 0 )
- return 0;
-
- bool tmp = mysql.query ( "INSERT INTO `TypeElement` (`id`) VALUES ('%lu');".printf ( id ) ) == 0;
- if ( tmp == false ) {
- stderr.printf ("ERROR: '%s'\n", mysql.error ());
- return 0;
+ if (this.run == false) {
+ return ;
+ }
}
- tmp = this.db_create_with_api_element ( element );
- if ( tmp == false )
- return 0;
-
- return id;
- }
-
- private string db_boolean ( bool boolean ) {
- return ( boolean == true )? "1" : "0";
- }
+ foreach (Signal sig in cl.get_signal_list()) {
+ sig.visit(this);
- private bool db_create_class_parent ( Class element ) {
- ContainerDataType parent = element.parent_class;
- if ( parent == null )
- return true;
-
- ulong id = this.get_type_id ( element );
- ulong pid = this.get_type_id ( parent );
-
- GLib.StringBuilder query = new GLib.StringBuilder ( "INSERT INTO `ParentClassElement` (`id`, `parent`) VALUES ('" );
- query.append ( id.to_string() );
- query.append ( "', '" );
- query.append ( pid.to_string() );
- query.append ( "');" );
-
- bool tmp = mysql.query ( query.str ) == 0;
- if ( tmp == false ) {
- stderr.printf ("ERROR: '%s'\n", mysql.error ());
- return false;
+ if (this.run == false) {
+ return ;
+ }
}
- return true;
- }
- private bool db_create_interface_list ( ContainerDataType element ) {
- Gee.Collection<DataType> interfacelist = element.get_parent_types ();
- if ( interfacelist.size == 0 )
- return true;
-
- GLib.StringBuilder query = new GLib.StringBuilder ( "INSERT INTO `ImplementedInterfaceList` (`id`, `interface`) VALUES ('" );
- query.append ( this.get_type_id ( element ).to_string() );
- query.append ( "', '%lu');" );
-
- foreach ( DataType type in interfacelist ) {
- if ( type is Valadoc.Interface ) {
- bool tmp = mysql.query ( query.str.printf ( this.get_type_id ( type ) ) ) == 0;
- if ( tmp == false ) {
- stderr.printf ("ERROR: '%s'\n", mysql.error ());
- return false;
- }
- }
- }
- return true;
- }
+ foreach (Constant c in cl.get_constant_list()) {
+ c.visit(this, cl);
- private bool db_create_with_image_element ( DocumentedElement element ) {
- string realimgpath = this.settings.path + element.package.name + "/" + element.full_name () + ".png";
- if ( element is Class ) {
- Diagrams.write_class_diagram ( (Class)element, realimgpath );
- }
- else if ( element is Interface ) {
- Diagrams.write_interface_diagram ( (Interface)element, realimgpath );
- }
- else if ( element is Struct ) {
- Diagrams.write_struct_diagram ( (Struct)element, realimgpath );
+ if (this.run == false) {
+ return ;
+ }
}
- return true;
- }
-
- private bool db_create_with_api_element ( DocumentedElement element ) {
- GLib.StringBuilder stream = new GLib.StringBuilder ();
- if ( element is Class ) {
- ((Class)element).write ( this.langlet, stream );
- }
- else if ( element is Interface ) {
- ((Interface)element).write ( this.langlet, stream );
- }
- else if ( element is Struct ) {
- ((Struct)element).write ( this.langlet, stream );
- }
- else if ( element is Method ) {
- ((Method)element).write ( this.langlet, stream, (MethodHandler)element.parent );
- }
- else if ( element is Delegate ) {
- ((Delegate)element).write ( this.langlet, stream );
- }
- else if ( element is Signal ) {
- ((Signal)element).write ( this.langlet, stream );
- }
- else if ( element is Property ) {
- ((Property)element).write ( this.langlet, stream );
- }
- else if ( element is Constant ) {
- ((Constant)element).write ( this.langlet, stream, (ConstantHandler)element.parent );
- }
- else if ( element is Field ) {
- ((Field)element).write ( this.langlet, stream, (FieldHandler)element.parent );
+ string modifier;
+ if (cl.is_abstract) {
+ modifier = "ABSTRACT";
}
else {
- return true;
- }
-
- unichar[] code = new unichar[stream.len*2+1];
- this.mysql.real_escape_string ( (string)code, stream.str, stream.len );
-
- GLib.StringBuilder query = new GLib.StringBuilder ( "INSERT INTO `WithApiElement` (`id`, `code`) VALUES ('" );
- query.append ( this.ids.get ( element ).to_string() );
- query.append ( "', '" );
- query.append ( (string)code );
- query.append ( "');" );
- bool tmp = mysql.query ( query.str ) == 0;
- if ( tmp == false ) {
- stderr.printf ("ERROR: '%s'\n", mysql.error ());
- return false;
- }
- return true;
- }
-
- private bool db_create_exception_list ( ExceptionHandler element ) {
- Gee.ReadOnlyCollection<DataType> list = element.get_error_domains ();
- if ( list.size == 0 )
- return true;
-
- GLib.StringBuilder query = new GLib.StringBuilder ( "INSERT INTO `ExceptionList` (`id`, `errordomain`) VALUES ('" );
- query.append ( this.ids.get ( element ).to_string() );
- query.append ( "', '%d');" );
-
- foreach ( DataType type in list ) {
- bool tmp = mysql.query ( query.str.printf ( this.get_type_id ( type ) ) ) == 0;
- if ( tmp == false ) {
- stderr.printf ("ERROR: '%s'\n", mysql.error ());
- return false;
- }
+ modifier = "NORMAL";
}
- return true;
- }
- private ulong db_create_accessibility ( SymbolAccessibility element ) {
- ulong id = this.ids.get ( element );
-
- GLib.StringBuilder query = new GLib.StringBuilder ( "INSERT INTO `AccessibilityElement` (`id`,`accessibility`) VALUES ('" );
- query.append ( id.to_string() );
- query.append ( "', '" );
-
- if ( element.is_protected )
- query.append ( "PROTECTED" );
- else if ( element.is_private )
- query.append ( "PRIVATE" );
- else if ( element.is_public )
- query.append ( "PUBLIC" );
-
- query.append ( "');" );
-
- bool tmp = mysql.query ( query.str ) == 0;
- if ( tmp == false ) {
- stderr.printf ("ERROR: '%s'\n", mysql.error ());
- return 0;
- }
-
- return id;
+ this.file.printf ("INSERT INTO `ValadocClasses` (`id`, `modifier`) VALUES ((SELECT `id` FROM `ValadocElement` WHERE BINARY `fullname`='%s' LIMIT 1),'%s');\n", this.get_type_path(cl), modifier);
}
- private ulong db_create_class ( Class element ) {
- ulong id = this.db_create_type ( element );
- if ( id == 0 )
- return 0;
-
- id = this.db_create_accessibility ( element );
- if ( id == 0 )
- return 0;
-
- GLib.StringBuilder query = new GLib.StringBuilder ( "INSERT INTO `ClassElement` (`id`,`abstract`) VALUES ('" );
- query.append ( id.to_string() );
- query.append ( "', '" );
- query.append ( this.db_boolean ( element.is_abstract ) );
- query.append ( "');" );
-
- bool tmp = mysql.query ( query.str ) == 0;
- if ( tmp == false ) {
- stderr.printf ("ERROR: '%s'\n", mysql.error ());
- return 0;
+ public override void visit_struct ( Struct stru ) {
+ this.write_insert_into_valadoc_element (stru);
+ if (this.run == false) {
+ return ;
}
- tmp = this.db_create_with_image_element ( element );
- if ( tmp == false )
- return 0;
-
- tmp = this.db_add_child_element ( element );
- if ( tmp == false )
- return 0;
-
- return id;
- }
-
- private ulong db_create_enum ( Enum element ) {
- ulong id = db_create_type ( element );
- if ( id == 0 )
- return 0;
-
- id = db_create_accessibility ( element );
- if ( id == 0 )
- return 0;
-
- GLib.StringBuilder query = new GLib.StringBuilder ( "INSERT INTO `EnumElement` (`id`) VALUES ('" );
- query.append ( id.to_string() );
- query.append ( "');" );
-
- bool tmp = mysql.query ( query.str ) == 0;
- if ( tmp == false ) {
- stderr.printf ("ERROR: '%s'\n", mysql.error ());
- return 0;
+ this.write_insert_into_code_element (stru);
+ if (this.run == false) {
+ return ;
}
- tmp = this.db_add_child_element ( element );
- if ( tmp == false )
- return 0;
-
- return id;
- }
+ foreach (Method m in stru.get_method_list()) {
+ m.visit(this, stru);
- private ulong db_create_errordomain ( ErrorDomain element ) {
- ulong id = db_create_type ( element );
- if ( id == 0 )
- return 0;
-
- id = db_create_accessibility ( element );
- if ( id == 0 )
- return 0;
-
- GLib.StringBuilder query = new GLib.StringBuilder ( "INSERT INTO `ErrordomainElement` (`id`) VALUES ('" );
- query.append ( id.to_string() );
- query.append ( "');" );
-
- bool tmp = mysql.query ( query.str ) == 0;
- if ( tmp == false ) {
- stderr.printf ("ERROR: '%s'\n", mysql.error ());
- return 0;
+ if (this.run == false) {
+ return ;
+ }
}
- tmp = this.db_add_child_element ( element );
- if ( tmp == false )
- return 0;
-
- return id;
- }
-
- private ulong db_create_enumvalue ( EnumValue element ) {
- ulong id = db_create_element ( element );
- if ( id == 0 )
- return 0;
-
- GLib.StringBuilder query = new GLib.StringBuilder ( "INSERT INTO `EnumValueElement` (`id`) VALUES ('" );
- query.append ( id.to_string() );
- query.append ( "');" );
+ foreach (Field f in stru.get_field_list()) {
+ f.visit(this, stru);
- bool tmp = mysql.query ( query.str ) == 0;
- if ( tmp == false ) {
- stderr.printf ("ERROR: '%s'\n", mysql.error ());
- return 0;
+ if (this.run == false) {
+ return ;
+ }
}
- tmp = this.db_add_child_element ( element );
- if ( tmp == false )
- return 0;
-
- return id;
- }
-
- private ulong db_create_errorcode ( ErrorCode element ) {
- ulong id = db_create_element ( element );
- if ( id == 0 )
- return 0;
+ foreach (Constant c in stru.get_constant_list()) {
+ c.visit(this, stru);
- GLib.StringBuilder query = new GLib.StringBuilder ( "INSERT INTO `ErrorCodeElement` (`id`) VALUES ('" );
- query.append ( id.to_string() );
- query.append ( "');" );
-
- bool tmp = mysql.query ( query.str ) == 0;
- if ( tmp == false ) {
- stderr.printf ("ERROR: '%s'\n", mysql.error ());
- return 0;
+ if (this.run == false) {
+ return ;
+ }
}
- tmp = this.db_add_child_element ( element );
- if ( tmp == false )
- return 0;
-
- return id;
+ this.file.printf ("INSERT INTO `ValadocStructs` (`id`) VALUES ((SELECT `id` FROM `ValadocElement` WHERE BINARY `fullname`='%s' LIMIT 1));\n", this.get_type_path(stru));
}
- private ulong db_create_interface ( Interface element ) {
- ulong id = db_create_type ( element );
- if ( id == 0 )
- return 0;
-
- id = db_create_accessibility ( element );
- if ( id == 0 )
- return 0;
-
- GLib.StringBuilder query = new GLib.StringBuilder ( "INSERT INTO `InterfaceElement` (`id`) VALUES ('" );
- query.append ( id.to_string() );
- query.append ( "');" );
-
- bool tmp = mysql.query ( query.str ) == 0;
- if ( tmp == false ) {
- stderr.printf ("ERROR: '%s'\n", mysql.error ());
- return 0;
+ public override void visit_error_domain ( ErrorDomain errdom ) {
+ this.write_insert_into_valadoc_element (errdom);
+ if (this.run == false) {
+ return ;
}
- tmp = this.db_create_with_image_element ( element );
- if ( tmp == false )
- return 0;
-
- tmp = this.db_add_child_element ( element );
- if ( tmp == false )
- return 0;
-
- return id;
- }
-
- private ulong db_create_delegate ( Delegate element ) {
- ulong id = db_create_type ( element );
- if ( id == 0 )
- return 0;
-
- id = db_create_accessibility ( element );
- if ( id == 0 )
- return 0;
-
- GLib.StringBuilder query = new GLib.StringBuilder ( "INSERT INTO `DelegateElement` (`id`) VALUES ('" );
- query.append ( id.to_string() );
- query.append ( "');" );
-
- bool tmp = mysql.query ( query.str ) == 0;
- if ( tmp == false ) {
- stderr.printf ("ERROR: '%s'\n", mysql.error ());
- return 0;
+ this.write_insert_into_code_element (errdom);
+ if (this.run == false) {
+ return ;
}
- tmp = this.db_add_child_element ( element );
- if ( tmp == false )
- return 0;
-
- return id;
- }
+ foreach (Method m in errdom.get_method_list()) {
+ m.visit(this, errdom);
- private ulong db_create_method ( Method element ) {
- ulong id = db_create_type ( element );
- if ( id == 0 )
- return 0;
-
- id = db_create_accessibility ( element );
- if ( id == 0 )
- return 0;
-
- GLib.StringBuilder query = new GLib.StringBuilder ( "INSERT INTO `MethodElement` (`id`, `yields`, `abstract`, `virtual`, `override`, `static`, `inline`, `constructor`) VALUES ('" );
- query.append ( id.to_string() );
- query.append ( "', '" );
- query.append ( this.db_boolean ( element.is_yields ) );
- query.append ( "', '" );
- query.append ( this.db_boolean ( element.is_abstract ) );
- query.append ( "', '" );
- query.append ( this.db_boolean ( element.is_virtual ) );
- query.append ( "', '" );
- query.append ( this.db_boolean ( element.is_override ) );
- query.append ( "', '" );
- query.append ( this.db_boolean ( element.is_static ) );
- query.append ( "', '" );
- query.append ( this.db_boolean ( element.is_inline ) );
- query.append ( "', '" );
- query.append ( this.db_boolean ( element.is_constructor ) );
- query.append ( "');" );
-
- bool tmp = mysql.query ( query.str ) == 0;
- if ( tmp == false ) {
- stderr.printf ("ERROR: '%s'\n", mysql.error ());
- return 0;
- }
-
- tmp = this.db_create_with_api_element ( element );
- if ( tmp == false )
- return 0;
-
- tmp = this.db_add_child_element ( element );
- if ( tmp == false )
- return 0;
-
- return id;
- }
-
- private ulong db_create_signal ( Signal element ) {
- ulong id = db_create_type ( element );
- if ( id == 0 )
- return 0;
-
- id = db_create_accessibility ( element );
- if ( id == 0 )
- return 0;
-
- GLib.StringBuilder query = new GLib.StringBuilder ( "INSERT INTO `SignalElement` (`id`, `virtual`) VALUES ('" );
- query.append ( id.to_string() );
- query.append ( "', '" );
- query.append ( this.db_boolean ( element.is_virtual ) );
- query.append ( "');" );
-
- bool tmp = mysql.query ( query.str ) == 0;
- if ( tmp == false ) {
- stderr.printf ("ERROR: '%s'\n", mysql.error ());
- return 0;
+ if (this.run == false) {
+ return ;
+ }
}
- tmp = this.db_create_with_api_element ( element );
- if ( tmp == false )
- return 0;
+ foreach (ErrorCode errc in errdom.get_error_code_list()) {
+ errc.visit(this);
- tmp = this.db_add_child_element ( element );
- if ( tmp == false )
- return 0;
-
- return id;
- }
-
- private ulong db_create_struct ( Struct element ) {
- ulong id = db_create_type ( element );
- if ( id == 0 )
- return 0;
-
- id = db_create_accessibility ( element );
- if ( id == 0 )
- return 0;
-
- GLib.StringBuilder query = new GLib.StringBuilder ( "INSERT INTO `StructElement` (`id`) VALUES ('" );
- query.append ( id.to_string() );
- query.append ( "');" );
-
- bool tmp = mysql.query ( query.str ) == 0;
- if ( tmp == false ) {
- stderr.printf ("ERROR: '%s'\n", mysql.error ());
- return 0;
+ if (this.run == false) {
+ return ;
+ }
}
- tmp = this.db_create_with_image_element ( element );
- if ( tmp == false )
- return 0;
-
- tmp = this.db_add_child_element ( element );
- if ( tmp == false )
- return 0;
-
- return id;
+ this.file.printf ("INSERT INTO `ValadocErrordomains` (`id`) VALUES ((SELECT `id` FROM `ValadocElement` WHERE BINARY `fullname`='%s' LIMIT 1));\n", this.get_type_path(errdom));
}
- private string getline ( ) {
- GLib.StringBuilder str = new GLib.StringBuilder ( );
-
- for ( int c = stdin.getc (); c != '\n' ; c = stdin.getc () ) {
- str.append_c ( (char)c );
- }
- return str.str;
- }
-
- public override void initialisation ( Settings settings, Tree tree ) {
- this.langlet = new Valadoc.ValadocOrgLanglet ( settings );
- this.settings = settings;
-
- this.mysql = new Database ();
- mysql.init ();
-
- DirUtils.create ( this.settings.path, 0777 );
-
-
- stdout.puts ( "host: " );
- string host = this.getline ( );
-
- stdout.puts ( "user: " );
- string usr = this.getline ( );
-
- stdout.puts ( "password: " );
- string pw = this.getline ( );
-
- stdout.puts ( "database: " );
- string db = this.getline ( );
-
- bool tmp = mysql.real_connect (host, usr, pw, db, 0, null, 0);
- if ( tmp == false ) {
- stderr.printf ("ERROR: '%s'\n", mysql.error ());
- return;
+ public override void visit_enum ( Enum en ) {
+ this.write_insert_into_valadoc_element (en);
+ if (this.run == false) {
+ return ;
}
- Gee.ReadOnlyCollection<Package> packages = tree.get_package_list ();
- this.level = 0;
-
- foreach ( Package pkg in packages ) {
- pkg.visit ( this );
+ this.write_insert_into_code_element (en);
+ if (this.run == false) {
+ return ;
}
- this.level = 1;
-
- foreach ( Package pkg in packages ) {
- if ( this.run == false ) {
- break;
- }
-
- pkg.visit ( this );
- }
- }
+ foreach (Method m in en.get_method_list()) {
+ m.visit(this, en);
- public override void visit_package ( Package pkg ) {
- if ( this.level == 0 ) {
- ulong id = this.get_package_id ( pkg );
- if ( id > 0 ) {
- this.exist.append ( pkg );
+ if (this.run == false) {
return ;
- }
+ }
+ }
- DirUtils.create ( this.settings.path + pkg.name, 0777 );
+ foreach (EnumValue enval in en.get_enum_values()) {
+ enval.visit(this);
- id = this.db_create_package ( pkg );
- if ( id == 0 ) {
- this.run = false;
+ if (this.run == false) {
return ;
- }
-
- pkg.visit_namespaces ( this );
- }
- else if ( this.exist.find ( pkg ) == null ) {
- pkg.visit_namespaces ( this );
+ }
}
+
+ this.file.printf ("INSERT INTO `ValadocEnum` (`id`) VALUES ((SELECT `id` FROM `ValadocElement` WHERE BINARY `fullname`='%s' LIMIT 1));\n", this.get_type_path(en));
}
- public override void visit_namespace ( Namespace ns ) {
- if ( this.run == false ) {
+ public override void visit_property ( Property prop ) {
+ this.write_insert_into_valadoc_element (prop);
+ if (this.run == false) {
return ;
}
- if ( this.level == 0 ) {
- ulong id = this.db_create_namespace ( ns );
- if ( id == 0 ) {
- this.run = false;
- return ;
- }
-
- ns.visit_namespaces ( this );
- ns.visit_classes ( this );
- ns.visit_interfaces ( this );
- ns.visit_structs ( this );
- ns.visit_enums ( this );
- ns.visit_error_domains ( this );
- ns.visit_delegates ( this );
- }
- else {
- ns.visit_namespaces ( this );
- ns.visit_classes ( this );
- ns.visit_interfaces ( this );
- ns.visit_structs ( this );
- ns.visit_enums ( this );
- ns.visit_error_domains ( this );
- ns.visit_delegates ( this );
- ns.visit_methods ( this );
- ns.visit_fields ( this );
- ns.visit_constants ( this );
- }
- }
-
- //TODO: parent list
- public override void visit_interface ( Interface iface ) {
- if ( this.run == false ) {
+ this.write_insert_into_code_element (prop);
+ if (this.run == false) {
return ;
}
- if ( this.level == 0 ) {
- ulong id = this.db_create_interface ( iface );
- if ( id == 0 ) {
- this.run = false;
- return ;
- }
-
- iface.visit_classes ( this );
- iface.visit_structs ( this );
- iface.visit_delegates ( this );
+ string modifier;
+ if (prop.is_virtual) {
+ modifier = "VIRTUAL";
+ }
+ else if (prop.is_abstract) {
+ modifier = "ABSTRACT";
}
+ //else if (prop.is_static) {
+ // modifier = "STATIC";
+ //}
else {
- bool tmp = this.db_create_interface_list ( iface );
- if ( tmp == false ) {
- this.run = false;
- return ;
- }
-
- iface.visit_methods ( this );
- iface.visit_signals ( this );
- iface.visit_properties ( this );
- iface.visit_fields ( this );
- iface.visit_classes ( this );
- iface.visit_structs ( this );
- iface.visit_delegates ( this );
+ modifier = "NORMAL";
}
+
+ this.file.printf ("INSERT INTO `ValadocProperties` (`id`, `modifier`) VALUES ((SELECT `id` FROM `ValadocElement` WHERE BINARY `fullname`='%s' LIMIT 1), '%s');\n", this.get_type_path(prop), modifier);
}
- public override void visit_class ( Class cl ) {
- if ( this.run == false ) {
+ public override void visit_constant ( Constant constant, ConstantHandler parent ) {
+ this.write_insert_into_valadoc_element (constant);
+ if (this.run == false) {
return ;
}
- if ( this.level == 0 ) {
- ulong id = this.db_create_class ( cl );
- if ( id == 0 ) {
- this.run = false;
- return ;
- }
-
- cl.visit_classes ( this );
- cl.visit_structs ( this );
- cl.visit_enums ( this );
- cl.visit_delegates ( this );
- }
- else {
- bool tmp = this.db_create_interface_list ( cl );
- if ( tmp == false ) {
- this.run = false;
- return ;
- }
-
- tmp = this.db_create_class_parent ( cl );
- if ( tmp == false ) {
- this.run = false;
- return ;
- }
-
- cl.visit_construction_methods ( this );
- cl.visit_methods ( this );
- cl.visit_signals ( this );
- cl.visit_properties ( this );
- cl.visit_fields ( this );
- cl.visit_constants ( this );
- cl.visit_classes ( this );
- cl.visit_structs ( this );
- cl.visit_enums ( this );
- cl.visit_delegates ( this );
- }
- }
-
- //TODO: parent list
- public override void visit_struct ( Struct stru ) {
- if ( this.run == false ) {
+ this.write_insert_into_code_element (constant);
+ if (this.run == false) {
return ;
}
- if ( this.level == 0 ) {
- ulong id = this.db_create_struct ( stru );
- if ( id == 0 ) {
- this.run = false;
- }
- }
- else {
- stru.visit_construction_methods ( this );
- stru.visit_methods ( this );
- stru.visit_fields ( this );
- stru.visit_constants ( this );
- }
+ this.file.printf ("INSERT INTO `ValadocConstants` (`id`) VALUES ((SELECT `id` FROM `ValadocElement` WHERE BINARY `fullname`='%s' LIMIT 1));\n", this.get_type_path(constant));
}
- public override void visit_error_domain ( ErrorDomain errdom ) {
- if ( this.run == false ) {
+ public override void visit_field ( Field field, FieldHandler parent ) {
+ this.write_insert_into_valadoc_element (field);
+ if (this.run == false) {
return ;
}
- if ( this.level == 0 ) {
- ulong id = this.db_create_errordomain ( errdom );
- if ( id == 0 ) {
- this.run = false;
- return ;
- }
-
- errdom.visit_error_codes ( this );
- }
- else {
- errdom.visit_methods ( this );
- }
- }
-
- public override void visit_enum ( Enum en ) {
- if ( this.run == false ) {
+ this.write_insert_into_code_element (field);
+ if (this.run == false) {
return ;
}
- if ( this.level == 0 ) {
- ulong id = this.db_create_enum ( en );
- if ( id == 0 ) {
- this.run = false;
- return ;
- }
-
- en.visit_enum_values ( this );
+ string modifier;
+ if (field.is_static) {
+ modifier = "STATIC";
}
else {
- en.visit_methods ( this );
+ modifier = "NORMAL";
}
+
+ this.file.printf ("INSERT INTO `ValadocFields` (`id`, `modifier`) VALUES ((SELECT `id` FROM `ValadocElement` WHERE BINARY `fullname`='%s' LIMIT 1), '%s');\n", this.get_type_path(field), modifier);
}
- public override void visit_property ( Property prop ) {
- if ( this.run == false ) {
+ public override void visit_error_code ( ErrorCode errcode ) {
+ this.write_insert_into_valadoc_element (errcode);
+ if (this.run == false) {
return ;
}
- if ( this.level == 1 ) {
- ulong id = this.db_create_property ( prop );
- if ( id == 0 )
- this.run = false;
- }
- }
-
- public override void visit_constant ( Constant constant, ConstantHandler parent ) {
- if ( this.run == false ) {
+ this.write_insert_into_code_element (errcode);
+ if (this.run == false) {
return ;
}
- if ( this.level == 1 ) {
- ulong id = this.db_create_constant ( constant );
- if ( id == 0 )
- this.run = false;
- }
+ this.file.printf ("INSERT INTO `ValadocErrorcodes` (`id`) VALUES ((SELECT `id` FROM `ValadocElement` WHERE BINARY `fullname`='%s' LIMIT 1));\n" , this.get_type_path(errcode));
}
- public override void visit_field ( Field field, FieldHandler parent ) {
- if ( this.run == false ) {
+ public override void visit_enum_value ( EnumValue enval ) {
+ this.write_insert_into_valadoc_element (enval);
+ if (this.run == false) {
return ;
}
- if ( this.level == 1 ) {
- ulong id = this.db_create_field ( field );
- if ( id == 0 )
- this.run = false;
- }
- }
-
- public override void visit_error_code ( ErrorCode errcode ) {
- if ( this.run == false ) {
+ this.write_insert_into_code_element (enval);
+ if (this.run == false) {
return ;
}
- if ( this.level == 0 ) {
- ulong id = this.db_create_errorcode ( errcode );
- if ( id == 0 )
- this.run = false;
- }
+ this.file.printf ("INSERT INTO `ValadocEnumvalues` (`id`) VALUES ((SELECT `id` FROM `ValadocElement` WHERE BINARY `fullname`='%s' LIMIT 1));\n", this.get_type_path(enval));
}
- public override void visit_enum_value ( EnumValue enval ) {
- if ( this.run == false ) {
+ public override void visit_delegate ( Delegate del ) {
+ this.write_insert_into_valadoc_element (del);
+ if (this.run == false) {
return ;
}
- if ( this.level == 0 ) {
- ulong id = this.db_create_enumvalue ( enval );
- if ( id == 0 )
- this.run = false;
- }
- }
-
- public override void visit_delegate ( Delegate del ) {
- if ( this.run == false ) {
+ this.write_insert_into_code_element (del);
+ if (this.run == false) {
return ;
}
- if ( this.level == 0 ) {
- ulong id = this.db_create_delegate ( del );
- if ( id == 0 )
- this.run = false;
+ string modifier;
+ if (del.is_static) {
+ modifier = "STATIC";
}
else {
- bool tmp = this.db_create_exception_list ( del );
- if ( tmp == false )
- this.run = false;
+ modifier = "NORMAL";
}
+
+ this.file.printf ("INSERT INTO `ValadocDelegates` (`id`, `modifier`) VALUES ((SELECT `id` FROM `ValadocElement` WHERE BINARY`fullname`='%s' LIMIT 1), '%s');\n", this.get_type_path(del), modifier);
}
- //TODO: exception list
public override void visit_signal ( Signal sig ) {
- if ( this.run == false ) {
+ this.write_insert_into_valadoc_element (sig);
+ if (this.run == false) {
return ;
}
- if ( this.level == 1 ) {
- ulong id = this.db_create_signal ( sig );
- if ( id == 0 )
- this.run = false;
+ this.write_insert_into_code_element (sig);
+ if (this.run == false) {
+ return ;
}
+
+ this.file.printf ("INSERT INTO `ValadocSignals` (`id`) VALUES ((SELECT `id` FROM `ValadocElement` WHERE BINARY `fullname`='%s' LIMIT 1));\n", this.get_type_path(sig));
}
public override void visit_method ( Method m, Valadoc.MethodHandler parent ) {
- if ( this.run == false ) {
+ this.write_insert_into_valadoc_element (m);
+ if (this.run == false) {
return ;
}
- if ( this.level == 1 ) {
- ulong id = this.db_create_method ( m );
- if ( id == 0 )
- this.run = false;
+ this.write_insert_into_code_element (m);
+ if (this.run == false) {
+ return ;
+ }
+
+
+ if (m.is_constructor) {
+ this.file.printf ("INSERT INTO `ValadocConstructors` (`id`) VALUES ((SELECT `id` FROM `ValadocElement` WHERE `fullname`='%s' LIMIT 1));\n", this.get_type_path(m));
}
else {
- bool tmp = this.db_create_exception_list ( m );
- if ( tmp == false )
- this.run = false;
+ string modifier;
+ if (m.is_abstract) {
+ modifier = "ABSTRACT";
+ }
+ else if (m.is_static) {
+ modifier = "STATIC";
+ }
+ else if (m.is_virtual) {
+ modifier = "VIRTUAL";
+ }
+ else {
+ modifier = "NORMAL";
+ }
+
+ this.file.printf("INSERT INTO `ValadocMethods` (`id`, `modifier`)VALUES ((SELECT `id` FROM `ValadocElement` WHERE BINARY `fullname`='%s' LIMIT 1), '%s');\n", this.get_type_path(m), modifier);
}
}
- public override void cleanups ( ) {
+ private string get_type_path (DocumentedElement element) {
+ if(element.name == null) {
+ return element.package.name;
+ }
+
+ return element.package.name+"/"+element.full_name();
}
}
-
-
[ModuleInit]
public Type register_plugin ( ) {
return typeof ( Valadoc.HtmlDoclet );
diff --git a/src/libvaladoc/apitree.vala b/src/libvaladoc/apitree.vala
index e953f7f..4c895c4 100755
--- a/src/libvaladoc/apitree.vala
+++ b/src/libvaladoc/apitree.vala
@@ -1220,7 +1220,7 @@ public interface Valadoc.ConstantHandler : Basic {
lstd.add ( c );
}
- return new Gee.ReadOnlyCollection<Type>( lstd );
+ return new Gee.ReadOnlyCollection<Constant>( lstd );
}
// internal
@@ -1303,7 +1303,7 @@ public interface Valadoc.FieldHandler : Basic {
lstd.add ( f );
}
- return new Gee.ReadOnlyCollection<Type>( lstd );
+ return new Gee.ReadOnlyCollection<Field>( lstd );
}
// internal
@@ -1537,6 +1537,10 @@ public class Valadoc.Constant : DocumentedElement, SymbolAccessibility, ReturnTy
this.set_ret_type ( vret );
}
+ public string get_cname () {
+ return this.vconst.get_cname ();
+ }
+
// internal
public void set_type_references ( ) {
((ReturnTypeHandler)this).set_return_type_references ( );
@@ -2203,7 +2207,7 @@ public class Valadoc.Method : DocumentedElement, ParameterListHandler, Exception
public Method ( Valadoc.Settings settings, Vala.Method vmethod, MethodHandler parent, Tree head ) {
this.template_param_lst = new Gee.ArrayList<TypeParameter> ();
this.param_list = new Gee.ArrayList<FormalParameter>();
- this.err_domains = new Gee.ArrayList<TypeReference>();
+ this.err_domains = new Gee.ArrayList<DocumentedElement>();
this.settings = settings;
this.vsymbol = vmethod;
@@ -2388,6 +2392,10 @@ public class Valadoc.EnumValue: DocumentedElement, Writeable {
this.head = head;
}
+ public string get_cname () {
+ return this.venval.get_cname ();
+ }
+
public bool is_venumvalue ( Vala.EnumValue venval ) {
return ( this.venval == venval );
}
@@ -2418,6 +2426,10 @@ public class Valadoc.ErrorCode : DocumentedElement, Writeable {
this.head = head;
}
+ public string get_cname () {
+ return this.verrcode.get_cname ();
+ }
+
public bool is_verrorcode ( Vala.ErrorCode verrcode ) {
return ( this.verrcode == verrcode );
}
@@ -2443,7 +2455,7 @@ public class Valadoc.Delegate : DocumentedElement, SymbolAccessibility, Visitabl
public Delegate ( Valadoc.Settings settings, Vala.Delegate vdelegate, DelegateHandler parent, Tree head ) {
this.template_param_lst = new Gee.ArrayList<TypeParameter> ();
this.param_list = new Gee.ArrayList<FormalParameter>();
- this.err_domains = new Gee.ArrayList<TypeReference>();
+ this.err_domains = new Gee.ArrayList<DocumentedElement>();
this.settings = settings;
this.vdelegate = vdelegate;
@@ -3192,6 +3204,7 @@ public class Valadoc.Enum : DocumentedElement, SymbolAccessibility, Visitable, W
private Gee.ArrayList<EnumValue> en_values;
+ // rename: get_enum_value_list
public Gee.ReadOnlyCollection<EnumValue> get_enum_values () {
return new Gee.ReadOnlyCollection<EnumValue>( this.en_values );
}
diff --git a/src/libvaladoc/parser.vala b/src/libvaladoc/parser.vala
index 944f74d..cf61627 100644
--- a/src/libvaladoc/parser.vala
+++ b/src/libvaladoc/parser.vala
@@ -851,7 +851,7 @@ public class Valadoc.Parser : Object {
return false;
}
- private bool parse_table_cell ( Documented curelement, string str, long strlen, Gee.ArrayList<DocElement> cells, ref long pos, ref long line, ref long newlinepos, bool wikimode ) {
+ private bool parse_table_cell ( Documented curelement, string str, long strlen, Gee.ArrayList<TableCellDocElement> cells, ref long pos, ref long line, ref long newlinepos, bool wikimode ) {
if ( !str.offset(pos).has_prefix("||") ) {
return false;
}
@@ -926,12 +926,12 @@ public class Valadoc.Parser : Object {
return false;
}
- private bool parse_table_row ( Documented curelement, string str, long strlen, Gee.ArrayList<Gee.ArrayList<TableCellDocElement>> rows , ref long npos, ref long nline, ref long nnewlinepos, ref long nspace, bool wikimode ) {
+ private bool parse_table_row ( Documented curelement, string str, long strlen, Gee.ArrayList<Gee.ArrayList<TableCellDocElement>> rows, ref long npos, ref long nline, ref long nnewlinepos, ref long nspace, bool wikimode ) {
if ( !str.offset(npos).has_prefix("||") ) {
return false;
}
- Gee.ArrayList<DocElement> cells = new Gee.ArrayList<DocElement> ();
+ Gee.ArrayList<TableCellDocElement> cells = new Gee.ArrayList<TableCellDocElement> ();
long newlinepos = nnewlinepos;
long space = nspace;
long line = nline;
@@ -951,7 +951,7 @@ public class Valadoc.Parser : Object {
nspace = space;
nline = line;
npos = pos;
-
+//Gee.ArrayList<Gee.ArrayList<TableCellDocElement>> rows
rows.add ( cells );
return true;
}
@@ -1319,7 +1319,9 @@ public class Valadoc.Parser : Object {
for (; str[npos]==' '||str[npos]=='\t'; npos++ );
this.parse_newline_pos (str, strlen, ref npos, ref line, ref linestartpos, wikimode);
- npos++;
+ if ( str[npos]=='*' ) {
+ npos++;
+ }
return true;
}
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]