]> git.ipfire.org Git - thirdparty/vala.git/commitdiff
codegen: Add public/private separator comments to type/instance structs
authorRico Tzschichholz <ricotz@ubuntu.com>
Wed, 17 Jan 2018 12:09:06 +0000 (13:09 +0100)
committerRico Tzschichholz <ricotz@ubuntu.com>
Thu, 12 Jul 2018 07:26:20 +0000 (09:26 +0200)
See https://gitlab.gnome.org/GNOME/vala/issues/598

codegen/valagtypemodule.vala

index 9227260e029a0f0317bcb28301f064b1581c117b..91f96d1c030dfbf89cc33a5b4cde85c6a4c3dd29 100644 (file)
@@ -222,6 +222,11 @@ public class Vala.GTypeModule : GErrorModule {
                        instance_struct.add_field ("volatile int", "ref_count");
                }
 
+               if (context.abi_stability) {
+                       // add "/*< public >*/" separator
+                       instance_struct.add_comment ("< public >");
+               }
+
                if (is_gtypeinstance) {
                        decl_space.add_type_declaration (new CCodeTypeDefinition ("struct %sPrivate".printf (instance_struct.name), new CCodeVariableDeclarator ("%sPrivate".printf (get_ccode_name (cl)))));
 
@@ -234,6 +239,11 @@ public class Vala.GTypeModule : GErrorModule {
                                type_struct.add_field ("%sClass".printf (get_ccode_name (cl.base_class)), "parent_class");
                        }
 
+                       if (context.abi_stability) {
+                               // add "/*< public >*/" separator
+                               type_struct.add_comment ("< public >");
+                       }
+
                        if (is_fundamental) {
                                type_struct.add_field ("void", "(*finalize) (%s *self)".printf (get_ccode_name (cl)));
                        }
@@ -280,6 +290,12 @@ public class Vala.GTypeModule : GErrorModule {
                        }
                }
 
+               if (context.abi_stability) {
+                       // add "/*< private >*/" separator
+                       instance_struct.add_comment ("< private >");
+                       type_struct.add_comment ("< private >");
+               }
+
                if (cl.is_compact && cl.base_class == null && !has_struct_member) {
                        // add dummy member, C doesn't allow empty structs
                        instance_struct.add_field ("int", "dummy");
@@ -2094,6 +2110,11 @@ public class Vala.GTypeModule : GErrorModule {
 
                type_struct.add_field ("GTypeInterface", "parent_iface");
 
+               if (context.abi_stability) {
+                       // add "/*< public >*/" separator
+                       type_struct.add_comment ("< public >");
+               }
+
                if (iface.get_attribute ("GenericAccessors") != null) {
                        foreach (TypeParameter p in iface.get_type_parameters ()) {
                                string method_name = "get_%s_type".printf (p.name.down ());
@@ -2195,6 +2216,11 @@ public class Vala.GTypeModule : GErrorModule {
                        }
                }
 
+               if (context.abi_stability) {
+                       // add "/*< private >*/" separator
+                       type_struct.add_comment ("< private >");
+               }
+
                decl_space.add_type_definition (type_struct);
 
                var type_fun = new InterfaceRegisterFunction (iface);