[vala/wip/issue/607: 2/3] girparser: Set length_type for arrays instead of CCode.array_length_type
- From: Rico Tzschichholz <ricotz src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [vala/wip/issue/607: 2/3] girparser: Set length_type for arrays instead of CCode.array_length_type
- Date: Tue, 4 Jan 2022 15:24:49 +0000 (UTC)
commit 95c9673297b364406fb4c15f8ea341b73fefd1a5
Author: Rico Tzschichholz <ricotz ubuntu com>
Date: Tue Jan 4 16:20:45 2022 +0100
girparser: Set length_type for arrays instead of CCode.array_length_type
See https://gitlab.gnome.org/GNOME/vala/issues/607
vala/valagirparser.vala | 22 ++++++----------------
1 file changed, 6 insertions(+), 16 deletions(-)
---
diff --git a/vala/valagirparser.vala b/vala/valagirparser.vala
index 3babf7424..b68d9d993 100644
--- a/vala/valagirparser.vala
+++ b/vala/valagirparser.vala
@@ -1195,13 +1195,7 @@ public class Vala.GirParser : CodeVisitor {
var length_field = (Field) array_length.symbol;
// array has length
field.set_attribute_string ("CCode",
"array_length_cname", length_field.name);
- var length_type =
length_field.variable_type.to_qualified_string ();
- if (length_type != "int") {
- var st = parser.root.lookup (length_type);
- if (st != null) {
- field.set_attribute_string ("CCode",
"array_length_type", st.get_cname ());
- }
- }
+ ((ArrayType) field.variable_type).length_type =
length_field.variable_type.copy ();
field.remove_attribute_argument ("CCode",
"array_length");
field.remove_attribute_argument ("CCode",
"array_null_terminated");
}
@@ -1990,17 +1984,13 @@ public class Vala.GirParser : CodeVisitor {
void set_array_ccode (Symbol sym, ParameterInfo info) {
sym.set_attribute_double ("CCode", "array_length_pos", info.vala_idx);
+ var length_type = info.param.variable_type.copy ();
+ length_type.nullable = false;
if (sym is Parameter) {
sym.set_attribute_string ("CCode", "array_length_cname", info.param.name);
- }
- var type_name = info.param.variable_type.to_qualified_string ();
- if (type_name != "int") {
- var st = root.lookup (type_name);
- if (st != null) {
- if (sym is Callable || sym is Parameter) {
- sym.set_attribute_string ("CCode", "array_length_type", st.get_cname
());
- }
- }
+ ((ArrayType) ((Parameter) sym).variable_type).length_type = length_type;
+ } else if (sym is Callable) {
+ ((ArrayType) ((Callable) sym).return_type).length_type = length_type;
}
}
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]