From: Rico Tzschichholz Date: Sun, 29 Mar 2020 12:30:49 +0000 (+0200) Subject: vala: Handle all ctors and dtors in CodeWriter X-Git-Tag: 0.49.1~214 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=dfc814c0ecd1340d6f53c62a44510980bdd90f80;p=thirdparty%2Fvala.git vala: Handle all ctors and dtors in CodeWriter --- diff --git a/vala/valacodewriter.vala b/vala/valacodewriter.vala index f98b26fc5..28ad9fd34 100644 --- a/vala/valacodewriter.vala +++ b/vala/valacodewriter.vala @@ -287,6 +287,26 @@ public class Vala.CodeWriter : CodeVisitor { cl.constructor.accept (this); } + if (cl.class_constructor != null) { + cl.class_constructor.accept (this); + } + + if (cl.static_constructor != null) { + cl.static_constructor.accept (this); + } + + if (cl.destructor != null) { + cl.destructor.accept (this); + } + + if (cl.static_destructor != null) { + cl.static_destructor.accept (this); + } + + if (cl.class_destructor != null) { + cl.class_destructor.accept (this); + } + current_scope = current_scope.parent_scope; write_end_block (); @@ -730,11 +750,39 @@ public class Vala.CodeWriter : CodeVisitor { } write_indent (); + if (c.binding == MemberBinding.STATIC) { + write_string ("static "); + } else if (c.binding == MemberBinding.CLASS) { + write_string ("class "); + } write_string ("construct"); write_code_block (c.body); write_newline (); } + public override void visit_destructor (Destructor d) { + if (type != CodeWriterType.DUMP) { + return; + } + + if (context.vapi_comments && d.comment != null) { + write_comment (d.comment); + } + + write_indent (); + if (d.binding == MemberBinding.STATIC) { + write_string ("static "); + } else if (d.binding == MemberBinding.CLASS) { + write_string ("class "); + } + write_string ("~"); + var datatype = (TypeSymbol) d.parent_symbol; + write_identifier (datatype.name); + write_string (" () "); + write_code_block (d.body); + write_newline (); + } + public override void visit_method (Method m) { if (m.external_package) { return;