[vala/staging: 14/22] libvaladoc: Clean up Api.Class constructor
- From: Rico Tzschichholz <ricotz src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [vala/staging: 14/22] libvaladoc: Clean up Api.Class constructor
- Date: Sun, 25 Nov 2018 13:09:16 +0000 (UTC)
commit 85b857c80f3089ab2dfd0be8ea0a8fa0751ae71d
Author: Rico Tzschichholz <ricotz ubuntu com>
Date: Wed Nov 14 15:18:53 2018 +0100
libvaladoc: Clean up Api.Class constructor
libvaladoc/api/class.vala | 56 ++++++++++++++++++++++++++++-------------------
valadoc/treebuilder.vala | 50 ------------------------------------------
2 files changed, 33 insertions(+), 73 deletions(-)
---
diff --git a/libvaladoc/api/class.vala b/libvaladoc/api/class.vala
index 9b0b8865d..c5712a94a 100644
--- a/libvaladoc/api/class.vala
+++ b/libvaladoc/api/class.vala
@@ -46,40 +46,50 @@ public class Valadoc.Api.Class : TypeSymbol {
private string? cname;
public Class (Node parent, SourceFile file, string name, Vala.SymbolAccessibility accessibility,
- SourceComment? comment, string? cname, string? private_cname, string?
class_macro_name,
+ SourceComment? comment,
string? type_macro_name, string? is_type_macro_name, string?
type_cast_macro_name,
- string? type_function_name, string? class_type_macro_name, string?
is_class_type_macro_name,
- string? dbus_name, string? type_id, string? param_spec_function_name,
string? ref_function_name,
- string? unref_function_name, string? free_function_name, string?
finalize_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, Vala.Class data)
+ string? type_function_name,
+ Vala.Class data)
{
+ bool is_basic_type = data.base_class == null && data.name == "string";
+
base (parent, file, name, accessibility, comment, type_macro_name,
is_type_macro_name, type_cast_macro_name, type_function_name, is_basic_type, data);
this.interfaces = new Vala.ArrayList<TypeReference> ();
- this.is_class_type_macro_name = is_class_type_macro_name;
- this.class_type_macro_name = class_type_macro_name;
- this.class_macro_name = class_macro_name;
- this.private_cname = private_cname;
- this.dbus_name = dbus_name;
- this.type_id = type_id;
- this.cname = cname;
+ if (!data.is_compact) {
+ this.is_class_type_macro_name = Vala.get_ccode_class_type_check_function (data);
+ this.class_type_macro_name = Vala.get_ccode_class_type_function (data);
+ this.class_macro_name = Vala.get_ccode_class_get_function (data);
+ this.private_cname = _get_private_cname (data);
+ }
+ this.dbus_name = Vala.GDBusModule.get_dbus_name (data);
+ this.type_id = Vala.get_ccode_type_id (data);
+ this.cname = Vala.get_ccode_name (data);
+
+ this.param_spec_function_name = Vala.get_ccode_param_spec_function (data);
- this.param_spec_function_name = param_spec_function_name;
+ this.unref_function_name = Vala.get_ccode_unref_function (data);
+ this.ref_function_name = Vala.get_ccode_ref_function (data);
+ this.finalize_function_name = (data.is_fundamental () ? "%s_finalize".printf
(Vala.get_ccode_lower_case_name (data, null)) : null);
+ this.free_function_name = (data.is_compact ? Vala.get_ccode_free_function (data) : null);
- this.unref_function_name = unref_function_name;
- this.ref_function_name = ref_function_name;
- this.finalize_function_name = finalize_function_name;
- this.free_function_name = free_function_name;
+ this.take_value_function_cname = Vala.get_ccode_take_value_function (data);
+ this.get_value_function_cname = Vala.get_ccode_get_value_function (data);
+ this.set_value_function_cname = Vala.get_ccode_set_value_function (data);
- 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 = data.is_fundamental ();
+ this.is_abstract = data.is_abstract;
+ }
+
+ string? _get_private_cname (Vala.Class element) {
+ if (element.is_compact) {
+ return null;
+ }
- this.is_fundamental = is_fundamental;
- this.is_abstract = is_abstract;
+ string? cname = Vala.get_ccode_name (element);
+ return (cname != null ? cname + "Private" : null);
}
/**
diff --git a/valadoc/treebuilder.vala b/valadoc/treebuilder.vala
index 5118b1a00..f4f25db53 100644
--- a/valadoc/treebuilder.vala
+++ b/valadoc/treebuilder.vala
@@ -278,41 +278,11 @@ public class Valadoc.Drivers.TreeBuilder : Vala.CodeVisitor {
return Vala.get_ccode_upper_case_name (element, null);
}
- private string? get_private_cname (Vala.Class element) {
- if (element.is_compact) {
- return null;
- }
-
- string? cname = Vala.get_ccode_name (element);
- return (cname != null)? cname + "Private" : null;
- }
-
- private string? get_class_macro_name (Vala.Class element) {
- if (element.is_compact) {
- return null;
- }
-
- return "%s_GET_CLASS".printf (Vala.get_ccode_upper_case_name (element, null));
- }
-
- private string? get_class_type_macro_name (Vala.Class element) {
- if (element.is_compact) {
- return null;
- }
-
- return "%s_CLASS".printf (Vala.get_ccode_upper_case_name (element, null));
- }
-
private string? get_is_type_macro_name (Vala.TypeSymbol element) {
string? name = Vala.get_ccode_type_check_function (element);
return (name != null && name != "")? name : null;
}
- private string? get_is_class_type_macro_name (Vala.TypeSymbol element) {
- string? name = get_is_type_macro_name (element);
- return (name != null)? name + "_CLASS" : null;
- }
-
private string? get_type_function_name (Vala.TypeSymbol element) {
if ((element is Vala.Class
&& ((Vala.Class) element).is_compact)
@@ -674,35 +644,15 @@ public class Valadoc.Drivers.TreeBuilder : Vala.CodeVisitor {
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,
element.access,
comment,
- Vala.get_ccode_name (element),
- get_private_cname (element),
- get_class_macro_name (element),
get_type_macro_name (element),
get_is_type_macro_name (element),
get_type_cast_macro_name (element),
get_type_function_name (element),
- get_class_type_macro_name (element),
- get_is_class_type_macro_name (element),
- Vala.GDBusModule.get_dbus_name (element),
- Vala.get_ccode_type_id (element),
- Vala.get_ccode_param_spec_function (element),
- Vala.get_ccode_ref_function (element),
- Vala.get_ccode_unref_function (element),
- (element.is_compact ?
Vala.get_ccode_free_function (element) : null),
- (element.is_fundamental () ?
"%s_finalize".printf (Vala.get_ccode_lower_case_name (element, null)) : null),
- Vala.get_ccode_take_value_function (element),
- Vala.get_ccode_get_value_function (element),
- Vala.get_ccode_set_value_function (element),
- element.is_fundamental (),
- element.is_abstract,
- is_basic_type,
element);
symbol_map.set (element, node);
parent.add_child (node);
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]