]> git.ipfire.org Git - thirdparty/vala.git/commitdiff
codewriter: Output bodies of code-blocks if in VAPIGEN mode
authorRico Tzschichholz <ricotz@ubuntu.com>
Thu, 5 Jul 2018 05:47:10 +0000 (07:47 +0200)
committerRico Tzschichholz <ricotz@ubuntu.com>
Thu, 5 Jul 2018 10:42:00 +0000 (12:42 +0200)
Fixes https://gitlab.gnome.org/GNOME/vala/issues/231

vala/valacodewriter.vala
vapigen/valavapigen.vala

index 4535f88739bb2cec47cde1bce648d65d0d4ec379..985a23182642d97e27657c88e4227b5b81a9f480 100644 (file)
@@ -290,7 +290,7 @@ public class Vala.CodeWriter : CodeVisitor {
        }
 
        void visit_sorted (List<Symbol> symbols) {
-               if (type != CodeWriterType.EXTERNAL) {
+               if (type != CodeWriterType.EXTERNAL && type != CodeWriterType.VAPIGEN) {
                        // order of virtual methods matters for fast vapis
                        foreach (Symbol sym in symbols) {
                                sym.accept (this);
@@ -1590,7 +1590,7 @@ public class Vala.CodeWriter : CodeVisitor {
        }
 
        void write_code_block (Block? block) {
-               if (block == null || type != CodeWriterType.DUMP) {
+               if (block == null || (type != CodeWriterType.DUMP && type != CodeWriterType.VAPIGEN)) {
                        write_string (";");
                        return;
                }
@@ -1618,6 +1618,7 @@ public class Vala.CodeWriter : CodeVisitor {
        private bool check_accessibility (Symbol sym) {
                switch (type) {
                case CodeWriterType.EXTERNAL:
+               case CodeWriterType.VAPIGEN:
                        return sym.access == SymbolAccessibility.PUBLIC ||
                               sym.access == SymbolAccessibility.PROTECTED;
 
@@ -1732,7 +1733,7 @@ public class Vala.CodeWriter : CodeVisitor {
                        write_string ("private ");
                }
 
-               if (type != CodeWriterType.EXTERNAL && sym.external && !sym.external_package) {
+               if (type != CodeWriterType.EXTERNAL && type != CodeWriterType.VAPIGEN && sym.external && !sym.external_package) {
                        write_string ("extern ");
                }
        }
@@ -1768,5 +1769,6 @@ public enum Vala.CodeWriterType {
        EXTERNAL,
        INTERNAL,
        FAST,
-       DUMP
+       DUMP,
+       VAPIGEN
 }
index e68523cb2edaa3ef70b37a85e65773ea8ca6871e..616efdf292c9e7c5691cf8b5be53053118ce3271 100644 (file)
@@ -191,7 +191,7 @@ class Vala.VAPIGen {
                        }
                }
 
-               var interface_writer = new CodeWriter ();
+               var interface_writer = new CodeWriter (CodeWriterType.VAPIGEN);
                var vapi_filename = "%s.vapi".printf (library);
                if (directory != null) {
                        vapi_filename = Path.build_path ("/", directory, vapi_filename);