]> git.ipfire.org Git - thirdparty/vala.git/commitdiff
vala: Handle all ctors and dtors in CodeWriter
authorRico Tzschichholz <ricotz@ubuntu.com>
Sun, 29 Mar 2020 12:30:49 +0000 (14:30 +0200)
committerRico Tzschichholz <ricotz@ubuntu.com>
Mon, 20 Apr 2020 19:11:15 +0000 (21:11 +0200)
vala/valacodewriter.vala

index 238a74c36cf459d9df604b1f6b944290bd0e4c78..da6103033e262f8708d689a629820757898d9906 100644 (file)
@@ -283,6 +283,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 ();
@@ -725,11 +745,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;