[vala/0.40] girwriter: Write implicit fields for arrays and delegates
- From: Rico Tzschichholz <ricotz src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [vala/0.40] girwriter: Write implicit fields for arrays and delegates
- Date: Mon, 5 Aug 2019 11:38:55 +0000 (UTC)
commit ba1bf95a57423163a399b874024db6d3c317a195
Author: Rico Tzschichholz <ricotz ubuntu com>
Date: Fri May 3 15:32:04 2019 +0200
girwriter: Write implicit fields for arrays and delegates
codegen/valagirwriter.vala | 44 ++++++++++++++++++++++++++++++++++++++++++++
1 file changed, 44 insertions(+)
---
diff --git a/codegen/valagirwriter.vala b/codegen/valagirwriter.vala
index b6eb20625..597ecaa3d 100644
--- a/codegen/valagirwriter.vala
+++ b/codegen/valagirwriter.vala
@@ -942,6 +942,50 @@ public class Vala.GIRWriter : CodeVisitor {
indent--;
write_indent ();
buffer.append_printf ("</field>\n");
+
+ if (f.variable_type is ArrayType && get_ccode_array_length (f)) {
+ var array_type = (ArrayType) f.variable_type;
+ if (!array_type.fixed_length) {
+ var int_type = new IntegerType (context.root.scope.lookup ("int") as Struct);
+ for (var i = 0; i < array_type.rank; i++) {
+ write_indent ();
+ buffer.append_printf ("<field name=\"%s_length%i\"", get_ccode_name
(f), i + 1);
+ write_symbol_attributes (f);
+ buffer.append_printf (">\n");
+ indent++;
+ write_type (int_type);
+ indent--;
+ write_indent ();
+ buffer.append_printf ("</field>\n");
+ }
+ }
+ } else if (f.variable_type is DelegateType) {
+ var deleg_type = (DelegateType) f.variable_type;
+ if (deleg_type.delegate_symbol.has_target) {
+ write_indent ();
+ buffer.append_printf ("<field name=\"%s\"", get_ccode_delegate_target_name
(f));
+ write_symbol_attributes (f);
+ buffer.append_printf (">\n");
+ indent++;
+ write_indent ();
+ buffer.append_printf ("<type name=\"gpointer\" c:type=\"gpointer\"/>\n");
+ indent--;
+ write_indent ();
+ buffer.append_printf ("</field>\n");
+ if (deleg_type.is_disposable ()) {
+ write_indent ();
+ buffer.append_printf ("<field name=\"%s\"", ((CCodeBaseModule)
context.codegen).get_delegate_target_destroy_notify_cname (get_ccode_name (f)));
+ write_symbol_attributes (f);
+ buffer.append_printf (">\n");
+ indent++;
+ write_indent ();
+ buffer.append_printf ("<type name=\"GLib.DestroyNotify\"
c:type=\"GDestroyNotify\"/>\n");
+ indent--;
+ write_indent ();
+ buffer.append_printf ("</field>\n");
+ }
+ }
+ }
}
private void write_implicit_params (DataType? type, ref int index, bool has_array_length, string?
name, ParameterDirection direction) {
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]