[vala/0.36] girwriter: Write implicit fields for arrays and delegates
- From: Rico Tzschichholz <ricotz src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [vala/0.36] girwriter: Write implicit fields for arrays and delegates
- Date: Tue, 13 Aug 2019 15:20:14 +0000 (UTC)
commit 9070aa92c34efc742c25b465f06975b4c77e0d60
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 7c843e6af..25800212e 100644
--- a/codegen/valagirwriter.vala
+++ b/codegen/valagirwriter.vala
@@ -939,6 +939,50 @@ public class Vala.GIRWriter : CodeVisitor {
indent--;
write_indent ();
buffer.append_printf ("</field>\n");
+
+ if (f.variable_type is ArrayType && CCodeBaseModule.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\"",
CCodeBaseModule.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\"",
CCodeBaseModule.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 (CCodeBaseModule.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]